Commits

daonix  committed c9d307c

Minor changes

  • Participants
  • Parent commits 14ac8c3

Comments (0)

Files changed (6)

 	((BView*)v_self)->AddChild((BView*)v_aView, (BView*)v_sibling);
 	CAMLreturn(Val_unit);
 }
+CAMLprim value bview_SetLayout(value v_self, value v_layout)
+{
+	CAMLparam2(v_self, v_layout);
+	((BView*)v_self)->SetLayout((BLayout*)v_layout);
+	CAMLreturn(Val_unit);
 }
+}
 	CAMLparam1(v_tabview);
 	CAMLreturn((value)((BView*)((BTabView*)v_tabview)));
 }
+CAMLprim value blayout_of_bgrouplayout(value v_layout)
+{
+	CAMLparam1(v_layout);
+	CAMLreturn((value)((BLayout*)((BGroupLayout*)v_layout)));
+}
 }
 uint32 view_flags_of_val(value f)
 {

File bGroupLayout.ml

       bgrouplayout_Orientation pointer
     method set_orientation ~orientation =
       bgrouplayout_SetOrientation pointer orientation
-    method add_view ?index ?weight ~child =
+    method add_view ?index ?weight ~child () =
       match index, weight with
       | None, None -> bgrouplayout_AddView_1 pointer child
       | Some index, None -> bgrouplayout_AddView_2 pointer index child
       | None, Some weight -> bgrouplayout_AddView_3 pointer child weight
       | Some index, Some weight -> bgrouplayout_AddView_4 pointer index child weight
-    method add_item ?index ?weight ~item =
+    method add_item ?index ?weight ~item () =
       match index, weight with
       | None, Some weight -> bgrouplayout_AddItem_1 pointer item weight
       | Some index, Some weight -> bgrouplayout_AddItem_2 pointer index item weight
 external bview_AddChild :
 	Beapi.bview -> Beapi.bview -> Beapi.bview -> unit =
 	"bview_AddChild"
+external bview_SetLayout :
+	Beapi.bview -> Beapi.blayout -> unit =
+	"bview_SetLayout"
 
 
 
 let bounds ~self () = bview_Bounds self
 
 let add_child ~self ~aView ~sibling () = bview_AddChild self aView sibling
+
+let set_layout ~self ~layout () = bview_SetLayout self layout 
 external bview_of_btabview :
 	btabview -> bview =
 	"bview_of_btabview"
+external blayout_of_bgrouplayout :
+	bgrouplayout -> blayout =
+	"blayout_of_bgrouplayout"
                     ~flags:Beapi.b_WILL_DRAW () in
       self#add_tab ~target:insert_tab_view ~tab:(BTab.null ()) () ;
         
-      let button2 =
-        BButton.bbutton ~frame:(BView.bounds ~self:home_tab_view ())
-                        ~name:"Hello2" ~label:"Hello3"
-                        ~message:(BMessage.bmessage ~command:1 ())
-                        ~resizingMode:Beapi.b_FOLLOW_NONE
-                        ~flags:Beapi.b_WILL_DRAW () in
-      BView.add_child ~self:home_tab_view
-                      ~aView:(Beapi.bview_of_bbutton button2)
-	              ~sibling:(BView.null ()) () ;
       let button =
         BButton.bbutton ~frame:(BView.bounds ~self:home_tab_view ())
                         ~name:"Hello" ~label:"Hello"
                         ~message:(BMessage.bmessage ~command:1 ())
                         ~resizingMode:Beapi.b_FOLLOW_ALL_SIDES
                         ~flags:Beapi.b_WILL_DRAW () in
-      BView.add_child ~self:home_tab_view
+      let home_tab_layout =
+        new BGroupLayout.bgrouplayout ~orientation:Beapi.B_HORIZONTAL
+                                      ~spacing:0.0 () in
+      BView.set_layout ~self:home_tab_view
+                       ~layout:
+                         (Beapi.blayout_of_bgrouplayout home_tab_layout#get_pointer)
+                       () ;
+
+(*      BView.add_child ~self:home_tab_view
                       ~aView:(Beapi.bview_of_bbutton button)
-	              ~sibling:(BView.null ()) ()
+	              ~sibling:(BView.null ()) ()*)
+      ignore (home_tab_layout#add_view ~child:(Beapi.bview_of_bbutton button) ())
 end
 
 class hello_window ~frame =
     val message_received = fun message -> print_endline "button clicked"
     initializer
       self#setMessageReceived message_received ;
-      let layout = new BGroupLayout.bgrouplayout ~orientation:Beapi.B_VERTICAL ~spacing:1.0 () in
-      let tabs = new ribbon_tabs ~frame:(self#bounds ()) in
-      self#add_child ~aView:(Beapi.bview_of_btabview tabs#get_pointer)
+      let main_view =
+        BView.bview ~frame:(self#bounds ()) ~name:"main_view"
+                    ~resizingMode:Beapi.b_FOLLOW_ALL_SIDES
+                    ~flags:Beapi.b_WILL_DRAW () in
+      let layout =
+        new BGroupLayout.bgrouplayout ~orientation:Beapi.B_VERTICAL ~spacing:0.0 () in
+      BView.set_layout ~self:main_view
+                       ~layout:(Beapi.blayout_of_bgrouplayout layout#get_pointer) () ;
+      let tabs = new ribbon_tabs ~frame:(BView.bounds ~self:main_view ()) in
+      layout#add_view ~child:(Beapi.bview_of_btabview tabs#get_pointer) () ;
+      self#add_child ~aView:(*Beapi.bview_of_btabview tabs#get_pointer*)main_view
                      ~sibling:(BView.null ()) () ;
+      let button =
+        BButton.bbutton ~frame:(BView.bounds ~self:main_view ())
+                        ~name:"Hello2" ~label:"Hello3"
+                        ~message:(BMessage.bmessage ~command:1 ())
+                        ~resizingMode:Beapi.b_FOLLOW_NONE
+                        ~flags:Beapi.b_WILL_DRAW () in
+      BView.add_child ~self:main_view
+                      ~aView:(Beapi.bview_of_bbutton button)
+	              ~sibling:(BView.null ()) () ;
 end
 
 class hello_haiku =