Anonymous avatar Anonymous committed 81d90f8

BWindow class ready.

Comments (0)

Files changed (4)

 	closure_Zoom_2 = cb_Zoom;
 }
 extern "C" {
+CAMLprim value bwindow_delete(value v_window)
+{
+	CAMLparam1(v_window);
+	delete ((BWindow*)v_window);
+	CAMLreturn(Val_unit);
+}
 CAMLprim value bwindow_constructor_1(value v_frame, value v_title, value v_type, value v_flags, value v_workspaces)
 {
 	CAMLparam5(v_frame, v_title, v_type, v_flags, v_workspaces);
+external bwindow_delete :
+	Beapi.bwindow -> unit =
+	"bwindow_delete"
 external bwindow_constructor_1 :
 	Beapi.brect -> string -> Beapi.window_type -> int -> int -> Beapi.bwindow =
 	"bwindow_constructor_1"
 	Beapi.bmessage -> Beapi.bwindow =
 	"bwindow_constructor_3"
 external bwindow_setFrameMoved :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (Beapi.bpoint -> unit) -> unit =
 	"bwindow_setFrameMoved"
 external bwindow_setFrameResized :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (float -> float -> unit) -> unit =
 	"bwindow_setFrameResized"
 external bwindow_setMenusBeginning :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (unit -> unit) -> unit =
 	"bwindow_setMenusBeginning"
 external bwindow_setMenusEnded :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (unit -> unit) -> unit =
 	"bwindow_setMenusEnded"
 external bwindow_setMessageReceived :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (Beapi.bmessage -> unit) -> unit =
 	"bwindow_setMessageReceived"
 external bwindow_setScreenChanged :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (Beapi.brect -> Beapi.color_space -> unit) -> unit =
 	"bwindow_setScreenChanged"
 external bwindow_setWindowActivated :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (bool -> unit) -> unit =
 	"bwindow_setWindowActivated"
 external bwindow_setWorkspaceActivated :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (int -> bool -> unit) -> unit =
 	"bwindow_setWorkspaceActivated"
 external bwindow_setWorkspacesChanged :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (int -> int -> unit) -> unit =
 	"bwindow_setWorkspacesChanged"
 external bwindow_setZoom_1 :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (unit -> unit) -> unit =
 	"bwindow_setZoom_1"
 external bwindow_setZoom_2 :
-	Beapi.bwindow -> 'a -> unit =
+	Beapi.bwindow -> (Beapi.bpoint -> float -> float -> unit) -> unit =
 	"bwindow_setZoom_2"
 external bwindow_Activate :
 	Beapi.bwindow -> bool -> unit =
 	Beapi.bwindow -> float -> float -> unit =
 	"bwindow_MoveBy"
 external bwindow_MoveTo_1 :
-	Beapi.bpoint -> unit =
+	Beapi.bwindow -> Beapi.bpoint -> unit =
 	"bwindow_MoveTo_1"
 external bwindow_MoveTo_2 :
-	float -> float -> unit =
+	Beapi.bwindow -> float -> float -> unit =
 	"bwindow_MoveTo_2"
 external bwindow_NeedsUpdate :
 	Beapi.bwindow -> bool =
 		bwindow_Frame self
 
 
-	let convert_to_screen_point ~windowPoint () =
-		bwindow_ConvertToScreen_1 windowPoint
-	let convert_to_screen_rect ~windowRect () =
-		bwindow_ConvertToScreen_2 windowRect
+	let convert_to_screen_point ~self ~windowPoint () =
+		bwindow_ConvertToScreen_1 self windowPoint
+	let convert_to_screen_rect ~self ~windowRect () =
+		bwindow_ConvertToScreen_2 self windowRect
 
 
-	let convert_from_screen_point ~windowPoint () =
-		bwindow_ConvertFromScreen_1 windowPoint
+	let convert_from_screen_point ~self ~windowPoint () =
+		bwindow_ConvertFromScreen_1 self windowPoint
 
-	let convert_from_screen_rect ~windowRect () =
-		bwindow_ConvertFromScreen_2 windowRect
+	let convert_from_screen_rect ~self ~windowRect () =
+		bwindow_ConvertFromScreen_2 self windowRect
 
 
 
 	let move_by ~self ~horizontal ~vertical () =
 		bwindow_MoveBy self horizontal vertical
 
-	let move_to ?point ?x ?y () =
+	let move_to ~self ?point ?x ?y () =
 		match point, x, y with
-		| Some point, None, None -> bwindow_MoveTo_1 point
-		| None, Some x, Some y -> bwindow_MoveTo_2 x y
+		| Some point, None, None -> bwindow_MoveTo_1 self point
+		| None, Some x, Some y -> bwindow_MoveTo_2 self x y
 		| _, _, _ -> invalid_arg "Wrong arg in BWindow.MoveTo"
 
 
 	let update_if_needed ~self () =
 		bwindow_UpdateIfNeeded self
 
+class bwindow ?frame ?title ?window_type ?flags ?workspaces
+              ?look ?feel ?archive ?external_pointer () =
+  object (self)
+    val pointer =
+      match external_pointer with
+      | Some p -> p
+      | None ->
+	  (match archive, frame, look, window_type, workspaces,
+            feel, title, flags with
+	   | None, Some frame, None, Some window_type, Some workspaces,
+             None, Some title, Some flags ->
+               bwindow_constructor_1 frame title window_type flags workspaces
+	   | None, Some frame, Some look, None, Some workspaces,
+             Some feel, Some title, Some flags ->
+               bwindow_constructor_2 frame title look feel flags workspaces
+	   | Some archive, None, None, None, None, None, None, None ->
+               bwindow_constructor_3 archive
+	   | _, _, _, _, _, _, _, _ ->
+               invalid_arg "Wrong arg in BWindow.constructor")
+    method get_pointer = pointer
+    method delete = bwindow_delete pointer
+    method setFrameMoved f = setFrameMoved ~self:pointer ~cb:f ()
+    method setFrameResized f = setFrameResized ~self:pointer ~cb:f ()
+    method setMenusBeginning f = setMenusBeginning ~self:pointer ~cb:f ()
+    method setMenusEnded f = setMenusEnded ~self:pointer ~cb:f ()
+    method setMessageReceived f = setMessageReceived ~self:pointer ~cb:f ()
+    method setScreenChanged f = setScreenChanged ~self:pointer ~cb:f ()
+    method setWindowActivated f = setWindowActivated ~self:pointer ~cb:f ()
+    method setWorkspaceActivated f =
+      setWorkspaceActivated ~self:pointer ~cb:f ()
+    method setWorkspacesChanged f =
+      setWorkspacesChanged ~self:pointer ~cb:f ()
+    method setZoom_1 f = setZoom_1 ~self:pointer ~cb:f ()
+    method setZoom_2 f = setZoom_2 ~self:pointer ~cb:f ()
+    method activate ~flag:flag () = activate ~self:pointer ~flag:flag ()
+    method is_active () = is_active ~self:pointer ()
+    method add_child ~aView ~sibling () =
+      add_child ~self:pointer ~aView:aView ~sibling:sibling ()
+    method remove_child ~aView () = remove_child ~self:pointer ~aView:aView ()
+    method child_at ~index () = child_at ~self:pointer ~index:index ()
+    method count_children () = count_children ~self:pointer ()
+    method add_shortcut ?modifiers ?key ?handler ?message () =
+      match modifiers, key, handler, message with
+      | Some modifiers, Some key, None, Some message ->
+          bwindow_AddShortcut_1 pointer key modifiers message
+      | Some modifiers, Some key, Some handler, Some message ->
+          bwindow_AddShortcut_2 pointer key modifiers message handler
+      | _, _, _, _ -> invalid_arg "Wrong arg in BWindow.AddShortcut" 
+    method remove_shortcut ~key ~modifiers () =
+      remove_shortcut ~self:pointer ~key:key ~modifiers:modifiers ()
+    method add_to_subset ~window () =
+      add_to_subset ~self:pointer ~window:window ()
+    method remove_from_subset ~window () =
+      remove_from_subset ~self:pointer ~window:window ()
+    method archive ~archive ~deep () =
+      bwindow_Archive pointer archive deep
+    method bounds () = bounds ~self:pointer ()
+    method frame () = bwindow_Frame pointer
+    method convert_to_screen_point ~windowPoint () =
+      convert_to_screen_point ~self:pointer ~windowPoint:windowPoint ()
+    method convert_to_screen_rect ~windowRect () =
+      convert_to_screen_rect ~self:pointer ~windowRect:windowRect () 
+    method convert_from_screen_point ~windowPoint () =
+      convert_from_screen_point ~self:pointer ~windowPoint:windowPoint ()
+    method convert_from_screen_rect ~windowRect () =
+      convert_from_screen_rect ~self:pointer ~windowRect:windowRect ()
+    method current_focus () =
+      current_focus ~self:pointer ()
+    method disable_updates () =
+      disable_updates ~self:pointer ()
+    method enable_updates () =
+      enable_updates ~self:pointer ()
+    method find_view ?point ?name () =
+      match point, name with
+      | Some point, None -> bwindow_FindView_1 pointer point
+      | None, Some name -> bwindow_FindView_2 pointer name
+      | _, _ -> invalid_arg "Wrong arg in BWindow.FindView"
+    method flush () =
+      flush ~self:pointer ()
+    method sync () =
+      sync ~self:pointer ()
+    method get_supported_suites ~message () =
+      get_supported_suites ~self:pointer ~message:message ()
+    method is_front () = is_front ~self:pointer ()
+    method is_floating () = is_floating ~self:pointer ()
+    method is_modal () = is_modal ~self:pointer ()
+    method last_mouse_moved_view () =
+      last_mouse_moved_view ~self:pointer ()
+    method move_by ~horizontal ~vertical () =
+      move_by ~self:pointer ~horizontal:horizontal ~vertical:vertical ()
+    method move_to ?point ?x ?y () =
+      match point, x, y with
+      | Some point, None, None -> bwindow_MoveTo_1 pointer point
+      | None, Some x, Some y -> bwindow_MoveTo_2 pointer x y
+      | _, _, _ -> invalid_arg "Wrong arg in BWindow.MoveTo"
+    method needs_update () =
+      needs_update ~self:pointer ()
+    method quit () =
+      quit ~self:pointer ()
+    method resize_by ~horizontal ~vertical () =
+      resize_by ~self:pointer ~horizontal:horizontal ~vertical:vertical ()
+    method resize_to ~width ~height () =
+      resize_to ~self:pointer ~width:width ~height:height ()
+    method resolve_specifier ~message ~index ~specifier ~command ~property () =
+      resolve_specifier ~self:pointer ~message:message ~index:index
+                        ~specifier:specifier ~command:command
+                        ~property:property ()
+    method send_behind ~window () = send_behind ~self:pointer ~window:window ()
+    method set_default_button ~button () =
+      set_default_button ~self:pointer ~button:button ()
+    method default_button () =
+      default_button ~self:pointer ()
+    method set_feel ~feel () =
+      set_feel ~self:pointer ~feel:feel ()
+    method feel () =
+      bwindow_Feel pointer
+    method set_flags ~flags () =
+      set_flags ~self:pointer ~flags:flags ()
+    method flags () =
+      bwindow_Flags pointer
+    method set_key_menu_bar ~menuBar () =
+      set_key_menu_bar ~self:pointer ~menuBar:menuBar ()
+    method key_menu_bar () =
+      key_menu_bar ~self:pointer ()
+    method set_look ~look () =
+      set_look ~self:pointer ~look:look ()
+    method look () =
+      bwindow_Look pointer
+    method set_pulse_rate ~microseconds () =
+      set_pulse_rate ~self:pointer ~microseconds:microseconds ()
+    method pulse_rate () =
+      pulse_rate ~self:pointer ()
+    method set_size_limits ~minWidth ~maxWidth ~minHeight ~maxHeight () =
+      set_size_limits ~self:pointer ~minWidth:minWidth ~maxWidth:maxWidth
+                      ~minHeight:minHeight ~maxHeight:maxHeight ()
+    method get_size_limits ~minWidth ~maxWidth ~minHeight ~maxHeight () =
+      get_size_limits ~self:pointer ~minWidth:minWidth ~maxWidth:maxWidth
+                      ~minHeight:minHeight ~maxHeight:maxHeight ()
+    method set_zoom_limits ~maxWidth ~maxHeight () =
+      set_zoom_limits ~self:pointer ~maxWidth:maxWidth ~maxHeight:maxHeight ()
+    method set_title ~newTitle () =
+      set_title ~self:pointer ~newTitle:newTitle ()
+    method title () =
+      bwindow_Title pointer
+    method set_type ~window_type () =
+      set_type ~self:pointer ~window_type:window_type ()
+    method window_type () =
+      bwindow_Type pointer
+    method set_window_alignment ~mode ~h ~hOffset ~width ~widthOffset
+                                ~v ~vOffset ~height ~heightOffset () =
+      set_window_alignment ~self:pointer ~mode:mode ~h:h ~hOffset:hOffset
+                           ~width:width ~widthOffset:widthOffset ~v:v
+                           ~vOffset:vOffset ~height:height
+                           ~heightOffset:heightOffset ()
+    method get_window_alignment ~mode ~h ~hOffset ~width ~widthOffset
+                                ~v ~vOffset ~height ~heightOffset () =
+      get_window_alignment ~self:pointer ~mode:mode ~h:h ~hOffset:hOffset
+                           ~width:width ~widthOffset:widthOffset
+                           ~v:v ~vOffset:vOffset ~height:height
+                           ~heightOffset:heightOffset ()
+    method set_workspaces ~workspaces () =
+      set_workspaces ~self:pointer ~workspaces:workspaces ()
+    method workspaces () =
+      bwindow_Workspaces pointer
+    method show () =
+      show ~self:pointer ()
+    method hide () =
+      hide ~self:pointer ()
+    method is_hidden () =
+      is_hidden ~self:pointer ()
+    method minimize ~minimize () =
+      bwindow_Minimize pointer minimize
+    method is_minimized () = is_minimized ~self:pointer ()
+    method update_if_needed () = update_if_needed ~self:pointer ()
+end
 
 type app_info
 type bigtime_t
+type color_space
 type entry_ref
 type status_t
 type ssize_t
 
 class hello_window ~frame =
   object (self)
-    val mutable object_pointer =
-      BWindow.constructor ~frame:frame ~title:"Hello Window"
-        ~window_type:Beapi.B_UNTYPED_WINDOW ~flags:0 ~workspaces:0 ()
-    val quit_requested = fun () -> 1
+    inherit BWindow.bwindow ~frame:frame ~title:"Hello Window"
+                            ~window_type:Beapi.B_UNTYPED_WINDOW
+                            ~flags:0 ~workspaces:0 ()
     val message_received = fun message -> print_endline "button clicked"
-    method bounds = BWindow.bounds ~self:object_pointer ()
-    method add_child ~aView ~sibling =
-      BWindow.add_child ~self:object_pointer ~aView:aView ~sibling:sibling ()
-    method show = BWindow.show ~self:object_pointer ()
-	initializer
-          BWindow.setMessageReceived ~self:object_pointer ~cb:message_received () ;
-	  let view = BView.bview ~frame:self#bounds
-	    ~name:"Hello, Gaiku" ~resizingMode:Beapi.b_FOLLOW_ALL_SIDES
-            ~flags:Beapi.b_WILL_DRAW () in
-	  self#add_child ~aView:view ~sibling:(BView.null ()) ;
-	  let button = BButton.bbutton ~frame:(BView.bounds ~self: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:view ~aView:(Beapi.bview_of_bbutton button)
-	    ~sibling:(BView.null ()) ()
+    initializer
+      self#setMessageReceived message_received ;
+      let view =
+        BView.bview ~frame:(self#bounds ()) ~name:"Hello, Gaiku"
+                    ~resizingMode:Beapi.b_FOLLOW_ALL_SIDES
+                    ~flags:Beapi.b_WILL_DRAW () in
+      self#add_child ~aView:view ~sibling:(BView.null ()) () ;
+      let button =
+        BButton.bbutton ~frame:(BView.bounds ~self: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:view ~aView:(Beapi.bview_of_bbutton button)
+	              ~sibling:(BView.null ()) ()
   end
 
 class hello_haiku =
         let win = new hello_window 
           ~frame:(BRect.brect ~left:100.0 ~top:100.0
             ~right:300.0 ~bottom:200.0 ()) in
-      win#show
+      win#show ()
     method run = BApplication.run ~self:object_pointer ()
     initializer
 	  BApplication.setReadyToRun ~self:object_pointer ~cb:ready_to_run ()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.