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"
56 #include "wx/listctrl.h"
59 #include "wx/radiobut.h"
63 #include "wx/scrolbar.h"
67 #include "wx/combobox.h"
70 #include "wx/validate.h"
79 #include "wx/resource.h"
80 #include "wx/string.h"
81 #include "wx/wxexpr.h"
83 #include "wx/settings.h"
84 #include "wx/stream.h"
86 // Forward (private) declarations
87 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
);
88 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
= FALSE
);
89 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
);
90 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
);
91 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
);
92 wxItemResource
*wxResourceInterpretString(wxResourceTable
& table
, wxExpr
*expr
);
93 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& table
, wxExpr
*expr
);
94 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
);
95 // Interpret list expression
96 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
);
98 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
99 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
) ;
100 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
= (wxResourceTable
*) NULL
);
102 wxResourceTable
*wxDefaultResourceTable
= (wxResourceTable
*) NULL
;
104 char *wxResourceBuffer
= (char *) NULL
;
105 long wxResourceBufferSize
= 0;
106 long wxResourceBufferCount
= 0;
107 int wxResourceStringPtr
= 0;
109 void wxInitializeResourceSystem()
111 wxDefaultResourceTable
= new wxResourceTable
;
114 void wxCleanUpResourceSystem()
116 delete wxDefaultResourceTable
;
117 if (wxResourceBuffer
)
118 delete[] wxResourceBuffer
;
121 void wxLogWarning(char *msg
)
123 wxMessageBox(msg
, _("Warning"), wxOK
);
126 IMPLEMENT_DYNAMIC_CLASS(wxItemResource
, wxObject
)
127 IMPLEMENT_DYNAMIC_CLASS(wxResourceTable
, wxHashTable
)
129 wxItemResource::wxItemResource()
135 m_x
= m_y
= m_width
= m_height
= 0;
136 m_value1
= m_value2
= m_value3
= m_value5
= 0;
142 wxItemResource::~wxItemResource()
144 wxNode
*node
= m_children
.First();
147 wxItemResource
*item
= (wxItemResource
*)node
->Data();
150 node
= m_children
.First();
158 wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING
), identifiers(wxKEY_STRING
)
162 wxResourceTable::~wxResourceTable()
167 wxItemResource
*wxResourceTable::FindResource(const wxString
& name
) const
169 wxItemResource
*item
= (wxItemResource
*)Get(WXSTRINGCAST name
);
173 void wxResourceTable::AddResource(wxItemResource
*item
)
175 wxString name
= item
->GetName();
177 name
= item
->GetTitle();
179 name
= wxT("no name");
181 // Delete existing resource, if any.
187 bool wxResourceTable::DeleteResource(const wxString
& name
)
189 wxItemResource
*item
= (wxItemResource
*)Delete(WXSTRINGCAST name
);
192 // See if any resource has this as its child; if so, delete from
193 // parent's child list.
195 wxNode
*node
= (wxNode
*) NULL
;
199 wxItemResource
*parent
= (wxItemResource
*)node
->Data();
200 if (parent
->GetChildren().Member(item
))
202 parent
->GetChildren().DeleteObject(item
);
215 bool wxResourceTable::ParseResourceFile( wxInputStream
*is
)
218 int len
= is
->StreamSize() ;
221 while ( is
->TellI() + 10 < len
) // it's a hack because the streams dont support EOF
223 wxResourceReadOneResource(is
, db
, &eof
, this) ;
225 return wxResourceInterpretResources(*this, db
);
228 bool wxResourceTable::ParseResourceFile(const wxString
& filename
)
232 FILE *fd
= wxFopen(filename
, _T("r"));
236 while (wxResourceReadOneResource(fd
, db
, &eof
, this) && !eof
)
241 return wxResourceInterpretResources(*this, db
);
244 bool wxResourceTable::ParseResourceData(const wxString
& data
)
247 if (!db
.ReadFromString(data
))
249 wxLogWarning(_("Ill-formed resource file syntax."));
253 return wxResourceInterpretResources(*this, db
);
256 bool wxResourceTable::RegisterResourceBitmapData(const wxString
& name
, char bits
[], int width
, int height
)
258 // Register pre-loaded bitmap data
259 wxItemResource
*item
= new wxItemResource
;
260 // item->SetType(wxRESOURCE_TYPE_XBM_DATA);
261 item
->SetType(wxT("wxXBMData"));
263 item
->SetValue1((long)bits
);
264 item
->SetValue2((long)width
);
265 item
->SetValue3((long)height
);
270 bool wxResourceTable::RegisterResourceBitmapData(const wxString
& name
, char **data
)
272 // Register pre-loaded bitmap data
273 wxItemResource
*item
= new wxItemResource
;
274 // item->SetType(wxRESOURCE_TYPE_XPM_DATA);
275 item
->SetType(wxT("wxXPMData"));
277 item
->SetValue1((long)data
);
282 bool wxResourceTable::SaveResource(const wxString
& WXUNUSED(filename
))
287 void wxResourceTable::ClearTable()
290 wxNode
*node
= Next();
293 wxNode
*next
= Next();
294 wxItemResource
*item
= (wxItemResource
*)node
->Data();
301 wxControl
*wxResourceTable::CreateItem(wxWindow
*parent
, const wxItemResource
* childResource
, const wxItemResource
* parentResource
) const
303 int id
= childResource
->GetId();
307 bool dlgUnits
= ((parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0);
309 wxControl
*control
= (wxControl
*) NULL
;
310 wxString
itemType(childResource
->GetType());
316 pos
= parent
->ConvertDialogToPixels(wxPoint(childResource
->GetX(), childResource
->GetY()));
317 size
= parent
->ConvertDialogToPixels(wxSize(childResource
->GetWidth(), childResource
->GetHeight()));
321 pos
= wxPoint(childResource
->GetX(), childResource
->GetY());
322 size
= wxSize(childResource
->GetWidth(), childResource
->GetHeight());
325 if (itemType
== wxString(wxT("wxButton")) || itemType
== wxString(wxT("wxBitmapButton")))
327 if (childResource
->GetValue4() != wxT(""))
330 wxBitmap bitmap
= childResource
->GetBitmap();
333 bitmap
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable
*)this);
334 ((wxItemResource
*) childResource
)->SetBitmap(bitmap
);
337 bitmap
.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE
);
338 control
= new wxBitmapButton(parent
, id
, bitmap
, pos
, size
,
339 childResource
->GetStyle() | wxBU_AUTODRAW
, wxDefaultValidator
, childResource
->GetName());
342 // Normal, text button
343 control
= new wxButton(parent
, id
, childResource
->GetTitle(), pos
, size
,
344 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
346 else if (itemType
== wxString(wxT("wxMessage")) || itemType
== wxString(wxT("wxStaticText")) ||
347 itemType
== wxString(wxT("wxStaticBitmap")))
349 if (childResource
->GetValue4() != wxT("") || itemType
== wxString(wxT("wxStaticBitmap")) )
352 wxBitmap bitmap
= childResource
->GetBitmap();
355 bitmap
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable
*)this);
356 ((wxItemResource
*) childResource
)->SetBitmap(bitmap
);
358 #if wxUSE_BITMAP_MESSAGE
360 // Use a default bitmap
362 bitmap
.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE
);
366 control
= new wxStaticBitmap(parent
, id
, bitmap
, pos
, size
,
367 childResource
->GetStyle(), childResource
->GetName());
372 control
= new wxStaticText(parent
, id
, childResource
->GetTitle(), pos
, size
,
373 childResource
->GetStyle(), childResource
->GetName());
376 else if (itemType
== wxString(wxT("wxText")) || itemType
== wxString(wxT("wxTextCtrl")) || itemType
== wxString(wxT("wxMultiText")))
378 control
= new wxTextCtrl(parent
, id
, childResource
->GetValue4(), pos
, size
,
379 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
381 else if (itemType
== wxString(wxT("wxCheckBox")))
383 control
= new wxCheckBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
384 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
386 ((wxCheckBox
*)control
)->SetValue((childResource
->GetValue1() != 0));
389 else if (itemType
== wxString(wxT("wxGauge")))
391 control
= new wxGauge(parent
, id
, (int)childResource
->GetValue2(), pos
, size
,
392 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
394 ((wxGauge
*)control
)->SetValue((int)childResource
->GetValue1());
398 else if (itemType
== wxString(wxT("wxRadioButton")))
400 control
= new wxRadioButton(parent
, id
, childResource
->GetTitle(), // (int)childResource->GetValue1(),
402 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
406 else if (itemType
== wxString(wxT("wxScrollBar")))
408 control
= new wxScrollBar(parent
, id
, pos
, size
,
409 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
411 ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1());
412 ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2());
413 ((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3());
414 ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5());
416 ((wxScrollBar
*)control
)->SetScrollbar((int)childResource
->GetValue1(),(int)childResource
->GetValue2(),
417 (int)childResource
->GetValue3(),(int)(long)childResource
->GetValue5(),FALSE
);
421 else if (itemType
== wxString(wxT("wxSlider")))
423 control
= new wxSlider(parent
, id
, (int)childResource
->GetValue1(),
424 (int)childResource
->GetValue2(), (int)childResource
->GetValue3(), pos
, size
,
425 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
427 else if (itemType
== wxString(wxT("wxGroupBox")) || itemType
== wxString(wxT("wxStaticBox")))
429 control
= new wxStaticBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
430 childResource
->GetStyle(), childResource
->GetName());
432 else if (itemType
== wxString(wxT("wxListBox")))
434 wxStringList
& stringList
= childResource
->GetStringValues();
435 wxString
*strings
= (wxString
*) NULL
;
437 if (stringList
.Number() > 0)
439 noStrings
= stringList
.Number();
440 strings
= new wxString
[noStrings
];
441 wxNode
*node
= stringList
.First();
445 strings
[i
] = (wxChar
*)node
->Data();
450 control
= new wxListBox(parent
, id
, pos
, size
,
451 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
456 else if (itemType
== wxString(wxT("wxChoice")))
458 wxStringList
& stringList
= childResource
->GetStringValues();
459 wxString
*strings
= (wxString
*) NULL
;
461 if (stringList
.Number() > 0)
463 noStrings
= stringList
.Number();
464 strings
= new wxString
[noStrings
];
465 wxNode
*node
= stringList
.First();
469 strings
[i
] = (wxChar
*)node
->Data();
474 control
= new wxChoice(parent
, id
, pos
, size
,
475 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
481 else if (itemType
== wxString(wxT("wxComboBox")))
483 wxStringList
& stringList
= childResource
->GetStringValues();
484 wxString
*strings
= (wxString
*) NULL
;
486 if (stringList
.Number() > 0)
488 noStrings
= stringList
.Number();
489 strings
= new wxString
[noStrings
];
490 wxNode
*node
= stringList
.First();
494 strings
[i
] = (wxChar
*)node
->Data();
499 control
= new wxComboBox(parent
, id
, childResource
->GetValue4(), pos
, size
,
500 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
506 else if (itemType
== wxString(wxT("wxRadioBox")))
508 wxStringList
& stringList
= childResource
->GetStringValues();
509 wxString
*strings
= (wxString
*) NULL
;
511 if (stringList
.Number() > 0)
513 noStrings
= stringList
.Number();
514 strings
= new wxString
[noStrings
];
515 wxNode
*node
= stringList
.First();
519 strings
[i
] = (wxChar
*)node
->Data();
524 control
= new wxRadioBox(parent
, (wxWindowID
) id
, wxString(childResource
->GetTitle()), pos
, size
,
525 noStrings
, strings
, (int)childResource
->GetValue1(), childResource
->GetStyle(), wxDefaultValidator
,
526 childResource
->GetName());
532 if ((parentResource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
534 // Don't set font; will be inherited from parent.
538 if (control
&& childResource
->GetFont().Ok())
540 control
->SetFont(childResource
->GetFont());
543 // Force the layout algorithm since the size changes the layout
544 if (control
->IsKindOf(CLASSINFO(wxRadioBox
)))
546 control
->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH
|wxSIZE_AUTO_HEIGHT
);
555 * Interpret database as a series of resources
558 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
)
560 wxNode
*node
= db
.First();
563 wxExpr
*clause
= (wxExpr
*)node
->Data();
564 wxString
functor(clause
->Functor());
566 wxItemResource
*item
= (wxItemResource
*) NULL
;
567 if (functor
== wxT("dialog"))
568 item
= wxResourceInterpretDialog(table
, clause
);
569 else if (functor
== wxT("panel"))
570 item
= wxResourceInterpretDialog(table
, clause
, TRUE
);
571 else if (functor
== wxT("menubar"))
572 item
= wxResourceInterpretMenuBar(table
, clause
);
573 else if (functor
== wxT("menu"))
574 item
= wxResourceInterpretMenu(table
, clause
);
575 else if (functor
== wxT("string"))
576 item
= wxResourceInterpretString(table
, clause
);
577 else if (functor
== wxT("bitmap"))
578 item
= wxResourceInterpretBitmap(table
, clause
);
579 else if (functor
== wxT("icon"))
580 item
= wxResourceInterpretIcon(table
, clause
);
584 // Remove any existing resource of same name
585 if (item
->GetName() != wxT(""))
586 table
.DeleteResource(item
->GetName());
587 table
.AddResource(item
);
594 static const wxChar
*g_ValidControlClasses
[] =
597 wxT("wxBitmapButton"),
600 wxT("wxStaticBitmap"),
606 wxT("wxRadioButton"),
608 wxT("wxBitmapCheckBox"),
618 static bool wxIsValidControlClass(const wxString
& c
)
620 for ( size_t i
= 0; i
< WXSIZEOF(g_ValidControlClasses
); i
++ )
622 if ( c
== g_ValidControlClasses
[i
] )
628 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
)
630 wxItemResource
*dialogItem
= new wxItemResource
;
632 dialogItem
->SetType(wxT("wxPanel"));
634 dialogItem
->SetType(wxT("wxDialog"));
635 wxString style
= wxT("");
636 wxString title
= wxT("");
637 wxString name
= wxT("");
638 wxString backColourHex
= wxT("");
639 wxString labelColourHex
= wxT("");
640 wxString buttonColourHex
= wxT("");
642 long windowStyle
= wxDEFAULT_DIALOG_STYLE
;
646 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
648 wxExpr
*labelFontExpr
= (wxExpr
*) NULL
;
649 wxExpr
*buttonFontExpr
= (wxExpr
*) NULL
;
650 wxExpr
*fontExpr
= (wxExpr
*) NULL
;
651 expr
->GetAttributeValue(wxT("style"), style
);
652 expr
->GetAttributeValue(wxT("name"), name
);
653 expr
->GetAttributeValue(wxT("title"), title
);
654 expr
->GetAttributeValue(wxT("x"), x
);
655 expr
->GetAttributeValue(wxT("y"), y
);
656 expr
->GetAttributeValue(wxT("width"), width
);
657 expr
->GetAttributeValue(wxT("height"), height
);
658 expr
->GetAttributeValue(wxT("modal"), isModal
);
659 expr
->GetAttributeValue(wxT("label_font"), &labelFontExpr
);
660 expr
->GetAttributeValue(wxT("button_font"), &buttonFontExpr
);
661 expr
->GetAttributeValue(wxT("font"), &fontExpr
);
662 expr
->GetAttributeValue(wxT("background_colour"), backColourHex
);
663 expr
->GetAttributeValue(wxT("label_colour"), labelColourHex
);
664 expr
->GetAttributeValue(wxT("button_colour"), buttonColourHex
);
666 int useDialogUnits
= 0;
667 expr
->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits
);
668 if (useDialogUnits
!= 0)
669 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
);
672 expr
->GetAttributeValue(wxT("use_system_defaults"), useDefaults
);
673 if (useDefaults
!= 0)
674 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
);
677 expr
->GetAttributeValue(wxT("id"), id
);
678 dialogItem
->SetId(id
);
680 if (style
!= wxT(""))
682 windowStyle
= wxParseWindowStyle(style
);
684 dialogItem
->SetStyle(windowStyle
);
685 dialogItem
->SetValue1(isModal
);
686 if (windowStyle
& wxDIALOG_MODAL
) // Uses style in wxWin 2
687 dialogItem
->SetValue1(TRUE
);
689 dialogItem
->SetName(name
);
690 dialogItem
->SetTitle(title
);
691 dialogItem
->SetSize(x
, y
, width
, height
);
693 // Check for wxWin 1.68-style specifications
694 if (style
.Find(wxT("VERTICAL_LABEL")) != -1)
695 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL
);
696 else if (style
.Find(wxT("HORIZONTAL_LABEL")) != -1)
697 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL
);
699 if (backColourHex
!= wxT(""))
704 r
= wxHexToDec(backColourHex
.Mid(0, 2));
705 g
= wxHexToDec(backColourHex
.Mid(2, 2));
706 b
= wxHexToDec(backColourHex
.Mid(4, 2));
707 dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
709 if (labelColourHex
!= wxT(""))
714 r
= wxHexToDec(labelColourHex
.Mid(0, 2));
715 g
= wxHexToDec(labelColourHex
.Mid(2, 2));
716 b
= wxHexToDec(labelColourHex
.Mid(4, 2));
717 dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
719 if (buttonColourHex
!= wxT(""))
724 r
= wxHexToDec(buttonColourHex
.Mid(0, 2));
725 g
= wxHexToDec(buttonColourHex
.Mid(2, 2));
726 b
= wxHexToDec(buttonColourHex
.Mid(4, 2));
727 dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
731 dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
));
732 else if (buttonFontExpr
)
733 dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
));
734 else if (labelFontExpr
)
735 dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
));
737 // Now parse all controls
738 wxExpr
*controlExpr
= expr
->GetFirst();
741 if (controlExpr
->Number() == 3)
743 wxString
controlKeyword(controlExpr
->Nth(1)->StringValue());
744 if (controlKeyword
!= wxT("") && controlKeyword
== wxT("control"))
746 // The value part: always a list.
747 wxExpr
*listExpr
= controlExpr
->Nth(2);
748 if (listExpr
->Type() == PrologList
)
750 wxItemResource
*controlItem
= wxResourceInterpretControl(table
, listExpr
);
753 dialogItem
->GetChildren().Append(controlItem
);
758 controlExpr
= controlExpr
->GetNext();
763 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
)
765 wxItemResource
*controlItem
= new wxItemResource
;
767 // First, find the standard features of a control definition:
768 // [optional integer/string id], control name, title, style, name, x, y, width, height
770 wxString controlType
;
775 long windowStyle
= 0;
776 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
779 wxExpr
*expr1
= expr
->Nth(0);
781 if ( expr1
->Type() == PrologString
|| expr1
->Type() == PrologWord
)
783 if ( wxIsValidControlClass(expr1
->StringValue()) )
786 controlType
= expr1
->StringValue();
790 wxString
str(expr1
->StringValue());
791 id
= wxResourceGetIdentifier(str
, &table
);
794 wxLogWarning(_("Could not resolve control class or id '%s'. Use (non-zero) integer instead\n or provide #define (see manual for caveats)"),
795 (const wxChar
*) expr1
->StringValue());
797 return (wxItemResource
*) NULL
;
801 // Success - we have an id, so the 2nd element must be the control class.
802 controlType
= expr
->Nth(1)->StringValue();
807 else if (expr1
->Type() == PrologInteger
)
809 id
= (int)expr1
->IntegerValue();
810 // Success - we have an id, so the 2nd element must be the control class.
811 controlType
= expr
->Nth(1)->StringValue();
815 expr1
= expr
->Nth(count
);
818 title
= expr1
->StringValue();
820 expr1
= expr
->Nth(count
);
824 style
= expr1
->StringValue();
825 windowStyle
= wxParseWindowStyle(style
);
828 expr1
= expr
->Nth(count
);
831 name
= expr1
->StringValue();
833 expr1
= expr
->Nth(count
);
836 x
= (int)expr1
->IntegerValue();
838 expr1
= expr
->Nth(count
);
841 y
= (int)expr1
->IntegerValue();
843 expr1
= expr
->Nth(count
);
846 width
= (int)expr1
->IntegerValue();
848 expr1
= expr
->Nth(count
);
851 height
= (int)expr1
->IntegerValue();
853 controlItem
->SetStyle(windowStyle
);
854 controlItem
->SetName(name
);
855 controlItem
->SetTitle(title
);
856 controlItem
->SetSize(x
, y
, width
, height
);
857 controlItem
->SetType(controlType
);
858 controlItem
->SetId(id
);
860 // Check for wxWin 1.68-style specifications
861 if (style
.Find(wxT("VERTICAL_LABEL")) != -1)
862 controlItem
->SetResourceStyle(controlItem
->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL
);
863 else if (style
.Find(wxT("HORIZONTAL_LABEL")) != -1)
864 controlItem
->SetResourceStyle(controlItem
->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL
);
866 if (controlType
== wxT("wxButton"))
868 // Check for bitmap resource name (in case loading old-style resource file)
869 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
871 wxString
str(expr
->Nth(count
)->StringValue());
876 controlItem
->SetValue4(str
);
877 controlItem
->SetType(wxT("wxBitmapButton"));
880 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
881 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
883 else if (controlType
== wxT("wxBitmapButton"))
885 // Check for bitmap resource name
886 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
888 wxString
str(expr
->Nth(count
)->StringValue());
889 controlItem
->SetValue4(str
);
891 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
892 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
895 else if (controlType
== wxT("wxCheckBox"))
897 // Check for default value
898 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
900 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
902 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
903 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
907 else if (controlType
== wxT("wxRadioButton"))
909 // Check for default value
910 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
912 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
914 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
915 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
919 else if (controlType
== wxT("wxText") || controlType
== wxT("wxTextCtrl") || controlType
== wxT("wxMultiText"))
921 // Check for default value
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
);
928 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
930 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
931 // Skip past the obsolete label font spec if there are two consecutive specs
932 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
934 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
938 else if (controlType
== wxT("wxMessage") || controlType
== wxT("wxStaticText"))
940 // Check for bitmap resource name (in case it's an old-style .wxr file)
941 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
943 wxString
str(expr
->Nth(count
)->StringValue());
944 controlItem
->SetValue4(str
);
946 controlItem
->SetType(wxT("wxStaticText"));
948 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
949 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
951 else if (controlType
== wxT("wxStaticBitmap"))
953 // Check for bitmap resource name
954 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
956 wxString
str(expr
->Nth(count
)->StringValue());
957 controlItem
->SetValue4(str
);
960 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
961 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
963 else if (controlType
== wxT("wxGroupBox") || controlType
== wxT("wxStaticBox"))
965 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
966 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
968 else if (controlType
== wxT("wxGauge"))
970 // Check for default value
971 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
973 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
977 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
979 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
982 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
984 // Skip past the obsolete label font spec if there are two consecutive specs
985 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
987 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
992 else if (controlType
== wxT("wxSlider"))
994 // Check for default value
995 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
997 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1001 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1003 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1007 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1009 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1012 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1014 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1018 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1019 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1025 else if (controlType
== wxT("wxScrollBar"))
1028 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1030 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1034 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1036 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1040 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1042 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1046 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1047 controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue());
1052 else if (controlType
== wxT("wxListBox"))
1054 wxExpr
*valueList
= (wxExpr
*) NULL
;
1056 if (((valueList
= expr
->Nth(count
)) != 0) && (valueList
->Type() == PrologList
))
1058 wxStringList stringList
;
1059 wxExpr
*stringExpr
= valueList
->GetFirst();
1062 stringList
.Add(stringExpr
->StringValue());
1063 stringExpr
= stringExpr
->GetNext();
1065 controlItem
->SetStringValues(stringList
);
1067 // This is now obsolete: it's in the window style.
1068 // Check for wxSINGLE/wxMULTIPLE
1069 wxExpr
*mult
= (wxExpr
*) NULL
;
1071 controlItem->SetValue1(wxLB_SINGLE);
1073 if (((mult
= expr
->Nth(count
)) != 0) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
)))
1076 wxString m(mult->StringValue());
1077 if (m == "wxLB_MULTIPLE")
1078 controlItem->SetValue1(wxLB_MULTIPLE);
1079 else if (m == "wxLB_EXTENDED")
1080 controlItem->SetValue1(wxLB_EXTENDED);
1085 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1087 // Skip past the obsolete label font spec if there are two consecutive specs
1088 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1090 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1094 else if (controlType
== wxT("wxChoice"))
1096 wxExpr
*valueList
= (wxExpr
*) NULL
;
1097 // Check for default value list
1098 if (((valueList
= expr
->Nth(count
)) != 0) && (valueList
->Type() == PrologList
))
1100 wxStringList stringList
;
1101 wxExpr
*stringExpr
= valueList
->GetFirst();
1104 stringList
.Add(stringExpr
->StringValue());
1105 stringExpr
= stringExpr
->GetNext();
1107 controlItem
->SetStringValues(stringList
);
1111 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1113 // Skip past the obsolete label font spec if there are two consecutive specs
1114 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1116 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1121 else if (controlType
== wxT("wxComboBox"))
1123 wxExpr
*textValue
= expr
->Nth(count
);
1124 if (textValue
&& (textValue
->Type() == PrologString
|| textValue
->Type() == PrologWord
))
1126 wxString
str(textValue
->StringValue());
1127 controlItem
->SetValue4(str
);
1131 wxExpr
*valueList
= (wxExpr
*) NULL
;
1132 // Check for default value list
1133 if (((valueList
= expr
->Nth(count
)) != 0) && (valueList
->Type() == PrologList
))
1135 wxStringList stringList
;
1136 wxExpr
*stringExpr
= valueList
->GetFirst();
1139 stringList
.Add(stringExpr
->StringValue());
1140 stringExpr
= stringExpr
->GetNext();
1142 controlItem
->SetStringValues(stringList
);
1146 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1148 // Skip past the obsolete label font spec if there are two consecutive specs
1149 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1151 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1158 else if (controlType
== wxT("wxRadioBox"))
1160 wxExpr
*valueList
= (wxExpr
*) NULL
;
1161 // Check for default value list
1162 if (((valueList
= expr
->Nth(count
)) != 0) && (valueList
->Type() == PrologList
))
1164 wxStringList stringList
;
1165 wxExpr
*stringExpr
= valueList
->GetFirst();
1168 stringList
.Add(stringExpr
->StringValue());
1169 stringExpr
= stringExpr
->GetNext();
1171 controlItem
->SetStringValues(stringList
);
1174 // majorDim (number of rows or cols)
1175 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1177 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1181 controlItem
->SetValue1(0);
1183 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1185 // Skip past the obsolete label font spec if there are two consecutive specs
1186 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1188 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1196 return (wxItemResource
*) NULL
;
1201 // Forward declaration
1202 wxItemResource
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr
*expr
);
1205 * Interpet a menu item
1208 wxItemResource
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr
*expr
)
1210 wxItemResource
*item
= new wxItemResource
;
1212 wxExpr
*labelExpr
= expr
->Nth(0);
1213 wxExpr
*idExpr
= expr
->Nth(1);
1214 wxExpr
*helpExpr
= expr
->Nth(2);
1215 wxExpr
*checkableExpr
= expr
->Nth(3);
1217 // Further keywords/attributes to follow sometime...
1218 if (expr
->Number() == 0)
1220 // item->SetType(wxRESOURCE_TYPE_SEPARATOR);
1221 item
->SetType(wxT("wxMenuSeparator"));
1226 // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
1227 item
->SetType(wxT("wxMenu")); // Well, menu item, but doesn't matter.
1230 wxString
str(labelExpr
->StringValue());
1231 item
->SetTitle(str
);
1236 // If a string or word, must look up in identifier table.
1237 if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
))
1239 wxString
str(idExpr
->StringValue());
1240 id
= wxResourceGetIdentifier(str
, &table
);
1243 wxLogWarning(_("Could not resolve menu id '%s'. Use (non-zero) integer instead\nor provide #define (see manual for caveats)"),
1244 (const wxChar
*) idExpr
->StringValue());
1247 else if (idExpr
->Type() == PrologInteger
)
1248 id
= (int)idExpr
->IntegerValue();
1249 item
->SetValue1(id
);
1253 wxString
str(helpExpr
->StringValue());
1254 item
->SetValue4(str
);
1257 item
->SetValue2(checkableExpr
->IntegerValue());
1259 // Find the first expression that's a list, for submenu
1260 wxExpr
*subMenuExpr
= expr
->GetFirst();
1261 while (subMenuExpr
&& (subMenuExpr
->Type() != PrologList
))
1262 subMenuExpr
= subMenuExpr
->GetNext();
1266 wxItemResource
*child
= wxResourceInterpretMenuItem(table
, subMenuExpr
);
1267 item
->GetChildren().Append(child
);
1268 subMenuExpr
= subMenuExpr
->GetNext();
1275 * Interpret a nested list as a menu
1278 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
1280 wxItemResource *menu = new wxItemResource;
1281 // menu->SetType(wxTYPE_MENU);
1282 menu->SetType("wxMenu");
1283 wxExpr *element = expr->GetFirst();
1286 wxItemResource *item = wxResourceInterpretMenuItem(table, element);
1288 menu->GetChildren().Append(item);
1289 element = element->GetNext();
1295 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
)
1297 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1298 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1300 return (wxItemResource
*) NULL
;
1302 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1305 return (wxItemResource
*) NULL
;
1308 if (expr
->GetAttributeValue(wxT("name"), name
))
1310 menuResource
->SetName(name
);
1313 return menuResource
;
1316 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
)
1318 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1319 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1321 return (wxItemResource
*) NULL
;
1323 wxItemResource
*resource
= new wxItemResource
;
1324 resource
->SetType(wxT("wxMenu"));
1325 // resource->SetType(wxTYPE_MENU);
1327 wxExpr
*element
= listExpr
->GetFirst();
1330 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1331 resource
->GetChildren().Append(menuResource
);
1332 element
= element
->GetNext();
1336 if (expr
->GetAttributeValue(wxT("name"), name
))
1338 resource
->SetName(name
);
1344 wxItemResource
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr
*WXUNUSED(expr
))
1346 return (wxItemResource
*) NULL
;
1349 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr
*expr
)
1351 wxItemResource
*bitmapItem
= new wxItemResource
;
1352 // bitmapItem->SetType(wxTYPE_BITMAP);
1353 bitmapItem
->SetType(wxT("wxBitmap"));
1355 if (expr
->GetAttributeValue(wxT("name"), name
))
1357 bitmapItem
->SetName(name
);
1359 // Now parse all bitmap specifications
1360 wxExpr
*bitmapExpr
= expr
->GetFirst();
1363 if (bitmapExpr
->Number() == 3)
1365 wxString
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue());
1366 if (bitmapKeyword
== wxT("bitmap") || bitmapKeyword
== wxT("icon"))
1368 // The value part: always a list.
1369 wxExpr
*listExpr
= bitmapExpr
->Nth(2);
1370 if (listExpr
->Type() == PrologList
)
1372 wxItemResource
*bitmapSpec
= new wxItemResource
;
1373 // bitmapSpec->SetType(wxTYPE_BITMAP);
1374 bitmapSpec
->SetType(wxT("wxBitmap"));
1376 // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
1377 // where everything after 'filename' is optional.
1378 wxExpr
*nameExpr
= listExpr
->Nth(0);
1379 wxExpr
*typeExpr
= listExpr
->Nth(1);
1380 wxExpr
*platformExpr
= listExpr
->Nth(2);
1381 wxExpr
*coloursExpr
= listExpr
->Nth(3);
1382 wxExpr
*xresExpr
= listExpr
->Nth(4);
1383 wxExpr
*yresExpr
= listExpr
->Nth(5);
1384 if (nameExpr
&& nameExpr
->StringValue() != wxT(""))
1386 bitmapSpec
->SetName(nameExpr
->StringValue());
1388 if (typeExpr
&& typeExpr
->StringValue() != wxT(""))
1390 bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue()));
1393 bitmapSpec
->SetValue1(0);
1395 if (platformExpr
&& platformExpr
->StringValue() != wxT(""))
1397 wxString
plat(platformExpr
->StringValue());
1398 if (plat
== wxT("windows") || plat
== wxT("WINDOWS"))
1399 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
);
1400 else if (plat
== wxT("x") || plat
== wxT("X"))
1401 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
);
1402 else if (plat
== wxT("mac") || plat
== wxT("MAC"))
1403 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
);
1405 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1408 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1411 bitmapSpec
->SetValue3(coloursExpr
->IntegerValue());
1415 xres
= (int)xresExpr
->IntegerValue();
1417 yres
= (int)yresExpr
->IntegerValue();
1418 bitmapSpec
->SetSize(0, 0, xres
, yres
);
1420 bitmapItem
->GetChildren().Append(bitmapSpec
);
1424 bitmapExpr
= bitmapExpr
->GetNext();
1430 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
)
1432 wxItemResource
*item
= wxResourceInterpretBitmap(table
, expr
);
1435 // item->SetType(wxTYPE_ICON);
1436 item
->SetType(wxT("wxIcon"));
1440 return (wxItemResource
*) NULL
;
1443 // Interpret list expression as a font
1444 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
)
1446 if (expr
->Type() != PrologList
)
1450 int family
= wxSWISS
;
1451 int style
= wxNORMAL
;
1452 int weight
= wxNORMAL
;
1454 wxString
faceName(wxT(""));
1456 wxExpr
*pointExpr
= expr
->Nth(0);
1457 wxExpr
*familyExpr
= expr
->Nth(1);
1458 wxExpr
*styleExpr
= expr
->Nth(2);
1459 wxExpr
*weightExpr
= expr
->Nth(3);
1460 wxExpr
*underlineExpr
= expr
->Nth(4);
1461 wxExpr
*faceNameExpr
= expr
->Nth(5);
1463 point
= (int)pointExpr
->IntegerValue();
1468 str
= familyExpr
->StringValue();
1469 family
= (int)wxParseWindowStyle(str
);
1473 str
= styleExpr
->StringValue();
1474 style
= (int)wxParseWindowStyle(str
);
1478 str
= weightExpr
->StringValue();
1479 weight
= (int)wxParseWindowStyle(str
);
1482 underline
= (int)underlineExpr
->IntegerValue();
1484 faceName
= faceNameExpr
->StringValue();
1486 wxFont
font(point
, family
, style
, weight
, (underline
!= 0), faceName
);
1490 // Separate file for the remainder of this, for BC++/Win16
1492 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
1494 * (Re)allocate buffer for reading in from resource file
1497 bool wxReallocateResourceBuffer()
1499 if (!wxResourceBuffer
)
1501 wxResourceBufferSize
= 1000;
1502 wxResourceBuffer
= new char[wxResourceBufferSize
];
1505 if (wxResourceBuffer
)
1507 long newSize
= wxResourceBufferSize
+ 1000;
1508 char *tmp
= new char[(int)newSize
];
1509 strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
);
1510 delete[] wxResourceBuffer
;
1511 wxResourceBuffer
= tmp
;
1512 wxResourceBufferSize
= newSize
;
1517 static bool wxEatWhiteSpace(FILE *fd
)
1521 while ((ch
= getc(fd
)) != EOF
)
1536 ungetc(prev_ch
, fd
);
1544 while ((ch
= getc(fd
)) != EOF
)
1546 if (ch
== '/' && prev_ch
== '*')
1554 static char buffer
[255];
1555 fgets(buffer
, 255, fd
);
1559 ungetc(prev_ch
, fd
);
1573 static bool wxEatWhiteSpace(wxInputStream
*is
)
1575 int ch
= is
->GetC() ;
1576 if ((ch
!= ' ') && (ch
!= '/') && (ch
!= ' ') && (ch
!= 10) && (ch
!= 13) && (ch
!= 9))
1583 while (ch
== ' ' || ch
== 10 || ch
== 13 || ch
== 9)
1585 // Check for comment
1591 bool finished
= FALSE
;
1599 int newCh
= is
->GetC();
1614 return wxEatWhiteSpace(is
);
1617 bool wxGetResourceToken(FILE *fd
)
1619 if (!wxResourceBuffer
)
1620 wxReallocateResourceBuffer();
1621 wxResourceBuffer
[0] = 0;
1622 wxEatWhiteSpace(fd
);
1628 wxResourceBufferCount
= 0;
1635 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1638 // Escaped characters
1639 else if (ch
== '\\')
1641 int newCh
= getc(fd
);
1644 else if (newCh
== 10)
1652 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1653 wxReallocateResourceBuffer();
1654 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1655 wxResourceBufferCount
++;
1658 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1662 wxResourceBufferCount
= 0;
1664 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1666 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1667 wxReallocateResourceBuffer();
1668 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1669 wxResourceBufferCount
++;
1673 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1680 bool wxGetResourceToken(wxInputStream
*is
)
1682 if (!wxResourceBuffer
)
1683 wxReallocateResourceBuffer();
1684 wxResourceBuffer
[0] = 0;
1685 wxEatWhiteSpace(is
);
1687 int ch
= is
->GetC() ;
1691 wxResourceBufferCount
= 0;
1698 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1701 // Escaped characters
1702 else if (ch
== '\\')
1704 int newCh
= is
->GetC();
1707 else if (newCh
== 10)
1709 else if (newCh
== 13) // mac
1717 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1718 wxReallocateResourceBuffer();
1719 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1720 wxResourceBufferCount
++;
1723 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1727 wxResourceBufferCount
= 0;
1729 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1731 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1732 wxReallocateResourceBuffer();
1733 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1734 wxResourceBufferCount
++;
1738 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1746 * Files are in form:
1747 static char *name = "....";
1748 with possible comments.
1751 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1754 table
= wxDefaultResourceTable
;
1756 // static or #define
1757 if (!wxGetResourceToken(fd
))
1763 if (strcmp(wxResourceBuffer
, "#define") == 0)
1765 wxGetResourceToken(fd
);
1766 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1767 wxGetResourceToken(fd
);
1768 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1769 if (wxIsdigit(value
[0]))
1771 int val
= (int)wxAtol(value
);
1772 wxResourceAddIdentifier(name
, val
, table
);
1776 wxLogWarning(_("#define %s must be an integer."), name
);
1786 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1788 wxGetResourceToken(fd
);
1789 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1790 wxChar
*actualName
= name
;
1791 if (name
[0] == wxT('"'))
1792 actualName
= name
+ 1;
1793 int len
= wxStrlen(name
);
1794 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1796 if (!wxResourceParseIncludeFile(actualName
, table
))
1798 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1803 else if (strcmp(wxResourceBuffer
, "static") != 0)
1806 wxStrcpy(buf
, _("Found "));
1807 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
1808 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1814 if (!wxGetResourceToken(fd
))
1816 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1821 if (strcmp(wxResourceBuffer
, "char") != 0)
1823 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1828 if (!wxGetResourceToken(fd
))
1830 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1835 if (wxResourceBuffer
[0] != '*')
1837 wxLogWarning(_("Expected '*' whilst parsing resource."));
1840 wxChar nameBuf
[100];
1841 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
1845 if (!wxGetResourceToken(fd
))
1847 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1852 if (strcmp(wxResourceBuffer
, "=") != 0)
1854 wxLogWarning(_("Expected '=' whilst parsing resource."));
1859 if (!wxGetResourceToken(fd
))
1861 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1867 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1869 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1874 if (!wxGetResourceToken(fd
))
1881 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1884 table
= wxDefaultResourceTable
;
1886 // static or #define
1887 if (!wxGetResourceToken(fd
))
1893 if (strcmp(wxResourceBuffer
, "#define") == 0)
1895 wxGetResourceToken(fd
);
1896 wxChar
*name
= copystring(wxConvLibc
.cMB2WX(wxResourceBuffer
));
1897 wxGetResourceToken(fd
);
1898 wxChar
*value
= copystring(wxConvLibc
.cMB2WX(wxResourceBuffer
));
1899 if (wxIsalpha(value
[0]))
1901 int val
= (int)wxAtol(value
);
1902 wxResourceAddIdentifier(name
, val
, table
);
1906 wxLogWarning(_("#define %s must be an integer."), name
);
1916 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1918 wxGetResourceToken(fd
);
1919 wxChar
*name
= copystring(wxConvLibc
.cMB2WX(wxResourceBuffer
));
1920 wxChar
*actualName
= name
;
1921 if (name
[0] == wxT('"'))
1922 actualName
= name
+ 1;
1923 int len
= wxStrlen(name
);
1924 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1926 if (!wxResourceParseIncludeFile(actualName
, table
))
1928 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1933 else if (strcmp(wxResourceBuffer
, "static") != 0)
1936 wxStrcpy(buf
, _("Found "));
1937 wxStrncat(buf
, wxConvLibc
.cMB2WX(wxResourceBuffer
), 30);
1938 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1944 if (!wxGetResourceToken(fd
))
1946 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1951 if (strcmp(wxResourceBuffer
, "char") != 0)
1953 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1958 if (!wxGetResourceToken(fd
))
1960 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1965 if (wxResourceBuffer
[0] != '*')
1967 wxLogWarning(_("Expected '*' whilst parsing resource."));
1971 strncpy(nameBuf
, wxResourceBuffer
+1, 99);
1974 if (!wxGetResourceToken(fd
))
1976 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1981 if (strcmp(wxResourceBuffer
, "=") != 0)
1983 wxLogWarning(_("Expected '=' whilst parsing resource."));
1988 if (!wxGetResourceToken(fd
))
1990 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1996 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1998 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
2003 if (!wxGetResourceToken(fd
))
2011 * Parses string window style into integer window style
2015 * Style flag parsing, e.g.
2016 * "wxSYSTEM_MENU | wxBORDER" -> integer
2019 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
)
2022 return (wxChar
*) NULL
;
2024 static wxChar buf
[150];
2025 int len
= wxStrlen(s
);
2028 while ((ii
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == wxT('_'))))
2036 // Eat whitespace and conjunction characters
2037 while ((ii
< len
) &&
2038 ((s
[ii
] == wxT(' ')) || (s
[ii
] == wxT('|')) || (s
[ii
] == wxT(','))))
2044 return (wxChar
*) NULL
;
2049 struct wxResourceBitListStruct
2055 static wxResourceBitListStruct wxResourceBitListTable
[] =
2058 { wxT("wxSINGLE"), wxLB_SINGLE
},
2059 { wxT("wxMULTIPLE"), wxLB_MULTIPLE
},
2060 { wxT("wxEXTENDED"), wxLB_EXTENDED
},
2061 { wxT("wxLB_SINGLE"), wxLB_SINGLE
},
2062 { wxT("wxLB_MULTIPLE"), wxLB_MULTIPLE
},
2063 { wxT("wxLB_EXTENDED"), wxLB_EXTENDED
},
2064 { wxT("wxLB_NEEDED_SB"), wxLB_NEEDED_SB
},
2065 { wxT("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB
},
2066 { wxT("wxLB_SORT"), wxLB_SORT
},
2067 { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW
},
2068 { wxT("wxLB_HSCROLL"), wxLB_HSCROLL
},
2071 { wxT("wxCB_SIMPLE"), wxCB_SIMPLE
},
2072 { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN
},
2073 { wxT("wxCB_READONLY"), wxCB_READONLY
},
2074 { wxT("wxCB_SORT"), wxCB_SORT
},
2077 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR
},
2078 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL
},
2079 { wxT("wxGA_VERTICAL"), wxGA_VERTICAL
},
2082 { wxT("wxPASSWORD"), wxPASSWORD
},
2083 { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER
},
2084 { wxT("wxTE_PASSWORD"), wxTE_PASSWORD
},
2085 { wxT("wxTE_READONLY"), wxTE_READONLY
},
2086 { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
},
2087 { wxT("wxTE_MULTILINE"), wxTE_MULTILINE
},
2088 { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL
},
2090 /* wxRadioBox/wxRadioButton */
2091 { wxT("wxRB_GROUP"), wxRB_GROUP
},
2092 { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS
},
2093 { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS
},
2094 { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL
},
2095 { wxT("wxRA_VERTICAL"), wxRA_VERTICAL
},
2098 { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL
},
2099 { wxT("wxSL_VERTICAL"), wxSL_VERTICAL
},
2100 { wxT("wxSL_AUTOTICKS"), wxSL_AUTOTICKS
},
2101 { wxT("wxSL_LABELS"), wxSL_LABELS
},
2102 { wxT("wxSL_LEFT"), wxSL_LEFT
},
2103 { wxT("wxSL_TOP"), wxSL_TOP
},
2104 { wxT("wxSL_RIGHT"), wxSL_RIGHT
},
2105 { wxT("wxSL_BOTTOM"), wxSL_BOTTOM
},
2106 { wxT("wxSL_BOTH"), wxSL_BOTH
},
2107 { wxT("wxSL_SELRANGE"), wxSL_SELRANGE
},
2110 { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL
},
2111 { wxT("wxSB_VERTICAL"), wxSB_VERTICAL
},
2114 { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW
},
2115 { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW
},
2118 { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS
},
2119 { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS
},
2120 { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT
},
2123 { wxT("wxLC_ICON"), wxLC_ICON
},
2124 { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON
},
2125 { wxT("wxLC_LIST"), wxLC_LIST
},
2126 { wxT("wxLC_REPORT"), wxLC_REPORT
},
2127 { wxT("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP
},
2128 { wxT("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT
},
2129 { wxT("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE
},
2130 { wxT("wxLC_USER_TEXT"), wxLC_USER_TEXT
},
2131 { wxT("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS
},
2132 { wxT("wxLC_NO_HEADER"), wxLC_NO_HEADER
},
2133 { wxT("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER
},
2134 { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL
},
2135 { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING
},
2136 { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING
},
2139 { wxT("wxSP_VERTICAL"), wxSP_VERTICAL
},
2140 { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
},
2141 { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
},
2142 { wxT("wxSP_WRAP"), wxSP_WRAP
},
2145 { wxT("wxSP_NOBORDER"), wxSP_NOBORDER
},
2146 { wxT("wxSP_3D"), wxSP_3D
},
2147 { wxT("wxSP_BORDER"), wxSP_BORDER
},
2150 { wxT("wxTC_MULTILINE"), wxTC_MULTILINE
},
2151 { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
},
2152 { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
},
2153 { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
},
2156 { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP
},
2159 { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH
},
2160 { wxT("wxALIGN_LEFT"), wxALIGN_LEFT
},
2161 { wxT("wxALIGN_CENTER"), wxALIGN_CENTER
},
2162 { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE
},
2163 { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT
},
2164 { wxT("wxCOLOURED"), wxCOLOURED
},
2167 { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
},
2168 { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
},
2169 { wxT("wxTB_VERTICAL"), wxTB_VERTICAL
},
2170 { wxT("wxTB_FLAT"), wxTB_FLAT
},
2173 { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL
},
2176 { wxT("wxVSCROLL"), wxVSCROLL
},
2177 { wxT("wxHSCROLL"), wxHSCROLL
},
2178 { wxT("wxCAPTION"), wxCAPTION
},
2179 { wxT("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
},
2180 { wxT("wxICONIZE"), wxICONIZE
},
2181 { wxT("wxMINIMIZE"), wxICONIZE
},
2182 { wxT("wxMAXIMIZE"), wxMAXIMIZE
},
2184 { wxT("wxMDI_PARENT"), 0},
2185 { wxT("wxMDI_CHILD"), 0},
2186 { wxT("wxTHICK_FRAME"), wxTHICK_FRAME
},
2187 { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER
},
2188 { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU
},
2189 { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
},
2190 { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
},
2191 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX
},
2192 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
},
2193 { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
},
2194 { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
},
2195 { wxT("wxBORDER"), wxBORDER
},
2196 { wxT("wxRETAINED"), wxRETAINED
},
2197 { wxT("wxNATIVE_IMPL"), 0},
2198 { wxT("wxEXTENDED_IMPL"), 0},
2199 { wxT("wxBACKINGSTORE"), wxBACKINGSTORE
},
2200 // { wxT("wxFLAT"), wxFLAT},
2201 // { wxT("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
2202 { wxT("wxFIXED_LENGTH"), 0},
2203 { wxT("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
},
2204 { wxT("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
},
2205 { wxT("wxRAISED_BORDER"), wxRAISED_BORDER
},
2206 { wxT("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
},
2207 { wxT("wxSTATIC_BORDER"), wxSTATIC_BORDER
},
2208 { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
},
2209 { wxT("wxNO_BORDER"), wxNO_BORDER
},
2210 { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
},
2211 { wxT("wxCLIP_SIBLINGS"), wxCLIP_SIBLINGS
},
2212 { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
2214 { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
},
2215 { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
},
2217 // Text font families
2218 { wxT("wxDEFAULT"), wxDEFAULT
},
2219 { wxT("wxDECORATIVE"), wxDECORATIVE
},
2220 { wxT("wxROMAN"), wxROMAN
},
2221 { wxT("wxSCRIPT"), wxSCRIPT
},
2222 { wxT("wxSWISS"), wxSWISS
},
2223 { wxT("wxMODERN"), wxMODERN
},
2224 { wxT("wxTELETYPE"), wxTELETYPE
},
2225 { wxT("wxVARIABLE"), wxVARIABLE
},
2226 { wxT("wxFIXED"), wxFIXED
},
2227 { wxT("wxNORMAL"), wxNORMAL
},
2228 { wxT("wxLIGHT"), wxLIGHT
},
2229 { wxT("wxBOLD"), wxBOLD
},
2230 { wxT("wxITALIC"), wxITALIC
},
2231 { wxT("wxSLANT"), wxSLANT
},
2232 { wxT("wxSOLID"), wxSOLID
},
2233 { wxT("wxDOT"), wxDOT
},
2234 { wxT("wxLONG_DASH"), wxLONG_DASH
},
2235 { wxT("wxSHORT_DASH"), wxSHORT_DASH
},
2236 { wxT("wxDOT_DASH"), wxDOT_DASH
},
2237 { wxT("wxUSER_DASH"), wxUSER_DASH
},
2238 { wxT("wxTRANSPARENT"), wxTRANSPARENT
},
2239 { wxT("wxSTIPPLE"), wxSTIPPLE
},
2240 { wxT("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
},
2241 { wxT("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
},
2242 { wxT("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
},
2243 { wxT("wxCROSS_HATCH"), wxCROSS_HATCH
},
2244 { wxT("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
},
2245 { wxT("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
},
2246 { wxT("wxJOIN_BEVEL"), wxJOIN_BEVEL
},
2247 { wxT("wxJOIN_MITER"), wxJOIN_MITER
},
2248 { wxT("wxJOIN_ROUND"), wxJOIN_ROUND
},
2249 { wxT("wxCAP_ROUND"), wxCAP_ROUND
},
2250 { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING
},
2251 { wxT("wxCAP_BUTT"), wxCAP_BUTT
},
2254 { wxT("wxCLEAR"), wxCLEAR
},
2255 { wxT("wxXOR"), wxXOR
},
2256 { wxT("wxINVERT"), wxINVERT
},
2257 { wxT("wxOR_REVERSE"), wxOR_REVERSE
},
2258 { wxT("wxAND_REVERSE"), wxAND_REVERSE
},
2259 { wxT("wxCOPY"), wxCOPY
},
2260 { wxT("wxAND"), wxAND
},
2261 { wxT("wxAND_INVERT"), wxAND_INVERT
},
2262 { wxT("wxNO_OP"), wxNO_OP
},
2263 { wxT("wxNOR"), wxNOR
},
2264 { wxT("wxEQUIV"), wxEQUIV
},
2265 { wxT("wxSRC_INVERT"), wxSRC_INVERT
},
2266 { wxT("wxOR_INVERT"), wxOR_INVERT
},
2267 { wxT("wxNAND"), wxNAND
},
2268 { wxT("wxOR"), wxOR
},
2269 { wxT("wxSET"), wxSET
},
2271 { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
},
2272 { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER
},
2273 { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE
},
2274 { wxT("wxWINDING_RULE"), wxWINDING_RULE
},
2275 { wxT("wxHORIZONTAL"), wxHORIZONTAL
},
2276 { wxT("wxVERTICAL"), wxVERTICAL
},
2277 { wxT("wxBOTH"), wxBOTH
},
2278 { wxT("wxCENTER_FRAME"), wxCENTER_FRAME
},
2279 { wxT("wxOK"), wxOK
},
2280 { wxT("wxYES_NO"), wxYES_NO
},
2281 { wxT("wxCANCEL"), wxCANCEL
},
2282 { wxT("wxYES"), wxYES
},
2283 { wxT("wxNO"), wxNO
},
2284 { wxT("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
},
2285 { wxT("wxICON_HAND"), wxICON_HAND
},
2286 { wxT("wxICON_QUESTION"), wxICON_QUESTION
},
2287 { wxT("wxICON_INFORMATION"), wxICON_INFORMATION
},
2288 { wxT("wxICON_STOP"), wxICON_STOP
},
2289 { wxT("wxICON_ASTERISK"), wxICON_ASTERISK
},
2290 { wxT("wxICON_MASK"), wxICON_MASK
},
2291 { wxT("wxCENTRE"), wxCENTRE
},
2292 { wxT("wxCENTER"), wxCENTRE
},
2293 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS
},
2294 { wxT("wxVERTICAL_LABEL"), 0},
2295 { wxT("wxHORIZONTAL_LABEL"), 0},
2297 // Bitmap types (not strictly styles)
2298 { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
},
2299 { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
},
2300 { wxT("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
},
2301 { wxT("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2302 { wxT("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2303 { wxT("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
},
2304 { wxT("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
},
2305 { wxT("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
},
2306 { wxT("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
},
2307 { wxT("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
},
2308 { wxT("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
},
2309 { wxT("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
},
2310 { wxT("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
},
2311 { wxT("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
}
2314 static int wxResourceBitListCount
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
));
2316 long wxParseWindowStyle(const wxString
& bitListString
)
2321 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2322 while (word
!= NULL
)
2326 for (j
= 0; j
< wxResourceBitListCount
; j
++)
2327 if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0)
2329 bitList
|= wxResourceBitListTable
[j
].bits
;
2335 wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
);
2338 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2344 * Load a bitmap from a wxWindows resource, choosing an optimum
2345 * depth and appropriate type.
2348 wxBitmap
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable
*table
)
2351 table
= wxDefaultResourceTable
;
2353 wxItemResource
*item
= table
->FindResource(resource
);
2356 if ((item
->GetType() == wxT("")) || (item
->GetType() != wxT("wxBitmap")))
2358 wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
);
2359 return wxNullBitmap
;
2361 int thisDepth
= wxDisplayDepth();
2362 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2364 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2366 // Try to find optimum bitmap for this platform/colour depth
2367 wxNode
*node
= item
->GetChildren().First();
2370 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2371 int platform
= (int)child
->GetValue2();
2372 int noColours
= (int)child
->GetValue3();
2374 char *name = child->GetName();
2375 int bitmapType = (int)child->GetValue1();
2376 int xRes = child->GetWidth();
2377 int yRes = child->GetHeight();
2382 case RESOURCE_PLATFORM_ANY
:
2384 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2385 optResource
= child
;
2388 // Maximise the number of colours.
2389 // If noColours is zero (unspecified), then assume this
2390 // is the right one.
2391 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2392 optResource
= child
;
2397 case RESOURCE_PLATFORM_WINDOWS
:
2399 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2400 optResource
= child
;
2403 // Maximise the number of colours
2404 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2405 optResource
= child
;
2411 case RESOURCE_PLATFORM_X
:
2413 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2414 optResource
= child
;
2417 // Maximise the number of colours
2418 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2419 optResource
= child
;
2425 case RESOURCE_PLATFORM_MAC
:
2427 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2428 optResource
= child
;
2431 // Maximise the number of colours
2432 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2433 optResource
= child
;
2441 node
= node
->Next();
2443 // If no matching resource, fail.
2445 return wxNullBitmap
;
2447 wxString name
= optResource
->GetName();
2448 int bitmapType
= (int)optResource
->GetValue1();
2451 case wxBITMAP_TYPE_XBM_DATA
:
2454 wxItemResource
*item
= table
->FindResource(name
);
2457 wxLogWarning(_("Failed to find XBM resource %s.\n"
2458 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2459 return wxNullBitmap
;
2461 return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ;
2463 wxLogWarning(_("No XBM facility available!"));
2467 case wxBITMAP_TYPE_XPM_DATA
:
2469 wxItemResource
*item
= table
->FindResource(name
);
2472 wxLogWarning(_("Failed to find XPM resource %s.\nForgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2473 return wxNullBitmap
;
2475 return wxBitmap((char **)item
->GetValue1());
2479 return wxBitmap(name
, (wxBitmapType
)bitmapType
);
2483 return wxNullBitmap
;
2488 wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
);
2489 return wxNullBitmap
;
2494 * Load an icon from a wxWindows resource, choosing an optimum
2495 * depth and appropriate type.
2498 wxIcon
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable
*table
)
2501 table
= wxDefaultResourceTable
;
2503 wxItemResource
*item
= table
->FindResource(resource
);
2506 if ((item
->GetType() == wxT("")) || wxStrcmp(item
->GetType(), wxT("wxIcon")) != 0)
2508 wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
);
2511 int thisDepth
= wxDisplayDepth();
2512 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2514 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2516 // Try to find optimum icon for this platform/colour depth
2517 wxNode
*node
= item
->GetChildren().First();
2520 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2521 int platform
= (int)child
->GetValue2();
2522 int noColours
= (int)child
->GetValue3();
2524 char *name = child->GetName();
2525 int bitmapType = (int)child->GetValue1();
2526 int xRes = child->GetWidth();
2527 int yRes = child->GetHeight();
2532 case RESOURCE_PLATFORM_ANY
:
2534 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2535 optResource
= child
;
2538 // Maximise the number of colours.
2539 // If noColours is zero (unspecified), then assume this
2540 // is the right one.
2541 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2542 optResource
= child
;
2547 case RESOURCE_PLATFORM_WINDOWS
:
2549 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2550 optResource
= child
;
2553 // Maximise the number of colours
2554 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2555 optResource
= child
;
2561 case RESOURCE_PLATFORM_X
:
2563 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2564 optResource
= child
;
2567 // Maximise the number of colours
2568 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2569 optResource
= child
;
2575 case RESOURCE_PLATFORM_MAC
:
2577 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2578 optResource
= child
;
2581 // Maximise the number of colours
2582 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2583 optResource
= child
;
2591 node
= node
->Next();
2593 // If no matching resource, fail.
2597 wxString name
= optResource
->GetName();
2598 int bitmapType
= (int)optResource
->GetValue1();
2601 case wxBITMAP_TYPE_XBM_DATA
:
2604 wxItemResource
*item
= table
->FindResource(name
);
2607 wxLogWarning(_("Failed to find XBM resource %s.\n"
2608 "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
);
2611 return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3());
2613 wxLogWarning(_("No XBM facility available!"));
2617 case wxBITMAP_TYPE_XPM_DATA
:
2619 // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
2621 wxItemResource *item = table->FindResource(name);
2625 sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name);
2629 return wxIcon((char **)item->GetValue1());
2631 wxLogWarning(_("No XPM icon facility available!"));
2637 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2640 return wxIcon(name
, bitmapType
);
2648 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2655 wxMenu
*wxResourceCreateMenu(wxItemResource
*item
)
2657 wxMenu
*menu
= new wxMenu
;
2658 wxNode
*node
= item
->GetChildren().First();
2661 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2662 if ((child
->GetType() != wxT("")) && (child
->GetType() == wxT("wxMenuSeparator")))
2663 menu
->AppendSeparator();
2664 else if (child
->GetChildren().Number() > 0)
2666 wxMenu
*subMenu
= wxResourceCreateMenu(child
);
2668 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4());
2672 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0));
2674 node
= node
->Next();
2679 wxMenuBar
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable
*table
, wxMenuBar
*menuBar
)
2682 table
= wxDefaultResourceTable
;
2684 wxItemResource
*menuResource
= table
->FindResource(resource
);
2685 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2688 menuBar
= new wxMenuBar
;
2689 wxNode
*node
= menuResource
->GetChildren().First();
2692 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2693 wxMenu
*menu
= wxResourceCreateMenu(child
);
2695 menuBar
->Append(menu
, child
->GetTitle());
2696 node
= node
->Next();
2700 return (wxMenuBar
*) NULL
;
2703 wxMenu
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable
*table
)
2706 table
= wxDefaultResourceTable
;
2708 wxItemResource
*menuResource
= table
->FindResource(resource
);
2709 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2710 // if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
2711 return wxResourceCreateMenu(menuResource
);
2712 return (wxMenu
*) NULL
;
2715 #endif // wxUSE_MENUS
2717 // Global equivalents (so don't have to refer to default table explicitly)
2718 bool wxResourceParseData(const wxString
& resource
, wxResourceTable
*table
)
2721 table
= wxDefaultResourceTable
;
2723 return table
->ParseResourceData(resource
);
2726 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable
*table
)
2729 table
= wxDefaultResourceTable
;
2731 return table
->ParseResourceFile(filename
);
2734 // Register XBM/XPM data
2735 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable
*table
)
2738 table
= wxDefaultResourceTable
;
2740 return table
->RegisterResourceBitmapData(name
, bits
, width
, height
);
2743 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable
*table
)
2746 table
= wxDefaultResourceTable
;
2748 return table
->RegisterResourceBitmapData(name
, data
);
2751 void wxResourceClear(wxResourceTable
*table
)
2754 table
= wxDefaultResourceTable
;
2756 table
->ClearTable();
2763 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable
*table
)
2766 table
= wxDefaultResourceTable
;
2768 table
->identifiers
.Put(name
, (wxObject
*)(long)value
);
2772 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable
*table
)
2775 table
= wxDefaultResourceTable
;
2777 return (int)(long)table
->identifiers
.Get(name
);
2781 * Parse #include file for #defines (only)
2784 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
)
2787 table
= wxDefaultResourceTable
;
2789 FILE *fd
= wxFopen(f
, _T("r"));
2794 while (wxGetResourceToken(fd
))
2796 if (strcmp(wxResourceBuffer
, "#define") == 0)
2798 wxGetResourceToken(fd
);
2799 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2800 wxGetResourceToken(fd
);
2801 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2802 if (wxIsdigit(value
[0]))
2804 int val
= (int)wxAtol(value
);
2805 wxResourceAddIdentifier(name
, val
, table
);
2816 * Reading strings as if they were .wxr files
2819 static int getc_string(char *s
)
2821 int ch
= s
[wxResourceStringPtr
];
2826 wxResourceStringPtr
++;
2831 static int ungetc_string()
2833 wxResourceStringPtr
--;
2837 bool wxEatWhiteSpaceString(char *s
)
2841 while ((ch
= getc_string(s
)) != EOF
)
2853 ch
= getc_string(s
);
2864 while ((ch
= getc_string(s
)) != EOF
)
2866 if (ch
== '/' && prev_ch
== '*')
2888 bool wxGetResourceTokenString(char *s
)
2890 if (!wxResourceBuffer
)
2891 wxReallocateResourceBuffer();
2892 wxResourceBuffer
[0] = 0;
2893 wxEatWhiteSpaceString(s
);
2895 int ch
= getc_string(s
);
2899 wxResourceBufferCount
= 0;
2900 ch
= getc_string(s
);
2906 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2909 // Escaped characters
2910 else if (ch
== '\\')
2912 int newCh
= getc_string(s
);
2915 else if (newCh
== 10)
2923 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2924 wxReallocateResourceBuffer();
2925 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
2926 wxResourceBufferCount
++;
2927 ch
= getc_string(s
);
2929 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2933 wxResourceBufferCount
= 0;
2935 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
2937 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2938 wxReallocateResourceBuffer();
2939 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
2940 wxResourceBufferCount
++;
2942 ch
= getc_string(s
);
2944 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2952 * Files are in form:
2953 static char *name = "....";
2954 with possible comments.
2957 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
2960 table
= wxDefaultResourceTable
;
2962 // static or #define
2963 if (!wxGetResourceTokenString(s
))
2969 if (strcmp(wxResourceBuffer
, "#define") == 0)
2971 wxGetResourceTokenString(s
);
2972 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2973 wxGetResourceTokenString(s
);
2974 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2975 if (wxIsdigit(value
[0]))
2977 int val
= (int)wxAtol(value
);
2978 wxResourceAddIdentifier(name
, val
, table
);
2982 wxLogWarning(_("#define %s must be an integer."), name
);
2993 else if (strcmp(wxResourceBuffer, "#include") == 0)
2995 wxGetResourceTokenString(s);
2996 char *name = copystring(wxResourceBuffer);
2997 char *actualName = name;
2999 actualName = name + 1;
3000 int len = strlen(name);
3001 if ((len > 0) && (name[len-1] == '"'))
3003 if (!wxResourceParseIncludeFile(actualName, table))
3006 sprintf(buf, _("Could not find resource include file %s."), actualName);
3013 else if (strcmp(wxResourceBuffer
, "static") != 0)
3016 wxStrcpy(buf
, _("Found "));
3017 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
3018 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
3024 if (!wxGetResourceTokenString(s
))
3026 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3031 if (strcmp(wxResourceBuffer
, "char") != 0)
3033 wxLogWarning(_("Expected 'char' whilst parsing resource."));
3038 if (!wxGetResourceTokenString(s
))
3040 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3045 if (wxResourceBuffer
[0] != '*')
3047 wxLogWarning(_("Expected '*' whilst parsing resource."));
3050 wxChar nameBuf
[100];
3051 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
3055 if (!wxGetResourceTokenString(s
))
3057 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3062 if (strcmp(wxResourceBuffer
, "=") != 0)
3064 wxLogWarning(_("Expected '=' whilst parsing resource."));
3069 if (!wxGetResourceTokenString(s
))
3071 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3077 if (!db
.ReadPrologFromString(wxResourceBuffer
))
3079 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
3084 if (!wxGetResourceTokenString(s
))
3091 bool wxResourceParseString(char *s
, wxResourceTable
*table
)
3094 table
= wxDefaultResourceTable
;
3099 // Turn backslashes into spaces
3102 int len
= strlen(s
);
3104 for (i
= 0; i
< len
; i
++)
3105 if (s
[i
] == 92 && s
[i
+1] == 13)
3113 wxResourceStringPtr
= 0;
3116 while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
)
3120 return wxResourceInterpretResources(*table
, db
);
3124 * resource loading facility
3127 bool wxWindowBase::LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
)
3130 table
= wxDefaultResourceTable
;
3132 wxItemResource
*resource
= table
->FindResource((const wxChar
*)resourceName
);
3133 // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
3134 if (!resource
|| (resource
->GetType() == wxT("")) ||
3135 ! ((resource
->GetType() == wxT("wxDialog")) || (resource
->GetType() == wxT("wxPanel"))))
3138 wxString
title(resource
->GetTitle());
3139 long theWindowStyle
= resource
->GetStyle();
3140 bool isModal
= (resource
->GetValue1() != 0) ;
3141 int x
= resource
->GetX();
3142 int y
= resource
->GetY();
3143 int width
= resource
->GetWidth();
3144 int height
= resource
->GetHeight();
3145 wxString name
= resource
->GetName();
3147 if (IsKindOf(CLASSINFO(wxDialog
)))
3149 wxDialog
*dialogBox
= (wxDialog
*)this;
3150 long modalStyle
= isModal
? wxDIALOG_MODAL
: 0;
3151 if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
))
3154 // Only reset the client size if we know we're not going to do it again below.
3155 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0)
3156 dialogBox
->SetClientSize(width
, height
);
3158 else if (IsKindOf(CLASSINFO(wxPanel
)))
3160 wxPanel
* panel
= (wxPanel
*)this;
3161 if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
| wxTAB_TRAVERSAL
, name
))
3166 if (!((wxWindow
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
))
3170 if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
3172 // No need to do this since it's done in wxPanel or wxDialog constructor.
3173 // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
3177 if (resource
->GetFont().Ok())
3178 SetFont(resource
->GetFont());
3179 if (resource
->GetBackgroundColour().Ok())
3180 SetBackgroundColour(resource
->GetBackgroundColour());
3183 // Should have some kind of font at this point
3184 if (!GetFont().Ok())
3185 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
3186 if (!GetBackgroundColour().Ok())
3187 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
3189 // Only when we've created the window and set the font can we set the correct size,
3190 // if based on dialog units.
3191 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
3193 wxSize sz
= ConvertDialogToPixels(wxSize(width
, height
));
3194 SetClientSize(sz
.x
, sz
.y
);
3196 wxPoint pt
= ConvertDialogToPixels(wxPoint(x
, y
));
3200 // Now create children
3201 wxNode
*node
= resource
->GetChildren().First();
3204 wxItemResource
*childResource
= (wxItemResource
*)node
->Data();
3206 (void) CreateItem(childResource
, resource
, table
);
3208 node
= node
->Next();
3213 wxControl
*wxWindowBase::CreateItem(const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
)
3216 table
= wxDefaultResourceTable
;
3217 return table
->CreateItem((wxWindow
*)this, resource
, parentResource
);
3221 #pragma warning(default:4706) // assignment within conditional expression
3227 #endif // wxUSE_WX_RESOURCES