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() | wxBU_AUTODRAW
, 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("") || itemType
== wxString(wxT("wxStaticBitmap")) )
353 wxBitmap bitmap
= childResource
->GetBitmap();
356 bitmap
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable
*)this);
357 ((wxItemResource
*) childResource
)->SetBitmap(bitmap
);
359 #if wxUSE_BITMAP_MESSAGE
361 // Use a default bitmap
363 bitmap
.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE
);
367 control
= new wxStaticBitmap(parent
, id
, bitmap
, pos
, size
,
368 childResource
->GetStyle(), childResource
->GetName());
373 control
= new wxStaticText(parent
, id
, childResource
->GetTitle(), pos
, size
,
374 childResource
->GetStyle(), childResource
->GetName());
377 else if (itemType
== wxString(wxT("wxText")) || itemType
== wxString(wxT("wxTextCtrl")) || itemType
== wxString(wxT("wxMultiText")))
379 control
= new wxTextCtrl(parent
, id
, childResource
->GetValue4(), pos
, size
,
380 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
382 else if (itemType
== wxString(wxT("wxCheckBox")))
384 control
= new wxCheckBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
385 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
387 ((wxCheckBox
*)control
)->SetValue((childResource
->GetValue1() != 0));
390 else if (itemType
== wxString(wxT("wxGauge")))
392 control
= new wxGauge(parent
, id
, (int)childResource
->GetValue2(), pos
, size
,
393 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
395 ((wxGauge
*)control
)->SetValue((int)childResource
->GetValue1());
399 else if (itemType
== wxString(wxT("wxRadioButton")))
401 control
= new wxRadioButton(parent
, id
, childResource
->GetTitle(), // (int)childResource->GetValue1(),
403 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
407 else if (itemType
== wxString(wxT("wxScrollBar")))
409 control
= new wxScrollBar(parent
, id
, pos
, size
,
410 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
412 ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1());
413 ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2());
414 ((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3());
415 ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5());
417 ((wxScrollBar
*)control
)->SetScrollbar((int)childResource
->GetValue1(),(int)childResource
->GetValue2(),
418 (int)childResource
->GetValue3(),(int)(long)childResource
->GetValue5(),FALSE
);
422 else if (itemType
== wxString(wxT("wxSlider")))
424 control
= new wxSlider(parent
, id
, (int)childResource
->GetValue1(),
425 (int)childResource
->GetValue2(), (int)childResource
->GetValue3(), pos
, size
,
426 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
428 else if (itemType
== wxString(wxT("wxGroupBox")) || itemType
== wxString(wxT("wxStaticBox")))
430 control
= new wxStaticBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
431 childResource
->GetStyle(), childResource
->GetName());
433 else if (itemType
== wxString(wxT("wxListBox")))
435 wxStringList
& stringList
= childResource
->GetStringValues();
436 wxString
*strings
= (wxString
*) NULL
;
438 if (stringList
.Number() > 0)
440 noStrings
= stringList
.Number();
441 strings
= new wxString
[noStrings
];
442 wxNode
*node
= stringList
.First();
446 strings
[i
] = (wxChar
*)node
->Data();
451 control
= new wxListBox(parent
, id
, pos
, size
,
452 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
457 else if (itemType
== wxString(wxT("wxChoice")))
459 wxStringList
& stringList
= childResource
->GetStringValues();
460 wxString
*strings
= (wxString
*) NULL
;
462 if (stringList
.Number() > 0)
464 noStrings
= stringList
.Number();
465 strings
= new wxString
[noStrings
];
466 wxNode
*node
= stringList
.First();
470 strings
[i
] = (wxChar
*)node
->Data();
475 control
= new wxChoice(parent
, id
, pos
, size
,
476 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
482 else if (itemType
== wxString(wxT("wxComboBox")))
484 wxStringList
& stringList
= childResource
->GetStringValues();
485 wxString
*strings
= (wxString
*) NULL
;
487 if (stringList
.Number() > 0)
489 noStrings
= stringList
.Number();
490 strings
= new wxString
[noStrings
];
491 wxNode
*node
= stringList
.First();
495 strings
[i
] = (wxChar
*)node
->Data();
500 control
= new wxComboBox(parent
, id
, childResource
->GetValue4(), pos
, size
,
501 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
507 else if (itemType
== wxString(wxT("wxRadioBox")))
509 wxStringList
& stringList
= childResource
->GetStringValues();
510 wxString
*strings
= (wxString
*) NULL
;
512 if (stringList
.Number() > 0)
514 noStrings
= stringList
.Number();
515 strings
= new wxString
[noStrings
];
516 wxNode
*node
= stringList
.First();
520 strings
[i
] = (wxChar
*)node
->Data();
525 control
= new wxRadioBox(parent
, (wxWindowID
) id
, wxString(childResource
->GetTitle()), pos
, size
,
526 noStrings
, strings
, (int)childResource
->GetValue1(), childResource
->GetStyle(), wxDefaultValidator
,
527 childResource
->GetName());
533 if ((parentResource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
535 // Don't set font; will be inherited from parent.
539 if (control
&& childResource
->GetFont().Ok())
541 control
->SetFont(childResource
->GetFont());
544 // Force the layout algorithm since the size changes the layout
545 if (control
->IsKindOf(CLASSINFO(wxRadioBox
)))
547 control
->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH
|wxSIZE_AUTO_HEIGHT
);
556 * Interpret database as a series of resources
559 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
)
561 wxNode
*node
= db
.First();
564 wxExpr
*clause
= (wxExpr
*)node
->Data();
565 wxString
functor(clause
->Functor());
567 wxItemResource
*item
= (wxItemResource
*) NULL
;
568 if (functor
== wxT("dialog"))
569 item
= wxResourceInterpretDialog(table
, clause
);
570 else if (functor
== wxT("panel"))
571 item
= wxResourceInterpretDialog(table
, clause
, TRUE
);
572 else if (functor
== wxT("menubar"))
573 item
= wxResourceInterpretMenuBar(table
, clause
);
574 else if (functor
== wxT("menu"))
575 item
= wxResourceInterpretMenu(table
, clause
);
576 else if (functor
== wxT("string"))
577 item
= wxResourceInterpretString(table
, clause
);
578 else if (functor
== wxT("bitmap"))
579 item
= wxResourceInterpretBitmap(table
, clause
);
580 else if (functor
== wxT("icon"))
581 item
= wxResourceInterpretIcon(table
, clause
);
585 // Remove any existing resource of same name
586 if (item
->GetName() != wxT(""))
587 table
.DeleteResource(item
->GetName());
588 table
.AddResource(item
);
595 static const wxChar
*g_ValidControlClasses
[] =
598 wxT("wxBitmapButton"),
601 wxT("wxStaticBitmap"),
607 wxT("wxRadioButton"),
609 wxT("wxBitmapCheckBox"),
619 static bool wxIsValidControlClass(const wxString
& c
)
621 for ( size_t i
= 0; i
< WXSIZEOF(g_ValidControlClasses
); i
++ )
623 if ( c
== g_ValidControlClasses
[i
] )
629 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
)
631 wxItemResource
*dialogItem
= new wxItemResource
;
633 dialogItem
->SetType(wxT("wxPanel"));
635 dialogItem
->SetType(wxT("wxDialog"));
636 wxString style
= wxT("");
637 wxString title
= wxT("");
638 wxString name
= wxT("");
639 wxString backColourHex
= wxT("");
640 wxString labelColourHex
= wxT("");
641 wxString buttonColourHex
= wxT("");
643 long windowStyle
= wxDEFAULT_DIALOG_STYLE
;
647 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
649 wxExpr
*labelFontExpr
= (wxExpr
*) NULL
;
650 wxExpr
*buttonFontExpr
= (wxExpr
*) NULL
;
651 wxExpr
*fontExpr
= (wxExpr
*) NULL
;
652 expr
->GetAttributeValue(wxT("style"), style
);
653 expr
->GetAttributeValue(wxT("name"), name
);
654 expr
->GetAttributeValue(wxT("title"), title
);
655 expr
->GetAttributeValue(wxT("x"), x
);
656 expr
->GetAttributeValue(wxT("y"), y
);
657 expr
->GetAttributeValue(wxT("width"), width
);
658 expr
->GetAttributeValue(wxT("height"), height
);
659 expr
->GetAttributeValue(wxT("modal"), isModal
);
660 expr
->GetAttributeValue(wxT("label_font"), &labelFontExpr
);
661 expr
->GetAttributeValue(wxT("button_font"), &buttonFontExpr
);
662 expr
->GetAttributeValue(wxT("font"), &fontExpr
);
663 expr
->GetAttributeValue(wxT("background_colour"), backColourHex
);
664 expr
->GetAttributeValue(wxT("label_colour"), labelColourHex
);
665 expr
->GetAttributeValue(wxT("button_colour"), buttonColourHex
);
667 int useDialogUnits
= 0;
668 expr
->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits
);
669 if (useDialogUnits
!= 0)
670 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
);
673 expr
->GetAttributeValue(wxT("use_system_defaults"), useDefaults
);
674 if (useDefaults
!= 0)
675 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
);
678 expr
->GetAttributeValue(wxT("id"), id
);
679 dialogItem
->SetId(id
);
681 if (style
!= wxT(""))
683 windowStyle
= wxParseWindowStyle(style
);
685 dialogItem
->SetStyle(windowStyle
);
686 dialogItem
->SetValue1(isModal
);
687 if (windowStyle
& wxDIALOG_MODAL
) // Uses style in wxWin 2
688 dialogItem
->SetValue1(TRUE
);
690 dialogItem
->SetName(name
);
691 dialogItem
->SetTitle(title
);
692 dialogItem
->SetSize(x
, y
, width
, height
);
694 if (backColourHex
!= wxT(""))
699 r
= wxHexToDec(backColourHex
.Mid(0, 2));
700 g
= wxHexToDec(backColourHex
.Mid(2, 2));
701 b
= wxHexToDec(backColourHex
.Mid(4, 2));
702 dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
704 if (labelColourHex
!= wxT(""))
709 r
= wxHexToDec(labelColourHex
.Mid(0, 2));
710 g
= wxHexToDec(labelColourHex
.Mid(2, 2));
711 b
= wxHexToDec(labelColourHex
.Mid(4, 2));
712 dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
714 if (buttonColourHex
!= wxT(""))
719 r
= wxHexToDec(buttonColourHex
.Mid(0, 2));
720 g
= wxHexToDec(buttonColourHex
.Mid(2, 2));
721 b
= wxHexToDec(buttonColourHex
.Mid(4, 2));
722 dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
726 dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
));
727 else if (buttonFontExpr
)
728 dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
));
729 else if (labelFontExpr
)
730 dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
));
732 // Now parse all controls
733 wxExpr
*controlExpr
= expr
->GetFirst();
736 if (controlExpr
->Number() == 3)
738 wxString
controlKeyword(controlExpr
->Nth(1)->StringValue());
739 if (controlKeyword
!= wxT("") && controlKeyword
== wxT("control"))
741 // The value part: always a list.
742 wxExpr
*listExpr
= controlExpr
->Nth(2);
743 if (listExpr
->Type() == PrologList
)
745 wxItemResource
*controlItem
= wxResourceInterpretControl(table
, listExpr
);
748 dialogItem
->GetChildren().Append(controlItem
);
753 controlExpr
= controlExpr
->GetNext();
758 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
)
760 wxItemResource
*controlItem
= new wxItemResource
;
762 // First, find the standard features of a control definition:
763 // [optional integer/string id], control name, title, style, name, x, y, width, height
765 wxString controlType
;
770 long windowStyle
= 0;
771 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
774 wxExpr
*expr1
= expr
->Nth(0);
776 if ( expr1
->Type() == PrologString
|| expr1
->Type() == PrologWord
)
778 if ( wxIsValidControlClass(expr1
->StringValue()) )
781 controlType
= expr1
->StringValue();
785 wxString
str(expr1
->StringValue());
786 id
= wxResourceGetIdentifier(str
, &table
);
789 wxLogWarning(_("Could not resolve control class or id '%s'. "
790 "Use (non-zero) integer instead\n or provide #define "
791 "(see manual for caveats)"),
792 (const wxChar
*) expr1
->StringValue());
794 return (wxItemResource
*) NULL
;
798 // Success - we have an id, so the 2nd element must be the control class.
799 controlType
= expr
->Nth(1)->StringValue();
804 else if (expr1
->Type() == PrologInteger
)
806 id
= (int)expr1
->IntegerValue();
807 // Success - we have an id, so the 2nd element must be the control class.
808 controlType
= expr
->Nth(1)->StringValue();
812 expr1
= expr
->Nth(count
);
815 title
= expr1
->StringValue();
817 expr1
= expr
->Nth(count
);
821 style
= expr1
->StringValue();
822 windowStyle
= wxParseWindowStyle(style
);
825 expr1
= expr
->Nth(count
);
828 name
= expr1
->StringValue();
830 expr1
= expr
->Nth(count
);
833 x
= (int)expr1
->IntegerValue();
835 expr1
= expr
->Nth(count
);
838 y
= (int)expr1
->IntegerValue();
840 expr1
= expr
->Nth(count
);
843 width
= (int)expr1
->IntegerValue();
845 expr1
= expr
->Nth(count
);
848 height
= (int)expr1
->IntegerValue();
850 controlItem
->SetStyle(windowStyle
);
851 controlItem
->SetName(name
);
852 controlItem
->SetTitle(title
);
853 controlItem
->SetSize(x
, y
, width
, height
);
854 controlItem
->SetType(controlType
);
855 controlItem
->SetId(id
);
857 if (controlType
== wxT("wxButton"))
859 // Check for bitmap resource name (in case loading old-style resource file)
860 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
862 wxString
str(expr
->Nth(count
)->StringValue());
867 controlItem
->SetValue4(str
);
868 controlItem
->SetType(wxT("wxBitmapButton"));
871 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
872 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
874 else if (controlType
== wxT("wxBitmapButton"))
876 // Check for bitmap resource name
877 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
879 wxString
str(expr
->Nth(count
)->StringValue());
880 controlItem
->SetValue4(str
);
882 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
883 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
886 else if (controlType
== wxT("wxCheckBox"))
888 // Check for default value
889 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
891 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
893 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
894 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
898 else if (controlType
== wxT("wxRadioButton"))
900 // Check for default value
901 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
903 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
905 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
906 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
910 else if (controlType
== wxT("wxText") || controlType
== wxT("wxTextCtrl") || controlType
== wxT("wxMultiText"))
912 // Check for default value
913 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
915 wxString
str(expr
->Nth(count
)->StringValue());
916 controlItem
->SetValue4(str
);
919 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
921 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
922 // Skip past the obsolete label font spec if there are two consecutive specs
923 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
925 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
929 else if (controlType
== wxT("wxMessage") || controlType
== wxT("wxStaticText"))
931 // Check for bitmap resource name (in case it's an old-style .wxr file)
932 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
934 wxString
str(expr
->Nth(count
)->StringValue());
935 controlItem
->SetValue4(str
);
937 controlItem
->SetType(wxT("wxStaticText"));
939 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
940 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
942 else if (controlType
== wxT("wxStaticBitmap"))
944 // Check for bitmap resource name
945 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
947 wxString
str(expr
->Nth(count
)->StringValue());
948 controlItem
->SetValue4(str
);
951 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
952 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
954 else if (controlType
== wxT("wxGroupBox") || controlType
== wxT("wxStaticBox"))
956 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
957 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
959 else if (controlType
== wxT("wxGauge"))
961 // Check for default value
962 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
964 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
968 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
970 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
973 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
975 // Skip past the obsolete label font spec if there are two consecutive specs
976 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
978 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
983 else if (controlType
== wxT("wxSlider"))
985 // Check for default value
986 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
988 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
992 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
994 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
998 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1000 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1003 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1005 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1009 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1010 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1016 else if (controlType
== wxT("wxScrollBar"))
1019 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1021 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1025 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1027 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1031 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1033 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1037 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1038 controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue());
1043 else if (controlType
== wxT("wxListBox"))
1045 wxExpr
*valueList
= (wxExpr
*) NULL
;
1047 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1049 wxStringList stringList
;
1050 wxExpr
*stringExpr
= valueList
->GetFirst();
1053 stringList
.Add(stringExpr
->StringValue());
1054 stringExpr
= stringExpr
->GetNext();
1056 controlItem
->SetStringValues(stringList
);
1058 // This is now obsolete: it's in the window style.
1059 // Check for wxSINGLE/wxMULTIPLE
1060 wxExpr
*mult
= (wxExpr
*) NULL
;
1062 controlItem->SetValue1(wxLB_SINGLE);
1064 if ((mult
= expr
->Nth(count
)) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
)))
1067 wxString m(mult->StringValue());
1068 if (m == "wxLB_MULTIPLE")
1069 controlItem->SetValue1(wxLB_MULTIPLE);
1070 else if (m == "wxLB_EXTENDED")
1071 controlItem->SetValue1(wxLB_EXTENDED);
1076 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1078 // Skip past the obsolete label font spec if there are two consecutive specs
1079 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1081 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1085 else if (controlType
== wxT("wxChoice"))
1087 wxExpr
*valueList
= (wxExpr
*) NULL
;
1088 // Check for default value list
1089 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1091 wxStringList stringList
;
1092 wxExpr
*stringExpr
= valueList
->GetFirst();
1095 stringList
.Add(stringExpr
->StringValue());
1096 stringExpr
= stringExpr
->GetNext();
1098 controlItem
->SetStringValues(stringList
);
1102 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1104 // Skip past the obsolete label font spec if there are two consecutive specs
1105 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1107 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1112 else if (controlType
== wxT("wxComboBox"))
1114 wxExpr
*textValue
= expr
->Nth(count
);
1115 if (textValue
&& (textValue
->Type() == PrologString
|| textValue
->Type() == PrologWord
))
1117 wxString
str(textValue
->StringValue());
1118 controlItem
->SetValue4(str
);
1122 wxExpr
*valueList
= (wxExpr
*) NULL
;
1123 // Check for default value list
1124 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1126 wxStringList stringList
;
1127 wxExpr
*stringExpr
= valueList
->GetFirst();
1130 stringList
.Add(stringExpr
->StringValue());
1131 stringExpr
= stringExpr
->GetNext();
1133 controlItem
->SetStringValues(stringList
);
1137 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1139 // Skip past the obsolete label font spec if there are two consecutive specs
1140 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1142 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1149 else if (controlType
== wxT("wxRadioBox"))
1151 wxExpr
*valueList
= (wxExpr
*) NULL
;
1152 // Check for default value list
1153 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1155 wxStringList stringList
;
1156 wxExpr
*stringExpr
= valueList
->GetFirst();
1159 stringList
.Add(stringExpr
->StringValue());
1160 stringExpr
= stringExpr
->GetNext();
1162 controlItem
->SetStringValues(stringList
);
1165 // majorDim (number of rows or cols)
1166 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1168 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1172 controlItem
->SetValue1(0);
1174 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1176 // Skip past the obsolete label font spec if there are two consecutive specs
1177 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1179 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1187 return (wxItemResource
*) NULL
;
1192 // Forward declaration
1193 wxItemResource
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr
*expr
);
1196 * Interpet a menu item
1199 wxItemResource
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr
*expr
)
1201 wxItemResource
*item
= new wxItemResource
;
1203 wxExpr
*labelExpr
= expr
->Nth(0);
1204 wxExpr
*idExpr
= expr
->Nth(1);
1205 wxExpr
*helpExpr
= expr
->Nth(2);
1206 wxExpr
*checkableExpr
= expr
->Nth(3);
1208 // Further keywords/attributes to follow sometime...
1209 if (expr
->Number() == 0)
1211 // item->SetType(wxRESOURCE_TYPE_SEPARATOR);
1212 item
->SetType(wxT("wxMenuSeparator"));
1217 // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
1218 item
->SetType(wxT("wxMenu")); // Well, menu item, but doesn't matter.
1221 wxString
str(labelExpr
->StringValue());
1222 item
->SetTitle(str
);
1227 // If a string or word, must look up in identifier table.
1228 if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
))
1230 wxString
str(idExpr
->StringValue());
1231 id
= wxResourceGetIdentifier(str
, &table
);
1234 wxLogWarning(_("Could not resolve menu id '%s'. "
1235 "Use (non-zero) integer instead\n"
1236 "or provide #define (see manual for caveats)"),
1237 (const wxChar
*) idExpr
->StringValue());
1240 else if (idExpr
->Type() == PrologInteger
)
1241 id
= (int)idExpr
->IntegerValue();
1242 item
->SetValue1(id
);
1246 wxString
str(helpExpr
->StringValue());
1247 item
->SetValue4(str
);
1250 item
->SetValue2(checkableExpr
->IntegerValue());
1252 // Find the first expression that's a list, for submenu
1253 wxExpr
*subMenuExpr
= expr
->GetFirst();
1254 while (subMenuExpr
&& (subMenuExpr
->Type() != PrologList
))
1255 subMenuExpr
= subMenuExpr
->GetNext();
1259 wxItemResource
*child
= wxResourceInterpretMenuItem(table
, subMenuExpr
);
1260 item
->GetChildren().Append(child
);
1261 subMenuExpr
= subMenuExpr
->GetNext();
1268 * Interpret a nested list as a menu
1271 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
1273 wxItemResource *menu = new wxItemResource;
1274 // menu->SetType(wxTYPE_MENU);
1275 menu->SetType("wxMenu");
1276 wxExpr *element = expr->GetFirst();
1279 wxItemResource *item = wxResourceInterpretMenuItem(table, element);
1281 menu->GetChildren().Append(item);
1282 element = element->GetNext();
1288 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
)
1290 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1291 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1293 return (wxItemResource
*) NULL
;
1295 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1298 return (wxItemResource
*) NULL
;
1301 if (expr
->GetAttributeValue(wxT("name"), name
))
1303 menuResource
->SetName(name
);
1306 return menuResource
;
1309 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
)
1311 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1312 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1314 return (wxItemResource
*) NULL
;
1316 wxItemResource
*resource
= new wxItemResource
;
1317 resource
->SetType(wxT("wxMenu"));
1318 // resource->SetType(wxTYPE_MENU);
1320 wxExpr
*element
= listExpr
->GetFirst();
1323 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1324 resource
->GetChildren().Append(menuResource
);
1325 element
= element
->GetNext();
1329 if (expr
->GetAttributeValue(wxT("name"), name
))
1331 resource
->SetName(name
);
1337 wxItemResource
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr
*WXUNUSED(expr
))
1339 return (wxItemResource
*) NULL
;
1342 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr
*expr
)
1344 wxItemResource
*bitmapItem
= new wxItemResource
;
1345 // bitmapItem->SetType(wxTYPE_BITMAP);
1346 bitmapItem
->SetType(wxT("wxBitmap"));
1348 if (expr
->GetAttributeValue(wxT("name"), name
))
1350 bitmapItem
->SetName(name
);
1352 // Now parse all bitmap specifications
1353 wxExpr
*bitmapExpr
= expr
->GetFirst();
1356 if (bitmapExpr
->Number() == 3)
1358 wxString
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue());
1359 if (bitmapKeyword
== wxT("bitmap") || bitmapKeyword
== wxT("icon"))
1361 // The value part: always a list.
1362 wxExpr
*listExpr
= bitmapExpr
->Nth(2);
1363 if (listExpr
->Type() == PrologList
)
1365 wxItemResource
*bitmapSpec
= new wxItemResource
;
1366 // bitmapSpec->SetType(wxTYPE_BITMAP);
1367 bitmapSpec
->SetType(wxT("wxBitmap"));
1369 // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
1370 // where everything after 'filename' is optional.
1371 wxExpr
*nameExpr
= listExpr
->Nth(0);
1372 wxExpr
*typeExpr
= listExpr
->Nth(1);
1373 wxExpr
*platformExpr
= listExpr
->Nth(2);
1374 wxExpr
*coloursExpr
= listExpr
->Nth(3);
1375 wxExpr
*xresExpr
= listExpr
->Nth(4);
1376 wxExpr
*yresExpr
= listExpr
->Nth(5);
1377 if (nameExpr
&& nameExpr
->StringValue() != wxT(""))
1379 bitmapSpec
->SetName(nameExpr
->StringValue());
1381 if (typeExpr
&& typeExpr
->StringValue() != wxT(""))
1383 bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue()));
1386 bitmapSpec
->SetValue1(0);
1388 if (platformExpr
&& platformExpr
->StringValue() != wxT(""))
1390 wxString
plat(platformExpr
->StringValue());
1391 if (plat
== wxT("windows") || plat
== wxT("WINDOWS"))
1392 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
);
1393 else if (plat
== wxT("x") || plat
== wxT("X"))
1394 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
);
1395 else if (plat
== wxT("mac") || plat
== wxT("MAC"))
1396 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
);
1398 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1401 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1404 bitmapSpec
->SetValue3(coloursExpr
->IntegerValue());
1408 xres
= (int)xresExpr
->IntegerValue();
1410 yres
= (int)yresExpr
->IntegerValue();
1411 bitmapSpec
->SetSize(0, 0, xres
, yres
);
1413 bitmapItem
->GetChildren().Append(bitmapSpec
);
1417 bitmapExpr
= bitmapExpr
->GetNext();
1423 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
)
1425 wxItemResource
*item
= wxResourceInterpretBitmap(table
, expr
);
1428 // item->SetType(wxTYPE_ICON);
1429 item
->SetType(wxT("wxIcon"));
1433 return (wxItemResource
*) NULL
;
1436 // Interpret list expression as a font
1437 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
)
1439 if (expr
->Type() != PrologList
)
1443 int family
= wxSWISS
;
1444 int style
= wxNORMAL
;
1445 int weight
= wxNORMAL
;
1447 wxString
faceName(wxT(""));
1449 wxExpr
*pointExpr
= expr
->Nth(0);
1450 wxExpr
*familyExpr
= expr
->Nth(1);
1451 wxExpr
*styleExpr
= expr
->Nth(2);
1452 wxExpr
*weightExpr
= expr
->Nth(3);
1453 wxExpr
*underlineExpr
= expr
->Nth(4);
1454 wxExpr
*faceNameExpr
= expr
->Nth(5);
1456 point
= (int)pointExpr
->IntegerValue();
1461 str
= familyExpr
->StringValue();
1462 family
= (int)wxParseWindowStyle(str
);
1466 str
= styleExpr
->StringValue();
1467 style
= (int)wxParseWindowStyle(str
);
1471 str
= weightExpr
->StringValue();
1472 weight
= (int)wxParseWindowStyle(str
);
1475 underline
= (int)underlineExpr
->IntegerValue();
1477 faceName
= faceNameExpr
->StringValue();
1479 wxFont
font(point
, family
, style
, weight
, (underline
!= 0), faceName
);
1483 // Separate file for the remainder of this, for BC++/Win16
1485 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
1487 * (Re)allocate buffer for reading in from resource file
1490 bool wxReallocateResourceBuffer()
1492 if (!wxResourceBuffer
)
1494 wxResourceBufferSize
= 1000;
1495 wxResourceBuffer
= new char[wxResourceBufferSize
];
1498 if (wxResourceBuffer
)
1500 long newSize
= wxResourceBufferSize
+ 1000;
1501 char *tmp
= new char[(int)newSize
];
1502 strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
);
1503 delete[] wxResourceBuffer
;
1504 wxResourceBuffer
= tmp
;
1505 wxResourceBufferSize
= newSize
;
1510 static bool wxEatWhiteSpace(FILE *fd
)
1514 while ((ch
= getc(fd
)) != EOF
)
1529 ungetc(prev_ch
, fd
);
1537 while ((ch
= getc(fd
)) != EOF
)
1539 if (ch
== '/' && prev_ch
== '*')
1547 static char buffer
[255];
1548 fgets(buffer
, 255, fd
);
1552 ungetc(prev_ch
, fd
);
1566 static bool wxEatWhiteSpace(wxInputStream
*is
)
1568 int ch
= is
->GetC() ;
1569 if ((ch
!= ' ') && (ch
!= '/') && (ch
!= ' ') && (ch
!= 10) && (ch
!= 13) && (ch
!= 9))
1576 while (ch
== ' ' || ch
== 10 || ch
== 13 || ch
== 9)
1578 // Check for comment
1584 bool finished
= FALSE
;
1592 int newCh
= is
->GetC();
1607 return wxEatWhiteSpace(is
);
1610 bool wxGetResourceToken(FILE *fd
)
1612 if (!wxResourceBuffer
)
1613 wxReallocateResourceBuffer();
1614 wxResourceBuffer
[0] = 0;
1615 wxEatWhiteSpace(fd
);
1621 wxResourceBufferCount
= 0;
1628 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1631 // Escaped characters
1632 else if (ch
== '\\')
1634 int newCh
= getc(fd
);
1637 else if (newCh
== 10)
1645 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1646 wxReallocateResourceBuffer();
1647 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1648 wxResourceBufferCount
++;
1651 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1655 wxResourceBufferCount
= 0;
1657 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1659 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1660 wxReallocateResourceBuffer();
1661 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1662 wxResourceBufferCount
++;
1666 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1673 bool wxGetResourceToken(wxInputStream
*is
)
1675 if (!wxResourceBuffer
)
1676 wxReallocateResourceBuffer();
1677 wxResourceBuffer
[0] = 0;
1678 wxEatWhiteSpace(is
);
1680 int ch
= is
->GetC() ;
1684 wxResourceBufferCount
= 0;
1691 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1694 // Escaped characters
1695 else if (ch
== '\\')
1697 int newCh
= is
->GetC();
1700 else if (newCh
== 10)
1702 else if (newCh
== 13) // mac
1710 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1711 wxReallocateResourceBuffer();
1712 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1713 wxResourceBufferCount
++;
1716 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1720 wxResourceBufferCount
= 0;
1722 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1724 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1725 wxReallocateResourceBuffer();
1726 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1727 wxResourceBufferCount
++;
1731 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1739 * Files are in form:
1740 static char *name = "....";
1741 with possible comments.
1744 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1747 table
= wxDefaultResourceTable
;
1749 // static or #define
1750 if (!wxGetResourceToken(fd
))
1756 if (strcmp(wxResourceBuffer
, "#define") == 0)
1758 wxGetResourceToken(fd
);
1759 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1760 wxGetResourceToken(fd
);
1761 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1762 if (wxIsdigit(value
[0]))
1764 int val
= (int)wxAtol(value
);
1765 wxResourceAddIdentifier(name
, val
, table
);
1769 wxLogWarning(_("#define %s must be an integer."), name
);
1779 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1781 wxGetResourceToken(fd
);
1782 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1783 wxChar
*actualName
= name
;
1784 if (name
[0] == wxT('"'))
1785 actualName
= name
+ 1;
1786 int len
= wxStrlen(name
);
1787 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1789 if (!wxResourceParseIncludeFile(actualName
, table
))
1791 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1796 else if (strcmp(wxResourceBuffer
, "static") != 0)
1799 wxStrcpy(buf
, _("Found "));
1800 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
1801 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1807 if (!wxGetResourceToken(fd
))
1809 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1814 if (strcmp(wxResourceBuffer
, "char") != 0)
1816 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1821 if (!wxGetResourceToken(fd
))
1823 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1828 if (wxResourceBuffer
[0] != '*')
1830 wxLogWarning(_("Expected '*' whilst parsing resource."));
1833 wxChar nameBuf
[100];
1834 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
1838 if (!wxGetResourceToken(fd
))
1840 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1845 if (strcmp(wxResourceBuffer
, "=") != 0)
1847 wxLogWarning(_("Expected '=' whilst parsing resource."));
1852 if (!wxGetResourceToken(fd
))
1854 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1860 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1862 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1867 if (!wxGetResourceToken(fd
))
1874 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1877 table
= wxDefaultResourceTable
;
1879 // static or #define
1880 if (!wxGetResourceToken(fd
))
1886 if (strcmp(wxResourceBuffer
, "#define") == 0)
1888 wxGetResourceToken(fd
);
1889 char *name
= copystring(wxResourceBuffer
);
1890 wxGetResourceToken(fd
);
1891 char *value
= copystring(wxResourceBuffer
);
1892 if (isalpha(value
[0]))
1894 int val
= (int)atol(value
);
1895 wxResourceAddIdentifier(name
, val
, table
);
1899 wxLogWarning(_("#define %s must be an integer."), name
);
1909 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1911 wxGetResourceToken(fd
);
1912 char *name
= copystring(wxResourceBuffer
);
1913 char *actualName
= name
;
1915 actualName
= name
+ 1;
1916 int len
= strlen(name
);
1917 if ((len
> 0) && (name
[len
-1] == '"'))
1919 if (!wxResourceParseIncludeFile(actualName
, table
))
1921 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1926 else if (strcmp(wxResourceBuffer
, "static") != 0)
1929 strcpy(buf
, _("Found "));
1930 strncat(buf
, wxResourceBuffer
, 30);
1931 strcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1937 if (!wxGetResourceToken(fd
))
1939 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1944 if (strcmp(wxResourceBuffer
, "char") != 0)
1946 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1951 if (!wxGetResourceToken(fd
))
1953 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1958 if (wxResourceBuffer
[0] != '*')
1960 wxLogWarning(_("Expected '*' whilst parsing resource."));
1964 strncpy(nameBuf
, wxResourceBuffer
+1, 99);
1967 if (!wxGetResourceToken(fd
))
1969 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1974 if (strcmp(wxResourceBuffer
, "=") != 0)
1976 wxLogWarning(_("Expected '=' whilst parsing resource."));
1981 if (!wxGetResourceToken(fd
))
1983 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1989 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1991 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1996 if (!wxGetResourceToken(fd
))
2004 * Parses string window style into integer window style
2008 * Style flag parsing, e.g.
2009 * "wxSYSTEM_MENU | wxBORDER" -> integer
2012 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
)
2015 return (wxChar
*) NULL
;
2017 static wxChar buf
[150];
2018 int len
= wxStrlen(s
);
2021 while ((ii
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == wxT('_'))))
2029 // Eat whitespace and conjunction characters
2030 while ((ii
< len
) &&
2031 ((s
[ii
] == wxT(' ')) || (s
[ii
] == wxT('|')) || (s
[ii
] == wxT(','))))
2037 return (wxChar
*) NULL
;
2042 struct wxResourceBitListStruct
2048 static wxResourceBitListStruct wxResourceBitListTable
[] =
2051 { wxT("wxSINGLE"), wxLB_SINGLE
},
2052 { wxT("wxMULTIPLE"), wxLB_MULTIPLE
},
2053 { wxT("wxEXTENDED"), wxLB_EXTENDED
},
2054 { wxT("wxLB_SINGLE"), wxLB_SINGLE
},
2055 { wxT("wxLB_MULTIPLE"), wxLB_MULTIPLE
},
2056 { wxT("wxLB_EXTENDED"), wxLB_EXTENDED
},
2057 { wxT("wxLB_NEEDED_SB"), wxLB_NEEDED_SB
},
2058 { wxT("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB
},
2059 { wxT("wxLB_SORT"), wxLB_SORT
},
2060 { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW
},
2061 { wxT("wxLB_HSCROLL"), wxLB_HSCROLL
},
2064 { wxT("wxCB_SIMPLE"), wxCB_SIMPLE
},
2065 { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN
},
2066 { wxT("wxCB_READONLY"), wxCB_READONLY
},
2067 { wxT("wxCB_SORT"), wxCB_SORT
},
2070 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR
},
2071 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL
},
2072 { wxT("wxGA_VERTICAL"), wxGA_VERTICAL
},
2075 { wxT("wxPASSWORD"), wxPASSWORD
},
2076 { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER
},
2077 { wxT("wxTE_PASSWORD"), wxTE_PASSWORD
},
2078 { wxT("wxTE_READONLY"), wxTE_READONLY
},
2079 { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
},
2080 { wxT("wxTE_MULTILINE"), wxTE_MULTILINE
},
2081 { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL
},
2083 /* wxRadioBox/wxRadioButton */
2084 { wxT("wxRB_GROUP"), wxRB_GROUP
},
2085 { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS
},
2086 { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS
},
2087 { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL
},
2088 { wxT("wxRA_VERTICAL"), wxRA_VERTICAL
},
2091 { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL
},
2092 { wxT("wxSL_VERTICAL"), wxSL_VERTICAL
},
2093 { wxT("wxSL_AUTOTICKS"), wxSL_AUTOTICKS
},
2094 { wxT("wxSL_LABELS"), wxSL_LABELS
},
2095 { wxT("wxSL_LEFT"), wxSL_LEFT
},
2096 { wxT("wxSL_TOP"), wxSL_TOP
},
2097 { wxT("wxSL_RIGHT"), wxSL_RIGHT
},
2098 { wxT("wxSL_BOTTOM"), wxSL_BOTTOM
},
2099 { wxT("wxSL_BOTH"), wxSL_BOTH
},
2100 { wxT("wxSL_SELRANGE"), wxSL_SELRANGE
},
2103 { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL
},
2104 { wxT("wxSB_VERTICAL"), wxSB_VERTICAL
},
2107 { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW
},
2108 { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW
},
2111 { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS
},
2112 { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS
},
2113 { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT
},
2116 { wxT("wxLC_ICON"), wxLC_ICON
},
2117 { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON
},
2118 { wxT("wxLC_LIST"), wxLC_LIST
},
2119 { wxT("wxLC_REPORT"), wxLC_REPORT
},
2120 { wxT("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP
},
2121 { wxT("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT
},
2122 { wxT("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE
},
2123 { wxT("wxLC_USER_TEXT"), wxLC_USER_TEXT
},
2124 { wxT("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS
},
2125 { wxT("wxLC_NO_HEADER"), wxLC_NO_HEADER
},
2126 { wxT("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER
},
2127 { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL
},
2128 { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING
},
2129 { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING
},
2132 { wxT("wxSP_VERTICAL"), wxSP_VERTICAL
},
2133 { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
},
2134 { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
},
2135 { wxT("wxSP_WRAP"), wxSP_WRAP
},
2138 { wxT("wxSP_NOBORDER"), wxSP_NOBORDER
},
2139 { wxT("wxSP_3D"), wxSP_3D
},
2140 { wxT("wxSP_BORDER"), wxSP_BORDER
},
2143 { wxT("wxTC_MULTILINE"), wxTC_MULTILINE
},
2144 { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
},
2145 { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
},
2146 { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
},
2149 { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP
},
2152 { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH
},
2153 { wxT("wxALIGN_LEFT"), wxALIGN_LEFT
},
2154 { wxT("wxALIGN_CENTER"), wxALIGN_CENTER
},
2155 { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE
},
2156 { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT
},
2157 { wxT("wxCOLOURED"), wxCOLOURED
},
2160 { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
},
2161 { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
},
2162 { wxT("wxTB_VERTICAL"), wxTB_VERTICAL
},
2163 { wxT("wxTB_FLAT"), wxTB_FLAT
},
2166 { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL
},
2169 { wxT("wxVSCROLL"), wxVSCROLL
},
2170 { wxT("wxHSCROLL"), wxHSCROLL
},
2171 { wxT("wxCAPTION"), wxCAPTION
},
2172 { wxT("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
},
2173 { wxT("wxICONIZE"), wxICONIZE
},
2174 { wxT("wxMINIMIZE"), wxICONIZE
},
2175 { wxT("wxMAXIMIZE"), wxMAXIMIZE
},
2177 { wxT("wxMDI_PARENT"), 0},
2178 { wxT("wxMDI_CHILD"), 0},
2179 { wxT("wxTHICK_FRAME"), wxTHICK_FRAME
},
2180 { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER
},
2181 { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU
},
2182 { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
},
2183 { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
},
2184 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX
},
2185 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
},
2186 { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
},
2187 { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
},
2188 { wxT("wxBORDER"), wxBORDER
},
2189 { wxT("wxRETAINED"), wxRETAINED
},
2190 { wxT("wxNATIVE_IMPL"), 0},
2191 { wxT("wxEXTENDED_IMPL"), 0},
2192 { wxT("wxBACKINGSTORE"), wxBACKINGSTORE
},
2193 // { wxT("wxFLAT"), wxFLAT},
2194 // { wxT("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
2195 { wxT("wxFIXED_LENGTH"), 0},
2196 { wxT("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
},
2197 { wxT("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
},
2198 { wxT("wxRAISED_BORDER"), wxRAISED_BORDER
},
2199 { wxT("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
},
2200 { wxT("wxSTATIC_BORDER"), wxSTATIC_BORDER
},
2201 { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
},
2202 { wxT("wxNO_BORDER"), wxNO_BORDER
},
2203 { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
},
2204 { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
2206 { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
},
2207 { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
},
2209 // Text font families
2210 { wxT("wxDEFAULT"), wxDEFAULT
},
2211 { wxT("wxDECORATIVE"), wxDECORATIVE
},
2212 { wxT("wxROMAN"), wxROMAN
},
2213 { wxT("wxSCRIPT"), wxSCRIPT
},
2214 { wxT("wxSWISS"), wxSWISS
},
2215 { wxT("wxMODERN"), wxMODERN
},
2216 { wxT("wxTELETYPE"), wxTELETYPE
},
2217 { wxT("wxVARIABLE"), wxVARIABLE
},
2218 { wxT("wxFIXED"), wxFIXED
},
2219 { wxT("wxNORMAL"), wxNORMAL
},
2220 { wxT("wxLIGHT"), wxLIGHT
},
2221 { wxT("wxBOLD"), wxBOLD
},
2222 { wxT("wxITALIC"), wxITALIC
},
2223 { wxT("wxSLANT"), wxSLANT
},
2224 { wxT("wxSOLID"), wxSOLID
},
2225 { wxT("wxDOT"), wxDOT
},
2226 { wxT("wxLONG_DASH"), wxLONG_DASH
},
2227 { wxT("wxSHORT_DASH"), wxSHORT_DASH
},
2228 { wxT("wxDOT_DASH"), wxDOT_DASH
},
2229 { wxT("wxUSER_DASH"), wxUSER_DASH
},
2230 { wxT("wxTRANSPARENT"), wxTRANSPARENT
},
2231 { wxT("wxSTIPPLE"), wxSTIPPLE
},
2232 { wxT("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
},
2233 { wxT("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
},
2234 { wxT("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
},
2235 { wxT("wxCROSS_HATCH"), wxCROSS_HATCH
},
2236 { wxT("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
},
2237 { wxT("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
},
2238 { wxT("wxJOIN_BEVEL"), wxJOIN_BEVEL
},
2239 { wxT("wxJOIN_MITER"), wxJOIN_MITER
},
2240 { wxT("wxJOIN_ROUND"), wxJOIN_ROUND
},
2241 { wxT("wxCAP_ROUND"), wxCAP_ROUND
},
2242 { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING
},
2243 { wxT("wxCAP_BUTT"), wxCAP_BUTT
},
2246 { wxT("wxCLEAR"), wxCLEAR
},
2247 { wxT("wxXOR"), wxXOR
},
2248 { wxT("wxINVERT"), wxINVERT
},
2249 { wxT("wxOR_REVERSE"), wxOR_REVERSE
},
2250 { wxT("wxAND_REVERSE"), wxAND_REVERSE
},
2251 { wxT("wxCOPY"), wxCOPY
},
2252 { wxT("wxAND"), wxAND
},
2253 { wxT("wxAND_INVERT"), wxAND_INVERT
},
2254 { wxT("wxNO_OP"), wxNO_OP
},
2255 { wxT("wxNOR"), wxNOR
},
2256 { wxT("wxEQUIV"), wxEQUIV
},
2257 { wxT("wxSRC_INVERT"), wxSRC_INVERT
},
2258 { wxT("wxOR_INVERT"), wxOR_INVERT
},
2259 { wxT("wxNAND"), wxNAND
},
2260 { wxT("wxOR"), wxOR
},
2261 { wxT("wxSET"), wxSET
},
2263 { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
},
2264 { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER
},
2265 { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE
},
2266 { wxT("wxWINDING_RULE"), wxWINDING_RULE
},
2267 { wxT("wxHORIZONTAL"), wxHORIZONTAL
},
2268 { wxT("wxVERTICAL"), wxVERTICAL
},
2269 { wxT("wxBOTH"), wxBOTH
},
2270 { wxT("wxCENTER_FRAME"), wxCENTER_FRAME
},
2271 { wxT("wxOK"), wxOK
},
2272 { wxT("wxYES_NO"), wxYES_NO
},
2273 { wxT("wxCANCEL"), wxCANCEL
},
2274 { wxT("wxYES"), wxYES
},
2275 { wxT("wxNO"), wxNO
},
2276 { wxT("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
},
2277 { wxT("wxICON_HAND"), wxICON_HAND
},
2278 { wxT("wxICON_QUESTION"), wxICON_QUESTION
},
2279 { wxT("wxICON_INFORMATION"), wxICON_INFORMATION
},
2280 { wxT("wxICON_STOP"), wxICON_STOP
},
2281 { wxT("wxICON_ASTERISK"), wxICON_ASTERISK
},
2282 { wxT("wxICON_MASK"), wxICON_MASK
},
2283 { wxT("wxCENTRE"), wxCENTRE
},
2284 { wxT("wxCENTER"), wxCENTRE
},
2285 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS
},
2286 { wxT("wxVERTICAL_LABEL"), 0},
2287 { wxT("wxHORIZONTAL_LABEL"), 0},
2289 // Bitmap types (not strictly styles)
2290 { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
},
2291 { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
},
2292 { wxT("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
},
2293 { wxT("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2294 { wxT("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2295 { wxT("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
},
2296 { wxT("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
},
2297 { wxT("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
},
2298 { wxT("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
},
2299 { wxT("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
},
2300 { wxT("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
},
2301 { wxT("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
},
2302 { wxT("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
},
2303 { wxT("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
}
2306 static int wxResourceBitListCount
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
));
2308 long wxParseWindowStyle(const wxString
& bitListString
)
2313 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2314 while (word
!= NULL
)
2318 for (j
= 0; j
< wxResourceBitListCount
; j
++)
2319 if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0)
2321 bitList
|= wxResourceBitListTable
[j
].bits
;
2327 wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
);
2330 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2336 * Load a bitmap from a wxWindows resource, choosing an optimum
2337 * depth and appropriate type.
2340 wxBitmap
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable
*table
)
2343 table
= wxDefaultResourceTable
;
2345 wxItemResource
*item
= table
->FindResource(resource
);
2348 if ((item
->GetType() == wxT("")) || (item
->GetType() != wxT("wxBitmap")))
2350 wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
);
2351 return wxNullBitmap
;
2353 int thisDepth
= wxDisplayDepth();
2354 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2356 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2358 // Try to find optimum bitmap for this platform/colour depth
2359 wxNode
*node
= item
->GetChildren().First();
2362 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2363 int platform
= (int)child
->GetValue2();
2364 int noColours
= (int)child
->GetValue3();
2366 char *name = child->GetName();
2367 int bitmapType = (int)child->GetValue1();
2368 int xRes = child->GetWidth();
2369 int yRes = child->GetHeight();
2374 case RESOURCE_PLATFORM_ANY
:
2376 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2377 optResource
= child
;
2380 // Maximise the number of colours.
2381 // If noColours is zero (unspecified), then assume this
2382 // is the right one.
2383 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2384 optResource
= child
;
2389 case RESOURCE_PLATFORM_WINDOWS
:
2391 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2392 optResource
= child
;
2395 // Maximise the number of colours
2396 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2397 optResource
= child
;
2403 case RESOURCE_PLATFORM_X
:
2405 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2406 optResource
= child
;
2409 // Maximise the number of colours
2410 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2411 optResource
= child
;
2417 case RESOURCE_PLATFORM_MAC
:
2419 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2420 optResource
= child
;
2423 // Maximise the number of colours
2424 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2425 optResource
= child
;
2433 node
= node
->Next();
2435 // If no matching resource, fail.
2437 return wxNullBitmap
;
2439 wxString name
= optResource
->GetName();
2440 int bitmapType
= (int)optResource
->GetValue1();
2443 case wxBITMAP_TYPE_XBM_DATA
:
2446 wxItemResource
*item
= table
->FindResource(name
);
2449 wxLogWarning(_("Failed to find XBM resource %s.\n"
2450 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2451 return wxNullBitmap
;
2453 return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ;
2455 wxLogWarning(_("No XBM facility available!"));
2459 case wxBITMAP_TYPE_XPM_DATA
:
2461 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2462 wxItemResource
*item
= table
->FindResource(name
);
2465 wxLogWarning(_("Failed to find XPM resource %s.\n"
2466 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2467 return wxNullBitmap
;
2469 return wxBitmap((char **)item
->GetValue1());
2471 wxLogWarning(_("No XPM facility available!"));
2477 return wxBitmap(name
, bitmapType
);
2480 return wxNullBitmap
;
2484 wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
);
2485 return wxNullBitmap
;
2490 * Load an icon from a wxWindows resource, choosing an optimum
2491 * depth and appropriate type.
2494 wxIcon
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable
*table
)
2497 table
= wxDefaultResourceTable
;
2499 wxItemResource
*item
= table
->FindResource(resource
);
2502 if ((item
->GetType() == wxT("")) || wxStrcmp(item
->GetType(), wxT("wxIcon")) != 0)
2504 wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
);
2507 int thisDepth
= wxDisplayDepth();
2508 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2510 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2512 // Try to find optimum icon for this platform/colour depth
2513 wxNode
*node
= item
->GetChildren().First();
2516 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2517 int platform
= (int)child
->GetValue2();
2518 int noColours
= (int)child
->GetValue3();
2520 char *name = child->GetName();
2521 int bitmapType = (int)child->GetValue1();
2522 int xRes = child->GetWidth();
2523 int yRes = child->GetHeight();
2528 case RESOURCE_PLATFORM_ANY
:
2530 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2531 optResource
= child
;
2534 // Maximise the number of colours.
2535 // If noColours is zero (unspecified), then assume this
2536 // is the right one.
2537 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2538 optResource
= child
;
2543 case RESOURCE_PLATFORM_WINDOWS
:
2545 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2546 optResource
= child
;
2549 // Maximise the number of colours
2550 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2551 optResource
= child
;
2557 case RESOURCE_PLATFORM_X
:
2559 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2560 optResource
= child
;
2563 // Maximise the number of colours
2564 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2565 optResource
= child
;
2571 case RESOURCE_PLATFORM_MAC
:
2573 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2574 optResource
= child
;
2577 // Maximise the number of colours
2578 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2579 optResource
= child
;
2587 node
= node
->Next();
2589 // If no matching resource, fail.
2593 wxString name
= optResource
->GetName();
2594 int bitmapType
= (int)optResource
->GetValue1();
2597 case wxBITMAP_TYPE_XBM_DATA
:
2600 wxItemResource
*item
= table
->FindResource(name
);
2603 wxLogWarning(_("Failed to find XBM resource %s.\n"
2604 "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
);
2607 return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3());
2609 wxLogWarning(_("No XBM facility available!"));
2613 case wxBITMAP_TYPE_XPM_DATA
:
2615 // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
2617 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2618 wxItemResource *item = table->FindResource(name);
2622 sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name);
2626 return wxIcon((char **)item->GetValue1());
2628 wxLogWarning(_("No XPM facility available!"));
2631 wxLogWarning(_("No XPM icon facility available!"));
2637 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2639 return wxIcon(name
, bitmapType
);
2648 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2653 wxMenu
*wxResourceCreateMenu(wxItemResource
*item
)
2655 wxMenu
*menu
= new wxMenu
;
2656 wxNode
*node
= item
->GetChildren().First();
2659 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2660 if ((child
->GetType() != wxT("")) && (child
->GetType() == wxT("wxMenuSeparator")))
2661 menu
->AppendSeparator();
2662 else if (child
->GetChildren().Number() > 0)
2664 wxMenu
*subMenu
= wxResourceCreateMenu(child
);
2666 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4());
2670 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0));
2672 node
= node
->Next();
2677 wxMenuBar
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable
*table
, wxMenuBar
*menuBar
)
2680 table
= wxDefaultResourceTable
;
2682 wxItemResource
*menuResource
= table
->FindResource(resource
);
2683 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2686 menuBar
= new wxMenuBar
;
2687 wxNode
*node
= menuResource
->GetChildren().First();
2690 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2691 wxMenu
*menu
= wxResourceCreateMenu(child
);
2693 menuBar
->Append(menu
, child
->GetTitle());
2694 node
= node
->Next();
2698 return (wxMenuBar
*) NULL
;
2701 wxMenu
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable
*table
)
2704 table
= wxDefaultResourceTable
;
2706 wxItemResource
*menuResource
= table
->FindResource(resource
);
2707 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2708 // if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
2709 return wxResourceCreateMenu(menuResource
);
2710 return (wxMenu
*) NULL
;
2713 // Global equivalents (so don't have to refer to default table explicitly)
2714 bool wxResourceParseData(const wxString
& resource
, wxResourceTable
*table
)
2717 table
= wxDefaultResourceTable
;
2719 return table
->ParseResourceData(resource
);
2722 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable
*table
)
2725 table
= wxDefaultResourceTable
;
2727 return table
->ParseResourceFile(filename
);
2730 // Register XBM/XPM data
2731 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable
*table
)
2734 table
= wxDefaultResourceTable
;
2736 return table
->RegisterResourceBitmapData(name
, bits
, width
, height
);
2739 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable
*table
)
2742 table
= wxDefaultResourceTable
;
2744 return table
->RegisterResourceBitmapData(name
, data
);
2747 void wxResourceClear(wxResourceTable
*table
)
2750 table
= wxDefaultResourceTable
;
2752 table
->ClearTable();
2759 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable
*table
)
2762 table
= wxDefaultResourceTable
;
2764 table
->identifiers
.Put(name
, (wxObject
*)(long)value
);
2768 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable
*table
)
2771 table
= wxDefaultResourceTable
;
2773 return (int)(long)table
->identifiers
.Get(name
);
2777 * Parse #include file for #defines (only)
2780 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
)
2783 table
= wxDefaultResourceTable
;
2785 FILE *fd
= fopen(f
.fn_str(), "r");
2790 while (wxGetResourceToken(fd
))
2792 if (strcmp(wxResourceBuffer
, "#define") == 0)
2794 wxGetResourceToken(fd
);
2795 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2796 wxGetResourceToken(fd
);
2797 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2798 if (wxIsdigit(value
[0]))
2800 int val
= (int)wxAtol(value
);
2801 wxResourceAddIdentifier(name
, val
, table
);
2812 * Reading strings as if they were .wxr files
2815 static int getc_string(char *s
)
2817 int ch
= s
[wxResourceStringPtr
];
2822 wxResourceStringPtr
++;
2827 static int ungetc_string()
2829 wxResourceStringPtr
--;
2833 bool wxEatWhiteSpaceString(char *s
)
2837 while ((ch
= getc_string(s
)) != EOF
)
2849 ch
= getc_string(s
);
2860 while ((ch
= getc_string(s
)) != EOF
)
2862 if (ch
== '/' && prev_ch
== '*')
2884 bool wxGetResourceTokenString(char *s
)
2886 if (!wxResourceBuffer
)
2887 wxReallocateResourceBuffer();
2888 wxResourceBuffer
[0] = 0;
2889 wxEatWhiteSpaceString(s
);
2891 int ch
= getc_string(s
);
2895 wxResourceBufferCount
= 0;
2896 ch
= getc_string(s
);
2902 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2905 // Escaped characters
2906 else if (ch
== '\\')
2908 int newCh
= getc_string(s
);
2911 else if (newCh
== 10)
2919 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2920 wxReallocateResourceBuffer();
2921 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
2922 wxResourceBufferCount
++;
2923 ch
= getc_string(s
);
2925 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2929 wxResourceBufferCount
= 0;
2931 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
2933 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2934 wxReallocateResourceBuffer();
2935 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
2936 wxResourceBufferCount
++;
2938 ch
= getc_string(s
);
2940 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2948 * Files are in form:
2949 static char *name = "....";
2950 with possible comments.
2953 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
2956 table
= wxDefaultResourceTable
;
2958 // static or #define
2959 if (!wxGetResourceTokenString(s
))
2965 if (strcmp(wxResourceBuffer
, "#define") == 0)
2967 wxGetResourceTokenString(s
);
2968 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2969 wxGetResourceTokenString(s
);
2970 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2971 if (wxIsdigit(value
[0]))
2973 int val
= (int)wxAtol(value
);
2974 wxResourceAddIdentifier(name
, val
, table
);
2978 wxLogWarning(_("#define %s must be an integer."), name
);
2989 else if (strcmp(wxResourceBuffer, "#include") == 0)
2991 wxGetResourceTokenString(s);
2992 char *name = copystring(wxResourceBuffer);
2993 char *actualName = name;
2995 actualName = name + 1;
2996 int len = strlen(name);
2997 if ((len > 0) && (name[len-1] == '"'))
2999 if (!wxResourceParseIncludeFile(actualName, table))
3002 sprintf(buf, _("Could not find resource include file %s."), actualName);
3009 else if (strcmp(wxResourceBuffer
, "static") != 0)
3012 wxStrcpy(buf
, _("Found "));
3013 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
3014 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
3020 if (!wxGetResourceTokenString(s
))
3022 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3027 if (strcmp(wxResourceBuffer
, "char") != 0)
3029 wxLogWarning(_("Expected 'char' whilst parsing resource."));
3034 if (!wxGetResourceTokenString(s
))
3036 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3041 if (wxResourceBuffer
[0] != '*')
3043 wxLogWarning(_("Expected '*' whilst parsing resource."));
3046 wxChar nameBuf
[100];
3047 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
3051 if (!wxGetResourceTokenString(s
))
3053 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3058 if (strcmp(wxResourceBuffer
, "=") != 0)
3060 wxLogWarning(_("Expected '=' whilst parsing resource."));
3065 if (!wxGetResourceTokenString(s
))
3067 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3073 if (!db
.ReadPrologFromString(wxResourceBuffer
))
3075 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
3080 if (!wxGetResourceTokenString(s
))
3087 bool wxResourceParseString(char *s
, wxResourceTable
*table
)
3090 table
= wxDefaultResourceTable
;
3095 // Turn backslashes into spaces
3098 int len
= strlen(s
);
3100 for (i
= 0; i
< len
; i
++)
3101 if (s
[i
] == 92 && s
[i
+1] == 13)
3109 wxResourceStringPtr
= 0;
3112 while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
)
3116 return wxResourceInterpretResources(*table
, db
);
3120 * resource loading facility
3123 bool wxWindowBase::LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
)
3126 table
= wxDefaultResourceTable
;
3128 wxItemResource
*resource
= table
->FindResource((const wxChar
*)resourceName
);
3129 // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
3130 if (!resource
|| (resource
->GetType() == wxT("")) ||
3131 ! ((resource
->GetType() == wxT("wxDialog")) || (resource
->GetType() == wxT("wxPanel"))))
3134 wxString
title(resource
->GetTitle());
3135 long theWindowStyle
= resource
->GetStyle();
3136 bool isModal
= (resource
->GetValue1() != 0);
3137 int x
= resource
->GetX();
3138 int y
= resource
->GetY();
3139 int width
= resource
->GetWidth();
3140 int height
= resource
->GetHeight();
3141 wxString name
= resource
->GetName();
3143 if (IsKindOf(CLASSINFO(wxDialog
)))
3145 wxDialog
*dialogBox
= (wxDialog
*)this;
3146 long modalStyle
= isModal
? wxDIALOG_MODAL
: 0;
3147 if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
))
3150 // Only reset the client size if we know we're not going to do it again below.
3151 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0)
3152 dialogBox
->SetClientSize(width
, height
);
3154 else if (IsKindOf(CLASSINFO(wxPanel
)))
3156 wxPanel
* panel
= (wxPanel
*)this;
3157 if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
| wxTAB_TRAVERSAL
, name
))
3162 if (!((wxWindow
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
))
3166 if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
3168 // No need to do this since it's done in wxPanel or wxDialog constructor.
3169 // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
3173 if (resource
->GetFont().Ok())
3174 SetFont(resource
->GetFont());
3175 if (resource
->GetBackgroundColour().Ok())
3176 SetBackgroundColour(resource
->GetBackgroundColour());
3179 // Should have some kind of font at this point
3180 if (!GetFont().Ok())
3181 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
3182 if (!GetBackgroundColour().Ok())
3183 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
3185 // Only when we've created the window and set the font can we set the correct size,
3186 // if based on dialog units.
3187 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
3189 wxSize sz
= ConvertDialogToPixels(wxSize(width
, height
));
3190 SetClientSize(sz
.x
, sz
.y
);
3192 wxPoint pt
= ConvertDialogToPixels(wxPoint(x
, y
));
3196 // Now create children
3197 wxNode
*node
= resource
->GetChildren().First();
3200 wxItemResource
*childResource
= (wxItemResource
*)node
->Data();
3202 (void) CreateItem(childResource
, resource
, table
);
3204 node
= node
->Next();
3209 wxControl
*wxWindowBase::CreateItem(const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
)
3212 table
= wxDefaultResourceTable
;
3213 return table
->CreateItem((wxWindow
*)this, resource
, parentResource
);
3217 #pragma warning(default:4706) // assignment within conditional expression
3223 #endif // wxUSE_WX_RESOURCES