2 #include "../src/lisp.h"
5 #include <X11/StringDefs.h>
6 #include <X11/IntrinsicP.h>
7 #include <X11/CompositeP.h>
10 #include <Xol/OpenLook.h>
11 #include <Xol/MenuButton.h>
12 #include <Xol/OblongButt.h>
13 #include <Xol/ControlAre.h>
15 #include <Xol/StaticText.h>
17 \f/* forward declarations */
19 update_menu_widget (widget_instance
* instance
, Widget widget
,
22 \f/* Menu callbacks */
24 pre_hook (Widget w
, caddr_t client_data
, caddr_t call_data
)
26 OlVirtualEvent ve
= (OlVirtualEvent
)call_data
;
27 widget_instance
* instance
= (widget_instance
*)client_data
;
29 if (w
->core
.being_destroyed
)
32 if (XtParent (w
) == instance
->widget
)
34 if (ve
->xevent
->type
== ButtonPress
&& instance
->info
->pre_activate_cb
)
35 instance
->info
->pre_activate_cb (instance
->widget
, instance
->info
->id
,
41 post_hook (Widget w
, caddr_t client_data
, caddr_t call_data
)
43 widget_instance
* instance
= (widget_instance
*)client_data
;
45 if (w
->core
.being_destroyed
)
48 if (instance
->info
->post_activate_cb
)
49 instance
->info
->post_activate_cb (w
, instance
->info
->id
, NULL
);
53 pick_hook (Widget w
, caddr_t client_data
, caddr_t call_data
)
55 widget_instance
* instance
= 0;
56 widget_value
* val
= (widget_value
*)client_data
;
58 if (w
->core
.being_destroyed
)
61 XtVaGetValues (w
, XtNuserData
, &instance
, 0);
66 if (instance
->info
->selection_cb
&& val
&& val
->enabled
68 instance
->info
->selection_cb (w
, instance
->info
->id
, val
->call_data
);
71 \f/* creation functions */
73 xol_create_menubar (widget_instance
* instance
)
76 XtVaCreateWidget (instance
->info
->name
, controlAreaWidgetClass
,
82 xol_create_popup_menu (widget_instance
* instance
)
85 XtCreatePopupShell (instance
->info
->name
, menuShellWidgetClass
,
86 instance
->parent
, NULL
, 0);
91 xol_creation_table
[] =
93 {"menubar", xol_create_menubar
},
94 {"popup", xol_create_popup_menu
},
99 xol_create_dialog (widget_instance
* instance
)
105 lw_olit_widget_p (Widget widget
)
110 \f/* update functions */
112 destroy_all_children (Widget widget
)
118 children
= (Widget
*) XtCompositeChildren (widget
, &number
);
121 /* Unmanage all children and destroy them. They will only be
122 * really destroyed when we get out of DispatchEvent. */
123 for (i
= 0; i
< number
; i
++)
125 Widget child
= children
[i
];
126 if (!child
->core
.being_destroyed
)
128 XtUnmanageChild (child
);
129 XtDestroyWidget (child
);
137 all_dashes_p (char* s
)
147 make_menu_in_widget (widget_instance
* instance
, Widget widget
,
156 for (cur
= val
; cur
; cur
= cur
->next
)
159 XtSetArg (al
[ac
], XtNsensitive
, cur
->enabled
); ac
++;
160 XtSetArg (al
[ac
], XtNuserData
, instance
); ac
++;
161 XtSetArg (al
[ac
], XtNacceleratorText
, cur
->key
); ac
++;
163 /* label = (char *) resource_string (widget, cur->name);*/
167 XtSetArg (al
[ac
], XtNlabel
, label
); ac
++;
170 if (all_dashes_p (cur
->name
))
172 /* no separator in OpenLook just make some space. */
173 XtSetArg (al
[ac
], XtNheight
, 5); ac
++;
174 XtSetArg (al
[ac
], XtNwidth
, 5); ac
++;
175 button
= XtCreateWidget (cur
->name
, stubWidgetClass
, widget
, al
, ac
);
177 else if (!cur
->contents
)
181 XtCreateManagedWidget (cur
->name
, staticTextWidgetClass
, widget
,
186 XtCreateManagedWidget (cur
->name
, oblongButtonWidgetClass
,
188 XtAddCallback (button
, XtNselect
, pick_hook
, cur
);
195 XtCreateManagedWidget (cur
->name
, menuButtonWidgetClass
, widget
,
197 XtVaGetValues (button
, XtNmenuPane
, &menu
, 0);
200 make_menu_in_widget (instance
, menu
, cur
->contents
);
201 OlAddCallback (button
, XtNconsumeEvent
, pre_hook
, instance
);
207 update_one_menu_entry (widget_instance
* instance
, Widget widget
,
213 widget_value
* contents
;
215 if (val
->change
== NO_CHANGE
)
218 /* update the sensitivity */
219 XtVaSetValues (widget
, XtNsensitive
, val
->enabled
, 0);
221 /* update the pulldown/pullaside as needed */
224 XtVaGetValues (widget
, XtNmenuPane
, &menu
, 0);
225 contents
= val
->contents
;
231 /* in OLIT this would have to be a structural change on the
238 /* in OLIT this would have to be a structural change on the button. */
241 else if (contents
->change
!= NO_CHANGE
)
242 update_menu_widget (instance
, menu
, val
);
246 update_menu_widget (widget_instance
* instance
, Widget widget
,
250 if (val
->change
== STRUCTURAL_CHANGE
251 || val
->contents
->change
== STRUCTURAL_CHANGE
)
253 destroy_all_children (widget
);
254 make_menu_in_widget (instance
, widget
, val
->contents
);
258 /* Update all the buttons of the composite widget in order. */
260 unsigned int num_children
;
264 children
= (Widget
*) XtCompositeChildren (widget
, &num_children
);
267 for (i
= 0, cur
= val
->contents
; i
< num_children
; i
++)
271 if (children
[i
]->core
.being_destroyed
272 || strcmp (XtName (children
[i
]), cur
->name
))
274 update_one_menu_entry (instance
, children
[i
], cur
);
285 xol_update_one_widget (widget_instance
* instance
, Widget widget
,
286 widget_value
* val
, Boolean deep_p
)
288 Widget menu
= widget
;
290 if (XtIsShell (widget
))
291 XtVaGetValues (widget
, XtNmenuPane
, &menu
, 0);
293 update_menu_widget (instance
, menu
, val
);
297 xol_update_one_value (widget_instance
* instance
, Widget widget
,
304 xol_pop_instance (widget_instance
* instance
, Boolean up
)
309 xol_popup_menu (Widget widget
)
314 \f/* Destruction of instances */
316 xol_destroy_instance (widget_instance
* instance
)
318 XtDestroyWidget (instance
->widget
);