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
)
230 #if defined(__WXMAC__) && !defined(__UNIX__)
231 FILE *fd
= fopen(wxUnix2MacFilename(filename
.fn_str()), "r");
233 FILE *fd
= wxFopen(filename
, _T("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 bitmap
.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE
);
340 control
= new wxBitmapButton(parent
, id
, bitmap
, pos
, size
,
341 childResource
->GetStyle() | wxBU_AUTODRAW
, wxDefaultValidator
, childResource
->GetName());
344 // Normal, text button
345 control
= new wxButton(parent
, id
, childResource
->GetTitle(), pos
, size
,
346 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
348 else if (itemType
== wxString(wxT("wxMessage")) || itemType
== wxString(wxT("wxStaticText")) ||
349 itemType
== wxString(wxT("wxStaticBitmap")))
351 if (childResource
->GetValue4() != wxT("") || itemType
== wxString(wxT("wxStaticBitmap")) )
354 wxBitmap bitmap
= childResource
->GetBitmap();
357 bitmap
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable
*)this);
358 ((wxItemResource
*) childResource
)->SetBitmap(bitmap
);
360 #if wxUSE_BITMAP_MESSAGE
362 // Use a default bitmap
364 bitmap
.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE
);
368 control
= new wxStaticBitmap(parent
, id
, bitmap
, pos
, size
,
369 childResource
->GetStyle(), childResource
->GetName());
374 control
= new wxStaticText(parent
, id
, childResource
->GetTitle(), pos
, size
,
375 childResource
->GetStyle(), childResource
->GetName());
378 else if (itemType
== wxString(wxT("wxText")) || itemType
== wxString(wxT("wxTextCtrl")) || itemType
== wxString(wxT("wxMultiText")))
380 control
= new wxTextCtrl(parent
, id
, childResource
->GetValue4(), pos
, size
,
381 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
383 else if (itemType
== wxString(wxT("wxCheckBox")))
385 control
= new wxCheckBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
386 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
388 ((wxCheckBox
*)control
)->SetValue((childResource
->GetValue1() != 0));
391 else if (itemType
== wxString(wxT("wxGauge")))
393 control
= new wxGauge(parent
, id
, (int)childResource
->GetValue2(), pos
, size
,
394 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
396 ((wxGauge
*)control
)->SetValue((int)childResource
->GetValue1());
400 else if (itemType
== wxString(wxT("wxRadioButton")))
402 control
= new wxRadioButton(parent
, id
, childResource
->GetTitle(), // (int)childResource->GetValue1(),
404 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
408 else if (itemType
== wxString(wxT("wxScrollBar")))
410 control
= new wxScrollBar(parent
, id
, pos
, size
,
411 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
413 ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1());
414 ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2());
415 ((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3());
416 ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5());
418 ((wxScrollBar
*)control
)->SetScrollbar((int)childResource
->GetValue1(),(int)childResource
->GetValue2(),
419 (int)childResource
->GetValue3(),(int)(long)childResource
->GetValue5(),FALSE
);
423 else if (itemType
== wxString(wxT("wxSlider")))
425 control
= new wxSlider(parent
, id
, (int)childResource
->GetValue1(),
426 (int)childResource
->GetValue2(), (int)childResource
->GetValue3(), pos
, size
,
427 childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
429 else if (itemType
== wxString(wxT("wxGroupBox")) || itemType
== wxString(wxT("wxStaticBox")))
431 control
= new wxStaticBox(parent
, id
, childResource
->GetTitle(), pos
, size
,
432 childResource
->GetStyle(), childResource
->GetName());
434 else if (itemType
== wxString(wxT("wxListBox")))
436 wxStringList
& stringList
= childResource
->GetStringValues();
437 wxString
*strings
= (wxString
*) NULL
;
439 if (stringList
.Number() > 0)
441 noStrings
= stringList
.Number();
442 strings
= new wxString
[noStrings
];
443 wxNode
*node
= stringList
.First();
447 strings
[i
] = (wxChar
*)node
->Data();
452 control
= new wxListBox(parent
, id
, pos
, size
,
453 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
458 else if (itemType
== wxString(wxT("wxChoice")))
460 wxStringList
& stringList
= childResource
->GetStringValues();
461 wxString
*strings
= (wxString
*) NULL
;
463 if (stringList
.Number() > 0)
465 noStrings
= stringList
.Number();
466 strings
= new wxString
[noStrings
];
467 wxNode
*node
= stringList
.First();
471 strings
[i
] = (wxChar
*)node
->Data();
476 control
= new wxChoice(parent
, id
, pos
, size
,
477 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
483 else if (itemType
== wxString(wxT("wxComboBox")))
485 wxStringList
& stringList
= childResource
->GetStringValues();
486 wxString
*strings
= (wxString
*) NULL
;
488 if (stringList
.Number() > 0)
490 noStrings
= stringList
.Number();
491 strings
= new wxString
[noStrings
];
492 wxNode
*node
= stringList
.First();
496 strings
[i
] = (wxChar
*)node
->Data();
501 control
= new wxComboBox(parent
, id
, childResource
->GetValue4(), pos
, size
,
502 noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName());
508 else if (itemType
== wxString(wxT("wxRadioBox")))
510 wxStringList
& stringList
= childResource
->GetStringValues();
511 wxString
*strings
= (wxString
*) NULL
;
513 if (stringList
.Number() > 0)
515 noStrings
= stringList
.Number();
516 strings
= new wxString
[noStrings
];
517 wxNode
*node
= stringList
.First();
521 strings
[i
] = (wxChar
*)node
->Data();
526 control
= new wxRadioBox(parent
, (wxWindowID
) id
, wxString(childResource
->GetTitle()), pos
, size
,
527 noStrings
, strings
, (int)childResource
->GetValue1(), childResource
->GetStyle(), wxDefaultValidator
,
528 childResource
->GetName());
534 if ((parentResource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
536 // Don't set font; will be inherited from parent.
540 if (control
&& childResource
->GetFont().Ok())
542 control
->SetFont(childResource
->GetFont());
545 // Force the layout algorithm since the size changes the layout
546 if (control
->IsKindOf(CLASSINFO(wxRadioBox
)))
548 control
->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH
|wxSIZE_AUTO_HEIGHT
);
557 * Interpret database as a series of resources
560 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
)
562 wxNode
*node
= db
.First();
565 wxExpr
*clause
= (wxExpr
*)node
->Data();
566 wxString
functor(clause
->Functor());
568 wxItemResource
*item
= (wxItemResource
*) NULL
;
569 if (functor
== wxT("dialog"))
570 item
= wxResourceInterpretDialog(table
, clause
);
571 else if (functor
== wxT("panel"))
572 item
= wxResourceInterpretDialog(table
, clause
, TRUE
);
573 else if (functor
== wxT("menubar"))
574 item
= wxResourceInterpretMenuBar(table
, clause
);
575 else if (functor
== wxT("menu"))
576 item
= wxResourceInterpretMenu(table
, clause
);
577 else if (functor
== wxT("string"))
578 item
= wxResourceInterpretString(table
, clause
);
579 else if (functor
== wxT("bitmap"))
580 item
= wxResourceInterpretBitmap(table
, clause
);
581 else if (functor
== wxT("icon"))
582 item
= wxResourceInterpretIcon(table
, clause
);
586 // Remove any existing resource of same name
587 if (item
->GetName() != wxT(""))
588 table
.DeleteResource(item
->GetName());
589 table
.AddResource(item
);
596 static const wxChar
*g_ValidControlClasses
[] =
599 wxT("wxBitmapButton"),
602 wxT("wxStaticBitmap"),
608 wxT("wxRadioButton"),
610 wxT("wxBitmapCheckBox"),
620 static bool wxIsValidControlClass(const wxString
& c
)
622 for ( size_t i
= 0; i
< WXSIZEOF(g_ValidControlClasses
); i
++ )
624 if ( c
== g_ValidControlClasses
[i
] )
630 wxItemResource
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr
*expr
, bool isPanel
)
632 wxItemResource
*dialogItem
= new wxItemResource
;
634 dialogItem
->SetType(wxT("wxPanel"));
636 dialogItem
->SetType(wxT("wxDialog"));
637 wxString style
= wxT("");
638 wxString title
= wxT("");
639 wxString name
= wxT("");
640 wxString backColourHex
= wxT("");
641 wxString labelColourHex
= wxT("");
642 wxString buttonColourHex
= wxT("");
644 long windowStyle
= wxDEFAULT_DIALOG_STYLE
;
648 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
650 wxExpr
*labelFontExpr
= (wxExpr
*) NULL
;
651 wxExpr
*buttonFontExpr
= (wxExpr
*) NULL
;
652 wxExpr
*fontExpr
= (wxExpr
*) NULL
;
653 expr
->GetAttributeValue(wxT("style"), style
);
654 expr
->GetAttributeValue(wxT("name"), name
);
655 expr
->GetAttributeValue(wxT("title"), title
);
656 expr
->GetAttributeValue(wxT("x"), x
);
657 expr
->GetAttributeValue(wxT("y"), y
);
658 expr
->GetAttributeValue(wxT("width"), width
);
659 expr
->GetAttributeValue(wxT("height"), height
);
660 expr
->GetAttributeValue(wxT("modal"), isModal
);
661 expr
->GetAttributeValue(wxT("label_font"), &labelFontExpr
);
662 expr
->GetAttributeValue(wxT("button_font"), &buttonFontExpr
);
663 expr
->GetAttributeValue(wxT("font"), &fontExpr
);
664 expr
->GetAttributeValue(wxT("background_colour"), backColourHex
);
665 expr
->GetAttributeValue(wxT("label_colour"), labelColourHex
);
666 expr
->GetAttributeValue(wxT("button_colour"), buttonColourHex
);
668 int useDialogUnits
= 0;
669 expr
->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits
);
670 if (useDialogUnits
!= 0)
671 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
);
674 expr
->GetAttributeValue(wxT("use_system_defaults"), useDefaults
);
675 if (useDefaults
!= 0)
676 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
);
679 expr
->GetAttributeValue(wxT("id"), id
);
680 dialogItem
->SetId(id
);
682 if (style
!= wxT(""))
684 windowStyle
= wxParseWindowStyle(style
);
686 dialogItem
->SetStyle(windowStyle
);
687 dialogItem
->SetValue1(isModal
);
688 if (windowStyle
& wxDIALOG_MODAL
) // Uses style in wxWin 2
689 dialogItem
->SetValue1(TRUE
);
691 dialogItem
->SetName(name
);
692 dialogItem
->SetTitle(title
);
693 dialogItem
->SetSize(x
, y
, width
, height
);
695 // Check for wxWin 1.68-style specifications
696 if (style
.Find(wxT("VERTICAL_LABEL")) != -1)
697 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL
);
698 else if (style
.Find(wxT("HORIZONTAL_LABEL")) != -1)
699 dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL
);
701 if (backColourHex
!= wxT(""))
706 r
= wxHexToDec(backColourHex
.Mid(0, 2));
707 g
= wxHexToDec(backColourHex
.Mid(2, 2));
708 b
= wxHexToDec(backColourHex
.Mid(4, 2));
709 dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
711 if (labelColourHex
!= wxT(""))
716 r
= wxHexToDec(labelColourHex
.Mid(0, 2));
717 g
= wxHexToDec(labelColourHex
.Mid(2, 2));
718 b
= wxHexToDec(labelColourHex
.Mid(4, 2));
719 dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
721 if (buttonColourHex
!= wxT(""))
726 r
= wxHexToDec(buttonColourHex
.Mid(0, 2));
727 g
= wxHexToDec(buttonColourHex
.Mid(2, 2));
728 b
= wxHexToDec(buttonColourHex
.Mid(4, 2));
729 dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
));
733 dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
));
734 else if (buttonFontExpr
)
735 dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
));
736 else if (labelFontExpr
)
737 dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
));
739 // Now parse all controls
740 wxExpr
*controlExpr
= expr
->GetFirst();
743 if (controlExpr
->Number() == 3)
745 wxString
controlKeyword(controlExpr
->Nth(1)->StringValue());
746 if (controlKeyword
!= wxT("") && controlKeyword
== wxT("control"))
748 // The value part: always a list.
749 wxExpr
*listExpr
= controlExpr
->Nth(2);
750 if (listExpr
->Type() == PrologList
)
752 wxItemResource
*controlItem
= wxResourceInterpretControl(table
, listExpr
);
755 dialogItem
->GetChildren().Append(controlItem
);
760 controlExpr
= controlExpr
->GetNext();
765 wxItemResource
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr
*expr
)
767 wxItemResource
*controlItem
= new wxItemResource
;
769 // First, find the standard features of a control definition:
770 // [optional integer/string id], control name, title, style, name, x, y, width, height
772 wxString controlType
;
777 long windowStyle
= 0;
778 int x
= 0; int y
= 0; int width
= -1; int height
= -1;
781 wxExpr
*expr1
= expr
->Nth(0);
783 if ( expr1
->Type() == PrologString
|| expr1
->Type() == PrologWord
)
785 if ( wxIsValidControlClass(expr1
->StringValue()) )
788 controlType
= expr1
->StringValue();
792 wxString
str(expr1
->StringValue());
793 id
= wxResourceGetIdentifier(str
, &table
);
796 wxLogWarning(_("Could not resolve control class or id '%s'. Use (non-zero) integer instead\n or provide #define (see manual for caveats)"),
797 (const wxChar
*) expr1
->StringValue());
799 return (wxItemResource
*) NULL
;
803 // Success - we have an id, so the 2nd element must be the control class.
804 controlType
= expr
->Nth(1)->StringValue();
809 else if (expr1
->Type() == PrologInteger
)
811 id
= (int)expr1
->IntegerValue();
812 // Success - we have an id, so the 2nd element must be the control class.
813 controlType
= expr
->Nth(1)->StringValue();
817 expr1
= expr
->Nth(count
);
820 title
= expr1
->StringValue();
822 expr1
= expr
->Nth(count
);
826 style
= expr1
->StringValue();
827 windowStyle
= wxParseWindowStyle(style
);
830 expr1
= expr
->Nth(count
);
833 name
= expr1
->StringValue();
835 expr1
= expr
->Nth(count
);
838 x
= (int)expr1
->IntegerValue();
840 expr1
= expr
->Nth(count
);
843 y
= (int)expr1
->IntegerValue();
845 expr1
= expr
->Nth(count
);
848 width
= (int)expr1
->IntegerValue();
850 expr1
= expr
->Nth(count
);
853 height
= (int)expr1
->IntegerValue();
855 controlItem
->SetStyle(windowStyle
);
856 controlItem
->SetName(name
);
857 controlItem
->SetTitle(title
);
858 controlItem
->SetSize(x
, y
, width
, height
);
859 controlItem
->SetType(controlType
);
860 controlItem
->SetId(id
);
862 // Check for wxWin 1.68-style specifications
863 if (style
.Find(wxT("VERTICAL_LABEL")) != -1)
864 controlItem
->SetResourceStyle(controlItem
->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL
);
865 else if (style
.Find(wxT("HORIZONTAL_LABEL")) != -1)
866 controlItem
->SetResourceStyle(controlItem
->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL
);
868 if (controlType
== wxT("wxButton"))
870 // Check for bitmap resource name (in case loading old-style resource file)
871 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
873 wxString
str(expr
->Nth(count
)->StringValue());
878 controlItem
->SetValue4(str
);
879 controlItem
->SetType(wxT("wxBitmapButton"));
882 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
883 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
885 else if (controlType
== wxT("wxBitmapButton"))
887 // Check for bitmap resource name
888 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
890 wxString
str(expr
->Nth(count
)->StringValue());
891 controlItem
->SetValue4(str
);
893 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
894 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
897 else if (controlType
== wxT("wxCheckBox"))
899 // Check for default value
900 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
902 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
904 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
905 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
909 else if (controlType
== wxT("wxRadioButton"))
911 // Check for default value
912 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
914 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
916 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
917 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
921 else if (controlType
== wxT("wxText") || controlType
== wxT("wxTextCtrl") || controlType
== wxT("wxMultiText"))
923 // Check for default value
924 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
926 wxString
str(expr
->Nth(count
)->StringValue());
927 controlItem
->SetValue4(str
);
930 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
932 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
933 // Skip past the obsolete label font spec if there are two consecutive specs
934 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
936 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
940 else if (controlType
== wxT("wxMessage") || controlType
== wxT("wxStaticText"))
942 // Check for bitmap resource name (in case it's an old-style .wxr file)
943 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
945 wxString
str(expr
->Nth(count
)->StringValue());
946 controlItem
->SetValue4(str
);
948 controlItem
->SetType(wxT("wxStaticText"));
950 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
951 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
953 else if (controlType
== wxT("wxStaticBitmap"))
955 // Check for bitmap resource name
956 if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
)))
958 wxString
str(expr
->Nth(count
)->StringValue());
959 controlItem
->SetValue4(str
);
962 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
963 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
965 else if (controlType
== wxT("wxGroupBox") || controlType
== wxT("wxStaticBox"))
967 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
968 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
970 else if (controlType
== wxT("wxGauge"))
972 // Check for default value
973 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
975 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
979 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
981 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
984 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
986 // Skip past the obsolete label font spec if there are two consecutive specs
987 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
989 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
994 else if (controlType
== wxT("wxSlider"))
996 // Check for default value
997 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
999 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1003 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1005 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1009 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1011 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1014 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1016 // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
1020 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1021 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1027 else if (controlType
== wxT("wxScrollBar"))
1030 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1032 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1036 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1038 controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue());
1042 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1044 controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue());
1048 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1049 controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue());
1054 else if (controlType
== wxT("wxListBox"))
1056 wxExpr
*valueList
= (wxExpr
*) NULL
;
1058 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1060 wxStringList stringList
;
1061 wxExpr
*stringExpr
= valueList
->GetFirst();
1064 stringList
.Add(stringExpr
->StringValue());
1065 stringExpr
= stringExpr
->GetNext();
1067 controlItem
->SetStringValues(stringList
);
1069 // This is now obsolete: it's in the window style.
1070 // Check for wxSINGLE/wxMULTIPLE
1071 wxExpr
*mult
= (wxExpr
*) NULL
;
1073 controlItem->SetValue1(wxLB_SINGLE);
1075 if ((mult
= expr
->Nth(count
)) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
)))
1078 wxString m(mult->StringValue());
1079 if (m == "wxLB_MULTIPLE")
1080 controlItem->SetValue1(wxLB_MULTIPLE);
1081 else if (m == "wxLB_EXTENDED")
1082 controlItem->SetValue1(wxLB_EXTENDED);
1087 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1089 // Skip past the obsolete label font spec if there are two consecutive specs
1090 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1092 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1096 else if (controlType
== wxT("wxChoice"))
1098 wxExpr
*valueList
= (wxExpr
*) NULL
;
1099 // Check for default value list
1100 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1102 wxStringList stringList
;
1103 wxExpr
*stringExpr
= valueList
->GetFirst();
1106 stringList
.Add(stringExpr
->StringValue());
1107 stringExpr
= stringExpr
->GetNext();
1109 controlItem
->SetStringValues(stringList
);
1113 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1115 // Skip past the obsolete label font spec if there are two consecutive specs
1116 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1118 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1123 else if (controlType
== wxT("wxComboBox"))
1125 wxExpr
*textValue
= expr
->Nth(count
);
1126 if (textValue
&& (textValue
->Type() == PrologString
|| textValue
->Type() == PrologWord
))
1128 wxString
str(textValue
->StringValue());
1129 controlItem
->SetValue4(str
);
1133 wxExpr
*valueList
= (wxExpr
*) NULL
;
1134 // Check for default value list
1135 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1137 wxStringList stringList
;
1138 wxExpr
*stringExpr
= valueList
->GetFirst();
1141 stringList
.Add(stringExpr
->StringValue());
1142 stringExpr
= stringExpr
->GetNext();
1144 controlItem
->SetStringValues(stringList
);
1148 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1150 // Skip past the obsolete label font spec if there are two consecutive specs
1151 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1153 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1160 else if (controlType
== wxT("wxRadioBox"))
1162 wxExpr
*valueList
= (wxExpr
*) NULL
;
1163 // Check for default value list
1164 if ((valueList
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
))
1166 wxStringList stringList
;
1167 wxExpr
*stringExpr
= valueList
->GetFirst();
1170 stringList
.Add(stringExpr
->StringValue());
1171 stringExpr
= stringExpr
->GetNext();
1173 controlItem
->SetStringValues(stringList
);
1176 // majorDim (number of rows or cols)
1177 if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
))
1179 controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue());
1183 controlItem
->SetValue1(0);
1185 if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
)
1187 // Skip past the obsolete label font spec if there are two consecutive specs
1188 if (expr
->Nth(count
+1) && expr
->Nth(count
+1)->Type() == PrologList
)
1190 controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
)));
1198 return (wxItemResource
*) NULL
;
1203 // Forward declaration
1204 wxItemResource
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr
*expr
);
1207 * Interpet a menu item
1210 wxItemResource
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr
*expr
)
1212 wxItemResource
*item
= new wxItemResource
;
1214 wxExpr
*labelExpr
= expr
->Nth(0);
1215 wxExpr
*idExpr
= expr
->Nth(1);
1216 wxExpr
*helpExpr
= expr
->Nth(2);
1217 wxExpr
*checkableExpr
= expr
->Nth(3);
1219 // Further keywords/attributes to follow sometime...
1220 if (expr
->Number() == 0)
1222 // item->SetType(wxRESOURCE_TYPE_SEPARATOR);
1223 item
->SetType(wxT("wxMenuSeparator"));
1228 // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
1229 item
->SetType(wxT("wxMenu")); // Well, menu item, but doesn't matter.
1232 wxString
str(labelExpr
->StringValue());
1233 item
->SetTitle(str
);
1238 // If a string or word, must look up in identifier table.
1239 if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
))
1241 wxString
str(idExpr
->StringValue());
1242 id
= wxResourceGetIdentifier(str
, &table
);
1245 wxLogWarning(_("Could not resolve menu id '%s'. Use (non-zero) integer instead\nor provide #define (see manual for caveats)"),
1246 (const wxChar
*) idExpr
->StringValue());
1249 else if (idExpr
->Type() == PrologInteger
)
1250 id
= (int)idExpr
->IntegerValue();
1251 item
->SetValue1(id
);
1255 wxString
str(helpExpr
->StringValue());
1256 item
->SetValue4(str
);
1259 item
->SetValue2(checkableExpr
->IntegerValue());
1261 // Find the first expression that's a list, for submenu
1262 wxExpr
*subMenuExpr
= expr
->GetFirst();
1263 while (subMenuExpr
&& (subMenuExpr
->Type() != PrologList
))
1264 subMenuExpr
= subMenuExpr
->GetNext();
1268 wxItemResource
*child
= wxResourceInterpretMenuItem(table
, subMenuExpr
);
1269 item
->GetChildren().Append(child
);
1270 subMenuExpr
= subMenuExpr
->GetNext();
1277 * Interpret a nested list as a menu
1280 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
1282 wxItemResource *menu = new wxItemResource;
1283 // menu->SetType(wxTYPE_MENU);
1284 menu->SetType("wxMenu");
1285 wxExpr *element = expr->GetFirst();
1288 wxItemResource *item = wxResourceInterpretMenuItem(table, element);
1290 menu->GetChildren().Append(item);
1291 element = element->GetNext();
1297 wxItemResource
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr
*expr
)
1299 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1300 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1302 return (wxItemResource
*) NULL
;
1304 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1307 return (wxItemResource
*) NULL
;
1310 if (expr
->GetAttributeValue(wxT("name"), name
))
1312 menuResource
->SetName(name
);
1315 return menuResource
;
1318 wxItemResource
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr
*expr
)
1320 wxExpr
*listExpr
= (wxExpr
*) NULL
;
1321 expr
->GetAttributeValue(wxT("menu"), &listExpr
);
1323 return (wxItemResource
*) NULL
;
1325 wxItemResource
*resource
= new wxItemResource
;
1326 resource
->SetType(wxT("wxMenu"));
1327 // resource->SetType(wxTYPE_MENU);
1329 wxExpr
*element
= listExpr
->GetFirst();
1332 wxItemResource
*menuResource
= wxResourceInterpretMenuItem(table
, listExpr
);
1333 resource
->GetChildren().Append(menuResource
);
1334 element
= element
->GetNext();
1338 if (expr
->GetAttributeValue(wxT("name"), name
))
1340 resource
->SetName(name
);
1346 wxItemResource
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr
*WXUNUSED(expr
))
1348 return (wxItemResource
*) NULL
;
1351 wxItemResource
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr
*expr
)
1353 wxItemResource
*bitmapItem
= new wxItemResource
;
1354 // bitmapItem->SetType(wxTYPE_BITMAP);
1355 bitmapItem
->SetType(wxT("wxBitmap"));
1357 if (expr
->GetAttributeValue(wxT("name"), name
))
1359 bitmapItem
->SetName(name
);
1361 // Now parse all bitmap specifications
1362 wxExpr
*bitmapExpr
= expr
->GetFirst();
1365 if (bitmapExpr
->Number() == 3)
1367 wxString
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue());
1368 if (bitmapKeyword
== wxT("bitmap") || bitmapKeyword
== wxT("icon"))
1370 // The value part: always a list.
1371 wxExpr
*listExpr
= bitmapExpr
->Nth(2);
1372 if (listExpr
->Type() == PrologList
)
1374 wxItemResource
*bitmapSpec
= new wxItemResource
;
1375 // bitmapSpec->SetType(wxTYPE_BITMAP);
1376 bitmapSpec
->SetType(wxT("wxBitmap"));
1378 // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
1379 // where everything after 'filename' is optional.
1380 wxExpr
*nameExpr
= listExpr
->Nth(0);
1381 wxExpr
*typeExpr
= listExpr
->Nth(1);
1382 wxExpr
*platformExpr
= listExpr
->Nth(2);
1383 wxExpr
*coloursExpr
= listExpr
->Nth(3);
1384 wxExpr
*xresExpr
= listExpr
->Nth(4);
1385 wxExpr
*yresExpr
= listExpr
->Nth(5);
1386 if (nameExpr
&& nameExpr
->StringValue() != wxT(""))
1388 bitmapSpec
->SetName(nameExpr
->StringValue());
1390 if (typeExpr
&& typeExpr
->StringValue() != wxT(""))
1392 bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue()));
1395 bitmapSpec
->SetValue1(0);
1397 if (platformExpr
&& platformExpr
->StringValue() != wxT(""))
1399 wxString
plat(platformExpr
->StringValue());
1400 if (plat
== wxT("windows") || plat
== wxT("WINDOWS"))
1401 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
);
1402 else if (plat
== wxT("x") || plat
== wxT("X"))
1403 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
);
1404 else if (plat
== wxT("mac") || plat
== wxT("MAC"))
1405 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
);
1407 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1410 bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
);
1413 bitmapSpec
->SetValue3(coloursExpr
->IntegerValue());
1417 xres
= (int)xresExpr
->IntegerValue();
1419 yres
= (int)yresExpr
->IntegerValue();
1420 bitmapSpec
->SetSize(0, 0, xres
, yres
);
1422 bitmapItem
->GetChildren().Append(bitmapSpec
);
1426 bitmapExpr
= bitmapExpr
->GetNext();
1432 wxItemResource
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr
*expr
)
1434 wxItemResource
*item
= wxResourceInterpretBitmap(table
, expr
);
1437 // item->SetType(wxTYPE_ICON);
1438 item
->SetType(wxT("wxIcon"));
1442 return (wxItemResource
*) NULL
;
1445 // Interpret list expression as a font
1446 wxFont
wxResourceInterpretFontSpec(wxExpr
*expr
)
1448 if (expr
->Type() != PrologList
)
1452 int family
= wxSWISS
;
1453 int style
= wxNORMAL
;
1454 int weight
= wxNORMAL
;
1456 wxString
faceName(wxT(""));
1458 wxExpr
*pointExpr
= expr
->Nth(0);
1459 wxExpr
*familyExpr
= expr
->Nth(1);
1460 wxExpr
*styleExpr
= expr
->Nth(2);
1461 wxExpr
*weightExpr
= expr
->Nth(3);
1462 wxExpr
*underlineExpr
= expr
->Nth(4);
1463 wxExpr
*faceNameExpr
= expr
->Nth(5);
1465 point
= (int)pointExpr
->IntegerValue();
1470 str
= familyExpr
->StringValue();
1471 family
= (int)wxParseWindowStyle(str
);
1475 str
= styleExpr
->StringValue();
1476 style
= (int)wxParseWindowStyle(str
);
1480 str
= weightExpr
->StringValue();
1481 weight
= (int)wxParseWindowStyle(str
);
1484 underline
= (int)underlineExpr
->IntegerValue();
1486 faceName
= faceNameExpr
->StringValue();
1488 wxFont
font(point
, family
, style
, weight
, (underline
!= 0), faceName
);
1492 // Separate file for the remainder of this, for BC++/Win16
1494 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
1496 * (Re)allocate buffer for reading in from resource file
1499 bool wxReallocateResourceBuffer()
1501 if (!wxResourceBuffer
)
1503 wxResourceBufferSize
= 1000;
1504 wxResourceBuffer
= new char[wxResourceBufferSize
];
1507 if (wxResourceBuffer
)
1509 long newSize
= wxResourceBufferSize
+ 1000;
1510 char *tmp
= new char[(int)newSize
];
1511 strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
);
1512 delete[] wxResourceBuffer
;
1513 wxResourceBuffer
= tmp
;
1514 wxResourceBufferSize
= newSize
;
1519 static bool wxEatWhiteSpace(FILE *fd
)
1523 while ((ch
= getc(fd
)) != EOF
)
1538 ungetc(prev_ch
, fd
);
1546 while ((ch
= getc(fd
)) != EOF
)
1548 if (ch
== '/' && prev_ch
== '*')
1556 static char buffer
[255];
1557 fgets(buffer
, 255, fd
);
1561 ungetc(prev_ch
, fd
);
1575 static bool wxEatWhiteSpace(wxInputStream
*is
)
1577 int ch
= is
->GetC() ;
1578 if ((ch
!= ' ') && (ch
!= '/') && (ch
!= ' ') && (ch
!= 10) && (ch
!= 13) && (ch
!= 9))
1585 while (ch
== ' ' || ch
== 10 || ch
== 13 || ch
== 9)
1587 // Check for comment
1593 bool finished
= FALSE
;
1601 int newCh
= is
->GetC();
1616 return wxEatWhiteSpace(is
);
1619 bool wxGetResourceToken(FILE *fd
)
1621 if (!wxResourceBuffer
)
1622 wxReallocateResourceBuffer();
1623 wxResourceBuffer
[0] = 0;
1624 wxEatWhiteSpace(fd
);
1630 wxResourceBufferCount
= 0;
1637 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1640 // Escaped characters
1641 else if (ch
== '\\')
1643 int newCh
= getc(fd
);
1646 else if (newCh
== 10)
1654 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1655 wxReallocateResourceBuffer();
1656 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1657 wxResourceBufferCount
++;
1660 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1664 wxResourceBufferCount
= 0;
1666 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1668 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1669 wxReallocateResourceBuffer();
1670 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1671 wxResourceBufferCount
++;
1675 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1682 bool wxGetResourceToken(wxInputStream
*is
)
1684 if (!wxResourceBuffer
)
1685 wxReallocateResourceBuffer();
1686 wxResourceBuffer
[0] = 0;
1687 wxEatWhiteSpace(is
);
1689 int ch
= is
->GetC() ;
1693 wxResourceBufferCount
= 0;
1700 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1703 // Escaped characters
1704 else if (ch
== '\\')
1706 int newCh
= is
->GetC();
1709 else if (newCh
== 10)
1711 else if (newCh
== 13) // mac
1719 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1720 wxReallocateResourceBuffer();
1721 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
1722 wxResourceBufferCount
++;
1725 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1729 wxResourceBufferCount
= 0;
1731 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
1733 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
1734 wxReallocateResourceBuffer();
1735 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
1736 wxResourceBufferCount
++;
1740 wxResourceBuffer
[wxResourceBufferCount
] = 0;
1748 * Files are in form:
1749 static char *name = "....";
1750 with possible comments.
1753 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1756 table
= wxDefaultResourceTable
;
1758 // static or #define
1759 if (!wxGetResourceToken(fd
))
1765 if (strcmp(wxResourceBuffer
, "#define") == 0)
1767 wxGetResourceToken(fd
);
1768 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1769 wxGetResourceToken(fd
);
1770 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1771 if (wxIsdigit(value
[0]))
1773 int val
= (int)wxAtol(value
);
1774 wxResourceAddIdentifier(name
, val
, table
);
1778 wxLogWarning(_("#define %s must be an integer."), name
);
1788 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1790 wxGetResourceToken(fd
);
1791 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
1792 wxChar
*actualName
= name
;
1793 if (name
[0] == wxT('"'))
1794 actualName
= name
+ 1;
1795 int len
= wxStrlen(name
);
1796 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1798 if (!wxResourceParseIncludeFile(actualName
, table
))
1800 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1805 else if (strcmp(wxResourceBuffer
, "static") != 0)
1808 wxStrcpy(buf
, _("Found "));
1809 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
1810 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1816 if (!wxGetResourceToken(fd
))
1818 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1823 if (strcmp(wxResourceBuffer
, "char") != 0)
1825 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1830 if (!wxGetResourceToken(fd
))
1832 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1837 if (wxResourceBuffer
[0] != '*')
1839 wxLogWarning(_("Expected '*' whilst parsing resource."));
1842 wxChar nameBuf
[100];
1843 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
1847 if (!wxGetResourceToken(fd
))
1849 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1854 if (strcmp(wxResourceBuffer
, "=") != 0)
1856 wxLogWarning(_("Expected '=' whilst parsing resource."));
1861 if (!wxGetResourceToken(fd
))
1863 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1869 if (!db
.ReadPrologFromString(wxResourceBuffer
))
1871 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
1876 if (!wxGetResourceToken(fd
))
1883 bool wxResourceReadOneResource(wxInputStream
*fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
1886 table
= wxDefaultResourceTable
;
1888 // static or #define
1889 if (!wxGetResourceToken(fd
))
1895 if (strcmp(wxResourceBuffer
, "#define") == 0)
1897 wxGetResourceToken(fd
);
1898 wxChar
*name
= copystring(wxConvLibc
.cMB2WX(wxResourceBuffer
));
1899 wxGetResourceToken(fd
);
1900 wxChar
*value
= copystring(wxConvLibc
.cMB2WX(wxResourceBuffer
));
1901 if (wxIsalpha(value
[0]))
1903 int val
= (int)wxAtol(value
);
1904 wxResourceAddIdentifier(name
, val
, table
);
1908 wxLogWarning(_("#define %s must be an integer."), name
);
1918 else if (strcmp(wxResourceBuffer
, "#include") == 0)
1920 wxGetResourceToken(fd
);
1921 wxChar
*name
= copystring(wxConvLibc
.cMB2WX(wxResourceBuffer
));
1922 wxChar
*actualName
= name
;
1923 if (name
[0] == wxT('"'))
1924 actualName
= name
+ 1;
1925 int len
= wxStrlen(name
);
1926 if ((len
> 0) && (name
[len
-1] == wxT('"')))
1928 if (!wxResourceParseIncludeFile(actualName
, table
))
1930 wxLogWarning(_("Could not find resource include file %s."), actualName
);
1935 else if (strcmp(wxResourceBuffer
, "static") != 0)
1938 wxStrcpy(buf
, _("Found "));
1939 wxStrncat(buf
, wxConvLibc
.cMB2WX(wxResourceBuffer
), 30);
1940 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
1946 if (!wxGetResourceToken(fd
))
1948 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1953 if (strcmp(wxResourceBuffer
, "char") != 0)
1955 wxLogWarning(_("Expected 'char' whilst parsing resource."));
1960 if (!wxGetResourceToken(fd
))
1962 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1967 if (wxResourceBuffer
[0] != '*')
1969 wxLogWarning(_("Expected '*' whilst parsing resource."));
1973 strncpy(nameBuf
, wxResourceBuffer
+1, 99);
1976 if (!wxGetResourceToken(fd
))
1978 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1983 if (strcmp(wxResourceBuffer
, "=") != 0)
1985 wxLogWarning(_("Expected '=' whilst parsing resource."));
1990 if (!wxGetResourceToken(fd
))
1992 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
1998 if (!db
.ReadPrologFromString(wxResourceBuffer
))
2000 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
2005 if (!wxGetResourceToken(fd
))
2013 * Parses string window style into integer window style
2017 * Style flag parsing, e.g.
2018 * "wxSYSTEM_MENU | wxBORDER" -> integer
2021 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
)
2024 return (wxChar
*) NULL
;
2026 static wxChar buf
[150];
2027 int len
= wxStrlen(s
);
2030 while ((ii
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == wxT('_'))))
2038 // Eat whitespace and conjunction characters
2039 while ((ii
< len
) &&
2040 ((s
[ii
] == wxT(' ')) || (s
[ii
] == wxT('|')) || (s
[ii
] == wxT(','))))
2046 return (wxChar
*) NULL
;
2051 struct wxResourceBitListStruct
2057 static wxResourceBitListStruct wxResourceBitListTable
[] =
2060 { wxT("wxSINGLE"), wxLB_SINGLE
},
2061 { wxT("wxMULTIPLE"), wxLB_MULTIPLE
},
2062 { wxT("wxEXTENDED"), wxLB_EXTENDED
},
2063 { wxT("wxLB_SINGLE"), wxLB_SINGLE
},
2064 { wxT("wxLB_MULTIPLE"), wxLB_MULTIPLE
},
2065 { wxT("wxLB_EXTENDED"), wxLB_EXTENDED
},
2066 { wxT("wxLB_NEEDED_SB"), wxLB_NEEDED_SB
},
2067 { wxT("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB
},
2068 { wxT("wxLB_SORT"), wxLB_SORT
},
2069 { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW
},
2070 { wxT("wxLB_HSCROLL"), wxLB_HSCROLL
},
2073 { wxT("wxCB_SIMPLE"), wxCB_SIMPLE
},
2074 { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN
},
2075 { wxT("wxCB_READONLY"), wxCB_READONLY
},
2076 { wxT("wxCB_SORT"), wxCB_SORT
},
2079 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR
},
2080 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL
},
2081 { wxT("wxGA_VERTICAL"), wxGA_VERTICAL
},
2084 { wxT("wxPASSWORD"), wxPASSWORD
},
2085 { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER
},
2086 { wxT("wxTE_PASSWORD"), wxTE_PASSWORD
},
2087 { wxT("wxTE_READONLY"), wxTE_READONLY
},
2088 { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
},
2089 { wxT("wxTE_MULTILINE"), wxTE_MULTILINE
},
2090 { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL
},
2092 /* wxRadioBox/wxRadioButton */
2093 { wxT("wxRB_GROUP"), wxRB_GROUP
},
2094 { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS
},
2095 { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS
},
2096 { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL
},
2097 { wxT("wxRA_VERTICAL"), wxRA_VERTICAL
},
2100 { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL
},
2101 { wxT("wxSL_VERTICAL"), wxSL_VERTICAL
},
2102 { wxT("wxSL_AUTOTICKS"), wxSL_AUTOTICKS
},
2103 { wxT("wxSL_LABELS"), wxSL_LABELS
},
2104 { wxT("wxSL_LEFT"), wxSL_LEFT
},
2105 { wxT("wxSL_TOP"), wxSL_TOP
},
2106 { wxT("wxSL_RIGHT"), wxSL_RIGHT
},
2107 { wxT("wxSL_BOTTOM"), wxSL_BOTTOM
},
2108 { wxT("wxSL_BOTH"), wxSL_BOTH
},
2109 { wxT("wxSL_SELRANGE"), wxSL_SELRANGE
},
2112 { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL
},
2113 { wxT("wxSB_VERTICAL"), wxSB_VERTICAL
},
2116 { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW
},
2117 { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW
},
2120 { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS
},
2121 { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS
},
2122 { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT
},
2125 { wxT("wxLC_ICON"), wxLC_ICON
},
2126 { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON
},
2127 { wxT("wxLC_LIST"), wxLC_LIST
},
2128 { wxT("wxLC_REPORT"), wxLC_REPORT
},
2129 { wxT("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP
},
2130 { wxT("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT
},
2131 { wxT("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE
},
2132 { wxT("wxLC_USER_TEXT"), wxLC_USER_TEXT
},
2133 { wxT("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS
},
2134 { wxT("wxLC_NO_HEADER"), wxLC_NO_HEADER
},
2135 { wxT("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER
},
2136 { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL
},
2137 { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING
},
2138 { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING
},
2141 { wxT("wxSP_VERTICAL"), wxSP_VERTICAL
},
2142 { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
},
2143 { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
},
2144 { wxT("wxSP_WRAP"), wxSP_WRAP
},
2147 { wxT("wxSP_NOBORDER"), wxSP_NOBORDER
},
2148 { wxT("wxSP_3D"), wxSP_3D
},
2149 { wxT("wxSP_BORDER"), wxSP_BORDER
},
2152 { wxT("wxTC_MULTILINE"), wxTC_MULTILINE
},
2153 { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
},
2154 { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
},
2155 { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
},
2158 { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP
},
2161 { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH
},
2162 { wxT("wxALIGN_LEFT"), wxALIGN_LEFT
},
2163 { wxT("wxALIGN_CENTER"), wxALIGN_CENTER
},
2164 { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE
},
2165 { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT
},
2166 { wxT("wxCOLOURED"), wxCOLOURED
},
2169 { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
},
2170 { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
},
2171 { wxT("wxTB_VERTICAL"), wxTB_VERTICAL
},
2172 { wxT("wxTB_FLAT"), wxTB_FLAT
},
2175 { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL
},
2178 { wxT("wxVSCROLL"), wxVSCROLL
},
2179 { wxT("wxHSCROLL"), wxHSCROLL
},
2180 { wxT("wxCAPTION"), wxCAPTION
},
2181 { wxT("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
},
2182 { wxT("wxICONIZE"), wxICONIZE
},
2183 { wxT("wxMINIMIZE"), wxICONIZE
},
2184 { wxT("wxMAXIMIZE"), wxMAXIMIZE
},
2186 { wxT("wxMDI_PARENT"), 0},
2187 { wxT("wxMDI_CHILD"), 0},
2188 { wxT("wxTHICK_FRAME"), wxTHICK_FRAME
},
2189 { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER
},
2190 { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU
},
2191 { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
},
2192 { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
},
2193 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX
},
2194 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
},
2195 { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
},
2196 { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
},
2197 { wxT("wxBORDER"), wxBORDER
},
2198 { wxT("wxRETAINED"), wxRETAINED
},
2199 { wxT("wxNATIVE_IMPL"), 0},
2200 { wxT("wxEXTENDED_IMPL"), 0},
2201 { wxT("wxBACKINGSTORE"), wxBACKINGSTORE
},
2202 // { wxT("wxFLAT"), wxFLAT},
2203 // { wxT("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
2204 { wxT("wxFIXED_LENGTH"), 0},
2205 { wxT("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
},
2206 { wxT("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
},
2207 { wxT("wxRAISED_BORDER"), wxRAISED_BORDER
},
2208 { wxT("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
},
2209 { wxT("wxSTATIC_BORDER"), wxSTATIC_BORDER
},
2210 { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
},
2211 { wxT("wxNO_BORDER"), wxNO_BORDER
},
2212 { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
},
2213 { wxT("wxCLIP_SIBLINGS"), wxCLIP_SIBLINGS
},
2214 { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
2216 { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
},
2217 { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
},
2219 // Text font families
2220 { wxT("wxDEFAULT"), wxDEFAULT
},
2221 { wxT("wxDECORATIVE"), wxDECORATIVE
},
2222 { wxT("wxROMAN"), wxROMAN
},
2223 { wxT("wxSCRIPT"), wxSCRIPT
},
2224 { wxT("wxSWISS"), wxSWISS
},
2225 { wxT("wxMODERN"), wxMODERN
},
2226 { wxT("wxTELETYPE"), wxTELETYPE
},
2227 { wxT("wxVARIABLE"), wxVARIABLE
},
2228 { wxT("wxFIXED"), wxFIXED
},
2229 { wxT("wxNORMAL"), wxNORMAL
},
2230 { wxT("wxLIGHT"), wxLIGHT
},
2231 { wxT("wxBOLD"), wxBOLD
},
2232 { wxT("wxITALIC"), wxITALIC
},
2233 { wxT("wxSLANT"), wxSLANT
},
2234 { wxT("wxSOLID"), wxSOLID
},
2235 { wxT("wxDOT"), wxDOT
},
2236 { wxT("wxLONG_DASH"), wxLONG_DASH
},
2237 { wxT("wxSHORT_DASH"), wxSHORT_DASH
},
2238 { wxT("wxDOT_DASH"), wxDOT_DASH
},
2239 { wxT("wxUSER_DASH"), wxUSER_DASH
},
2240 { wxT("wxTRANSPARENT"), wxTRANSPARENT
},
2241 { wxT("wxSTIPPLE"), wxSTIPPLE
},
2242 { wxT("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
},
2243 { wxT("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
},
2244 { wxT("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
},
2245 { wxT("wxCROSS_HATCH"), wxCROSS_HATCH
},
2246 { wxT("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
},
2247 { wxT("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
},
2248 { wxT("wxJOIN_BEVEL"), wxJOIN_BEVEL
},
2249 { wxT("wxJOIN_MITER"), wxJOIN_MITER
},
2250 { wxT("wxJOIN_ROUND"), wxJOIN_ROUND
},
2251 { wxT("wxCAP_ROUND"), wxCAP_ROUND
},
2252 { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING
},
2253 { wxT("wxCAP_BUTT"), wxCAP_BUTT
},
2256 { wxT("wxCLEAR"), wxCLEAR
},
2257 { wxT("wxXOR"), wxXOR
},
2258 { wxT("wxINVERT"), wxINVERT
},
2259 { wxT("wxOR_REVERSE"), wxOR_REVERSE
},
2260 { wxT("wxAND_REVERSE"), wxAND_REVERSE
},
2261 { wxT("wxCOPY"), wxCOPY
},
2262 { wxT("wxAND"), wxAND
},
2263 { wxT("wxAND_INVERT"), wxAND_INVERT
},
2264 { wxT("wxNO_OP"), wxNO_OP
},
2265 { wxT("wxNOR"), wxNOR
},
2266 { wxT("wxEQUIV"), wxEQUIV
},
2267 { wxT("wxSRC_INVERT"), wxSRC_INVERT
},
2268 { wxT("wxOR_INVERT"), wxOR_INVERT
},
2269 { wxT("wxNAND"), wxNAND
},
2270 { wxT("wxOR"), wxOR
},
2271 { wxT("wxSET"), wxSET
},
2273 { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
},
2274 { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER
},
2275 { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE
},
2276 { wxT("wxWINDING_RULE"), wxWINDING_RULE
},
2277 { wxT("wxHORIZONTAL"), wxHORIZONTAL
},
2278 { wxT("wxVERTICAL"), wxVERTICAL
},
2279 { wxT("wxBOTH"), wxBOTH
},
2280 { wxT("wxCENTER_FRAME"), wxCENTER_FRAME
},
2281 { wxT("wxOK"), wxOK
},
2282 { wxT("wxYES_NO"), wxYES_NO
},
2283 { wxT("wxCANCEL"), wxCANCEL
},
2284 { wxT("wxYES"), wxYES
},
2285 { wxT("wxNO"), wxNO
},
2286 { wxT("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
},
2287 { wxT("wxICON_HAND"), wxICON_HAND
},
2288 { wxT("wxICON_QUESTION"), wxICON_QUESTION
},
2289 { wxT("wxICON_INFORMATION"), wxICON_INFORMATION
},
2290 { wxT("wxICON_STOP"), wxICON_STOP
},
2291 { wxT("wxICON_ASTERISK"), wxICON_ASTERISK
},
2292 { wxT("wxICON_MASK"), wxICON_MASK
},
2293 { wxT("wxCENTRE"), wxCENTRE
},
2294 { wxT("wxCENTER"), wxCENTRE
},
2295 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS
},
2296 { wxT("wxVERTICAL_LABEL"), 0},
2297 { wxT("wxHORIZONTAL_LABEL"), 0},
2299 // Bitmap types (not strictly styles)
2300 { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
},
2301 { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
},
2302 { wxT("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
},
2303 { wxT("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2304 { wxT("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
},
2305 { wxT("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
},
2306 { wxT("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
},
2307 { wxT("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
},
2308 { wxT("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
},
2309 { wxT("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
},
2310 { wxT("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
},
2311 { wxT("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
},
2312 { wxT("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
},
2313 { wxT("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
}
2316 static int wxResourceBitListCount
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
));
2318 long wxParseWindowStyle(const wxString
& bitListString
)
2323 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2324 while (word
!= NULL
)
2328 for (j
= 0; j
< wxResourceBitListCount
; j
++)
2329 if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0)
2331 bitList
|= wxResourceBitListTable
[j
].bits
;
2337 wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
);
2340 word
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
);
2346 * Load a bitmap from a wxWindows resource, choosing an optimum
2347 * depth and appropriate type.
2350 wxBitmap
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable
*table
)
2353 table
= wxDefaultResourceTable
;
2355 wxItemResource
*item
= table
->FindResource(resource
);
2358 if ((item
->GetType() == wxT("")) || (item
->GetType() != wxT("wxBitmap")))
2360 wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
);
2361 return wxNullBitmap
;
2363 int thisDepth
= wxDisplayDepth();
2364 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2366 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2368 // Try to find optimum bitmap for this platform/colour depth
2369 wxNode
*node
= item
->GetChildren().First();
2372 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2373 int platform
= (int)child
->GetValue2();
2374 int noColours
= (int)child
->GetValue3();
2376 char *name = child->GetName();
2377 int bitmapType = (int)child->GetValue1();
2378 int xRes = child->GetWidth();
2379 int yRes = child->GetHeight();
2384 case RESOURCE_PLATFORM_ANY
:
2386 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2387 optResource
= child
;
2390 // Maximise the number of colours.
2391 // If noColours is zero (unspecified), then assume this
2392 // is the right one.
2393 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2394 optResource
= child
;
2399 case RESOURCE_PLATFORM_WINDOWS
:
2401 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2402 optResource
= child
;
2405 // Maximise the number of colours
2406 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2407 optResource
= child
;
2413 case RESOURCE_PLATFORM_X
:
2415 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2416 optResource
= child
;
2419 // Maximise the number of colours
2420 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2421 optResource
= child
;
2427 case RESOURCE_PLATFORM_MAC
:
2429 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2430 optResource
= child
;
2433 // Maximise the number of colours
2434 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2435 optResource
= child
;
2443 node
= node
->Next();
2445 // If no matching resource, fail.
2447 return wxNullBitmap
;
2449 wxString name
= optResource
->GetName();
2450 int bitmapType
= (int)optResource
->GetValue1();
2453 case wxBITMAP_TYPE_XBM_DATA
:
2456 wxItemResource
*item
= table
->FindResource(name
);
2459 wxLogWarning(_("Failed to find XBM resource %s.\n"
2460 "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2461 return wxNullBitmap
;
2463 return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ;
2465 wxLogWarning(_("No XBM facility available!"));
2469 case wxBITMAP_TYPE_XPM_DATA
:
2471 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2472 wxItemResource
*item
= table
->FindResource(name
);
2475 wxLogWarning(_("Failed to find XPM resource %s.\nForgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
);
2476 return wxNullBitmap
;
2478 return wxBitmap((char **)item
->GetValue1());
2480 wxLogWarning(_("No XPM facility available!"));
2486 return wxBitmap(name
, (wxBitmapType
)bitmapType
);
2490 return wxNullBitmap
;
2495 wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
);
2496 return wxNullBitmap
;
2501 * Load an icon from a wxWindows resource, choosing an optimum
2502 * depth and appropriate type.
2505 wxIcon
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable
*table
)
2508 table
= wxDefaultResourceTable
;
2510 wxItemResource
*item
= table
->FindResource(resource
);
2513 if ((item
->GetType() == wxT("")) || wxStrcmp(item
->GetType(), wxT("wxIcon")) != 0)
2515 wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
);
2518 int thisDepth
= wxDisplayDepth();
2519 long thisNoColours
= (long)pow(2.0, (double)thisDepth
);
2521 wxItemResource
*optResource
= (wxItemResource
*) NULL
;
2523 // Try to find optimum icon for this platform/colour depth
2524 wxNode
*node
= item
->GetChildren().First();
2527 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2528 int platform
= (int)child
->GetValue2();
2529 int noColours
= (int)child
->GetValue3();
2531 char *name = child->GetName();
2532 int bitmapType = (int)child->GetValue1();
2533 int xRes = child->GetWidth();
2534 int yRes = child->GetHeight();
2539 case RESOURCE_PLATFORM_ANY
:
2541 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2542 optResource
= child
;
2545 // Maximise the number of colours.
2546 // If noColours is zero (unspecified), then assume this
2547 // is the right one.
2548 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2549 optResource
= child
;
2554 case RESOURCE_PLATFORM_WINDOWS
:
2556 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2557 optResource
= child
;
2560 // Maximise the number of colours
2561 if ((noColours
> 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2562 optResource
= child
;
2568 case RESOURCE_PLATFORM_X
:
2570 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2571 optResource
= child
;
2574 // Maximise the number of colours
2575 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2576 optResource
= child
;
2582 case RESOURCE_PLATFORM_MAC
:
2584 if (!optResource
&& ((noColours
== 0) || (noColours
<= thisNoColours
)))
2585 optResource
= child
;
2588 // Maximise the number of colours
2589 if ((noColours
== 0) || ((noColours
<= thisNoColours
) && (noColours
> optResource
->GetValue3())))
2590 optResource
= child
;
2598 node
= node
->Next();
2600 // If no matching resource, fail.
2604 wxString name
= optResource
->GetName();
2605 int bitmapType
= (int)optResource
->GetValue1();
2608 case wxBITMAP_TYPE_XBM_DATA
:
2611 wxItemResource
*item
= table
->FindResource(name
);
2614 wxLogWarning(_("Failed to find XBM resource %s.\n"
2615 "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
);
2618 return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3());
2620 wxLogWarning(_("No XBM facility available!"));
2624 case wxBITMAP_TYPE_XPM_DATA
:
2626 // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
2628 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
2629 wxItemResource *item = table->FindResource(name);
2633 sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name);
2637 return wxIcon((char **)item->GetValue1());
2639 wxLogWarning(_("No XPM facility available!"));
2642 wxLogWarning(_("No XPM icon facility available!"));
2648 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2650 return wxIcon(name
, bitmapType
);
2659 wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
);
2664 wxMenu
*wxResourceCreateMenu(wxItemResource
*item
)
2666 wxMenu
*menu
= new wxMenu
;
2667 wxNode
*node
= item
->GetChildren().First();
2670 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2671 if ((child
->GetType() != wxT("")) && (child
->GetType() == wxT("wxMenuSeparator")))
2672 menu
->AppendSeparator();
2673 else if (child
->GetChildren().Number() > 0)
2675 wxMenu
*subMenu
= wxResourceCreateMenu(child
);
2677 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4());
2681 menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0));
2683 node
= node
->Next();
2688 wxMenuBar
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable
*table
, wxMenuBar
*menuBar
)
2691 table
= wxDefaultResourceTable
;
2693 wxItemResource
*menuResource
= table
->FindResource(resource
);
2694 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2697 menuBar
= new wxMenuBar
;
2698 wxNode
*node
= menuResource
->GetChildren().First();
2701 wxItemResource
*child
= (wxItemResource
*)node
->Data();
2702 wxMenu
*menu
= wxResourceCreateMenu(child
);
2704 menuBar
->Append(menu
, child
->GetTitle());
2705 node
= node
->Next();
2709 return (wxMenuBar
*) NULL
;
2712 wxMenu
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable
*table
)
2715 table
= wxDefaultResourceTable
;
2717 wxItemResource
*menuResource
= table
->FindResource(resource
);
2718 if (menuResource
&& (menuResource
->GetType() != wxT("")) && (menuResource
->GetType() == wxT("wxMenu")))
2719 // if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
2720 return wxResourceCreateMenu(menuResource
);
2721 return (wxMenu
*) NULL
;
2724 // Global equivalents (so don't have to refer to default table explicitly)
2725 bool wxResourceParseData(const wxString
& resource
, wxResourceTable
*table
)
2728 table
= wxDefaultResourceTable
;
2730 return table
->ParseResourceData(resource
);
2733 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable
*table
)
2736 table
= wxDefaultResourceTable
;
2738 return table
->ParseResourceFile(filename
);
2741 // Register XBM/XPM data
2742 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable
*table
)
2745 table
= wxDefaultResourceTable
;
2747 return table
->RegisterResourceBitmapData(name
, bits
, width
, height
);
2750 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable
*table
)
2753 table
= wxDefaultResourceTable
;
2755 return table
->RegisterResourceBitmapData(name
, data
);
2758 void wxResourceClear(wxResourceTable
*table
)
2761 table
= wxDefaultResourceTable
;
2763 table
->ClearTable();
2770 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable
*table
)
2773 table
= wxDefaultResourceTable
;
2775 table
->identifiers
.Put(name
, (wxObject
*)(long)value
);
2779 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable
*table
)
2782 table
= wxDefaultResourceTable
;
2784 return (int)(long)table
->identifiers
.Get(name
);
2788 * Parse #include file for #defines (only)
2791 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable
*table
)
2794 table
= wxDefaultResourceTable
;
2796 FILE *fd
= wxFopen(f
, _T("r"));
2801 while (wxGetResourceToken(fd
))
2803 if (strcmp(wxResourceBuffer
, "#define") == 0)
2805 wxGetResourceToken(fd
);
2806 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2807 wxGetResourceToken(fd
);
2808 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2809 if (wxIsdigit(value
[0]))
2811 int val
= (int)wxAtol(value
);
2812 wxResourceAddIdentifier(name
, val
, table
);
2823 * Reading strings as if they were .wxr files
2826 static int getc_string(char *s
)
2828 int ch
= s
[wxResourceStringPtr
];
2833 wxResourceStringPtr
++;
2838 static int ungetc_string()
2840 wxResourceStringPtr
--;
2844 bool wxEatWhiteSpaceString(char *s
)
2848 while ((ch
= getc_string(s
)) != EOF
)
2860 ch
= getc_string(s
);
2871 while ((ch
= getc_string(s
)) != EOF
)
2873 if (ch
== '/' && prev_ch
== '*')
2895 bool wxGetResourceTokenString(char *s
)
2897 if (!wxResourceBuffer
)
2898 wxReallocateResourceBuffer();
2899 wxResourceBuffer
[0] = 0;
2900 wxEatWhiteSpaceString(s
);
2902 int ch
= getc_string(s
);
2906 wxResourceBufferCount
= 0;
2907 ch
= getc_string(s
);
2913 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2916 // Escaped characters
2917 else if (ch
== '\\')
2919 int newCh
= getc_string(s
);
2922 else if (newCh
== 10)
2930 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2931 wxReallocateResourceBuffer();
2932 wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
;
2933 wxResourceBufferCount
++;
2934 ch
= getc_string(s
);
2936 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2940 wxResourceBufferCount
= 0;
2942 while (ch
!= ' ' && ch
!= EOF
&& ch
!= ' ' && ch
!= 13 && ch
!= 9 && ch
!= 10)
2944 if (wxResourceBufferCount
>= wxResourceBufferSize
-1)
2945 wxReallocateResourceBuffer();
2946 wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
;
2947 wxResourceBufferCount
++;
2949 ch
= getc_string(s
);
2951 wxResourceBuffer
[wxResourceBufferCount
] = 0;
2959 * Files are in form:
2960 static char *name = "....";
2961 with possible comments.
2964 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable
*table
)
2967 table
= wxDefaultResourceTable
;
2969 // static or #define
2970 if (!wxGetResourceTokenString(s
))
2976 if (strcmp(wxResourceBuffer
, "#define") == 0)
2978 wxGetResourceTokenString(s
);
2979 wxChar
*name
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2980 wxGetResourceTokenString(s
);
2981 wxChar
*value
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
));
2982 if (wxIsdigit(value
[0]))
2984 int val
= (int)wxAtol(value
);
2985 wxResourceAddIdentifier(name
, val
, table
);
2989 wxLogWarning(_("#define %s must be an integer."), name
);
3000 else if (strcmp(wxResourceBuffer, "#include") == 0)
3002 wxGetResourceTokenString(s);
3003 char *name = copystring(wxResourceBuffer);
3004 char *actualName = name;
3006 actualName = name + 1;
3007 int len = strlen(name);
3008 if ((len > 0) && (name[len-1] == '"'))
3010 if (!wxResourceParseIncludeFile(actualName, table))
3013 sprintf(buf, _("Could not find resource include file %s."), actualName);
3020 else if (strcmp(wxResourceBuffer
, "static") != 0)
3023 wxStrcpy(buf
, _("Found "));
3024 wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30);
3025 wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource."));
3031 if (!wxGetResourceTokenString(s
))
3033 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3038 if (strcmp(wxResourceBuffer
, "char") != 0)
3040 wxLogWarning(_("Expected 'char' whilst parsing resource."));
3045 if (!wxGetResourceTokenString(s
))
3047 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3052 if (wxResourceBuffer
[0] != '*')
3054 wxLogWarning(_("Expected '*' whilst parsing resource."));
3057 wxChar nameBuf
[100];
3058 wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99);
3062 if (!wxGetResourceTokenString(s
))
3064 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3069 if (strcmp(wxResourceBuffer
, "=") != 0)
3071 wxLogWarning(_("Expected '=' whilst parsing resource."));
3076 if (!wxGetResourceTokenString(s
))
3078 wxLogWarning(_("Unexpected end of file whilst parsing resource."));
3084 if (!db
.ReadPrologFromString(wxResourceBuffer
))
3086 wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
);
3091 if (!wxGetResourceTokenString(s
))
3098 bool wxResourceParseString(char *s
, wxResourceTable
*table
)
3101 table
= wxDefaultResourceTable
;
3106 // Turn backslashes into spaces
3109 int len
= strlen(s
);
3111 for (i
= 0; i
< len
; i
++)
3112 if (s
[i
] == 92 && s
[i
+1] == 13)
3120 wxResourceStringPtr
= 0;
3123 while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
)
3127 return wxResourceInterpretResources(*table
, db
);
3131 * resource loading facility
3134 bool wxWindowBase::LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
)
3137 table
= wxDefaultResourceTable
;
3139 wxItemResource
*resource
= table
->FindResource((const wxChar
*)resourceName
);
3140 // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
3141 if (!resource
|| (resource
->GetType() == wxT("")) ||
3142 ! ((resource
->GetType() == wxT("wxDialog")) || (resource
->GetType() == wxT("wxPanel"))))
3145 wxString
title(resource
->GetTitle());
3146 long theWindowStyle
= resource
->GetStyle();
3147 bool isModal
= (resource
->GetValue1() != 0) ;
3148 int x
= resource
->GetX();
3149 int y
= resource
->GetY();
3150 int width
= resource
->GetWidth();
3151 int height
= resource
->GetHeight();
3152 wxString name
= resource
->GetName();
3154 if (IsKindOf(CLASSINFO(wxDialog
)))
3156 wxDialog
*dialogBox
= (wxDialog
*)this;
3157 long modalStyle
= isModal
? wxDIALOG_MODAL
: 0;
3158 if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
))
3161 // Only reset the client size if we know we're not going to do it again below.
3162 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0)
3163 dialogBox
->SetClientSize(width
, height
);
3165 else if (IsKindOf(CLASSINFO(wxPanel
)))
3167 wxPanel
* panel
= (wxPanel
*)this;
3168 if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
| wxTAB_TRAVERSAL
, name
))
3173 if (!((wxWindow
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
))
3177 if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
3179 // No need to do this since it's done in wxPanel or wxDialog constructor.
3180 // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
3184 if (resource
->GetFont().Ok())
3185 SetFont(resource
->GetFont());
3186 if (resource
->GetBackgroundColour().Ok())
3187 SetBackgroundColour(resource
->GetBackgroundColour());
3190 // Should have some kind of font at this point
3191 if (!GetFont().Ok())
3192 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
3193 if (!GetBackgroundColour().Ok())
3194 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
3196 // Only when we've created the window and set the font can we set the correct size,
3197 // if based on dialog units.
3198 if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
3200 wxSize sz
= ConvertDialogToPixels(wxSize(width
, height
));
3201 SetClientSize(sz
.x
, sz
.y
);
3203 wxPoint pt
= ConvertDialogToPixels(wxPoint(x
, y
));
3207 // Now create children
3208 wxNode
*node
= resource
->GetChildren().First();
3211 wxItemResource
*childResource
= (wxItemResource
*)node
->Data();
3213 (void) CreateItem(childResource
, resource
, table
);
3215 node
= node
->Next();
3220 wxControl
*wxWindowBase::CreateItem(const wxItemResource
*resource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
)
3223 table
= wxDefaultResourceTable
;
3224 return table
->CreateItem((wxWindow
*)this, resource
, parentResource
);
3228 #pragma warning(default:4706) // assignment within conditional expression
3234 #endif // wxUSE_WX_RESOURCES