| File: | lwlib/lwlib-Xlw.c |
| Location: | line 454, column 42 |
| Description: | Dereference of null pointer |
| 1 | /* The lwlib interface to "xlwmenu" menus. | ||
| 2 | Copyright (C) 1992, 1994 Lucid, Inc. | ||
| 3 | |||
| 4 | This file is part of the Lucid Widget Library. | ||
| 5 | |||
| 6 | The Lucid Widget Library is free software; you can redistribute it and/or | ||
| 7 | modify it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | any later version. | ||
| 10 | |||
| 11 | The Lucid Widget Library is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with XEmacs; see the file COPYING. If not, write to | ||
| 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 19 | Boston, MA 02111-1307, USA. */ | ||
| 20 | |||
| 21 | #include <config.h> | ||
| 22 | #include <stdlib.h> /* for abort () */ | ||
| 23 | #include <stdio.h> /* for abort () */ | ||
| 24 | #include <limits.h> | ||
| 25 | |||
| 26 | #include "lwlib-Xlw.h" | ||
| 27 | #include "lwlib-utils.h" | ||
| 28 | #include <X11/StringDefs.h> | ||
| 29 | #include <X11/IntrinsicP.h> | ||
| 30 | #include <X11/ObjectP.h> | ||
| 31 | #include <X11/CompositeP.h> | ||
| 32 | #include <X11/Shell.h> | ||
| 33 | #include <X11/Xmu/Converters.h> | ||
| 34 | #ifdef HAVE_X_WIDGETS | ||
| 35 | #include "../src/EmacsManager.h" | ||
| 36 | #endif | ||
| 37 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 38 | #include "xlwmenu.h" | ||
| 39 | #endif | ||
| 40 | #ifdef LWLIB_SCROLLBARS_LUCID1 | ||
| 41 | #include "xlwscrollbar.h" | ||
| 42 | #endif | ||
| 43 | #ifdef LWLIB_TABS_LUCID1 | ||
| 44 | #ifdef NEED_MOTIF | ||
| 45 | #include "lwlib-Xm.h" | ||
| 46 | #endif | ||
| 47 | #ifdef NEED_ATHENA1 | ||
| 48 | #include "lwlib-Xaw.h" | ||
| 49 | #endif | ||
| 50 | #include "xlwtabs.h" | ||
| 51 | #endif | ||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 56 | |||
| 57 | /* Menu callbacks */ | ||
| 58 | |||
| 59 | static void | ||
| 60 | pre_hook (Widget w, XtPointer client_data, XtPointer call_data) | ||
| 61 | { | ||
| 62 | widget_instance* instance = (widget_instance*)client_data; | ||
| 63 | widget_value* val; | ||
| 64 | |||
| 65 | if (w->core.being_destroyed) | ||
| 66 | return; | ||
| 67 | |||
| 68 | val = lw_get_widget_value_for_widget (instance, w); | ||
| 69 | #if 0 | ||
| 70 | /* #### - this code used to (for some random back_asswards reason) pass | ||
| 71 | the expression below in the call_data slot. For incremental menu | ||
| 72 | construction, this needs to go. I can't even figure out why it was done | ||
| 73 | this way in the first place...it's just a historical weirdism. --Stig */ | ||
| 74 | call_data = (val ? val->call_data : NULL((void*)0)); | ||
| 75 | #endif | ||
| 76 | if (val && val->call_data) | ||
| 77 | abort()(assert_failed ("/home/jamesjer/Projects/xemacs/xemacs-21.5/lwlib/lwlib-Xlw.c" , 77, "abort()")); /* #### - the call_data for the top_level | ||
| 78 | "menubar" widget_value used to be passed | ||
| 79 | back to the pre_hook. */ | ||
| 80 | |||
| 81 | if (instance->info->pre_activate_cb) | ||
| 82 | instance->info->pre_activate_cb (w, instance->info->id, call_data); | ||
| 83 | } | ||
| 84 | |||
| 85 | static void | ||
| 86 | pick_hook (Widget w, XtPointer client_data, XtPointer call_data) | ||
| 87 | { | ||
| 88 | widget_instance* instance = (widget_instance*)client_data; | ||
| 89 | widget_value* contents_val = (widget_value*)call_data; | ||
| 90 | widget_value* widget_val; | ||
| 91 | XtPointer widget_arg; | ||
| 92 | LWLIB_ID id; | ||
| 93 | lw_callback post_activate_cb; | ||
| 94 | |||
| 95 | if (w->core.being_destroyed) | ||
| 96 | return; | ||
| 97 | |||
| 98 | /* Grab these values before running any functions, in case running | ||
| 99 | the selection_cb causes the widget to be destroyed. */ | ||
| 100 | id = instance->info->id; | ||
| 101 | post_activate_cb = instance->info->post_activate_cb; | ||
| 102 | |||
| 103 | widget_val = lw_get_widget_value_for_widget (instance, w); | ||
| 104 | widget_arg = widget_val ? widget_val->call_data : NULL((void*)0); | ||
| 105 | |||
| 106 | if (instance->info->selection_cb && | ||
| 107 | contents_val && | ||
| 108 | contents_val->enabled && | ||
| 109 | !contents_val->contents) | ||
| 110 | instance->info->selection_cb (w, id, contents_val->call_data); | ||
| 111 | |||
| 112 | if (post_activate_cb) | ||
| 113 | post_activate_cb (w, id, widget_arg); | ||
| 114 | } | ||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | /* creation functions */ | ||
| 119 | static Widget | ||
| 120 | xlw_create_menubar (widget_instance* instance) | ||
| 121 | { | ||
| 122 | Arg al [1]; | ||
| 123 | Widget widget; | ||
| 124 | |||
| 125 | Xt_SET_ARG (al [0], XtNmenu, instance->info->val)do { ((void)( ((al [0])).name = ((String) ("menu")), ((al [0] )).value = (XtArgVal)((instance->info->val)) )); } while (0); | ||
| 126 | widget = XtCreateWidget (instance->info->name, xlwMenuWidgetClass, | ||
| 127 | instance->parent, al, 1); | ||
| 128 | XtAddCallback (widget, XtNopen"open", pre_hook, (XtPointer)instance); | ||
| 129 | XtAddCallback (widget, XtNselect"select", pick_hook, (XtPointer)instance); | ||
| 130 | return widget; | ||
| 131 | } | ||
| 132 | |||
| 133 | static Widget | ||
| 134 | xlw_create_popup_menu (widget_instance* instance) | ||
| 135 | { | ||
| 136 | Arg al [2]; | ||
| 137 | Widget popup_shell, widget; | ||
| 138 | |||
| 139 | popup_shell = XtCreatePopupShell (instance->info->name, | ||
| 140 | overrideShellWidgetClass, | ||
| 141 | instance->parent, NULL((void*)0), 0); | ||
| 142 | Xt_SET_ARG (al [0], XtNmenu, instance->info->val)do { ((void)( ((al [0])).name = ((String) ("menu")), ((al [0] )).value = (XtArgVal)((instance->info->val)) )); } while (0); | ||
| 143 | Xt_SET_ARG (al [1], XtNhorizontal, False)do { ((void)( ((al [1])).name = ((String) ("horizontal")), (( al [1])).value = (XtArgVal)((0)) )); } while (0); | ||
| 144 | widget = XtCreateManagedWidget ("popup", xlwMenuWidgetClass, | ||
| 145 | popup_shell, al, 2); | ||
| 146 | XtAddCallback (widget, XtNselect"select", pick_hook, (XtPointer)instance); | ||
| 147 | |||
| 148 | return popup_shell; | ||
| 149 | } | ||
| 150 | #endif /* LWLIB_MENUBARS_LUCID */ | ||
| 151 | |||
| 152 | #ifdef LWLIB_SCROLLBARS_LUCID1 | ||
| 153 | static void | ||
| 154 | xlw_scrollbar_callback (Widget widget, XtPointer closure, XtPointer call_data) | ||
| 155 | { | ||
| 156 | widget_instance *instance = (widget_instance *) closure; | ||
| 157 | LWLIB_ID id; | ||
| 158 | XlwScrollBarCallbackStruct *data = | ||
| 159 | (XlwScrollBarCallbackStruct *) call_data; | ||
| 160 | scroll_event event_data; | ||
| 161 | scrollbar_values *val; | ||
| 162 | double percent; | ||
| 163 | |||
| 164 | if (!instance || widget->core.being_destroyed) | ||
| 165 | return; | ||
| 166 | |||
| 167 | val = (scrollbar_values *) instance->info->val->scrollbar_data; | ||
| 168 | id = instance->info->id; | ||
| 169 | |||
| 170 | percent = (double) (data->value - 1) / (double) (INT_MAX2147483647 - 1); | ||
| 171 | event_data.slider_value = | ||
| 172 | (int) (percent * (double) (val->maximum - val->minimum)) + val->minimum; | ||
| 173 | |||
| 174 | if (event_data.slider_value > val->maximum - val->slider_size) | ||
| 175 | event_data.slider_value = val->maximum - val->slider_size; | ||
| 176 | else if (event_data.slider_value < val->minimum) | ||
| 177 | event_data.slider_value = val->minimum; | ||
| 178 | |||
| 179 | if (data->event) | ||
| 180 | { | ||
| 181 | switch (data->event->type) | ||
| 182 | { | ||
| 183 | case KeyPress2: | ||
| 184 | case KeyRelease3: | ||
| 185 | event_data.time = data->event->xkey.time; | ||
| 186 | break; | ||
| 187 | case ButtonPress4: | ||
| 188 | case ButtonRelease5: | ||
| 189 | event_data.time = data->event->xbutton.time; | ||
| 190 | break; | ||
| 191 | case MotionNotify6: | ||
| 192 | event_data.time = data->event->xmotion.time; | ||
| 193 | break; | ||
| 194 | case EnterNotify7: | ||
| 195 | case LeaveNotify8: | ||
| 196 | event_data.time = data->event->xcrossing.time; | ||
| 197 | break; | ||
| 198 | default: | ||
| 199 | event_data.time = 0; | ||
| 200 | break; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | else | ||
| 204 | event_data.time = 0; | ||
| 205 | |||
| 206 | switch (data->reason) | ||
| 207 | { | ||
| 208 | case XmCR_DECREMENT: event_data.action = SCROLLBAR_LINE_UP; break; | ||
| 209 | case XmCR_INCREMENT: event_data.action = SCROLLBAR_LINE_DOWN; break; | ||
| 210 | case XmCR_PAGE_DECREMENT: event_data.action = SCROLLBAR_PAGE_UP; break; | ||
| 211 | case XmCR_PAGE_INCREMENT: event_data.action = SCROLLBAR_PAGE_DOWN; break; | ||
| 212 | case XmCR_TO_TOP: event_data.action = SCROLLBAR_TOP; break; | ||
| 213 | case XmCR_TO_BOTTOM: event_data.action = SCROLLBAR_BOTTOM; break; | ||
| 214 | case XmCR_DRAG: event_data.action = SCROLLBAR_DRAG; break; | ||
| 215 | case XmCR_VALUE_CHANGED: event_data.action = SCROLLBAR_CHANGE; break; | ||
| 216 | default: event_data.action = SCROLLBAR_CHANGE; break; | ||
| 217 | } | ||
| 218 | |||
| 219 | if (instance->info->pre_activate_cb) | ||
| 220 | instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | ||
| 221 | } | ||
| 222 | |||
| 223 | #define add_scrollbar_callback(resource)XtAddCallback (scrollbar, resource, xlw_scrollbar_callback, ( XtPointer) instance) \ | ||
| 224 | XtAddCallback (scrollbar, resource, xlw_scrollbar_callback, (XtPointer) instance) | ||
| 225 | |||
| 226 | /* #### Does not yet support horizontal scrollbars. */ | ||
| 227 | static Widget | ||
| 228 | xlw_create_scrollbar (widget_instance *instance, int vertical) | ||
| 229 | { | ||
| 230 | Arg al[20]; | ||
| 231 | int ac = 0; | ||
| 232 | static XtCallbackRec callbacks[2] = | ||
| 233 | { {xlw_scrollbar_callback, NULL((void*)0)}, {NULL((void*)0), NULL((void*)0)} }; | ||
| 234 | |||
| 235 | callbacks[0].closure = (XtPointer) instance; | ||
| 236 | |||
| 237 | Xt_SET_ARG (al[ac], XmNminimum, 1)do { ((void)( ((al[ac])).name = ((String) ("minimum")), ((al[ ac])).value = (XtArgVal)((1)) )); } while (0); ac++; | ||
| 238 | Xt_SET_ARG (al[ac], XmNmaximum, INT_MAX)do { ((void)( ((al[ac])).name = ((String) ("maximum")), ((al[ ac])).value = (XtArgVal)((2147483647)) )); } while (0); ac++; | ||
| 239 | Xt_SET_ARG (al[ac], XmNincrement, 1)do { ((void)( ((al[ac])).name = ((String) ("increment")), ((al [ac])).value = (XtArgVal)((1)) )); } while (0); ac++; | ||
| 240 | Xt_SET_ARG (al[ac], XmNpageIncrement, 1)do { ((void)( ((al[ac])).name = ((String) ("pageIncrement")), ((al[ac])).value = (XtArgVal)((1)) )); } while (0); ac++; | ||
| 241 | Xt_SET_ARG (al[ac], XmNorientation, (vertical ? XmVERTICAL : XmHORIZONTAL))do { ((void)( ((al[ac])).name = ((String) ("orientation")), ( (al[ac])).value = (XtArgVal)(((vertical ? XmVERTICAL : XmHORIZONTAL ))) )); } while (0); ac++; | ||
| 242 | |||
| 243 | Xt_SET_ARG (al[ac], XmNdecrementCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("decrementCallback" )), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0 ); ac++; | ||
| 244 | Xt_SET_ARG (al[ac], XmNdragCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("dragCallback")), ( (al[ac])).value = (XtArgVal)((callbacks)) )); } while (0); ac++; | ||
| 245 | Xt_SET_ARG (al[ac], XmNincrementCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("incrementCallback" )), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0 ); ac++; | ||
| 246 | Xt_SET_ARG (al[ac], XmNpageDecrementCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("pageDecrementCallback" )), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0 ); ac++; | ||
| 247 | Xt_SET_ARG (al[ac], XmNpageIncrementCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("pageIncrementCallback" )), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0 ); ac++; | ||
| 248 | Xt_SET_ARG (al[ac], XmNtoBottomCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("toBottomCallback" )), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0 ); ac++; | ||
| 249 | Xt_SET_ARG (al[ac], XmNtoTopCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("toTopCallback")), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0); ac++; | ||
| 250 | Xt_SET_ARG (al[ac], XmNvalueChangedCallback, callbacks)do { ((void)( ((al[ac])).name = ((String) ("valueChangedCallback" )), ((al[ac])).value = (XtArgVal)((callbacks)) )); } while (0 ); ac++; | ||
| 251 | |||
| 252 | return XtCreateWidget (instance->info->name, xlwScrollBarWidgetClass, | ||
| 253 | instance->parent, al, ac); | ||
| 254 | } | ||
| 255 | |||
| 256 | static Widget | ||
| 257 | xlw_create_vertical_scrollbar (widget_instance *instance) | ||
| 258 | { | ||
| 259 | return xlw_create_scrollbar (instance, 1); | ||
| 260 | } | ||
| 261 | |||
| 262 | static Widget | ||
| 263 | xlw_create_horizontal_scrollbar (widget_instance *instance) | ||
| 264 | { | ||
| 265 | return xlw_create_scrollbar (instance, 0); | ||
| 266 | } | ||
| 267 | |||
| 268 | static void | ||
| 269 | xlw_update_scrollbar (widget_instance *UNUSED (instance)unused_instance __attribute__ ((unused)), Widget widget, | ||
| 270 | widget_value *val) | ||
| 271 | { | ||
| 272 | if (val->scrollbar_data) | ||
| 273 | { | ||
| 274 | scrollbar_values *data = val->scrollbar_data; | ||
| 275 | int widget_sliderSize, widget_val; | ||
| 276 | int new_sliderSize, new_value; | ||
| 277 | double percent; | ||
| 278 | Arg al [4]; | ||
| 279 | |||
| 280 | /* First size and position the scrollbar widget. */ | ||
| 281 | Xt_SET_ARG (al [0], XtNx, data->scrollbar_x)do { ((void)( ((al [0])).name = ((String) (((char*)&XtStrings [885]))), ((al [0])).value = (XtArgVal)((data->scrollbar_x )) )); } while (0); | ||
| 282 | Xt_SET_ARG (al [1], XtNy, data->scrollbar_y)do { ((void)( ((al [1])).name = ((String) (((char*)&XtStrings [887]))), ((al [1])).value = (XtArgVal)((data->scrollbar_y )) )); } while (0); | ||
| 283 | Xt_SET_ARG (al [2], XtNwidth, data->scrollbar_width)do { ((void)( ((al [2])).name = ((String) (((char*)&XtStrings [872]))), ((al [2])).value = (XtArgVal)((data->scrollbar_width )) )); } while (0); | ||
| 284 | Xt_SET_ARG (al [3], XtNheight, data->scrollbar_height)do { ((void)( ((al [3])).name = ((String) (((char*)&XtStrings [234]))), ((al [3])).value = (XtArgVal)((data->scrollbar_height )) )); } while (0); | ||
| 285 | XtSetValues (widget, al, 4); | ||
| 286 | |||
| 287 | /* Now size the scrollbar's slider. */ | ||
| 288 | Xt_SET_ARG (al [0], XmNsliderSize, &widget_sliderSize)do { ((void)( ((al [0])).name = ((String) ("sliderSize")), (( al [0])).value = (XtArgVal)((&widget_sliderSize)) )); } while (0); | ||
| 289 | Xt_SET_ARG (al [1], XmNvalue, &widget_val)do { ((void)( ((al [1])).name = ((String) ("value")), ((al [1 ])).value = (XtArgVal)((&widget_val)) )); } while (0); | ||
| 290 | XtGetValues (widget, al, 2); | ||
| 291 | |||
| 292 | percent = (double) data->slider_size / | ||
| 293 | (double) (data->maximum - data->minimum); | ||
| 294 | percent = (percent > 1.0 ? 1.0 : percent); | ||
| 295 | new_sliderSize = (int) ((double) (INT_MAX2147483647 - 1) * percent); | ||
| 296 | |||
| 297 | percent = (double) (data->slider_position - data->minimum) / | ||
| 298 | (double) (data->maximum - data->minimum); | ||
| 299 | percent = (percent > 1.0 ? 1.0 : percent); | ||
| 300 | new_value = (int) ((double) (INT_MAX2147483647 - 1) * percent); | ||
| 301 | |||
| 302 | if (new_sliderSize > INT_MAX2147483647 - 1) | ||
| 303 | new_sliderSize = INT_MAX2147483647 - 1; | ||
| 304 | else if (new_sliderSize < 1) | ||
| 305 | new_sliderSize = 1; | ||
| 306 | |||
| 307 | if (new_value > (INT_MAX2147483647 - new_sliderSize)) | ||
| 308 | new_value = INT_MAX2147483647 - new_sliderSize; | ||
| 309 | else if (new_value < 1) | ||
| 310 | new_value = 1; | ||
| 311 | |||
| 312 | if (new_sliderSize != widget_sliderSize || new_value != widget_val) | ||
| 313 | XlwScrollBarSetValues (widget, new_value, new_sliderSize, 1, 1, False0); | ||
| 314 | } | ||
| 315 | } | ||
| 316 | |||
| 317 | #endif /* LWLIB_SCROLLBARS_LUCID */ | ||
| 318 | |||
| 319 | #ifdef LWLIB_TABS_LUCID1 | ||
| 320 | /* tab control | ||
| 321 | |||
| 322 | [[ lwlib is such an incredible hairy crock. I just cannot believe | ||
| 323 | it! There are random dependencies between functions, there is a | ||
| 324 | total lack of genericity, even though it initially appears to be | ||
| 325 | generic. It should all be junked and begun again. Building tabs are | ||
| 326 | an example - in theory we should be able to reuse a lot of the | ||
| 327 | general stuff because we want to put labels of whatever toolkit we | ||
| 328 | are using in the tab. Instead we have to hack it by hand. ]] | ||
| 329 | While lwlib is a hairy crock, whoever wrote that seems to misunderstand | ||
| 330 | Falk's tab control widget. The tab control widget has *two* kinds of | ||
| 331 | children: *widgets*, which all occupy a *single* pane below the row of | ||
| 332 | tabs---this is where the labels created in build_tabs_in_widget go, and | ||
| 333 | *gadgets*, the tabs themselves, which do *not* draw themselves, but | ||
| 334 | rather are drawn by the control. In fact, in XEmacs the true widget | ||
| 335 | children are *never* visible! So this case is not a problem in the | ||
| 336 | design of lwlib, but rather of Falk's widget. -- sjt */ | ||
| 337 | static void | ||
| 338 | xlw_tab_control_callback (Widget w, XtPointer client_data, XtPointer call_data) | ||
| 339 | { | ||
| 340 | /* call data is the topmost widget */ | ||
| 341 | widget_instance* instance = (widget_instance*)client_data; | ||
| 342 | Widget top = (Widget)call_data; | ||
| 343 | char *name = XtName (top); | ||
| 344 | widget_value* widget_val; | ||
| 345 | XtPointer widget_arg; | ||
| 346 | LWLIB_ID id; | ||
| 347 | lw_callback post_activate_cb; | ||
| 348 | |||
| 349 | if (w->core.being_destroyed) | ||
| 350 | return; | ||
| 351 | |||
| 352 | /* Grab these values before running any functions, in case running | ||
| 353 | the selection_cb causes the widget to be destroyed. */ | ||
| 354 | id = instance->info->id; | ||
| 355 | post_activate_cb = instance->info->post_activate_cb; | ||
| 356 | |||
| 357 | /* search for the widget_val for the selected tab */ | ||
| 358 | for (widget_val = instance->info->val->contents; widget_val; | ||
| 359 | widget_val = widget_val->next) | ||
| 360 | { | ||
| 361 | if (!strcmp (widget_val->name, name)) | ||
| 362 | break; | ||
| 363 | } | ||
| 364 | |||
| 365 | widget_arg = widget_val ? widget_val->call_data : NULL((void*)0); | ||
| 366 | |||
| 367 | if (instance->info->selection_cb && | ||
| 368 | widget_val && | ||
| 369 | widget_val->enabled && | ||
| 370 | !widget_val->contents) | ||
| 371 | instance->info->selection_cb (w, id, widget_arg); | ||
| 372 | |||
| 373 | if (post_activate_cb) | ||
| 374 | post_activate_cb (w, id, widget_arg); | ||
| 375 | } | ||
| 376 | |||
| 377 | static Widget | ||
| 378 | xlw_create_tab_control (widget_instance *instance) | ||
| 379 | { | ||
| 380 | Arg al[20]; | ||
| 381 | int ac = 0; | ||
| 382 | Widget tab = 0; | ||
| 383 | widget_value* val = instance->info->val; | ||
| 384 | |||
| 385 | Xt_SET_ARG (al [ac], XtNsensitive, val->enabled)do { ((void)( ((al [ac])).name = ((String) (((char*)&XtStrings [711]))), ((al [ac])).value = (XtArgVal)((val->enabled)) ) ); } while (0); ac++; | ||
| 386 | Xt_SET_ARG (al [ac], XtNmappedWhenManaged, False)do { ((void)( ((al [ac])).name = ((String) (((char*)&XtStrings [453]))), ((al [ac])).value = (XtArgVal)((0)) )); } while (0); ac++; | ||
| 387 | Xt_SET_ARG (al [ac], XtNorientation, XtorientHorizontal)do { ((void)( ((al [ac])).name = ((String) (((char*)&XtStrings [505]))), ((al [ac])).value = (XtArgVal)((XtorientHorizontal) ) )); } while (0); ac++; | ||
| 388 | |||
| 389 | /* add any args the user supplied for creation time */ | ||
| 390 | lw_add_value_args_to_args (val, al, &ac); | ||
| 391 | |||
| 392 | tab = XtCreateManagedWidget (val->name, tabsWidgetClass, | ||
| 393 | instance->parent, al, ac); | ||
| 394 | XtRemoveAllCallbacks (tab, XtNcallback((char*)&XtStrings[136])); | ||
| 395 | XtAddCallback (tab, XtNcallback((char*)&XtStrings[136]), xlw_tab_control_callback, (XtPointer)instance); | ||
| 396 | |||
| 397 | XtManageChild (tab); | ||
| 398 | |||
| 399 | return tab; | ||
| 400 | } | ||
| 401 | |||
| 402 | static void build_tabs_in_widget (widget_instance* UNUSED (instance)unused_instance __attribute__ ((unused)), | ||
| 403 | Widget widget, widget_value* val) | ||
| 404 | { | ||
| 405 | widget_value* cur = val; | ||
| 406 | Arg al[1]; | ||
| 407 | |||
| 408 | /* Children are always invisible, don't permit resizing. */ | ||
| 409 | Xt_SET_ARG (al[0], XtNresizable, False)do { ((void)( ((al[0])).name = ((String) ("resizable")), ((al [0])).value = (XtArgVal)((0)) )); } while (0); | ||
| 410 | |||
| 411 | for (cur = val; cur; cur = cur->next) | ||
| 412 | { | ||
| 413 | if (cur->value) | ||
| 414 | { | ||
| 415 | Widget w; | ||
| 416 | #ifdef LWLIB_WIDGETS_MOTIF | ||
| 417 | w = xm_create_label (widget, cur); | ||
| 418 | #else | ||
| 419 | w = xaw_create_label (widget, cur); | ||
| 420 | #endif | ||
| 421 | XtSetValues (w, al, 1); | ||
| 422 | } | ||
| 423 | cur->change = NO_CHANGE; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | |||
| 427 | static void | ||
| 428 | xlw_update_tab_control (widget_instance* instance, Widget widget, widget_value* val) | ||
| 429 | { | ||
| 430 | Widget* children; | ||
| 431 | unsigned int num_children; | ||
| 432 | Dimension i; | ||
| 433 | widget_value *cur = 0; | ||
| 434 | |||
| 435 | XtRemoveAllCallbacks (widget, XtNcallback((char*)&XtStrings[136])); | ||
| 436 | XtAddCallback (widget, XtNcallback((char*)&XtStrings[136]), xlw_tab_control_callback, (XtPointer)instance); | ||
| 437 | |||
| 438 | if (val->change == STRUCTURAL_CHANGE | ||
| |||
| 439 | || | ||
| 440 | (val->contents && val->contents->change == STRUCTURAL_CHANGE)) | ||
| 441 | { | ||
| 442 | destroy_all_children (widget); | ||
| 443 | build_tabs_in_widget (instance, widget, val->contents); | ||
| 444 | } | ||
| 445 | |||
| 446 | children = XtCompositeChildren (widget, &num_children); | ||
| 447 | if (children) | ||
| |||
| 448 | { | ||
| 449 | for (i = 0, cur = val->contents; i < (int) num_children; i++) | ||
| |||
| 450 | { | ||
| 451 | if (!cur) | ||
| |||
| |||
| 452 | abort ()(assert_failed ("/home/jamesjer/Projects/xemacs/xemacs-21.5/lwlib/lwlib-Xlw.c" , 452, "abort()")); | ||
| 453 | if (children [i]->core.being_destroyed | ||
| 454 | || strcmp (XtName (children [i]), cur->name)) | ||
| |||
| 455 | continue; | ||
| 456 | #ifdef NEED_MOTIF | ||
| 457 | if (lw_motif_widget_p (children [i])) | ||
| 458 | xm_update_one_widget (instance, children [i], cur, False0); | ||
| 459 | #endif | ||
| 460 | #ifdef NEED_ATHENA1 | ||
| 461 | if (lw_xaw_widget_p (children [i])) | ||
| 462 | xaw_update_one_widget (instance, children [i], cur, False0); | ||
| 463 | #endif | ||
| 464 | cur = cur->next; | ||
| 465 | } | ||
| 466 | XtFree ((char *) children); | ||
| 467 | } | ||
| 468 | if (cur) | ||
| 469 | abort ()(assert_failed ("/home/jamesjer/Projects/xemacs/xemacs-21.5/lwlib/lwlib-Xlw.c" , 469, "abort()")); | ||
| 470 | } | ||
| 471 | #endif /* LWLIB_TABS_LUCID */ | ||
| 472 | |||
| 473 | #ifdef HAVE_X_WIDGETS | ||
| 474 | static Widget | ||
| 475 | xlw_create_clip_window (widget_instance *instance) | ||
| 476 | { | ||
| 477 | Arg al[20]; | ||
| 478 | int ac = 0; | ||
| 479 | Widget clip = 0; | ||
| 480 | widget_value* val = instance->info->val; | ||
| 481 | |||
| 482 | Xt_SET_ARG (al [ac], XtNmappedWhenManaged, False)do { ((void)( ((al [ac])).name = ((String) (((char*)&XtStrings [453]))), ((al [ac])).value = (XtArgVal)((0)) )); } while (0); ac++; | ||
| 483 | Xt_SET_ARG (al [ac], XtNsensitive, True)do { ((void)( ((al [ac])).name = ((String) (((char*)&XtStrings [711]))), ((al [ac])).value = (XtArgVal)((1)) )); } while (0); ac++; | ||
| 484 | /* add any args the user supplied for creation time */ | ||
| 485 | lw_add_value_args_to_args (val, al, &ac); | ||
| 486 | |||
| 487 | /* Create a clip window to contain the subwidget. Incredibly the | ||
| 488 | XEmacs manager seems to be the most appropriate widget for | ||
| 489 | this. Nothing else is simple enough and yet does what is | ||
| 490 | required. */ | ||
| 491 | clip = XtCreateManagedWidget (val->name, | ||
| 492 | emacsManagerWidgetClass, | ||
| 493 | instance->parent, al, ac); | ||
| 494 | |||
| 495 | return clip; | ||
| 496 | } | ||
| 497 | #endif | ||
| 498 | |||
| 499 | const widget_creation_entry | ||
| 500 | xlw_creation_table [] = | ||
| 501 | { | ||
| 502 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 503 | {"menubar", xlw_create_menubar}, | ||
| 504 | {"popup", xlw_create_popup_menu}, | ||
| 505 | #endif | ||
| 506 | #ifdef LWLIB_SCROLLBARS_LUCID1 | ||
| 507 | {"vertical-scrollbar", xlw_create_vertical_scrollbar}, | ||
| 508 | {"horizontal-scrollbar", xlw_create_horizontal_scrollbar}, | ||
| 509 | #endif | ||
| 510 | #ifdef LWLIB_TABS_LUCID1 | ||
| 511 | {"tab-control", xlw_create_tab_control}, | ||
| 512 | #endif | ||
| 513 | #ifdef HAVE_X_WIDGETS | ||
| 514 | {"clip-window", xlw_create_clip_window}, | ||
| 515 | #endif | ||
| 516 | {NULL((void*)0), NULL((void*)0)} | ||
| 517 | }; | ||
| 518 | |||
| 519 | Boolean | ||
| 520 | lw_lucid_widget_p (Widget widget) | ||
| 521 | { | ||
| 522 | WidgetClass the_class = XtClass (widget)((widget)->core.widget_class); | ||
| 523 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 524 | if (the_class == xlwMenuWidgetClass) | ||
| 525 | return True1; | ||
| 526 | #endif | ||
| 527 | #ifdef LWLIB_SCROLLBARS_LUCID1 | ||
| 528 | if (the_class == xlwScrollBarWidgetClass) | ||
| 529 | return True1; | ||
| 530 | #endif | ||
| 531 | #ifdef LWLIB_TABS_LUCID1 | ||
| 532 | if (the_class == tabsWidgetClass) | ||
| 533 | return True1; | ||
| 534 | #endif | ||
| 535 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 536 | if (the_class == overrideShellWidgetClass) | ||
| 537 | return | ||
| 538 | XtClass (((CompositeWidget)widget)->composite.children [0])((((CompositeWidget)widget)->composite.children [0])->core .widget_class) | ||
| 539 | == xlwMenuWidgetClass; | ||
| 540 | #endif | ||
| 541 | #ifdef HAVE_X_WIDGETS | ||
| 542 | if (the_class == emacsManagerWidgetClass) | ||
| 543 | return True1; | ||
| 544 | #endif | ||
| 545 | return False0; | ||
| 546 | } | ||
| 547 | |||
| 548 | void | ||
| 549 | xlw_update_one_widget (widget_instance* instance, Widget widget, | ||
| 550 | widget_value* val, Boolean UNUSED (deep_p)unused_deep_p __attribute__ ((unused))) | ||
| 551 | { | ||
| 552 | WidgetClass class_ = XtClass (widget)((widget)->core.widget_class); | ||
| 553 | |||
| 554 | if (0) | ||
| 555 | ; | ||
| 556 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 557 | else if (class_ == xlwMenuWidgetClass) | ||
| 558 | { | ||
| 559 | XlwMenuWidget mw; | ||
| 560 | if (XtIsShell (widget)(((Object)(widget))->object.widget_class->core_class.class_inited & 0x20)) | ||
| 561 | mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; | ||
| 562 | else | ||
| 563 | mw = (XlwMenuWidget)widget; | ||
| 564 | Xt_SET_VALUE (widget, XtNmenu, val)do { Arg al__; do { ((void)( ((al__)).name = ((String) ("menu" )), ((al__)).value = (XtArgVal)((val)) )); } while (0); XtSetValues (widget, &al__, 1); } while (0); /* #### mw unused! */ | ||
| 565 | } | ||
| 566 | #endif | ||
| 567 | #ifdef LWLIB_SCROLLBARS_LUCID1 | ||
| 568 | else if (class_ == xlwScrollBarWidgetClass) | ||
| 569 | { | ||
| 570 | xlw_update_scrollbar (instance, widget, val); | ||
| 571 | } | ||
| 572 | #endif | ||
| 573 | #ifdef LWLIB_TABS_LUCID1 | ||
| 574 | else if (class_ == tabsWidgetClass) | ||
| 575 | { | ||
| 576 | xlw_update_tab_control (instance, widget, val); | ||
| 577 | } | ||
| 578 | #endif | ||
| 579 | /* Lastly update our global arg values. */ | ||
| 580 | if (val->args && val->args->nargs) | ||
| 581 | XtSetValues (widget, val->args->args, val->args->nargs); | ||
| 582 | } | ||
| 583 | |||
| 584 | void | ||
| 585 | xlw_update_one_value (widget_instance* UNUSED (instance)unused_instance __attribute__ ((unused)), | ||
| 586 | Widget UNUSED (widget)unused_widget __attribute__ ((unused)), widget_value* UNUSED (val)unused_val __attribute__ ((unused))) | ||
| 587 | { | ||
| 588 | } | ||
| 589 | |||
| 590 | void | ||
| 591 | xlw_pop_instance (widget_instance* UNUSED (instance)unused_instance __attribute__ ((unused)), Boolean UNUSED (up)unused_up __attribute__ ((unused))) | ||
| 592 | { | ||
| 593 | } | ||
| 594 | |||
| 595 | #ifdef LWLIB_MENUBARS_LUCID1 | ||
| 596 | void | ||
| 597 | xlw_popup_menu (Widget widget, XEvent *event) | ||
| 598 | { | ||
| 599 | XlwMenuWidget mw; | ||
| 600 | |||
| 601 | if (!XtIsShell (widget)(((Object)(widget))->object.widget_class->core_class.class_inited & 0x20)) | ||
| 602 | return; | ||
| 603 | |||
| 604 | if (event->type == ButtonPress4 || event->type == ButtonRelease5) | ||
| 605 | { | ||
| 606 | mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; | ||
| 607 | xlw_pop_up_menu (mw, (XButtonPressedEvent *)event); | ||
| 608 | } | ||
| 609 | else | ||
| 610 | abort ()(assert_failed ("/home/jamesjer/Projects/xemacs/xemacs-21.5/lwlib/lwlib-Xlw.c" , 610, "abort()")); | ||
| 611 | } | ||
| 612 | #endif /* LWLIB_MENUBARS_LUCID */ | ||
| 613 | |||
| 614 | /* Destruction of instances */ | ||
| 615 | void | ||
| 616 | xlw_destroy_instance (widget_instance* instance) | ||
| 617 | { | ||
| 618 | if (instance->widget) | ||
| 619 | XtDestroyWidget (instance->widget); | ||
| 620 | } |