]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/reswrite.cpp
*** empty log message ***
[wxWidgets.git] / utils / dialoged / src / reswrite.cpp
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(__WINDOWS__) && !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(char *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, wxItemResource *childResource)
51 {
52 wxControl *item = wxResourceTable::CreateItem(panel, childResource);
53 if (item)
54 wxResourceManager::currentResourceManager->GetResourceAssociations().Put((long)childResource, item);
55 return item;
56 }
57
58 void wxResourceTableWithSaving::OutputFont(ostream& stream, 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))
90 return FALSE;
91 }
92 }
93 return TRUE;
94 }
95
96 bool wxResourceTableWithSaving::SaveResource(ostream& stream, wxItemResource *item)
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 GeneratePanelStyleString(item->GetStyle(), styleBuf);
112 }
113 stream << " style = '" << styleBuf << "',\\\n";
114 stream << " title = '" << item->GetTitle() << "',\\\n";
115 stream << " x = " << item->GetX() << ", y = " << item->GetY();
116 stream << ", width = " << item->GetWidth() << ", height = " << item->GetHeight() << ",\\\n";
117 stream << " modal = " << item->GetValue1();
118
119 if (item->GetStyle() & wxUSER_COLOURS)
120 {
121 if (item->GetBackgroundColour())
122 {
123 char buf[7];
124 wxDecToHex(item->GetBackgroundColour()->Red(), buf);
125 wxDecToHex(item->GetBackgroundColour()->Green(), buf+2);
126 wxDecToHex(item->GetBackgroundColour()->Blue(), buf+4);
127 buf[6] = 0;
128
129 stream << ",\\\n " << "background_colour = '" << buf << "'";
130 }
131 if (item->GetLabelColour())
132 {
133 char buf[7];
134 wxDecToHex(item->GetLabelColour()->Red(), buf);
135 wxDecToHex(item->GetLabelColour()->Green(), buf+2);
136 wxDecToHex(item->GetLabelColour()->Blue(), buf+4);
137 buf[6] = 0;
138
139 stream << ",\\\n " << "label_colour = '" << buf << "'";
140 }
141 if (item->GetButtonColour())
142 {
143 char buf[7];
144 wxDecToHex(item->GetButtonColour()->Red(), buf);
145 wxDecToHex(item->GetButtonColour()->Green(), buf+2);
146 wxDecToHex(item->GetButtonColour()->Blue(), buf+4);
147 buf[6] = 0;
148
149 stream << ",\\\n " << "button_colour = '" << buf << "'";
150 }
151 }
152
153 if (item->GetFont())
154 {
155 stream << ",\\\n font = ";
156 OutputFont(stream, item->GetFont());
157 }
158 /*
159 if (item->GetButtonFont())
160 {
161 stream << ",\\\n button_font = ";
162 OutputFont(stream, item->GetButtonFont());
163 }
164 */
165
166 if (item->GetChildren().Number() > 0)
167 stream << ",\\\n";
168 else
169 stream << "\\\n";
170 wxNode *node = item->GetChildren().First();
171 while (node)
172 {
173 wxItemResource *child = (wxItemResource *)node->Data();
174
175 stream << " control = [";
176
177 SaveResource(stream, child);
178
179 stream << "]";
180
181 if (node->Next())
182 stream << ",\\\n";
183 node = node->Next();
184 }
185 stream << ").\";\n\n";
186 }
187 else if (itemType == "wxButton")
188 {
189 GenerateButtonStyleString(item->GetStyle(), styleBuf);
190 stream << "wxButton, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
191 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
192 stream << item->GetWidth() << ", " << item->GetHeight();
193 if (item->GetValue4())
194 stream << ", '" << item->GetValue4() << "'";
195 if (item->GetFont())
196 {
197 stream << ",\\\n ";
198 OutputFont(stream, item->GetFont());
199 }
200 }
201 else if (itemType == "wxMessage")
202 {
203 GenerateMessageStyleString(item->GetStyle(), styleBuf);
204 stream << "wxMessage, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
205 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
206 stream << item->GetWidth() << ", " << item->GetHeight();
207 if (item->GetValue4())
208 stream << ", '" << item->GetValue4() << "'";
209 if (item->GetFont())
210 {
211 stream << ",\\\n ";
212 OutputFont(stream, item->GetFont());
213 }
214 }
215 else if (itemType == "wxCheckBox")
216 {
217 GenerateCheckBoxStyleString(item->GetStyle(), styleBuf);
218 stream << "wxCheckBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
219 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
220 stream << item->GetWidth() << ", " << item->GetHeight();
221 stream << ", " << item->GetValue1();
222 if (item->GetFont())
223 {
224 stream << ",\\\n ";
225 OutputFont(stream, item->GetFont());
226 }
227 }
228 else if (itemType == "wxGroupBox")
229 {
230 GenerateGroupBoxStyleString(item->GetStyle(), styleBuf);
231 stream << "wxGroupBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
232 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
233 stream << item->GetWidth() << ", " << item->GetHeight();
234 if (item->GetFont())
235 {
236 stream << ",\\\n ";
237 OutputFont(stream, item->GetFont());
238 }
239 }
240 else if (itemType == "wxText" || itemType == "wxMultiText")
241 {
242 GenerateTextStyleString(item->GetStyle(), styleBuf);
243 stream << ((itemType == "wxText") ? "wxText, " : "wxMultiText, ");
244 stream << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
245 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
246 stream << item->GetWidth() << ", " << item->GetHeight();
247 stream << ", " << SafeWord(item->GetValue4());
248 if (item->GetFont())
249 {
250 stream << ",\\\n ";
251 OutputFont(stream, item->GetFont());
252 }
253 }
254 else if (itemType == "wxGauge")
255 {
256 GenerateGaugeStyleString(item->GetStyle(), styleBuf);
257 stream << "wxGauge, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
258 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
259 stream << item->GetWidth() << ", " << item->GetHeight();
260 stream << ", " << item->GetValue1() << ", " << item->GetValue2();
261 if (item->GetFont())
262 {
263 stream << ",\\\n ";
264 OutputFont(stream, item->GetFont());
265 }
266 }
267 else if (itemType == "wxSlider")
268 {
269 GenerateSliderStyleString(item->GetStyle(), styleBuf);
270 stream << "wxSlider, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
271 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
272 stream << item->GetWidth() << ", " << item->GetHeight();
273 stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3();
274 if (item->GetFont())
275 {
276 stream << ",\\\n ";
277 OutputFont(stream, item->GetFont());
278 }
279 }
280 else if (itemType == "wxScrollBar")
281 {
282 GenerateScrollBarStyleString(item->GetStyle(), styleBuf);
283 stream << "wxScrollBar, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
284 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
285 stream << item->GetWidth() << ", " << item->GetHeight();
286 stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3() << ", ";
287 stream << item->GetValue5();
288 }
289 else if (itemType == "wxListBox")
290 {
291 GenerateListBoxStyleString(item->GetStyle(), styleBuf);
292 stream << "wxListBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
293 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
294 stream << item->GetWidth() << ", " << item->GetHeight();
295
296 // Default list of values
297
298 stream << ", [";
299 if (item->GetStringValues())
300 {
301 wxNode *node = item->GetStringValues()->First();
302 while (node)
303 {
304 char *s = (char *)node->Data();
305 stream << SafeWord(s);
306 if (node->Next())
307 stream << ", ";
308 node = node->Next();
309 }
310 }
311 stream << "], ";
312 switch (item->GetValue1())
313 {
314 case wxLB_MULTIPLE:
315 {
316 stream << "'wxLB_MULTIPLE'";
317 break;
318 }
319 case wxLB_EXTENDED:
320 {
321 stream << "'wxLB_EXTENDED'";
322 break;
323 }
324 case wxLB_SINGLE:
325 default:
326 {
327 stream << "'wxLB_SINGLE'";
328 break;
329 }
330 }
331 if (item->GetFont())
332 {
333 stream << ",\\\n ";
334 OutputFont(stream, item->GetFont());
335 }
336 }
337 else if (itemType == "wxChoice")
338 {
339 GenerateChoiceStyleString(item->GetStyle(), styleBuf);
340 stream << "wxChoice, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
341 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
342 stream << item->GetWidth() << ", " << item->GetHeight();
343
344 // Default list of values
345
346 stream << ", [";
347 if (item->GetStringValues())
348 {
349 wxNode *node = item->GetStringValues()->First();
350 while (node)
351 {
352 char *s = (char *)node->Data();
353 stream << SafeWord(s);
354 if (node->Next())
355 stream << ", ";
356 node = node->Next();
357 }
358 }
359 stream << "]";
360 if (item->GetFont())
361 {
362 stream << ",\\\n ";
363 OutputFont(stream, item->GetFont());
364 }
365 }
366 else if (itemType == "wxRadioBox")
367 {
368 // Must write out the orientation and number of rows/cols!!
369 GenerateRadioBoxStyleString(item->GetStyle(), styleBuf);
370 stream << "wxRadioBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
371 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
372 stream << item->GetWidth() << ", " << item->GetHeight();
373
374 // Default list of values
375
376 stream << ", [";
377 if (item->GetStringValues())
378 {
379 wxNode *node = item->GetStringValues()->First();
380 while (node)
381 {
382 char *s = (char *)node->Data();
383 stream << SafeWord(s);
384 if (node->Next())
385 stream << ", ";
386 node = node->Next();
387 }
388 }
389 stream << "], " << item->GetValue1();
390 if (item->GetFont())
391 {
392 stream << ",\\\n ";
393 OutputFont(stream, item->GetFont());
394 }
395 }
396 else if (itemType == "wxBitmap")
397 {
398 stream << "static char *" << item->GetName() << " = \"bitmap(name = '" << item->GetName() << "',\\\n";
399
400 wxNode *node = item->GetChildren().First();
401 while (node)
402 {
403 wxItemResource *child = (wxItemResource *)node->Data();
404 stream << " bitmap = [";
405
406 char buf[400];
407 strcpy(buf, child->GetName());
408 #ifdef __WINDOWS__
409 wxDos2UnixFilename(buf);
410 #endif
411
412 stream << "'" << buf << "', ";
413
414 int bitmapType = (int)child->GetValue1();
415 switch (bitmapType)
416 {
417 case wxBITMAP_TYPE_XBM_DATA:
418 {
419 stream << "wxBITMAP_TYPE_XBM_DATA";
420 break;
421 }
422 case wxBITMAP_TYPE_XPM_DATA:
423 {
424 stream << "wxBITMAP_TYPE_XPM_DATA";
425 break;
426 }
427 case wxBITMAP_TYPE_XBM:
428 {
429 stream << "wxBITMAP_TYPE_XBM";
430 break;
431 }
432 case wxBITMAP_TYPE_XPM:
433 {
434 stream << "wxBITMAP_TYPE_XPM";
435 break;
436 }
437 case wxBITMAP_TYPE_BMP:
438 {
439 stream << "wxBITMAP_TYPE_BMP";
440 break;
441 }
442 case wxBITMAP_TYPE_BMP_RESOURCE:
443 {
444 stream << "wxBITMAP_TYPE_BMP_RESOURCE";
445 break;
446 }
447 case wxBITMAP_TYPE_GIF:
448 {
449 stream << "wxBITMAP_TYPE_GIF";
450 break;
451 }
452 case wxBITMAP_TYPE_TIF:
453 {
454 stream << "wxBITMAP_TYPE_TIF";
455 break;
456 }
457 case wxBITMAP_TYPE_ICO:
458 {
459 stream << "wxBITMAP_TYPE_ICO";
460 break;
461 }
462 case wxBITMAP_TYPE_ICO_RESOURCE:
463 {
464 stream << "wxBITMAP_TYPE_ICO_RESOURCE";
465 break;
466 }
467 case wxBITMAP_TYPE_CUR:
468 {
469 stream << "wxBITMAP_TYPE_CUR";
470 break;
471 }
472 case wxBITMAP_TYPE_CUR_RESOURCE:
473 {
474 stream << "wxBITMAP_TYPE_CUR_RESOURCE";
475 break;
476 }
477 default:
478 case wxBITMAP_TYPE_ANY:
479 {
480 stream << "wxBITMAP_TYPE_ANY";
481 break;
482 }
483 }
484 stream << ", ";
485 int platform = child->GetValue2();
486 switch (platform)
487 {
488 case RESOURCE_PLATFORM_WINDOWS:
489 {
490 stream << "'WINDOWS'";
491 break;
492 }
493 case RESOURCE_PLATFORM_X:
494 {
495 stream << "'X'";
496 break;
497 }
498 case RESOURCE_PLATFORM_MAC:
499 {
500 stream << "'MAC'";
501 break;
502 }
503 case RESOURCE_PLATFORM_ANY:
504 {
505 stream << "'ANY'";
506 break;
507 }
508 }
509 int noColours = (int)child->GetValue3();
510 if (noColours > 0)
511 stream << ", " << noColours;
512
513 stream << "]";
514
515 if (node->Next())
516 stream << ",\\\n";
517
518 node = node->Next();
519 }
520 stream << ").\";\n\n";
521 }
522 return TRUE;
523 }
524
525 void wxResourceTableWithSaving::GenerateWindowStyleString(long windowStyle, char *buf)
526 {
527 GenerateStyle(buf, windowStyle, wxUSER_COLOURS, "wxUSER_COLOURS");
528 GenerateStyle(buf, windowStyle, wxVSCROLL, "wxVSCROLL");
529 GenerateStyle(buf, windowStyle, wxHSCROLL, "wxHSCROLL");
530 GenerateStyle(buf, windowStyle, wxBORDER, "wxBORDER");
531 }
532
533 void wxResourceTableWithSaving::GenerateDialogStyleString(long windowStyle, char *buf)
534 {
535 buf[0] = 0;
536 GenerateWindowStyleString(windowStyle, buf);
537
538 /*
539 GenerateStyle(buf, windowStyle, wxRETAINED, "wxRETAINED");
540 */
541 if (!GenerateStyle(buf, windowStyle, wxDEFAULT_DIALOG_STYLE, "wxDEFAULT_DIALOG_STYLE"))
542 {
543 GenerateStyle(buf, windowStyle, wxCAPTION, "wxCAPTION");
544 GenerateStyle(buf, windowStyle, wxTHICK_FRAME, "wxTHICK_FRAME");
545 GenerateStyle(buf, windowStyle, wxRESIZE_BORDER, "wxRESIZE_BORDER");
546 GenerateStyle(buf, windowStyle, wxSYSTEM_MENU, "wxSYSTEM_MENU");
547 GenerateStyle(buf, windowStyle, wxMINIMIZE_BOX, "wxMINIMIZE_BOX");
548 GenerateStyle(buf, windowStyle, wxMAXIMIZE_BOX, "wxMAXIMIZE_BOX");
549 }
550 if (strlen(buf) == 0)
551 strcat(buf, "0");
552 }
553
554 void wxResourceTableWithSaving::GeneratePanelStyleString(long windowStyle, char *buf)
555 {
556 buf[0] = 0;
557 GenerateWindowStyleString(windowStyle, buf);
558
559 /*
560 GenerateStyle(buf, windowStyle, wxRETAINED, "wxRETAINED");
561 */
562 if (strlen(buf) == 0)
563 strcat(buf, "0");
564 }
565
566
567 void wxResourceTableWithSaving::GenerateItemStyleString(long windowStyle, char *buf)
568 {
569 GenerateWindowStyleString(windowStyle, buf);
570
571 GenerateStyle(buf, windowStyle, wxHORIZONTAL, "wxHORIZONTAL");
572 GenerateStyle(buf, windowStyle, wxVERTICAL, "wxVERTICAL");
573 }
574
575 void wxResourceTableWithSaving::GenerateRadioBoxStyleString(long windowStyle, char *buf)
576 {
577 buf[0] = 0;
578 GenerateItemStyleString(windowStyle, buf);
579
580 if (strlen(buf) == 0)
581 strcat(buf, "0");
582 }
583
584 void wxResourceTableWithSaving::GenerateMessageStyleString(long windowStyle, char *buf)
585 {
586 buf[0] = 0;
587 GenerateItemStyleString(windowStyle, buf);
588
589 if (strlen(buf) == 0)
590 strcat(buf, "0");
591 }
592
593 void wxResourceTableWithSaving::GenerateTextStyleString(long windowStyle, char *buf)
594 {
595 buf[0] = 0;
596 GenerateItemStyleString(windowStyle, buf);
597
598 GenerateStyle(buf, windowStyle, wxTE_PROCESS_ENTER, "wxTE_PROCESS_ENTER");
599 GenerateStyle(buf, windowStyle, wxTE_READONLY, "wxTE_READONLY");
600 GenerateStyle(buf, windowStyle, wxTE_PASSWORD, "wxTE_PASSWORD");
601
602 if (strlen(buf) == 0)
603 strcat(buf, "0");
604 }
605
606 void wxResourceTableWithSaving::GenerateButtonStyleString(long windowStyle, char *buf)
607 {
608 buf[0] = 0;
609 GenerateItemStyleString(windowStyle, buf);
610
611 if (strlen(buf) == 0)
612 strcat(buf, "0");
613 }
614
615 void wxResourceTableWithSaving::GenerateCheckBoxStyleString(long windowStyle, char *buf)
616 {
617 buf[0] = 0;
618 GenerateItemStyleString(windowStyle, buf);
619
620 if (strlen(buf) == 0)
621 strcat(buf, "0");
622 }
623
624 void wxResourceTableWithSaving::GenerateListBoxStyleString(long windowStyle, char *buf)
625 {
626 buf[0] = 0;
627 GenerateItemStyleString(windowStyle, buf);
628
629 GenerateStyle(buf, windowStyle, wxLB_ALWAYS_SB, "wxLB_ALWAYS_SB");
630 GenerateStyle(buf, windowStyle, wxLB_SORT, "wxLB_SORT");
631 // GenerateStyle(buf, windowStyle, wxLB_SINGLE, "wxLB_SINGLE"); // Done already
632 GenerateStyle(buf, windowStyle, wxLB_MULTIPLE, "wxLB_MULTIPLE");
633 GenerateStyle(buf, windowStyle, wxLB_EXTENDED, "wxLB_EXTENDED");
634
635 if (strlen(buf) == 0)
636 strcat(buf, "0");
637 }
638
639 void wxResourceTableWithSaving::GenerateSliderStyleString(long windowStyle, char *buf)
640 {
641 buf[0] = 0;
642 GenerateItemStyleString(windowStyle, buf);
643
644 if (strlen(buf) == 0)
645 strcat(buf, "0");
646 }
647
648 void wxResourceTableWithSaving::GenerateGroupBoxStyleString(long windowStyle, char *buf)
649 {
650 buf[0] = 0;
651 GenerateItemStyleString(windowStyle, buf);
652
653 if (strlen(buf) == 0)
654 strcat(buf, "0");
655 }
656
657 void wxResourceTableWithSaving::GenerateGaugeStyleString(long windowStyle, char *buf)
658 {
659 buf[0] = 0;
660 GenerateItemStyleString(windowStyle, buf);
661
662 GenerateStyle(buf, windowStyle, wxGA_PROGRESSBAR, "wxGA_PROGRESSBAR");
663
664 if (strlen(buf) == 0)
665 strcat(buf, "0");
666 }
667
668 void wxResourceTableWithSaving::GenerateChoiceStyleString(long windowStyle, char *buf)
669 {
670 buf[0] = 0;
671 GenerateItemStyleString(windowStyle, buf);
672
673 if (strlen(buf) == 0)
674 strcat(buf, "0");
675 }
676
677 void wxResourceTableWithSaving::GenerateScrollBarStyleString(long windowStyle, char *buf)
678 {
679 buf[0] = 0;
680 GenerateItemStyleString(windowStyle, buf);
681
682 if (strlen(buf) == 0)
683 strcat(buf, "0");
684 }
685
686 bool wxResourceTableWithSaving::GenerateStyle(char *buf, long windowStyle, long flag, char *strStyle)
687 {
688 if ((windowStyle & flag) == flag)
689 {
690 if (strlen(buf) > 0)
691 strcat(buf, " | ");
692 strcat(buf, strStyle);
693 return TRUE;
694 }
695 else
696 return FALSE;
697 }
698
699 // Returns quoted string or "NULL"
700 char *SafeString(char *s)
701 {
702 if (!s)
703 return "NULL";
704 else
705 {
706 strcpy(wxBuffer, "\"");
707 strcat(wxBuffer, s);
708 strcat(wxBuffer, "\"");
709 return wxBuffer;
710 }
711 }
712
713 // Returns quoted string or ''
714 char *SafeWord(char *s)
715 {
716 if (!s)
717 return "''";
718 else
719 {
720 strcpy(wxBuffer, "'");
721 strcat(wxBuffer, s);
722 strcat(wxBuffer, "'");
723 return wxBuffer;
724 }
725 }
726