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