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("") || 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 wxSize sz
= control
->GetSize();
548 control
->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH
|wxSIZE_AUTO_HEIGHT
);
557 * Interpret database as a series of resources
560 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
)
562 wxNode
*node
= db
.First();
565 wxExpr
*clause
= (wxExpr
*)node
->Data();
566 wxString
functor(clause
->Functor());
568 wxItemResource
*item
= (wxItemResource
*) NULL
;
569 if (functor
== wxT("dialog"))
570 item
= wxResourceInterpretDialog(table
, clause
);
571 else if (functor
== wxT("panel"))
572 item
= wxResourceInterpretDialog(table
, clause
, TRUE
);
573 else if (functor
== wxT("menubar"))
574 item
= wxResourceInterpretMenuBar(table
, clause
);
575 else if (functor
== wxT("menu"))
576 item
= wxResourceInterpretMenu(table
, clause
);
577 else if (functor
== wxT("string"))
578 item
= wxResourceInterpretString(table
, clause
);
579 else if (functor
== wxT("bitmap"))
580 item
= wxResourceInterpretBitmap(table
, clause
);
581 else if (functor
== wxT("icon"))
582 item
= wxResourceInterpretIcon(table
, clause
);
586 // Remove any existing resource of same name
587 if (item
->GetName() != wxT(""))
588 table
.DeleteResource(item
->GetName());
589 table
.AddResource(item
);
596 static const wxChar
*g_ValidControlClasses
[] =
599 wxT("wxBitmapButton"),
602 wxT("wxStaticBitmap"),
608 wxT("wxRadioButton"),
610 wxT("wxBitmapCheckBox"),
620 static bool wxIsValidControlClass(const wxString
& c
)
622 for ( size_t i
= 0; i
< WXSIZEOF(g_ValidControlClasses
); i
++ )
624 if ( c
== g_ValidControlClasses
[i
] )
630 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
)
632 wxItemResource
*dialogItem
= new wxItemResource
;
634 dialogItem
->SetType(wxT("wxPanel"));
636 dialogItem
->SetType(wxT("wxDialog"));
637 wxString style
= wxT("");
638 wxString title
= wxT("");
639 wxString name
= wxT("");
640 wxString backColourHex
= wxT("");
641 wxString labelColourHex
= wxT("");
642 wxString buttonColourHex
= wxT("");
644 long windowStyle
= wxDEFAULT_DIALOG_STYLE
;
648 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
650 wxExpr
*labelFontExpr
= (wxExpr
*) NULL
;
651 wxExpr
*buttonFontExpr
= (wxExpr
*) NULL
;
652 wxExpr
*fontExpr
= (wxExpr
*) NULL
;
653 expr
->GetAttributeValue(wxT("style"), style
);
654 expr
->GetAttributeValue(wxT("name"), name
);
655 expr
->GetAttributeValue(wxT("title"), title
);
656 expr
->GetAttributeValue(wxT("x"), x
);
657 expr
->GetAttributeValue(wxT("y"), y
);
658 expr
->GetAttributeValue(wxT("width"), width
);
659 expr
->GetAttributeValue(wxT("height"), height
);
660 expr
->GetAttributeValue(wxT("modal"), isModal
);
661 expr
->GetAttributeValue(wxT("label_font"), &labelFontExpr
);
662 expr
->GetAttributeValue(wxT("button_font"), &buttonFontExpr
);
663 expr
->GetAttributeValue(wxT("font"), &fontExpr
);
664 expr
->GetAttributeValue(wxT("background_colour"), backColourHex
);
665 expr
->GetAttributeValue(wxT("label_colour"), labelColourHex
);
666 expr
->GetAttributeValue(wxT("button_colour"), buttonColourHex
);
668 int useDialogUnits
= 0;
669 expr
->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits
);
670 if (useDialogUnits
!= 0)
671 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
);
674 expr
->GetAttributeValue(wxT("use_system_defaults"), useDefaults
);
675 if (useDefaults
!= 0)
676 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
);
679 expr
->GetAttributeValue(wxT("id"), id
);
680 dialogItem
->SetId(id
);
682 if (style
!= wxT(""))
684 windowStyle
= wxParseWindowStyle(style
);
686 dialogItem
->SetStyle(windowStyle
);
687 dialogItem
->SetValue1(isModal
);
688 if (windowStyle
& wxDIALOG_MODAL
) // Uses style in wxWin 2
689 dialogItem
->SetValue1(TRUE
);
691 dialogItem
->SetName(name
);
692 dialogItem
->SetTitle(title
);
693 dialogItem
->SetSize(x
, y
, width
, height
);
695 if (backColourHex
!= wxT(""))
700 r
= wxHexToDec(backColourHex
.Mid(0, 2));
701 g
= wxHexToDec(backColourHex
.Mid(2, 2));
702 b
= wxHexToDec(backColourHex
.Mid(4, 2));
703 dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
705 if (labelColourHex
!= wxT(""))
710 r
= wxHexToDec(labelColourHex
.Mid(0, 2));
711 g
= wxHexToDec(labelColourHex
.Mid(2, 2));
712 b
= wxHexToDec(labelColourHex
.Mid(4, 2));
713 dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
715 if (buttonColourHex
!= wxT(""))
720 r
= wxHexToDec(buttonColourHex
.Mid(0, 2));
721 g
= wxHexToDec(buttonColourHex
.Mid(2, 2));
722 b
= wxHexToDec(buttonColourHex
.Mid(4, 2));
723 dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
727 dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
));
728 else if (buttonFontExpr
)
729 dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
));
730 else if (labelFontExpr
)
731 dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
));
733 // Now parse all controls
734 wxExpr
*controlExpr
= expr
->GetFirst();
737 if (controlExpr
->Number() == 3)
739 wxString
controlKeyword(controlExpr
->Nth(1)->StringValue());
740 if (controlKeyword
!= wxT("") && controlKeyword
== wxT("control"))
742 // The value part: always a list.
743 wxExpr
*listExpr
= controlExpr
->Nth(2);
744 if (listExpr
->Type() == PrologList
)
746 wxItemResource
*controlItem
= wxResourceInterpretControl(table
, listExpr
);
749 dialogItem
->GetChildren().Append(controlItem
);
754 controlExpr
= controlExpr
->GetNext();
759 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
)
761 wxItemResource
*controlItem
= new wxItemResource
;
763 // First, find the standard features of a control definition:
764 // [optional integer/string id], control name, title, style, name, x, y, width, height
766 wxString controlType
;
771 long windowStyle
= 0;
772 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
775 wxExpr
*expr1
= expr
->Nth(0);
777 if ( expr1
->Type() == PrologString
|| expr1
->Type() == PrologWord
)
779 if ( wxIsValidControlClass(expr1
->StringValue()) )
782 controlType
= expr1
->StringValue();
786 wxString
str(expr1
->StringValue());
787 id
= wxResourceGetIdentifier(str
, &table
);
790 wxLogWarning(_("Could not resolve control class or id '%s'. "
791 "Use (non-zero) integer instead\n or provide #define "
792 "(see manual for caveats)"),
793 (const wxChar
*) expr1
->StringValue());
795 return (wxItemResource
*) NULL
;
799 // Success - we have an id, so the 2nd element must be the control class.
800 controlType
= expr
->Nth(1)->StringValue();
805 else if (expr1
->Type() == PrologInteger
)
807 id
= (int)expr1
->IntegerValue();
808 // Success - we have an id, so the 2nd element must be the control class.
809 controlType
= expr
->Nth(1)->StringValue();
813 expr1
= expr
->Nth(count
);
816 title
= expr1
->StringValue();
818 expr1
= expr
->Nth(count
);
822 style
= expr1
->StringValue();
823 windowStyle
= wxParseWindowStyle(style
);
826 expr1
= expr
->Nth(count
);
829 name
= expr1
->StringValue();
831 expr1
= expr
->Nth(count
);
834 x
= (int)expr1
->IntegerValue();
836 expr1
= expr
->Nth(count
);
839 y
= (int)expr1
->IntegerValue();
841 expr1
= expr
->Nth(count
);
844 width
= (int)expr1
->IntegerValue();
846 expr1
= expr
->Nth(count
);
849 height
= (int)expr1
->IntegerValue();
851 controlItem
->SetStyle(windowStyle
);
852 controlItem
->SetName(name
);
853 controlItem
->SetTitle(title
);
854 controlItem
->SetSize(x
, y
, width
, height
);
855 controlItem
->SetType(controlType
);
856 controlItem
->SetId(id
);
858 if (controlType
== wxT("wxButton"))
860 // Check for bitmap resource name (in case loading old-style resource file)
861 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
863 wxString
str(expr
->Nth(count
)->StringValue());
868 controlItem
->SetValue4(str
);
869 controlItem
->SetType(wxT("wxBitmapButton"));
872 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
873 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
875 else if (controlType
== wxT("wxBitmapButton"))
877 // Check for bitmap resource name
878 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
880 wxString
str(expr
->Nth(count
)->StringValue());
881 controlItem
->SetValue4(str
);
883 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
884 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
887 else if (controlType
== wxT("wxCheckBox"))
889 // Check for default value
890 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
892 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
894 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
895 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
899 else if (controlType
== wxT("wxRadioButton"))
901 // Check for default value
902 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
904 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
906 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
907 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
911 else if (controlType
== wxT("wxText") || controlType
== wxT("wxTextCtrl") || controlType
== wxT("wxMultiText"))
913 // Check for default value
914 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
916 wxString
str(expr
->Nth(count
)->StringValue());
917 controlItem
->SetValue4(str
);
920 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
922 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
923 // Skip past the obsolete label font spec if there are two consecutive specs
924 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
926 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
930 else if (controlType
== wxT("wxMessage") || controlType
== wxT("wxStaticText"))
932 // Check for bitmap resource name (in case it's an old-style .wxr file)
933 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
935 wxString
str(expr
->Nth(count
)->StringValue());
936 controlItem
->SetValue4(str
);
938 controlItem
->SetType(wxT("wxStaticText"));
940 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
941 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
943 else if (controlType
== wxT("wxStaticBitmap"))
945 // Check for bitmap resource name
946 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
948 wxString
str(expr
->Nth(count
)->StringValue());
949 controlItem
->SetValue4(str
);
952 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
953 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
955 else if (controlType
== wxT("wxGroupBox") || controlType
== wxT("wxStaticBox"))
957 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
958 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
960 else if (controlType
== wxT("wxGauge"))
962 // Check for default value
963 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
965 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
969 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
971 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
974 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
976 // Skip past the obsolete label font spec if there are two consecutive specs
977 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
979 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
984 else if (controlType
== wxT("wxSlider"))
986 // Check for default value
987 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
989 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
993 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
995 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
999 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1001 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1004 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1006 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1010 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1011 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1017 else if (controlType
== wxT("wxScrollBar"))
1020 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1022 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1026 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1028 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1032 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1034 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1038 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1039 controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue());
1044 else if (controlType
== wxT("wxListBox"))
1046 wxExpr
*valueList
= (wxExpr
*) NULL
;
1048 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1050 wxStringList stringList
;
1051 wxExpr
*stringExpr
= valueList
->GetFirst();
1054 stringList
.Add(stringExpr
->StringValue());
1055 stringExpr
= stringExpr
->GetNext();
1057 controlItem
->SetStringValues(stringList
);
1059 // This is now obsolete: it's in the window style.
1060 // Check for wxSINGLE/wxMULTIPLE
1061 wxExpr
*mult
= (wxExpr
*) NULL
;
1063 controlItem->SetValue1(wxLB_SINGLE);
1065 if ((mult
= expr
->Nth(count
)) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
)))
1068 wxString m(mult->StringValue());
1069 if (m == "wxLB_MULTIPLE")
1070 controlItem->SetValue1(wxLB_MULTIPLE);
1071 else if (m == "wxLB_EXTENDED")
1072 controlItem->SetValue1(wxLB_EXTENDED);
1077 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1079 // Skip past the obsolete label font spec if there are two consecutive specs
1080 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1082 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1086 else if (controlType
== wxT("wxChoice"))
1088 wxExpr
*valueList
= (wxExpr
*) NULL
;
1089 // Check for default value list
1090 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1092 wxStringList stringList
;
1093 wxExpr
*stringExpr
= valueList
->GetFirst();
1096 stringList
.Add(stringExpr
->StringValue());
1097 stringExpr
= stringExpr
->GetNext();
1099 controlItem
->SetStringValues(stringList
);
1103 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1105 // Skip past the obsolete label font spec if there are two consecutive specs
1106 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1108 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1113 else if (controlType
== wxT("wxComboBox"))
1115 wxExpr
*textValue
= expr
->Nth(count
);
1116 if (textValue
&& (textValue
->Type() == PrologString
|| textValue
->Type() == PrologWord
))
1118 wxString
str(textValue
->StringValue());
1119 controlItem
->SetValue4(str
);
1123 wxExpr
*valueList
= (wxExpr
*) NULL
;
1124 // Check for default value list
1125 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1127 wxStringList stringList
;
1128 wxExpr
*stringExpr
= valueList
->GetFirst();
1131 stringList
.Add(stringExpr
->StringValue());
1132 stringExpr
= stringExpr
->GetNext();
1134 controlItem
->SetStringValues(stringList
);
1138 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1140 // Skip past the obsolete label font spec if there are two consecutive specs
1141 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1143 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1150 else if (controlType
== wxT("wxRadioBox"))
1152 wxExpr
*valueList
= (wxExpr
*) NULL
;
1153 // Check for default value list
1154 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1156 wxStringList stringList
;
1157 wxExpr
*stringExpr
= valueList
->GetFirst();
1160 stringList
.Add(stringExpr
->StringValue());
1161 stringExpr
= stringExpr
->GetNext();
1163 controlItem
->SetStringValues(stringList
);
1166 // majorDim (number of rows or cols)
1167 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1169 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1173 controlItem
->SetValue1(0);
1175 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1177 // Skip past the obsolete label font spec if there are two consecutive specs
1178 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1180 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1188 return (wxItemResource
*) NULL
;
1193 // Forward declaration
1194 wxItemResource
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr
*expr
);
1197 * Interpet a menu item
1200 wxItemResource
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr
*expr
)
1202 wxItemResource
*item
= new wxItemResource
;
1204 wxExpr
*labelExpr
= expr
->Nth(0);
1205 wxExpr
*idExpr
= expr
->Nth(1);
1206 wxExpr
*helpExpr
= expr
->Nth(2);
1207 wxExpr
*checkableExpr
= expr
->Nth(3);
1209 // Further keywords/attributes to follow sometime...
1210 if (expr
->Number() == 0)
1212 // item->SetType(wxRESOURCE_TYPE_SEPARATOR);
1213 item
->SetType(wxT("wxMenuSeparator"));
1218 // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
1219 item
->SetType(wxT("wxMenu")); // Well, menu item, but doesn't matter.
1222 wxString
str(labelExpr
->StringValue());
1223 item
->SetTitle(str
);
1228 // If a string or word, must look up in identifier table.
1229 if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
))
1231 wxString
str(idExpr
->StringValue());
1232 id
= wxResourceGetIdentifier(str
, &table
);
1235 wxLogWarning(_("Could not resolve menu id '%s'. "
1236 "Use (non-zero) integer instead\n"
1237 "or provide #define (see manual for caveats)"),
1238 (const wxChar
*) idExpr
->StringValue());
1241 else if (idExpr
->Type() == PrologInteger
)
1242 id
= (int)idExpr
->IntegerValue();
1243 item
->SetValue1(id
);
1247 wxString
str(helpExpr
->StringValue());
1248 item
->SetValue4(str
);
1251 item
->SetValue2(checkableExpr
->IntegerValue());
1253 // Find the first expression that's a list, for submenu
1254 wxExpr
*subMenuExpr
= expr
->GetFirst();
1255 while (subMenuExpr
&& (subMenuExpr
->Type() != PrologList
))
1256 subMenuExpr
= subMenuExpr
->GetNext();
1260 wxItemResource
*child
= wxResourceInterpretMenuItem(table
, subMenuExpr
);
1261 item
->GetChildren().Append(child
);
1262 subMenuExpr
= subMenuExpr
->GetNext();
1269 * Interpret a nested list as a menu
1272 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
1274 wxItemResource *menu = new wxItemResource;
1275 // menu->SetType(wxTYPE_MENU);
1276 menu->SetType("wxMenu");
1277 wxExpr *element = expr->GetFirst();
1280 wxItemResource *item = wxResourceInterpretMenuItem(table, element);
1282 menu->GetChildren().Append(item);
1283 element = element->GetNext();
1289 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
)
1291 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1292 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1294 return (wxItemResource
*) NULL
;
1296 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1299 return (wxItemResource
*) NULL
;
1302 if (expr
->GetAttributeValue(wxT("name"), name
))
1304 menuResource
->SetName(name
);
1307 return menuResource
;
1310 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
)
1312 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1313 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1315 return (wxItemResource
*) NULL
;
1317 wxItemResource
*resource
= new wxItemResource
;
1318 resource
->SetType(wxT("wxMenu"));
1319 // resource->SetType(wxTYPE_MENU);
1321 wxExpr
*element
= listExpr
->GetFirst();
1324 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1325 resource
->GetChildren().Append(menuResource
);
1326 element
= element
->GetNext();
1330 if (expr
->GetAttributeValue(wxT("name"), name
))
1332 resource
->SetName(name
);
1338 wxItemResource
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr
*WXUNUSED(expr
))
1340 return (wxItemResource
*) NULL
;
1343 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr
*expr
)
1345 wxItemResource
*bitmapItem
= new wxItemResource
;
1346 // bitmapItem->SetType(wxTYPE_BITMAP);
1347 bitmapItem
->SetType(wxT("wxBitmap"));
1349 if (expr
->GetAttributeValue(wxT("name"), name
))
1351 bitmapItem
->SetName(name
);
1353 // Now parse all bitmap specifications
1354 wxExpr
*bitmapExpr
= expr
->GetFirst();
1357 if (bitmapExpr
->Number() == 3)
1359 wxString
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue());
1360 if (bitmapKeyword
== wxT("bitmap") || bitmapKeyword
== wxT("icon"))
1362 // The value part: always a list.
1363 wxExpr
*listExpr
= bitmapExpr
->Nth(2);
1364 if (listExpr
->Type() == PrologList
)
1366 wxItemResource
*bitmapSpec
= new wxItemResource
;
1367 // bitmapSpec->SetType(wxTYPE_BITMAP);
1368 bitmapSpec
->SetType(wxT("wxBitmap"));
1370 // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
1371 // where everything after 'filename' is optional.
1372 wxExpr
*nameExpr
= listExpr
->Nth(0);
1373 wxExpr
*typeExpr
= listExpr
->Nth(1);
1374 wxExpr
*platformExpr
= listExpr
->Nth(2);
1375 wxExpr
*coloursExpr
= listExpr
->Nth(3);
1376 wxExpr
*xresExpr
= listExpr
->Nth(4);
1377 wxExpr
*yresExpr
= listExpr
->Nth(5);
1378 if (nameExpr
&& nameExpr
->StringValue() != wxT(""))
1380 bitmapSpec
->SetName(nameExpr
->StringValue());
1382 if (typeExpr
&& typeExpr
->StringValue() != wxT(""))
1384 bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue()));
1387 bitmapSpec
->SetValue1(0);
1389 if (platformExpr
&& platformExpr
->StringValue() != wxT(""))
1391 wxString
plat(platformExpr
->StringValue());
1392 if (plat
== wxT("windows") || plat
== wxT("WINDOWS"))
1393 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
);
1394 else if (plat
== wxT("x") || plat
== wxT("X"))
1395 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
);
1396 else if (plat
== wxT("mac") || plat
== wxT("MAC"))
1397 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
);
1399 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1402 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1405 bitmapSpec
->SetValue3(coloursExpr
->IntegerValue());
1409 xres
= (int)xresExpr
->IntegerValue();
1411 yres
= (int)yresExpr
->IntegerValue();
1412 bitmapSpec
->SetSize(0, 0, xres
, yres
);
1414 bitmapItem
->GetChildren().Append(bitmapSpec
);
1418 bitmapExpr
= bitmapExpr
->GetNext();
1424 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
)
1426 wxItemResource
*item
= wxResourceInterpretBitmap(table
, expr
);
1429 // item->SetType(wxTYPE_ICON);
1430 item
->SetType(wxT("wxIcon"));
1434 return (wxItemResource
*) NULL
;
1437 // Interpret list expression as a font
1438 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
)
1440 if (expr
->Type() != PrologList
)
1444 int family
= wxSWISS
;
1445 int style
= wxNORMAL
;
1446 int weight
= wxNORMAL
;
1448 wxString
faceName(wxT(""));
1450 wxExpr
*pointExpr
= expr
->Nth(0);
1451 wxExpr
*familyExpr
= expr
->Nth(1);
1452 wxExpr
*styleExpr
= expr
->Nth(2);
1453 wxExpr
*weightExpr
= expr
->Nth(3);
1454 wxExpr
*underlineExpr
= expr
->Nth(4);
1455 wxExpr
*faceNameExpr
= expr
->Nth(5);
1457 point
= (int)pointExpr
->IntegerValue();
1462 str
= familyExpr
->StringValue();
1463 family
= (int)wxParseWindowStyle(str
);
1467 str
= styleExpr
->StringValue();
1468 style
= (int)wxParseWindowStyle(str
);
1472 str
= weightExpr
->StringValue();
1473 weight
= (int)wxParseWindowStyle(str
);
1476 underline
= (int)underlineExpr
->IntegerValue();
1478 faceName
= faceNameExpr
->StringValue();
1480 wxFont
font(point
, family
, style
, weight
, (underline
!= 0), faceName
);
1484 // Separate file for the remainder of this, for BC++/Win16
1486 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
1488 * (Re)allocate buffer for reading in from resource file
1491 bool wxReallocateResourceBuffer()
1493 if (!wxResourceBuffer
)
1495 wxResourceBufferSize
= 1000;
1496 wxResourceBuffer
= new char[wxResourceBufferSize
];
1499 if (wxResourceBuffer
)
1501 long newSize
= wxResourceBufferSize
+ 1000;
1502 char *tmp
= new char[(int)newSize
];
1503 strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
);
1504 delete[] wxResourceBuffer
;
1505 wxResourceBuffer
= tmp
;
1506 wxResourceBufferSize
= newSize
;
1511 static bool wxEatWhiteSpace(FILE *fd
)
1515 while ((ch
= getc(fd
)) != EOF
)
1530 ungetc(prev_ch
, fd
);
1538 while ((ch
= getc(fd
)) != EOF
)
1540 if (ch
== '/' && prev_ch
== '*')
1548 static char buffer
[255];
1549 fgets(buffer
, 255, fd
);
1553 ungetc(prev_ch
, fd
);
1567 static bool wxEatWhiteSpace(wxInputStream
*is
)
1569 int ch
= is
->GetC() ;
1570 if ((ch
!= ' ') && (ch
!= '/') && (ch
!= ' ') && (ch
!= 10) && (ch
!= 13) && (ch
!= 9))
1577 while (ch
== ' ' || ch
== 10 || ch
== 13 || ch
== 9)
1579 // Check for comment
1585 bool finished
= FALSE
;
1593 int newCh
= is
->GetC();
1608 return wxEatWhiteSpace(is
);
1611 bool wxGetResourceToken(FILE *fd
)
1613 if (!wxResourceBuffer
)
1614 wxReallocateResourceBuffer();
1615 wxResourceBuffer
[0] = 0;
1616 wxEatWhiteSpace(fd
);
1622 wxResourceBufferCount
= 0;
1629 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1632 // Escaped characters
1633 else if (ch
== '\\')
1635 int newCh
= getc(fd
);
1638 else if (newCh
== 10)
1646 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1647 wxReallocateResourceBuffer();
1648 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1649 wxResourceBufferCount
++;
1652 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1656 wxResourceBufferCount
= 0;
1658 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1660 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1661 wxReallocateResourceBuffer();
1662 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1663 wxResourceBufferCount
++;
1667 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1674 bool wxGetResourceToken(wxInputStream
*is
)
1676 if (!wxResourceBuffer
)
1677 wxReallocateResourceBuffer();
1678 wxResourceBuffer
[0] = 0;
1679 wxEatWhiteSpace(is
);
1681 int ch
= is
->GetC() ;
1685 wxResourceBufferCount
= 0;
1692 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1695 // Escaped characters
1696 else if (ch
== '\\')
1698 int newCh
= is
->GetC();
1701 else if (newCh
== 10)
1703 else if (newCh
== 13) // mac
1711 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1712 wxReallocateResourceBuffer();
1713 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1714 wxResourceBufferCount
++;
1717 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1721 wxResourceBufferCount
= 0;
1723 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1725 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1726 wxReallocateResourceBuffer();
1727 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1728 wxResourceBufferCount
++;
1732 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1740 * Files are in form:
1741 static char *name = "....";
1742 with possible comments.
1745 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1748 table
= wxDefaultResourceTable
;
1750 // static or #define
1751 if (!wxGetResourceToken(fd
))
1757 if (strcmp(wxResourceBuffer
, "#define") == 0)
1759 wxGetResourceToken(fd
);
1760 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1761 wxGetResourceToken(fd
);
1762 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1763 if (wxIsdigit(value
[0]))
1765 int val
= (int)wxAtol(value
);
1766 wxResourceAddIdentifier(name
, val
, table
);
1770 wxLogWarning(_("#define %s must be an integer."), name
);
1780 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1782 wxGetResourceToken(fd
);
1783 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1784 wxChar
*actualName
= name
;
1785 if (name
[0] == wxT('"'))
1786 actualName
= name
+ 1;
1787 int len
= wxStrlen(name
);
1788 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1790 if (!wxResourceParseIncludeFile(actualName
, table
))
1792 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1797 else if (strcmp(wxResourceBuffer
, "static") != 0)
1800 wxStrcpy(buf
, _("Found "));
1801 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
1802 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1808 if (!wxGetResourceToken(fd
))
1810 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1815 if (strcmp(wxResourceBuffer
, "char") != 0)
1817 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1822 if (!wxGetResourceToken(fd
))
1824 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1829 if (wxResourceBuffer
[0] != '*')
1831 wxLogWarning(_("Expected '*' whilst parsing resource."));
1834 wxChar nameBuf
[100];
1835 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
1839 if (!wxGetResourceToken(fd
))
1841 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1846 if (strcmp(wxResourceBuffer
, "=") != 0)
1848 wxLogWarning(_("Expected '=' whilst parsing resource."));
1853 if (!wxGetResourceToken(fd
))
1855 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1861 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1863 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1868 if (!wxGetResourceToken(fd
))
1875 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1878 table
= wxDefaultResourceTable
;
1880 // static or #define
1881 if (!wxGetResourceToken(fd
))
1887 if (strcmp(wxResourceBuffer
, "#define") == 0)
1889 wxGetResourceToken(fd
);
1890 char *name
= copystring(wxResourceBuffer
);
1891 wxGetResourceToken(fd
);
1892 char *value
= copystring(wxResourceBuffer
);
1893 if (isalpha(value
[0]))
1895 int val
= (int)atol(value
);
1896 wxResourceAddIdentifier(name
, val
, table
);
1900 wxLogWarning(_("#define %s must be an integer."), name
);
1910 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1912 wxGetResourceToken(fd
);
1913 char *name
= copystring(wxResourceBuffer
);
1914 char *actualName
= name
;
1916 actualName
= name
+ 1;
1917 int len
= strlen(name
);
1918 if ((len
> 0) && (name
[len
-1] == '"'))
1920 if (!wxResourceParseIncludeFile(actualName
, table
))
1922 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1927 else if (strcmp(wxResourceBuffer
, "static") != 0)
1930 strcpy(buf
, _("Found "));
1931 strncat(buf
, wxResourceBuffer
, 30);
1932 strcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1938 if (!wxGetResourceToken(fd
))
1940 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1945 if (strcmp(wxResourceBuffer
, "char") != 0)
1947 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1952 if (!wxGetResourceToken(fd
))
1954 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1959 if (wxResourceBuffer
[0] != '*')
1961 wxLogWarning(_("Expected '*' whilst parsing resource."));
1965 strncpy(nameBuf
, wxResourceBuffer
+1, 99);
1968 if (!wxGetResourceToken(fd
))
1970 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1975 if (strcmp(wxResourceBuffer
, "=") != 0)
1977 wxLogWarning(_("Expected '=' whilst parsing resource."));
1982 if (!wxGetResourceToken(fd
))
1984 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1990 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1992 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1997 if (!wxGetResourceToken(fd
))
2005 * Parses string window style into integer window style
2009 * Style flag parsing, e.g.
2010 * "wxSYSTEM_MENU | wxBORDER" -> integer
2013 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
)
2016 return (wxChar
*) NULL
;
2018 static wxChar buf
[150];
2019 int len
= wxStrlen(s
);
2022 while ((ii
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == wxT('_'))))
2030 // Eat whitespace and conjunction characters
2031 while ((ii
< len
) &&
2032 ((s
[ii
] == wxT(' ')) || (s
[ii
] == wxT('|')) || (s
[ii
] == wxT(','))))
2038 return (wxChar
*) NULL
;
2043 struct wxResourceBitListStruct
2049 static wxResourceBitListStruct wxResourceBitListTable
[] =
2052 { wxT("wxSINGLE"), wxLB_SINGLE
},
2053 { wxT("wxMULTIPLE"), wxLB_MULTIPLE
},
2054 { wxT("wxEXTENDED"), wxLB_EXTENDED
},
2055 { wxT("wxLB_SINGLE"), wxLB_SINGLE
},
2056 { wxT("wxLB_MULTIPLE"), wxLB_MULTIPLE
},
2057 { wxT("wxLB_EXTENDED"), wxLB_EXTENDED
},
2058 { wxT("wxLB_NEEDED_SB"), wxLB_NEEDED_SB
},
2059 { wxT("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB
},
2060 { wxT("wxLB_SORT"), wxLB_SORT
},
2061 { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW
},
2062 { wxT("wxLB_HSCROLL"), wxLB_HSCROLL
},
2065 { wxT("wxCB_SIMPLE"), wxCB_SIMPLE
},
2066 { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN
},
2067 { wxT("wxCB_READONLY"), wxCB_READONLY
},
2068 { wxT("wxCB_SORT"), wxCB_SORT
},
2071 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR
},
2072 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL
},
2073 { wxT("wxGA_VERTICAL"), wxGA_VERTICAL
},
2076 { wxT("wxPASSWORD"), wxPASSWORD
},
2077 { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER
},
2078 { wxT("wxTE_PASSWORD"), wxTE_PASSWORD
},
2079 { wxT("wxTE_READONLY"), wxTE_READONLY
},
2080 { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
},
2081 { wxT("wxTE_MULTILINE"), wxTE_MULTILINE
},
2082 { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL
},
2084 /* wxRadioBox/wxRadioButton */
2085 { wxT("wxRB_GROUP"), wxRB_GROUP
},
2086 { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS
},
2087 { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS
},
2088 { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL
},
2089 { wxT("wxRA_VERTICAL"), wxRA_VERTICAL
},
2092 { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL
},
2093 { wxT("wxSL_VERTICAL"), wxSL_VERTICAL
},
2094 { wxT("wxSL_AUTOTICKS"), wxSL_AUTOTICKS
},
2095 { wxT("wxSL_LABELS"), wxSL_LABELS
},
2096 { wxT("wxSL_LEFT"), wxSL_LEFT
},
2097 { wxT("wxSL_TOP"), wxSL_TOP
},
2098 { wxT("wxSL_RIGHT"), wxSL_RIGHT
},
2099 { wxT("wxSL_BOTTOM"), wxSL_BOTTOM
},
2100 { wxT("wxSL_BOTH"), wxSL_BOTH
},
2101 { wxT("wxSL_SELRANGE"), wxSL_SELRANGE
},
2104 { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL
},
2105 { wxT("wxSB_VERTICAL"), wxSB_VERTICAL
},
2108 { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW
},
2109 { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW
},
2112 { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS
},
2113 { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS
},
2114 { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT
},
2117 { wxT("wxLC_ICON"), wxLC_ICON
},
2118 { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON
},
2119 { wxT("wxLC_LIST"), wxLC_LIST
},
2120 { wxT("wxLC_REPORT"), wxLC_REPORT
},
2121 { wxT("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP
},
2122 { wxT("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT
},
2123 { wxT("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE
},
2124 { wxT("wxLC_USER_TEXT"), wxLC_USER_TEXT
},
2125 { wxT("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS
},
2126 { wxT("wxLC_NO_HEADER"), wxLC_NO_HEADER
},
2127 { wxT("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER
},
2128 { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL
},
2129 { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING
},
2130 { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING
},
2133 { wxT("wxSP_VERTICAL"), wxSP_VERTICAL
},
2134 { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
},
2135 { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
},
2136 { wxT("wxSP_WRAP"), wxSP_WRAP
},
2139 { wxT("wxSP_NOBORDER"), wxSP_NOBORDER
},
2140 { wxT("wxSP_3D"), wxSP_3D
},
2141 { wxT("wxSP_BORDER"), wxSP_BORDER
},
2144 { wxT("wxTC_MULTILINE"), wxTC_MULTILINE
},
2145 { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
},
2146 { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
},
2147 { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
},
2150 { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP
},
2153 { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH
},
2154 { wxT("wxALIGN_LEFT"), wxALIGN_LEFT
},
2155 { wxT("wxALIGN_CENTER"), wxALIGN_CENTER
},
2156 { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE
},
2157 { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT
},
2158 { wxT("wxCOLOURED"), wxCOLOURED
},
2161 { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
},
2162 { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
},
2163 { wxT("wxTB_VERTICAL"), wxTB_VERTICAL
},
2164 { wxT("wxTB_FLAT"), wxTB_FLAT
},
2167 { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL
},
2170 { wxT("wxVSCROLL"), wxVSCROLL
},
2171 { wxT("wxHSCROLL"), wxHSCROLL
},
2172 { wxT("wxCAPTION"), wxCAPTION
},
2173 { wxT("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
},
2174 { wxT("wxICONIZE"), wxICONIZE
},
2175 { wxT("wxMINIMIZE"), wxICONIZE
},
2176 { wxT("wxMAXIMIZE"), wxMAXIMIZE
},
2178 { wxT("wxMDI_PARENT"), 0},
2179 { wxT("wxMDI_CHILD"), 0},
2180 { wxT("wxTHICK_FRAME"), wxTHICK_FRAME
},
2181 { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER
},
2182 { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU
},
2183 { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
},
2184 { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
},
2185 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX
},
2186 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
},
2187 { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
},
2188 { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
},
2189 { wxT("wxBORDER"), wxBORDER
},
2190 { wxT("wxRETAINED"), wxRETAINED
},
2191 { wxT("wxNATIVE_IMPL"), 0},
2192 { wxT("wxEXTENDED_IMPL"), 0},
2193 { wxT("wxBACKINGSTORE"), wxBACKINGSTORE
},
2194 // { wxT("wxFLAT"), wxFLAT},
2195 // { wxT("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
2196 { wxT("wxFIXED_LENGTH"), 0},
2197 { wxT("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
},
2198 { wxT("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
},
2199 { wxT("wxRAISED_BORDER"), wxRAISED_BORDER
},
2200 { wxT("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
},
2201 { wxT("wxSTATIC_BORDER"), wxSTATIC_BORDER
},
2202 { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
},
2203 { wxT("wxNO_BORDER"), wxNO_BORDER
},
2204 { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
},
2205 { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
2207 { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
},
2208 { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
},
2210 // Text font families
2211 { wxT("wxDEFAULT"), wxDEFAULT
},
2212 { wxT("wxDECORATIVE"), wxDECORATIVE
},
2213 { wxT("wxROMAN"), wxROMAN
},
2214 { wxT("wxSCRIPT"), wxSCRIPT
},
2215 { wxT("wxSWISS"), wxSWISS
},
2216 { wxT("wxMODERN"), wxMODERN
},
2217 { wxT("wxTELETYPE"), wxTELETYPE
},
2218 { wxT("wxVARIABLE"), wxVARIABLE
},
2219 { wxT("wxFIXED"), wxFIXED
},
2220 { wxT("wxNORMAL"), wxNORMAL
},
2221 { wxT("wxLIGHT"), wxLIGHT
},
2222 { wxT("wxBOLD"), wxBOLD
},
2223 { wxT("wxITALIC"), wxITALIC
},
2224 { wxT("wxSLANT"), wxSLANT
},
2225 { wxT("wxSOLID"), wxSOLID
},
2226 { wxT("wxDOT"), wxDOT
},
2227 { wxT("wxLONG_DASH"), wxLONG_DASH
},
2228 { wxT("wxSHORT_DASH"), wxSHORT_DASH
},
2229 { wxT("wxDOT_DASH"), wxDOT_DASH
},
2230 { wxT("wxUSER_DASH"), wxUSER_DASH
},
2231 { wxT("wxTRANSPARENT"), wxTRANSPARENT
},
2232 { wxT("wxSTIPPLE"), wxSTIPPLE
},
2233 { wxT("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
},
2234 { wxT("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
},
2235 { wxT("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
},
2236 { wxT("wxCROSS_HATCH"), wxCROSS_HATCH
},
2237 { wxT("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
},
2238 { wxT("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
},
2239 { wxT("wxJOIN_BEVEL"), wxJOIN_BEVEL
},
2240 { wxT("wxJOIN_MITER"), wxJOIN_MITER
},
2241 { wxT("wxJOIN_ROUND"), wxJOIN_ROUND
},
2242 { wxT("wxCAP_ROUND"), wxCAP_ROUND
},
2243 { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING
},
2244 { wxT("wxCAP_BUTT"), wxCAP_BUTT
},
2247 { wxT("wxCLEAR"), wxCLEAR
},
2248 { wxT("wxXOR"), wxXOR
},
2249 { wxT("wxINVERT"), wxINVERT
},
2250 { wxT("wxOR_REVERSE"), wxOR_REVERSE
},
2251 { wxT("wxAND_REVERSE"), wxAND_REVERSE
},
2252 { wxT("wxCOPY"), wxCOPY
},
2253 { wxT("wxAND"), wxAND
},
2254 { wxT("wxAND_INVERT"), wxAND_INVERT
},
2255 { wxT("wxNO_OP"), wxNO_OP
},
2256 { wxT("wxNOR"), wxNOR
},
2257 { wxT("wxEQUIV"), wxEQUIV
},
2258 { wxT("wxSRC_INVERT"), wxSRC_INVERT
},
2259 { wxT("wxOR_INVERT"), wxOR_INVERT
},
2260 { wxT("wxNAND"), wxNAND
},
2261 { wxT("wxOR"), wxOR
},
2262 { wxT("wxSET"), wxSET
},
2264 { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
},
2265 { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER
},
2266 { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE
},
2267 { wxT("wxWINDING_RULE"), wxWINDING_RULE
},
2268 { wxT("wxHORIZONTAL"), wxHORIZONTAL
},
2269 { wxT("wxVERTICAL"), wxVERTICAL
},
2270 { wxT("wxBOTH"), wxBOTH
},
2271 { wxT("wxCENTER_FRAME"), wxCENTER_FRAME
},
2272 { wxT("wxOK"), wxOK
},
2273 { wxT("wxYES_NO"), wxYES_NO
},
2274 { wxT("wxCANCEL"), wxCANCEL
},
2275 { wxT("wxYES"), wxYES
},
2276 { wxT("wxNO"), wxNO
},
2277 { wxT("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
},
2278 { wxT("wxICON_HAND"), wxICON_HAND
},
2279 { wxT("wxICON_QUESTION"), wxICON_QUESTION
},
2280 { wxT("wxICON_INFORMATION"), wxICON_INFORMATION
},
2281 { wxT("wxICON_STOP"), wxICON_STOP
},
2282 { wxT("wxICON_ASTERISK"), wxICON_ASTERISK
},
2283 { wxT("wxICON_MASK"), wxICON_MASK
},
2284 { wxT("wxCENTRE"), wxCENTRE
},
2285 { wxT("wxCENTER"), wxCENTRE
},
2286 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS
},
2287 { wxT("wxVERTICAL_LABEL"), 0},
2288 { wxT("wxHORIZONTAL_LABEL"), 0},
2290 // Bitmap types (not strictly styles)
2291 { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
},
2292 { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
},
2293 { wxT("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
},
2294 { wxT("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2295 { wxT("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2296 { wxT("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
},
2297 { wxT("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
},
2298 { wxT("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
},
2299 { wxT("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
},
2300 { wxT("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
},
2301 { wxT("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
},
2302 { wxT("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
},
2303 { wxT("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
},
2304 { wxT("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
}
2307 static int wxResourceBitListCount
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
));
2309 long wxParseWindowStyle(const wxString
& bitListString
)
2314 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2315 while (word
!= NULL
)
2319 for (j
= 0; j
< wxResourceBitListCount
; j
++)
2320 if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0)
2322 bitList
|= wxResourceBitListTable
[j
].bits
;
2328 wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
);
2331 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2337 * Load a bitmap from a wxWindows resource, choosing an optimum
2338 * depth and appropriate type.
2341 wxBitmap
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable
*table
)
2344 table
= wxDefaultResourceTable
;
2346 wxItemResource
*item
= table
->FindResource(resource
);
2349 if ((item
->GetType() == wxT("")) || (item
->GetType() != wxT("wxBitmap")))
2351 wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
);
2352 return wxNullBitmap
;
2354 int thisDepth
= wxDisplayDepth();
2355 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2357 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2359 // Try to find optimum bitmap for this platform/colour depth
2360 wxNode
*node
= item
->GetChildren().First();
2363 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2364 int platform
= (int)child
->GetValue2();
2365 int noColours
= (int)child
->GetValue3();
2367 char *name = child->GetName();
2368 int bitmapType = (int)child->GetValue1();
2369 int xRes = child->GetWidth();
2370 int yRes = child->GetHeight();
2375 case RESOURCE_PLATFORM_ANY
:
2377 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2378 optResource
= child
;
2381 // Maximise the number of colours.
2382 // If noColours is zero (unspecified), then assume this
2383 // is the right one.
2384 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2385 optResource
= child
;
2390 case RESOURCE_PLATFORM_WINDOWS
:
2392 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2393 optResource
= child
;
2396 // Maximise the number of colours
2397 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2398 optResource
= child
;
2404 case RESOURCE_PLATFORM_X
:
2406 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2407 optResource
= child
;
2410 // Maximise the number of colours
2411 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2412 optResource
= child
;
2418 case RESOURCE_PLATFORM_MAC
:
2420 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2421 optResource
= child
;
2424 // Maximise the number of colours
2425 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2426 optResource
= child
;
2434 node
= node
->Next();
2436 // If no matching resource, fail.
2438 return wxNullBitmap
;
2440 wxString name
= optResource
->GetName();
2441 int bitmapType
= (int)optResource
->GetValue1();
2444 case wxBITMAP_TYPE_XBM_DATA
:
2447 wxItemResource
*item
= table
->FindResource(name
);
2450 wxLogWarning(_("Failed to find XBM resource %s.\n"
2451 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2452 return wxNullBitmap
;
2454 return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ;
2456 wxLogWarning(_("No XBM facility available!"));
2460 case wxBITMAP_TYPE_XPM_DATA
:
2462 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2463 wxItemResource
*item
= table
->FindResource(name
);
2466 wxLogWarning(_("Failed to find XPM resource %s.\n"
2467 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2468 return wxNullBitmap
;
2470 return wxBitmap((char **)item
->GetValue1());
2472 wxLogWarning(_("No XPM facility available!"));
2478 return wxBitmap(name
, bitmapType
);
2481 return wxNullBitmap
;
2485 wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
);
2486 return wxNullBitmap
;
2491 * Load an icon from a wxWindows resource, choosing an optimum
2492 * depth and appropriate type.
2495 wxIcon
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable
*table
)
2498 table
= wxDefaultResourceTable
;
2500 wxItemResource
*item
= table
->FindResource(resource
);
2503 if ((item
->GetType() == wxT("")) || wxStrcmp(item
->GetType(), wxT("wxIcon")) != 0)
2505 wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
);
2508 int thisDepth
= wxDisplayDepth();
2509 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2511 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2513 // Try to find optimum icon for this platform/colour depth
2514 wxNode
*node
= item
->GetChildren().First();
2517 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2518 int platform
= (int)child
->GetValue2();
2519 int noColours
= (int)child
->GetValue3();
2521 char *name = child->GetName();
2522 int bitmapType = (int)child->GetValue1();
2523 int xRes = child->GetWidth();
2524 int yRes = child->GetHeight();
2529 case RESOURCE_PLATFORM_ANY
:
2531 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2532 optResource
= child
;
2535 // Maximise the number of colours.
2536 // If noColours is zero (unspecified), then assume this
2537 // is the right one.
2538 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2539 optResource
= child
;
2544 case RESOURCE_PLATFORM_WINDOWS
:
2546 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2547 optResource
= child
;
2550 // Maximise the number of colours
2551 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2552 optResource
= child
;
2558 case RESOURCE_PLATFORM_X
:
2560 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2561 optResource
= child
;
2564 // Maximise the number of colours
2565 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2566 optResource
= child
;
2572 case RESOURCE_PLATFORM_MAC
:
2574 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2575 optResource
= child
;
2578 // Maximise the number of colours
2579 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2580 optResource
= child
;
2588 node
= node
->Next();
2590 // If no matching resource, fail.
2594 wxString name
= optResource
->GetName();
2595 int bitmapType
= (int)optResource
->GetValue1();
2598 case wxBITMAP_TYPE_XBM_DATA
:
2601 wxItemResource
*item
= table
->FindResource(name
);
2604 wxLogWarning(_("Failed to find XBM resource %s.\n"
2605 "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
);
2608 return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3());
2610 wxLogWarning(_("No XBM facility available!"));
2614 case wxBITMAP_TYPE_XPM_DATA
:
2616 // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
2618 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2619 wxItemResource *item = table->FindResource(name);
2623 sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name);
2627 return wxIcon((char **)item->GetValue1());
2629 wxLogWarning(_("No XPM facility available!"));
2632 wxLogWarning(_("No XPM icon facility available!"));
2638 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2640 return wxIcon(name
, bitmapType
);
2649 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2654 wxMenu
*wxResourceCreateMenu(wxItemResource
*item
)
2656 wxMenu
*menu
= new wxMenu
;
2657 wxNode
*node
= item
->GetChildren().First();
2660 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2661 if ((child
->GetType() != wxT("")) && (child
->GetType() == wxT("wxMenuSeparator")))
2662 menu
->AppendSeparator();
2663 else if (child
->GetChildren().Number() > 0)
2665 wxMenu
*subMenu
= wxResourceCreateMenu(child
);
2667 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4());
2671 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0));
2673 node
= node
->Next();
2678 wxMenuBar
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable
*table
, wxMenuBar
*menuBar
)
2681 table
= wxDefaultResourceTable
;
2683 wxItemResource
*menuResource
= table
->FindResource(resource
);
2684 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2687 menuBar
= new wxMenuBar
;
2688 wxNode
*node
= menuResource
->GetChildren().First();
2691 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2692 wxMenu
*menu
= wxResourceCreateMenu(child
);
2694 menuBar
->Append(menu
, child
->GetTitle());
2695 node
= node
->Next();
2699 return (wxMenuBar
*) NULL
;
2702 wxMenu
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable
*table
)
2705 table
= wxDefaultResourceTable
;
2707 wxItemResource
*menuResource
= table
->FindResource(resource
);
2708 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2709 // if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
2710 return wxResourceCreateMenu(menuResource
);
2711 return (wxMenu
*) NULL
;
2714 // Global equivalents (so don't have to refer to default table explicitly)
2715 bool wxResourceParseData(const wxString
& resource
, wxResourceTable
*table
)
2718 table
= wxDefaultResourceTable
;
2720 return table
->ParseResourceData(resource
);
2723 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable
*table
)
2726 table
= wxDefaultResourceTable
;
2728 return table
->ParseResourceFile(filename
);
2731 // Register XBM/XPM data
2732 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable
*table
)
2735 table
= wxDefaultResourceTable
;
2737 return table
->RegisterResourceBitmapData(name
, bits
, width
, height
);
2740 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable
*table
)
2743 table
= wxDefaultResourceTable
;
2745 return table
->RegisterResourceBitmapData(name
, data
);
2748 void wxResourceClear(wxResourceTable
*table
)
2751 table
= wxDefaultResourceTable
;
2753 table
->ClearTable();
2760 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable
*table
)
2763 table
= wxDefaultResourceTable
;
2765 table
->identifiers
.Put(name
, (wxObject
*)(long)value
);
2769 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable
*table
)
2772 table
= wxDefaultResourceTable
;
2774 return (int)(long)table
->identifiers
.Get(name
);
2778 * Parse #include file for #defines (only)
2781 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
)
2784 table
= wxDefaultResourceTable
;
2786 FILE *fd
= fopen(f
.fn_str(), "r");
2791 while (wxGetResourceToken(fd
))
2793 if (strcmp(wxResourceBuffer
, "#define") == 0)
2795 wxGetResourceToken(fd
);
2796 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2797 wxGetResourceToken(fd
);
2798 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2799 if (wxIsdigit(value
[0]))
2801 int val
= (int)wxAtol(value
);
2802 wxResourceAddIdentifier(name
, val
, table
);
2813 * Reading strings as if they were .wxr files
2816 static int getc_string(char *s
)
2818 int ch
= s
[wxResourceStringPtr
];
2823 wxResourceStringPtr
++;
2828 static int ungetc_string()
2830 wxResourceStringPtr
--;
2834 bool wxEatWhiteSpaceString(char *s
)
2838 while ((ch
= getc_string(s
)) != EOF
)
2850 ch
= getc_string(s
);
2861 while ((ch
= getc_string(s
)) != EOF
)
2863 if (ch
== '/' && prev_ch
== '*')
2885 bool wxGetResourceTokenString(char *s
)
2887 if (!wxResourceBuffer
)
2888 wxReallocateResourceBuffer();
2889 wxResourceBuffer
[0] = 0;
2890 wxEatWhiteSpaceString(s
);
2892 int ch
= getc_string(s
);
2896 wxResourceBufferCount
= 0;
2897 ch
= getc_string(s
);
2903 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2906 // Escaped characters
2907 else if (ch
== '\\')
2909 int newCh
= getc_string(s
);
2912 else if (newCh
== 10)
2920 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2921 wxReallocateResourceBuffer();
2922 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
2923 wxResourceBufferCount
++;
2924 ch
= getc_string(s
);
2926 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2930 wxResourceBufferCount
= 0;
2932 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
2934 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2935 wxReallocateResourceBuffer();
2936 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
2937 wxResourceBufferCount
++;
2939 ch
= getc_string(s
);
2941 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2949 * Files are in form:
2950 static char *name = "....";
2951 with possible comments.
2954 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
2957 table
= wxDefaultResourceTable
;
2959 // static or #define
2960 if (!wxGetResourceTokenString(s
))
2966 if (strcmp(wxResourceBuffer
, "#define") == 0)
2968 wxGetResourceTokenString(s
);
2969 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2970 wxGetResourceTokenString(s
);
2971 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2972 if (wxIsdigit(value
[0]))
2974 int val
= (int)wxAtol(value
);
2975 wxResourceAddIdentifier(name
, val
, table
);
2979 wxLogWarning(_("#define %s must be an integer."), name
);
2990 else if (strcmp(wxResourceBuffer, "#include") == 0)
2992 wxGetResourceTokenString(s);
2993 char *name = copystring(wxResourceBuffer);
2994 char *actualName = name;
2996 actualName = name + 1;
2997 int len = strlen(name);
2998 if ((len > 0) && (name[len-1] == '"'))
3000 if (!wxResourceParseIncludeFile(actualName, table))
3003 sprintf(buf, _("Could not find resource include file %s."), actualName);
3010 else if (strcmp(wxResourceBuffer
, "static") != 0)
3013 wxStrcpy(buf
, _("Found "));
3014 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
3015 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
3021 if (!wxGetResourceTokenString(s
))
3023 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3028 if (strcmp(wxResourceBuffer
, "char") != 0)
3030 wxLogWarning(_("Expected 'char' whilst parsing resource."));
3035 if (!wxGetResourceTokenString(s
))
3037 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3042 if (wxResourceBuffer
[0] != '*')
3044 wxLogWarning(_("Expected '*' whilst parsing resource."));
3047 wxChar nameBuf
[100];
3048 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
3052 if (!wxGetResourceTokenString(s
))
3054 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3059 if (strcmp(wxResourceBuffer
, "=") != 0)
3061 wxLogWarning(_("Expected '=' whilst parsing resource."));
3066 if (!wxGetResourceTokenString(s
))
3068 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3074 if (!db
.ReadPrologFromString(wxResourceBuffer
))
3076 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
3081 if (!wxGetResourceTokenString(s
))
3088 bool wxResourceParseString(char *s
, wxResourceTable
*table
)
3091 table
= wxDefaultResourceTable
;
3096 // Turn backslashes into spaces
3099 int len
= strlen(s
);
3101 for (i
= 0; i
< len
; i
++)
3102 if (s
[i
] == 92 && s
[i
+1] == 13)
3110 wxResourceStringPtr
= 0;
3113 while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
)
3117 return wxResourceInterpretResources(*table
, db
);
3121 * resource loading facility
3124 bool wxWindowBase::LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
)
3127 table
= wxDefaultResourceTable
;
3129 wxItemResource
*resource
= table
->FindResource((const wxChar
*)resourceName
);
3130 // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
3131 if (!resource
|| (resource
->GetType() == wxT("")) ||
3132 ! ((resource
->GetType() == wxT("wxDialog")) || (resource
->GetType() == wxT("wxPanel"))))
3135 wxString
title(resource
->GetTitle());
3136 long theWindowStyle
= resource
->GetStyle();
3137 bool isModal
= (resource
->GetValue1() != 0);
3138 int x
= resource
->GetX();
3139 int y
= resource
->GetY();
3140 int width
= resource
->GetWidth();
3141 int height
= resource
->GetHeight();
3142 wxString name
= resource
->GetName();
3144 if (IsKindOf(CLASSINFO(wxDialog
)))
3146 wxDialog
*dialogBox
= (wxDialog
*)this;
3147 long modalStyle
= isModal
? wxDIALOG_MODAL
: 0;
3148 if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
))
3151 // Only reset the client size if we know we're not going to do it again below.
3152 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0)
3153 dialogBox
->SetClientSize(width
, height
);
3155 else if (IsKindOf(CLASSINFO(wxPanel
)))
3157 wxPanel
* panel
= (wxPanel
*)this;
3158 if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
| wxTAB_TRAVERSAL
, name
))
3163 if (!((wxWindow
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
))
3167 if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
3169 // No need to do this since it's done in wxPanel or wxDialog constructor.
3170 // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
3174 if (resource
->GetFont().Ok())
3175 SetFont(resource
->GetFont());
3176 if (resource
->GetBackgroundColour().Ok())
3177 SetBackgroundColour(resource
->GetBackgroundColour());
3180 // Should have some kind of font at this point
3181 if (!GetFont().Ok())
3182 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
3183 if (!GetBackgroundColour().Ok())
3184 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
3186 // Only when we've created the window and set the font can we set the correct size,
3187 // if based on dialog units.
3188 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
3190 wxSize sz
= ConvertDialogToPixels(wxSize(width
, height
));
3191 SetClientSize(sz
.x
, sz
.y
);
3193 wxPoint pt
= ConvertDialogToPixels(wxPoint(x
, y
));
3197 // Now create children
3198 wxNode
*node
= resource
->GetChildren().First();
3201 wxItemResource
*childResource
= (wxItemResource
*)node
->Data();
3203 (void) CreateItem(childResource
, resource
, table
);
3205 node
= node
->Next();
3210 wxControl
*wxWindowBase::CreateItem(const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
)
3213 table
= wxDefaultResourceTable
;
3214 return table
->CreateItem((wxWindow
*)this, resource
, parentResource
);
3218 #pragma warning(default:4706) // assignment within conditional expression
3224 #endif // wxUSE_WX_RESOURCES