1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Resource system
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "resource.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #if wxUSE_WX_RESOURCES
26 #pragma warning(disable:4706) // assignment within conditional expression
34 #include "wx/gdicmn.h"
38 #include "wx/stattext.h"
39 #include "wx/button.h"
40 #include "wx/bmpbuttn.h"
41 #include "wx/radiobox.h"
42 #include "wx/listbox.h"
43 #include "wx/choice.h"
44 #include "wx/checkbox.h"
45 #include "wx/settings.h"
46 #include "wx/slider.h"
48 #include "wx/statbox.h"
49 #include "wx/statbmp.h"
51 #include "wx/textctrl.h"
52 #include "wx/msgdlg.h"
57 #include "wx/radiobut.h"
61 #include "wx/scrolbar.h"
65 #include "wx/combobox.h"
68 #include "wx/validate.h"
77 #include "wx/resource.h"
78 #include "wx/string.h"
79 #include "wx/wxexpr.h"
81 #include "wx/settings.h"
82 #include "wx/stream.h"
84 // Forward (private) declarations
85 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
);
86 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
= FALSE
);
87 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
);
88 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
);
89 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
);
90 wxItemResource
*wxResourceInterpretString(wxResourceTable
& table
, wxExpr
*expr
);
91 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& table
, wxExpr
*expr
);
92 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
);
93 // Interpret list expression
94 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
);
96 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
97 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
) ;
98 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
100 wxResourceTable
*wxDefaultResourceTable
= (wxResourceTable
*) NULL
;
102 char *wxResourceBuffer
= (char *) NULL
;
103 long wxResourceBufferSize
= 0;
104 long wxResourceBufferCount
= 0;
105 int wxResourceStringPtr
= 0;
107 void wxInitializeResourceSystem()
109 wxDefaultResourceTable
= new wxResourceTable
;
112 void wxCleanUpResourceSystem()
114 delete wxDefaultResourceTable
;
115 if (wxResourceBuffer
)
116 delete[] wxResourceBuffer
;
119 void wxLogWarning(char *msg
)
121 wxMessageBox(msg
, _("Warning"), wxOK
);
124 IMPLEMENT_DYNAMIC_CLASS(wxItemResource
, wxObject
)
125 IMPLEMENT_DYNAMIC_CLASS(wxResourceTable
, wxHashTable
)
127 wxItemResource::wxItemResource()
133 m_x
= m_y
= m_width
= m_height
= 0;
134 m_value1
= m_value2
= m_value3
= m_value5
= 0;
140 wxItemResource::~wxItemResource()
142 wxNode
*node
= m_children
.First();
145 wxItemResource
*item
= (wxItemResource
*)node
->Data();
148 node
= m_children
.First();
156 wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING
), identifiers(wxKEY_STRING
)
160 wxResourceTable::~wxResourceTable()
165 wxItemResource
*wxResourceTable::FindResource(const wxString
& name
) const
167 wxItemResource
*item
= (wxItemResource
*)Get(WXSTRINGCAST name
);
171 void wxResourceTable::AddResource(wxItemResource
*item
)
173 wxString name
= item
->GetName();
175 name
= item
->GetTitle();
177 name
= wxT("no name");
179 // Delete existing resource, if any.
185 bool wxResourceTable::DeleteResource(const wxString
& name
)
187 wxItemResource
*item
= (wxItemResource
*)Delete(WXSTRINGCAST name
);
190 // See if any resource has this as its child; if so, delete from
191 // parent's child list.
193 wxNode
*node
= (wxNode
*) NULL
;
197 wxItemResource
*parent
= (wxItemResource
*)node
->Data();
198 if (parent
->GetChildren().Member(item
))
200 parent
->GetChildren().DeleteObject(item
);
213 bool wxResourceTable::ParseResourceFile( wxInputStream
*is
)
216 int len
= is
->StreamSize() ;
219 while ( is
->TellI() + 10 < len
) // it's a hack because the streams dont support EOF
221 wxResourceReadOneResource(is
, db
, &eof
, this) ;
223 return wxResourceInterpretResources(*this, db
);
226 bool wxResourceTable::ParseResourceFile(const wxString
& filename
)
231 FILE *fd
= fopen(wxUnix2MacFilename(filename
.fn_str()), "r");
233 FILE *fd
= fopen(filename
.fn_str(), "r");
238 while (wxResourceReadOneResource(fd
, db
, &eof
, this) && !eof
)
243 return wxResourceInterpretResources(*this, db
);
246 bool wxResourceTable::ParseResourceData(const wxString
& data
)
249 if (!db
.ReadFromString(data
))
251 wxLogWarning(_("Ill-formed resource file syntax."));
255 return wxResourceInterpretResources(*this, db
);
258 bool wxResourceTable::RegisterResourceBitmapData(const wxString
& name
, char bits
[], int width
, int height
)
260 // Register pre-loaded bitmap data
261 wxItemResource
*item
= new wxItemResource
;
262 // item->SetType(wxRESOURCE_TYPE_XBM_DATA);
263 item
->SetType(wxT("wxXBMData"));
265 item
->SetValue1((long)bits
);
266 item
->SetValue2((long)width
);
267 item
->SetValue3((long)height
);
272 bool wxResourceTable::RegisterResourceBitmapData(const wxString
& name
, char **data
)
274 // Register pre-loaded bitmap data
275 wxItemResource
*item
= new wxItemResource
;
276 // item->SetType(wxRESOURCE_TYPE_XPM_DATA);
277 item
->SetType(wxT("wxXPMData"));
279 item
->SetValue1((long)data
);
284 bool wxResourceTable::SaveResource(const wxString
& WXUNUSED(filename
))
289 void wxResourceTable::ClearTable()
292 wxNode
*node
= Next();
295 wxNode
*next
= Next();
296 wxItemResource
*item
= (wxItemResource
*)node
->Data();
303 wxControl
*wxResourceTable::CreateItem(wxWindow
*parent
, const wxItemResource
* childResource
, const wxItemResource
* parentResource
) const
305 int id
= childResource
->GetId();
309 bool dlgUnits
= ((parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0);
311 wxControl
*control
= (wxControl
*) NULL
;
312 wxString
itemType(childResource
->GetType());
318 pos
= parent
->ConvertDialogToPixels(wxPoint(childResource
->GetX(), childResource
->GetY()));
319 size
= parent
->ConvertDialogToPixels(wxSize(childResource
->GetWidth(), childResource
->GetHeight()));
323 pos
= wxPoint(childResource
->GetX(), childResource
->GetY());
324 size
= wxSize(childResource
->GetWidth(), childResource
->GetHeight());
327 if (itemType
== wxString(wxT("wxButton")) || itemType
== wxString(wxT("wxBitmapButton")))
329 if (childResource
->GetValue4() != wxT(""))
332 wxBitmap bitmap
= childResource
->GetBitmap();
335 bitmap
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable
*)this);
336 ((wxItemResource
*) childResource
)->SetBitmap(bitmap
);
339 control
= new wxBitmapButton(parent
, id
, bitmap
, pos
, size
,
340 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
343 // Normal, text button
344 control
= new wxButton(parent
, id
, childResource
->GetTitle(), pos
, size
,
345 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
347 else if (itemType
== wxString(wxT("wxMessage")) || itemType
== wxString(wxT("wxStaticText")) ||
348 itemType
== wxString(wxT("wxStaticBitmap")))
350 if (childResource
->GetValue4() != wxT(""))
353 wxBitmap bitmap
= childResource
->GetBitmap();
356 bitmap
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable
*)this);
357 ((wxItemResource
*) childResource
)->SetBitmap(bitmap
);
359 #if wxUSE_BITMAP_MESSAGE
361 control
= new wxStaticBitmap(parent
, id
, bitmap
, pos
, size
,
362 childResource
->GetStyle(), childResource
->GetName());
367 control
= new wxStaticText(parent
, id
, childResource
->GetTitle(), pos
, size
,
368 childResource
->GetStyle(), childResource
->GetName());
371 else if (itemType
== wxString(wxT("wxText")) || itemType
== wxString(wxT("wxTextCtrl")) || itemType
== wxString(wxT("wxMultiText")))
373 control
= new wxTextCtrl(parent
, id
, childResource
->GetValue4(), pos
, size
,
374 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
376 else if (itemType
== wxString(wxT("wxCheckBox")))
378 control
= new wxCheckBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
379 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
381 ((wxCheckBox
*)control
)->SetValue((childResource
->GetValue1() != 0));
384 else if (itemType
== wxString(wxT("wxGauge")))
386 control
= new wxGauge(parent
, id
, (int)childResource
->GetValue2(), pos
, size
,
387 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
389 ((wxGauge
*)control
)->SetValue((int)childResource
->GetValue1());
393 else if (itemType
== wxString(wxT("wxRadioButton")))
395 control
= new wxRadioButton(parent
, id
, childResource
->GetTitle(), // (int)childResource->GetValue1(),
397 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
401 else if (itemType
== wxString(wxT("wxScrollBar")))
403 control
= new wxScrollBar(parent
, id
, pos
, size
,
404 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
406 ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1());
407 ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2());
408 ((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3());
409 ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5());
411 ((wxScrollBar
*)control
)->SetScrollbar((int)childResource
->GetValue1(),(int)childResource
->GetValue2(),
412 (int)childResource
->GetValue3(),(int)(long)childResource
->GetValue5(),FALSE
);
416 else if (itemType
== wxString(wxT("wxSlider")))
418 control
= new wxSlider(parent
, id
, (int)childResource
->GetValue1(),
419 (int)childResource
->GetValue2(), (int)childResource
->GetValue3(), pos
, size
,
420 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
422 else if (itemType
== wxString(wxT("wxGroupBox")) || itemType
== wxString(wxT("wxStaticBox")))
424 control
= new wxStaticBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
425 childResource
->GetStyle(), childResource
->GetName());
427 else if (itemType
== wxString(wxT("wxListBox")))
429 wxStringList
& stringList
= childResource
->GetStringValues();
430 wxString
*strings
= (wxString
*) NULL
;
432 if (stringList
.Number() > 0)
434 noStrings
= stringList
.Number();
435 strings
= new wxString
[noStrings
];
436 wxNode
*node
= stringList
.First();
440 strings
[i
] = (wxChar
*)node
->Data();
445 control
= new wxListBox(parent
, id
, pos
, size
,
446 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
451 else if (itemType
== wxString(wxT("wxChoice")))
453 wxStringList
& stringList
= childResource
->GetStringValues();
454 wxString
*strings
= (wxString
*) NULL
;
456 if (stringList
.Number() > 0)
458 noStrings
= stringList
.Number();
459 strings
= new wxString
[noStrings
];
460 wxNode
*node
= stringList
.First();
464 strings
[i
] = (wxChar
*)node
->Data();
469 control
= new wxChoice(parent
, id
, pos
, size
,
470 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
476 else if (itemType
== wxString(wxT("wxComboBox")))
478 wxStringList
& stringList
= childResource
->GetStringValues();
479 wxString
*strings
= (wxString
*) NULL
;
481 if (stringList
.Number() > 0)
483 noStrings
= stringList
.Number();
484 strings
= new wxString
[noStrings
];
485 wxNode
*node
= stringList
.First();
489 strings
[i
] = (wxChar
*)node
->Data();
494 control
= new wxComboBox(parent
, id
, childResource
->GetValue4(), pos
, size
,
495 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
501 else if (itemType
== wxString(wxT("wxRadioBox")))
503 wxStringList
& stringList
= childResource
->GetStringValues();
504 wxString
*strings
= (wxString
*) NULL
;
506 if (stringList
.Number() > 0)
508 noStrings
= stringList
.Number();
509 strings
= new wxString
[noStrings
];
510 wxNode
*node
= stringList
.First();
514 strings
[i
] = (wxChar
*)node
->Data();
519 control
= new wxRadioBox(parent
, (wxWindowID
) id
, wxString(childResource
->GetTitle()), pos
, size
,
520 noStrings
, strings
, (int)childResource
->GetValue1(), childResource
->GetStyle(), wxDefaultValidator
,
521 childResource
->GetName());
527 if ((parentResource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
529 // Don't set font; will be inherited from parent.
533 if (control
&& childResource
->GetFont().Ok())
534 control
->SetFont(childResource
->GetFont());
540 * Interpret database as a series of resources
543 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
)
545 wxNode
*node
= db
.First();
548 wxExpr
*clause
= (wxExpr
*)node
->Data();
549 wxString
functor(clause
->Functor());
551 wxItemResource
*item
= (wxItemResource
*) NULL
;
552 if (functor
== wxT("dialog"))
553 item
= wxResourceInterpretDialog(table
, clause
);
554 else if (functor
== wxT("panel"))
555 item
= wxResourceInterpretDialog(table
, clause
, TRUE
);
556 else if (functor
== wxT("menubar"))
557 item
= wxResourceInterpretMenuBar(table
, clause
);
558 else if (functor
== wxT("menu"))
559 item
= wxResourceInterpretMenu(table
, clause
);
560 else if (functor
== wxT("string"))
561 item
= wxResourceInterpretString(table
, clause
);
562 else if (functor
== wxT("bitmap"))
563 item
= wxResourceInterpretBitmap(table
, clause
);
564 else if (functor
== wxT("icon"))
565 item
= wxResourceInterpretIcon(table
, clause
);
569 // Remove any existing resource of same name
570 if (item
->GetName() != wxT(""))
571 table
.DeleteResource(item
->GetName());
572 table
.AddResource(item
);
579 static const wxChar
*g_ValidControlClasses
[] =
582 wxT("wxBitmapButton"),
585 wxT("wxStaticBitmap"),
591 wxT("wxRadioButton"),
593 wxT("wxBitmapCheckBox"),
603 static bool wxIsValidControlClass(const wxString
& c
)
605 for ( size_t i
= 0; i
< WXSIZEOF(g_ValidControlClasses
); i
++ )
607 if ( c
== g_ValidControlClasses
[i
] )
613 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
)
615 wxItemResource
*dialogItem
= new wxItemResource
;
617 dialogItem
->SetType(wxT("wxPanel"));
619 dialogItem
->SetType(wxT("wxDialog"));
620 wxString style
= wxT("");
621 wxString title
= wxT("");
622 wxString name
= wxT("");
623 wxString backColourHex
= wxT("");
624 wxString labelColourHex
= wxT("");
625 wxString buttonColourHex
= wxT("");
627 long windowStyle
= wxDEFAULT_DIALOG_STYLE
;
631 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
633 wxExpr
*labelFontExpr
= (wxExpr
*) NULL
;
634 wxExpr
*buttonFontExpr
= (wxExpr
*) NULL
;
635 wxExpr
*fontExpr
= (wxExpr
*) NULL
;
636 expr
->GetAttributeValue(wxT("style"), style
);
637 expr
->GetAttributeValue(wxT("name"), name
);
638 expr
->GetAttributeValue(wxT("title"), title
);
639 expr
->GetAttributeValue(wxT("x"), x
);
640 expr
->GetAttributeValue(wxT("y"), y
);
641 expr
->GetAttributeValue(wxT("width"), width
);
642 expr
->GetAttributeValue(wxT("height"), height
);
643 expr
->GetAttributeValue(wxT("modal"), isModal
);
644 expr
->GetAttributeValue(wxT("label_font"), &labelFontExpr
);
645 expr
->GetAttributeValue(wxT("button_font"), &buttonFontExpr
);
646 expr
->GetAttributeValue(wxT("font"), &fontExpr
);
647 expr
->GetAttributeValue(wxT("background_colour"), backColourHex
);
648 expr
->GetAttributeValue(wxT("label_colour"), labelColourHex
);
649 expr
->GetAttributeValue(wxT("button_colour"), buttonColourHex
);
651 int useDialogUnits
= 0;
652 expr
->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits
);
653 if (useDialogUnits
!= 0)
654 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
);
657 expr
->GetAttributeValue(wxT("use_system_defaults"), useDefaults
);
658 if (useDefaults
!= 0)
659 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
);
662 expr
->GetAttributeValue(wxT("id"), id
);
663 dialogItem
->SetId(id
);
665 if (style
!= wxT(""))
667 windowStyle
= wxParseWindowStyle(style
);
669 dialogItem
->SetStyle(windowStyle
);
670 dialogItem
->SetValue1(isModal
);
671 if (windowStyle
& wxDIALOG_MODAL
) // Uses style in wxWin 2
672 dialogItem
->SetValue1(TRUE
);
674 dialogItem
->SetName(name
);
675 dialogItem
->SetTitle(title
);
676 dialogItem
->SetSize(x
, y
, width
, height
);
678 if (backColourHex
!= wxT(""))
683 r
= wxHexToDec(backColourHex
.Mid(0, 2));
684 g
= wxHexToDec(backColourHex
.Mid(2, 2));
685 b
= wxHexToDec(backColourHex
.Mid(4, 2));
686 dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
688 if (labelColourHex
!= wxT(""))
693 r
= wxHexToDec(labelColourHex
.Mid(0, 2));
694 g
= wxHexToDec(labelColourHex
.Mid(2, 2));
695 b
= wxHexToDec(labelColourHex
.Mid(4, 2));
696 dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
698 if (buttonColourHex
!= wxT(""))
703 r
= wxHexToDec(buttonColourHex
.Mid(0, 2));
704 g
= wxHexToDec(buttonColourHex
.Mid(2, 2));
705 b
= wxHexToDec(buttonColourHex
.Mid(4, 2));
706 dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
710 dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
));
711 else if (buttonFontExpr
)
712 dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
));
713 else if (labelFontExpr
)
714 dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
));
716 // Now parse all controls
717 wxExpr
*controlExpr
= expr
->GetFirst();
720 if (controlExpr
->Number() == 3)
722 wxString
controlKeyword(controlExpr
->Nth(1)->StringValue());
723 if (controlKeyword
!= wxT("") && controlKeyword
== wxT("control"))
725 // The value part: always a list.
726 wxExpr
*listExpr
= controlExpr
->Nth(2);
727 if (listExpr
->Type() == PrologList
)
729 wxItemResource
*controlItem
= wxResourceInterpretControl(table
, listExpr
);
732 dialogItem
->GetChildren().Append(controlItem
);
737 controlExpr
= controlExpr
->GetNext();
742 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
)
744 wxItemResource
*controlItem
= new wxItemResource
;
746 // First, find the standard features of a control definition:
747 // [optional integer/string id], control name, title, style, name, x, y, width, height
749 wxString controlType
;
754 long windowStyle
= 0;
755 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
758 wxExpr
*expr1
= expr
->Nth(0);
760 if ( expr1
->Type() == PrologString
|| expr1
->Type() == PrologWord
)
762 if ( wxIsValidControlClass(expr1
->StringValue()) )
765 controlType
= expr1
->StringValue();
769 wxString
str(expr1
->StringValue());
770 id
= wxResourceGetIdentifier(str
, &table
);
773 wxLogWarning(_("Could not resolve control class or id '%s'. "
774 "Use (non-zero) integer instead\n or provide #define "
775 "(see manual for caveats)"),
776 (const wxChar
*) expr1
->StringValue());
778 return (wxItemResource
*) NULL
;
782 // Success - we have an id, so the 2nd element must be the control class.
783 controlType
= expr
->Nth(1)->StringValue();
788 else if (expr1
->Type() == PrologInteger
)
790 id
= (int)expr1
->IntegerValue();
791 // Success - we have an id, so the 2nd element must be the control class.
792 controlType
= expr
->Nth(1)->StringValue();
796 expr1
= expr
->Nth(count
);
799 title
= expr1
->StringValue();
801 expr1
= expr
->Nth(count
);
805 style
= expr1
->StringValue();
806 windowStyle
= wxParseWindowStyle(style
);
809 expr1
= expr
->Nth(count
);
812 name
= expr1
->StringValue();
814 expr1
= expr
->Nth(count
);
817 x
= (int)expr1
->IntegerValue();
819 expr1
= expr
->Nth(count
);
822 y
= (int)expr1
->IntegerValue();
824 expr1
= expr
->Nth(count
);
827 width
= (int)expr1
->IntegerValue();
829 expr1
= expr
->Nth(count
);
832 height
= (int)expr1
->IntegerValue();
834 controlItem
->SetStyle(windowStyle
);
835 controlItem
->SetName(name
);
836 controlItem
->SetTitle(title
);
837 controlItem
->SetSize(x
, y
, width
, height
);
838 controlItem
->SetType(controlType
);
839 controlItem
->SetId(id
);
841 if (controlType
== wxT("wxButton"))
843 // Check for bitmap resource name (in case loading old-style resource file)
844 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
846 wxString
str(expr
->Nth(count
)->StringValue());
851 controlItem
->SetValue4(str
);
852 controlItem
->SetType(wxT("wxBitmapButton"));
855 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
856 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
858 else if (controlType
== wxT("wxBitmapButton"))
860 // Check for bitmap resource name
861 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
863 wxString
str(expr
->Nth(count
)->StringValue());
864 controlItem
->SetValue4(str
);
866 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
867 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
870 else if (controlType
== wxT("wxCheckBox"))
872 // Check for default value
873 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
875 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
877 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
878 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
882 else if (controlType
== wxT("wxRadioButton"))
884 // Check for default value
885 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
887 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
889 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
890 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
894 else if (controlType
== wxT("wxText") || controlType
== wxT("wxTextCtrl") || controlType
== wxT("wxMultiText"))
896 // Check for default value
897 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
899 wxString
str(expr
->Nth(count
)->StringValue());
900 controlItem
->SetValue4(str
);
903 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
905 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
906 // Do nothing - no label font any more
908 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
909 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
913 else if (controlType
== wxT("wxMessage") || controlType
== wxT("wxStaticText"))
915 // Check for bitmap resource name (in case it's an old-style .wxr file)
916 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
918 wxString
str(expr
->Nth(count
)->StringValue());
919 controlItem
->SetValue4(str
);
921 controlItem
->SetType(wxT("wxStaticText"));
923 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
924 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
926 else if (controlType
== wxT("wxStaticBitmap"))
928 // Check for bitmap resource name
929 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
931 wxString
str(expr
->Nth(count
)->StringValue());
932 controlItem
->SetValue4(str
);
935 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
936 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
938 else if (controlType
== wxT("wxGroupBox") || controlType
== wxT("wxStaticBox"))
940 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
941 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
943 else if (controlType
== wxT("wxGauge"))
945 // Check for default value
946 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
948 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
952 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
954 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
957 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
959 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
963 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
964 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
969 else if (controlType
== wxT("wxSlider"))
971 // Check for default value
972 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
974 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
978 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
980 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
984 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
986 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
989 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
991 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
995 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
996 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1002 else if (controlType
== wxT("wxScrollBar"))
1005 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1007 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1011 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1013 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1017 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1019 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1023 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1024 controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue());
1029 else if (controlType
== wxT("wxListBox"))
1031 wxExpr
*valueList
= (wxExpr
*) NULL
;
1033 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1035 wxStringList stringList
;
1036 wxExpr
*stringExpr
= valueList
->GetFirst();
1039 stringList
.Add(stringExpr
->StringValue());
1040 stringExpr
= stringExpr
->GetNext();
1042 controlItem
->SetStringValues(stringList
);
1044 // This is now obsolete: it's in the window style.
1045 // Check for wxSINGLE/wxMULTIPLE
1046 wxExpr
*mult
= (wxExpr
*) NULL
;
1048 controlItem->SetValue1(wxLB_SINGLE);
1050 if ((mult
= expr
->Nth(count
)) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
)))
1053 wxString m(mult->StringValue());
1054 if (m == "wxLB_MULTIPLE")
1055 controlItem->SetValue1(wxLB_MULTIPLE);
1056 else if (m == "wxLB_EXTENDED")
1057 controlItem->SetValue1(wxLB_EXTENDED);
1062 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1064 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1066 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1067 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1071 else if (controlType
== wxT("wxChoice"))
1073 wxExpr
*valueList
= (wxExpr
*) NULL
;
1074 // Check for default value list
1075 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1077 wxStringList stringList
;
1078 wxExpr
*stringExpr
= valueList
->GetFirst();
1081 stringList
.Add(stringExpr
->StringValue());
1082 stringExpr
= stringExpr
->GetNext();
1084 controlItem
->SetStringValues(stringList
);
1088 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1090 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1093 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1094 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1099 else if (controlType
== wxT("wxComboBox"))
1101 wxExpr
*textValue
= expr
->Nth(count
);
1102 if (textValue
&& (textValue
->Type() == PrologString
|| textValue
->Type() == PrologWord
))
1104 wxString
str(textValue
->StringValue());
1105 controlItem
->SetValue4(str
);
1109 wxExpr
*valueList
= (wxExpr
*) NULL
;
1110 // Check for default value list
1111 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1113 wxStringList stringList
;
1114 wxExpr
*stringExpr
= valueList
->GetFirst();
1117 stringList
.Add(stringExpr
->StringValue());
1118 stringExpr
= stringExpr
->GetNext();
1120 controlItem
->SetStringValues(stringList
);
1124 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1126 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1129 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1130 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1137 else if (controlType
== wxT("wxRadioBox"))
1139 wxExpr
*valueList
= (wxExpr
*) NULL
;
1140 // Check for default value list
1141 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1143 wxStringList stringList
;
1144 wxExpr
*stringExpr
= valueList
->GetFirst();
1147 stringList
.Add(stringExpr
->StringValue());
1148 stringExpr
= stringExpr
->GetNext();
1150 controlItem
->SetStringValues(stringList
);
1153 // majorDim (number of rows or cols)
1154 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1156 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1160 controlItem
->SetValue1(0);
1162 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1164 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1167 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1168 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1176 return (wxItemResource
*) NULL
;
1181 // Forward declaration
1182 wxItemResource
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr
*expr
);
1185 * Interpet a menu item
1188 wxItemResource
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr
*expr
)
1190 wxItemResource
*item
= new wxItemResource
;
1192 wxExpr
*labelExpr
= expr
->Nth(0);
1193 wxExpr
*idExpr
= expr
->Nth(1);
1194 wxExpr
*helpExpr
= expr
->Nth(2);
1195 wxExpr
*checkableExpr
= expr
->Nth(3);
1197 // Further keywords/attributes to follow sometime...
1198 if (expr
->Number() == 0)
1200 // item->SetType(wxRESOURCE_TYPE_SEPARATOR);
1201 item
->SetType(wxT("wxMenuSeparator"));
1206 // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
1207 item
->SetType(wxT("wxMenu")); // Well, menu item, but doesn't matter.
1210 wxString
str(labelExpr
->StringValue());
1211 item
->SetTitle(str
);
1216 // If a string or word, must look up in identifier table.
1217 if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
))
1219 wxString
str(idExpr
->StringValue());
1220 id
= wxResourceGetIdentifier(str
, &table
);
1223 wxLogWarning(_("Could not resolve menu id '%s'. "
1224 "Use (non-zero) integer instead\n"
1225 "or provide #define (see manual for caveats)"),
1226 (const wxChar
*) idExpr
->StringValue());
1229 else if (idExpr
->Type() == PrologInteger
)
1230 id
= (int)idExpr
->IntegerValue();
1231 item
->SetValue1(id
);
1235 wxString
str(helpExpr
->StringValue());
1236 item
->SetValue4(str
);
1239 item
->SetValue2(checkableExpr
->IntegerValue());
1241 // Find the first expression that's a list, for submenu
1242 wxExpr
*subMenuExpr
= expr
->GetFirst();
1243 while (subMenuExpr
&& (subMenuExpr
->Type() != PrologList
))
1244 subMenuExpr
= subMenuExpr
->GetNext();
1248 wxItemResource
*child
= wxResourceInterpretMenuItem(table
, subMenuExpr
);
1249 item
->GetChildren().Append(child
);
1250 subMenuExpr
= subMenuExpr
->GetNext();
1257 * Interpret a nested list as a menu
1260 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
1262 wxItemResource *menu = new wxItemResource;
1263 // menu->SetType(wxTYPE_MENU);
1264 menu->SetType("wxMenu");
1265 wxExpr *element = expr->GetFirst();
1268 wxItemResource *item = wxResourceInterpretMenuItem(table, element);
1270 menu->GetChildren().Append(item);
1271 element = element->GetNext();
1277 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
)
1279 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1280 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1282 return (wxItemResource
*) NULL
;
1284 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1287 return (wxItemResource
*) NULL
;
1290 if (expr
->GetAttributeValue(wxT("name"), name
))
1292 menuResource
->SetName(name
);
1295 return menuResource
;
1298 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
)
1300 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1301 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1303 return (wxItemResource
*) NULL
;
1305 wxItemResource
*resource
= new wxItemResource
;
1306 resource
->SetType(wxT("wxMenu"));
1307 // resource->SetType(wxTYPE_MENU);
1309 wxExpr
*element
= listExpr
->GetFirst();
1312 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1313 resource
->GetChildren().Append(menuResource
);
1314 element
= element
->GetNext();
1318 if (expr
->GetAttributeValue(wxT("name"), name
))
1320 resource
->SetName(name
);
1326 wxItemResource
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr
*WXUNUSED(expr
))
1328 return (wxItemResource
*) NULL
;
1331 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr
*expr
)
1333 wxItemResource
*bitmapItem
= new wxItemResource
;
1334 // bitmapItem->SetType(wxTYPE_BITMAP);
1335 bitmapItem
->SetType(wxT("wxBitmap"));
1337 if (expr
->GetAttributeValue(wxT("name"), name
))
1339 bitmapItem
->SetName(name
);
1341 // Now parse all bitmap specifications
1342 wxExpr
*bitmapExpr
= expr
->GetFirst();
1345 if (bitmapExpr
->Number() == 3)
1347 wxString
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue());
1348 if (bitmapKeyword
== wxT("bitmap") || bitmapKeyword
== wxT("icon"))
1350 // The value part: always a list.
1351 wxExpr
*listExpr
= bitmapExpr
->Nth(2);
1352 if (listExpr
->Type() == PrologList
)
1354 wxItemResource
*bitmapSpec
= new wxItemResource
;
1355 // bitmapSpec->SetType(wxTYPE_BITMAP);
1356 bitmapSpec
->SetType(wxT("wxBitmap"));
1358 // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
1359 // where everything after 'filename' is optional.
1360 wxExpr
*nameExpr
= listExpr
->Nth(0);
1361 wxExpr
*typeExpr
= listExpr
->Nth(1);
1362 wxExpr
*platformExpr
= listExpr
->Nth(2);
1363 wxExpr
*coloursExpr
= listExpr
->Nth(3);
1364 wxExpr
*xresExpr
= listExpr
->Nth(4);
1365 wxExpr
*yresExpr
= listExpr
->Nth(5);
1366 if (nameExpr
&& nameExpr
->StringValue() != wxT(""))
1368 bitmapSpec
->SetName(nameExpr
->StringValue());
1370 if (typeExpr
&& typeExpr
->StringValue() != wxT(""))
1372 bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue()));
1375 bitmapSpec
->SetValue1(0);
1377 if (platformExpr
&& platformExpr
->StringValue() != wxT(""))
1379 wxString
plat(platformExpr
->StringValue());
1380 if (plat
== wxT("windows") || plat
== wxT("WINDOWS"))
1381 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
);
1382 else if (plat
== wxT("x") || plat
== wxT("X"))
1383 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
);
1384 else if (plat
== wxT("mac") || plat
== wxT("MAC"))
1385 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
);
1387 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1390 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1393 bitmapSpec
->SetValue3(coloursExpr
->IntegerValue());
1397 xres
= (int)xresExpr
->IntegerValue();
1399 yres
= (int)yresExpr
->IntegerValue();
1400 bitmapSpec
->SetSize(0, 0, xres
, yres
);
1402 bitmapItem
->GetChildren().Append(bitmapSpec
);
1406 bitmapExpr
= bitmapExpr
->GetNext();
1412 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
)
1414 wxItemResource
*item
= wxResourceInterpretBitmap(table
, expr
);
1417 // item->SetType(wxTYPE_ICON);
1418 item
->SetType(wxT("wxIcon"));
1422 return (wxItemResource
*) NULL
;
1425 // Interpret list expression as a font
1426 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
)
1428 if (expr
->Type() != PrologList
)
1432 int family
= wxSWISS
;
1433 int style
= wxNORMAL
;
1434 int weight
= wxNORMAL
;
1436 wxString
faceName(wxT(""));
1438 wxExpr
*pointExpr
= expr
->Nth(0);
1439 wxExpr
*familyExpr
= expr
->Nth(1);
1440 wxExpr
*styleExpr
= expr
->Nth(2);
1441 wxExpr
*weightExpr
= expr
->Nth(3);
1442 wxExpr
*underlineExpr
= expr
->Nth(4);
1443 wxExpr
*faceNameExpr
= expr
->Nth(5);
1445 point
= (int)pointExpr
->IntegerValue();
1450 str
= familyExpr
->StringValue();
1451 family
= (int)wxParseWindowStyle(str
);
1455 str
= styleExpr
->StringValue();
1456 style
= (int)wxParseWindowStyle(str
);
1460 str
= weightExpr
->StringValue();
1461 weight
= (int)wxParseWindowStyle(str
);
1464 underline
= (int)underlineExpr
->IntegerValue();
1466 faceName
= faceNameExpr
->StringValue();
1468 wxFont
font(point
, family
, style
, weight
, (underline
!= 0), faceName
);
1472 // Separate file for the remainder of this, for BC++/Win16
1474 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
1476 * (Re)allocate buffer for reading in from resource file
1479 bool wxReallocateResourceBuffer()
1481 if (!wxResourceBuffer
)
1483 wxResourceBufferSize
= 1000;
1484 wxResourceBuffer
= new char[wxResourceBufferSize
];
1487 if (wxResourceBuffer
)
1489 long newSize
= wxResourceBufferSize
+ 1000;
1490 char *tmp
= new char[(int)newSize
];
1491 strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
);
1492 delete[] wxResourceBuffer
;
1493 wxResourceBuffer
= tmp
;
1494 wxResourceBufferSize
= newSize
;
1499 static bool wxEatWhiteSpace(FILE *fd
)
1503 while ((ch
= getc(fd
)) != EOF
)
1518 ungetc(prev_ch
, fd
);
1526 while ((ch
= getc(fd
)) != EOF
)
1528 if (ch
== '/' && prev_ch
== '*')
1536 static char buffer
[255];
1537 fgets(buffer
, 255, fd
);
1541 ungetc(prev_ch
, fd
);
1555 static bool wxEatWhiteSpace(wxInputStream
*is
)
1557 int ch
= is
->GetC() ;
1558 if ((ch
!= ' ') && (ch
!= '/') && (ch
!= ' ') && (ch
!= 10) && (ch
!= 13) && (ch
!= 9))
1565 while (ch
== ' ' || ch
== 10 || ch
== 13 || ch
== 9)
1567 // Check for comment
1573 bool finished
= FALSE
;
1581 int newCh
= is
->GetC();
1596 return wxEatWhiteSpace(is
);
1599 bool wxGetResourceToken(FILE *fd
)
1601 if (!wxResourceBuffer
)
1602 wxReallocateResourceBuffer();
1603 wxResourceBuffer
[0] = 0;
1604 wxEatWhiteSpace(fd
);
1610 wxResourceBufferCount
= 0;
1617 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1620 // Escaped characters
1621 else if (ch
== '\\')
1623 int newCh
= getc(fd
);
1626 else if (newCh
== 10)
1634 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1635 wxReallocateResourceBuffer();
1636 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1637 wxResourceBufferCount
++;
1640 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1644 wxResourceBufferCount
= 0;
1646 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1648 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1649 wxReallocateResourceBuffer();
1650 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1651 wxResourceBufferCount
++;
1655 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1662 bool wxGetResourceToken(wxInputStream
*is
)
1664 if (!wxResourceBuffer
)
1665 wxReallocateResourceBuffer();
1666 wxResourceBuffer
[0] = 0;
1667 wxEatWhiteSpace(is
);
1669 int ch
= is
->GetC() ;
1673 wxResourceBufferCount
= 0;
1680 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1683 // Escaped characters
1684 else if (ch
== '\\')
1686 int newCh
= is
->GetC();
1689 else if (newCh
== 10)
1691 else if (newCh
== 13) // mac
1699 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1700 wxReallocateResourceBuffer();
1701 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1702 wxResourceBufferCount
++;
1705 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1709 wxResourceBufferCount
= 0;
1711 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1713 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1714 wxReallocateResourceBuffer();
1715 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1716 wxResourceBufferCount
++;
1720 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1728 * Files are in form:
1729 static char *name = "....";
1730 with possible comments.
1733 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1736 table
= wxDefaultResourceTable
;
1738 // static or #define
1739 if (!wxGetResourceToken(fd
))
1745 if (strcmp(wxResourceBuffer
, "#define") == 0)
1747 wxGetResourceToken(fd
);
1748 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1749 wxGetResourceToken(fd
);
1750 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1751 if (wxIsdigit(value
[0]))
1753 int val
= (int)wxAtol(value
);
1754 wxResourceAddIdentifier(name
, val
, table
);
1758 wxLogWarning(_("#define %s must be an integer."), name
);
1768 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1770 wxGetResourceToken(fd
);
1771 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1772 wxChar
*actualName
= name
;
1773 if (name
[0] == wxT('"'))
1774 actualName
= name
+ 1;
1775 int len
= wxStrlen(name
);
1776 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1778 if (!wxResourceParseIncludeFile(actualName
, table
))
1780 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1785 else if (strcmp(wxResourceBuffer
, "static") != 0)
1788 wxStrcpy(buf
, _("Found "));
1789 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
1790 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1796 if (!wxGetResourceToken(fd
))
1798 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1803 if (strcmp(wxResourceBuffer
, "char") != 0)
1805 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1810 if (!wxGetResourceToken(fd
))
1812 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1817 if (wxResourceBuffer
[0] != '*')
1819 wxLogWarning(_("Expected '*' whilst parsing resource."));
1822 wxChar nameBuf
[100];
1823 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
1827 if (!wxGetResourceToken(fd
))
1829 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1834 if (strcmp(wxResourceBuffer
, "=") != 0)
1836 wxLogWarning(_("Expected '=' whilst parsing resource."));
1841 if (!wxGetResourceToken(fd
))
1843 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1849 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1851 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1856 if (!wxGetResourceToken(fd
))
1863 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1866 table
= wxDefaultResourceTable
;
1868 // static or #define
1869 if (!wxGetResourceToken(fd
))
1875 if (strcmp(wxResourceBuffer
, "#define") == 0)
1877 wxGetResourceToken(fd
);
1878 char *name
= copystring(wxResourceBuffer
);
1879 wxGetResourceToken(fd
);
1880 char *value
= copystring(wxResourceBuffer
);
1881 if (isalpha(value
[0]))
1883 int val
= (int)atol(value
);
1884 wxResourceAddIdentifier(name
, val
, table
);
1888 wxLogWarning(_("#define %s must be an integer."), name
);
1898 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1900 wxGetResourceToken(fd
);
1901 char *name
= copystring(wxResourceBuffer
);
1902 char *actualName
= name
;
1904 actualName
= name
+ 1;
1905 int len
= strlen(name
);
1906 if ((len
> 0) && (name
[len
-1] == '"'))
1908 if (!wxResourceParseIncludeFile(actualName
, table
))
1910 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1915 else if (strcmp(wxResourceBuffer
, "static") != 0)
1918 strcpy(buf
, _("Found "));
1919 strncat(buf
, wxResourceBuffer
, 30);
1920 strcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1926 if (!wxGetResourceToken(fd
))
1928 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1933 if (strcmp(wxResourceBuffer
, "char") != 0)
1935 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1940 if (!wxGetResourceToken(fd
))
1942 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1947 if (wxResourceBuffer
[0] != '*')
1949 wxLogWarning(_("Expected '*' whilst parsing resource."));
1953 strncpy(nameBuf
, wxResourceBuffer
+1, 99);
1956 if (!wxGetResourceToken(fd
))
1958 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1963 if (strcmp(wxResourceBuffer
, "=") != 0)
1965 wxLogWarning(_("Expected '=' whilst parsing resource."));
1970 if (!wxGetResourceToken(fd
))
1972 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1978 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1980 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1985 if (!wxGetResourceToken(fd
))
1993 * Parses string window style into integer window style
1997 * Style flag parsing, e.g.
1998 * "wxSYSTEM_MENU | wxBORDER" -> integer
2001 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
)
2004 return (wxChar
*) NULL
;
2006 static wxChar buf
[150];
2007 int len
= wxStrlen(s
);
2010 while ((ii
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == wxT('_'))))
2018 // Eat whitespace and conjunction characters
2019 while ((ii
< len
) &&
2020 ((s
[ii
] == wxT(' ')) || (s
[ii
] == wxT('|')) || (s
[ii
] == wxT(','))))
2026 return (wxChar
*) NULL
;
2031 struct wxResourceBitListStruct
2037 static wxResourceBitListStruct wxResourceBitListTable
[] =
2040 { wxT("wxSINGLE"), wxLB_SINGLE
},
2041 { wxT("wxMULTIPLE"), wxLB_MULTIPLE
},
2042 { wxT("wxEXTENDED"), wxLB_EXTENDED
},
2043 { wxT("wxLB_SINGLE"), wxLB_SINGLE
},
2044 { wxT("wxLB_MULTIPLE"), wxLB_MULTIPLE
},
2045 { wxT("wxLB_EXTENDED"), wxLB_EXTENDED
},
2046 { wxT("wxLB_NEEDED_SB"), wxLB_NEEDED_SB
},
2047 { wxT("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB
},
2048 { wxT("wxLB_SORT"), wxLB_SORT
},
2049 { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW
},
2050 { wxT("wxLB_HSCROLL"), wxLB_HSCROLL
},
2053 { wxT("wxCB_SIMPLE"), wxCB_SIMPLE
},
2054 { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN
},
2055 { wxT("wxCB_READONLY"), wxCB_READONLY
},
2056 { wxT("wxCB_SORT"), wxCB_SORT
},
2059 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR
},
2060 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL
},
2061 { wxT("wxGA_VERTICAL"), wxGA_VERTICAL
},
2064 { wxT("wxPASSWORD"), wxPASSWORD
},
2065 { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER
},
2066 { wxT("wxTE_PASSWORD"), wxTE_PASSWORD
},
2067 { wxT("wxTE_READONLY"), wxTE_READONLY
},
2068 { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
},
2069 { wxT("wxTE_MULTILINE"), wxTE_MULTILINE
},
2070 { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL
},
2072 /* wxRadioBox/wxRadioButton */
2073 { wxT("wxRB_GROUP"), wxRB_GROUP
},
2074 { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS
},
2075 { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS
},
2076 { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL
},
2077 { wxT("wxRA_VERTICAL"), wxRA_VERTICAL
},
2080 { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL
},
2081 { wxT("wxSL_VERTICAL"), wxSL_VERTICAL
},
2082 { wxT("wxSL_AUTOTICKS"), wxSL_AUTOTICKS
},
2083 { wxT("wxSL_LABELS"), wxSL_LABELS
},
2084 { wxT("wxSL_LEFT"), wxSL_LEFT
},
2085 { wxT("wxSL_TOP"), wxSL_TOP
},
2086 { wxT("wxSL_RIGHT"), wxSL_RIGHT
},
2087 { wxT("wxSL_BOTTOM"), wxSL_BOTTOM
},
2088 { wxT("wxSL_BOTH"), wxSL_BOTH
},
2089 { wxT("wxSL_SELRANGE"), wxSL_SELRANGE
},
2092 { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL
},
2093 { wxT("wxSB_VERTICAL"), wxSB_VERTICAL
},
2096 { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW
},
2097 { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW
},
2100 { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS
},
2101 { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS
},
2102 { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT
},
2105 { wxT("wxLC_ICON"), wxLC_ICON
},
2106 { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON
},
2107 { wxT("wxLC_LIST"), wxLC_LIST
},
2108 { wxT("wxLC_REPORT"), wxLC_REPORT
},
2109 { wxT("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP
},
2110 { wxT("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT
},
2111 { wxT("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE
},
2112 { wxT("wxLC_USER_TEXT"), wxLC_USER_TEXT
},
2113 { wxT("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS
},
2114 { wxT("wxLC_NO_HEADER"), wxLC_NO_HEADER
},
2115 { wxT("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER
},
2116 { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL
},
2117 { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING
},
2118 { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING
},
2121 { wxT("wxSP_VERTICAL"), wxSP_VERTICAL
},
2122 { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
},
2123 { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
},
2124 { wxT("wxSP_WRAP"), wxSP_WRAP
},
2127 { wxT("wxSP_NOBORDER"), wxSP_NOBORDER
},
2128 { wxT("wxSP_3D"), wxSP_3D
},
2129 { wxT("wxSP_BORDER"), wxSP_BORDER
},
2132 { wxT("wxTC_MULTILINE"), wxTC_MULTILINE
},
2133 { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
},
2134 { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
},
2135 { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
},
2138 { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP
},
2141 { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH
},
2142 { wxT("wxALIGN_LEFT"), wxALIGN_LEFT
},
2143 { wxT("wxALIGN_CENTER"), wxALIGN_CENTER
},
2144 { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE
},
2145 { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT
},
2146 { wxT("wxCOLOURED"), wxCOLOURED
},
2149 { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
},
2150 { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
},
2151 { wxT("wxTB_VERTICAL"), wxTB_VERTICAL
},
2152 { wxT("wxTB_FLAT"), wxTB_FLAT
},
2155 { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL
},
2158 { wxT("wxVSCROLL"), wxVSCROLL
},
2159 { wxT("wxHSCROLL"), wxHSCROLL
},
2160 { wxT("wxCAPTION"), wxCAPTION
},
2161 { wxT("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
},
2162 { wxT("wxICONIZE"), wxICONIZE
},
2163 { wxT("wxMINIMIZE"), wxICONIZE
},
2164 { wxT("wxMAXIMIZE"), wxMAXIMIZE
},
2166 { wxT("wxMDI_PARENT"), 0},
2167 { wxT("wxMDI_CHILD"), 0},
2168 { wxT("wxTHICK_FRAME"), wxTHICK_FRAME
},
2169 { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER
},
2170 { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU
},
2171 { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
},
2172 { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
},
2173 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX
},
2174 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
},
2175 { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
},
2176 { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
},
2177 { wxT("wxBORDER"), wxBORDER
},
2178 { wxT("wxRETAINED"), wxRETAINED
},
2179 { wxT("wxNATIVE_IMPL"), 0},
2180 { wxT("wxEXTENDED_IMPL"), 0},
2181 { wxT("wxBACKINGSTORE"), wxBACKINGSTORE
},
2182 // { wxT("wxFLAT"), wxFLAT},
2183 // { wxT("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
2184 { wxT("wxFIXED_LENGTH"), 0},
2185 { wxT("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
},
2186 { wxT("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
},
2187 { wxT("wxRAISED_BORDER"), wxRAISED_BORDER
},
2188 { wxT("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
},
2189 { wxT("wxSTATIC_BORDER"), wxSTATIC_BORDER
},
2190 { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
},
2191 { wxT("wxNO_BORDER"), wxNO_BORDER
},
2192 { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
},
2193 { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
2195 { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
},
2196 { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
},
2198 // Text font families
2199 { wxT("wxDEFAULT"), wxDEFAULT
},
2200 { wxT("wxDECORATIVE"), wxDECORATIVE
},
2201 { wxT("wxROMAN"), wxROMAN
},
2202 { wxT("wxSCRIPT"), wxSCRIPT
},
2203 { wxT("wxSWISS"), wxSWISS
},
2204 { wxT("wxMODERN"), wxMODERN
},
2205 { wxT("wxTELETYPE"), wxTELETYPE
},
2206 { wxT("wxVARIABLE"), wxVARIABLE
},
2207 { wxT("wxFIXED"), wxFIXED
},
2208 { wxT("wxNORMAL"), wxNORMAL
},
2209 { wxT("wxLIGHT"), wxLIGHT
},
2210 { wxT("wxBOLD"), wxBOLD
},
2211 { wxT("wxITALIC"), wxITALIC
},
2212 { wxT("wxSLANT"), wxSLANT
},
2213 { wxT("wxSOLID"), wxSOLID
},
2214 { wxT("wxDOT"), wxDOT
},
2215 { wxT("wxLONG_DASH"), wxLONG_DASH
},
2216 { wxT("wxSHORT_DASH"), wxSHORT_DASH
},
2217 { wxT("wxDOT_DASH"), wxDOT_DASH
},
2218 { wxT("wxUSER_DASH"), wxUSER_DASH
},
2219 { wxT("wxTRANSPARENT"), wxTRANSPARENT
},
2220 { wxT("wxSTIPPLE"), wxSTIPPLE
},
2221 { wxT("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
},
2222 { wxT("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
},
2223 { wxT("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
},
2224 { wxT("wxCROSS_HATCH"), wxCROSS_HATCH
},
2225 { wxT("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
},
2226 { wxT("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
},
2227 { wxT("wxJOIN_BEVEL"), wxJOIN_BEVEL
},
2228 { wxT("wxJOIN_MITER"), wxJOIN_MITER
},
2229 { wxT("wxJOIN_ROUND"), wxJOIN_ROUND
},
2230 { wxT("wxCAP_ROUND"), wxCAP_ROUND
},
2231 { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING
},
2232 { wxT("wxCAP_BUTT"), wxCAP_BUTT
},
2235 { wxT("wxCLEAR"), wxCLEAR
},
2236 { wxT("wxXOR"), wxXOR
},
2237 { wxT("wxINVERT"), wxINVERT
},
2238 { wxT("wxOR_REVERSE"), wxOR_REVERSE
},
2239 { wxT("wxAND_REVERSE"), wxAND_REVERSE
},
2240 { wxT("wxCOPY"), wxCOPY
},
2241 { wxT("wxAND"), wxAND
},
2242 { wxT("wxAND_INVERT"), wxAND_INVERT
},
2243 { wxT("wxNO_OP"), wxNO_OP
},
2244 { wxT("wxNOR"), wxNOR
},
2245 { wxT("wxEQUIV"), wxEQUIV
},
2246 { wxT("wxSRC_INVERT"), wxSRC_INVERT
},
2247 { wxT("wxOR_INVERT"), wxOR_INVERT
},
2248 { wxT("wxNAND"), wxNAND
},
2249 { wxT("wxOR"), wxOR
},
2250 { wxT("wxSET"), wxSET
},
2252 { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
},
2253 { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER
},
2254 { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE
},
2255 { wxT("wxWINDING_RULE"), wxWINDING_RULE
},
2256 { wxT("wxHORIZONTAL"), wxHORIZONTAL
},
2257 { wxT("wxVERTICAL"), wxVERTICAL
},
2258 { wxT("wxBOTH"), wxBOTH
},
2259 { wxT("wxCENTER_FRAME"), wxCENTER_FRAME
},
2260 { wxT("wxOK"), wxOK
},
2261 { wxT("wxYES_NO"), wxYES_NO
},
2262 { wxT("wxCANCEL"), wxCANCEL
},
2263 { wxT("wxYES"), wxYES
},
2264 { wxT("wxNO"), wxNO
},
2265 { wxT("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
},
2266 { wxT("wxICON_HAND"), wxICON_HAND
},
2267 { wxT("wxICON_QUESTION"), wxICON_QUESTION
},
2268 { wxT("wxICON_INFORMATION"), wxICON_INFORMATION
},
2269 { wxT("wxICON_STOP"), wxICON_STOP
},
2270 { wxT("wxICON_ASTERISK"), wxICON_ASTERISK
},
2271 { wxT("wxICON_MASK"), wxICON_MASK
},
2272 { wxT("wxCENTRE"), wxCENTRE
},
2273 { wxT("wxCENTER"), wxCENTRE
},
2274 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS
},
2275 { wxT("wxVERTICAL_LABEL"), 0},
2276 { wxT("wxHORIZONTAL_LABEL"), 0},
2278 // Bitmap types (not strictly styles)
2279 { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
},
2280 { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
},
2281 { wxT("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
},
2282 { wxT("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2283 { wxT("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2284 { wxT("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
},
2285 { wxT("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
},
2286 { wxT("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
},
2287 { wxT("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
},
2288 { wxT("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
},
2289 { wxT("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
},
2290 { wxT("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
},
2291 { wxT("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
},
2292 { wxT("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
}
2295 static int wxResourceBitListCount
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
));
2297 long wxParseWindowStyle(const wxString
& bitListString
)
2302 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2303 while (word
!= NULL
)
2307 for (j
= 0; j
< wxResourceBitListCount
; j
++)
2308 if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0)
2310 bitList
|= wxResourceBitListTable
[j
].bits
;
2316 wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
);
2319 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2325 * Load a bitmap from a wxWindows resource, choosing an optimum
2326 * depth and appropriate type.
2329 wxBitmap
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable
*table
)
2332 table
= wxDefaultResourceTable
;
2334 wxItemResource
*item
= table
->FindResource(resource
);
2337 if ((item
->GetType() == wxT("")) || (item
->GetType() != wxT("wxBitmap")))
2339 wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
);
2340 return wxNullBitmap
;
2342 int thisDepth
= wxDisplayDepth();
2343 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2345 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2347 // Try to find optimum bitmap for this platform/colour depth
2348 wxNode
*node
= item
->GetChildren().First();
2351 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2352 int platform
= (int)child
->GetValue2();
2353 int noColours
= (int)child
->GetValue3();
2355 char *name = child->GetName();
2356 int bitmapType = (int)child->GetValue1();
2357 int xRes = child->GetWidth();
2358 int yRes = child->GetHeight();
2363 case RESOURCE_PLATFORM_ANY
:
2365 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2366 optResource
= child
;
2369 // Maximise the number of colours.
2370 // If noColours is zero (unspecified), then assume this
2371 // is the right one.
2372 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2373 optResource
= child
;
2378 case RESOURCE_PLATFORM_WINDOWS
:
2380 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2381 optResource
= child
;
2384 // Maximise the number of colours
2385 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2386 optResource
= child
;
2392 case RESOURCE_PLATFORM_X
:
2394 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2395 optResource
= child
;
2398 // Maximise the number of colours
2399 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2400 optResource
= child
;
2406 case RESOURCE_PLATFORM_MAC
:
2408 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2409 optResource
= child
;
2412 // Maximise the number of colours
2413 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2414 optResource
= child
;
2422 node
= node
->Next();
2424 // If no matching resource, fail.
2426 return wxNullBitmap
;
2428 wxString name
= optResource
->GetName();
2429 int bitmapType
= (int)optResource
->GetValue1();
2432 case wxBITMAP_TYPE_XBM_DATA
:
2435 wxItemResource
*item
= table
->FindResource(name
);
2438 wxLogWarning(_("Failed to find XBM resource %s.\n"
2439 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2440 return wxNullBitmap
;
2442 return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ;
2444 wxLogWarning(_("No XBM facility available!"));
2448 case wxBITMAP_TYPE_XPM_DATA
:
2450 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2451 wxItemResource
*item
= table
->FindResource(name
);
2454 wxLogWarning(_("Failed to find XPM resource %s.\n"
2455 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2456 return wxNullBitmap
;
2458 return wxBitmap((char **)item
->GetValue1());
2460 wxLogWarning(_("No XPM facility available!"));
2466 return wxBitmap(name
, bitmapType
);
2469 return wxNullBitmap
;
2473 wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
);
2474 return wxNullBitmap
;
2479 * Load an icon from a wxWindows resource, choosing an optimum
2480 * depth and appropriate type.
2483 wxIcon
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable
*table
)
2486 table
= wxDefaultResourceTable
;
2488 wxItemResource
*item
= table
->FindResource(resource
);
2491 if ((item
->GetType() == wxT("")) || wxStrcmp(item
->GetType(), wxT("wxIcon")) != 0)
2493 wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
);
2496 int thisDepth
= wxDisplayDepth();
2497 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2499 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2501 // Try to find optimum icon for this platform/colour depth
2502 wxNode
*node
= item
->GetChildren().First();
2505 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2506 int platform
= (int)child
->GetValue2();
2507 int noColours
= (int)child
->GetValue3();
2509 char *name = child->GetName();
2510 int bitmapType = (int)child->GetValue1();
2511 int xRes = child->GetWidth();
2512 int yRes = child->GetHeight();
2517 case RESOURCE_PLATFORM_ANY
:
2519 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2520 optResource
= child
;
2523 // Maximise the number of colours.
2524 // If noColours is zero (unspecified), then assume this
2525 // is the right one.
2526 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2527 optResource
= child
;
2532 case RESOURCE_PLATFORM_WINDOWS
:
2534 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2535 optResource
= child
;
2538 // Maximise the number of colours
2539 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2540 optResource
= child
;
2546 case RESOURCE_PLATFORM_X
:
2548 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2549 optResource
= child
;
2552 // Maximise the number of colours
2553 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2554 optResource
= child
;
2560 case RESOURCE_PLATFORM_MAC
:
2562 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2563 optResource
= child
;
2566 // Maximise the number of colours
2567 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2568 optResource
= child
;
2576 node
= node
->Next();
2578 // If no matching resource, fail.
2582 wxString name
= optResource
->GetName();
2583 int bitmapType
= (int)optResource
->GetValue1();
2586 case wxBITMAP_TYPE_XBM_DATA
:
2589 wxItemResource
*item
= table
->FindResource(name
);
2592 wxLogWarning(_("Failed to find XBM resource %s.\n"
2593 "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
);
2596 return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3());
2598 wxLogWarning(_("No XBM facility available!"));
2602 case wxBITMAP_TYPE_XPM_DATA
:
2604 // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
2606 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2607 wxItemResource *item = table->FindResource(name);
2611 sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name);
2615 return wxIcon((char **)item->GetValue1());
2617 wxLogWarning(_("No XPM facility available!"));
2620 wxLogWarning(_("No XPM icon facility available!"));
2626 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2628 return wxIcon(name
, bitmapType
);
2637 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2642 wxMenu
*wxResourceCreateMenu(wxItemResource
*item
)
2644 wxMenu
*menu
= new wxMenu
;
2645 wxNode
*node
= item
->GetChildren().First();
2648 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2649 if ((child
->GetType() != wxT("")) && (child
->GetType() == wxT("wxMenuSeparator")))
2650 menu
->AppendSeparator();
2651 else if (child
->GetChildren().Number() > 0)
2653 wxMenu
*subMenu
= wxResourceCreateMenu(child
);
2655 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4());
2659 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0));
2661 node
= node
->Next();
2666 wxMenuBar
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable
*table
, wxMenuBar
*menuBar
)
2669 table
= wxDefaultResourceTable
;
2671 wxItemResource
*menuResource
= table
->FindResource(resource
);
2672 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2675 menuBar
= new wxMenuBar
;
2676 wxNode
*node
= menuResource
->GetChildren().First();
2679 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2680 wxMenu
*menu
= wxResourceCreateMenu(child
);
2682 menuBar
->Append(menu
, child
->GetTitle());
2683 node
= node
->Next();
2687 return (wxMenuBar
*) NULL
;
2690 wxMenu
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable
*table
)
2693 table
= wxDefaultResourceTable
;
2695 wxItemResource
*menuResource
= table
->FindResource(resource
);
2696 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2697 // if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
2698 return wxResourceCreateMenu(menuResource
);
2699 return (wxMenu
*) NULL
;
2702 // Global equivalents (so don't have to refer to default table explicitly)
2703 bool wxResourceParseData(const wxString
& resource
, wxResourceTable
*table
)
2706 table
= wxDefaultResourceTable
;
2708 return table
->ParseResourceData(resource
);
2711 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable
*table
)
2714 table
= wxDefaultResourceTable
;
2716 return table
->ParseResourceFile(filename
);
2719 // Register XBM/XPM data
2720 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable
*table
)
2723 table
= wxDefaultResourceTable
;
2725 return table
->RegisterResourceBitmapData(name
, bits
, width
, height
);
2728 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable
*table
)
2731 table
= wxDefaultResourceTable
;
2733 return table
->RegisterResourceBitmapData(name
, data
);
2736 void wxResourceClear(wxResourceTable
*table
)
2739 table
= wxDefaultResourceTable
;
2741 table
->ClearTable();
2748 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable
*table
)
2751 table
= wxDefaultResourceTable
;
2753 table
->identifiers
.Put(name
, (wxObject
*)(long)value
);
2757 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable
*table
)
2760 table
= wxDefaultResourceTable
;
2762 return (int)(long)table
->identifiers
.Get(name
);
2766 * Parse #include file for #defines (only)
2769 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
)
2772 table
= wxDefaultResourceTable
;
2774 FILE *fd
= fopen(f
.fn_str(), "r");
2779 while (wxGetResourceToken(fd
))
2781 if (strcmp(wxResourceBuffer
, "#define") == 0)
2783 wxGetResourceToken(fd
);
2784 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2785 wxGetResourceToken(fd
);
2786 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2787 if (wxIsdigit(value
[0]))
2789 int val
= (int)wxAtol(value
);
2790 wxResourceAddIdentifier(name
, val
, table
);
2801 * Reading strings as if they were .wxr files
2804 static int getc_string(char *s
)
2806 int ch
= s
[wxResourceStringPtr
];
2811 wxResourceStringPtr
++;
2816 static int ungetc_string()
2818 wxResourceStringPtr
--;
2822 bool wxEatWhiteSpaceString(char *s
)
2826 while ((ch
= getc_string(s
)) != EOF
)
2838 ch
= getc_string(s
);
2849 while ((ch
= getc_string(s
)) != EOF
)
2851 if (ch
== '/' && prev_ch
== '*')
2873 bool wxGetResourceTokenString(char *s
)
2875 if (!wxResourceBuffer
)
2876 wxReallocateResourceBuffer();
2877 wxResourceBuffer
[0] = 0;
2878 wxEatWhiteSpaceString(s
);
2880 int ch
= getc_string(s
);
2884 wxResourceBufferCount
= 0;
2885 ch
= getc_string(s
);
2891 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2894 // Escaped characters
2895 else if (ch
== '\\')
2897 int newCh
= getc_string(s
);
2900 else if (newCh
== 10)
2908 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2909 wxReallocateResourceBuffer();
2910 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
2911 wxResourceBufferCount
++;
2912 ch
= getc_string(s
);
2914 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2918 wxResourceBufferCount
= 0;
2920 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
2922 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2923 wxReallocateResourceBuffer();
2924 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
2925 wxResourceBufferCount
++;
2927 ch
= getc_string(s
);
2929 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2937 * Files are in form:
2938 static char *name = "....";
2939 with possible comments.
2942 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
2945 table
= wxDefaultResourceTable
;
2947 // static or #define
2948 if (!wxGetResourceTokenString(s
))
2954 if (strcmp(wxResourceBuffer
, "#define") == 0)
2956 wxGetResourceTokenString(s
);
2957 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2958 wxGetResourceTokenString(s
);
2959 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2960 if (wxIsdigit(value
[0]))
2962 int val
= (int)wxAtol(value
);
2963 wxResourceAddIdentifier(name
, val
, table
);
2967 wxLogWarning(_("#define %s must be an integer."), name
);
2978 else if (strcmp(wxResourceBuffer, "#include") == 0)
2980 wxGetResourceTokenString(s);
2981 char *name = copystring(wxResourceBuffer);
2982 char *actualName = name;
2984 actualName = name + 1;
2985 int len = strlen(name);
2986 if ((len > 0) && (name[len-1] == '"'))
2988 if (!wxResourceParseIncludeFile(actualName, table))
2991 sprintf(buf, _("Could not find resource include file %s."), actualName);
2998 else if (strcmp(wxResourceBuffer
, "static") != 0)
3001 wxStrcpy(buf
, _("Found "));
3002 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
3003 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
3009 if (!wxGetResourceTokenString(s
))
3011 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3016 if (strcmp(wxResourceBuffer
, "char") != 0)
3018 wxLogWarning(_("Expected 'char' whilst parsing resource."));
3023 if (!wxGetResourceTokenString(s
))
3025 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3030 if (wxResourceBuffer
[0] != '*')
3032 wxLogWarning(_("Expected '*' whilst parsing resource."));
3035 wxChar nameBuf
[100];
3036 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
3040 if (!wxGetResourceTokenString(s
))
3042 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3047 if (strcmp(wxResourceBuffer
, "=") != 0)
3049 wxLogWarning(_("Expected '=' whilst parsing resource."));
3054 if (!wxGetResourceTokenString(s
))
3056 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3062 if (!db
.ReadPrologFromString(wxResourceBuffer
))
3064 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
3069 if (!wxGetResourceTokenString(s
))
3076 bool wxResourceParseString(char *s
, wxResourceTable
*table
)
3079 table
= wxDefaultResourceTable
;
3084 // Turn backslashes into spaces
3087 int len
= strlen(s
);
3089 for (i
= 0; i
< len
; i
++)
3090 if (s
[i
] == 92 && s
[i
+1] == 13)
3098 wxResourceStringPtr
= 0;
3101 while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
)
3105 return wxResourceInterpretResources(*table
, db
);
3109 * resource loading facility
3112 bool wxWindowBase::LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
)
3115 table
= wxDefaultResourceTable
;
3117 wxItemResource
*resource
= table
->FindResource((const wxChar
*)resourceName
);
3118 // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
3119 if (!resource
|| (resource
->GetType() == wxT("")) ||
3120 ! ((resource
->GetType() == wxT("wxDialog")) || (resource
->GetType() == wxT("wxPanel"))))
3123 wxString
title(resource
->GetTitle());
3124 long theWindowStyle
= resource
->GetStyle();
3125 bool isModal
= (resource
->GetValue1() != 0);
3126 int x
= resource
->GetX();
3127 int y
= resource
->GetY();
3128 int width
= resource
->GetWidth();
3129 int height
= resource
->GetHeight();
3130 wxString name
= resource
->GetName();
3132 if (IsKindOf(CLASSINFO(wxDialog
)))
3134 wxDialog
*dialogBox
= (wxDialog
*)this;
3135 long modalStyle
= isModal
? wxDIALOG_MODAL
: 0;
3136 if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
))
3139 // Only reset the client size if we know we're not going to do it again below.
3140 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0)
3141 dialogBox
->SetClientSize(width
, height
);
3143 else if (IsKindOf(CLASSINFO(wxPanel
)))
3145 wxPanel
* panel
= (wxPanel
*)this;
3146 if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
| wxTAB_TRAVERSAL
, name
))
3151 if (!((wxWindow
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
))
3155 if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
3157 // No need to do this since it's done in wxPanel or wxDialog constructor.
3158 // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
3162 if (resource
->GetFont().Ok())
3163 SetFont(resource
->GetFont());
3164 if (resource
->GetBackgroundColour().Ok())
3165 SetBackgroundColour(resource
->GetBackgroundColour());
3168 // Should have some kind of font at this point
3169 if (!GetFont().Ok())
3170 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
3171 if (!GetBackgroundColour().Ok())
3172 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
3174 // Only when we've created the window and set the font can we set the correct size,
3175 // if based on dialog units.
3176 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
3178 wxSize sz
= ConvertDialogToPixels(wxSize(width
, height
));
3179 SetClientSize(sz
.x
, sz
.y
);
3181 wxPoint pt
= ConvertDialogToPixels(wxPoint(x
, y
));
3185 // Now create children
3186 wxNode
*node
= resource
->GetChildren().First();
3189 wxItemResource
*childResource
= (wxItemResource
*)node
->Data();
3191 (void) CreateItem(childResource
, resource
, table
);
3193 node
= node
->Next();
3198 wxControl
*wxWindowBase::CreateItem(const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
)
3201 table
= wxDefaultResourceTable
;
3202 return table
->CreateItem((wxWindow
*)this, resource
, parentResource
);
3206 #pragma warning(default:4706) // assignment within conditional expression
3212 #endif // wxUSE_WX_RESOURCES