ui/motif/window.c

changeset 106
a4f4123ca12a
parent 62
70d2aee84432
child 111
40dbf1a7526a
equal deleted inserted replaced
105:86d729874ff4 106:a4f4123ca12a
46 if(nwindows == 0) { 46 if(nwindows == 0) {
47 ui_exit_mainloop(); 47 ui_exit_mainloop();
48 } 48 }
49 } 49 }
50 50
51 UiObject* ui_window(char *title, void *window_data) { 51 static UiObject* create_window(char *title, void *window_data, UiBool simple) {
52 UcxMempool *mp = ucx_mempool_new(256); 52 UcxMempool *mp = ucx_mempool_new(256);
53 UiObject *obj = ucx_mempool_calloc(mp, 1, sizeof(UiObject)); 53 UiObject *obj = ucx_mempool_calloc(mp, 1, sizeof(UiObject));
54 obj->ctx = uic_context(obj, mp); 54 obj->ctx = uic_context(obj, mp);
55 55
56 Arg args[16]; 56 Arg args[16];
85 obj); 85 obj);
86 86
87 // TODO: use callback 87 // TODO: use callback
88 ui_set_active_window(toplevel); 88 ui_set_active_window(toplevel);
89 89
90 // menu
91 Widget window = XtVaCreateManagedWidget( 90 Widget window = XtVaCreateManagedWidget(
92 title, 91 title,
93 xmMainWindowWidgetClass, 92 xmMainWindowWidgetClass,
94 toplevel, 93 toplevel,
95 NULL); 94 NULL);
96 obj->widget = window; 95 obj->widget = window;
97 ui_create_menubar(obj);
98
99 // toolbar
100 Widget form = XtVaCreateManagedWidget( 96 Widget form = XtVaCreateManagedWidget(
101 "window_form", 97 "window_form",
102 xmFormWidgetClass, 98 xmFormWidgetClass,
103 window, 99 window,
104 NULL); 100 NULL);
101 Widget toolbar = NULL;
105 102
106 Widget toolbar = ui_create_toolbar(obj, form); 103 if(!simple) {
107 104 ui_create_menubar(obj);
105 toolbar = ui_create_toolbar(obj, form);
106 }
108 107
109 // window content 108 // window content
110 XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT); 109 XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT);
111 XtSetArg(args[1], XmNshadowThickness, 0); 110 XtSetArg(args[1], XmNshadowThickness, 0);
112 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM); 111 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
130 XtManageChild(form); 129 XtManageChild(form);
131 130
132 obj->widget = toplevel; 131 obj->widget = toplevel;
133 nwindows++; 132 nwindows++;
134 return obj; 133 return obj;
134 }
135
136 UiObject* ui_window(char *title, void *window_data) {
137 return create_window(title, window_data, FALSE);
138 }
139
140 UiObject* ui_simplewindow(char *title, void *window_data) {
141 return create_window(title, window_data, TRUE);
135 } 142 }
136 143
137 void ui_close(UiObject *obj) { 144 void ui_close(UiObject *obj) {
138 XtDestroyWidget(obj->widget); 145 XtDestroyWidget(obj->widget);
139 window_close_handler(obj->widget, obj, NULL); 146 window_close_handler(obj->widget, obj, NULL);

mercurial