application/main.c

changeset 115
102fc0b8fe3e
parent 114
909fe96e5659
child 116
480354705c2f
--- a/application/main.c	Sun Jan 24 22:20:47 2016 +0100
+++ b/application/main.c	Mon Jan 25 16:36:31 2016 +0100
@@ -76,17 +76,27 @@
     
     ui_graphics_color(g, 255, 255, 255);
     ui_draw_text(g, 50, 50, text);
+    ui_draw_line(g, 50, 55 + h, 50+w, 55 +h);
+    ui_draw_line(g, 50, 55 + h, 50, 75 +h);
     
     ui_draw_line(g, 0, 120, width, 120);
     ui_draw_line(g, 200, 0, 200, height);
     
+    ui_draw_rect(g, 250, 250, 50, 50, FALSE);
+    
     //ui_text_free(text);
     //*/
 }
 
+UIMENU ctxmenu;
 void click(UiEvent *event, void *data) {
     UiMouseEvent *me = event->eventdata;
     printf("click[%d](%d,%d)\n", me->type, me->x, me->y);
+    
+    if(me->button == 1) {
+        ui_contextmenu_popup(ctxmenu);
+    }
+    
 }
 
 void window_close(UiEvent *event, void *data) {
@@ -113,11 +123,17 @@
     
     UiObject *obj = ui_window("Test", NULL);
     ui_context_closefunc(obj->ctx, window_close, NULL);
+    
     UIWIDGET w = ui_drawingarea(obj, draw, NULL);
-    //ui_mouse_handler(obj, w, click, NULL);
+    ctxmenu = ui_contextmenu_w(obj, w);
+    ui_widget_menuitem(obj, "Test1", NULL, NULL);
+    ui_widget_menuitem(obj, "Test2", NULL, NULL);
+    ui_widget_menuitem(obj, "Test3", NULL, NULL);
+    ui_widget_menuitem(obj, "Test4", NULL, NULL);
+    ui_drawingarea_mousehandler(obj, w, click, NULL);
     
 /*
-    ui_vbox_sp(obj, 8, 4);
+    ui_vbox_sp(obj, 8, 4);   
     ui_button(obj, "Button", NULL, NULL);
     ui_button(obj, "Button", NULL, NULL);
     ui_button(obj, "Button", NULL, NULL);

mercurial