]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/dialoged/src/reswrite.cpp
stray #include "wincmn.cpp" removed
[wxWidgets.git] / utils / dialoged / src / reswrite.cpp
... / ...
CommitLineData
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
45char *SafeString(char *s);
46char *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.
50wxControl *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
58void 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
74bool 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
96bool 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 == "wxRadioButton")
225 {
226 GenerateRadioButtonStyleString(item->GetStyle(), styleBuf);
227 stream << "wxRadioButton, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
228 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
229 stream << item->GetWidth() << ", " << item->GetHeight();
230 stream << ", " << item->GetValue1();
231 if (item->GetFont())
232 {
233 stream << ",\\\n ";
234 OutputFont(stream, item->GetFont());
235 }
236 }
237 else if (itemType == "wxStaticBox")
238 {
239 GenerateGroupBoxStyleString(item->GetStyle(), styleBuf);
240 stream << "wxGroupBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
241 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
242 stream << item->GetWidth() << ", " << item->GetHeight();
243 if (item->GetFont())
244 {
245 stream << ",\\\n ";
246 OutputFont(stream, item->GetFont());
247 }
248 }
249 else if (itemType == "wxText" || itemType == "wxMultiText" || itemType == "wxTextCtrl")
250 {
251 GenerateTextStyleString(item->GetStyle(), styleBuf);
252 stream << "wxTextCtrl, ";
253 stream << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
254 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
255 stream << item->GetWidth() << ", " << item->GetHeight();
256 stream << ", " << SafeWord(item->GetValue4());
257 if (item->GetFont())
258 {
259 stream << ",\\\n ";
260 OutputFont(stream, item->GetFont());
261 }
262 }
263 else if (itemType == "wxGauge")
264 {
265 GenerateGaugeStyleString(item->GetStyle(), styleBuf);
266 stream << "wxGauge, " << 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();
270 if (item->GetFont())
271 {
272 stream << ",\\\n ";
273 OutputFont(stream, item->GetFont());
274 }
275 }
276 else if (itemType == "wxSlider")
277 {
278 GenerateSliderStyleString(item->GetStyle(), styleBuf);
279 stream << "wxSlider, " << 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 if (item->GetFont())
284 {
285 stream << ",\\\n ";
286 OutputFont(stream, item->GetFont());
287 }
288 }
289 else if (itemType == "wxScrollBar")
290 {
291 GenerateScrollBarStyleString(item->GetStyle(), styleBuf);
292 stream << "wxScrollBar, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
293 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
294 stream << item->GetWidth() << ", " << item->GetHeight();
295 stream << ", " << item->GetValue1() << ", " << item->GetValue2() << ", " << item->GetValue3() << ", ";
296 stream << item->GetValue5();
297 }
298 else if (itemType == "wxListBox")
299 {
300 GenerateListBoxStyleString(item->GetStyle(), styleBuf);
301 stream << "wxListBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
302 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
303 stream << item->GetWidth() << ", " << item->GetHeight();
304
305 // Default list of values
306
307 stream << ", [";
308 if (item->GetStringValues())
309 {
310 wxNode *node = item->GetStringValues()->First();
311 while (node)
312 {
313 char *s = (char *)node->Data();
314 stream << SafeWord(s);
315 if (node->Next())
316 stream << ", ";
317 node = node->Next();
318 }
319 }
320 stream << "], ";
321 switch (item->GetValue1())
322 {
323 case wxLB_MULTIPLE:
324 {
325 stream << "'wxLB_MULTIPLE'";
326 break;
327 }
328 case wxLB_EXTENDED:
329 {
330 stream << "'wxLB_EXTENDED'";
331 break;
332 }
333 case wxLB_SINGLE:
334 default:
335 {
336 stream << "'wxLB_SINGLE'";
337 break;
338 }
339 }
340 if (item->GetFont())
341 {
342 stream << ",\\\n ";
343 OutputFont(stream, item->GetFont());
344 }
345 }
346 else if (itemType == "wxChoice")
347 {
348 GenerateChoiceStyleString(item->GetStyle(), styleBuf);
349 stream << "wxChoice, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
350 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
351 stream << item->GetWidth() << ", " << item->GetHeight();
352
353 // Default list of values
354
355 stream << ", [";
356 if (item->GetStringValues())
357 {
358 wxNode *node = item->GetStringValues()->First();
359 while (node)
360 {
361 char *s = (char *)node->Data();
362 stream << SafeWord(s);
363 if (node->Next())
364 stream << ", ";
365 node = node->Next();
366 }
367 }
368 stream << "]";
369 if (item->GetFont())
370 {
371 stream << ",\\\n ";
372 OutputFont(stream, item->GetFont());
373 }
374 }
375 else if (itemType == "wxRadioBox")
376 {
377 // Must write out the orientation and number of rows/cols!!
378 GenerateRadioBoxStyleString(item->GetStyle(), styleBuf);
379 stream << "wxRadioBox, " << SafeWord(item->GetTitle()) << ", '" << styleBuf << "', ";
380 stream << SafeWord(item->GetName()) << ", " << item->GetX() << ", " << item->GetY() << ", ";
381 stream << item->GetWidth() << ", " << item->GetHeight();
382
383 // Default list of values
384
385 stream << ", [";
386 if (item->GetStringValues())
387 {
388 wxNode *node = item->GetStringValues()->First();
389 while (node)
390 {
391 char *s = (char *)node->Data();
392 stream << SafeWord(s);
393 if (node->Next())
394 stream << ", ";
395 node = node->Next();
396 }
397 }
398 stream << "], " << item->GetValue1();
399 if (item->GetFont())
400 {
401 stream << ",\\\n ";
402 OutputFont(stream, item->GetFont());
403 }
404 }
405 else if (itemType == "wxBitmap")
406 {
407 stream << "static char *" << item->GetName() << " = \"bitmap(name = '" << item->GetName() << "',\\\n";
408
409 wxNode *node = item->GetChildren().First();
410 while (node)
411 {
412 wxItemResource *child = (wxItemResource *)node->Data();
413 stream << " bitmap = [";
414
415 char buf[400];
416 strcpy(buf, child->GetName());
417#ifdef __WXMSW__
418 wxDos2UnixFilename(buf);
419#endif
420
421 stream << "'" << buf << "', ";
422
423 int bitmapType = (int)child->GetValue1();
424 switch (bitmapType)
425 {
426 case wxBITMAP_TYPE_XBM_DATA:
427 {
428 stream << "wxBITMAP_TYPE_XBM_DATA";
429 break;
430 }
431 case wxBITMAP_TYPE_XPM_DATA:
432 {
433 stream << "wxBITMAP_TYPE_XPM_DATA";
434 break;
435 }
436 case wxBITMAP_TYPE_XBM:
437 {
438 stream << "wxBITMAP_TYPE_XBM";
439 break;
440 }
441 case wxBITMAP_TYPE_XPM:
442 {
443 stream << "wxBITMAP_TYPE_XPM";
444 break;
445 }
446 case wxBITMAP_TYPE_BMP:
447 {
448 stream << "wxBITMAP_TYPE_BMP";
449 break;
450 }
451 case wxBITMAP_TYPE_BMP_RESOURCE:
452 {
453 stream << "wxBITMAP_TYPE_BMP_RESOURCE";
454 break;
455 }
456 case wxBITMAP_TYPE_GIF:
457 {
458 stream << "wxBITMAP_TYPE_GIF";
459 break;
460 }
461 case wxBITMAP_TYPE_TIF:
462 {
463 stream << "wxBITMAP_TYPE_TIF";
464 break;
465 }
466 case wxBITMAP_TYPE_ICO:
467 {
468 stream << "wxBITMAP_TYPE_ICO";
469 break;
470 }
471 case wxBITMAP_TYPE_ICO_RESOURCE:
472 {
473 stream << "wxBITMAP_TYPE_ICO_RESOURCE";
474 break;
475 }
476 case wxBITMAP_TYPE_CUR:
477 {
478 stream << "wxBITMAP_TYPE_CUR";
479 break;
480 }
481 case wxBITMAP_TYPE_CUR_RESOURCE:
482 {
483 stream << "wxBITMAP_TYPE_CUR_RESOURCE";
484 break;
485 }
486 default:
487 case wxBITMAP_TYPE_ANY:
488 {
489 stream << "wxBITMAP_TYPE_ANY";
490 break;
491 }
492 }
493 stream << ", ";
494 int platform = child->GetValue2();
495 switch (platform)
496 {
497 case RESOURCE_PLATFORM_WINDOWS:
498 {
499 stream << "'WINDOWS'";
500 break;
501 }
502 case RESOURCE_PLATFORM_X:
503 {
504 stream << "'X'";
505 break;
506 }
507 case RESOURCE_PLATFORM_MAC:
508 {
509 stream << "'MAC'";
510 break;
511 }
512 case RESOURCE_PLATFORM_ANY:
513 {
514 stream << "'ANY'";
515 break;
516 }
517 }
518 int noColours = (int)child->GetValue3();
519 if (noColours > 0)
520 stream << ", " << noColours;
521
522 stream << "]";
523
524 if (node->Next())
525 stream << ",\\\n";
526
527 node = node->Next();
528 }
529 stream << ").\";\n\n";
530 }
531 return TRUE;
532}
533
534void wxResourceTableWithSaving::GenerateWindowStyleString(long windowStyle, char *buf)
535{
536 GenerateStyle(buf, windowStyle, wxNO_3D, "wxNO_3D");
537 GenerateStyle(buf, windowStyle, wxVSCROLL, "wxVSCROLL");
538 GenerateStyle(buf, windowStyle, wxHSCROLL, "wxHSCROLL");
539 GenerateStyle(buf, windowStyle, wxBORDER, "wxBORDER");
540}
541
542void wxResourceTableWithSaving::GenerateDialogStyleString(long windowStyle, char *buf)
543{
544 buf[0] = 0;
545 GenerateWindowStyleString(windowStyle, buf);
546
547/*
548 GenerateStyle(buf, windowStyle, wxRETAINED, "wxRETAINED");
549*/
550 if (!GenerateStyle(buf, windowStyle, wxDEFAULT_DIALOG_STYLE, "wxDEFAULT_DIALOG_STYLE"))
551 {
552 GenerateStyle(buf, windowStyle, wxCAPTION, "wxCAPTION");
553 GenerateStyle(buf, windowStyle, wxTHICK_FRAME, "wxTHICK_FRAME");
554 GenerateStyle(buf, windowStyle, wxRESIZE_BORDER, "wxRESIZE_BORDER");
555 GenerateStyle(buf, windowStyle, wxSYSTEM_MENU, "wxSYSTEM_MENU");
556 GenerateStyle(buf, windowStyle, wxMINIMIZE_BOX, "wxMINIMIZE_BOX");
557 GenerateStyle(buf, windowStyle, wxMAXIMIZE_BOX, "wxMAXIMIZE_BOX");
558 }
559 if (strlen(buf) == 0)
560 strcat(buf, "0");
561}
562
563void wxResourceTableWithSaving::GeneratePanelStyleString(long windowStyle, char *buf)
564{
565 buf[0] = 0;
566 GenerateWindowStyleString(windowStyle, buf);
567
568/*
569 GenerateStyle(buf, windowStyle, wxRETAINED, "wxRETAINED");
570*/
571 if (strlen(buf) == 0)
572 strcat(buf, "0");
573}
574
575
576void wxResourceTableWithSaving::GenerateItemStyleString(long windowStyle, char *buf)
577{
578 GenerateWindowStyleString(windowStyle, buf);
579
580 GenerateStyle(buf, windowStyle, wxHORIZONTAL, "wxHORIZONTAL");
581 GenerateStyle(buf, windowStyle, wxVERTICAL, "wxVERTICAL");
582}
583
584void wxResourceTableWithSaving::GenerateRadioBoxStyleString(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
593void wxResourceTableWithSaving::GenerateMessageStyleString(long windowStyle, char *buf)
594{
595 buf[0] = 0;
596 GenerateItemStyleString(windowStyle, buf);
597
598 if (strlen(buf) == 0)
599 strcat(buf, "0");
600}
601
602void wxResourceTableWithSaving::GenerateTextStyleString(long windowStyle, char *buf)
603{
604 buf[0] = 0;
605 GenerateItemStyleString(windowStyle, buf);
606
607 GenerateStyle(buf, windowStyle, wxTE_PROCESS_ENTER, "wxTE_PROCESS_ENTER");
608 GenerateStyle(buf, windowStyle, wxTE_READONLY, "wxTE_READONLY");
609 GenerateStyle(buf, windowStyle, wxTE_PASSWORD, "wxTE_PASSWORD");
610 GenerateStyle(buf, windowStyle, wxTE_MULTILINE, "wxTE_MULTILINE");
611
612 if (strlen(buf) == 0)
613 strcat(buf, "0");
614}
615
616void wxResourceTableWithSaving::GenerateButtonStyleString(long windowStyle, char *buf)
617{
618 buf[0] = 0;
619 GenerateItemStyleString(windowStyle, buf);
620
621 if (strlen(buf) == 0)
622 strcat(buf, "0");
623}
624
625void wxResourceTableWithSaving::GenerateCheckBoxStyleString(long windowStyle, char *buf)
626{
627 buf[0] = 0;
628 GenerateItemStyleString(windowStyle, buf);
629
630 if (strlen(buf) == 0)
631 strcat(buf, "0");
632}
633
634void wxResourceTableWithSaving::GenerateRadioButtonStyleString(long windowStyle, char *buf)
635{
636 buf[0] = 0;
637 GenerateItemStyleString(windowStyle, buf);
638
639 if (strlen(buf) == 0)
640 strcat(buf, "0");
641}
642
643void wxResourceTableWithSaving::GenerateListBoxStyleString(long windowStyle, char *buf)
644{
645 buf[0] = 0;
646 GenerateItemStyleString(windowStyle, buf);
647
648 GenerateStyle(buf, windowStyle, wxLB_ALWAYS_SB, "wxLB_ALWAYS_SB");
649 GenerateStyle(buf, windowStyle, wxLB_SORT, "wxLB_SORT");
650// GenerateStyle(buf, windowStyle, wxLB_SINGLE, "wxLB_SINGLE"); // Done already
651 GenerateStyle(buf, windowStyle, wxLB_MULTIPLE, "wxLB_MULTIPLE");
652 GenerateStyle(buf, windowStyle, wxLB_EXTENDED, "wxLB_EXTENDED");
653
654 if (strlen(buf) == 0)
655 strcat(buf, "0");
656}
657
658void wxResourceTableWithSaving::GenerateSliderStyleString(long windowStyle, char *buf)
659{
660 buf[0] = 0;
661 GenerateItemStyleString(windowStyle, buf);
662
663 if (strlen(buf) == 0)
664 strcat(buf, "0");
665}
666
667void wxResourceTableWithSaving::GenerateGroupBoxStyleString(long windowStyle, char *buf)
668{
669 buf[0] = 0;
670 GenerateItemStyleString(windowStyle, buf);
671
672 if (strlen(buf) == 0)
673 strcat(buf, "0");
674}
675
676void wxResourceTableWithSaving::GenerateGaugeStyleString(long windowStyle, char *buf)
677{
678 buf[0] = 0;
679 GenerateItemStyleString(windowStyle, buf);
680
681 GenerateStyle(buf, windowStyle, wxGA_PROGRESSBAR, "wxGA_PROGRESSBAR");
682
683 if (strlen(buf) == 0)
684 strcat(buf, "0");
685}
686
687void wxResourceTableWithSaving::GenerateChoiceStyleString(long windowStyle, char *buf)
688{
689 buf[0] = 0;
690 GenerateItemStyleString(windowStyle, buf);
691
692 if (strlen(buf) == 0)
693 strcat(buf, "0");
694}
695
696void wxResourceTableWithSaving::GenerateScrollBarStyleString(long windowStyle, char *buf)
697{
698 buf[0] = 0;
699 GenerateItemStyleString(windowStyle, buf);
700
701 if (strlen(buf) == 0)
702 strcat(buf, "0");
703}
704
705bool wxResourceTableWithSaving::GenerateStyle(char *buf, long windowStyle, long flag, char *strStyle)
706{
707 if ((windowStyle & flag) == flag)
708 {
709 if (strlen(buf) > 0)
710 strcat(buf, " | ");
711 strcat(buf, strStyle);
712 return TRUE;
713 }
714 else
715 return FALSE;
716}
717
718// Returns quoted string or "NULL"
719char *SafeString(char *s)
720{
721 if (!s)
722 return "NULL";
723 else
724 {
725 strcpy(wxBuffer, "\"");
726 strcat(wxBuffer, s);
727 strcat(wxBuffer, "\"");
728 return wxBuffer;
729 }
730}
731
732// Returns quoted string or ''
733char *SafeWord(char *s)
734{
735 if (!s)
736 return "''";
737 else
738 {
739 strcpy(wxBuffer, "'");
740 strcat(wxBuffer, s);
741 strcat(wxBuffer, "'");
742 return wxBuffer;
743 }
744}
745