1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
|
#ifndef _GuiP_h_
#define _GuiP_h_
/* GuiP.h
*
* Copyright (C) 1993-2011,2012 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Gui.h"
/*
* In GUI implementations, we order everything by ease of programming: Unix, Windows, Macintosh.
*/
#if defined (UNIX)
#define uni 1
#define win 0
#define mac 0
#endif
#if defined (_WIN32)
#define uni 0
#define win 1
#define mac 0
#endif
#if defined (macintosh)
#define uni 0
#define win 0
#define mac 1
#endif
void _GuiObject_position (GuiObject me, int left, int right, int top, int bottom);
void * _GuiObject_getUserData (GuiObject me);
void _GuiObject_setUserData (GuiObject me, void *userData);
#if gtk
#elif motif
#if win
#include <windows.h>
#include <commctrl.h>
#endif
#if win || mac
/*
#define MEMBER(widget,klas) (widget -> widgetClass == xm##klas##WidgetClass)
#define MEMBER2(widget,klas1,klas2) (MEMBER (widget, klas1) || MEMBER (widget, klas2))
#define MEMBER3(widget,klas1,klas2,klas3) (MEMBER2 (widget, klas1, klas2) || MEMBER (widget, klas3))
#define MEMBER4(widget,klas1,klas2,klas3,klas4) (MEMBER3 (widget, klas1, klas2, klas3) || MEMBER (widget, klas4))
#define MEMBER5(widget,klas1,klas2,klas3,klas4,klas5) (MEMBER4 (widget, klas1, klas2, klas3, klas4) || MEMBER (widget, klas5))
*/
#define MEMBER(widget,klas) ((widget -> widgetClass & xm##klas##WidgetClass) != 0)
#define MEMBER2(widget,klas1,klas2) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass)) != 0)
#define MEMBER3(widget,klas1,klas2,klas3) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass | xm##klas3##WidgetClass)) != 0)
#define MEMBER4(widget,klas1,klas2,klas3,klas4) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass | xm##klas3##WidgetClass | xm##klas4##WidgetClass)) != 0)
#define MEMBER5(widget,klas1,klas2,klas3,klas4,klas5) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass | xm##klas3##WidgetClass | xm##klas4##WidgetClass | xm##klas5##WidgetClass)) != 0)
#define MAXNUM_CALLBACKS 3 /* E.g., maximum number of activate callbacks for a PushButton. */
typedef struct {
struct { XtCallbackProc proc; XtPointer closure; } pairs [MAXNUM_CALLBACKS];
} XtCallbackList;
class structGuiObject {
public:
long magicNumber;
unsigned long widgetClass;
GuiObject parent, previousSibling, nextSibling, firstChild;
wchar_t *name;
bool inMenu, nativized, managed, insensitive;
GuiObject textFocus; /* For shells. */
GuiObject shell; /* My shell ancestor. */
/* Native. */
#if win
HWND window;
union {
/* XtShell: */
struct { GuiObject menuBar; int uniqueItemID, duringMoveWindow; } shell;
/* XmPushButton (if in menu), XmToggleButton (if in menu), XmCascadeButton (if in menu): */
struct { HMENU handle; ULONG_PTR id; } entry;
/* XmMenuBar, XmPulldownMenu: */
struct { HMENU handle; ULONG_PTR id; } menu;
} nat;
#elif mac
Rect rect; /* Window coordinates. */
WindowPtr macWindow;
bool isControl;
struct {
/* XtShell: */
struct { WindowPtr ptr; ControlRef rootControl; } window;
/* XmPushButton (if not in menu), XmToggleButton (if not in menu), XmScrollBar, XmLabel (sometimes), XmCascadeButton (if not in menu or bar): */
struct { ControlHandle handle; bool isBevel, isPopup; } control;
/* XmPushButton (if in menu), XmToggleButton (if in menu), XmCascadeButton (if in menu): */
struct { MenuHandle handle; int item; } entry;
/* XmPulldownMenu: */
struct { MenuHandle handle; int item /* if cascading */; int id; } menu;
} nat;
#endif
/* Motif */
union {
struct { GuiObject horizontalBar, verticalBar, clipWindow, workWindow; } scrolledWindow;
struct { XtCallbackList moveCallbacks; } drawingArea;
struct { bool active, isDialog, canFullScreen;
unsigned long lowAccelerators [8]; XtCallbackProc goAwayCallback; XtPointer goAwayClosure; } shell;
struct { unsigned char acceleratorChar; int acceleratorModifiers; } pushButton;
struct { int inBar; } cascadeButton;
struct { unsigned char acceleratorChar; int acceleratorModifiers; XtCallbackList valueChangedCallbacks; } toggleButton;
struct { XtCallbackList valueChangedCallbacks, dragCallbacks; } scrollBar;
} motiff;
/* Resources. */
int x, y, width, height;
bool isRadioButton; /* For radio buttons and check buttons. */
int radioBehavior, rowColumnType; /* For row-columns. */
int orientation; /* For row-columns and scroll bars. */
GuiObject defaultButton, cancelButton; /* For forms and shells. */
int dialogStyle; /* For forms and shells. */
GuiObject messageText; /* For message boxes. */
bool autoUnmanage; /* For bulletin boards. */
GuiObject subMenuId, popUpButton; /* For cascade buttons and their menus. */
long increment, pageIncrement, sliderSize; /* For scroll bars. */
long minimum, maximum, value; /* For scales and scroll bars. */
XtCallbackProc activateCallback, destroyCallback;
XtPointer activateClosure, destroyClosure;
int leftAttachment, rightAttachment, topAttachment, bottomAttachment;
int leftOffset, rightOffset, topOffset, bottomOffset;
int leftPosition, rightPosition, topPosition, bottomPosition;
int deleteResponse; /* For shells. */
void *userData;
};
#define my me ->
extern struct Gui {
GuiObject textFocus;
bool duringUpdate;
#if win
HINSTANCE instance; /* First argument of WinMain. */
#elif mac
WindowPtr modalDialog;
#endif
} theGui;
void _Gui_callCallbacks (GuiObject w, XtCallbackList *callbacks, XtPointer call);
#if mac
void _GuiMac_clipOnParent (GuiObject me);
void _GuiMac_clipOffValid (GuiObject me);
void _GuiMac_clipOffInvalid (GuiObject me);
#elif win
wchar_t * _GuiWin_getDrawingAreaClassName (void);
#endif
GuiObject _Gui_initializeWidget (int widgetClass, GuiObject parent, const wchar_t *name);
void _Gui_invalidateWidget (GuiObject me);
void _Gui_validateWidget (GuiObject me);
void _Gui_manageScrolledWindow (GuiObject me);
void _GuiNativeControl_check (GuiObject me, Boolean value);
void _GuiNativeControl_destroy (GuiObject me);
void _GuiNativeControl_setFont (GuiObject me, int style, int size);
void _GuiNativeControl_setTitle (GuiObject me);
void _GuiNativeControl_show (GuiObject me);
void _GuiNativeControl_hide (GuiObject me);
void _GuiNativeControl_setSensitive (GuiObject me);
wchar_t * _GuiWin_expandAmpersands (const wchar_t *title);
/********** GuiButton.cpp **********/
#if win
void _GuiWinButton_destroy (GuiObject widget);
void _GuiWinButton_handleClick (GuiObject widget);
bool _GuiWinButton_tryToHandleShortcutKey (GuiObject widget);
#elif mac
void _GuiMacButton_destroy (GuiObject widget);
void _GuiMacButton_handleClick (GuiObject widget, EventRecord *macEvent);
bool _GuiMacButton_tryToHandleShortcutKey (GuiObject widget, EventRecord *macEvent);
#endif
/********** GuiCheckButton.cpp **********/
#if win
void _GuiWinCheckButton_destroy (GuiObject widget);
void _GuiWinCheckButton_handleClick (GuiObject widget);
#elif mac
void _GuiMacCheckButton_destroy (GuiObject widget);
void _GuiMacCheckButton_handleClick (GuiObject widget, EventRecord *macEvent);
#endif
/********** GuiDrawingArea.cpp **********/
#if win
void _GuiWinDrawingArea_destroy (GuiObject widget);
void _GuiWinDrawingArea_update (GuiObject widget);
void _GuiWinDrawingArea_handleClick (GuiObject widget, int x, int y);
void _GuiWinDrawingArea_handleKey (GuiObject widget, TCHAR kar);
void _GuiWinDrawingArea_shellResize (GuiObject widget);
#elif mac
void _GuiMacDrawingArea_destroy (GuiObject widget);
void _GuiMacDrawingArea_update (GuiObject widget);
void _GuiMacDrawingArea_handleClick (GuiObject widget, EventRecord *macEvent);
bool _GuiMacDrawingArea_tryToHandleKey (GuiObject widget, EventRecord *macEvent);
void _GuiMacDrawingArea_shellResize (GuiObject widget);
#endif
/********** GuiLabel.cpp **********/
#if win
void _GuiWinLabel_destroy (GuiObject widget);
#elif mac
void _GuiMacLabel_destroy (GuiObject widget);
#endif
/********** GuiList.cpp **********/
#if win
void _GuiWinList_destroy (GuiObject widget);
void _GuiWinList_map (GuiObject widget);
void _GuiWinList_destroy (GuiObject widget);
void _GuiWinList_handleClick (GuiObject widget);
#elif mac
void _GuiMacList_destroy (GuiObject widget);
void _GuiMacList_map (GuiObject widget);
void _GuiMacList_activate (GuiObject widget, bool activate);
void _GuiMacList_handleClick (GuiObject widget, EventRecord *event);
void _GuiMacList_handleControlClick (GuiObject widget, EventRecord *event);
void _GuiMacList_move (GuiObject widget);
void _GuiMacList_resize (GuiObject widget);
void _GuiMacList_shellResize (GuiObject widget);
void _GuiMacList_update (GuiObject widget, RgnHandle visRgn);
#endif
/********** GuiRadioButton.cpp **********/
#if win
void _GuiWinRadioButton_destroy (GuiObject widget);
void _GuiWinRadioButton_handleClick (GuiObject widget);
#elif mac
void _GuiMacRadioButton_destroy (GuiObject widget);
void _GuiMacRadioButton_handleClick (GuiObject widget, EventRecord *macEvent);
#endif
/********** GuiText.cpp **********/
#if win
void _GuiWinText_destroy (GuiObject widget);
void _GuiWinText_map (GuiObject widget);
#elif mac
void _GuiMacText_destroy (GuiObject widget);
void _GuiMacText_map (GuiObject widget);
#endif
void _GuiText_handleFocusReception (GuiObject widget);
void _GuiText_handleFocusLoss (GuiObject widget);
#if mac
void _GuiMac_clearTheTextFocus (void);
#endif
void _GuiText_setTheTextFocus (GuiObject widget);
void _GuiText_handleValueChanged (GuiObject widget);
void _GuiText_unmanage (GuiObject widget);
#if mac
void _GuiMacText_move (GuiObject widget);
void _GuiMacText_shellResize (GuiObject widget);
void _GuiMacText_resize (GuiObject widget);
void _GuiMacText_update (GuiObject widget);
int _GuiMacText_tryToHandleKey (EventHandlerCallRef eventHandlerCallRef, EventRef eventRef, GuiObject widget, unsigned char keyCode, unsigned char charCode, EventRecord *event);
int _GuiMacText_tryToHandleReturnKey (EventHandlerCallRef eventHandlerCallRef, EventRef eventRef, GuiObject widget, EventRecord *event);
int _GuiMacText_tryToHandleClipboardShortcut (EventHandlerCallRef eventHandlerCallRef, EventRef eventRef, GuiObject widget, unsigned char charCode, EventRecord *event);
void _GuiMacText_handleClick (GuiObject widget, EventRecord *event);
void _GuiMac_makeTextCaretBlink (void);
#endif
void _GuiText_init (void);
void _GuiText_exit (void);
#endif
#endif
/* End of file GuiP.h */
#endif
|