| 86 if(!simple) { |
86 if(!simple) { |
| 87 ui_get_window_default_width(&window_width, &window_height); |
87 ui_get_window_default_width(&window_width, &window_height); |
| 88 } |
88 } |
| 89 |
89 |
| 90 UiMotifAppWindow *appwindow = cxZalloc(a, sizeof(UiMotifAppWindow)); |
90 UiMotifAppWindow *appwindow = cxZalloc(a, sizeof(UiMotifAppWindow)); |
| 91 // Because we store appwindow as userdata in the widget, we use this |
91 ui_object_set(obj, "ui_motif_app_window", appwindow); |
| 92 // magic field to check, if the pointer is actually the correct type. |
|
| 93 // This is a dubious technique, but this is only the last defense |
|
| 94 // mechanism against someone using the API wrong. |
|
| 95 appwindow->magic = UI_MOTIF_APP_WINDOW; |
|
| 96 |
92 |
| 97 Arg args[16]; |
93 Arg args[16]; |
| 98 int n = 0; |
94 int n = 0; |
| 99 XtSetArg(args[n], XmNtitle, title); n++; |
95 XtSetArg(args[n], XmNtitle, title); n++; |
| 100 XtSetArg(args[n], XmNminWidth, 100); n++; |
96 XtSetArg(args[n], XmNminWidth, 100); n++; |
| 101 XtSetArg(args[n], XmNminHeight, 50); n++; |
97 XtSetArg(args[n], XmNminHeight, 50); n++; |
| 102 XtSetArg(args[n], XmNwidth, window_width); n++; |
98 XtSetArg(args[n], XmNwidth, window_width); n++; |
| 103 XtSetArg(args[n], XmNheight, window_height); n++; |
99 XtSetArg(args[n], XmNheight, window_height); n++; |
| 104 XtSetArg(args[n], XmNuserData, appwindow); n++; |
|
| 105 |
100 |
| 106 Widget toplevel = XtAppCreateShell( |
101 Widget toplevel = XtAppCreateShell( |
| 107 ui_appname(), |
102 ui_appname(), |
| 108 "mainwindow", |
103 "mainwindow", |
| 109 //applicationShellWidgetClass, |
104 //applicationShellWidgetClass, |
| 172 window_default_width = width; |
167 window_default_width = width; |
| 173 window_default_height = height; |
168 window_default_height = height; |
| 174 } |
169 } |
| 175 |
170 |
| 176 void ui_window_menubar_set_visible(UiObject *obj, UiBool visible) { |
171 void ui_window_menubar_set_visible(UiObject *obj, UiBool visible) { |
| 177 UiMotifAppWindow *window = NULL; |
172 UiMotifAppWindow *window = ui_object_get(obj, "ui_motif_app_window"); |
| 178 XtVaGetValues(obj->widget, XmNuserData, &window, NULL); |
|
| 179 if(window) { |
173 if(window) { |
| 180 if(window->magic != UI_MOTIF_APP_WINDOW) { |
|
| 181 fprintf(stderr, "Error: obj is not an app window\n"); |
|
| 182 return; |
|
| 183 } |
|
| 184 if(window->menubar) { |
174 if(window->menubar) { |
| 185 ui_set_visible(window->menubar, visible); |
175 ui_set_visible(window->menubar, visible); |
| 186 } |
176 } |
| |
177 } else { |
| |
178 fprintf(stderr, "Error: obj is not an application window\n"); |
| 187 } |
179 } |
| 188 } |
180 } |
| 189 |
181 |
| 190 static void filedialog_event(UiEventData *event, int result, UiFileList flist) { |
182 static void filedialog_event(UiEventData *event, int result, UiFileList flist) { |
| 191 UiEvent evt; |
183 UiEvent evt; |