Commits

Anonymous committed c31efd5

BAlignment added

  • Participants
  • Parent commits fe33fdf

Comments (0)

Files changed (8)

+#include "BAlignmentML.hpp"
+#include <stdio.h>
+extern "C" {
+CAMLprim value balignment_constructor_1()
+{
+	CAMLparam0();
+	BAlignment* res = new BAlignment();
+	CAMLreturn((value)res);
+}
+CAMLprim value balignment_constructor_2(value v_other)
+{
+	CAMLparam1(v_other);
+	BAlignment* res = new BAlignment(*(BAlignment*)v_other);
+	CAMLreturn((value)res);
+}
+CAMLprim value balignment_constructor_3(value v_horizontal, value v_vertical)
+{
+	CAMLparam2(v_horizontal, v_vertical);
+	BAlignment* res = new BAlignment((alignment)Int_val(v_horizontal), (vertical_alignment)Int_val(v_vertical));
+	CAMLreturn((value)res);
+}
+}
+#ifndef BALIGNMENTML_H
+#define BALIGNMENTML_H
+#include <interface/Alignment.h>
+extern "C" {
+#include "HaikuML.h"
+}
+
+#endif
 #include "BTextViewML.hpp"
+#include <stdio.h>
 BTextViewML::BTextViewML(BRect frame, const char * name, BRect textRect, int resizingMode, int flags)
 	:BTextView(frame, name, textRect, resizingMode, flags)
 {
 all : ApplicationKit InterfaceKit
 
 ApplicationKit : bapplication bmessage
-InterfaceKit : bbutton bgrouplayout brect btab btabview btextview bview bwindow
+InterfaceKit : balignment bbutton bgrouplayout brect btab btabview btextview bview bwindow
 
 beapi :
 	g++ -o haikuml_beapi.o -I/boot/common/lib/ocaml -c BeapiML.cpp
 	ocamlmklib -o bMessage bMessage.cmx
 
 
+balignment : beapi
+	g++ -o haikuml_balignment.o -I/boot/common/lib/ocaml -c BAlignmentML.cpp
+	ocamlopt -c bAlignment.ml
+	ocamlmklib -o bAlignment haikuml_balignment.o
+	ocamlmklib -o bAlignment bAlignment.cmx
+
 bbutton : beapi
 	g++ -o haikuml_bbutton.o -I/boot/common/lib/ocaml -c BButtonML.cpp
 	ocamlopt -c bButton.ml
 	ocamlmklib -o bWindow bWindow.cmx
 
 hello_world : all
-	ocamlopt -I . -cclib -lroot -cclib -lbe bWindow.cmxa bView.cmxa bTextView.cmxa bTabView.cmxa bTab.cmxa bRect.cmxa bGroupLayout.cmxa bButton.cmxa bMessage.cmxa bApplication.cmxa beapi.cmxa caller.ml -o caller.opt
+	ocamlopt -I . -cclib -lroot -cclib -lbe bWindow.cmxa bView.cmxa bTextView.cmxa bTabView.cmxa bTab.cmxa bRect.cmxa bGroupLayout.cmxa bButton.cmxa bAlignment.cmxa bMessage.cmxa bApplication.cmxa beapi.cmxa caller.ml -o caller.opt
+external balignment_constructor_1 :
+	unit -> Beapi.balignment =
+	"balignment_constructor_1"
+external balignment_constructor_2 :
+	Beapi.balignment -> Beapi.balignment =
+	"balignment_constructor_2"
+external balignment_constructor_3 :
+	Beapi.alignment -> Beapi.vertical_alignment -> Beapi.balignment =
+	"balignment_constructor_3"
+
+let balignment ?other ?horizontal ?vertical () =
+	match other, horizontal, vertical with
+	| None, None, None -> balignment_constructor_1 ()
+	| Some other, None, None -> balignment_constructor_2 other
+	| None, Some h, Some v -> balignment_constructor_3 h v
+	| _, _, _ -> invalid_arg "Wrong arg in Balignment constructor"
 	Beapi.bgrouplayout -> Beapi.bsize =
 	"bgrouplayout_PreferredSize"
 external bgrouplayout_SetExplicitAlignment :
-	Beapi.bgrouplayout -> Beapi.alignment -> unit =
+	Beapi.bgrouplayout -> Beapi.balignment -> unit =
 	"bgrouplayout_SetExplicitAlignment"
 external bgrouplayout_SetExplicitMaxSize :
 	Beapi.bgrouplayout -> Beapi.bsize -> unit =
 	| B_UNDO_PASTE
 	| B_UNDO_CLEAR
 	| B_UNDO_DROP
-
+type vertical_alignment =
+	| B_ALIGN_TOP
+	| B_ALIGN_MIDDLE
+	| B_ALIGN_BOTTOM
 type window_alignment
 type window_feel =
 	| B_NORMAL_WINDOW_FEEL
     method get_view = view
     initializer
       self#set_view ;
+      layout#set_explicit_alignment
+        ~alignment:(BAlignment.balignment ~horizontal:Beapi.B_ALIGN_LEFT
+                                          ~vertical:Beapi.B_ALIGN_TOP ());
       BView.set_view_color ~self:view ~red:Beapi.default_bview_color
                            ~green:Beapi.default_bview_color
                            ~blue:Beapi.default_bview_color ~alpha:255 () ;