1 
2 #include "stdafx.h"
3 
4 #ifndef __WXMSW__
5 #define SIMPLERENDER
6 #endif
7 
8 //#define SIMPLERENDER // for testing
9 
10 int g_grid_margin = 1;
11 int g_cell_margin = 2;
12 int g_margin_extra = 2;  // TODO, could make this configurable: 0/2/4/6
13 int g_line_width = 1;
14 int g_selmargin = 2;
15 int g_deftextsize = 12;
g_mintextsize()16 int g_mintextsize() { return g_deftextsize - 8; }
g_maxtextsize()17 int g_maxtextsize() { return g_deftextsize + 32; }
18 int g_grid_left_offset = 15;
19 
20 int g_scrollratecursor = 240;  // FIXME: must be configurable
21 int g_scrollratewheel = 2;     // relative to 1 step on a fixed wheel usually being 120
22 
23 static uint celltextcolors[] = {
24     0xFFFFFF,  // CUSTOM COLOR!
25     0xFFFFFF, 0x000000, 0x202020, 0x404040, 0x606060, 0x808080, 0xA0A0A0, 0xC0C0C0, 0xD0D0D0,
26     0xE0E0E0, 0xE8E8E8, 0x000080, 0x0000FF, 0x8080FF, 0xC0C0FF, 0xC0C0E0, 0x008000, 0x00FF00,
27     0x80FF80, 0xC0FFC0, 0xC0E0C0, 0x800000, 0xFF0000, 0xFF8080, 0xFFC0C0, 0xE0C0C0, 0x800080,
28     0xFF00FF, 0xFF80FF, 0xFFC0FF, 0xE0C0E0, 0x008080, 0x00FFFF, 0x80FFFF, 0xC0FFFF, 0xC0E0E0,
29     0x808000, 0xFFFF00, 0xFFFF80, 0xFFFFC0, 0xE0E0C0,
30 };
31 #define CUSTOMCOLORIDX 0
32 
33 enum { TS_VERSION = 19, TS_TEXT = 0, TS_GRID, TS_BOTH, TS_NEITHER };
34 
35 enum {
36     A_NEW = 500,
37     A_OPEN,
38     A_CLOSE,
39     A_SAVE,
40     A_SAVEAS,
41     A_CUT,
42     A_COPY,
43     A_PASTE,
44     A_NEWGRID,
45     A_UNDO,
46     A_ABOUT,
47     A_RUN,
48     A_CLRVIEW,
49     A_MARKDATA,
50     A_MARKVIEWH,
51     A_MARKVIEWV,
52     A_MARKCODE,
53     A_IMAGE,
54     A_EXPIMAGE,
55     A_EXPXML,
56     A_EXPHTMLT,
57     A_EXPHTMLO,
58     A_EXPTEXT,
59     A_ZOOMIN,
60     A_ZOOMOUT,
61     A_TRANSPOSE,
62     A_DELETE,
63     A_BACKSPACE,
64     A_LEFT,
65     A_RIGHT,
66     A_UP,
67     A_DOWN,
68     A_MLEFT,
69     A_MRIGHT,
70     A_MUP,
71     A_MDOWN,
72     A_SLEFT,
73     A_SRIGHT,
74     A_SUP,
75     A_SDOWN,
76     A_ALEFT,
77     A_ARIGHT,
78     A_AUP,
79     A_ADOWN,
80     A_SCLEFT,
81     A_SCRIGHT,
82     A_SCUP,
83     A_SCDOWN,
84     A_DEFFONT,
85     A_IMPXML,
86     A_IMPXMLA,
87     A_IMPTXTI,
88     A_IMPTXTC,
89     A_IMPTXTS,
90     A_IMPTXTT,
91     A_HELP,
92     A_MARKVARD,
93     A_MARKVARU,
94     A_SHOWSBAR,
95     A_SHOWTBAR,
96     A_LEFTTABS,
97     A_TRADSCROLL,
98     A_HOME,
99     A_END,
100     A_CHOME,
101     A_CEND,
102     A_PRINT,
103     A_PREVIEW,
104     A_PAGESETUP,
105     A_PRINTSCALE,
106     A_EXIT,
107     A_NEXT,
108     A_PREV,
109     A_BOLD,
110     A_ITALIC,
111     A_TT,
112     A_UNDERL,
113     A_SEARCH,
114     A_REPLACE,
115     A_REPLACEONCE,
116     A_REPLACEONCEJ,
117     A_REPLACEALL,
118     A_SELALL,
119     A_CANCELEDIT,
120     A_BROWSE,
121     A_ENTERCELL,
122     A_CELLCOLOR,
123     A_TEXTCOLOR,
124     A_BORDCOLOR,
125     A_INCSIZE,
126     A_DECSIZE,
127     A_INCWIDTH,
128     A_DECWIDTH,
129     A_ENTERGRID,
130     A_LINK,
131     A_LINKREV,
132     A_SEARCHNEXT,
133     A_CUSTCOL,
134     A_COLCELL,
135     A_SORT,
136     A_SEARCHF,
137     A_MAKEBAKS,
138     A_TOTRAY,
139     A_AUTOSAVE,
140     A_FULLSCREEN,
141     A_SCALED,
142     A_SCOLS,
143     A_SROWS,
144     A_SHOME,
145     A_SEND,
146     A_BORD0,
147     A_BORD1,
148     A_BORD2,
149     A_BORD3,
150     A_BORD4,
151     A_BORD5,
152     A_HSWAP,
153     A_TEXTGRID,
154     A_TAGADD,
155     A_TAGREMOVE,
156     A_WRAP,
157     A_HIFY,
158     A_FLATTEN,
159     A_BROWSEF,
160     A_ROUND0,
161     A_ROUND1,
162     A_ROUND2,
163     A_ROUND3,
164     A_ROUND4,
165     A_ROUND5,
166     A_ROUND6,
167     A_FILTER5,
168     A_FILTER10,
169     A_FILTER20,
170     A_FILTER50,
171     A_FILTERM,
172     A_FILTERL,
173     A_FILTERS,
174     A_FILTEROFF,
175     A_FASTRENDER,
176     A_EXPCSV,
177     A_PASTESTYLE,
178     A_PREVFILE,
179     A_NEXTFILE,
180     A_IMAGER,
181     A_INCWIDTHNH,
182     A_DECWIDTHNH,
183     A_ZOOMSCR,
184     A_ICONSET,
185     A_V_GS,
186     A_V_BS,
187     A_V_LS,
188     A_H_GS,
189     A_H_BS,
190     A_H_LS,
191     A_GS,
192     A_BS,
193     A_LS,
194     A_RESETSIZE,
195     A_RESETWIDTH,
196     A_RESETSTYLE,
197     A_RESETCOLOR,
198     A_DDIMAGE,
199     A_MINCLOSE,
200     A_SINGLETRAY,
201     A_CENTERED,
202     A_SORTD,
203     A_STRIKET,
204     A_FOLD,
205     A_FOLDALL,
206     A_UNFOLDALL,
207     A_IMAGESCP,
208     A_IMAGESCF,
209     A_IMAGESCN,
210     A_HELPI,
211     A_REDO,
212     A_FSWATCH,
213     A_DEFBGCOL,
214     A_THINSELC,
215     A_COPYCT,
216     A_MINISIZE,
217     A_CUSTKEY,
218     A_AUTOEXPORT,
219     A_NOP,
220     A_TAGSET = 1000,  // and all values from here on
221     A_SCRIPT = 2000,  // and all values from here on
222     A_MAXACTION = 3000
223 };
224 
225 enum {
226     STYLE_BOLD = 1,
227     STYLE_ITALIC = 2,
228     STYLE_FIXED = 4,
229     STYLE_UNDERLINE = 8,
230     STYLE_STRIKETHRU = 16
231 };
232 
233 #include "script_interface.h"
234 
235 using namespace script;
236 
237 struct treesheets {
238     struct TreeSheetsScriptImpl;
239 
240     struct Cell;
241     struct Grid;
242     struct Text;
243     struct Evaluator;
244     struct Image;
245     struct Document;
246     class Selection;
247 
248     struct System;
249 
250     struct MyApp;
251     struct MyFrame;
252     struct TSCanvas;
253 
254     static System *sys;
255 
256     #include "treesheets_impl.h"
257 
258     #include "selection.h"
259     #include "text.h"
260     #include "cell.h"
261     #include "grid.h"
262     #include "evaluator.h"
263 
264     #include "document.h"
265     #include "system.h"
266 
267     #include "mywxtools.h"
268     #include "mycanvas.h"
269     #include "myframe.h"
270     #include "myapp.h"
271 };
272 
273 treesheets::System *treesheets::sys = nullptr;
274 treesheets::TreeSheetsScriptImpl treesheets::tssi;
275 
276 IMPLEMENT_APP(treesheets::MyApp)
277 
278 #include "myevents.h"
279