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())
540 control
->SetFont(childResource
->GetFont());
546 * Interpret database as a series of resources
549 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
)
551 wxNode
*node
= db
.First();
554 wxExpr
*clause
= (wxExpr
*)node
->Data();
555 wxString
functor(clause
->Functor());
557 wxItemResource
*item
= (wxItemResource
*) NULL
;
558 if (functor
== wxT("dialog"))
559 item
= wxResourceInterpretDialog(table
, clause
);
560 else if (functor
== wxT("panel"))
561 item
= wxResourceInterpretDialog(table
, clause
, TRUE
);
562 else if (functor
== wxT("menubar"))
563 item
= wxResourceInterpretMenuBar(table
, clause
);
564 else if (functor
== wxT("menu"))
565 item
= wxResourceInterpretMenu(table
, clause
);
566 else if (functor
== wxT("string"))
567 item
= wxResourceInterpretString(table
, clause
);
568 else if (functor
== wxT("bitmap"))
569 item
= wxResourceInterpretBitmap(table
, clause
);
570 else if (functor
== wxT("icon"))
571 item
= wxResourceInterpretIcon(table
, clause
);
575 // Remove any existing resource of same name
576 if (item
->GetName() != wxT(""))
577 table
.DeleteResource(item
->GetName());
578 table
.AddResource(item
);
585 static const wxChar
*g_ValidControlClasses
[] =
588 wxT("wxBitmapButton"),
591 wxT("wxStaticBitmap"),
597 wxT("wxRadioButton"),
599 wxT("wxBitmapCheckBox"),
609 static bool wxIsValidControlClass(const wxString
& c
)
611 for ( size_t i
= 0; i
< WXSIZEOF(g_ValidControlClasses
); i
++ )
613 if ( c
== g_ValidControlClasses
[i
] )
619 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
)
621 wxItemResource
*dialogItem
= new wxItemResource
;
623 dialogItem
->SetType(wxT("wxPanel"));
625 dialogItem
->SetType(wxT("wxDialog"));
626 wxString style
= wxT("");
627 wxString title
= wxT("");
628 wxString name
= wxT("");
629 wxString backColourHex
= wxT("");
630 wxString labelColourHex
= wxT("");
631 wxString buttonColourHex
= wxT("");
633 long windowStyle
= wxDEFAULT_DIALOG_STYLE
;
637 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
639 wxExpr
*labelFontExpr
= (wxExpr
*) NULL
;
640 wxExpr
*buttonFontExpr
= (wxExpr
*) NULL
;
641 wxExpr
*fontExpr
= (wxExpr
*) NULL
;
642 expr
->GetAttributeValue(wxT("style"), style
);
643 expr
->GetAttributeValue(wxT("name"), name
);
644 expr
->GetAttributeValue(wxT("title"), title
);
645 expr
->GetAttributeValue(wxT("x"), x
);
646 expr
->GetAttributeValue(wxT("y"), y
);
647 expr
->GetAttributeValue(wxT("width"), width
);
648 expr
->GetAttributeValue(wxT("height"), height
);
649 expr
->GetAttributeValue(wxT("modal"), isModal
);
650 expr
->GetAttributeValue(wxT("label_font"), &labelFontExpr
);
651 expr
->GetAttributeValue(wxT("button_font"), &buttonFontExpr
);
652 expr
->GetAttributeValue(wxT("font"), &fontExpr
);
653 expr
->GetAttributeValue(wxT("background_colour"), backColourHex
);
654 expr
->GetAttributeValue(wxT("label_colour"), labelColourHex
);
655 expr
->GetAttributeValue(wxT("button_colour"), buttonColourHex
);
657 int useDialogUnits
= 0;
658 expr
->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits
);
659 if (useDialogUnits
!= 0)
660 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
);
663 expr
->GetAttributeValue(wxT("use_system_defaults"), useDefaults
);
664 if (useDefaults
!= 0)
665 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
);
668 expr
->GetAttributeValue(wxT("id"), id
);
669 dialogItem
->SetId(id
);
671 if (style
!= wxT(""))
673 windowStyle
= wxParseWindowStyle(style
);
675 dialogItem
->SetStyle(windowStyle
);
676 dialogItem
->SetValue1(isModal
);
677 if (windowStyle
& wxDIALOG_MODAL
) // Uses style in wxWin 2
678 dialogItem
->SetValue1(TRUE
);
680 dialogItem
->SetName(name
);
681 dialogItem
->SetTitle(title
);
682 dialogItem
->SetSize(x
, y
, width
, height
);
684 if (backColourHex
!= wxT(""))
689 r
= wxHexToDec(backColourHex
.Mid(0, 2));
690 g
= wxHexToDec(backColourHex
.Mid(2, 2));
691 b
= wxHexToDec(backColourHex
.Mid(4, 2));
692 dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
694 if (labelColourHex
!= wxT(""))
699 r
= wxHexToDec(labelColourHex
.Mid(0, 2));
700 g
= wxHexToDec(labelColourHex
.Mid(2, 2));
701 b
= wxHexToDec(labelColourHex
.Mid(4, 2));
702 dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
704 if (buttonColourHex
!= wxT(""))
709 r
= wxHexToDec(buttonColourHex
.Mid(0, 2));
710 g
= wxHexToDec(buttonColourHex
.Mid(2, 2));
711 b
= wxHexToDec(buttonColourHex
.Mid(4, 2));
712 dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
716 dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
));
717 else if (buttonFontExpr
)
718 dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
));
719 else if (labelFontExpr
)
720 dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
));
722 // Now parse all controls
723 wxExpr
*controlExpr
= expr
->GetFirst();
726 if (controlExpr
->Number() == 3)
728 wxString
controlKeyword(controlExpr
->Nth(1)->StringValue());
729 if (controlKeyword
!= wxT("") && controlKeyword
== wxT("control"))
731 // The value part: always a list.
732 wxExpr
*listExpr
= controlExpr
->Nth(2);
733 if (listExpr
->Type() == PrologList
)
735 wxItemResource
*controlItem
= wxResourceInterpretControl(table
, listExpr
);
738 dialogItem
->GetChildren().Append(controlItem
);
743 controlExpr
= controlExpr
->GetNext();
748 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
)
750 wxItemResource
*controlItem
= new wxItemResource
;
752 // First, find the standard features of a control definition:
753 // [optional integer/string id], control name, title, style, name, x, y, width, height
755 wxString controlType
;
760 long windowStyle
= 0;
761 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
764 wxExpr
*expr1
= expr
->Nth(0);
766 if ( expr1
->Type() == PrologString
|| expr1
->Type() == PrologWord
)
768 if ( wxIsValidControlClass(expr1
->StringValue()) )
771 controlType
= expr1
->StringValue();
775 wxString
str(expr1
->StringValue());
776 id
= wxResourceGetIdentifier(str
, &table
);
779 wxLogWarning(_("Could not resolve control class or id '%s'. "
780 "Use (non-zero) integer instead\n or provide #define "
781 "(see manual for caveats)"),
782 (const wxChar
*) expr1
->StringValue());
784 return (wxItemResource
*) NULL
;
788 // Success - we have an id, so the 2nd element must be the control class.
789 controlType
= expr
->Nth(1)->StringValue();
794 else if (expr1
->Type() == PrologInteger
)
796 id
= (int)expr1
->IntegerValue();
797 // Success - we have an id, so the 2nd element must be the control class.
798 controlType
= expr
->Nth(1)->StringValue();
802 expr1
= expr
->Nth(count
);
805 title
= expr1
->StringValue();
807 expr1
= expr
->Nth(count
);
811 style
= expr1
->StringValue();
812 windowStyle
= wxParseWindowStyle(style
);
815 expr1
= expr
->Nth(count
);
818 name
= expr1
->StringValue();
820 expr1
= expr
->Nth(count
);
823 x
= (int)expr1
->IntegerValue();
825 expr1
= expr
->Nth(count
);
828 y
= (int)expr1
->IntegerValue();
830 expr1
= expr
->Nth(count
);
833 width
= (int)expr1
->IntegerValue();
835 expr1
= expr
->Nth(count
);
838 height
= (int)expr1
->IntegerValue();
840 controlItem
->SetStyle(windowStyle
);
841 controlItem
->SetName(name
);
842 controlItem
->SetTitle(title
);
843 controlItem
->SetSize(x
, y
, width
, height
);
844 controlItem
->SetType(controlType
);
845 controlItem
->SetId(id
);
847 if (controlType
== wxT("wxButton"))
849 // Check for bitmap resource name (in case loading old-style resource file)
850 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
852 wxString
str(expr
->Nth(count
)->StringValue());
857 controlItem
->SetValue4(str
);
858 controlItem
->SetType(wxT("wxBitmapButton"));
861 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
862 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
864 else if (controlType
== wxT("wxBitmapButton"))
866 // Check for bitmap resource name
867 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
869 wxString
str(expr
->Nth(count
)->StringValue());
870 controlItem
->SetValue4(str
);
872 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
873 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
876 else if (controlType
== wxT("wxCheckBox"))
878 // Check for default value
879 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
881 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
883 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
884 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
888 else if (controlType
== wxT("wxRadioButton"))
890 // Check for default value
891 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
893 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
895 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
896 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
900 else if (controlType
== wxT("wxText") || controlType
== wxT("wxTextCtrl") || controlType
== wxT("wxMultiText"))
902 // Check for default value
903 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
905 wxString
str(expr
->Nth(count
)->StringValue());
906 controlItem
->SetValue4(str
);
909 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
911 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
912 // Skip past the obsolete label font spec if there are two consecutive specs
913 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
915 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
919 else if (controlType
== wxT("wxMessage") || controlType
== wxT("wxStaticText"))
921 // Check for bitmap resource name (in case it's an old-style .wxr file)
922 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
924 wxString
str(expr
->Nth(count
)->StringValue());
925 controlItem
->SetValue4(str
);
927 controlItem
->SetType(wxT("wxStaticText"));
929 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
930 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
932 else if (controlType
== wxT("wxStaticBitmap"))
934 // Check for bitmap resource name
935 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
937 wxString
str(expr
->Nth(count
)->StringValue());
938 controlItem
->SetValue4(str
);
941 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
942 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
944 else if (controlType
== wxT("wxGroupBox") || controlType
== wxT("wxStaticBox"))
946 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
947 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
949 else if (controlType
== wxT("wxGauge"))
951 // Check for default value
952 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
954 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
958 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
960 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
963 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
965 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
969 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
970 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
975 else if (controlType
== wxT("wxSlider"))
977 // Check for default value
978 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
980 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
984 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
986 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
990 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
992 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
995 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
997 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1001 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1002 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1008 else if (controlType
== wxT("wxScrollBar"))
1011 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1013 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1017 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1019 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1023 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1025 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1029 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1030 controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue());
1035 else if (controlType
== wxT("wxListBox"))
1037 wxExpr
*valueList
= (wxExpr
*) NULL
;
1039 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1041 wxStringList stringList
;
1042 wxExpr
*stringExpr
= valueList
->GetFirst();
1045 stringList
.Add(stringExpr
->StringValue());
1046 stringExpr
= stringExpr
->GetNext();
1048 controlItem
->SetStringValues(stringList
);
1050 // This is now obsolete: it's in the window style.
1051 // Check for wxSINGLE/wxMULTIPLE
1052 wxExpr
*mult
= (wxExpr
*) NULL
;
1054 controlItem->SetValue1(wxLB_SINGLE);
1056 if ((mult
= expr
->Nth(count
)) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
)))
1059 wxString m(mult->StringValue());
1060 if (m == "wxLB_MULTIPLE")
1061 controlItem->SetValue1(wxLB_MULTIPLE);
1062 else if (m == "wxLB_EXTENDED")
1063 controlItem->SetValue1(wxLB_EXTENDED);
1068 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1070 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1072 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1073 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1077 else if (controlType
== wxT("wxChoice"))
1079 wxExpr
*valueList
= (wxExpr
*) NULL
;
1080 // Check for default value list
1081 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1083 wxStringList stringList
;
1084 wxExpr
*stringExpr
= valueList
->GetFirst();
1087 stringList
.Add(stringExpr
->StringValue());
1088 stringExpr
= stringExpr
->GetNext();
1090 controlItem
->SetStringValues(stringList
);
1094 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1096 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1099 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1100 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1105 else if (controlType
== wxT("wxComboBox"))
1107 wxExpr
*textValue
= expr
->Nth(count
);
1108 if (textValue
&& (textValue
->Type() == PrologString
|| textValue
->Type() == PrologWord
))
1110 wxString
str(textValue
->StringValue());
1111 controlItem
->SetValue4(str
);
1115 wxExpr
*valueList
= (wxExpr
*) NULL
;
1116 // Check for default value list
1117 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1119 wxStringList stringList
;
1120 wxExpr
*stringExpr
= valueList
->GetFirst();
1123 stringList
.Add(stringExpr
->StringValue());
1124 stringExpr
= stringExpr
->GetNext();
1126 controlItem
->SetStringValues(stringList
);
1130 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1132 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1135 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1136 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1143 else if (controlType
== wxT("wxRadioBox"))
1145 wxExpr
*valueList
= (wxExpr
*) NULL
;
1146 // Check for default value list
1147 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1149 wxStringList stringList
;
1150 wxExpr
*stringExpr
= valueList
->GetFirst();
1153 stringList
.Add(stringExpr
->StringValue());
1154 stringExpr
= stringExpr
->GetNext();
1156 controlItem
->SetStringValues(stringList
);
1159 // majorDim (number of rows or cols)
1160 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1162 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1166 controlItem
->SetValue1(0);
1168 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1170 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1173 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1174 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1182 return (wxItemResource
*) NULL
;
1187 // Forward declaration
1188 wxItemResource
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr
*expr
);
1191 * Interpet a menu item
1194 wxItemResource
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr
*expr
)
1196 wxItemResource
*item
= new wxItemResource
;
1198 wxExpr
*labelExpr
= expr
->Nth(0);
1199 wxExpr
*idExpr
= expr
->Nth(1);
1200 wxExpr
*helpExpr
= expr
->Nth(2);
1201 wxExpr
*checkableExpr
= expr
->Nth(3);
1203 // Further keywords/attributes to follow sometime...
1204 if (expr
->Number() == 0)
1206 // item->SetType(wxRESOURCE_TYPE_SEPARATOR);
1207 item
->SetType(wxT("wxMenuSeparator"));
1212 // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
1213 item
->SetType(wxT("wxMenu")); // Well, menu item, but doesn't matter.
1216 wxString
str(labelExpr
->StringValue());
1217 item
->SetTitle(str
);
1222 // If a string or word, must look up in identifier table.
1223 if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
))
1225 wxString
str(idExpr
->StringValue());
1226 id
= wxResourceGetIdentifier(str
, &table
);
1229 wxLogWarning(_("Could not resolve menu id '%s'. "
1230 "Use (non-zero) integer instead\n"
1231 "or provide #define (see manual for caveats)"),
1232 (const wxChar
*) idExpr
->StringValue());
1235 else if (idExpr
->Type() == PrologInteger
)
1236 id
= (int)idExpr
->IntegerValue();
1237 item
->SetValue1(id
);
1241 wxString
str(helpExpr
->StringValue());
1242 item
->SetValue4(str
);
1245 item
->SetValue2(checkableExpr
->IntegerValue());
1247 // Find the first expression that's a list, for submenu
1248 wxExpr
*subMenuExpr
= expr
->GetFirst();
1249 while (subMenuExpr
&& (subMenuExpr
->Type() != PrologList
))
1250 subMenuExpr
= subMenuExpr
->GetNext();
1254 wxItemResource
*child
= wxResourceInterpretMenuItem(table
, subMenuExpr
);
1255 item
->GetChildren().Append(child
);
1256 subMenuExpr
= subMenuExpr
->GetNext();
1263 * Interpret a nested list as a menu
1266 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
1268 wxItemResource *menu = new wxItemResource;
1269 // menu->SetType(wxTYPE_MENU);
1270 menu->SetType("wxMenu");
1271 wxExpr *element = expr->GetFirst();
1274 wxItemResource *item = wxResourceInterpretMenuItem(table, element);
1276 menu->GetChildren().Append(item);
1277 element = element->GetNext();
1283 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
)
1285 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1286 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1288 return (wxItemResource
*) NULL
;
1290 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1293 return (wxItemResource
*) NULL
;
1296 if (expr
->GetAttributeValue(wxT("name"), name
))
1298 menuResource
->SetName(name
);
1301 return menuResource
;
1304 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
)
1306 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1307 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1309 return (wxItemResource
*) NULL
;
1311 wxItemResource
*resource
= new wxItemResource
;
1312 resource
->SetType(wxT("wxMenu"));
1313 // resource->SetType(wxTYPE_MENU);
1315 wxExpr
*element
= listExpr
->GetFirst();
1318 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1319 resource
->GetChildren().Append(menuResource
);
1320 element
= element
->GetNext();
1324 if (expr
->GetAttributeValue(wxT("name"), name
))
1326 resource
->SetName(name
);
1332 wxItemResource
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr
*WXUNUSED(expr
))
1334 return (wxItemResource
*) NULL
;
1337 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr
*expr
)
1339 wxItemResource
*bitmapItem
= new wxItemResource
;
1340 // bitmapItem->SetType(wxTYPE_BITMAP);
1341 bitmapItem
->SetType(wxT("wxBitmap"));
1343 if (expr
->GetAttributeValue(wxT("name"), name
))
1345 bitmapItem
->SetName(name
);
1347 // Now parse all bitmap specifications
1348 wxExpr
*bitmapExpr
= expr
->GetFirst();
1351 if (bitmapExpr
->Number() == 3)
1353 wxString
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue());
1354 if (bitmapKeyword
== wxT("bitmap") || bitmapKeyword
== wxT("icon"))
1356 // The value part: always a list.
1357 wxExpr
*listExpr
= bitmapExpr
->Nth(2);
1358 if (listExpr
->Type() == PrologList
)
1360 wxItemResource
*bitmapSpec
= new wxItemResource
;
1361 // bitmapSpec->SetType(wxTYPE_BITMAP);
1362 bitmapSpec
->SetType(wxT("wxBitmap"));
1364 // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
1365 // where everything after 'filename' is optional.
1366 wxExpr
*nameExpr
= listExpr
->Nth(0);
1367 wxExpr
*typeExpr
= listExpr
->Nth(1);
1368 wxExpr
*platformExpr
= listExpr
->Nth(2);
1369 wxExpr
*coloursExpr
= listExpr
->Nth(3);
1370 wxExpr
*xresExpr
= listExpr
->Nth(4);
1371 wxExpr
*yresExpr
= listExpr
->Nth(5);
1372 if (nameExpr
&& nameExpr
->StringValue() != wxT(""))
1374 bitmapSpec
->SetName(nameExpr
->StringValue());
1376 if (typeExpr
&& typeExpr
->StringValue() != wxT(""))
1378 bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue()));
1381 bitmapSpec
->SetValue1(0);
1383 if (platformExpr
&& platformExpr
->StringValue() != wxT(""))
1385 wxString
plat(platformExpr
->StringValue());
1386 if (plat
== wxT("windows") || plat
== wxT("WINDOWS"))
1387 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
);
1388 else if (plat
== wxT("x") || plat
== wxT("X"))
1389 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
);
1390 else if (plat
== wxT("mac") || plat
== wxT("MAC"))
1391 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
);
1393 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1396 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1399 bitmapSpec
->SetValue3(coloursExpr
->IntegerValue());
1403 xres
= (int)xresExpr
->IntegerValue();
1405 yres
= (int)yresExpr
->IntegerValue();
1406 bitmapSpec
->SetSize(0, 0, xres
, yres
);
1408 bitmapItem
->GetChildren().Append(bitmapSpec
);
1412 bitmapExpr
= bitmapExpr
->GetNext();
1418 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
)
1420 wxItemResource
*item
= wxResourceInterpretBitmap(table
, expr
);
1423 // item->SetType(wxTYPE_ICON);
1424 item
->SetType(wxT("wxIcon"));
1428 return (wxItemResource
*) NULL
;
1431 // Interpret list expression as a font
1432 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
)
1434 if (expr
->Type() != PrologList
)
1438 int family
= wxSWISS
;
1439 int style
= wxNORMAL
;
1440 int weight
= wxNORMAL
;
1442 wxString
faceName(wxT(""));
1444 wxExpr
*pointExpr
= expr
->Nth(0);
1445 wxExpr
*familyExpr
= expr
->Nth(1);
1446 wxExpr
*styleExpr
= expr
->Nth(2);
1447 wxExpr
*weightExpr
= expr
->Nth(3);
1448 wxExpr
*underlineExpr
= expr
->Nth(4);
1449 wxExpr
*faceNameExpr
= expr
->Nth(5);
1451 point
= (int)pointExpr
->IntegerValue();
1456 str
= familyExpr
->StringValue();
1457 family
= (int)wxParseWindowStyle(str
);
1461 str
= styleExpr
->StringValue();
1462 style
= (int)wxParseWindowStyle(str
);
1466 str
= weightExpr
->StringValue();
1467 weight
= (int)wxParseWindowStyle(str
);
1470 underline
= (int)underlineExpr
->IntegerValue();
1472 faceName
= faceNameExpr
->StringValue();
1474 wxFont
font(point
, family
, style
, weight
, (underline
!= 0), faceName
);
1478 // Separate file for the remainder of this, for BC++/Win16
1480 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
1482 * (Re)allocate buffer for reading in from resource file
1485 bool wxReallocateResourceBuffer()
1487 if (!wxResourceBuffer
)
1489 wxResourceBufferSize
= 1000;
1490 wxResourceBuffer
= new char[wxResourceBufferSize
];
1493 if (wxResourceBuffer
)
1495 long newSize
= wxResourceBufferSize
+ 1000;
1496 char *tmp
= new char[(int)newSize
];
1497 strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
);
1498 delete[] wxResourceBuffer
;
1499 wxResourceBuffer
= tmp
;
1500 wxResourceBufferSize
= newSize
;
1505 static bool wxEatWhiteSpace(FILE *fd
)
1509 while ((ch
= getc(fd
)) != EOF
)
1524 ungetc(prev_ch
, fd
);
1532 while ((ch
= getc(fd
)) != EOF
)
1534 if (ch
== '/' && prev_ch
== '*')
1542 static char buffer
[255];
1543 fgets(buffer
, 255, fd
);
1547 ungetc(prev_ch
, fd
);
1561 static bool wxEatWhiteSpace(wxInputStream
*is
)
1563 int ch
= is
->GetC() ;
1564 if ((ch
!= ' ') && (ch
!= '/') && (ch
!= ' ') && (ch
!= 10) && (ch
!= 13) && (ch
!= 9))
1571 while (ch
== ' ' || ch
== 10 || ch
== 13 || ch
== 9)
1573 // Check for comment
1579 bool finished
= FALSE
;
1587 int newCh
= is
->GetC();
1602 return wxEatWhiteSpace(is
);
1605 bool wxGetResourceToken(FILE *fd
)
1607 if (!wxResourceBuffer
)
1608 wxReallocateResourceBuffer();
1609 wxResourceBuffer
[0] = 0;
1610 wxEatWhiteSpace(fd
);
1616 wxResourceBufferCount
= 0;
1623 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1626 // Escaped characters
1627 else if (ch
== '\\')
1629 int newCh
= getc(fd
);
1632 else if (newCh
== 10)
1640 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1641 wxReallocateResourceBuffer();
1642 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1643 wxResourceBufferCount
++;
1646 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1650 wxResourceBufferCount
= 0;
1652 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1654 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1655 wxReallocateResourceBuffer();
1656 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1657 wxResourceBufferCount
++;
1661 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1668 bool wxGetResourceToken(wxInputStream
*is
)
1670 if (!wxResourceBuffer
)
1671 wxReallocateResourceBuffer();
1672 wxResourceBuffer
[0] = 0;
1673 wxEatWhiteSpace(is
);
1675 int ch
= is
->GetC() ;
1679 wxResourceBufferCount
= 0;
1686 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1689 // Escaped characters
1690 else if (ch
== '\\')
1692 int newCh
= is
->GetC();
1695 else if (newCh
== 10)
1697 else if (newCh
== 13) // mac
1705 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1706 wxReallocateResourceBuffer();
1707 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1708 wxResourceBufferCount
++;
1711 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1715 wxResourceBufferCount
= 0;
1717 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1719 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1720 wxReallocateResourceBuffer();
1721 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1722 wxResourceBufferCount
++;
1726 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1734 * Files are in form:
1735 static char *name = "....";
1736 with possible comments.
1739 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1742 table
= wxDefaultResourceTable
;
1744 // static or #define
1745 if (!wxGetResourceToken(fd
))
1751 if (strcmp(wxResourceBuffer
, "#define") == 0)
1753 wxGetResourceToken(fd
);
1754 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1755 wxGetResourceToken(fd
);
1756 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1757 if (wxIsdigit(value
[0]))
1759 int val
= (int)wxAtol(value
);
1760 wxResourceAddIdentifier(name
, val
, table
);
1764 wxLogWarning(_("#define %s must be an integer."), name
);
1774 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1776 wxGetResourceToken(fd
);
1777 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1778 wxChar
*actualName
= name
;
1779 if (name
[0] == wxT('"'))
1780 actualName
= name
+ 1;
1781 int len
= wxStrlen(name
);
1782 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1784 if (!wxResourceParseIncludeFile(actualName
, table
))
1786 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1791 else if (strcmp(wxResourceBuffer
, "static") != 0)
1794 wxStrcpy(buf
, _("Found "));
1795 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
1796 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1802 if (!wxGetResourceToken(fd
))
1804 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1809 if (strcmp(wxResourceBuffer
, "char") != 0)
1811 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1816 if (!wxGetResourceToken(fd
))
1818 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1823 if (wxResourceBuffer
[0] != '*')
1825 wxLogWarning(_("Expected '*' whilst parsing resource."));
1828 wxChar nameBuf
[100];
1829 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
1833 if (!wxGetResourceToken(fd
))
1835 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1840 if (strcmp(wxResourceBuffer
, "=") != 0)
1842 wxLogWarning(_("Expected '=' whilst parsing resource."));
1847 if (!wxGetResourceToken(fd
))
1849 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1855 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1857 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1862 if (!wxGetResourceToken(fd
))
1869 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1872 table
= wxDefaultResourceTable
;
1874 // static or #define
1875 if (!wxGetResourceToken(fd
))
1881 if (strcmp(wxResourceBuffer
, "#define") == 0)
1883 wxGetResourceToken(fd
);
1884 char *name
= copystring(wxResourceBuffer
);
1885 wxGetResourceToken(fd
);
1886 char *value
= copystring(wxResourceBuffer
);
1887 if (isalpha(value
[0]))
1889 int val
= (int)atol(value
);
1890 wxResourceAddIdentifier(name
, val
, table
);
1894 wxLogWarning(_("#define %s must be an integer."), name
);
1904 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1906 wxGetResourceToken(fd
);
1907 char *name
= copystring(wxResourceBuffer
);
1908 char *actualName
= name
;
1910 actualName
= name
+ 1;
1911 int len
= strlen(name
);
1912 if ((len
> 0) && (name
[len
-1] == '"'))
1914 if (!wxResourceParseIncludeFile(actualName
, table
))
1916 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1921 else if (strcmp(wxResourceBuffer
, "static") != 0)
1924 strcpy(buf
, _("Found "));
1925 strncat(buf
, wxResourceBuffer
, 30);
1926 strcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1932 if (!wxGetResourceToken(fd
))
1934 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1939 if (strcmp(wxResourceBuffer
, "char") != 0)
1941 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1946 if (!wxGetResourceToken(fd
))
1948 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1953 if (wxResourceBuffer
[0] != '*')
1955 wxLogWarning(_("Expected '*' whilst parsing resource."));
1959 strncpy(nameBuf
, wxResourceBuffer
+1, 99);
1962 if (!wxGetResourceToken(fd
))
1964 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1969 if (strcmp(wxResourceBuffer
, "=") != 0)
1971 wxLogWarning(_("Expected '=' whilst parsing resource."));
1976 if (!wxGetResourceToken(fd
))
1978 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1984 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1986 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1991 if (!wxGetResourceToken(fd
))
1999 * Parses string window style into integer window style
2003 * Style flag parsing, e.g.
2004 * "wxSYSTEM_MENU | wxBORDER" -> integer
2007 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
)
2010 return (wxChar
*) NULL
;
2012 static wxChar buf
[150];
2013 int len
= wxStrlen(s
);
2016 while ((ii
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == wxT('_'))))
2024 // Eat whitespace and conjunction characters
2025 while ((ii
< len
) &&
2026 ((s
[ii
] == wxT(' ')) || (s
[ii
] == wxT('|')) || (s
[ii
] == wxT(','))))
2032 return (wxChar
*) NULL
;
2037 struct wxResourceBitListStruct
2043 static wxResourceBitListStruct wxResourceBitListTable
[] =
2046 { wxT("wxSINGLE"), wxLB_SINGLE
},
2047 { wxT("wxMULTIPLE"), wxLB_MULTIPLE
},
2048 { wxT("wxEXTENDED"), wxLB_EXTENDED
},
2049 { wxT("wxLB_SINGLE"), wxLB_SINGLE
},
2050 { wxT("wxLB_MULTIPLE"), wxLB_MULTIPLE
},
2051 { wxT("wxLB_EXTENDED"), wxLB_EXTENDED
},
2052 { wxT("wxLB_NEEDED_SB"), wxLB_NEEDED_SB
},
2053 { wxT("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB
},
2054 { wxT("wxLB_SORT"), wxLB_SORT
},
2055 { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW
},
2056 { wxT("wxLB_HSCROLL"), wxLB_HSCROLL
},
2059 { wxT("wxCB_SIMPLE"), wxCB_SIMPLE
},
2060 { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN
},
2061 { wxT("wxCB_READONLY"), wxCB_READONLY
},
2062 { wxT("wxCB_SORT"), wxCB_SORT
},
2065 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR
},
2066 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL
},
2067 { wxT("wxGA_VERTICAL"), wxGA_VERTICAL
},
2070 { wxT("wxPASSWORD"), wxPASSWORD
},
2071 { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER
},
2072 { wxT("wxTE_PASSWORD"), wxTE_PASSWORD
},
2073 { wxT("wxTE_READONLY"), wxTE_READONLY
},
2074 { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
},
2075 { wxT("wxTE_MULTILINE"), wxTE_MULTILINE
},
2076 { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL
},
2078 /* wxRadioBox/wxRadioButton */
2079 { wxT("wxRB_GROUP"), wxRB_GROUP
},
2080 { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS
},
2081 { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS
},
2082 { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL
},
2083 { wxT("wxRA_VERTICAL"), wxRA_VERTICAL
},
2086 { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL
},
2087 { wxT("wxSL_VERTICAL"), wxSL_VERTICAL
},
2088 { wxT("wxSL_AUTOTICKS"), wxSL_AUTOTICKS
},
2089 { wxT("wxSL_LABELS"), wxSL_LABELS
},
2090 { wxT("wxSL_LEFT"), wxSL_LEFT
},
2091 { wxT("wxSL_TOP"), wxSL_TOP
},
2092 { wxT("wxSL_RIGHT"), wxSL_RIGHT
},
2093 { wxT("wxSL_BOTTOM"), wxSL_BOTTOM
},
2094 { wxT("wxSL_BOTH"), wxSL_BOTH
},
2095 { wxT("wxSL_SELRANGE"), wxSL_SELRANGE
},
2098 { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL
},
2099 { wxT("wxSB_VERTICAL"), wxSB_VERTICAL
},
2102 { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW
},
2103 { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW
},
2106 { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS
},
2107 { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS
},
2108 { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT
},
2111 { wxT("wxLC_ICON"), wxLC_ICON
},
2112 { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON
},
2113 { wxT("wxLC_LIST"), wxLC_LIST
},
2114 { wxT("wxLC_REPORT"), wxLC_REPORT
},
2115 { wxT("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP
},
2116 { wxT("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT
},
2117 { wxT("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE
},
2118 { wxT("wxLC_USER_TEXT"), wxLC_USER_TEXT
},
2119 { wxT("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS
},
2120 { wxT("wxLC_NO_HEADER"), wxLC_NO_HEADER
},
2121 { wxT("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER
},
2122 { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL
},
2123 { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING
},
2124 { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING
},
2127 { wxT("wxSP_VERTICAL"), wxSP_VERTICAL
},
2128 { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
},
2129 { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
},
2130 { wxT("wxSP_WRAP"), wxSP_WRAP
},
2133 { wxT("wxSP_NOBORDER"), wxSP_NOBORDER
},
2134 { wxT("wxSP_3D"), wxSP_3D
},
2135 { wxT("wxSP_BORDER"), wxSP_BORDER
},
2138 { wxT("wxTC_MULTILINE"), wxTC_MULTILINE
},
2139 { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
},
2140 { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
},
2141 { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
},
2144 { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP
},
2147 { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH
},
2148 { wxT("wxALIGN_LEFT"), wxALIGN_LEFT
},
2149 { wxT("wxALIGN_CENTER"), wxALIGN_CENTER
},
2150 { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE
},
2151 { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT
},
2152 { wxT("wxCOLOURED"), wxCOLOURED
},
2155 { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
},
2156 { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
},
2157 { wxT("wxTB_VERTICAL"), wxTB_VERTICAL
},
2158 { wxT("wxTB_FLAT"), wxTB_FLAT
},
2161 { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL
},
2164 { wxT("wxVSCROLL"), wxVSCROLL
},
2165 { wxT("wxHSCROLL"), wxHSCROLL
},
2166 { wxT("wxCAPTION"), wxCAPTION
},
2167 { wxT("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
},
2168 { wxT("wxICONIZE"), wxICONIZE
},
2169 { wxT("wxMINIMIZE"), wxICONIZE
},
2170 { wxT("wxMAXIMIZE"), wxMAXIMIZE
},
2172 { wxT("wxMDI_PARENT"), 0},
2173 { wxT("wxMDI_CHILD"), 0},
2174 { wxT("wxTHICK_FRAME"), wxTHICK_FRAME
},
2175 { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER
},
2176 { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU
},
2177 { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
},
2178 { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
},
2179 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX
},
2180 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
},
2181 { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
},
2182 { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
},
2183 { wxT("wxBORDER"), wxBORDER
},
2184 { wxT("wxRETAINED"), wxRETAINED
},
2185 { wxT("wxNATIVE_IMPL"), 0},
2186 { wxT("wxEXTENDED_IMPL"), 0},
2187 { wxT("wxBACKINGSTORE"), wxBACKINGSTORE
},
2188 // { wxT("wxFLAT"), wxFLAT},
2189 // { wxT("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
2190 { wxT("wxFIXED_LENGTH"), 0},
2191 { wxT("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
},
2192 { wxT("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
},
2193 { wxT("wxRAISED_BORDER"), wxRAISED_BORDER
},
2194 { wxT("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
},
2195 { wxT("wxSTATIC_BORDER"), wxSTATIC_BORDER
},
2196 { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
},
2197 { wxT("wxNO_BORDER"), wxNO_BORDER
},
2198 { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
},
2199 { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
2201 { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
},
2202 { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
},
2204 // Text font families
2205 { wxT("wxDEFAULT"), wxDEFAULT
},
2206 { wxT("wxDECORATIVE"), wxDECORATIVE
},
2207 { wxT("wxROMAN"), wxROMAN
},
2208 { wxT("wxSCRIPT"), wxSCRIPT
},
2209 { wxT("wxSWISS"), wxSWISS
},
2210 { wxT("wxMODERN"), wxMODERN
},
2211 { wxT("wxTELETYPE"), wxTELETYPE
},
2212 { wxT("wxVARIABLE"), wxVARIABLE
},
2213 { wxT("wxFIXED"), wxFIXED
},
2214 { wxT("wxNORMAL"), wxNORMAL
},
2215 { wxT("wxLIGHT"), wxLIGHT
},
2216 { wxT("wxBOLD"), wxBOLD
},
2217 { wxT("wxITALIC"), wxITALIC
},
2218 { wxT("wxSLANT"), wxSLANT
},
2219 { wxT("wxSOLID"), wxSOLID
},
2220 { wxT("wxDOT"), wxDOT
},
2221 { wxT("wxLONG_DASH"), wxLONG_DASH
},
2222 { wxT("wxSHORT_DASH"), wxSHORT_DASH
},
2223 { wxT("wxDOT_DASH"), wxDOT_DASH
},
2224 { wxT("wxUSER_DASH"), wxUSER_DASH
},
2225 { wxT("wxTRANSPARENT"), wxTRANSPARENT
},
2226 { wxT("wxSTIPPLE"), wxSTIPPLE
},
2227 { wxT("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
},
2228 { wxT("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
},
2229 { wxT("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
},
2230 { wxT("wxCROSS_HATCH"), wxCROSS_HATCH
},
2231 { wxT("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
},
2232 { wxT("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
},
2233 { wxT("wxJOIN_BEVEL"), wxJOIN_BEVEL
},
2234 { wxT("wxJOIN_MITER"), wxJOIN_MITER
},
2235 { wxT("wxJOIN_ROUND"), wxJOIN_ROUND
},
2236 { wxT("wxCAP_ROUND"), wxCAP_ROUND
},
2237 { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING
},
2238 { wxT("wxCAP_BUTT"), wxCAP_BUTT
},
2241 { wxT("wxCLEAR"), wxCLEAR
},
2242 { wxT("wxXOR"), wxXOR
},
2243 { wxT("wxINVERT"), wxINVERT
},
2244 { wxT("wxOR_REVERSE"), wxOR_REVERSE
},
2245 { wxT("wxAND_REVERSE"), wxAND_REVERSE
},
2246 { wxT("wxCOPY"), wxCOPY
},
2247 { wxT("wxAND"), wxAND
},
2248 { wxT("wxAND_INVERT"), wxAND_INVERT
},
2249 { wxT("wxNO_OP"), wxNO_OP
},
2250 { wxT("wxNOR"), wxNOR
},
2251 { wxT("wxEQUIV"), wxEQUIV
},
2252 { wxT("wxSRC_INVERT"), wxSRC_INVERT
},
2253 { wxT("wxOR_INVERT"), wxOR_INVERT
},
2254 { wxT("wxNAND"), wxNAND
},
2255 { wxT("wxOR"), wxOR
},
2256 { wxT("wxSET"), wxSET
},
2258 { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
},
2259 { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER
},
2260 { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE
},
2261 { wxT("wxWINDING_RULE"), wxWINDING_RULE
},
2262 { wxT("wxHORIZONTAL"), wxHORIZONTAL
},
2263 { wxT("wxVERTICAL"), wxVERTICAL
},
2264 { wxT("wxBOTH"), wxBOTH
},
2265 { wxT("wxCENTER_FRAME"), wxCENTER_FRAME
},
2266 { wxT("wxOK"), wxOK
},
2267 { wxT("wxYES_NO"), wxYES_NO
},
2268 { wxT("wxCANCEL"), wxCANCEL
},
2269 { wxT("wxYES"), wxYES
},
2270 { wxT("wxNO"), wxNO
},
2271 { wxT("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
},
2272 { wxT("wxICON_HAND"), wxICON_HAND
},
2273 { wxT("wxICON_QUESTION"), wxICON_QUESTION
},
2274 { wxT("wxICON_INFORMATION"), wxICON_INFORMATION
},
2275 { wxT("wxICON_STOP"), wxICON_STOP
},
2276 { wxT("wxICON_ASTERISK"), wxICON_ASTERISK
},
2277 { wxT("wxICON_MASK"), wxICON_MASK
},
2278 { wxT("wxCENTRE"), wxCENTRE
},
2279 { wxT("wxCENTER"), wxCENTRE
},
2280 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS
},
2281 { wxT("wxVERTICAL_LABEL"), 0},
2282 { wxT("wxHORIZONTAL_LABEL"), 0},
2284 // Bitmap types (not strictly styles)
2285 { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
},
2286 { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
},
2287 { wxT("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
},
2288 { wxT("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2289 { wxT("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2290 { wxT("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
},
2291 { wxT("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
},
2292 { wxT("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
},
2293 { wxT("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
},
2294 { wxT("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
},
2295 { wxT("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
},
2296 { wxT("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
},
2297 { wxT("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
},
2298 { wxT("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
}
2301 static int wxResourceBitListCount
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
));
2303 long wxParseWindowStyle(const wxString
& bitListString
)
2308 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2309 while (word
!= NULL
)
2313 for (j
= 0; j
< wxResourceBitListCount
; j
++)
2314 if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0)
2316 bitList
|= wxResourceBitListTable
[j
].bits
;
2322 wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
);
2325 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2331 * Load a bitmap from a wxWindows resource, choosing an optimum
2332 * depth and appropriate type.
2335 wxBitmap
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable
*table
)
2338 table
= wxDefaultResourceTable
;
2340 wxItemResource
*item
= table
->FindResource(resource
);
2343 if ((item
->GetType() == wxT("")) || (item
->GetType() != wxT("wxBitmap")))
2345 wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
);
2346 return wxNullBitmap
;
2348 int thisDepth
= wxDisplayDepth();
2349 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2351 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2353 // Try to find optimum bitmap for this platform/colour depth
2354 wxNode
*node
= item
->GetChildren().First();
2357 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2358 int platform
= (int)child
->GetValue2();
2359 int noColours
= (int)child
->GetValue3();
2361 char *name = child->GetName();
2362 int bitmapType = (int)child->GetValue1();
2363 int xRes = child->GetWidth();
2364 int yRes = child->GetHeight();
2369 case RESOURCE_PLATFORM_ANY
:
2371 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2372 optResource
= child
;
2375 // Maximise the number of colours.
2376 // If noColours is zero (unspecified), then assume this
2377 // is the right one.
2378 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2379 optResource
= child
;
2384 case RESOURCE_PLATFORM_WINDOWS
:
2386 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2387 optResource
= child
;
2390 // Maximise the number of colours
2391 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2392 optResource
= child
;
2398 case RESOURCE_PLATFORM_X
:
2400 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2401 optResource
= child
;
2404 // Maximise the number of colours
2405 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2406 optResource
= child
;
2412 case RESOURCE_PLATFORM_MAC
:
2414 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2415 optResource
= child
;
2418 // Maximise the number of colours
2419 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2420 optResource
= child
;
2428 node
= node
->Next();
2430 // If no matching resource, fail.
2432 return wxNullBitmap
;
2434 wxString name
= optResource
->GetName();
2435 int bitmapType
= (int)optResource
->GetValue1();
2438 case wxBITMAP_TYPE_XBM_DATA
:
2441 wxItemResource
*item
= table
->FindResource(name
);
2444 wxLogWarning(_("Failed to find XBM resource %s.\n"
2445 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2446 return wxNullBitmap
;
2448 return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ;
2450 wxLogWarning(_("No XBM facility available!"));
2454 case wxBITMAP_TYPE_XPM_DATA
:
2456 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2457 wxItemResource
*item
= table
->FindResource(name
);
2460 wxLogWarning(_("Failed to find XPM resource %s.\n"
2461 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2462 return wxNullBitmap
;
2464 return wxBitmap((char **)item
->GetValue1());
2466 wxLogWarning(_("No XPM facility available!"));
2472 return wxBitmap(name
, bitmapType
);
2475 return wxNullBitmap
;
2479 wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
);
2480 return wxNullBitmap
;
2485 * Load an icon from a wxWindows resource, choosing an optimum
2486 * depth and appropriate type.
2489 wxIcon
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable
*table
)
2492 table
= wxDefaultResourceTable
;
2494 wxItemResource
*item
= table
->FindResource(resource
);
2497 if ((item
->GetType() == wxT("")) || wxStrcmp(item
->GetType(), wxT("wxIcon")) != 0)
2499 wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
);
2502 int thisDepth
= wxDisplayDepth();
2503 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2505 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2507 // Try to find optimum icon for this platform/colour depth
2508 wxNode
*node
= item
->GetChildren().First();
2511 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2512 int platform
= (int)child
->GetValue2();
2513 int noColours
= (int)child
->GetValue3();
2515 char *name = child->GetName();
2516 int bitmapType = (int)child->GetValue1();
2517 int xRes = child->GetWidth();
2518 int yRes = child->GetHeight();
2523 case RESOURCE_PLATFORM_ANY
:
2525 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2526 optResource
= child
;
2529 // Maximise the number of colours.
2530 // If noColours is zero (unspecified), then assume this
2531 // is the right one.
2532 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2533 optResource
= child
;
2538 case RESOURCE_PLATFORM_WINDOWS
:
2540 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2541 optResource
= child
;
2544 // Maximise the number of colours
2545 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2546 optResource
= child
;
2552 case RESOURCE_PLATFORM_X
:
2554 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2555 optResource
= child
;
2558 // Maximise the number of colours
2559 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2560 optResource
= child
;
2566 case RESOURCE_PLATFORM_MAC
:
2568 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2569 optResource
= child
;
2572 // Maximise the number of colours
2573 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2574 optResource
= child
;
2582 node
= node
->Next();
2584 // If no matching resource, fail.
2588 wxString name
= optResource
->GetName();
2589 int bitmapType
= (int)optResource
->GetValue1();
2592 case wxBITMAP_TYPE_XBM_DATA
:
2595 wxItemResource
*item
= table
->FindResource(name
);
2598 wxLogWarning(_("Failed to find XBM resource %s.\n"
2599 "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
);
2602 return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3());
2604 wxLogWarning(_("No XBM facility available!"));
2608 case wxBITMAP_TYPE_XPM_DATA
:
2610 // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
2612 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2613 wxItemResource *item = table->FindResource(name);
2617 sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name);
2621 return wxIcon((char **)item->GetValue1());
2623 wxLogWarning(_("No XPM facility available!"));
2626 wxLogWarning(_("No XPM icon facility available!"));
2632 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2634 return wxIcon(name
, bitmapType
);
2643 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2648 wxMenu
*wxResourceCreateMenu(wxItemResource
*item
)
2650 wxMenu
*menu
= new wxMenu
;
2651 wxNode
*node
= item
->GetChildren().First();
2654 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2655 if ((child
->GetType() != wxT("")) && (child
->GetType() == wxT("wxMenuSeparator")))
2656 menu
->AppendSeparator();
2657 else if (child
->GetChildren().Number() > 0)
2659 wxMenu
*subMenu
= wxResourceCreateMenu(child
);
2661 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4());
2665 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0));
2667 node
= node
->Next();
2672 wxMenuBar
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable
*table
, wxMenuBar
*menuBar
)
2675 table
= wxDefaultResourceTable
;
2677 wxItemResource
*menuResource
= table
->FindResource(resource
);
2678 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2681 menuBar
= new wxMenuBar
;
2682 wxNode
*node
= menuResource
->GetChildren().First();
2685 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2686 wxMenu
*menu
= wxResourceCreateMenu(child
);
2688 menuBar
->Append(menu
, child
->GetTitle());
2689 node
= node
->Next();
2693 return (wxMenuBar
*) NULL
;
2696 wxMenu
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable
*table
)
2699 table
= wxDefaultResourceTable
;
2701 wxItemResource
*menuResource
= table
->FindResource(resource
);
2702 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2703 // if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
2704 return wxResourceCreateMenu(menuResource
);
2705 return (wxMenu
*) NULL
;
2708 // Global equivalents (so don't have to refer to default table explicitly)
2709 bool wxResourceParseData(const wxString
& resource
, wxResourceTable
*table
)
2712 table
= wxDefaultResourceTable
;
2714 return table
->ParseResourceData(resource
);
2717 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable
*table
)
2720 table
= wxDefaultResourceTable
;
2722 return table
->ParseResourceFile(filename
);
2725 // Register XBM/XPM data
2726 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable
*table
)
2729 table
= wxDefaultResourceTable
;
2731 return table
->RegisterResourceBitmapData(name
, bits
, width
, height
);
2734 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable
*table
)
2737 table
= wxDefaultResourceTable
;
2739 return table
->RegisterResourceBitmapData(name
, data
);
2742 void wxResourceClear(wxResourceTable
*table
)
2745 table
= wxDefaultResourceTable
;
2747 table
->ClearTable();
2754 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable
*table
)
2757 table
= wxDefaultResourceTable
;
2759 table
->identifiers
.Put(name
, (wxObject
*)(long)value
);
2763 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable
*table
)
2766 table
= wxDefaultResourceTable
;
2768 return (int)(long)table
->identifiers
.Get(name
);
2772 * Parse #include file for #defines (only)
2775 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
)
2778 table
= wxDefaultResourceTable
;
2780 FILE *fd
= fopen(f
.fn_str(), "r");
2785 while (wxGetResourceToken(fd
))
2787 if (strcmp(wxResourceBuffer
, "#define") == 0)
2789 wxGetResourceToken(fd
);
2790 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2791 wxGetResourceToken(fd
);
2792 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2793 if (wxIsdigit(value
[0]))
2795 int val
= (int)wxAtol(value
);
2796 wxResourceAddIdentifier(name
, val
, table
);
2807 * Reading strings as if they were .wxr files
2810 static int getc_string(char *s
)
2812 int ch
= s
[wxResourceStringPtr
];
2817 wxResourceStringPtr
++;
2822 static int ungetc_string()
2824 wxResourceStringPtr
--;
2828 bool wxEatWhiteSpaceString(char *s
)
2832 while ((ch
= getc_string(s
)) != EOF
)
2844 ch
= getc_string(s
);
2855 while ((ch
= getc_string(s
)) != EOF
)
2857 if (ch
== '/' && prev_ch
== '*')
2879 bool wxGetResourceTokenString(char *s
)
2881 if (!wxResourceBuffer
)
2882 wxReallocateResourceBuffer();
2883 wxResourceBuffer
[0] = 0;
2884 wxEatWhiteSpaceString(s
);
2886 int ch
= getc_string(s
);
2890 wxResourceBufferCount
= 0;
2891 ch
= getc_string(s
);
2897 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2900 // Escaped characters
2901 else if (ch
== '\\')
2903 int newCh
= getc_string(s
);
2906 else if (newCh
== 10)
2914 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2915 wxReallocateResourceBuffer();
2916 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
2917 wxResourceBufferCount
++;
2918 ch
= getc_string(s
);
2920 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2924 wxResourceBufferCount
= 0;
2926 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
2928 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2929 wxReallocateResourceBuffer();
2930 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
2931 wxResourceBufferCount
++;
2933 ch
= getc_string(s
);
2935 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2943 * Files are in form:
2944 static char *name = "....";
2945 with possible comments.
2948 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
2951 table
= wxDefaultResourceTable
;
2953 // static or #define
2954 if (!wxGetResourceTokenString(s
))
2960 if (strcmp(wxResourceBuffer
, "#define") == 0)
2962 wxGetResourceTokenString(s
);
2963 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2964 wxGetResourceTokenString(s
);
2965 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2966 if (wxIsdigit(value
[0]))
2968 int val
= (int)wxAtol(value
);
2969 wxResourceAddIdentifier(name
, val
, table
);
2973 wxLogWarning(_("#define %s must be an integer."), name
);
2984 else if (strcmp(wxResourceBuffer, "#include") == 0)
2986 wxGetResourceTokenString(s);
2987 char *name = copystring(wxResourceBuffer);
2988 char *actualName = name;
2990 actualName = name + 1;
2991 int len = strlen(name);
2992 if ((len > 0) && (name[len-1] == '"'))
2994 if (!wxResourceParseIncludeFile(actualName, table))
2997 sprintf(buf, _("Could not find resource include file %s."), actualName);
3004 else if (strcmp(wxResourceBuffer
, "static") != 0)
3007 wxStrcpy(buf
, _("Found "));
3008 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
3009 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
3015 if (!wxGetResourceTokenString(s
))
3017 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3022 if (strcmp(wxResourceBuffer
, "char") != 0)
3024 wxLogWarning(_("Expected 'char' whilst parsing resource."));
3029 if (!wxGetResourceTokenString(s
))
3031 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3036 if (wxResourceBuffer
[0] != '*')
3038 wxLogWarning(_("Expected '*' whilst parsing resource."));
3041 wxChar nameBuf
[100];
3042 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
3046 if (!wxGetResourceTokenString(s
))
3048 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3053 if (strcmp(wxResourceBuffer
, "=") != 0)
3055 wxLogWarning(_("Expected '=' whilst parsing resource."));
3060 if (!wxGetResourceTokenString(s
))
3062 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3068 if (!db
.ReadPrologFromString(wxResourceBuffer
))
3070 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
3075 if (!wxGetResourceTokenString(s
))
3082 bool wxResourceParseString(char *s
, wxResourceTable
*table
)
3085 table
= wxDefaultResourceTable
;
3090 // Turn backslashes into spaces
3093 int len
= strlen(s
);
3095 for (i
= 0; i
< len
; i
++)
3096 if (s
[i
] == 92 && s
[i
+1] == 13)
3104 wxResourceStringPtr
= 0;
3107 while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
)
3111 return wxResourceInterpretResources(*table
, db
);
3115 * resource loading facility
3118 bool wxWindowBase::LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
)
3121 table
= wxDefaultResourceTable
;
3123 wxItemResource
*resource
= table
->FindResource((const wxChar
*)resourceName
);
3124 // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
3125 if (!resource
|| (resource
->GetType() == wxT("")) ||
3126 ! ((resource
->GetType() == wxT("wxDialog")) || (resource
->GetType() == wxT("wxPanel"))))
3129 wxString
title(resource
->GetTitle());
3130 long theWindowStyle
= resource
->GetStyle();
3131 bool isModal
= (resource
->GetValue1() != 0);
3132 int x
= resource
->GetX();
3133 int y
= resource
->GetY();
3134 int width
= resource
->GetWidth();
3135 int height
= resource
->GetHeight();
3136 wxString name
= resource
->GetName();
3138 if (IsKindOf(CLASSINFO(wxDialog
)))
3140 wxDialog
*dialogBox
= (wxDialog
*)this;
3141 long modalStyle
= isModal
? wxDIALOG_MODAL
: 0;
3142 if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
))
3145 // Only reset the client size if we know we're not going to do it again below.
3146 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0)
3147 dialogBox
->SetClientSize(width
, height
);
3149 else if (IsKindOf(CLASSINFO(wxPanel
)))
3151 wxPanel
* panel
= (wxPanel
*)this;
3152 if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
| wxTAB_TRAVERSAL
, name
))
3157 if (!((wxWindow
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
))
3161 if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
3163 // No need to do this since it's done in wxPanel or wxDialog constructor.
3164 // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
3168 if (resource
->GetFont().Ok())
3169 SetFont(resource
->GetFont());
3170 if (resource
->GetBackgroundColour().Ok())
3171 SetBackgroundColour(resource
->GetBackgroundColour());
3174 // Should have some kind of font at this point
3175 if (!GetFont().Ok())
3176 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
3177 if (!GetBackgroundColour().Ok())
3178 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
3180 // Only when we've created the window and set the font can we set the correct size,
3181 // if based on dialog units.
3182 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
3184 wxSize sz
= ConvertDialogToPixels(wxSize(width
, height
));
3185 SetClientSize(sz
.x
, sz
.y
);
3187 wxPoint pt
= ConvertDialogToPixels(wxPoint(x
, y
));
3191 // Now create children
3192 wxNode
*node
= resource
->GetChildren().First();
3195 wxItemResource
*childResource
= (wxItemResource
*)node
->Data();
3197 (void) CreateItem(childResource
, resource
, table
);
3199 node
= node
->Next();
3204 wxControl
*wxWindowBase::CreateItem(const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
)
3207 table
= wxDefaultResourceTable
;
3208 return table
->CreateItem((wxWindow
*)this, resource
, parentResource
);
3212 #pragma warning(default:4706) // assignment within conditional expression
3218 #endif // wxUSE_WX_RESOURCES