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