]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: reswrite.cpp | |
3 | // Purpose: Resource writing functionality | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx/wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/wx.h" | |
25 | #endif | |
26 | ||
27 | #include <ctype.h> | |
28 | #include <stdlib.h> | |
29 | #include <math.h> | |
30 | #include <string.h> | |
31 | ||
203feea8 | 32 | #if wxUSE_IOSTREAMH |
2049ba38 | 33 | #if defined(__WXMSW__) && !defined(__GNUWIN32__) |
457814b5 JS |
34 | #include <strstrea.h> |
35 | #else | |
36 | #include <strstream.h> | |
203feea8 UU |
37 | #include <fstream.h> |
38 | #endif | |
39 | #else | |
40 | #include <strstream> | |
41 | #include <fstream> | |
457814b5 JS |
42 | #endif |
43 | ||
457814b5 JS |
44 | |
45 | #include "wx/scrolbar.h" | |
46 | #include "wx/string.h" | |
47 | ||
48 | #include "reseditr.h" | |
49 | ||
50 | char *SafeString(char *s); | |
fd71308f | 51 | char *SafeWord(const wxString& s); |
457814b5 JS |
52 | |
53 | // Save an association between the child resource and the panel item, to allow | |
54 | // us not to require unique window names. | |
fd71308f | 55 | wxControl *wxResourceTableWithSaving::CreateItem(wxPanel *panel, const wxItemResource *childResource, const wxItemResource* parentResource) |
457814b5 | 56 | { |
fd71308f | 57 | wxControl *item = wxResourceTable::CreateItem(panel, childResource, parentResource); |
457814b5 | 58 | if (item) |
ae8351fc | 59 | wxResourceManager::GetCurrentResourceManager()->GetResourceAssociations().Put((long)childResource, item); |
457814b5 JS |
60 | return item; |
61 | } | |
62 | ||
fd71308f | 63 | void wxResourceTableWithSaving::OutputFont(ostream& stream, const wxFont& font) |
457814b5 | 64 | { |
fd71308f JS |
65 | stream << "[" << font.GetPointSize() << ", '"; |
66 | stream << font.GetFamilyString() << "', '"; | |
67 | stream << font.GetStyleString() << "', '"; | |
68 | stream << font.GetWeightString() << "', "; | |
69 | stream << (int)font.GetUnderlined(); | |
70 | if (font.GetFaceName() != "") | |
71 | stream << ", '" << font.GetFaceName() << "'"; | |
457814b5 JS |
72 | stream << "]"; |
73 | } | |
74 | ||
75 | /* | |
76 | * Resource table with saving (basic one only has loading) | |
77 | */ | |
78 | ||
79 | bool wxResourceTableWithSaving::Save(const wxString& filename) | |
80 | { | |
81 | ofstream stream(((wxString &) filename).GetData()); | |
82 | if (stream.bad()) | |
83 | return FALSE; | |
84 | ||
85 | BeginFind(); | |
86 | wxNode *node = NULL; | |
fd71308f | 87 | while ((node = Next())) |
457814b5 JS |
88 | { |
89 | wxItemResource *item = (wxItemResource *)node->Data(); | |
90 | wxString resType(item->GetType()); | |
91 | ||
92 | if (resType == "wxDialogBox" || resType == "wxDialog" || resType == "wxPanel" || resType == "wxBitmap") | |
93 | { | |
fd71308f | 94 | if (!SaveResource(stream, item, (wxItemResource*) NULL)) |
457814b5 JS |
95 | return FALSE; |
96 | } | |
97 | } | |
98 | return TRUE; | |
99 | } | |
100 | ||
fd71308f | 101 | bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource* item, wxItemResource* parentItem) |
457814b5 JS |
102 | { |
103 | char styleBuf[400]; | |
104 | wxString itemType(item->GetType()); | |
105 | ||
106 | if (itemType == "wxDialogBox" || itemType == "wxDialog" || itemType == "wxPanel") | |
107 | { | |
108 | if (itemType == "wxDialogBox" || itemType == "wxDialog") | |
109 | { | |
110 | stream << "static char *" << item->GetName() << " = \"dialog(name = '" << item->GetName() << "',\\\n"; | |
111 | GenerateDialogStyleString(item->GetStyle(), styleBuf); | |
112 | } | |
113 | else | |
114 | { | |
115 | stream << "static char *" << item->GetName() << " = \"panel(name = '" << item->GetName() << "',\\\n"; | |
bbcdf8bc | 116 | GenerateDialogStyleString(item->GetStyle(), styleBuf); |
457814b5 | 117 | } |
fd71308f | 118 | |
457814b5 JS |
119 | stream << " style = '" << styleBuf << "',\\\n"; |
120 | stream << " title = '" << item->GetTitle() << "',\\\n"; | |
bbcdf8bc | 121 | stream << " id = " << item->GetId() << ",\\\n"; |
457814b5 | 122 | stream << " x = " << item->GetX() << ", y = " << item->GetY(); |
ae8351fc | 123 | stream << ", width = " << item->GetWidth() << ", height = " << item->GetHeight(); |
bbcdf8bc | 124 | |
ae8351fc | 125 | if (1) // item->GetStyle() & wxNO_3D) |
457814b5 | 126 | { |
fd71308f | 127 | if (item->GetBackgroundColour().Ok()) |
457814b5 JS |
128 | { |
129 | char buf[7]; | |
fd71308f JS |
130 | wxDecToHex(item->GetBackgroundColour().Red(), buf); |
131 | wxDecToHex(item->GetBackgroundColour().Green(), buf+2); | |
132 | wxDecToHex(item->GetBackgroundColour().Blue(), buf+4); | |
457814b5 JS |
133 | buf[6] = 0; |
134 | ||
135 | stream << ",\\\n " << "background_colour = '" << buf << "'"; | |
136 | } | |
457814b5 | 137 | } |
fd71308f JS |
138 | |
139 | int dialogUnits = 0; | |
140 | int useDefaults = 0; | |
141 | if ((item->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) | |
142 | dialogUnits = 1; | |
143 | if ((item->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) | |
144 | useDefaults = 1; | |
145 | ||
146 | stream << ",\\\n " << "use_dialog_units = " << dialogUnits; | |
147 | stream << ",\\\n " << "use_system_defaults = " << useDefaults; | |
457814b5 | 148 | |
fd71308f | 149 | if (item->GetFont().Ok()) |
457814b5 JS |
150 | { |
151 | stream << ",\\\n font = "; | |
152 | OutputFont(stream, item->GetFont()); | |
153 | } | |
ae8351fc | 154 | |
457814b5 JS |
155 | if (item->GetChildren().Number() > 0) |
156 | stream << ",\\\n"; | |
157 | else | |
158 | stream << "\\\n"; | |
159 | wxNode *node = item->GetChildren().First(); | |
160 | while (node) | |
161 | { | |
162 | wxItemResource *child = (wxItemResource *)node->Data(); | |
163 | ||
164 | stream << " control = ["; | |
165 | ||
fd71308f | 166 | SaveResource(stream, child, item); |
457814b5 JS |
167 | |
168 | stream << "]"; | |
169 | ||
170 | if (node->Next()) | |
171 | stream << ",\\\n"; | |
172 | node = node->Next(); | |
173 | } | |
174 | stream << ").\";\n\n"; | |
175 | } | |
ae8351fc | 176 | else if (itemType == "wxButton" || itemType == "wxBitmapButton") |
457814b5 | 177 | { |
bbcdf8bc JS |
178 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
179 | stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
180 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
181 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
182 | if (item->GetValue4()) | |
183 | stream << ", '" << item->GetValue4() << "'"; | |
fd71308f | 184 | if (item->GetFont().Ok()) |
457814b5 JS |
185 | { |
186 | stream << ",\\\n "; | |
187 | OutputFont(stream, item->GetFont()); | |
188 | } | |
189 | } | |
ae8351fc | 190 | else if (itemType == "wxStaticText" || itemType == "wxStaticBitmap") |
457814b5 | 191 | { |
bbcdf8bc JS |
192 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
193 | stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
194 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
195 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
196 | if (item->GetValue4()) | |
197 | stream << ", '" << item->GetValue4() << "'"; | |
fd71308f | 198 | if (item->GetFont().Ok()) |
457814b5 JS |
199 | { |
200 | stream << ",\\\n "; | |
201 | OutputFont(stream, item->GetFont()); | |
202 | } | |
203 | } | |
204 | else if (itemType == "wxCheckBox") | |
205 | { | |
bbcdf8bc JS |
206 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
207 | stream << item->GetId() << ", " << "wxCheckBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
208 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
209 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
210 | stream << ", " << item->GetValue1(); | |
fd71308f | 211 | if (item->GetFont().Ok()) |
457814b5 JS |
212 | { |
213 | stream << ",\\\n "; | |
214 | OutputFont(stream, item->GetFont()); | |
215 | } | |
216 | } | |
03f68f12 JS |
217 | else if (itemType == "wxRadioButton") |
218 | { | |
bbcdf8bc JS |
219 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
220 | stream << item->GetId() << ", " << "wxRadioButton, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
03f68f12 JS |
221 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
222 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
223 | stream << ", " << item->GetValue1(); | |
fd71308f | 224 | if (item->GetFont().Ok()) |
03f68f12 JS |
225 | { |
226 | stream << ",\\\n "; | |
227 | OutputFont(stream, item->GetFont()); | |
228 | } | |
229 | } | |
ae8351fc | 230 | else if (itemType == "wxStaticBox") |
457814b5 | 231 | { |
bbcdf8bc | 232 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
9c331ded | 233 | stream << item->GetId() << ", " << "wxStaticBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; |
457814b5 JS |
234 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
235 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
fd71308f | 236 | if (item->GetFont().Ok()) |
457814b5 JS |
237 | { |
238 | stream << ",\\\n "; | |
239 | OutputFont(stream, item->GetFont()); | |
240 | } | |
241 | } | |
ae8351fc | 242 | else if (itemType == "wxText" || itemType == "wxMultiText" || itemType == "wxTextCtrl") |
457814b5 | 243 | { |
bbcdf8bc JS |
244 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
245 | stream << item->GetId() << ", " << "wxTextCtrl, "; | |
457814b5 JS |
246 | stream << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; |
247 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; | |
248 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
249 | stream << ", " << SafeWord(item->GetValue4()); | |
fd71308f | 250 | if (item->GetFont().Ok()) |
457814b5 JS |
251 | { |
252 | stream << ",\\\n "; | |
253 | OutputFont(stream, item->GetFont()); | |
254 | } | |
255 | } | |
256 | else if (itemType == "wxGauge") | |
257 | { | |
bbcdf8bc JS |
258 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
259 | stream << item->GetId() << ", " << "wxGauge, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
260 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
261 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
262 | stream << ", " << item->GetValue1() << ", " << item->GetValue2(); | |
fd71308f | 263 | if (item->GetFont().Ok()) |
457814b5 JS |
264 | { |
265 | stream << ",\\\n "; | |
266 | OutputFont(stream, item->GetFont()); | |
267 | } | |
268 | } | |
269 | else if (itemType == "wxSlider") | |
270 | { | |
bbcdf8bc JS |
271 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
272 | stream << item->GetId() << ", " << "wxSlider, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
273 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
274 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
275 | stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3(); | |
fd71308f | 276 | if (item->GetFont().Ok()) |
457814b5 JS |
277 | { |
278 | stream << ",\\\n "; | |
279 | OutputFont(stream, item->GetFont()); | |
280 | } | |
281 | } | |
282 | else if (itemType == "wxScrollBar") | |
283 | { | |
bbcdf8bc JS |
284 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
285 | stream << item->GetId() << ", " << "wxScrollBar, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
286 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
287 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
288 | stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3() << ", "; | |
289 | stream << item->GetValue5(); | |
290 | } | |
291 | else if (itemType == "wxListBox") | |
292 | { | |
bbcdf8bc JS |
293 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
294 | stream << item->GetId() << ", " << "wxListBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
295 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
296 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
297 | ||
298 | // Default list of values | |
299 | ||
300 | stream << ", ["; | |
fd71308f | 301 | if (item->GetStringValues().Number() > 0) |
457814b5 | 302 | { |
fd71308f | 303 | wxNode *node = item->GetStringValues().First(); |
457814b5 JS |
304 | while (node) |
305 | { | |
306 | char *s = (char *)node->Data(); | |
307 | stream << SafeWord(s); | |
308 | if (node->Next()) | |
309 | stream << ", "; | |
310 | node = node->Next(); | |
311 | } | |
312 | } | |
313 | stream << "], "; | |
314 | switch (item->GetValue1()) | |
315 | { | |
316 | case wxLB_MULTIPLE: | |
317 | { | |
318 | stream << "'wxLB_MULTIPLE'"; | |
319 | break; | |
320 | } | |
321 | case wxLB_EXTENDED: | |
322 | { | |
323 | stream << "'wxLB_EXTENDED'"; | |
324 | break; | |
325 | } | |
326 | case wxLB_SINGLE: | |
327 | default: | |
328 | { | |
329 | stream << "'wxLB_SINGLE'"; | |
330 | break; | |
331 | } | |
332 | } | |
fd71308f | 333 | if (item->GetFont().Ok()) |
457814b5 JS |
334 | { |
335 | stream << ",\\\n "; | |
336 | OutputFont(stream, item->GetFont()); | |
337 | } | |
338 | } | |
bbcdf8bc | 339 | else if (itemType == "wxChoice" || itemType == "wxComboBox") |
457814b5 | 340 | { |
bbcdf8bc JS |
341 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
342 | ||
343 | stream << item->GetId() << ", " << itemType << ", " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
344 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
345 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
346 | ||
bbcdf8bc | 347 | if (itemType == "wxComboBox") |
9c331ded | 348 | stream << ", " << SafeWord(item->GetValue4()); |
bbcdf8bc | 349 | |
457814b5 JS |
350 | // Default list of values |
351 | ||
352 | stream << ", ["; | |
fd71308f | 353 | if (item->GetStringValues().Number() > 0) |
457814b5 | 354 | { |
fd71308f | 355 | wxNode *node = item->GetStringValues().First(); |
457814b5 JS |
356 | while (node) |
357 | { | |
358 | char *s = (char *)node->Data(); | |
359 | stream << SafeWord(s); | |
360 | if (node->Next()) | |
361 | stream << ", "; | |
362 | node = node->Next(); | |
363 | } | |
364 | } | |
365 | stream << "]"; | |
fd71308f | 366 | if (item->GetFont().Ok()) |
457814b5 JS |
367 | { |
368 | stream << ",\\\n "; | |
369 | OutputFont(stream, item->GetFont()); | |
370 | } | |
371 | } | |
372 | else if (itemType == "wxRadioBox") | |
373 | { | |
374 | // Must write out the orientation and number of rows/cols!! | |
bbcdf8bc JS |
375 | GenerateControlStyleString(itemType, item->GetStyle(), styleBuf); |
376 | stream << item->GetId() << ", " << "wxRadioBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', "; | |
457814b5 JS |
377 | stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", "; |
378 | stream << item->GetWidth() << ", " << item->GetHeight(); | |
379 | ||
380 | // Default list of values | |
381 | ||
382 | stream << ", ["; | |
fd71308f | 383 | if (item->GetStringValues().Number() > 0) |
457814b5 | 384 | { |
fd71308f | 385 | wxNode *node = item->GetStringValues().First(); |
457814b5 JS |
386 | while (node) |
387 | { | |
388 | char *s = (char *)node->Data(); | |
389 | stream << SafeWord(s); | |
390 | if (node->Next()) | |
391 | stream << ", "; | |
392 | node = node->Next(); | |
393 | } | |
394 | } | |
395 | stream << "], " << item->GetValue1(); | |
fd71308f | 396 | if (item->GetFont().Ok()) |
457814b5 JS |
397 | { |
398 | stream << ",\\\n "; | |
399 | OutputFont(stream, item->GetFont()); | |
400 | } | |
401 | } | |
402 | else if (itemType == "wxBitmap") | |
403 | { | |
404 | stream << "static char *" << item->GetName() << " = \"bitmap(name = '" << item->GetName() << "',\\\n"; | |
405 | ||
406 | wxNode *node = item->GetChildren().First(); | |
407 | while (node) | |
408 | { | |
409 | wxItemResource *child = (wxItemResource *)node->Data(); | |
410 | stream << " bitmap = ["; | |
411 | ||
412 | char buf[400]; | |
413 | strcpy(buf, child->GetName()); | |
2049ba38 | 414 | #ifdef __WXMSW__ |
457814b5 JS |
415 | wxDos2UnixFilename(buf); |
416 | #endif | |
417 | ||
418 | stream << "'" << buf << "', "; | |
419 | ||
420 | int bitmapType = (int)child->GetValue1(); | |
421 | switch (bitmapType) | |
422 | { | |
423 | case wxBITMAP_TYPE_XBM_DATA: | |
424 | { | |
425 | stream << "wxBITMAP_TYPE_XBM_DATA"; | |
426 | break; | |
427 | } | |
428 | case wxBITMAP_TYPE_XPM_DATA: | |
429 | { | |
430 | stream << "wxBITMAP_TYPE_XPM_DATA"; | |
431 | break; | |
432 | } | |
433 | case wxBITMAP_TYPE_XBM: | |
434 | { | |
435 | stream << "wxBITMAP_TYPE_XBM"; | |
436 | break; | |
437 | } | |
438 | case wxBITMAP_TYPE_XPM: | |
439 | { | |
440 | stream << "wxBITMAP_TYPE_XPM"; | |
441 | break; | |
442 | } | |
443 | case wxBITMAP_TYPE_BMP: | |
444 | { | |
445 | stream << "wxBITMAP_TYPE_BMP"; | |
446 | break; | |
447 | } | |
448 | case wxBITMAP_TYPE_BMP_RESOURCE: | |
449 | { | |
450 | stream << "wxBITMAP_TYPE_BMP_RESOURCE"; | |
451 | break; | |
452 | } | |
453 | case wxBITMAP_TYPE_GIF: | |
454 | { | |
455 | stream << "wxBITMAP_TYPE_GIF"; | |
456 | break; | |
457 | } | |
458 | case wxBITMAP_TYPE_TIF: | |
459 | { | |
460 | stream << "wxBITMAP_TYPE_TIF"; | |
461 | break; | |
462 | } | |
463 | case wxBITMAP_TYPE_ICO: | |
464 | { | |
465 | stream << "wxBITMAP_TYPE_ICO"; | |
466 | break; | |
467 | } | |
468 | case wxBITMAP_TYPE_ICO_RESOURCE: | |
469 | { | |
470 | stream << "wxBITMAP_TYPE_ICO_RESOURCE"; | |
471 | break; | |
472 | } | |
473 | case wxBITMAP_TYPE_CUR: | |
474 | { | |
475 | stream << "wxBITMAP_TYPE_CUR"; | |
476 | break; | |
477 | } | |
478 | case wxBITMAP_TYPE_CUR_RESOURCE: | |
479 | { | |
480 | stream << "wxBITMAP_TYPE_CUR_RESOURCE"; | |
481 | break; | |
482 | } | |
483 | default: | |
484 | case wxBITMAP_TYPE_ANY: | |
485 | { | |
486 | stream << "wxBITMAP_TYPE_ANY"; | |
487 | break; | |
488 | } | |
489 | } | |
490 | stream << ", "; | |
491 | int platform = child->GetValue2(); | |
492 | switch (platform) | |
493 | { | |
494 | case RESOURCE_PLATFORM_WINDOWS: | |
495 | { | |
496 | stream << "'WINDOWS'"; | |
497 | break; | |
498 | } | |
499 | case RESOURCE_PLATFORM_X: | |
500 | { | |
501 | stream << "'X'"; | |
502 | break; | |
503 | } | |
504 | case RESOURCE_PLATFORM_MAC: | |
505 | { | |
506 | stream << "'MAC'"; | |
507 | break; | |
508 | } | |
509 | case RESOURCE_PLATFORM_ANY: | |
510 | { | |
511 | stream << "'ANY'"; | |
512 | break; | |
513 | } | |
514 | } | |
515 | int noColours = (int)child->GetValue3(); | |
516 | if (noColours > 0) | |
517 | stream << ", " << noColours; | |
518 | ||
519 | stream << "]"; | |
520 | ||
521 | if (node->Next()) | |
522 | stream << ",\\\n"; | |
523 | ||
524 | node = node->Next(); | |
525 | } | |
526 | stream << ").\";\n\n"; | |
527 | } | |
9c331ded JS |
528 | else |
529 | { | |
530 | wxString str("Unimplemented resource type: "); | |
531 | str += itemType; | |
532 | wxMessageBox(str); | |
533 | } | |
457814b5 JS |
534 | return TRUE; |
535 | } | |
536 | ||
457814b5 JS |
537 | void wxResourceTableWithSaving::GenerateDialogStyleString(long windowStyle, char *buf) |
538 | { | |
539 | buf[0] = 0; | |
bbcdf8bc JS |
540 | m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); |
541 | m_styleTable.GenerateStyleStrings("wxPanel", windowStyle, buf); | |
542 | m_styleTable.GenerateStyleStrings("wxDialog", windowStyle, buf); | |
457814b5 | 543 | |
457814b5 JS |
544 | if (strlen(buf) == 0) |
545 | strcat(buf, "0"); | |
546 | } | |
547 | ||
548 | void wxResourceTableWithSaving::GeneratePanelStyleString(long windowStyle, char *buf) | |
549 | { | |
550 | buf[0] = 0; | |
bbcdf8bc JS |
551 | m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); |
552 | m_styleTable.GenerateStyleStrings("wxPanel", windowStyle, buf); | |
457814b5 | 553 | |
457814b5 JS |
554 | if (strlen(buf) == 0) |
555 | strcat(buf, "0"); | |
556 | } | |
557 | ||
457814b5 | 558 | |
bbcdf8bc | 559 | void wxResourceTableWithSaving::GenerateControlStyleString(const wxString& windowClass, long windowStyle, char *buf) |
457814b5 JS |
560 | { |
561 | buf[0] = 0; | |
bbcdf8bc JS |
562 | m_styleTable.GenerateStyleStrings("wxWindow", windowStyle, buf); |
563 | m_styleTable.GenerateStyleStrings("wxControl", windowStyle, buf); | |
564 | m_styleTable.GenerateStyleStrings(windowClass, windowStyle, buf); | |
457814b5 | 565 | |
457814b5 JS |
566 | if (strlen(buf) == 0) |
567 | strcat(buf, "0"); | |
568 | } | |
569 | ||
457814b5 | 570 | // Returns quoted string or "NULL" |
fd71308f | 571 | char *SafeString(const wxString& s) |
457814b5 | 572 | { |
fd71308f | 573 | if (s == "") |
457814b5 JS |
574 | return "NULL"; |
575 | else | |
576 | { | |
577 | strcpy(wxBuffer, "\""); | |
578 | strcat(wxBuffer, s); | |
579 | strcat(wxBuffer, "\""); | |
580 | return wxBuffer; | |
581 | } | |
582 | } | |
583 | ||
584 | // Returns quoted string or '' | |
fd71308f | 585 | char *SafeWord(const wxString& s) |
457814b5 | 586 | { |
fd71308f | 587 | if (s == "") |
457814b5 JS |
588 | return "''"; |
589 | else | |
590 | { | |
591 | strcpy(wxBuffer, "'"); | |
fd71308f | 592 | strcat(wxBuffer, (const char*) s); |
457814b5 JS |
593 | strcat(wxBuffer, "'"); |
594 | return wxBuffer; | |
595 | } | |
596 | } | |
597 |