1 /* 2 * dialogs.h -- shared variables for generic dialog popup of XBoard 3 * 4 * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc. 5 * ------------------------------------------------------------------------ 6 * 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. 11 * 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. 16 * 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/. * 19 * 20 *------------------------------------------------------------------------ 21 ** See the file ChangeLog for a revision history. */ 22 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 X/E X/E * 36 // char ** choice C 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 // char ** font X X X X (GTK only) 40 // File and Path options are like String (but get a browse button added in the dialog), and Slider 41 // is like Spin. Menu can be PopUp or PopDown; both need the COMBO_CALLBACK bit (3) set! 42 // (h) or (w) means the field optionally (when non-null) specifies the height or width of the main 43 // control element (excluding accompanying description texts). [w] means the width is written there. 44 // C specifies the 'target' is a user-supplied callback function, which will be executed when the 45 // option is exercised. 46 47 48 /* Flags Option.min used (2) for TextBox (-string): */ 49 #define T_VSCRL (1 << 0) 50 #define T_HSCRL (1 << 1) 51 #define T_FILL (1 << 2) 52 #define T_WRAP (1 << 3) 53 #define T_TOP (1 << 4) 54 55 /* Flags Option.min used (3) for ComboBox (-combo) and menus (PopUp, PopDown): */ 56 #define COMBO_CALLBACK (1 << 0) 57 #define NO_GETTEXT (1 << 2) 58 59 /* Flags for Option.min used (1) for Button, SaveButton, ListBox, Label: */ 60 #define SAME_ROW (1 << 0) /* also in Break & EndMark */ 61 #define BORDER (1 << 1) /* Label */ 62 #define FIX_H (1 << 1) /* in other, this bit specifies top and botom of the control chain to same window edge */ 63 #define B2B (1 << 2) /* chain bottom to bottom (by default, no chaining is done) */ 64 #define T2T (1 << 3) 65 #define R2R (1 << 4) 66 #define L2R (1 << 5) 67 #define R2L (1 << 6) 68 #define L2L (1 << 7) 69 #define TT (T2T|FIX_H) /* useful combinations: 0xA = entirely to top */ 70 #define BB (B2B|FIX_H) /* 6 = entirely to bottom */ 71 #define TB (B2B|T2T) /* 0xC = absorb all vertical size change */ 72 #define LL (L2L|R2L) /* 0xC0 = entirely to left */ 73 #define RR (L2R|R2R) /* 0x30 = entirely to right */ 74 #define LR (L2L|R2R) /* 0x90 = absorb all horizontal size change */ 75 76 /* Flags for Option.min used (4) for EndMark: */ 77 #define NO_OK (1 << 1) 78 #define NO_CANCEL (1 << 2) 79 80 #define REPLACE (1 << 16) 81 82 #define MODAL 1 83 #define NONMODAL 0 84 85 /* Board widget numbers, MUST correspond to mainOptions array */ 86 87 #define W_MENU 0 // main menu bar 88 #define W_ENGIN 6 // engine menu 89 #define W_TITLE 10 90 #define W_WHITE 12 91 #define W_BLACK 13 92 #define W_SMALL 15 // title in small layout 93 #define W_MESSG 16 94 #define W_BUTTON 17 // button bar 95 #define W_PAUSE 20 96 #define W_BOARD 24 97 #define W_MENUW 25 98 #define W_MENUB 26 99 #define W_DROP 27 // drop (popup) menu 100 101 typedef enum { // identifier of dialogs done by GenericPopup 102 TransientDlg=0, // transient: grabs mouse events and is destroyed at pop-down (so other dialog can use this ID next time) 103 CommentDlg, TagsDlg, TextMenuDlg, InputBoxDlg, ChatDlg, DummyDlg, HistoryDlg, // persistent: no grab and reused 104 GameListDlg, 105 EngOutDlg, 106 EvalGraphDlg, 107 PromoDlg, // this and beyond are destroyed at pop-down 108 ErrorDlg, 109 AskDlg, // this and beyond do grab mouse events (and are destroyed) 110 FatalDlg, 111 BoardWindow, 112 BrowserDlg, 113 MasterDlg, 114 NrOfDialogs // dummy for total 115 } DialogClass; 116 117 typedef int MemoCallback (Option *opt, int n, int x, int y, char *text, int index); 118 typedef Option *PointerCallback(int n, int x, int y); 119 typedef void ListBoxCallback(int n, int selected); 120 typedef void ButtonCallback(int n); 121 typedef int OKCallback(int n); 122 123 extern char commentTranslations[]; 124 extern char historyTranslations[]; 125 //extern Pixel timerBackgroundPixel; 126 extern int values[]; 127 extern ChessProgramState *currentCps; 128 extern int dialogError; 129 extern ButtonCallback *comboCallback; 130 extern void *userLogo; 131 132 extern WindowPlacement wpComment, wpTags, wpMoveHistory, wpMain, wpDualBoard, wpConsole; 133 extern char *marked[]; 134 extern Boolean shellUp[]; 135 extern Option textOptions[], typeOptions[], dualOptions[], mainOptions[]; 136 extern Option historyOptions[], engoutOptions[], gamesOptions[], chatOptions[], tagsOptions[], commentOptions[]; 137 #define MAX_SIZE 130 138 extern Boolean fontIsSet[], fontValid[][MAX_SIZE]; 139 extern int initialSquareSize; 140 extern char *fontTable[][MAX_SIZE]; 141 142 143 void GetPlacement P((DialogClass dlg, WindowPlacement *wp)); 144 int DialogExists P((DialogClass n)); 145 int GenericPopUp P((Option *option, char *title, DialogClass dlgNr, DialogClass parent, int modal, int topLevel)); 146 int GenericReadout P((Option *currentOption, int selected)); 147 int PopDown P((DialogClass n)); 148 void MarkMenu P((char *item, int dlgNr)); 149 int AppendText P((Option *opt, char *s)); 150 void AppendColorized P((Option *opt, char *s, int count)); 151 void Show P((Option *opt, int hide)); 152 int IcsHist P((int dir, Option *opt, DialogClass dlg)); 153 void HighlightText P((Option *opt, int from, int to, Boolean highlight)); 154 void SetColor P((char *colorName, Option *box)); 155 //void ColorChanged P((Widget w, XtPointer data, XEvent *event, Boolean *b)); 156 void SetInsertPos P((Option *opt, int pos)); 157 void HardSetFocus P((Option *opt, DialogClass dlg)); 158 void CursorAtEnd P((Option *opt)); 159 void GetWidgetText P((Option *opt, char **buf)); 160 void SetWidgetText P((Option *opt, char *buf, int n)); 161 void GetWidgetState P((Option *opt, int *state)); 162 void SetWidgetState P((Option *opt, int state)); 163 void SetWidgetLabel P((Option *opt, char *buf)); 164 void SetComboChoice P((Option *opt, int choice)); 165 void SetDialogTitle P((DialogClass dlg, char *title)); 166 void LoadListBox P((Option *opt, char *emptyText, int n1, int n2)); 167 void HighlightListBoxItem P((Option *opt, int nr)); 168 void HighlightWithScroll P((Option *opt, int sel, int max)); 169 void ScrollToCursor P((Option *opt, int pos)); 170 int SelectedListBoxItem P((Option *opt)); 171 void BoardFocus P((void)); 172 void FocusOnWidget P((Option *opt, DialogClass dlg)); 173 void UnCaret P((void)); 174 void SetIconName P((DialogClass dlg, char *name)); 175 int ReadScroll P((Option *opt, float *top, float *bottom)); 176 void SetScroll P((Option *opt, float f)); 177 void AddHandler P((Option *opt, DialogClass dlg, int nr)); 178 void SendText P((int n)); 179 void DisplayLogos P((Option *left, Option *right)); 180 void StartDir P((char *filter, char *newName)); 181 void Browse P((DialogClass dlg, char *label, char *proposed, char *ext, 182 Boolean pathFlag, char *mode, char **name, FILE **fp)); 183 void FileNamePopUpWrapper P((char *label, char *def, char *filter, FileProc proc, 184 Boolean pathFlag, char *openMode, char **openName, FILE **openFP)); 185 186 void InitDrawingParams P((int reload)); // in draw.c 187 void InitDrawingHandle P((Option *opt)); 188 void ExposeRedraw P((Option *opt, int x, int y, int w, int h)); 189 void DrawLogo P((Option *opt, void *logo)); 190 void ErrorPopUp P((char *title, char *text, int modal)); 191 int ShiftKeys P((void)); 192 void SetClockIcon P((int color)); 193 void DelayedLoad P((void)); 194 void DisplayTimerLabel P((Option *opt, char *color, long timer, int highlight)); 195 void SetWindowTitle P((char *text, char *title, char *icon)); 196 void SetupDropMenu P((void)); 197 Option *BoardPopUp P((int squareSize, int lineGap, void *clockFontThingy)); 198 void SlaveResize P((Option *opt)); 199 200 int SetCurrentComboSelection P((Option *opt)); 201 void BoxAutoPopUp P((char *buf)); 202 void ConsoleAutoPopUp P((char *buf)); 203 void IcsKey P((int n)); 204 void ICSInputBoxPopUp P((void)); 205 void LoadOptionsPopUp P((DialogClass parent)); 206 void GameListOptionsPopUp P((DialogClass parent)); 207 void RefreshColor P((int source, int n)); 208 void SendString P((char *p)); 209 void DisplayHelp P((char *name)); 210 void WidgetEcho P((Option *opt, int n)); 211 int ErrorOK P((int n)); 212 void ApplyFont P((Option *opt, char *font)); 213 void LockBoardSize P((int after)); 214 void Preview P((int n, char *s)); 215 void DrawPosition P((int fullRedraw, Board b)); 216 217 218 // in ngamelist.c 219 int GameListClicks P((int direction)); 220 void SetFilter P((void)); 221