added ui_layout_fill (WPF)

Sun, 01 Feb 2015 12:37:31 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 01 Feb 2015 12:37:31 +0100
changeset 85
91f45354d1e2
parent 84
a56c2baa9429
child 86
3c63f57a8f77

added ui_layout_fill (WPF)

application/main.c file | annotate | diff | comparison | revisions
ui/wpf/UIcore/Container.cs file | annotate | diff | comparison | revisions
ui/wpf/UIcore/Window.cs file | annotate | diff | comparison | revisions
ui/wpf/UIwrapper/UIwrapper/container.cpp file | annotate | diff | comparison | revisions
ui/wpf/container.c file | annotate | diff | comparison | revisions
ui/wpf/container.h file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Feb 01 10:35:07 2015 +0100
+++ b/application/main.c	Sun Feb 01 12:37:31 2015 +0100
@@ -117,9 +117,12 @@
     ui_menuitem("item4", NULL, NULL);
     
     UiObject *obj = ui_window("Test", NULL);
+    ui_layout_fill(obj, FALSE);
     ui_hbox(obj);
     ui_button(obj, "HELLO", NULL, NULL);
     ui_button(obj, "WORLD", NULL, NULL);
+    ui_layout_fill(obj, TRUE);
+    ui_button(obj, "BUTTON", NULL, NULL);
     ui_end(obj);
     ui_button(obj, "Test1", action_button, NULL);
     ui_button(obj, "Test2", action_button, NULL);
--- a/ui/wpf/UIcore/Container.cs	Sun Feb 01 10:35:07 2015 +0100
+++ b/ui/wpf/UIcore/Container.cs	Sun Feb 01 12:37:31 2015 +0100
@@ -10,9 +10,36 @@
 {
     public interface Container
     {
+        Layout Layout { get; set; }
+        
         void Add(UIElement control, bool fill);
     }
 
+    public class Layout
+    {
+        public bool? Fill { get; set; }
+
+        public Layout()
+        {
+            Fill = null;
+        }
+
+        public bool IsFill(bool fill)
+        {
+            if (Fill != null)
+            {
+                
+                return (bool)Fill;
+            }
+            return fill;
+        }
+
+        public void Reset()
+        {
+            Fill = null;
+        }
+    }
+
     public enum BoxOrientation
     {
         VERTICAL,
@@ -21,7 +48,9 @@
 
     public class BoxContainer : Grid, Container
     {
-        public BoxOrientation Orientation;
+        public Layout Layout { get; set; }
+        
+        private BoxOrientation Orientation;
 
         private int x = 0;
         private int y = 0;
@@ -30,6 +59,8 @@
 
         public BoxContainer(BoxOrientation orientation) : base()
         {
+            Layout = new Layout();
+            
             Orientation = orientation;
             if(Orientation == BoxOrientation.HORIZONTAL)
             {
@@ -52,6 +83,8 @@
         
         public void Add(UIElement control, bool fill)
         {
+            fill = Layout.IsFill(fill);
+            
             if(Orientation == BoxOrientation.HORIZONTAL)
             {
                 ColumnDefinition col = new ColumnDefinition();
@@ -103,6 +136,8 @@
             {
                 y++;
             }
+
+            Layout.Reset();
         }
 
         public static BoxContainer CreateBoxContainer(Container parent, BoxOrientation orientation)
@@ -113,6 +148,8 @@
     
     public class GridContainer : Container
     {
+        public Layout Layout { get; set; }
+        
         public Grid Grid;
 
         public GridContainer(System.Windows.Controls.Grid grid)
--- a/ui/wpf/UIcore/Window.cs	Sun Feb 01 10:35:07 2015 +0100
+++ b/ui/wpf/UIcore/Window.cs	Sun Feb 01 12:37:31 2015 +0100
@@ -11,6 +11,18 @@
 {
     public class MainWindow : Window, Container
     {
+        public Layout Layout
+        {
+            get
+            {
+                return Container.Layout;
+            }
+            set
+            {
+                Container.Layout = value;
+            }
+        }
+        
         public IntPtr Object;
         public Container Container;
         
--- a/ui/wpf/UIwrapper/UIwrapper/container.cpp	Sun Feb 01 10:35:07 2015 +0100
+++ b/ui/wpf/UIwrapper/UIwrapper/container.cpp	Sun Feb 01 12:37:31 2015 +0100
@@ -20,3 +20,12 @@
 	*container = hbox;
 	return container;
 }
+
+
+
+/* ------------------- layout functions ------------------- */
+
+UI_EXPORT void __stdcall UIlayout_fill(gcroot<UI::Container^> *container, int fill) {
+	UI::Container ^ct = *container;
+	ct->Layout->Fill = fill;
+}
--- a/ui/wpf/container.c	Sun Feb 01 10:35:07 2015 +0100
+++ b/ui/wpf/container.c	Sun Feb 01 12:37:31 2015 +0100
@@ -28,3 +28,20 @@
     return hbox;
 }
 
+
+/*
+ * -------------------- Layout Functions --------------------
+ * 
+ * functions for setting layout attributes for the current container
+ *
+ */
+
+void ui_layout_fill(UiObject *obj, UiBool fill) {
+    UiContainer *ct = uic_get_current_container(obj);
+    UIlayout_fill(ct, fill);
+}
+
+void ui_newline(UiObject *obj) {
+    UiContainer *ct = uic_get_current_container(obj);
+    
+}
\ No newline at end of file
--- a/ui/wpf/container.h	Sun Feb 01 10:35:07 2015 +0100
+++ b/ui/wpf/container.h	Sun Feb 01 12:37:31 2015 +0100
@@ -18,6 +18,8 @@
 UI_IMPORT void* __stdcall UIhbox(UiContainer *parent);
 
 
+UI_IMPORT void __stdcall UIlayout_fill(UiContainer *container, int fill);
+
 #ifdef	__cplusplus
 }
 #endif

mercurial