You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/05/28 02:28:10 UTC

svn commit: r779366 - in /incubator/pivot/trunk: tutorials/src/pivot/tutorials/navigation/ wtk/src/pivot/wtk/ wtk/src/pivot/wtk/skin/ wtk/test/pivot/wtk/test/

Author: gbrown
Date: Thu May 28 00:28:10 2009
New Revision: 779366

URL: http://svn.apache.org/viewvc?rev=779366&view=rev
Log:
Add Panel class for absolutely positioning components; add Panel tutorial and test code.

Added:
    incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/Panels.java
    incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/panels.wtkx
    incubator/pivot/trunk/wtk/src/pivot/wtk/Panel.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/PanelSkin.java
    incubator/pivot/trunk/wtk/test/pivot/wtk/test/panel_test.wtkx
Modified:
    incubator/pivot/trunk/wtk/src/pivot/wtk/Component.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/Theme.java

Added: incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/Panels.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/Panels.java?rev=779366&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/Panels.java (added)
+++ incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/Panels.java Thu May 28 00:28:10 2009
@@ -0,0 +1,36 @@
+package pivot.tutorials.navigation;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.DesktopApplicationContext;
+import pivot.wtk.Display;
+import pivot.wtk.Window;
+import pivot.wtkx.Bindable;
+
+public class Panels extends Bindable implements Application {
+    @Load(resourceName="panels.wtkx") private Window window;
+
+    public void startup(Display display, Dictionary<String, String> properties)
+        throws Exception {
+        bind();
+        window.open(display);
+    }
+
+    public boolean shutdown(boolean optional) {
+        if (window != null) {
+            window.close();
+        }
+
+        return true;
+    }
+
+    public void suspend() {
+    }
+
+    public void resume() {
+    }
+
+    public static void main(String[] args) {
+        DesktopApplicationContext.main(Panels.class, args);
+    }
+}

Added: incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/panels.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/panels.wtkx?rev=779366&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/panels.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/pivot/tutorials/navigation/panels.wtkx Thu May 28 00:28:10 2009
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="Panels" maximized="true"
+    xmlns:wtkx="http://incubator.apache.org/pivot/wtkx/1.1"
+    xmlns="pivot.wtk"
+    xmlns:media="pivot.wtk.media"
+    xmlns:drawing="pivot.wtk.media.drawing">
+    <content>
+        <StackPane>
+            <ImageView styles="{horizontalAlignment:'left', verticalAlignment:'top'}">
+                <image>
+                    <media:Drawing width="400" height="320">
+                        <canvas>
+                            <drawing:Canvas>
+                                <drawing:Rectangle x="20" y="20" width="320" height="240"
+                                    fill="{paintType:'gradient', startX:0, startY:0, startColor:'#4444ff',
+                                        endX:320, endY:240, endColor:'#000044'}"
+                                    stroke="#0000aa" strokeThickness="4"
+                                    cornerRadius="10"/>
+                            </drawing:Canvas>
+                        </canvas>
+                    </media:Drawing>
+                </image>
+            </ImageView>
+            <Panel>
+                <PushButton buttonData="Button 1"
+                    styles="{color:'#ffffff', backgroundColor:'#000066', borderColor:'#0000dd'}"
+                    x="30" y="30" width="120" height="24"/>
+                <PushButton buttonData="Button 2"
+                    styles="{color:'#ffffff', backgroundColor:'#000066', borderColor:'#0000dd'}"
+                    x="30" y="60" width="120" height="24"/>
+                <PushButton buttonData="Button 3"
+                    styles="{color:'#ffffff', backgroundColor:'#000066', borderColor:'#0000dd'}"
+                    x="30" y="90" width="120" height="24"/>
+            </Panel>
+        </StackPane>
+    </content>
+</Window>

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/Component.java?rev=779366&r1=779365&r2=779366&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/Component.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/Component.java Thu May 28 00:28:10 2009
@@ -763,10 +763,18 @@
         return skin.getWidth();
     }
 
+    public void setWidth(int width) {
+        setSize(width, getHeight());
+    }
+
     public int getHeight() {
         return skin.getHeight();
     }
 
+    public void setHeight(int height) {
+        setSize(getWidth(), height);
+    }
+
     public Dimensions getSize() {
         return new Dimensions(this.getWidth(), this.getHeight());
     }

Added: incubator/pivot/trunk/wtk/src/pivot/wtk/Panel.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/Panel.java?rev=779366&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/Panel.java (added)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/Panel.java Thu May 28 00:28:10 2009
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk;
+
+/**
+ * Simple container that performs no layout.
+ *
+ * @author gbrown
+ */
+public class Panel extends Container {
+    public Panel() {
+        installSkin(Panel.class);
+    }
+}

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/Theme.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/Theme.java?rev=779366&r1=779365&r2=779366&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/Theme.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/Theme.java Thu May 28 00:28:10 2009
@@ -29,6 +29,7 @@
 import pivot.wtk.skin.ImageViewSkin;
 import pivot.wtk.skin.LabelSkin;
 import pivot.wtk.skin.MovieViewSkin;
+import pivot.wtk.skin.PanelSkin;
 import pivot.wtk.skin.ScrollPaneSkin;
 import pivot.wtk.skin.SeparatorSkin;
 import pivot.wtk.skin.StackPaneSkin;
@@ -73,6 +74,7 @@
         componentSkinMap.put(ImageView.class, ImageViewSkin.class);
         componentSkinMap.put(Label.class, LabelSkin.class);
         componentSkinMap.put(MovieView.class, MovieViewSkin.class);
+        componentSkinMap.put(Panel.class, PanelSkin.class);
         componentSkinMap.put(ScrollPane.class, ScrollPaneSkin.class);
         componentSkinMap.put(Separator.class, SeparatorSkin.class);
         componentSkinMap.put(StackPane.class, StackPaneSkin.class);

Added: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/PanelSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/PanelSkin.java?rev=779366&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/PanelSkin.java (added)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/PanelSkin.java Thu May 28 00:28:10 2009
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin;
+
+/**
+ * Panel skin.
+ *
+ * @author gbrown
+ */
+public class PanelSkin extends ContainerSkin {
+    public void layout() {
+        // No-op
+    }
+}

Added: incubator/pivot/trunk/wtk/test/pivot/wtk/test/panel_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/test/panel_test.wtkx?rev=779366&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/test/panel_test.wtkx (added)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/test/panel_test.wtkx Thu May 28 00:28:10 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Panel styles="{backgroundColor:'#aacccc'}"
+    preferredWidth="640" preferredHeight="480"
+    xmlns:wtkx="http://incubator.apache.org/pivot/wtkx/1.1"
+    xmlns="pivot.wtk">
+    <PushButton buttonData="Push Button"
+        x="100" y="20" width="120" height="40"/>
+</Panel>