1 // This file is part of Golly. 2 // See docs/License.html for the copyright notice. 3 4 #ifndef _WXPREFS_H_ 5 #define _WXPREFS_H_ 6 7 // Routines for getting, saving and changing user preferences: 8 9 void GetPrefs(); 10 // Read preferences from the GollyPrefs file. 11 12 void SavePrefs(); 13 // Write preferences to the GollyPrefs file. 14 15 bool ChangePrefs(const wxString& page); 16 // Open a modal dialog so user can change various preferences. 17 // Returns true if the user hits OK (so client can call SavePrefs). 18 19 void ChooseTextEditor(wxWindow* parent, wxString& result); 20 // Let user select their preferred text editor. The result is the 21 // path to the application or empty if the user cancels the dialog. 22 23 char* ReplaceDeprecatedAlgo(char* algoname); 24 // If given algo name is deprecated then return replacement name, 25 // otherwise return same name. 26 27 // Global preference data: 28 29 extern wxString gollydir; // path of directory containing app 30 extern wxString datadir; // path of directory for user-specific data 31 extern wxString tempdir; // path of directory for temporary data 32 extern wxString rulesdir; // path of directory for app's rule data 33 extern wxString userrules; // path of directory for user's rule data 34 extern wxString downloaddir; // path of directory for downloaded data 35 36 extern int debuglevel; // for displaying debug info if > 0 37 38 extern int mainx; // main window's location 39 extern int mainy; 40 extern int mainwd; // main window's size 41 extern int mainht; 42 extern bool maximize; // maximize main window? 43 44 extern int helpx; // help window's location 45 extern int helpy; 46 extern int helpwd; // help window's size 47 extern int helpht; 48 extern int helpfontsize; // font size in help window 49 50 extern int infox; // info window's location 51 extern int infoy; 52 extern int infowd; // info window's size 53 extern int infoht; 54 55 extern int rulex; // rule dialog's location 56 extern int ruley; 57 extern int ruleexwd; // rule dialog's extra size 58 extern int ruleexht; 59 extern bool showalgohelp; // show algorithm help in rule dialog? 60 61 extern char initrule[]; // initial rule 62 extern bool initautofit; // initial autofit setting 63 extern bool inithyperspeed; // initial hyperspeed setting 64 extern bool initshowhashinfo; // initial showhashinfo setting 65 extern bool showpopulation; // show population counts while generating? 66 extern bool savexrle; // save RLE file using XRLE format? 67 extern bool showtips; // show button tips? 68 extern bool showtool; // show tool bar? 69 extern bool showlayer; // show layer bar? 70 extern bool showedit; // show edit bar? 71 extern bool showallstates; // show all cell states in edit bar? 72 extern bool showstatus; // show status bar? 73 extern bool showexact; // show exact numbers in status bar? 74 extern bool showscrollbars; // show scroll bars? 75 extern bool showtimeline; // show timeline bar? 76 extern bool showgridlines; // display grid lines? 77 extern bool showoverlay; // display the current overlay? 78 extern bool showicons; // display icons for cell states? 79 extern bool smartscale; // smarter scaling when zoomed out? 80 extern bool swapcolors; // swap colors used for cell states? 81 extern bool scrollpencil; // scroll if pencil cursor is dragged outside view? 82 extern bool scrollcross; // scroll if cross cursor is dragged outside view? 83 extern bool scrollhand; // scroll if hand cursor is dragged outside view? 84 extern bool allowundo; // allow undo/redo? 85 extern bool restoreview; // should reset/undo restore view? 86 extern bool allowbeep; // okay to play beep sound? 87 extern int controlspos; // position of translucent controls 88 extern int canchangerule; // if > 0 then paste can change rule 89 extern int randomfill; // random fill percentage 90 extern int opacity; // percentage opacity of live cells in overlays 91 extern int tileborder; // width of tiled window borders 92 extern int mingridmag; // minimum mag to draw grid lines 93 extern int boldspacing; // spacing of bold grid lines 94 extern bool showboldlines; // show bold grid lines? 95 extern bool mathcoords; // show Y values increasing upwards? 96 extern bool cellborders; // should zoomed cells have borders? 97 extern bool syncviews; // synchronize viewports? 98 extern bool synccursors; // synchronize cursors? 99 extern bool stacklayers; // stack all layers? 100 extern bool tilelayers; // tile all layers? 101 extern bool askonnew; // ask to save changes before creating new pattern? 102 extern bool askonload; // ask to save changes before loading pattern file? 103 extern bool askondelete; // ask to save changes before deleting layer? 104 extern bool askonquit; // ask to save changes before quitting app? 105 extern bool warn_on_save; // warn if saving non-starting generation? 106 extern int newmag; // mag setting for new pattern 107 extern bool newremovesel; // new pattern removes selection? 108 extern bool openremovesel; // opening pattern removes selection? 109 extern wxCursor* newcurs; // cursor after creating new pattern 110 extern wxCursor* opencurs; // cursor after opening pattern 111 extern int mousewheelmode; // 0:Ignore, 1:forward=ZoomOut, 2:forward=ZoomIn 112 extern int thumbrange; // thumb box scrolling range in terms of view wd/ht 113 extern int wheelsens; // mouse wheel sensitivity 114 extern int mindelay; // minimum millisec delay 115 extern int maxdelay; // maximum millisec delay 116 extern wxString opensavedir; // directory for Open/Save Pattern dialogs 117 extern wxString overlaydir; // directory for Save Overlay dialog 118 extern wxString rundir; // directory for Run Script dialog 119 extern wxString choosedir; // directory used by Choose File button 120 extern wxString filedir; // directory used by Show Files 121 extern wxString texteditor; // path of user's preferred text editor 122 extern wxString perllib; // name of Perl library (loaded at runtime) 123 extern wxString pythonlib; // name of Python library (loaded at runtime) 124 extern int dirwinwd; // width of file directory window 125 extern bool showfiles; // show file directory? 126 extern wxMenu* patternSubMenu; // submenu of recent pattern files 127 extern wxMenu* scriptSubMenu; // submenu of recent script files 128 extern int numpatterns; // current number of recent pattern files 129 extern int numscripts; // current number of recent script files 130 extern int maxpatterns; // maximum number of recent pattern files 131 extern int maxscripts; // maximum number of recent script files 132 133 extern wxArrayString namedrules; 134 // We maintain an array of named rules, where each string is of the form 135 // "name of rule|B.../S...". The first string is always "Life|B3/S23". 136 137 // Keyboard shortcuts: 138 139 // define the actions that can be invoked by various key combinations 140 typedef enum { 141 DO_NOTHING = 0, // null action must be zero 142 DO_OPENFILE, // open a chosen pattern/script/rule/html file 143 // rest are in alphabetical order (well, almost) 144 DO_ABOUT, // about Golly 145 DO_ADD, // add layer 146 DO_ADVANCEOUT, // advance outside 147 DO_ADVANCE, // advance selection 148 DO_AUTOFIT, // auto fit 149 DO_CHANGE00, // change origin 150 DO_CLEAROUT, // clear outside 151 DO_CLEAR, // clear selection 152 DO_CLONE, // clone layer 153 DO_COPY, // copy selection 154 DO_CURSDRAW, // cursor mode: draw 155 DO_CURSMOVE, // cursor mode: move 156 DO_CURSPICK, // cursor mode: pick 157 DO_CURSSEL, // cursor mode: select 158 DO_CURSIN, // cursor mode: zoom in 159 DO_CURSOUT, // cursor mode: zoom out 160 DO_CUT, // cut selection 161 DO_CURSCYCLE, // cycle cursor mode 162 DO_PASTELOC, // cycle paste location 163 DO_PASTEMODE, // cycle paste mode 164 DO_DELETE, // delete layer 165 DO_DELOTHERS, // delete other layers 166 DO_DELOVERLAY, // delete overlay 167 DO_DELTIME, // delete timeline 168 DO_DISABLE, // disable undo/redo 169 DO_DUPLICATE, // duplicate layer 170 DO_FASTER, // faster 171 DO_FIT, // fit pattern 172 DO_FITSEL, // fit selection 173 DO_FLIPLR, // flip left-right 174 DO_FLIPTB, // flip top-bottom 175 DO_FULLSCREEN, // full screen 176 DO_HYPER, // hyperspeed 177 DO_INVERT, // invert colors 178 DO_MIDDLE, // middle 179 DO_MOVELAYER, // move layer... 180 DO_NAMELAYER, // name layer... 181 DO_NEWPATT, // new pattern 182 DO_NEXTGEN, // next generation 183 DO_NEXTSTEP, // next step 184 DO_NEXTHIGHER, // next higher state 185 DO_NEXTLOWER, // next lower state 186 DO_OPENCLIP, // open clipboard 187 DO_OPENPATT, // open pattern... 188 DO_PASTE, // paste 189 DO_PASTESEL, // paste to selection 190 DO_INFO, // pattern info 191 DO_PLAYBACK, // play timeline backwards 192 DO_PREFS, // preferences... 193 DO_QUIT, // quit Golly 194 DO_RANDFILL, // random fill 195 DO_REDO, // redo 196 DO_REMOVESEL, // remove selection 197 DO_RESET, // reset 198 DO_RESTORE00, // restore origin 199 DO_ROTATEACW, // rotate anticlockwise 200 DO_ROTATECW, // rotate clockwise 201 DO_RUNCLIP, // run clipboard 202 DO_RUNSCRIPT, // run script... 203 DO_SAVEXRLE, // save extended rle 204 DO_SAVEOVERLAY, // save overlay... 205 DO_SAVE, // save pattern... 206 DO_DOWN, // scroll down 207 DO_LEFT, // scroll left 208 DO_RIGHT, // scroll right 209 DO_UP, // scroll up 210 DO_NE, // scroll NE 211 DO_NW, // scroll NW 212 DO_SE, // scroll SE 213 DO_SW, // scroll SW 214 DO_SELALL, // select all 215 DO_SETBASE, // set base step... 216 DO_FILEDIR, // set file folder... 217 DO_SETGEN, // set generation... 218 DO_SETCOLORS, // set layer colors... 219 DO_SETRULE, // set rule... 220 DO_SCALE1, // set scale 1:1 221 DO_SCALE2, // set scale 1:2 222 DO_SCALE4, // set scale 1:4 223 DO_SCALE8, // set scale 1:8 224 DO_SCALE16, // set scale 1:16 225 DO_SCALE32, // set scale 1:32 226 DO_SHOWSTATES, // show all states 227 DO_SHOWICONS, // show cell icons 228 DO_SHOWEDIT, // show edit bar 229 DO_SHOWEXACT, // show exact numbers 230 DO_SHOWFILES, // show files 231 DO_SHOWGRID, // show grid lines 232 DO_HASHINFO, // show hash info 233 DO_HELP, // show help 234 DO_SHOWLAYER, // show layer bar 235 DO_SHOWOVERLAY, // show overlay 236 DO_SHOWPOP, // show population 237 DO_SHOWSCROLL, // show scroll bars 238 DO_SHOWSTATUS, // show status bar 239 DO_SHOWTIME, // show timeline 240 DO_TIMING, // show timing 241 DO_SHOWTOOL, // show tool bar 242 DO_SHRINKFIT, // shrink and fit 243 DO_SHRINK, // shrink selection 244 DO_SLOWER, // slower 245 DO_SMARTSCALE, // smarter scaling 246 DO_STACK, // stack layers 247 DO_STARTSTOP, // start/stop generating 248 DO_RECORD, // start/stop recording 249 DO_SYNCCURS, // synchronize cursors 250 DO_SYNCVIEWS, // synchronize views 251 DO_TILE, // tile layers 252 DO_UNDO, // undo 253 DO_HASHING, // use hashing 254 DO_ZOOMIN, // zoom in 255 DO_ZOOMOUT, // zoom out 256 MAX_ACTIONS 257 } action_id; 258 259 typedef struct { 260 action_id id; // one of the above 261 wxString file; // non-empty if id is DO_OPENFILE 262 } action_info; 263 264 action_info FindAction(int key, int modifiers); 265 // return the action info for the given key and modifier set 266 267 wxString GetAccelerator(action_id action); 268 // return a string, possibly empty, containing the menu item 269 // accelerator(s) for the given action 270 271 void RemoveAccelerator(wxMenuBar* mbar, int item, action_id action); 272 // remove any accelerator from given menu item 273 274 void SetAccelerator(wxMenuBar* mbar, int item, action_id action); 275 // update accelerator for given menu item using given action 276 277 wxString GetShortcutTable(); 278 // return HTML data to display current keyboard shortcuts 279 280 // Colors: 281 282 extern wxColor* borderrgb; // color for border around bounded grid 283 extern wxColor* selectrgb; // color for selected cells 284 extern wxColor* pastergb; // color for pasted pattern 285 286 void UpdateStatusBrushes(); // update colors in status brushes 287 void FreeDefaultColors(); // deallocate memory allocated by CreateDefaultColors() 288 289 // Various constants: 290 291 const int minmainwd = 200; // main window's minimum width 292 const int minmainht = 100; // main window's minimum height 293 294 const int minhelpwd = 400; // help window's minimum width 295 const int minhelpht = 100; // help window's minimum height 296 297 const int minfontsize = 6; // minimum value of helpfontsize 298 const int maxfontsize = 30; // maximum value of helpfontsize 299 300 const int mininfowd = 400; // info window's minimum width 301 const int mininfoht = 100; // info window's minimum height 302 303 const int MAX_RECENT = 100; // maximum value of maxpatterns and maxscripts 304 const int MAX_SPACING = 1000; // maximum value of boldspacing 305 const int MIN_MEM_MB = 0; // minimum value of maximum memory 306 const int MAX_MEM_MB = // maximum value of maximum memory 307 sizeof(char*) <= 4 ? 4000 : 100000000; 308 const int MAX_BASESTEP = 2000000000; // maximum base step 309 const int MAX_DELAY = 5000; // maximum mindelay or maxdelay 310 const int MAX_THUMBRANGE = 500; // maximum thumbrange 311 const int MAX_SENSITIVITY = 10; // maximum wheelsens 312 const int MIN_DIRWD = 10; // minimum dirwinwd 313 314 // Golly uses wxTimers to control the speed of generating patterns, drawing cells, 315 // playing timelines, etc. The value defined below will cause the timers to fire 316 // at approximately 60 times per sec (to match the refresh rate of most screens). 317 #ifdef __WXMSW__ 318 // It seems that wxTimers on Windows only have a resolution of about 15.6ms 319 // so we need to set SIXTY_HERTZ to a value below 16, based on Tim Hutton's 320 // test results (using a 64-bit build of Golly on Windows 10): 321 // interval=5 : 63.9gps = 15.6ms actual interval 322 // interval=10 : 63.9gps = 15.6ms actual interval 323 // interval=15 : 63.9gps = 15.6ms actual interval 324 // interval=16 : 40.0gps = 25.0ms actual interval 325 // interval=17 : 31.9gps = 31.3ms actual interval (= 2 times 15.6ms) 326 // interval=20 : 31.9gps = 31.3ms actual interval 327 // interval=25 : 31.9gps = 31.3ms actual interval 328 const int SIXTY_HERTZ = 15; 329 #else 330 // Mac and Linux 331 const int SIXTY_HERTZ = 16; // 1000/60 332 #endif 333 334 // Following are used by GetPrefs() before the view window is created: 335 336 typedef enum { 337 TopLeft, TopRight, BottomRight, BottomLeft, Middle 338 } paste_location; 339 340 typedef enum { 341 And, Copy, Or, Xor 342 } paste_mode; 343 344 extern paste_location plocation; // location of cursor in paste rectangle 345 extern paste_mode pmode; // logical paste mode 346 347 // get/set plocation 348 const char* GetPasteLocation(); 349 void SetPasteLocation(const char* s); 350 351 // get/set pmode 352 const char* GetPasteMode(); 353 void SetPasteMode(const char* s); 354 355 // Cursor modes: 356 357 extern wxCursor* curs_pencil; // for drawing cells 358 extern wxCursor* curs_pick; // for picking cell states 359 extern wxCursor* curs_cross; // for selecting cells 360 extern wxCursor* curs_hand; // for moving view by dragging 361 extern wxCursor* curs_zoomin; // for zooming in to a clicked cell 362 extern wxCursor* curs_zoomout; // for zooming out from a clicked cell 363 extern wxCursor* curs_wait; // for indicating a lengthy task is in progress 364 extern wxCursor* curs_hidden; // for hiding cursor when mouse is in overlay 365 366 void FreeCursors(); 367 // deallocate memory allocated by CreateCursors() 368 369 const char* CursorToString(wxCursor* curs); 370 // convert given cursor to corresponding string in Cursor Mode submenu 371 372 wxCursor* StringToCursor(const char* s); 373 // convert given string to a cursor (NULL if s is not valid) 374 375 int CursorToIndex(wxCursor* curs); 376 // convert given cursor to an index: 0 for curs_pencil, etc 377 378 wxCursor* IndexToCursor(int i); 379 // convert given index to a cursor (NULL if i is not in valid range) 380 381 #endif 382