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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
|
// This file is part of Golly.
// See docs/License.html for the copyright notice.
#ifndef _WXMAIN_H_
#define _WXMAIN_H_
#include "wx/splitter.h" // for wxSplitterWindow, wxSplitterEvent
#include "wx/dirctrl.h" // for wxGenericDirCtrl
#include "wx/treectrl.h" // for wxTreeCtrl, wxTreeEvent
#include "wx/dataobj.h" // for wxTextDataObject
#include "bigint.h" // for bigint
#include "lifealgo.h" // for lifealgo
#include "writepattern.h" // for pattern_format
#include "wxprefs.h" // for MAX_RECENT
#include "wxalgos.h" // for MAX_ALGOS, algo_type
#include "wxlayer.h" // for MAX_LAYERS
// Golly's main window:
class MainFrame : public wxFrame
{
public:
MainFrame();
~MainFrame();
// update functions
void UpdateEverything();
void UpdateUserInterface();
void UpdateToolBar();
void EnableAllMenus(bool enable);
void UpdateMenuItems();
void UpdatePatternAndStatus(bool update_now = false);
void UpdateStatus();
void UpdateMenuAccelerators();
// clipboard functions
bool ClipboardHasText();
bool CopyTextToClipboard(const wxString& text);
bool GetTextFromClipboard(wxTextDataObject* data);
bool ClipboardContainsRule();
bool ClipboardContainsRLE3();
void OpenClipboard();
void RunClipboard();
// file functions
void OpenFile(const wxString& path, bool remember = true);
void LoadPattern(const wxString& path, const wxString& newtitle,
bool updatestatus = true, bool updateall = true);
void NewPattern(const wxString& title = _("untitled"));
void CreateUniverse();
void SetWindowTitle(const wxString& filename);
void OpenPattern();
void OpenScript();
void ToggleShowFiles();
void ChangeFileDir();
void SetFileDir(const wxString& newdir);
bool SavePattern();
bool SaveCurrentLayer();
const char* SaveFile(const wxString& path, const wxString& format, bool remember);
const char* WritePattern(const wxString& path, pattern_format format,
output_compression compression,
int top, int left, int bottom, int right);
void CheckBeforeRunning(const wxString& scriptpath, bool remember,
const wxString& zippath);
bool ExtractZipEntry(const wxString& zippath,
const wxString& entryname,
const wxString& outfile);
#if wxUSE_DRAG_AND_DROP
wxDropTarget* NewDropTarget();
#endif
// edit functions
void ToggleAllowUndo();
void RestorePattern(bigint& gen, const wxString& filename,
bigint& x, bigint& y, int mag, int base, int expo);
// prefs functions
void SetRandomFillPercentage();
void SetMinimumStepExponent();
void UpdateStepExponent();
void ShowPrefsDialog(const wxString& page = wxEmptyString);
// control functions
void StartGenTimer();
void StartGenerating();
void StopGenerating();
void StartOrStop();
void Stop();
void FinishUp();
void GoFaster();
void GoSlower();
void DisplayTimingInfo();
void NextGeneration(bool useinc);
void ToggleAutoFit();
void ToggleHyperspeed();
void ToggleHashInfo();
void ToggleShowPopulation();
void SetStepExponent(int newexpo);
void SetGenIncrement();
bool SaveStartingPattern();
void ResetPattern(bool resetundo = true);
void SetGeneration();
const char* ChangeGenCount(const char* genstring, bool inundoredo = false);
void SetBaseStep();
void ClearOutsideGrid();
void ReduceCellStates(int newmaxstate);
void ShowRuleDialog();
void ConvertOldRules();
wxString CreateRuleFiles(const wxSortedArrayString& deprecated,
const wxSortedArrayString& ziprules);
void ChangeAlgorithm(algo_type newalgotype,
const wxString& newrule = wxEmptyString,
bool inundoredo = false);
// view functions
void ToggleStatusBar();
void ToggleExactNumbers();
void ToggleToolBar();
void ToggleScrollBars();
void ToggleFullScreen();
void ShowPatternInfo();
void ResizeSplitWindow(int wd, int ht);
void ResizeStatusBar(int wd, int ht);
void ResizeBigView();
wxWindow* RightPane();
// layer functions
void SaveOverlay();
void ToggleOverlay();
void DeleteOverlay();
void UpdateLayerItem(int index);
void AppendLayerItem();
void RemoveLayerItem();
// miscellaneous functions
void OnTreeClick(wxMouseEvent& event);
void EditFile(const wxString& filepath);
void QuitApp();
bool generating; // currently generating a pattern?
bool fullscreen; // in full screen mode?
bool showbanner; // showing banner message?
bool keepmessage; // don't clear message created by script?
bool command_pending; // user selected a command while generating?
bool draw_pending; // user wants to draw while generating?
wxCommandEvent cmdevent; // the pending command
wxMouseEvent mouseevent; // the pending draw
wxTimer* gentimer; // timer for generating patterns
wxTimer* opentimer; // timer for calling OpenFile from OnIdle
// temporary files
wxString clipfile; // name of temporary file for storing clipboard data
wxString luafile; // name of temporary Lua script
wxString perlfile; // name of temporary Perl script
wxString pythonfile; // name of temporary Python script
// store files passed via command line (processed in first OnIdle)
wxArrayString pendingfiles;
bool infront; // main window is active?
// these scroll bars are needed to avoid bug in wxGLCanvas on Mac
// and to allow showing/hiding them on all platforms
wxScrollBar* hbar;
wxScrollBar* vbar;
private:
// any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE()
// event handlers
void OnMenu(wxCommandEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnActivate(wxActivateEvent& event);
void OnSize(wxSizeEvent& event);
void OnIdle(wxIdleEvent& event);
void OnDirTreeSelection(wxTreeEvent& event);
void OnSashDblClick(wxSplitterEvent& event);
void OnGenTimer(wxTimerEvent& event);
void OnOpenTimer(wxTimerEvent& event);
void OnClose(wxCloseEvent& event);
void OnScroll(wxScrollEvent& event);
// file functions
bool LoadImage(const wxString& path);
wxString GetBaseName(const wxString& path);
void SaveSucceeded(const wxString& path);
void AddRecentPattern(const wxString& path);
void OpenRecentPattern(int id);
void ClearMissingPatterns();
void ClearAllPatterns();
void AddRecentScript(const wxString& path);
void OpenRecentScript(int id);
void ClearMissingScripts();
void ClearAllScripts();
wxString GetScriptFileName(const wxString& text);
void OpenZipFile(const wxString& path);
// control functions
void DisplayPattern();
bool StepPattern();
// miscellaneous functions
void CreateMenus();
void CreateToolbar();
void CreateDirControl();
void SimplifyTree(wxString& dir, wxTreeCtrl* treectrl, wxTreeItemId root);
void DoPendingAction(bool restart);
// splittable window contains file directory in left pane
// and layer/edit/timeline bars plus viewport window in right pane
wxSplitterWindow* splitwin;
wxGenericDirCtrl* filectrl;
int hypdown; // for hyperspeed
int minexpo; // currexpo at maximum delay (must be <= 0)
long begintime, endtime; // for timing info
double begingen, endgen; // ditto
};
// ids for menu commands, etc
enum {
// File menu
// wxID_NEW,
// wxID_OPEN,
ID_OPEN_CLIP = wxID_HIGHEST + 1,
ID_OPEN_RECENT,
// last 2 items in Open Recent submenu
ID_CLEAR_MISSING_PATTERNS = ID_OPEN_RECENT + MAX_RECENT + 1,
ID_CLEAR_ALL_PATTERNS,
// wxID_SAVE,
ID_SAVE_XRLE,
ID_RUN_SCRIPT,
ID_RUN_CLIP,
ID_RUN_RECENT,
// last 2 items in Run Recent submenu
ID_CLEAR_MISSING_SCRIPTS = ID_RUN_RECENT + MAX_RECENT + 1,
ID_CLEAR_ALL_SCRIPTS,
ID_SHOW_FILES,
ID_FILE_DIR,
// wxID_PREFERENCES,
// wxID_EXIT,
// Edit menu
// due to wxMac bugs we don't use wxID_UNDO/REDO/CUT/COPY/CLEAR/PASTE/SELECTALL
// (problems occur when info window or a modal dialog is active, and we can't
// change the Undo/Redo menu labels)
ID_UNDO,
ID_REDO,
ID_CUT,
ID_COPY,
ID_NO_UNDO,
ID_CLEAR,
ID_OUTSIDE,
ID_PASTE,
ID_PMODE,
ID_PLOCATION,
ID_PASTE_SEL,
ID_SELECTALL,
ID_REMOVE,
ID_SHRINK,
ID_SHRINKFIT, // there's currently no menu item for "Shrink and Fit"
ID_RANDOM,
ID_FLIPTB,
ID_FLIPLR,
ID_ROTATEC,
ID_ROTATEA,
ID_CMODE,
// Paste Location submenu
ID_PL_TL,
ID_PL_TR,
ID_PL_BR,
ID_PL_BL,
ID_PL_MID,
// Paste Mode submenu
ID_PM_AND,
ID_PM_COPY,
ID_PM_OR,
ID_PM_XOR,
// Cursor Mode submenu
ID_DRAW,
ID_PICK,
ID_SELECT,
ID_MOVE,
ID_ZOOMIN,
ID_ZOOMOUT,
// Control menu
ID_START,
ID_NEXT,
ID_STEP,
ID_RESET,
ID_SETGEN,
ID_FASTER,
ID_SLOWER,
ID_SETBASE,
ID_AUTO,
ID_HYPER,
ID_HINFO,
ID_SHOW_POP,
ID_RECORD,
ID_DELTIME,
ID_SETALGO,
ID_SETRULE,
ID_CONVERT,
// Set Algorithm submenu
ID_ALGO0,
ID_ALGOMAX = ID_ALGO0 + MAX_ALGOS - 1,
// View menu
ID_FULL,
ID_FIT,
ID_FIT_SEL,
ID_MIDDLE,
ID_RESTORE00,
// wxID_ZOOM_IN,
// wxID_ZOOM_OUT,
ID_SET_SCALE,
ID_TOOL_BAR,
ID_LAYER_BAR,
ID_EDIT_BAR,
ID_ALL_STATES,
ID_STATUS_BAR,
ID_EXACT,
ID_GRID,
ID_ICONS,
ID_INVERT,
ID_SMARTSCALE,
ID_TIMELINE,
ID_SCROLL,
ID_INFO,
// Set Scale submenu
ID_SCALE_1,
ID_SCALE_2,
ID_SCALE_4,
ID_SCALE_8,
ID_SCALE_16,
ID_SCALE_32,
// Layer menu
ID_SAVE_OVERLAY,
ID_SHOW_OVERLAY,
ID_DEL_OVERLAY,
ID_ADD_LAYER,
ID_CLONE,
ID_DUPLICATE,
ID_DEL_LAYER,
ID_DEL_OTHERS,
ID_MOVE_LAYER,
ID_NAME_LAYER,
ID_SET_COLORS,
ID_SYNC_VIEW,
ID_SYNC_CURS,
ID_STACK,
ID_TILE,
ID_LAYER0,
ID_LAYERMAX = ID_LAYER0 + MAX_LAYERS - 1,
// Help menu
ID_HELP_INDEX,
ID_HELP_INTRO,
ID_HELP_TIPS,
ID_HELP_ALGOS,
ID_HELP_KEYBOARD,
ID_HELP_MOUSE,
ID_HELP_LUA,
ID_HELP_OVERLAY,
ID_HELP_PYTHON,
ID_HELP_LEXICON,
ID_HELP_ARCHIVES,
ID_HELP_FILE,
ID_HELP_EDIT,
ID_HELP_CONTROL,
ID_HELP_VIEW,
ID_HELP_LAYER,
ID_HELP_HELP,
ID_HELP_REFS,
ID_HELP_FORMATS,
ID_HELP_BOUNDED,
ID_HELP_PROBLEMS,
ID_HELP_CHANGES,
ID_HELP_CREDITS,
// these ids aren't associated with any menu item
ID_LOAD_LEXICON, // for loading a lexicon pattern
ID_HELP_BUTT, // for help button in tool bar
ID_OPENTIMER, // for opentimer
ID_GENTIMER // for gentimer
};
#endif
|