added vbox,hbox function (WPF)

Sun, 01 Feb 2015 10:35:07 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 01 Feb 2015 10:35:07 +0100
changeset 84
a56c2baa9429
parent 83
a38aec91bd66
child 85
91f45354d1e2

added vbox,hbox function (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.v12.suo file | annotate | diff | comparison | revisions
ui/wpf/UIwrapper/UIwrapper/UIwrapper.vcxproj file | annotate | diff | comparison | revisions
ui/wpf/UIwrapper/UIwrapper/UIwrapper.vcxproj.filters file | annotate | diff | comparison | revisions
ui/wpf/UIwrapper/UIwrapper/container.cpp file | annotate | diff | comparison | revisions
ui/wpf/UIwrapper/UIwrapper/container.h file | annotate | diff | comparison | revisions
ui/wpf/container.c file | annotate | diff | comparison | revisions
ui/wpf/container.h file | annotate | diff | comparison | revisions
ui/wpf/objs.mk file | annotate | diff | comparison | revisions
--- a/application/main.c	Sat Jan 31 11:51:54 2015 +0100
+++ b/application/main.c	Sun Feb 01 10:35:07 2015 +0100
@@ -117,11 +117,16 @@
     ui_menuitem("item4", NULL, NULL);
     
     UiObject *obj = ui_window("Test", NULL);
+    ui_hbox(obj);
+    ui_button(obj, "HELLO", NULL, NULL);
+    ui_button(obj, "WORLD", NULL, NULL);
+    ui_end(obj);
     ui_button(obj, "Test1", action_button, NULL);
     ui_button(obj, "Test2", action_button, NULL);
     ui_button(obj, "Test3", action_button, NULL);
     ui_button(obj, "Test4", action_button, NULL);
     ui_show(obj);
+    fflush(stdout);
     ui_main();
     /*
 	ui_locales_dir("/opt/app1/locales");
--- a/ui/wpf/UIcore/Container.cs	Sat Jan 31 11:51:54 2015 +0100
+++ b/ui/wpf/UIcore/Container.cs	Sun Feb 01 10:35:07 2015 +0100
@@ -19,9 +19,8 @@
         HORIZONTAL
     }
 
-    public class BoxContainer : Container
+    public class BoxContainer : Grid, Container
     {
-        public Grid Grid;
         public BoxOrientation Orientation;
 
         private int x = 0;
@@ -29,23 +28,27 @@
 
         private bool filled = false;
 
-        public BoxContainer(Grid grid, BoxOrientation orientation)
+        public BoxContainer(BoxOrientation orientation) : base()
         {
-            Grid = grid;
             Orientation = orientation;
             if(Orientation == BoxOrientation.HORIZONTAL)
             {
                 RowDefinition row = new RowDefinition();
                 row.Height = new GridLength(1, GridUnitType.Star);
-                Grid.RowDefinitions.Add(row);
+                RowDefinitions.Add(row);
             }
             else
             {
                 ColumnDefinition col = new ColumnDefinition();
                 col.Width = new GridLength(1, GridUnitType.Star);
-                Grid.ColumnDefinitions.Add(col);
+                ColumnDefinitions.Add(col);
             }
         }
+
+        public BoxContainer(Container parent, BoxOrientation orientation) : this(orientation)
+        {
+            parent.Add(this, true);
+        }
         
         public void Add(UIElement control, bool fill)
         {
@@ -66,7 +69,7 @@
                 {
                     col.Width = GridLength.Auto;
                 }
-                Grid.ColumnDefinitions.Add(col);
+                ColumnDefinitions.Add(col);
             }
             else
             {
@@ -85,12 +88,12 @@
                 {
                     row.Height = GridLength.Auto;
                 }
-                Grid.RowDefinitions.Add(row);
+                RowDefinitions.Add(row);
             }
 
             Grid.SetColumn(control, x);
             Grid.SetRow(control, y);
-            Grid.Children.Add(control);
+            Children.Add(control);
 
             if(Orientation == BoxOrientation.HORIZONTAL)
             {
@@ -101,6 +104,11 @@
                 y++;
             }
         }
+
+        public static BoxContainer CreateBoxContainer(Container parent, BoxOrientation orientation)
+        {
+            return Application.GetInstance().Exec<BoxContainer>(() => new BoxContainer(parent, orientation));
+        }
     }
     
     public class GridContainer : Container
--- a/ui/wpf/UIcore/Window.cs	Sat Jan 31 11:51:54 2015 +0100
+++ b/ui/wpf/UIcore/Window.cs	Sun Feb 01 10:35:07 2015 +0100
@@ -25,13 +25,12 @@
             ColumnDefinition column = new ColumnDefinition();
             column.Width = new GridLength(1, GridUnitType.Star);
             windowGrid.ColumnDefinitions.Add(column);
-
-            AddChild(windowGrid);
+            this.AddChild(windowGrid);
             int rowIndex = 0;
 
             // menu
             Application app = Application.GetInstance();
-            if (!app.AppMenu.IsEmpty())
+            if (!app.AppMenu.IsEmpty() && false)
             {
                 System.Windows.Controls.Menu menu = app.AppMenu.CreateMenu(uiobj);
 
@@ -51,13 +50,13 @@
             RowDefinition contentRow = new RowDefinition();
             contentRow.Height = new GridLength(1, GridUnitType.Star);
             windowGrid.RowDefinitions.Add(contentRow);
-            Grid content = new Grid();
-            Grid.SetColumn(content, 0);
-            Grid.SetRow(content, rowIndex);
-            windowGrid.Children.Add(content);
+            BoxContainer vbox = new BoxContainer(BoxOrientation.VERTICAL);
+            Grid.SetColumn(vbox, 0);
+            Grid.SetRow(vbox, rowIndex);
+            windowGrid.Children.Add(vbox);
             rowIndex++;
 
-            Container = new BoxContainer(content, BoxOrientation.VERTICAL);
+            Container = vbox;
 
             Closed += CloseEvent;
         }
Binary file ui/wpf/UIwrapper/UIwrapper.v12.suo has changed
--- a/ui/wpf/UIwrapper/UIwrapper/UIwrapper.vcxproj	Sat Jan 31 11:51:54 2015 +0100
+++ b/ui/wpf/UIwrapper/UIwrapper/UIwrapper.vcxproj	Sun Feb 01 10:35:07 2015 +0100
@@ -152,6 +152,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="controls.h" />
+    <ClInclude Include="container.h" />
     <ClInclude Include="menu.h" />
     <ClInclude Include="resource.h" />
     <ClInclude Include="Stdafx.h" />
@@ -162,6 +163,7 @@
     <ClCompile Include="AssemblyInfo.cpp" />
     <ClCompile Include="controls.cpp" />
     <ClCompile Include="menu.cpp" />
+    <ClCompile Include="container.cpp" />
     <ClCompile Include="window.cpp" />
     <ClCompile Include="Stdafx.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
--- a/ui/wpf/UIwrapper/UIwrapper/UIwrapper.vcxproj.filters	Sat Jan 31 11:51:54 2015 +0100
+++ b/ui/wpf/UIwrapper/UIwrapper/UIwrapper.vcxproj.filters	Sun Feb 01 10:35:07 2015 +0100
@@ -33,6 +33,9 @@
     <ClInclude Include="controls.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
+    <ClInclude Include="container.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="AssemblyInfo.cpp">
@@ -53,6 +56,9 @@
     <ClCompile Include="controls.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
+    <ClCompile Include="container.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Text Include="ReadMe.txt" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/wpf/UIwrapper/UIwrapper/container.cpp	Sun Feb 01 10:35:07 2015 +0100
@@ -0,0 +1,22 @@
+
+
+#include "stdafx.h"
+#include <stdio.h>
+
+#include "container.h"
+
+#using "UIcore.dll"
+
+UI_EXPORT void* __stdcall UIvbox(gcroot<UI::Container^> *parent) {
+	UI::BoxContainer ^vbox = UI::BoxContainer::CreateBoxContainer(*parent, UI::BoxOrientation::VERTICAL);
+	gcroot<UI::BoxContainer^> *container = new gcroot<UI::BoxContainer^>();
+	*container = vbox;
+	return container;
+}
+
+UI_EXPORT void* __stdcall UIhbox(gcroot<UI::Container^> *parent) {
+	UI::BoxContainer ^hbox = UI::BoxContainer::CreateBoxContainer(*parent, UI::BoxOrientation::HORIZONTAL);
+	gcroot<UI::BoxContainer^> *container = new gcroot<UI::BoxContainer^>();
+	*container = hbox;
+	return container;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/wpf/UIwrapper/UIwrapper/container.h	Sun Feb 01 10:35:07 2015 +0100
@@ -0,0 +1,5 @@
+
+
+#pragma once
+
+#include "toolkit.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/wpf/container.c	Sun Feb 01 10:35:07 2015 +0100
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "container.h"
+#include "../common/object.h"
+
+UIWIDGET ui_vbox(UiObject *obj) {
+    UiContainer *ct = uic_get_current_container(obj);
+    
+    UIWIDGET *vbox = UIvbox(ct);
+    
+    UiObject *newobj = uic_object_new(obj, vbox);
+    newobj->container = (UiContainer*)vbox;
+    uic_obj_add(obj, newobj);
+    
+    return vbox;
+}
+
+UIWIDGET ui_hbox(UiObject *obj) {
+    UiContainer *ct = uic_get_current_container(obj);
+    
+    UIWIDGET *hbox = UIhbox(ct);
+    
+    UiObject *newobj = uic_object_new(obj, hbox);
+    newobj->container = (UiContainer*)hbox;
+    uic_obj_add(obj, newobj);
+    
+    return hbox;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/wpf/container.h	Sun Feb 01 10:35:07 2015 +0100
@@ -0,0 +1,26 @@
+/* 
+ * File:   container.h
+ * Author: Olaf
+ *
+ * Created on 31. Januar 2015, 23:20
+ */
+
+#ifndef CONTAINER_H
+#define	CONTAINER_H
+
+#include "toolkit.h"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+UI_IMPORT void* __stdcall UIvbox(UiContainer *parent);
+UI_IMPORT void* __stdcall UIhbox(UiContainer *parent);
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* CONTAINER_H */
+
--- a/ui/wpf/objs.mk	Sat Jan 31 11:51:54 2015 +0100
+++ b/ui/wpf/objs.mk	Sun Feb 01 10:35:07 2015 +0100
@@ -31,6 +31,7 @@
 
 WPFOBJ = toolkit.o
 WPFOBJ += window.o
+WPFOBJ += container.o
 WPFOBJ += menu.o
 WPFOBJ += button.o
 

mercurial