open X11
(*let font = font_load "Times New Roman:pixelsize=14"*)
-let font = font_load "Helvetica:pixelsize=48"
+let font = font_load "Liberation Mono:size=10"
+(* Drawing functions
+ ******************************************************************************)
+type drawpos = { x: int; y: int }
+
+let draw_background width height =
+ draw_rect { x = 0; y = 0; w = width; h = height; c = Cfg.Color.palette.(0) }
+
+let draw_hrule pos width =
+ draw_rect { x = 0; y = pos.y; w = width; h = 1; c = Cfg.Color.palette.(3) };
+ { pos with y = pos.y + 1 }
+
+let draw_vrule pos height =
+ draw_rect { x = pos.x; y = pos.y; w = 1; h = height - pos.y; c = Cfg.Color.palette.(3) };
+ { pos with x = pos.x + 1 }
+
+let draw_status pos width text =
+ draw_string font Cfg.Color.palette.(5) text (pos.x + 2, pos.y + 2);
+ let pos = { pos with y = (4 + font.height) } in
+ draw_hrule pos width
+
+let draw_tags pos width text =
+ draw_string font Cfg.Color.palette.(5) text (pos.x + 2, pos.y + 2);
+ let pos = { pos with y = (pos.y + 2 + font.height) } in
+ draw_hrule pos width
+
+let draw_scroll pos height =
+ let pos = { pos with x = 14 } in
+ draw_vrule pos height
+
+let draw_edit pos width height =
+ ()
+
+(* Event functions
+ ******************************************************************************)
let onfocus focused =
print_endline "onfocus"
print_endline "onmousemove"
let onupdate width height =
- let text = "FooBarBazYay" in
- Printf.printf "onupdate: %d %d\n" width height;
- draw_rect { x = 2; y = 2; w = width; h = height; c = Cfg.Color.palette.(0) };
- draw_string font Cfg.Color.palette.(5) text (2,2);
- draw_string font Cfg.Color.palette.(5) text (2,2+font.height);
- draw_rect { x = 2; y = 2; w = 1; h = font.height; c = Cfg.Color.palette.(3) };
+ draw_background width height;
+ let (pos : drawpos) = { x = 0; y = 0 } in
+ let pos = draw_status pos width "UNSI> *scratch*" in
+ let pos = draw_tags pos width "Sample tags data" in
+ let pos = draw_scroll pos height in
+ draw_edit pos width height;
flip ()
let onshutdown () =
| Update e -> onupdate e.width e.height
| Shutdown -> onshutdown ()
+(* Main Routine
+ ******************************************************************************)
let () =
let win = make_window 640 480 in
show_window win true;