1 /* -*- c++ -*- 2 FILE: WidgetsX.h 3 RCS REVISION: $Revision: 1.13 $ 4 5 COPYRIGHT: (c) 1999 -- 2003 Melinda Green, Don Hatch, and Jay Berkenbilt - Superliminal Software 6 7 LICENSE: Free to use and modify for non-commercial purposes as long as the 8 following conditions are adhered to: 9 1) Obvious credit for the source of this code and the designs it embodies 10 are clearly made, and 11 2) Ports and derived versions of 4D Magic Cube programs are not distributed 12 without the express written permission of the authors. 13 14 DESCRIPTION: 15 This is the Athena Widgets version of the Widgets interface. 16 */ 17 18 #ifndef WIDGETSX_H 19 #define WIDGETSX_H 20 21 #include "Widgets.h" 22 23 #include <X11/Intrinsic.h> 24 #include <X11/StringDefs.h> 25 #include <X11/Shell.h> 26 27 #include <map> 28 29 class WidgetsX; 30 class MacroManager; // XXX 31 32 class WidgetsX: public Widgets 33 { 34 public: 35 WidgetsX(Preferences&, EventHandler*, 36 Widget toplevel, Widget& drawingwindow); 37 virtual ~WidgetsX(); 38 39 // ButtonData* is an array 40 virtual void addMenuButton(char *name, int nbuttons, ButtonData*); 41 virtual void addButton(ButtonData); 42 virtual char* getMacroName(int i); 43 virtual void* addMacro(char* name, void* prev_ui_data); 44 virtual void removeMacro(void* ui_data); 45 46 // Create a dialog box with up to three buttons. 47 virtual void createDialog(char *s, int nbuttons, ButtonData*); 48 virtual void destroyDialog(); 49 50 virtual void updateFastButton(int fast_automoves); 51 52 virtual void debuggingHack(MacroManager*); 53 54 private: 55 class MacroUIData 56 { 57 public: MacroUIData(Widget box,Widget apply,Widget invert,MacroUIData * prev)58 MacroUIData(Widget box, Widget apply, Widget invert, 59 MacroUIData* prev) : 60 box(box), 61 apply(apply), 62 invert(invert), 63 prev(prev), 64 next(0) 65 { 66 } 67 Widget box; 68 Widget apply; 69 Widget invert; 70 MacroUIData* prev; 71 MacroUIData* next; 72 }; 73 74 static int const MAX_DIALOGS = 10;// maximum simultaneous dialog boxes 75 76 EventHandler* event_handler; 77 78 Widget buttonbox; 79 Widget macrosform; 80 Widget toplevel; 81 Widget bigform; 82 Widget drawingwindow; 83 Widget deletebutton; 84 Widget macrocontrols; 85 Widget fast_toggle; 86 static XtActionsRec actions[]; 87 88 Widget transientshells[MAX_DIALOGS]; 89 EventHandler::Callback** dialog_callbacks[MAX_DIALOGS]; 90 int cur_transientshell; 91 92 static std::map<Widget, MacroUIData*> apply_to_ui_data; 93 static std::map<Widget, MacroUIData*> invert_to_ui_data; 94 95 // Functions that we wish were part of Xt 96 97 // Use this function to get the size of a widget that's not 98 // managed yet. 99 static void XtForceDimensionsOfUnmanagedWidget(Widget w); 100 static void XtGetLowerRight(Widget w, Position *x, Position *y); 101 static void XtSetLowerRight(Widget w, Position x, Position y); 102 static void XtGetCenter(Widget w, Position *x, Position *y); 103 static void XtSetCenter(Widget w, Position x, Position y); 104 105 static void macroApply_cb(Widget, XtPointer arg, XtPointer); 106 static void macroInvert_cb(Widget, XtPointer arg, XtPointer); 107 static void callCallback(Widget, XtPointer arg, XtPointer); 108 109 void resizeToplevelToMatchBigform(); 110 void createMacrosForm(); 111 }; 112 113 #endif 114 115 // Local Variables: 116 // c-basic-offset: 4 117 // c-comment-only-line-offset: 0 118 // c-file-offsets: ((defun-block-intro . +) (block-open . 0) (substatement-open . 0) (statement-cont . +) (statement-case-open . +4) (arglist-intro . +) (arglist-close . +) (inline-open . 0)) 119 // indent-tabs-mode: nil 120 // End: 121