File: wxscript.h

package info (click to toggle)
golly 2.6-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,440 kB
  • ctags: 8,558
  • sloc: cpp: 55,629; python: 7,963; sh: 4,420; objc: 3,613; java: 2,791; ansic: 2,512; xml: 1,379; perl: 1,172; makefile: 54
file content (117 lines) | stat: -rw-r--r-- 4,687 bytes parent folder | download
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
/*** /
 
 This file is part of Golly, a Game of Life Simulator.
 Copyright (C) 2013 Andrew Trevorrow and Tomas Rokicki.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 Web site:  http://sourceforge.net/projects/golly
 Authors:   rokicki@gmail.com  andrew@trevorrow.com
 
 / ***/

#ifndef _WXSCRIPT_H_
#define _WXSCRIPT_H_

#include "lifealgo.h"   // for lifealgo class

extern bool inscript;
// Is a script currently running?  We allow access to this flag
// so clients can temporarily save and restore its setting.

extern bool passkeys;
extern bool passclicks;
// Pass keyboard and/or mouse events to script?  Both flags are initially false
// at the start of a script; both become true if the script calls getevent.
// If the script calls getkey (deprecated) then only passkeys becomes true.

extern bool canswitch;
// Can user switch layers while a script is running?

extern bool stop_after_script;
// Stop generating pattern after running script?

void RunScript(const wxString& filename);
// Run the given Perl or Python script.

void PassClickToScript(const bigint& x, const bigint& y, int button, int modifiers);
// Called if a script is running and user clicks mouse.

void PassKeyToScript(int key, int modifiers = 0);
// Called if a script is running and user hits a key.
// Can also be used to abort a script by passing WXK_ESCAPE.

void ShowTitleLater();
// Called if a script is running and window title has changed.

void ChangeCell(int x, int y, int oldstate, int newstate);
// A setcell/putcells command is changing state of cell at x,y.

void SavePendingChanges(bool checkgenchanges = true);
// Called to save any pending cell changes made by ChangeCell calls.
// If checkgenchanges is true then it will also save any pending
// generating changes.  This lets us accumulate consecutive cell/gen
// changes in a single undo/redo change node, which is better for
// scripts like invert.py that can call setcell() many times, or
// for scripts like oscar.py that can call run() many times.
// Must be called BEFORE all undoredo->Remember... calls but
// only if inscript && allowundo && !currlayer->stayclean.

void FinishScripting();
// Called when app quits to abort a running script.

// Following are used in wxperl.cpp and wxpython.cpp:

extern bool autoupdate;       // update display after changing current universe?
extern bool allowcheck;       // allow event checking?
extern wxString scripterr;    // Perl/Python error message
extern wxString mousepos;     // current mouse position

const char abortmsg[] = "GOLLY: ABORT SCRIPT";
// special message used to indicate that the script was aborted

void DoAutoUpdate();          // update display if autoupdate is true

// The following Golly Script Functions are used to reduce code duplication.
// They are called by corresponding pl_* and py_* functions in wxperl.cpp
// and wxpython.cpp respectively.

const char* GSF_open(char* filename, int remember);
const char* GSF_save(char* filename, char* format, int remember);
const char* GSF_setdir(char* dirname, char* newdir);
const char* GSF_getdir(char* dirname);
const char* GSF_setalgo(char* algostring);
const char* GSF_setrule(char* rulestring);
const char* GSF_setgen(char* genstring);
const char* GSF_setpos(char* x, char* y);
const char* GSF_setcell(int x, int y, int newstate);
const char* GSF_paste(int x, int y, char* mode);
const char* GSF_checkpos(lifealgo* algo, int x, int y);
const char* GSF_checkrect(int x, int y, int wd, int ht);
int GSF_hash(int x, int y, int wd, int ht);
bool GSF_setoption(char* optname, int newval, int* oldval);
bool GSF_getoption(char* optname, int* optval);
bool GSF_setcolor(char* colname, wxColor& newcol, wxColor& oldcol);
bool GSF_getcolor(char* colname, wxColor& color);
void GSF_setname(char* name, int index);
void GSF_select(int x, int y, int wd, int ht);
void GSF_getevent(wxString& event, int get);
const char* GSF_doevent(const wxString& event);
void GSF_getkey(char* s);
void GSF_dokey(char* ascii);
void GSF_update();
void GSF_exit(char* errmsg);

#endif