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