2 * dialogs.h -- shared variables for generic dialog popup
4 * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
5 * ------------------------------------------------------------------------
7 * GNU XBoard 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 3 of the License, or (at
10 * your option) any later version.
12 * GNU XBoard 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. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see http://www.gnu.org/licenses/. *
20 *------------------------------------------------------------------------
21 ** See the file ChangeLog for a revision history. */
23 // [HGM] Some remarks about the generic dialog creator of XBoard:
24 // GenericPopUp is needed to create a dialog from the lists of options supplied by the engines.
25 // But once it is there, it provides a very easy way for creating other settings dialogs as well,
26 // by letting XBoard provide its own, compiled-in lists of XBoard options (located in dialogs.c).
27 // The Option struct uses the following fields (E = for engine options, X = for XBoard options):
28 // Option types | XBoard-only ->
29 // TYPE NAME spin check string combo button box label list graph menu break end
30 // int value E E (h) X/E [w] (h) (h)
31 // int min X/E (2) (3) (1) (1) (1) (1) (3) (1) (4)
32 // int max X/E (w) (w) (w) (w) (w) (w) (w) (w)
33 // void* handle X/E X/E X/E X/E X/E X X X X X
34 // void* target X X X X/C C X X C C
35 // char* textValue E X/E *
36 // char ** choice X/E * X
37 // enum type X/E X/E X/E X/E X X X X X X X X
38 // char[] name X/E X/E X/E X/E X X X X X
39 // File and Path options are like String (but get a browse button added in the dialog), and Slider
40 // is like Spin. Menu can be PopUp or PopDown; both need the COMBO_CALLBACK bit (3) set!
41 // (h) or (w) means the field optionally (when non-null) specifies the height or width of the main
42 // control element (excluding accompanying description texts). [w] means the width is written there.
43 // C specifies the 'target' is a user-supplied callback function, which will be executed when the
44 // option is exercised.
47 /* Flags Option.min used (2) for TextBox (-string): */
48 #define T_VSCRL (1 << 0)
49 #define T_HSCRL (1 << 1)
50 #define T_FILL (1 << 2)
51 #define T_WRAP (1 << 3)
52 #define T_TOP (1 << 4)
54 /* Flags Option.min used (3) for ComboBox (-combo) and menus (PopUp, PopDown): */
55 #define COMBO_CALLBACK (1 << 8)
56 #define NO_GETTEXT (1 << 2)
58 /* Flags for Option.min used (1) for Button, SaveButton, ListBox, Label: */
59 #define SAME_ROW (1 << 0) /* also in Break & EndMark */
60 #define BORDER (1 << 1) /* Label */
61 #define FIX_H (1 << 1) /* in other, this bit specifies top and botom of the control chain to same window edge */
62 #define B2B (1 << 2) /* chain bottom to bottom (by default, no chaining is done) */
68 #define TT (T2T|FIX_H) /* useful combinations: 0xA = entirely to top */
69 #define BB (B2B|FIX_H) /* 6 = entirely to bottom */
70 #define TB (B2B|T2T) /* 0xC = absorb all vertical size change */
71 #define LL (L2L|R2L) /* 0xC0 = entirely to left */
72 #define RR (L2R|R2R) /* 0x30 = entirely to right */
73 #define LR (L2L|R2R) /* 0x90 = absorb all horizontal size change */
75 /* Flags for Option.min used (4) for EndMark: */
76 #define NO_OK (1 << 1)
77 #define NO_CANCEL (1 << 2)
82 #define MAX_OPTIONS 100
84 /* Board widget numbers, MUST correspond to mainOptions array */
86 #define W_MENU 0 // main menu bar
88 #define W_BLACK 7 // clock
90 #define W_PIECE 9 // PieceID
91 #define W_LAST 10 // LastMove
92 #define W_NEXT 11 // side to move
94 #define W_WHITE 13 // clock
96 typedef enum { // identifier of dialogs done by GenericPopup
97 TransientDlg
=0, // transient: grabs mouse events and is destroyed at pop-down (so other dialog can use this ID next time)
98 CommentDlg
, TagsDlg
, TextMenuDlg
, InputBoxDlg
, ChatDlg
, DummyDlg
, HistoryDlg
, // persistent: no grab and reused
103 PromoDlg
, // this and beyond are destroyed at pop-down
105 AskDlg
, // this and beyond do grab mouse events (and are destroyed)
110 NrOfDialogs
// dummy for total
113 typedef int MemoCallback (Option
*opt
, int n
, int x
, int y
, char *text
, int index
);
114 typedef Option
*PointerCallback(int n
, int x
, int y
);
115 typedef void ListBoxCallback(int n
, int selected
);
116 typedef void ButtonCallback(int n
);
117 typedef int OKCallback(int n
);
119 extern char commentTranslations
[];
120 extern char historyTranslations
[];
122 extern int dialogError
;
123 extern void *dotSmall
, *dotLarge
;
125 extern WindowPlacement wpComment
, wpTags
, wpMoveHistory
, wpMain
, wpDualBoard
, wpConsole
;
126 extern char *marked
[];
127 extern Boolean shellUp
[];
128 extern Option textOptions
[], typeOptions
[], dualOptions
[], mainOptions
[];
131 void GetPlacement(DialogClass dlg
, WindowPlacement
*wp
);
132 int DialogExists(DialogClass n
);
133 int GenericPopUp(Option
*option
, char *title
, DialogClass dlgNr
, DialogClass parent
, int modal
, int topLevel
);
134 int GenericReadout(Option
*currentOption
, int selected
);
135 int PopDown(DialogClass n
);
136 void Destroy(DialogClass n
);
137 void MarkMenu(char *item
, int dlgNr
);
138 int AppendText(Option
*opt
, char *s
);
139 void AppendColorized(Option
*opt
, char *s
, int count
);
140 void Show(Option
*opt
, int hide
);
141 int IcsHist(int dir
, Option
*opt
, DialogClass dlg
);
142 void HighlightText(Option
*opt
, int from
, int to
, Boolean highlight
);
143 void SetColor(char *colorName
, Option
*box
);
144 //void ColorChanged(Widget w, XtPointer data, XEvent *event, Boolean *b);
145 void SetInsertPos(Option
*opt
, int pos
);
146 void HardSetFocus(Option
*opt
, DialogClass dlg
);
147 void CursorAtEnd(Option
*opt
);
148 void GetWidgetText (Option
*opt
, char **buf
);
149 void SetWidgetText (Option
*opt
, char *buf
, int n
);
150 void GetWidgetState (Option
*opt
, int *state
);
151 void SetWidgetState (Option
*opt
, int state
);
152 void SetWidgetLabel(Option
*opt
, char *buf
);
153 void SetDialogTitle (DialogClass dlg
, char *title
);
154 void LoadListBox(Option
*opt
, char *emptyText
, int n1
, int n2
);
155 void HighlightListBoxItem(Option
*opt
, int nr
);
156 void HighlightWithScroll(Option
*opt
, int sel
, int max
);
157 void ScrollToCursor(Option
*opt
, int pos
);
158 int SelectedListBoxItem(Option
*opt
);
159 void BoardFocus(void);
160 void FocusOnWidget(Option
*opt
, DialogClass dlg
);
162 void SetIconName(DialogClass dlg
, char *name
);
163 int ReadScroll(Option
*opt
, float *top
, float *bottom
);
164 void SetScroll(Option
*opt
, float f
);
165 void AddHandler (Option
*opt
, DialogClass dlg
, int nr
);
166 void SendText(int n
);
167 void DisplayLogos(Option
*left
, Option
*right
);
168 void Browse(DialogClass dlg
, char *label
, char *proposed
, char *ext
,
169 Boolean pathFlag
, char *mode
, char **name
, FILE **fp
);
172 void InitDrawingParams(int reload
); // in draw.c
173 void InitDrawingHandle(Option
*opt
);
174 void ExposeRedraw(Option
*opt
, int x
, int y
, int w
, int h
);
175 void DrawLogo(Option
*opt
, void *logo
);
176 void ErrorPopUp(char *title
, char *text
, int modal
);
178 void SetClockIcon(int color
);
179 void DelayedLoad(void);
180 void DisplayTimerLabel(Option
*opt
, char *color
, long timer
, int highlight
);
181 void SetWindowTitle(DialogClass dlg
, char *title
, char *icon
);
182 void SetupDropMenu(void);
183 Option
*BoardPopUp(int squareSize
, int lineGap
, void *clockFontThingy
);
184 void SlaveResize(Option
*opt
);
186 int SetCurrentComboSelection(Option
*opt
);
187 void BoxAutoPopUp(char *buf
);
188 void ConsoleAutoPopUp(char *buf
);
190 void ICSInputBoxPopUp(void);
191 void LoadOptionsPopUp(DialogClass parent
);
192 void GameListOptionsPopUp(DialogClass parent
);
193 void RefreshColor(int source
, int n
);
194 void SendString(char *p
);
195 void NewCursor(Option
*opt
, char *src
);
196 void GetTimeMark(TimeMark
*t
);
197 void ReadIcon(char *filename
, int number
);
198 void DrawWidgetIcon(Option
*opt
, int number
);
199 void SetColoredLabel(Option
*opt
, char *text
, char *fgcolor
, char *bgcolor
, char *font
);