| 1 |
#ifndef _GuiP_h_ |
| 2 |
#define _GuiP_h_ |
| 3 |
/* GuiP.h |
| 4 |
* |
| 5 |
* Copyright (C) 1993-2013,2015-2018,2020,2022-2024 Paul Boersma |
| 6 |
* |
| 7 |
* This code is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This code is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 |
* See the GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "Gui.h" |
| 22 |
|
| 23 |
void _GuiObject_position (GuiObject me, int left, int right, int top, int bottom, GuiForm parent); |
| 24 |
void * _GuiObject_getUserData (GuiObject me); |
| 25 |
void _GuiObject_setUserData (GuiObject me, void *userData); |
| 26 |
|
| 27 |
class GuiControlBlockValueChangedCallbacks { |
| 28 |
private: |
| 29 |
GuiControl d_control; |
| 30 |
public: |
| 31 |
GuiControlBlockValueChangedCallbacks (GuiControl control) : d_control (control) { |
| 32 |
d_control -> d_blockValueChangedCallbacks = true; |
| 33 |
} |
| 34 |
~GuiControlBlockValueChangedCallbacks () { |
| 35 |
d_control -> d_blockValueChangedCallbacks = false; |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
#if gtk |
| 40 |
void GuiGtk_initialize (); |
| 41 |
#elif motif |
| 42 |
#include <windows.h> |
| 43 |
#include <commctrl.h> |
| 44 |
|
| 45 |
#define MEMBER(widget,klas) ((widget -> widgetClass & xm##klas##WidgetClass) != 0) |
| 46 |
#define MEMBER2(widget,klas1,klas2) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass)) != 0) |
| 47 |
#define MEMBER3(widget,klas1,klas2,klas3) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass | xm##klas3##WidgetClass)) != 0) |
| 48 |
#define MEMBER4(widget,klas1,klas2,klas3,klas4) ((widget -> widgetClass & (xm##klas1##WidgetClass | xm##klas2##WidgetClass | xm##klas3##WidgetClass | xm##klas4##WidgetClass)) != 0) |
| 49 |
#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) |
| 50 |
|
| 51 |
#define MAXNUM_CALLBACKS 3 /* E.g., maximum number of activate callbacks for a PushButton. */ |
| 52 |
|
| 53 |
typedef struct { |
| 54 |
struct { XtCallbackProc proc; XtPointer closure; } pairs [MAXNUM_CALLBACKS]; |
| 55 |
} XtCallbackList; |
| 56 |
|
| 57 |
class structGuiObject { |
| 58 |
public: |
| 59 |
integer magicNumber; |
| 60 |
uinteger widgetClass; |
| 61 |
GuiObject parent, previousSibling, nextSibling, firstChild; |
| 62 |
autostring32 name; |
| 63 |
bool inMenu, nativized, managed, insensitive; |
| 64 |
GuiObject textFocus; /* For shells. */ |
| 65 |
GuiObject shell; /* My shell ancestor. */ |
| 66 |
|
| 67 |
/* Native. */ |
| 68 |
|
| 69 |
HWND window; |
| 70 |
union { |
| 71 |
/* XtShell: */ |
| 72 |
struct { GuiObject menuBar; int uniqueItemID, duringMoveWindow; } shell; |
| 73 |
|
| 74 |
/* XmPushButton (if in menu), XmToggleButton (if in menu), XmCascadeButton (if in menu): */ |
| 75 |
struct { HMENU handle; ULONG_PTR id; } entry; |
| 76 |
|
| 77 |
/* XmMenuBar, XmPulldownMenu: */ |
| 78 |
struct { HMENU handle; ULONG_PTR id; } menu; |
| 79 |
} nat; |
| 80 |
|
| 81 |
/* Motif */ |
| 82 |
|
| 83 |
union { |
| 84 |
struct { GuiObject horizontalBar, verticalBar, clipWindow, workWindow; } scrolledWindow; |
| 85 |
struct { bool active, isDialog, canFullScreen; |
| 86 |
uinteger lowAccelerators [8]; XtCallbackProc goAwayCallback; XtPointer goAwayClosure; } shell; |
| 87 |
struct { unsigned char acceleratorChar; int acceleratorModifiers; } pushButton; |
| 88 |
struct { int inBar; } cascadeButton; |
| 89 |
struct { unsigned char acceleratorChar; int acceleratorModifiers; XtCallbackList valueChangedCallbacks; } toggleButton; |
| 90 |
struct { XtCallbackList valueChangedCallbacks, dragCallbacks; } scrollBar; |
| 91 |
} motiff; |
| 92 |
|
| 93 |
/* Resources. */ |
| 94 |
|
| 95 |
int x, y, width, height; |
| 96 |
bool isRadioButton; /* For radio buttons and check buttons. */ |
| 97 |
int radioBehavior, rowColumnType; /* For row-columns. */ |
| 98 |
int orientation; /* For row-columns and scroll bars. */ |
| 99 |
GuiObject defaultButton, cancelButton; /* For forms and shells. */ |
| 100 |
int dialogStyle; /* For forms and shells. */ |
| 101 |
GuiObject messageText; /* For message boxes. */ |
| 102 |
bool autoUnmanage; /* For bulletin boards. */ |
| 103 |
GuiObject subMenuId, popUpButton; /* For cascade buttons and their menus. */ |
| 104 |
integer increment, pageIncrement, sliderSize; /* For scroll bars. */ |
| 105 |
integer minimum, maximum, value; /* For scales and scroll bars. */ |
| 106 |
|
| 107 |
XtCallbackProc activateCallback, destroyCallback; |
| 108 |
XtPointer activateClosure, destroyClosure; |
| 109 |
int leftAttachment, rightAttachment, topAttachment, bottomAttachment; |
| 110 |
int leftOffset, rightOffset, topOffset, bottomOffset; |
| 111 |
int leftPosition, rightPosition, topPosition, bottomPosition; |
| 112 |
int deleteResponse; /* For shells. */ |
| 113 |
void *userData; |
| 114 |
}; |
| 115 |
|
| 116 |
extern struct Gui { |
| 117 |
GuiObject textFocus; |
| 118 |
bool duringUpdate; |
| 119 |
HINSTANCE instance; // first argument of WinMain |
| 120 |
int commandShow; // another argument of WinMain |
| 121 |
} theGui; |
| 122 |
|
| 123 |
void _Gui_callCallbacks (GuiObject w, XtCallbackList *callbacks, XtPointer call); |
| 124 |
char32 * _GuiWin_getDrawingAreaClassName (void); |
| 125 |
|
| 126 |
GuiObject _Gui_initializeWidget (int widgetClass, GuiObject parent, conststring32 name); |
| 127 |
void _Gui_invalidateWidget (GuiObject me); |
| 128 |
void _Gui_validateWidget (GuiObject me); |
| 129 |
void _Gui_manageScrolledWindow (GuiObject me); |
| 130 |
void _GuiNativeControl_check (GuiObject me, Boolean value); |
| 131 |
void _GuiNativeControl_destroy (GuiObject me); |
| 132 |
void _GuiNativeControl_setTitle (GuiObject me); |
| 133 |
void _GuiNativeControl_show (GuiObject me); |
| 134 |
void _GuiNativeControl_hide (GuiObject me); |
| 135 |
void _GuiNativeControl_setSensitive (GuiObject me); |
| 136 |
char32 * _GuiWin_expandAmpersands (conststring32 title); |
| 137 |
|
| 138 |
/********** GuiButton.cpp **********/ |
| 139 |
void _GuiWinButton_destroy (GuiObject widget); |
| 140 |
void _GuiWinButton_handleClick (GuiObject widget); |
| 141 |
bool _GuiWinButton_tryToHandleShortcutKey (GuiObject widget); |
| 142 |
|
| 143 |
/********** GuiCheckButton.cpp **********/ |
| 144 |
void _GuiWinCheckButton_destroy (GuiObject widget); |
| 145 |
void _GuiWinCheckButton_handleClick (GuiObject widget); |
| 146 |
|
| 147 |
/********** GuiDrawingArea.cpp **********/ |
| 148 |
void _GuiWinDrawingArea_destroy (GuiObject widget); |
| 149 |
void _GuiWinDrawingArea_update (GuiObject widget); |
| 150 |
void _GuiWinDrawingArea_handleMouse (GuiObject widget, structGuiDrawingArea_MouseEvent::Phase phase, int x, int y); |
| 151 |
void _GuiWinDrawingArea_handleKey (GuiObject widget, TCHAR kar); |
| 152 |
void _GuiWinDrawingArea_shellResize (GuiObject widget); |
| 153 |
void _GuiWinDrawingArea_handleZoom (GuiObject widget, double delta); |
| 154 |
|
| 155 |
/********** GuiLabel.cpp **********/ |
| 156 |
void _GuiWinLabel_destroy (GuiObject widget); |
| 157 |
|
| 158 |
/********** GuiList.cpp **********/ |
| 159 |
void _GuiWinList_destroy (GuiObject widget); |
| 160 |
void _GuiWinList_map (GuiObject widget); |
| 161 |
void _GuiWinList_destroy (GuiObject widget); |
| 162 |
void _GuiWinList_handleClick (GuiObject widget); |
| 163 |
|
| 164 |
/********** GuiMenuItem.cpp **********/ |
| 165 |
void _GuiWinMenuItem_setText (GuiObject widget); |
| 166 |
|
| 167 |
/********** GuiRadioButton.cpp **********/ |
| 168 |
void _GuiWinRadioButton_destroy (GuiObject widget); |
| 169 |
void _GuiWinRadioButton_handleClick (GuiObject widget); |
| 170 |
|
| 171 |
/********** GuiScale.cpp **********/ |
| 172 |
void _GuiWinScale_destroy (GuiObject widget); |
| 173 |
|
| 174 |
/********** GuiScrollBar.cpp **********/ |
| 175 |
void _GuiWinScrollBar_destroy (GuiObject widget); |
| 176 |
|
| 177 |
/********** GuiScrolledWindow.cpp **********/ |
| 178 |
void _GuiWinScrolledWindow_destroy (GuiObject widget); |
| 179 |
|
| 180 |
/********** GuiText.cpp **********/ |
| 181 |
void _GuiWinText_destroy (GuiObject widget); |
| 182 |
void _GuiWinText_map (GuiObject widget); |
| 183 |
void _GuiText_handleFocusReception (GuiObject widget); |
| 184 |
void _GuiText_handleFocusLoss (GuiObject widget); |
| 185 |
void _GuiText_setTheTextFocus (GuiObject widget); |
| 186 |
void _GuiText_handleValueChanged (GuiObject widget); |
| 187 |
void _GuiText_unmanage (GuiObject widget); |
| 188 |
void _GuiText_init (); |
| 189 |
void _GuiText_exit (); |
| 190 |
|
| 191 |
#endif |
| 192 |
|
| 193 |
|
| 194 |
/********** FONTS, BRUSHES **********/ |
| 195 |
|
| 196 |
#if defined (macintosh) |
| 197 |
extern NSFont *theMacGuiNormalLabelFont (), *theMacGuiBoldLabelFont (); |
| 198 |
#elif defined (_WIN32) |
| 199 |
extern HFONT theWinGuiNormalLabelFont (), theWinGuiBoldLabelFont (); |
| 200 |
extern HBRUSH theWinGuiBackgroundBrush (); |
| 201 |
#endif |
| 202 |
|
| 203 |
/* End of file GuiP.h */ |
| 204 |
#endif |