diff options
| author | Pavel Janík | 2002-04-25 05:44:56 +0000 |
|---|---|---|
| committer | Pavel Janík | 2002-04-25 05:44:56 +0000 |
| commit | 557c29061e63a23d7a950416c496b16dcdf9d360 (patch) | |
| tree | ec8b8366a4c224e318a162adc17007df34beff11 | |
| parent | 9e2b2e3071102e98f088d880fa0bcf4cb15c733a (diff) | |
| download | emacs-557c29061e63a23d7a950416c496b16dcdf9d360.tar.gz emacs-557c29061e63a23d7a950416c496b16dcdf9d360.zip | |
Remove file.
| -rw-r--r-- | lwlib/lwlib-Xol.c | 320 | ||||
| -rw-r--r-- | lwlib/lwlib-Xol.h | 29 | ||||
| -rw-r--r-- | lwlib/lwlib-Xolmb.c | 374 | ||||
| -rw-r--r-- | lwlib/lwlib-Xolmb.h | 26 | ||||
| -rw-r--r-- | lwlib/lwlib-XolmbP.h | 50 |
5 files changed, 0 insertions, 799 deletions
diff --git a/lwlib/lwlib-Xol.c b/lwlib/lwlib-Xol.c deleted file mode 100644 index b89bf243653..00000000000 --- a/lwlib/lwlib-Xol.c +++ /dev/null | |||
| @@ -1,320 +0,0 @@ | |||
| 1 | |||
| 2 | #include "../src/lisp.h" | ||
| 3 | |||
| 4 | #include "lwlib-Xol.h" | ||
| 5 | #include <X11/StringDefs.h> | ||
| 6 | #include <X11/IntrinsicP.h> | ||
| 7 | #include <X11/CompositeP.h> | ||
| 8 | #include <X11/Shell.h> | ||
| 9 | #include <Xol/Menu.h> | ||
| 10 | #include <Xol/OpenLook.h> | ||
| 11 | #include <Xol/MenuButton.h> | ||
| 12 | #include <Xol/OblongButt.h> | ||
| 13 | #include <Xol/ControlAre.h> | ||
| 14 | #include <Xol/Stub.h> | ||
| 15 | #include <Xol/StaticText.h> | ||
| 16 | |||
| 17 | /* forward declarations */ | ||
| 18 | static void | ||
| 19 | update_menu_widget (widget_instance* instance, Widget widget, | ||
| 20 | widget_value* val); | ||
| 21 | |||
| 22 | /* Menu callbacks */ | ||
| 23 | static void | ||
| 24 | pre_hook (Widget w, caddr_t client_data, caddr_t call_data) | ||
| 25 | { | ||
| 26 | OlVirtualEvent ve = (OlVirtualEvent)call_data; | ||
| 27 | widget_instance* instance = (widget_instance*)client_data; | ||
| 28 | |||
| 29 | if (w->core.being_destroyed) | ||
| 30 | return; | ||
| 31 | |||
| 32 | if (XtParent (w) == instance->widget) | ||
| 33 | { | ||
| 34 | if (ve->xevent->type == ButtonPress && instance->info->pre_activate_cb) | ||
| 35 | instance->info->pre_activate_cb (instance->widget, instance->info->id, | ||
| 36 | NULL); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | static void | ||
| 41 | post_hook (Widget w, caddr_t client_data, caddr_t call_data) | ||
| 42 | { | ||
| 43 | widget_instance* instance = (widget_instance*)client_data; | ||
| 44 | |||
| 45 | if (w->core.being_destroyed) | ||
| 46 | return; | ||
| 47 | |||
| 48 | if (instance->info->post_activate_cb) | ||
| 49 | instance->info->post_activate_cb (w, instance->info->id, NULL); | ||
| 50 | } | ||
| 51 | |||
| 52 | static void | ||
| 53 | pick_hook (Widget w, caddr_t client_data, caddr_t call_data) | ||
| 54 | { | ||
| 55 | widget_instance* instance = 0; | ||
| 56 | widget_value* val = (widget_value*)client_data; | ||
| 57 | |||
| 58 | if (w->core.being_destroyed) | ||
| 59 | return; | ||
| 60 | |||
| 61 | XtVaGetValues (w, XtNuserData, &instance, 0); | ||
| 62 | |||
| 63 | if (!instance) | ||
| 64 | return; | ||
| 65 | |||
| 66 | if (instance->info->selection_cb && val && val->enabled | ||
| 67 | && !val->contents) | ||
| 68 | instance->info->selection_cb (w, instance->info->id, val->call_data); | ||
| 69 | } | ||
| 70 | |||
| 71 | /* creation functions */ | ||
| 72 | static Widget | ||
| 73 | xol_create_menubar (widget_instance* instance) | ||
| 74 | { | ||
| 75 | Widget widget = | ||
| 76 | XtVaCreateWidget (instance->info->name, controlAreaWidgetClass, | ||
| 77 | instance->parent, 0); | ||
| 78 | return widget; | ||
| 79 | } | ||
| 80 | |||
| 81 | static Widget | ||
| 82 | xol_create_popup_menu (widget_instance* instance) | ||
| 83 | { | ||
| 84 | Widget popup_shell = | ||
| 85 | XtCreatePopupShell (instance->info->name, menuShellWidgetClass, | ||
| 86 | instance->parent, NULL, 0); | ||
| 87 | return popup_shell; | ||
| 88 | } | ||
| 89 | |||
| 90 | widget_creation_entry | ||
| 91 | xol_creation_table [] = | ||
| 92 | { | ||
| 93 | {"menubar", xol_create_menubar}, | ||
| 94 | {"popup", xol_create_popup_menu}, | ||
| 95 | {NULL, NULL} | ||
| 96 | }; | ||
| 97 | |||
| 98 | Widget | ||
| 99 | xol_create_dialog (widget_instance* instance) | ||
| 100 | { | ||
| 101 | return NULL; | ||
| 102 | } | ||
| 103 | |||
| 104 | Boolean | ||
| 105 | lw_olit_widget_p (Widget widget) | ||
| 106 | { | ||
| 107 | return True; | ||
| 108 | } | ||
| 109 | |||
| 110 | /* update functions */ | ||
| 111 | static void | ||
| 112 | destroy_all_children (Widget widget) | ||
| 113 | { | ||
| 114 | Widget* children; | ||
| 115 | unsigned int number; | ||
| 116 | int i; | ||
| 117 | |||
| 118 | children = (Widget *) XtCompositeChildren (widget, &number); | ||
| 119 | if (children) | ||
| 120 | { | ||
| 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++) | ||
| 124 | { | ||
| 125 | Widget child = children [i]; | ||
| 126 | if (!child->core.being_destroyed) | ||
| 127 | { | ||
| 128 | XtUnmanageChild (child); | ||
| 129 | XtDestroyWidget (child); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | XtFree (children); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | static Boolean | ||
| 137 | all_dashes_p (char* s) | ||
| 138 | { | ||
| 139 | char* t; | ||
| 140 | for (t = s; *t; t++) | ||
| 141 | if (*t != '-') | ||
| 142 | return False; | ||
| 143 | return True; | ||
| 144 | } | ||
| 145 | |||
| 146 | static void | ||
| 147 | make_menu_in_widget (widget_instance* instance, Widget widget, | ||
| 148 | widget_value* val) | ||
| 149 | { | ||
| 150 | widget_value* cur; | ||
| 151 | Widget button; | ||
| 152 | Arg al [256]; | ||
| 153 | int ac; | ||
| 154 | String label; | ||
| 155 | |||
| 156 | for (cur = val; cur; cur = cur->next) | ||
| 157 | { | ||
| 158 | ac = 0; | ||
| 159 | XtSetArg (al [ac], XtNsensitive, cur->enabled); ac++; | ||
| 160 | XtSetArg (al [ac], XtNuserData, instance); ac++; | ||
| 161 | XtSetArg (al [ac], XtNacceleratorText, cur->key); ac++; | ||
| 162 | |||
| 163 | /* label = (char *) resource_string (widget, cur->name);*/ | ||
| 164 | label = cur->name; | ||
| 165 | if (label) | ||
| 166 | { | ||
| 167 | XtSetArg (al [ac], XtNlabel, label); ac++; | ||
| 168 | } | ||
| 169 | |||
| 170 | if (all_dashes_p (cur->name)) | ||
| 171 | { | ||
| 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); | ||
| 176 | } | ||
| 177 | else if (!cur->contents) | ||
| 178 | { | ||
| 179 | if (!cur->call_data) | ||
| 180 | button = | ||
| 181 | XtCreateManagedWidget (cur->name, staticTextWidgetClass, widget, | ||
| 182 | al, ac); | ||
| 183 | else | ||
| 184 | { | ||
| 185 | button = | ||
| 186 | XtCreateManagedWidget (cur->name, oblongButtonWidgetClass, | ||
| 187 | widget, al, ac); | ||
| 188 | XtAddCallback (button, XtNselect, pick_hook, cur); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | else | ||
| 192 | { | ||
| 193 | Widget menu = NULL; | ||
| 194 | button = | ||
| 195 | XtCreateManagedWidget (cur->name, menuButtonWidgetClass, widget, | ||
| 196 | al, ac); | ||
| 197 | XtVaGetValues (button, XtNmenuPane, &menu, 0); | ||
| 198 | if (!menu) | ||
| 199 | abort (); | ||
| 200 | make_menu_in_widget (instance, menu, cur->contents); | ||
| 201 | OlAddCallback (button, XtNconsumeEvent, pre_hook, instance); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | static void | ||
| 207 | update_one_menu_entry (widget_instance* instance, Widget widget, | ||
| 208 | widget_value* val) | ||
| 209 | { | ||
| 210 | Arg al [256]; | ||
| 211 | int ac; | ||
| 212 | Widget menu; | ||
| 213 | widget_value* contents; | ||
| 214 | |||
| 215 | if (val->change == NO_CHANGE) | ||
| 216 | return; | ||
| 217 | |||
| 218 | /* update the sensitivity */ | ||
| 219 | XtVaSetValues (widget, XtNsensitive, val->enabled, 0); | ||
| 220 | |||
| 221 | /* update the pulldown/pullaside as needed */ | ||
| 222 | ac = 0; | ||
| 223 | menu = NULL; | ||
| 224 | XtVaGetValues (widget, XtNmenuPane, &menu, 0); | ||
| 225 | contents = val->contents; | ||
| 226 | |||
| 227 | if (!menu) | ||
| 228 | { | ||
| 229 | if (contents) | ||
| 230 | { | ||
| 231 | /* in OLIT this would have to be a structural change on the | ||
| 232 | button. */ | ||
| 233 | abort (); | ||
| 234 | } | ||
| 235 | } | ||
| 236 | else if (!contents) | ||
| 237 | { | ||
| 238 | /* in OLIT this would have to be a structural change on the button. */ | ||
| 239 | abort (); | ||
| 240 | } | ||
| 241 | else if (contents->change != NO_CHANGE) | ||
| 242 | update_menu_widget (instance, menu, val); | ||
| 243 | } | ||
| 244 | |||
| 245 | static void | ||
| 246 | update_menu_widget (widget_instance* instance, Widget widget, | ||
| 247 | widget_value* val) | ||
| 248 | |||
| 249 | { | ||
| 250 | if (val->change == STRUCTURAL_CHANGE | ||
| 251 | || val->contents->change == STRUCTURAL_CHANGE) | ||
| 252 | { | ||
| 253 | destroy_all_children (widget); | ||
| 254 | make_menu_in_widget (instance, widget, val->contents); | ||
| 255 | } | ||
| 256 | else | ||
| 257 | { | ||
| 258 | /* Update all the buttons of the composite widget in order. */ | ||
| 259 | Widget* children; | ||
| 260 | unsigned int num_children; | ||
| 261 | int i; | ||
| 262 | widget_value* cur; | ||
| 263 | |||
| 264 | children = (Widget *) XtCompositeChildren (widget, &num_children); | ||
| 265 | if (children) | ||
| 266 | { | ||
| 267 | for (i = 0, cur = val->contents; i < num_children; i++) | ||
| 268 | { | ||
| 269 | if (!cur) | ||
| 270 | abort (); | ||
| 271 | if (children [i]->core.being_destroyed | ||
| 272 | || strcmp (XtName (children [i]), cur->name)) | ||
| 273 | continue; | ||
| 274 | update_one_menu_entry (instance, children [i], cur); | ||
| 275 | cur = cur->next; | ||
| 276 | } | ||
| 277 | XtFree (children); | ||
| 278 | } | ||
| 279 | if (cur) | ||
| 280 | abort (); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | void | ||
| 285 | xol_update_one_widget (widget_instance* instance, Widget widget, | ||
| 286 | widget_value* val, Boolean deep_p) | ||
| 287 | { | ||
| 288 | Widget menu = widget; | ||
| 289 | |||
| 290 | if (XtIsShell (widget)) | ||
| 291 | XtVaGetValues (widget, XtNmenuPane, &menu, 0); | ||
| 292 | |||
| 293 | update_menu_widget (instance, menu, val); | ||
| 294 | } | ||
| 295 | |||
| 296 | void | ||
| 297 | xol_update_one_value (widget_instance* instance, Widget widget, | ||
| 298 | widget_value* val) | ||
| 299 | { | ||
| 300 | return; | ||
| 301 | } | ||
| 302 | |||
| 303 | void | ||
| 304 | xol_pop_instance (widget_instance* instance, Boolean up) | ||
| 305 | { | ||
| 306 | } | ||
| 307 | |||
| 308 | void | ||
| 309 | xol_popup_menu (Widget widget) | ||
| 310 | { | ||
| 311 | OlMenuPost (widget); | ||
| 312 | } | ||
| 313 | |||
| 314 | /* Destruction of instances */ | ||
| 315 | void | ||
| 316 | xol_destroy_instance (widget_instance* instance) | ||
| 317 | { | ||
| 318 | XtDestroyWidget (instance->widget); | ||
| 319 | } | ||
| 320 | |||
diff --git a/lwlib/lwlib-Xol.h b/lwlib/lwlib-Xol.h deleted file mode 100644 index 3bf8d11e9e3..00000000000 --- a/lwlib/lwlib-Xol.h +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | #ifndef LWLIB_XOL_H | ||
| 2 | #define LWLIB_XOL_H | ||
| 3 | |||
| 4 | #include "lwlib-int.h" | ||
| 5 | |||
| 6 | extern widget_creation_entry xol_creation_table []; | ||
| 7 | extern Widget xol_create_dialog (widget_instance *); | ||
| 8 | |||
| 9 | Boolean | ||
| 10 | lw_olit_widget_p (Widget widget); | ||
| 11 | |||
| 12 | void | ||
| 13 | xol_update_one_widget (widget_instance* instance, Widget widget, | ||
| 14 | widget_value* val, Boolean deep_p); | ||
| 15 | |||
| 16 | void | ||
| 17 | xol_update_one_value (widget_instance* instance, Widget widget, | ||
| 18 | widget_value* val); | ||
| 19 | |||
| 20 | void | ||
| 21 | xol_destroy_instance (widget_instance* instance); | ||
| 22 | |||
| 23 | void | ||
| 24 | xol_pop_instance (widget_instance* instance, Boolean up); | ||
| 25 | |||
| 26 | void | ||
| 27 | xol_popup_menu (Widget widget); | ||
| 28 | |||
| 29 | #endif /* LWLIB_XOL_H */ | ||
diff --git a/lwlib/lwlib-Xolmb.c b/lwlib/lwlib-Xolmb.c deleted file mode 100644 index cc63ebcd39e..00000000000 --- a/lwlib/lwlib-Xolmb.c +++ /dev/null | |||
| @@ -1,374 +0,0 @@ | |||
| 1 | /* An OLIT menubar widget, by Chuck Thompson <cthomp@cs.uiuc.edu> | ||
| 2 | Copyright (C) 1993 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 1, 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 GNU Emacs; 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 | |||
| 22 | #include "../src/lisp.h" | ||
| 23 | |||
| 24 | #include <X11/IntrinsicP.h> | ||
| 25 | #include <X11/Intrinsic.h> | ||
| 26 | #include <X11/CompositeP.h> | ||
| 27 | #include <X11/Composite.h> | ||
| 28 | #include "lwlib-Xol-mbP.h" | ||
| 29 | #include "lwlib-Xol-mb.h" | ||
| 30 | |||
| 31 | #define HORIZ_SPACING 4 | ||
| 32 | #define VERT_SPACING 4 | ||
| 33 | |||
| 34 | static void Initialize(); | ||
| 35 | static void Resize(); | ||
| 36 | static void ChangeManaged(); | ||
| 37 | static Boolean SetValues(); | ||
| 38 | static XtGeometryResult GeometryManager(); | ||
| 39 | static XtGeometryResult PreferredSize(); | ||
| 40 | static void do_layout(); | ||
| 41 | static XtGeometryResult try_layout(); | ||
| 42 | |||
| 43 | lwMenuBarClassRec lwMenubarClassRec = | ||
| 44 | { | ||
| 45 | { | ||
| 46 | /* core_class members */ | ||
| 47 | |||
| 48 | (WidgetClass) &compositeClassRec, /* superclass */ | ||
| 49 | "Menubar", /* class_name */ | ||
| 50 | sizeof(lwMenuBarRec), /* widget_size */ | ||
| 51 | NULL, /* class_initialize */ | ||
| 52 | NULL, /* class_part_initialize */ | ||
| 53 | FALSE, /* class_inited */ | ||
| 54 | Initialize, /* initialize */ | ||
| 55 | NULL, /* initialize_hook */ | ||
| 56 | XtInheritRealize, /* realize */ | ||
| 57 | NULL, /* actions */ | ||
| 58 | 0, /* num_actions */ | ||
| 59 | NULL, /* resources */ | ||
| 60 | 0, /* num_resources */ | ||
| 61 | NULLQUARK, /* xrm_class */ | ||
| 62 | TRUE, /* compress_motion */ | ||
| 63 | XtExposeCompressMaximal, /* compress_exposure */ | ||
| 64 | TRUE, /* compress_enterleave */ | ||
| 65 | FALSE, /* visible_interest */ | ||
| 66 | NULL, /* destroy */ | ||
| 67 | Resize, /* resize */ | ||
| 68 | NULL, /* expose */ | ||
| 69 | NULL, /* set_values */ | ||
| 70 | NULL, /* set_values_hook */ | ||
| 71 | XtInheritSetValuesAlmost, /* set_values_almost */ | ||
| 72 | NULL, /* get_values_hook */ | ||
| 73 | NULL, /* accept_focus */ | ||
| 74 | XtVersion, /* version */ | ||
| 75 | NULL, /* callback_private */ | ||
| 76 | NULL, /* tm_table */ | ||
| 77 | PreferredSize, /* query_geometry */ | ||
| 78 | NULL, /* display_accelerator */ | ||
| 79 | NULL, /* extension */ | ||
| 80 | }, | ||
| 81 | { | ||
| 82 | /* composite_class members */ | ||
| 83 | |||
| 84 | GeometryManager, /* geometry_manager */ | ||
| 85 | ChangeManaged, /* change_managed */ | ||
| 86 | XtInheritInsertChild, /* insert_child */ | ||
| 87 | XtInheritDeleteChild, /* delete_child */ | ||
| 88 | NULL, /* extension */ | ||
| 89 | }, | ||
| 90 | { | ||
| 91 | /* Menubar class members */ | ||
| 92 | |||
| 93 | 0, /* empty */ | ||
| 94 | } | ||
| 95 | }; | ||
| 96 | WidgetClass lwMenubarWidgetClass = (WidgetClass) &lwMenubarClassRec; | ||
| 97 | |||
| 98 | |||
| 99 | static void Initialize (request, new) | ||
| 100 | lwMenuBarWidget request, new; | ||
| 101 | { | ||
| 102 | if (request->core.width <= 0) | ||
| 103 | new->core.width = 1; | ||
| 104 | if (request->core.height <= 0) | ||
| 105 | new->core.height = 23; | ||
| 106 | } | ||
| 107 | |||
| 108 | static void | ||
| 109 | Resize (w) | ||
| 110 | lwMenuBarWidget w; | ||
| 111 | { | ||
| 112 | do_layout(w); | ||
| 113 | } | ||
| 114 | |||
| 115 | static void | ||
| 116 | do_layout (parent) | ||
| 117 | lwMenuBarWidget parent; | ||
| 118 | { | ||
| 119 | Widget child; | ||
| 120 | int cnt; | ||
| 121 | int managed_children = 0; | ||
| 122 | int managed_width = 0; | ||
| 123 | int new_pos = 0; | ||
| 124 | |||
| 125 | /* | ||
| 126 | * Determine number of children which will fit on one line. | ||
| 127 | * For now we ignore the rest, making sure they are unmanaged. | ||
| 128 | */ | ||
| 129 | |||
| 130 | cnt = 0; | ||
| 131 | while ((cnt < (int) parent->composite.num_children) && | ||
| 132 | (managed_width < (int) parent->core.width)) | ||
| 133 | { | ||
| 134 | child = parent->composite.children[cnt++]; | ||
| 135 | managed_children++; | ||
| 136 | managed_width += child->core.width + child->core.border_width * 2 + | ||
| 137 | HORIZ_SPACING; | ||
| 138 | } | ||
| 139 | |||
| 140 | if (managed_width > (int) parent->core.width) | ||
| 141 | managed_children--; | ||
| 142 | |||
| 143 | /* | ||
| 144 | * Correct positioning of children. | ||
| 145 | */ | ||
| 146 | |||
| 147 | cnt = 0; | ||
| 148 | while (managed_children) | ||
| 149 | { | ||
| 150 | child = parent->composite.children[cnt++]; | ||
| 151 | |||
| 152 | if (!child->core.managed) | ||
| 153 | XtManageChild (child); | ||
| 154 | |||
| 155 | if ((child->core.x != new_pos) || (child->core.y != 0)) | ||
| 156 | XtMoveWidget (child, new_pos, 0); | ||
| 157 | new_pos += child->core.width + child->core.border_width * 2 + | ||
| 158 | HORIZ_SPACING; | ||
| 159 | |||
| 160 | managed_children--; | ||
| 161 | } | ||
| 162 | |||
| 163 | /* | ||
| 164 | * Make sure all remaining children are unmanaged. | ||
| 165 | */ | ||
| 166 | |||
| 167 | while (cnt < parent->composite.num_children) | ||
| 168 | { | ||
| 169 | child = parent->composite.children[cnt]; | ||
| 170 | |||
| 171 | if (child->core.managed) | ||
| 172 | XtUnmanageChild (child); | ||
| 173 | |||
| 174 | if ((child->core.x != parent->core.width) || | ||
| 175 | (child->core.y != parent->core.height)) | ||
| 176 | XtMoveWidget (child, parent->core.width, parent->core.height); | ||
| 177 | |||
| 178 | cnt++; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 182 | |||
| 183 | static XtGeometryResult | ||
| 184 | PreferredSize (w, request, preferred) | ||
| 185 | lwMenuBarWidget w; | ||
| 186 | XtWidgetGeometry *request, *preferred; | ||
| 187 | { | ||
| 188 | Widget child; | ||
| 189 | int cnt; | ||
| 190 | |||
| 191 | /* | ||
| 192 | * If no changes are being made to the width or height, just agree. | ||
| 193 | */ | ||
| 194 | |||
| 195 | if (!(request->request_mode & CWWidth) && | ||
| 196 | !(request->request_mode & CWHeight)) | ||
| 197 | return (XtGeometryYes); | ||
| 198 | |||
| 199 | /* | ||
| 200 | * Right now assume everything goes in one row. Calculate the | ||
| 201 | * minimum required width and height. | ||
| 202 | */ | ||
| 203 | |||
| 204 | preferred->width = 0; | ||
| 205 | preferred->height = 0; | ||
| 206 | |||
| 207 | for (cnt = 0; cnt < w->composite.num_children; cnt++) | ||
| 208 | { | ||
| 209 | child = w->composite.children[cnt]; | ||
| 210 | if (child->core.managed) | ||
| 211 | { | ||
| 212 | preferred->width += child->core.width + child->core.border_width*2 + | ||
| 213 | HORIZ_SPACING; | ||
| 214 | if (preferred->height < (Dimension) (child->core.height + | ||
| 215 | child->core.border_width * 2)) | ||
| 216 | preferred->height = child->core.height + | ||
| 217 | child->core.border_width * 2; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | preferred->request_mode = CWWidth | CWHeight; | ||
| 222 | |||
| 223 | /* | ||
| 224 | * Case: both height and width requested | ||
| 225 | */ | ||
| 226 | |||
| 227 | if ((request->request_mode & CWWidth) && | ||
| 228 | (request->request_mode & CWHeight)) | ||
| 229 | { | ||
| 230 | /* | ||
| 231 | * Ok if same or bigger. | ||
| 232 | */ | ||
| 233 | |||
| 234 | if (preferred->width <= request->width && | ||
| 235 | preferred->height <= request->height) | ||
| 236 | { | ||
| 237 | preferred->width = request->width; | ||
| 238 | return (XtGeometryYes); | ||
| 239 | } | ||
| 240 | |||
| 241 | /* | ||
| 242 | * If both dimensions are too small, say no. | ||
| 243 | */ | ||
| 244 | |||
| 245 | else | ||
| 246 | if (preferred->width > request->width && | ||
| 247 | preferred->height > request->height) | ||
| 248 | return (XtGeometryNo); | ||
| 249 | |||
| 250 | /* | ||
| 251 | * Otherwise one must be right, so say almost. | ||
| 252 | */ | ||
| 253 | |||
| 254 | else | ||
| 255 | return (XtGeometryAlmost); | ||
| 256 | } | ||
| 257 | |||
| 258 | /* | ||
| 259 | * If only one dimension is requested, either its OK or it isn't. | ||
| 260 | */ | ||
| 261 | |||
| 262 | else | ||
| 263 | { | ||
| 264 | if (request->request_mode & CWWidth) | ||
| 265 | { | ||
| 266 | if (preferred->width <= request->width) | ||
| 267 | { | ||
| 268 | preferred->width = request->width; | ||
| 269 | return (XtGeometryYes); | ||
| 270 | } | ||
| 271 | else | ||
| 272 | return (XtGeometryNo); | ||
| 273 | } | ||
| 274 | else if (request->request_mode & CWHeight) | ||
| 275 | { | ||
| 276 | if (preferred->height <= request->height) | ||
| 277 | { | ||
| 278 | return (XtGeometryYes); | ||
| 279 | } | ||
| 280 | else | ||
| 281 | return (XtGeometryNo); | ||
| 282 | } | ||
| 283 | |||
| 284 | return (XtGeometryYes); | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | |||
| 289 | static XtGeometryResult | ||
| 290 | GeometryManager (w, request, reply) | ||
| 291 | Widget w; | ||
| 292 | XtWidgetGeometry *request; | ||
| 293 | XtWidgetGeometry *reply; | ||
| 294 | { | ||
| 295 | |||
| 296 | lwMenuBarWidget parent = (lwMenuBarWidget) w->core.parent; | ||
| 297 | |||
| 298 | /* | ||
| 299 | * If the widget wants to move, just say no. | ||
| 300 | */ | ||
| 301 | |||
| 302 | if ((request->request_mode & CWX && request->x != w->core.x) || | ||
| 303 | (request->request_mode & CWY && request->y != w->core.y)) | ||
| 304 | return (XtGeometryNo); | ||
| 305 | |||
| 306 | /* | ||
| 307 | * Since everything "fits" for now, grant all requests. | ||
| 308 | */ | ||
| 309 | |||
| 310 | if (request->request_mode & CWWidth) | ||
| 311 | w->core.width = request->width; | ||
| 312 | if (request->request_mode & CWHeight) | ||
| 313 | w->core.height = request->height; | ||
| 314 | if (request->request_mode & CWBorderWidth) | ||
| 315 | w->core.border_width = request->border_width; | ||
| 316 | |||
| 317 | do_layout (parent); | ||
| 318 | return (XtGeometryYes); | ||
| 319 | } | ||
| 320 | |||
| 321 | |||
| 322 | static XtGeometryResult | ||
| 323 | try_layout (parent) | ||
| 324 | lwMenuBarWidget parent; | ||
| 325 | { | ||
| 326 | Widget child; | ||
| 327 | int cnt; | ||
| 328 | int managed_children = 0; | ||
| 329 | int managed_width = 0; | ||
| 330 | int new_pos = 0; | ||
| 331 | |||
| 332 | /* | ||
| 333 | * Determine number of children which will fit on one line. | ||
| 334 | * For now we ignore the rest, making sure they are unmanaged. | ||
| 335 | */ | ||
| 336 | |||
| 337 | cnt = 0; | ||
| 338 | while ((cnt < (int) parent->composite.num_children) && | ||
| 339 | (managed_width < (int) parent->core.width)) | ||
| 340 | { | ||
| 341 | child = parent->composite.children[cnt++]; | ||
| 342 | if (child->core.managed) | ||
| 343 | { | ||
| 344 | managed_children++; | ||
| 345 | managed_width += child->core.width + child->core.border_width * 2 + | ||
| 346 | HORIZ_SPACING; | ||
| 347 | } | ||
| 348 | } | ||
| 349 | |||
| 350 | if (managed_width > (int) parent->core.width) | ||
| 351 | return (XtGeometryNo); | ||
| 352 | else | ||
| 353 | return (XtGeometryYes); | ||
| 354 | } | ||
| 355 | |||
| 356 | |||
| 357 | |||
| 358 | static void | ||
| 359 | ChangeManaged (w) | ||
| 360 | lwMenuBarWidget w; | ||
| 361 | { | ||
| 362 | XtGeometryResult result; | ||
| 363 | |||
| 364 | result = try_layout (w); | ||
| 365 | |||
| 366 | if (result != XtGeometryYes) | ||
| 367 | { | ||
| 368 | XtUnmanageChild (w->composite.children[w->composite.num_children - 1]); | ||
| 369 | XtMoveWidget (w->composite.children[w->composite.num_children-1], | ||
| 370 | w->core.width, w->core.height); | ||
| 371 | } | ||
| 372 | |||
| 373 | do_layout (w); | ||
| 374 | } | ||
diff --git a/lwlib/lwlib-Xolmb.h b/lwlib/lwlib-Xolmb.h deleted file mode 100644 index d2ce13b3ecb..00000000000 --- a/lwlib/lwlib-Xolmb.h +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 1 | /* An OLIT menubar widget, by Chuck Thompson <cthomp@cs.uiuc.edu> | ||
| 2 | Copyright (C) 1993 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 1, 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 GNU Emacs; 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 | #ifndef LW_MENUBAR_H | ||
| 22 | #define LW_MENUBAR_H | ||
| 23 | extern WidgetClass lwMenubarWidgetClass; | ||
| 24 | typedef struct _lwMenuBarClassRec *lwMenuBarWidgetClass; | ||
| 25 | typedef struct _lwMenuBarRec *lwMenuBarWidget; | ||
| 26 | #endif /* LW_MENUBAR_H */ | ||
diff --git a/lwlib/lwlib-XolmbP.h b/lwlib/lwlib-XolmbP.h deleted file mode 100644 index 84267dbc6b8..00000000000 --- a/lwlib/lwlib-XolmbP.h +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | /* An OLIT menubar widget, by Chuck Thompson <cthomp@cs.uiuc.edu> | ||
| 2 | Copyright (C) 1993 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 1, 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 GNU Emacs; 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 | #ifndef LW_MENUBARP_H | ||
| 22 | #define LW_MENUBARP_H | ||
| 23 | |||
| 24 | typedef struct _lwMenuBarClassPart | ||
| 25 | { | ||
| 26 | int ignore; | ||
| 27 | } lwMenuBarClassPart; | ||
| 28 | |||
| 29 | typedef struct _lwMenuBarClassRec | ||
| 30 | { | ||
| 31 | CoreClassPart core_class; | ||
| 32 | CompositeClassPart composite_class; | ||
| 33 | lwMenuBarClassPart menubar_class; | ||
| 34 | } lwMenuBarClassRec; | ||
| 35 | |||
| 36 | extern lwMenuBarClassRec lwMenubarClassRec; | ||
| 37 | |||
| 38 | typedef struct | ||
| 39 | { | ||
| 40 | int empty; | ||
| 41 | } lwMenuBarPart; | ||
| 42 | |||
| 43 | typedef struct _lwMenuBarRec | ||
| 44 | { | ||
| 45 | CorePart core; | ||
| 46 | CompositePart composite; | ||
| 47 | lwMenuBarPart menubar; | ||
| 48 | } lwMenuBarRec; | ||
| 49 | |||
| 50 | #endif /* LW_MENUBARP_H */ | ||