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/radiobut.h" 
  43 #include "wx/listbox.h" 
  44 #include "wx/choice.h" 
  45 #include "wx/checkbox.h" 
  46 #include "wx/settings.h" 
  47 #include "wx/slider.h" 
  49 #include "wx/statbox.h" 
  50 #include "wx/statbmp.h" 
  54 #include "wx/textctrl.h" 
  55 #include "wx/msgdlg.h" 
  60 #include "wx/radiobut.h" 
  64 #include "wx/scrolbar.h" 
  68 #include "wx/combobox.h" 
  71 #include "wx/validate.h" 
  80 #include "wx/resource.h" 
  81 #include "wx/string.h" 
  82 #include "wx/wxexpr.h" 
  84 #include "wx/settings.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 wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable 
*table 
= (wxResourceTable 
*) NULL
); 
 101 wxResourceTable 
*wxDefaultResourceTable 
= (wxResourceTable 
*) NULL
; 
 103 char *wxResourceBuffer 
= (char *) NULL
; 
 104 long wxResourceBufferSize 
= 0; 
 105 long wxResourceBufferCount 
= 0; 
 106 int wxResourceStringPtr 
= 0; 
 108 void wxInitializeResourceSystem() 
 110     wxDefaultResourceTable 
= new wxResourceTable
; 
 113 void wxCleanUpResourceSystem() 
 115     delete wxDefaultResourceTable
; 
 116     if (wxResourceBuffer
) 
 117         delete[] wxResourceBuffer
; 
 120 void wxLogWarning(char *msg
) 
 122   wxMessageBox(msg
, _("Warning"), wxOK
); 
 125 #if !USE_SHARED_LIBRARY 
 126 IMPLEMENT_DYNAMIC_CLASS(wxItemResource
, wxObject
) 
 127 IMPLEMENT_DYNAMIC_CLASS(wxResourceTable
, wxHashTable
) 
 130 wxItemResource::wxItemResource() 
 136   m_x 
= m_y 
= m_width 
= m_height 
= 0; 
 137   m_value1 
= m_value2 
= m_value3 
= m_value5 
= 0; 
 143 wxItemResource::~wxItemResource() 
 145   wxNode 
*node 
= m_children
.First(); 
 148     wxItemResource 
*item 
= (wxItemResource 
*)node
->Data(); 
 151     node 
= m_children
.First(); 
 159 wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING
), identifiers(wxKEY_STRING
) 
 163 wxResourceTable::~wxResourceTable() 
 168 wxItemResource 
*wxResourceTable::FindResource(const wxString
& name
) const 
 170   wxItemResource 
*item 
= (wxItemResource 
*)Get(WXSTRINGCAST name
); 
 174 void wxResourceTable::AddResource(wxItemResource 
*item
) 
 176   wxString name 
= item
->GetName(); 
 178     name 
= item
->GetTitle(); 
 180     name 
= _T("no name"); 
 182   // Delete existing resource, if any. 
 188 bool wxResourceTable::DeleteResource(const wxString
& name
) 
 190   wxItemResource 
*item 
= (wxItemResource 
*)Delete(WXSTRINGCAST name
); 
 193     // See if any resource has this as its child; if so, delete from 
 194     // parent's child list. 
 196     wxNode 
*node 
= (wxNode 
*) NULL
; 
 197     while ((node 
= Next())) 
 199       wxItemResource 
*parent 
= (wxItemResource 
*)node
->Data(); 
 200       if (parent
->GetChildren().Member(item
)) 
 202         parent
->GetChildren().DeleteObject(item
); 
 214 bool wxResourceTable::ParseResourceFile(const wxString
& filename
) 
 218   FILE *fd 
= fopen(filename
.fn_str(), "r"); 
 222   while (wxResourceReadOneResource(fd
, db
, &eof
, this) && !eof
) 
 227   return wxResourceInterpretResources(*this, db
); 
 230 bool wxResourceTable::ParseResourceData(const wxString
& data
) 
 233   if (!db
.ReadFromString(data
)) 
 235     wxLogWarning(_("Ill-formed resource file syntax.")); 
 239   return wxResourceInterpretResources(*this, db
); 
 242 bool wxResourceTable::RegisterResourceBitmapData(const wxString
& name
, char bits
[], int width
, int height
) 
 244   // Register pre-loaded bitmap data 
 245   wxItemResource 
*item 
= new wxItemResource
; 
 246 //  item->SetType(wxRESOURCE_TYPE_XBM_DATA); 
 247   item
->SetType(_T("wxXBMData")); 
 249   item
->SetValue1((long)bits
); 
 250   item
->SetValue2((long)width
); 
 251   item
->SetValue3((long)height
); 
 256 bool wxResourceTable::RegisterResourceBitmapData(const wxString
& name
, char **data
) 
 258   // Register pre-loaded bitmap data 
 259   wxItemResource 
*item 
= new wxItemResource
; 
 260 //  item->SetType(wxRESOURCE_TYPE_XPM_DATA); 
 261   item
->SetType(_T("wxXPMData")); 
 263   item
->SetValue1((long)data
); 
 268 bool wxResourceTable::SaveResource(const wxString
& WXUNUSED(filename
)) 
 273 void wxResourceTable::ClearTable() 
 276   wxNode 
*node 
= Next(); 
 279     wxNode 
*next 
= Next(); 
 280     wxItemResource 
*item 
= (wxItemResource 
*)node
->Data(); 
 287 wxControl 
*wxResourceTable::CreateItem(wxWindow 
*parent
, const wxItemResource
* childResource
, const wxItemResource
* parentResource
) const 
 289   int id 
= childResource
->GetId(); 
 293   bool dlgUnits 
= ((parentResource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0); 
 295   wxControl 
*control 
= (wxControl 
*) NULL
; 
 296   wxString 
itemType(childResource
->GetType()); 
 302     pos 
= parent
->ConvertDialogToPixels(wxPoint(childResource
->GetX(), childResource
->GetY())); 
 303     size 
= parent
->ConvertDialogToPixels(wxSize(childResource
->GetWidth(), childResource
->GetHeight())); 
 307     pos 
= wxPoint(childResource
->GetX(), childResource
->GetY()); 
 308     size 
= wxSize(childResource
->GetWidth(), childResource
->GetHeight()); 
 311   if (itemType 
== wxString(_T("wxButton")) || itemType 
== wxString(_T("wxBitmapButton"))) 
 313         if (childResource
->GetValue4() != _T("")) 
 316           wxBitmap bitmap 
= childResource
->GetBitmap(); 
 319             bitmap 
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable 
*)this); 
 320             ((wxItemResource
*) childResource
)->SetBitmap(bitmap
); 
 323            control 
= new wxBitmapButton(parent
, id
, bitmap
, pos
, size
, 
 324                childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 327           // Normal, text button 
 328           control 
= new wxButton(parent
, id
, childResource
->GetTitle(), pos
, size
, 
 329            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 331    else if (itemType 
== wxString(_T("wxMessage")) || itemType 
== wxString(_T("wxStaticText")) || 
 332          itemType 
== wxString(_T("wxStaticBitmap"))) 
 334         if (childResource
->GetValue4() != _T("")) 
 337           wxBitmap bitmap 
= childResource
->GetBitmap(); 
 340             bitmap 
= wxResourceCreateBitmap(childResource
->GetValue4(), (wxResourceTable 
*)this); 
 341             ((wxItemResource
*) childResource
)->SetBitmap(bitmap
); 
 343 #if wxUSE_BITMAP_MESSAGE 
 345            control 
= new wxStaticBitmap(parent
, id
, bitmap
, pos
, size
, 
 346              childResource
->GetStyle(), childResource
->GetName()); 
 351            control 
= new wxStaticText(parent
, id
, childResource
->GetTitle(), pos
, size
, 
 352              childResource
->GetStyle(), childResource
->GetName()); 
 355    else if (itemType 
== wxString(_T("wxText")) || itemType 
== wxString(_T("wxTextCtrl")) || itemType 
== wxString(_T("wxMultiText"))) 
 357         control 
= new wxTextCtrl(parent
, id
, childResource
->GetValue4(), pos
, size
, 
 358            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 360    else if (itemType 
== wxString(_T("wxCheckBox"))) 
 362         control 
= new wxCheckBox(parent
, id
, childResource
->GetTitle(), pos
, size
, 
 363            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 365         ((wxCheckBox 
*)control
)->SetValue((childResource
->GetValue1() != 0)); 
 368    else if (itemType 
== wxString(_T("wxGauge"))) 
 370         control 
= new wxGauge(parent
, id
, (int)childResource
->GetValue2(), pos
, size
, 
 371            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 373         ((wxGauge 
*)control
)->SetValue((int)childResource
->GetValue1()); 
 376 #if wxUSE_RADIOBUTTON 
 377    else if (itemType 
== wxString(_T("wxRadioButton"))) 
 379         control 
= new wxRadioButton(parent
, id
, childResource
->GetTitle(), // (int)childResource->GetValue1(), 
 381            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 385    else if (itemType 
== wxString(_T("wxScrollBar"))) 
 387         control 
= new wxScrollBar(parent
, id
, pos
, size
, 
 388            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 390         ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1()); 
 391         ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2()); 
 392         ((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3()); 
 393         ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5()); 
 395                 ((wxScrollBar 
*)control
)->SetScrollbar((int)childResource
->GetValue1(),(int)childResource
->GetValue2(), 
 396                         (int)childResource
->GetValue3(),(int)(long)childResource
->GetValue5(),FALSE
); 
 400    else if (itemType 
== wxString(_T("wxSlider"))) 
 402         control 
= new wxSlider(parent
, id
, (int)childResource
->GetValue1(), 
 403            (int)childResource
->GetValue2(), (int)childResource
->GetValue3(), pos
, size
, 
 404            childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 406    else if (itemType 
== wxString(_T("wxGroupBox")) || itemType 
== wxString(_T("wxStaticBox"))) 
 408         control 
= new wxStaticBox(parent
, id
, childResource
->GetTitle(), pos
, size
, 
 409            childResource
->GetStyle(), childResource
->GetName()); 
 411    else if (itemType 
== wxString(_T("wxListBox"))) 
 413         wxStringList
& stringList 
= childResource
->GetStringValues(); 
 414         wxString 
*strings 
= (wxString 
*) NULL
; 
 416         if (stringList
.Number() > 0) 
 418           noStrings 
= stringList
.Number(); 
 419           strings 
= new wxString
[noStrings
]; 
 420           wxNode 
*node 
= stringList
.First(); 
 424             strings
[i
] = (wxChar 
*)node
->Data(); 
 429         control 
= new wxListBox(parent
, id
, pos
, size
, 
 430            noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 435    else if (itemType 
== wxString(_T("wxChoice"))) 
 437         wxStringList
& stringList 
= childResource
->GetStringValues(); 
 438         wxString 
*strings 
= (wxString 
*) NULL
; 
 440         if (stringList
.Number() > 0) 
 442           noStrings 
= stringList
.Number(); 
 443           strings 
= new wxString
[noStrings
]; 
 444           wxNode 
*node 
= stringList
.First(); 
 448             strings
[i
] = (wxChar 
*)node
->Data(); 
 453         control 
= new wxChoice(parent
, id
, pos
, size
, 
 454            noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 460    else if (itemType 
== wxString(_T("wxComboBox"))) 
 462         wxStringList
& stringList 
= childResource
->GetStringValues(); 
 463         wxString 
*strings 
= (wxString 
*) NULL
; 
 465         if (stringList
.Number() > 0) 
 467           noStrings 
= stringList
.Number(); 
 468           strings 
= new wxString
[noStrings
]; 
 469           wxNode 
*node 
= stringList
.First(); 
 473             strings
[i
] = (wxChar 
*)node
->Data(); 
 478         control 
= new wxComboBox(parent
, id
, childResource
->GetValue4(), pos
, size
, 
 479            noStrings
, strings
, childResource
->GetStyle(), wxDefaultValidator
, childResource
->GetName()); 
 485    else if (itemType 
== wxString(_T("wxRadioBox"))) 
 487         wxStringList
& stringList 
= childResource
->GetStringValues(); 
 488         wxString 
*strings 
= (wxString 
*) NULL
; 
 490         if (stringList
.Number() > 0) 
 492           noStrings 
= stringList
.Number(); 
 493           strings 
= new wxString
[noStrings
]; 
 494           wxNode 
*node 
= stringList
.First(); 
 498             strings
[i
] = (wxChar 
*)node
->Data(); 
 503         control 
= new wxRadioBox(parent
, (wxWindowID
) id
, wxString(childResource
->GetTitle()), pos
, size
, 
 504            noStrings
, strings
, (int)childResource
->GetValue1(), childResource
->GetStyle(), wxDefaultValidator
, 
 505          childResource
->GetName()); 
 511   if ((parentResource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0) 
 513     // Don't set font; will be inherited from parent. 
 517     if (control 
&& childResource
->GetFont().Ok()) 
 518       control
->SetFont(childResource
->GetFont()); 
 524  * Interpret database as a series of resources 
 527 bool wxResourceInterpretResources(wxResourceTable
& table
, wxExprDatabase
& db
) 
 529   wxNode 
*node 
= db
.First(); 
 532     wxExpr 
*clause 
= (wxExpr 
*)node
->Data(); 
 533    wxString 
functor(clause
->Functor()); 
 535     wxItemResource 
*item 
= (wxItemResource 
*) NULL
; 
 536     if (functor 
== _T("dialog")) 
 537       item 
= wxResourceInterpretDialog(table
, clause
); 
 538     else if (functor 
== _T("panel")) 
 539       item 
= wxResourceInterpretDialog(table
, clause
, TRUE
); 
 540     else if (functor 
== _T("menubar")) 
 541       item 
= wxResourceInterpretMenuBar(table
, clause
); 
 542     else if (functor 
== _T("menu")) 
 543       item 
= wxResourceInterpretMenu(table
, clause
); 
 544     else if (functor 
== _T("string")) 
 545       item 
= wxResourceInterpretString(table
, clause
); 
 546     else if (functor 
== _T("bitmap")) 
 547       item 
= wxResourceInterpretBitmap(table
, clause
); 
 548     else if (functor 
== _T("icon")) 
 549       item 
= wxResourceInterpretIcon(table
, clause
); 
 553       // Remove any existing resource of same name 
 554       if (item
->GetName() != _T("")) 
 555         table
.DeleteResource(item
->GetName()); 
 556       table
.AddResource(item
); 
 563 static const wxChar 
*g_ValidControlClasses
[] = 
 566     _T("wxBitmapButton"), 
 569     _T("wxStaticBitmap"), 
 577     _T("wxBitmapCheckBox"), 
 587 static bool wxIsValidControlClass(const wxString
& c
) 
 589    for ( size_t i 
= 0; i 
< WXSIZEOF(g_ValidControlClasses
); i
++ ) 
 591       if ( c 
== g_ValidControlClasses
[i
] ) 
 597 wxItemResource 
*wxResourceInterpretDialog(wxResourceTable
& table
, wxExpr 
*expr
, bool isPanel
) 
 599   wxItemResource 
*dialogItem 
= new wxItemResource
; 
 601     dialogItem
->SetType(_T("wxPanel")); 
 603     dialogItem
->SetType(_T("wxDialog")); 
 604   wxString style 
= _T(""); 
 605   wxString title 
= _T(""); 
 606   wxString name 
= _T(""); 
 607   wxString backColourHex 
= _T(""); 
 608   wxString labelColourHex 
= _T(""); 
 609   wxString buttonColourHex 
= _T(""); 
 611   long windowStyle 
= wxDEFAULT_DIALOG_STYLE
; 
 615   int x 
= 0; int y 
= 0; int width 
= -1; int height 
= -1; 
 617   wxExpr 
*labelFontExpr 
= (wxExpr 
*) NULL
; 
 618   wxExpr 
*buttonFontExpr 
= (wxExpr 
*) NULL
; 
 619   wxExpr 
*fontExpr 
= (wxExpr 
*) NULL
; 
 620   expr
->GetAttributeValue(_T("style"), style
); 
 621   expr
->GetAttributeValue(_T("name"), name
); 
 622   expr
->GetAttributeValue(_T("title"), title
); 
 623   expr
->GetAttributeValue(_T("x"), x
); 
 624   expr
->GetAttributeValue(_T("y"), y
); 
 625   expr
->GetAttributeValue(_T("width"), width
); 
 626   expr
->GetAttributeValue(_T("height"), height
); 
 627   expr
->GetAttributeValue(_T("modal"), isModal
); 
 628   expr
->GetAttributeValue(_T("label_font"), &labelFontExpr
); 
 629   expr
->GetAttributeValue(_T("button_font"), &buttonFontExpr
); 
 630   expr
->GetAttributeValue(_T("font"), &fontExpr
); 
 631   expr
->GetAttributeValue(_T("background_colour"), backColourHex
); 
 632   expr
->GetAttributeValue(_T("label_colour"), labelColourHex
); 
 633   expr
->GetAttributeValue(_T("button_colour"), buttonColourHex
); 
 635   int useDialogUnits 
= 0; 
 636   expr
->GetAttributeValue(_T("use_dialog_units"), useDialogUnits
); 
 637   if (useDialogUnits 
!= 0) 
 638     dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS
); 
 641   expr
->GetAttributeValue(_T("use_system_defaults"), useDefaults
); 
 642   if (useDefaults 
!= 0) 
 643     dialogItem
->SetResourceStyle(dialogItem
->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS
); 
 646   expr
->GetAttributeValue(_T("id"), id
); 
 647   dialogItem
->SetId(id
); 
 651     windowStyle 
= wxParseWindowStyle(style
); 
 653   dialogItem
->SetStyle(windowStyle
); 
 654   dialogItem
->SetValue1(isModal
); 
 655   if (windowStyle 
& wxDIALOG_MODAL
) // Uses style in wxWin 2 
 656     dialogItem
->SetValue1(TRUE
); 
 658   dialogItem
->SetName(name
); 
 659   dialogItem
->SetTitle(title
); 
 660   dialogItem
->SetSize(x
, y
, width
, height
); 
 662   if (backColourHex 
!= _T("")) 
 667     r 
= wxHexToDec(backColourHex
.Mid(0, 2)); 
 668     g 
= wxHexToDec(backColourHex
.Mid(2, 2)); 
 669     b 
= wxHexToDec(backColourHex
.Mid(4, 2)); 
 670     dialogItem
->SetBackgroundColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
)); 
 672   if (labelColourHex 
!= _T("")) 
 677     r 
= wxHexToDec(labelColourHex
.Mid(0, 2)); 
 678     g 
= wxHexToDec(labelColourHex
.Mid(2, 2)); 
 679     b 
= wxHexToDec(labelColourHex
.Mid(4, 2)); 
 680     dialogItem
->SetLabelColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
)); 
 682   if (buttonColourHex 
!= _T("")) 
 687     r 
= wxHexToDec(buttonColourHex
.Mid(0, 2)); 
 688     g 
= wxHexToDec(buttonColourHex
.Mid(2, 2)); 
 689     b 
= wxHexToDec(buttonColourHex
.Mid(4, 2)); 
 690     dialogItem
->SetButtonColour(wxColour((unsigned char)r
,(unsigned char)g
,(unsigned char)b
)); 
 694     dialogItem
->SetFont(wxResourceInterpretFontSpec(fontExpr
)); 
 695   else if (buttonFontExpr
) 
 696     dialogItem
->SetFont(wxResourceInterpretFontSpec(buttonFontExpr
)); 
 697   else if (labelFontExpr
) 
 698     dialogItem
->SetFont(wxResourceInterpretFontSpec(labelFontExpr
)); 
 700   // Now parse all controls 
 701   wxExpr 
*controlExpr 
= expr
->GetFirst(); 
 704     if (controlExpr
->Number() == 3) 
 706       wxString 
controlKeyword(controlExpr
->Nth(1)->StringValue()); 
 707       if (controlKeyword 
!= _T("") && controlKeyword 
== _T("control")) 
 709         // The value part: always a list. 
 710         wxExpr 
*listExpr 
= controlExpr
->Nth(2); 
 711         if (listExpr
->Type() == PrologList
) 
 713           wxItemResource 
*controlItem 
= wxResourceInterpretControl(table
, listExpr
); 
 716             dialogItem
->GetChildren().Append(controlItem
); 
 721     controlExpr 
= controlExpr
->GetNext(); 
 726 wxItemResource 
*wxResourceInterpretControl(wxResourceTable
& table
, wxExpr 
*expr
) 
 728   wxItemResource 
*controlItem 
= new wxItemResource
; 
 730   // First, find the standard features of a control definition: 
 731   // [optional integer/string id], control name, title, style, name, x, y, width, height 
 733   wxString controlType
; 
 738   long windowStyle 
= 0; 
 739   int x 
= 0; int y 
= 0; int width 
= -1; int height 
= -1; 
 742   wxExpr 
*expr1 
= expr
->Nth(0); 
 744   if ( expr1
->Type() == PrologString 
|| expr1
->Type() == PrologWord 
) 
 746    if ( wxIsValidControlClass(expr1
->StringValue()) ) 
 749       controlType 
= expr1
->StringValue(); 
 753         wxString 
str(expr1
->StringValue()); 
 754         id 
= wxResourceGetIdentifier(str
, &table
); 
 757           wxLogWarning(_("Could not resolve control class or id '%s'. " 
 758                          "Use (non-zero) integer instead\n or provide #define " 
 759                          "(see manual for caveats)"), 
 760                          (const wxChar
*) expr1
->StringValue()); 
 762         return (wxItemResource 
*) NULL
; 
 766          // Success - we have an id, so the 2nd element must be the control class. 
 767          controlType 
= expr
->Nth(1)->StringValue(); 
 772   else if (expr1
->Type() == PrologInteger
) 
 774         id 
= (int)expr1
->IntegerValue(); 
 775       // Success - we have an id, so the 2nd element must be the control class. 
 776       controlType 
= expr
->Nth(1)->StringValue(); 
 780   expr1 
= expr
->Nth(count
); 
 783    title 
= expr1
->StringValue(); 
 785   expr1 
= expr
->Nth(count
); 
 789     style 
= expr1
->StringValue(); 
 790     windowStyle 
= wxParseWindowStyle(style
); 
 793   expr1 
= expr
->Nth(count
); 
 796     name 
= expr1
->StringValue(); 
 798   expr1 
= expr
->Nth(count
); 
 801     x 
= (int)expr1
->IntegerValue(); 
 803   expr1 
= expr
->Nth(count
); 
 806     y 
= (int)expr1
->IntegerValue(); 
 808   expr1 
= expr
->Nth(count
); 
 811     width 
= (int)expr1
->IntegerValue(); 
 813   expr1 
= expr
->Nth(count
); 
 816     height 
= (int)expr1
->IntegerValue(); 
 818   controlItem
->SetStyle(windowStyle
); 
 819   controlItem
->SetName(name
); 
 820   controlItem
->SetTitle(title
); 
 821   controlItem
->SetSize(x
, y
, width
, height
); 
 822   controlItem
->SetType(controlType
); 
 823   controlItem
->SetId(id
); 
 825   if (controlType 
== _T("wxButton")) 
 827     // Check for bitmap resource name (in case loading old-style resource file) 
 828     if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
))) 
 830         wxString 
str(expr
->Nth(count
)->StringValue()); 
 835             controlItem
->SetValue4(str
); 
 836             controlItem
->SetType(_T("wxBitmapButton")); 
 839     if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 840       controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 842   else if (controlType 
== _T("wxBitmapButton")) 
 844     // Check for bitmap resource name 
 845     if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
))) 
 847         wxString 
str(expr
->Nth(count
)->StringValue()); 
 848         controlItem
->SetValue4(str
); 
 850         if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 851           controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 854   else if (controlType 
== _T("wxCheckBox")) 
 856     // Check for default value 
 857     if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 859       controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue()); 
 861       if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 862         controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 865 #if wxUSE_RADIOBUTTON 
 866   else if (controlType 
== _T("wxRadioButton")) 
 868     // Check for default value 
 869     if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 871       controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue()); 
 873       if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 874         controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 878   else if (controlType 
== _T("wxText") || controlType 
== _T("wxTextCtrl") || controlType 
== _T("wxMultiText")) 
 880     // Check for default value 
 881     if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
))) 
 883       wxString 
str(expr
->Nth(count
)->StringValue()); 
 884       controlItem
->SetValue4(str
); 
 887       if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 889         // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
 890        // Do nothing - no label font any more 
 892         if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 893           controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 897   else if (controlType 
== _T("wxMessage") || controlType 
== _T("wxStaticText")) 
 899     // Check for bitmap resource name (in case it's an old-style .wxr file) 
 900     if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
))) 
 902       wxString 
str(expr
->Nth(count
)->StringValue()); 
 903       controlItem
->SetValue4(str
); 
 905       controlItem
->SetType(_T("wxStaticText")); 
 907     if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 908       controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 910   else if (controlType 
== _T("wxStaticBitmap")) 
 912     // Check for bitmap resource name 
 913     if (expr
->Nth(count
) && ((expr
->Nth(count
)->Type() == PrologString
) || (expr
->Nth(count
)->Type() == PrologWord
))) 
 915       wxString 
str(expr
->Nth(count
)->StringValue()); 
 916       controlItem
->SetValue4(str
); 
 919     if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 920       controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 922   else if (controlType 
== _T("wxGroupBox") || controlType 
== _T("wxStaticBox")) 
 924     if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 925       controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 927   else if (controlType 
== _T("wxGauge")) 
 929     // Check for default value 
 930     if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 932       controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue()); 
 936       if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 938         controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue()); 
 941         if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 943          // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
 947           if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 948             controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 953   else if (controlType 
== _T("wxSlider")) 
 955     // Check for default value 
 956     if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 958       controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue()); 
 962       if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 964         controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue()); 
 968         if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 970           controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue()); 
 973           if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 975             // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
 979             if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
 980               controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
 986   else if (controlType 
== _T("wxScrollBar")) 
 989     if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 991       controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue()); 
 995       if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
 997         controlItem
->SetValue2(expr
->Nth(count
)->IntegerValue()); 
1001         if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
1003           controlItem
->SetValue3(expr
->Nth(count
)->IntegerValue()); 
1007           if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
1008             controlItem
->SetValue5(expr
->Nth(count
)->IntegerValue()); 
1013   else if (controlType 
== _T("wxListBox")) 
1015     wxExpr 
*valueList 
= (wxExpr 
*) NULL
; 
1017     if ((valueList 
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
)) 
1019       wxStringList stringList
; 
1020       wxExpr 
*stringExpr 
= valueList
->GetFirst(); 
1023         stringList
.Add(stringExpr
->StringValue()); 
1024         stringExpr 
= stringExpr
->GetNext(); 
1026       controlItem
->SetStringValues(stringList
); 
1028 // This is now obsolete: it's in the window style. 
1029       // Check for wxSINGLE/wxMULTIPLE 
1030       wxExpr 
*mult 
= (wxExpr 
*) NULL
; 
1032       controlItem->SetValue1(wxLB_SINGLE); 
1034       if ((mult 
= expr
->Nth(count
)) && ((mult
->Type() == PrologString
)||(mult
->Type() == PrologWord
))) 
1037         wxString m(mult->StringValue()); 
1038         if (m == "wxLB_MULTIPLE") 
1039           controlItem->SetValue1(wxLB_MULTIPLE); 
1040         else if (m == "wxLB_EXTENDED") 
1041           controlItem->SetValue1(wxLB_EXTENDED); 
1046       if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1048          // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
1050          if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1051            controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
1055   else if (controlType 
== _T("wxChoice")) 
1057     wxExpr 
*valueList 
= (wxExpr 
*) NULL
; 
1058     // Check for default value list 
1059     if ((valueList 
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
)) 
1061       wxStringList stringList
; 
1062       wxExpr 
*stringExpr 
= valueList
->GetFirst(); 
1065         stringList
.Add(stringExpr
->StringValue()); 
1066         stringExpr 
= stringExpr
->GetNext(); 
1068       controlItem
->SetStringValues(stringList
); 
1072       if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1074         // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
1077         if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1078           controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
1083   else if (controlType 
== _T("wxComboBox")) 
1085     wxExpr 
*textValue 
= expr
->Nth(count
); 
1086     if (textValue 
&& (textValue
->Type() == PrologString 
|| textValue
->Type() == PrologWord
)) 
1088       wxString 
str(textValue
->StringValue()); 
1089       controlItem
->SetValue4(str
); 
1093       wxExpr 
*valueList 
= (wxExpr 
*) NULL
; 
1094       // Check for default value list 
1095       if ((valueList 
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
)) 
1097         wxStringList stringList
; 
1098         wxExpr 
*stringExpr 
= valueList
->GetFirst(); 
1101           stringList
.Add(stringExpr
->StringValue()); 
1102           stringExpr 
= stringExpr
->GetNext(); 
1104         controlItem
->SetStringValues(stringList
); 
1108         if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1110           // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
1113           if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1114             controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
1121   else if (controlType 
== _T("wxRadioBox")) 
1123     wxExpr 
*valueList 
= (wxExpr 
*) NULL
; 
1124     // Check for default value list 
1125     if ((valueList 
= expr
->Nth(count
)) && (valueList
->Type() == PrologList
)) 
1127       wxStringList stringList
; 
1128       wxExpr 
*stringExpr 
= valueList
->GetFirst(); 
1131         stringList
.Add(stringExpr
->StringValue()); 
1132         stringExpr 
= stringExpr
->GetNext(); 
1134       controlItem
->SetStringValues(stringList
); 
1137       // majorDim (number of rows or cols) 
1138       if (expr
->Nth(count
) && (expr
->Nth(count
)->Type() == PrologInteger
)) 
1140         controlItem
->SetValue1(expr
->Nth(count
)->IntegerValue()); 
1144         controlItem
->SetValue1(0); 
1146       if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1148         // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); 
1151         if (expr
->Nth(count
) && expr
->Nth(count
)->Type() == PrologList
) 
1152           controlItem
->SetFont(wxResourceInterpretFontSpec(expr
->Nth(count
))); 
1160     return (wxItemResource 
*) NULL
; 
1165 // Forward declaration 
1166 wxItemResource 
*wxResourceInterpretMenu1(wxResourceTable
& table
, wxExpr 
*expr
); 
1169  * Interpet a menu item 
1172 wxItemResource 
*wxResourceInterpretMenuItem(wxResourceTable
& table
, wxExpr 
*expr
) 
1174   wxItemResource 
*item 
= new wxItemResource
; 
1176   wxExpr 
*labelExpr 
= expr
->Nth(0); 
1177   wxExpr 
*idExpr 
= expr
->Nth(1); 
1178   wxExpr 
*helpExpr 
= expr
->Nth(2); 
1179   wxExpr 
*checkableExpr 
= expr
->Nth(3); 
1181   // Further keywords/attributes to follow sometime... 
1182   if (expr
->Number() == 0) 
1184 //    item->SetType(wxRESOURCE_TYPE_SEPARATOR); 
1185     item
->SetType(_T("wxMenuSeparator")); 
1190 //    item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter. 
1191     item
->SetType(_T("wxMenu")); // Well, menu item, but doesn't matter. 
1194       wxString 
str(labelExpr
->StringValue()); 
1195       item
->SetTitle(str
); 
1200       // If a string or word, must look up in identifier table. 
1201       if ((idExpr
->Type() == PrologString
) || (idExpr
->Type() == PrologWord
)) 
1203         wxString 
str(idExpr
->StringValue()); 
1204         id 
= wxResourceGetIdentifier(str
, &table
); 
1207           wxLogWarning(_("Could not resolve menu id '%s'. " 
1208                          "Use (non-zero) integer instead\n" 
1209                          "or provide #define (see manual for caveats)"), 
1210                          (const wxChar
*) idExpr
->StringValue()); 
1213       else if (idExpr
->Type() == PrologInteger
) 
1214         id 
= (int)idExpr
->IntegerValue(); 
1215       item
->SetValue1(id
); 
1219       wxString 
str(helpExpr
->StringValue()); 
1220       item
->SetValue4(str
); 
1223       item
->SetValue2(checkableExpr
->IntegerValue()); 
1225     // Find the first expression that's a list, for submenu 
1226     wxExpr 
*subMenuExpr 
= expr
->GetFirst(); 
1227     while (subMenuExpr 
&& (subMenuExpr
->Type() != PrologList
)) 
1228       subMenuExpr 
= subMenuExpr
->GetNext(); 
1232       wxItemResource 
*child 
= wxResourceInterpretMenuItem(table
, subMenuExpr
); 
1233       item
->GetChildren().Append(child
); 
1234       subMenuExpr 
= subMenuExpr
->GetNext(); 
1241  * Interpret a nested list as a menu 
1244 wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr) 
1246   wxItemResource *menu = new wxItemResource; 
1247 //  menu->SetType(wxTYPE_MENU); 
1248   menu->SetType("wxMenu"); 
1249   wxExpr *element = expr->GetFirst(); 
1252     wxItemResource *item = wxResourceInterpretMenuItem(table, element); 
1254       menu->GetChildren().Append(item); 
1255     element = element->GetNext(); 
1261 wxItemResource 
*wxResourceInterpretMenu(wxResourceTable
& table
, wxExpr 
*expr
) 
1263   wxExpr 
*listExpr 
= (wxExpr 
*) NULL
; 
1264   expr
->GetAttributeValue(_T("menu"), &listExpr
); 
1266     return (wxItemResource 
*) NULL
; 
1268   wxItemResource 
*menuResource 
= wxResourceInterpretMenuItem(table
, listExpr
); 
1271     return (wxItemResource 
*) NULL
; 
1274   if (expr
->GetAttributeValue(_T("name"), name
)) 
1276     menuResource
->SetName(name
); 
1279   return menuResource
; 
1282 wxItemResource 
*wxResourceInterpretMenuBar(wxResourceTable
& table
, wxExpr 
*expr
) 
1284   wxExpr 
*listExpr 
= (wxExpr 
*) NULL
; 
1285   expr
->GetAttributeValue(_T("menu"), &listExpr
); 
1287     return (wxItemResource 
*) NULL
; 
1289   wxItemResource 
*resource 
= new wxItemResource
; 
1290   resource
->SetType(_T("wxMenu")); 
1291 //  resource->SetType(wxTYPE_MENU); 
1293   wxExpr 
*element 
= listExpr
->GetFirst(); 
1296     wxItemResource 
*menuResource 
= wxResourceInterpretMenuItem(table
, listExpr
); 
1297     resource
->GetChildren().Append(menuResource
); 
1298     element 
= element
->GetNext(); 
1302   if (expr
->GetAttributeValue(_T("name"), name
)) 
1304     resource
->SetName(name
); 
1310 wxItemResource 
*wxResourceInterpretString(wxResourceTable
& WXUNUSED(table
), wxExpr 
*WXUNUSED(expr
)) 
1312   return (wxItemResource 
*) NULL
; 
1315 wxItemResource 
*wxResourceInterpretBitmap(wxResourceTable
& WXUNUSED(table
), wxExpr 
*expr
) 
1317   wxItemResource 
*bitmapItem 
= new wxItemResource
; 
1318 //  bitmapItem->SetType(wxTYPE_BITMAP); 
1319   bitmapItem
->SetType(_T("wxBitmap")); 
1321   if (expr
->GetAttributeValue(_T("name"), name
)) 
1323     bitmapItem
->SetName(name
); 
1325   // Now parse all bitmap specifications 
1326   wxExpr 
*bitmapExpr 
= expr
->GetFirst(); 
1329     if (bitmapExpr
->Number() == 3) 
1331       wxString 
bitmapKeyword(bitmapExpr
->Nth(1)->StringValue()); 
1332       if (bitmapKeyword 
== _T("bitmap") || bitmapKeyword 
== _T("icon")) 
1334         // The value part: always a list. 
1335         wxExpr 
*listExpr 
= bitmapExpr
->Nth(2); 
1336         if (listExpr
->Type() == PrologList
) 
1338           wxItemResource 
*bitmapSpec 
= new wxItemResource
; 
1339 //          bitmapSpec->SetType(wxTYPE_BITMAP); 
1340           bitmapSpec
->SetType(_T("wxBitmap")); 
1342           // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution] 
1343           // where everything after 'filename' is optional. 
1344           wxExpr 
*nameExpr 
= listExpr
->Nth(0); 
1345           wxExpr 
*typeExpr 
= listExpr
->Nth(1); 
1346           wxExpr 
*platformExpr 
= listExpr
->Nth(2); 
1347           wxExpr 
*coloursExpr 
= listExpr
->Nth(3); 
1348           wxExpr 
*xresExpr 
= listExpr
->Nth(4); 
1349           wxExpr 
*yresExpr 
= listExpr
->Nth(5); 
1350           if (nameExpr 
&& nameExpr
->StringValue() != _T("")) 
1352             bitmapSpec
->SetName(nameExpr
->StringValue()); 
1354           if (typeExpr 
&& typeExpr
->StringValue() != _T("")) 
1356             bitmapSpec
->SetValue1(wxParseWindowStyle(typeExpr
->StringValue())); 
1359             bitmapSpec
->SetValue1(0); 
1361           if (platformExpr 
&& platformExpr
->StringValue() != _T("")) 
1363             wxString 
plat(platformExpr
->StringValue()); 
1364             if (plat 
== _T("windows") || plat 
== _T("WINDOWS")) 
1365               bitmapSpec
->SetValue2(RESOURCE_PLATFORM_WINDOWS
); 
1366             else if (plat 
== _T("x") || plat 
== _T("X")) 
1367               bitmapSpec
->SetValue2(RESOURCE_PLATFORM_X
); 
1368             else if (plat 
== _T("mac") || plat 
== _T("MAC")) 
1369               bitmapSpec
->SetValue2(RESOURCE_PLATFORM_MAC
); 
1371               bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
); 
1374             bitmapSpec
->SetValue2(RESOURCE_PLATFORM_ANY
); 
1377             bitmapSpec
->SetValue3(coloursExpr
->IntegerValue()); 
1381             xres 
= (int)xresExpr
->IntegerValue(); 
1383             yres 
= (int)yresExpr
->IntegerValue(); 
1384           bitmapSpec
->SetSize(0, 0, xres
, yres
); 
1386           bitmapItem
->GetChildren().Append(bitmapSpec
); 
1390     bitmapExpr 
= bitmapExpr
->GetNext(); 
1396 wxItemResource 
*wxResourceInterpretIcon(wxResourceTable
& table
, wxExpr 
*expr
) 
1398   wxItemResource 
*item 
= wxResourceInterpretBitmap(table
, expr
); 
1401 //    item->SetType(wxTYPE_ICON); 
1402     item
->SetType(_T("wxIcon")); 
1406     return (wxItemResource 
*) NULL
; 
1409 // Interpret list expression as a font 
1410 wxFont 
wxResourceInterpretFontSpec(wxExpr 
*expr
) 
1412   if (expr
->Type() != PrologList
) 
1416   int family 
= wxSWISS
; 
1417   int style 
= wxNORMAL
; 
1418   int weight 
= wxNORMAL
; 
1420   wxString 
faceName(_T("")); 
1422   wxExpr 
*pointExpr 
= expr
->Nth(0); 
1423   wxExpr 
*familyExpr 
= expr
->Nth(1); 
1424   wxExpr 
*styleExpr 
= expr
->Nth(2); 
1425   wxExpr 
*weightExpr 
= expr
->Nth(3); 
1426   wxExpr 
*underlineExpr 
= expr
->Nth(4); 
1427   wxExpr 
*faceNameExpr 
= expr
->Nth(5); 
1429     point 
= (int)pointExpr
->IntegerValue(); 
1434     str 
= familyExpr
->StringValue(); 
1435     family 
= (int)wxParseWindowStyle(str
); 
1439     str 
= styleExpr
->StringValue(); 
1440     style 
= (int)wxParseWindowStyle(str
); 
1444     str 
= weightExpr
->StringValue(); 
1445     weight 
= (int)wxParseWindowStyle(str
); 
1448     underline 
= (int)underlineExpr
->IntegerValue(); 
1450     faceName 
= faceNameExpr
->StringValue(); 
1452   wxFont 
font(point
, family
, style
, weight
, (underline 
!= 0), faceName
); 
1456 // Separate file for the remainder of this, for BC++/Win16 
1458 #if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__)) 
1460  * (Re)allocate buffer for reading in from resource file 
1463 bool wxReallocateResourceBuffer() 
1465   if (!wxResourceBuffer
) 
1467     wxResourceBufferSize 
= 1000; 
1468     wxResourceBuffer 
= new char[wxResourceBufferSize
]; 
1471   if (wxResourceBuffer
) 
1473     long newSize 
= wxResourceBufferSize 
+ 1000; 
1474     char *tmp 
= new char[(int)newSize
]; 
1475     strncpy(tmp
, wxResourceBuffer
, (int)wxResourceBufferCount
); 
1476     delete[] wxResourceBuffer
; 
1477     wxResourceBuffer 
= tmp
; 
1478     wxResourceBufferSize 
= newSize
; 
1483 static bool wxEatWhiteSpace(FILE *fd
) 
1487    while ((ch 
= getc(fd
)) != EOF
) 
1502                ungetc(prev_ch
, fd
); 
1510                while ((ch 
= getc(fd
)) != EOF
) 
1512                   if (ch 
== '/' && prev_ch 
== '*') 
1520                static char buffer
[255]; 
1521                fgets(buffer
, 255, fd
); 
1525                ungetc(prev_ch
, fd
); 
1540 bool wxGetResourceToken(FILE *fd
) 
1542   if (!wxResourceBuffer
) 
1543     wxReallocateResourceBuffer(); 
1544   wxResourceBuffer
[0] = 0; 
1545   wxEatWhiteSpace(fd
); 
1551     wxResourceBufferCount 
= 0; 
1558         wxResourceBuffer
[wxResourceBufferCount
] = 0; 
1561       // Escaped characters 
1562       else if (ch 
== '\\') 
1564         int newCh 
= getc(fd
); 
1567         else if (newCh 
== 10) 
1575       if (wxResourceBufferCount 
>= wxResourceBufferSize
-1) 
1576         wxReallocateResourceBuffer(); 
1577       wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
; 
1578       wxResourceBufferCount 
++; 
1581     wxResourceBuffer
[wxResourceBufferCount
] = 0; 
1585     wxResourceBufferCount 
= 0; 
1587     while (ch 
!= ' ' && ch 
!= EOF 
&& ch 
!= ' ' && ch 
!= 13 && ch 
!= 9 && ch 
!= 10) 
1589       if (wxResourceBufferCount 
>= wxResourceBufferSize
-1) 
1590         wxReallocateResourceBuffer(); 
1591       wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
; 
1592       wxResourceBufferCount 
++; 
1596     wxResourceBuffer
[wxResourceBufferCount
] = 0; 
1604  * Files are in form: 
1605   static char *name = "...."; 
1606   with possible comments. 
1609 bool wxResourceReadOneResource(FILE *fd
, wxExprDatabase
& db
, bool *eof
, wxResourceTable 
*table
) 
1612     table 
= wxDefaultResourceTable
; 
1614   // static or #define 
1615   if (!wxGetResourceToken(fd
)) 
1621   if (strcmp(wxResourceBuffer
, "#define") == 0) 
1623     wxGetResourceToken(fd
); 
1624     wxChar 
*name 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
1625     wxGetResourceToken(fd
); 
1626     wxChar 
*value 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
1627     if (wxIsalpha(value
[0])) 
1629       int val 
= (int)wxAtol(value
); 
1630       wxResourceAddIdentifier(name
, val
, table
); 
1634       wxLogWarning(_("#define %s must be an integer."), name
); 
1644   else if (strcmp(wxResourceBuffer
, "#include") == 0) 
1646     wxGetResourceToken(fd
); 
1647     wxChar 
*name 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
1648     wxChar 
*actualName 
= name
; 
1649     if (name
[0] == _T('"')) 
1650       actualName 
= name 
+ 1; 
1651     int len 
= wxStrlen(name
); 
1652     if ((len 
> 0) && (name
[len
-1] == _T('"'))) 
1654     if (!wxResourceParseIncludeFile(actualName
, table
)) 
1656       wxLogWarning(_("Could not find resource include file %s."), actualName
); 
1661   else if (strcmp(wxResourceBuffer
, "static") != 0) 
1664     wxStrcpy(buf
, _("Found ")); 
1665     wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30); 
1666     wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource.")); 
1672   if (!wxGetResourceToken(fd
)) 
1674     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
1679   if (strcmp(wxResourceBuffer
, "char") != 0) 
1681     wxLogWarning(_("Expected 'char' whilst parsing resource.")); 
1686   if (!wxGetResourceToken(fd
)) 
1688     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
1693   if (wxResourceBuffer
[0] != '*') 
1695     wxLogWarning(_("Expected '*' whilst parsing resource.")); 
1698   wxChar nameBuf
[100]; 
1699   wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99); 
1703   if (!wxGetResourceToken(fd
)) 
1705     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
1710   if (strcmp(wxResourceBuffer
, "=") != 0) 
1712     wxLogWarning(_("Expected '=' whilst parsing resource.")); 
1717   if (!wxGetResourceToken(fd
)) 
1719     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
1725     if (!db
.ReadPrologFromString(wxResourceBuffer
)) 
1727       wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
); 
1732   if (!wxGetResourceToken(fd
)) 
1740  * Parses string window style into integer window style 
1744  * Style flag parsing, e.g. 
1745  * "wxSYSTEM_MENU | wxBORDER" -> integer 
1748 wxChar
* wxResourceParseWord(wxChar
*s
, int *i
) 
1751     return (wxChar
*) NULL
; 
1753   static wxChar buf
[150]; 
1754   int len 
= wxStrlen(s
); 
1757   while ((ii 
< len
) && (wxIsalpha(s
[ii
]) || (s
[ii
] == _T('_')))) 
1765   // Eat whitespace and conjunction characters 
1766   while ((ii 
< len
) && 
1767          ((s
[ii
] == _T(' ')) || (s
[ii
] == _T('|')) || (s
[ii
] == _T(',')))) 
1773     return (wxChar
*) NULL
; 
1778 struct wxResourceBitListStruct
 
1784 static wxResourceBitListStruct wxResourceBitListTable
[] = 
1787   { _T("wxSINGLE"), wxLB_SINGLE 
}, 
1788   { _T("wxMULTIPLE"), wxLB_MULTIPLE 
}, 
1789   { _T("wxEXTENDED"), wxLB_EXTENDED 
}, 
1790   { _T("wxLB_SINGLE"), wxLB_SINGLE 
}, 
1791   { _T("wxLB_MULTIPLE"), wxLB_MULTIPLE 
}, 
1792   { _T("wxLB_EXTENDED"), wxLB_EXTENDED 
}, 
1793   { _T("wxLB_NEEDED_SB"), wxLB_NEEDED_SB 
}, 
1794   { _T("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB 
}, 
1795   { _T("wxLB_SORT"), wxLB_SORT 
}, 
1796   { _T("wxLB_OWNERDRAW"), wxLB_OWNERDRAW 
}, 
1797   { _T("wxLB_HSCROLL"), wxLB_HSCROLL 
}, 
1800   { _T("wxCB_SIMPLE"), wxCB_SIMPLE 
}, 
1801   { _T("wxCB_DROPDOWN"), wxCB_DROPDOWN 
}, 
1802   { _T("wxCB_READONLY"), wxCB_READONLY 
}, 
1803   { _T("wxCB_SORT"), wxCB_SORT 
}, 
1806   { _T("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR 
}, 
1807   { _T("wxGA_HORIZONTAL"), wxGA_HORIZONTAL 
}, 
1808   { _T("wxGA_VERTICAL"), wxGA_VERTICAL 
}, 
1811   { _T("wxPASSWORD"), wxPASSWORD
}, 
1812   { _T("wxPROCESS_ENTER"), wxPROCESS_ENTER
}, 
1813   { _T("wxTE_PASSWORD"), wxTE_PASSWORD
}, 
1814   { _T("wxTE_READONLY"), wxTE_READONLY
}, 
1815   { _T("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER
}, 
1816   { _T("wxTE_MULTILINE"), wxTE_MULTILINE
}, 
1818   /* wxRadioBox/wxRadioButton */ 
1819   { _T("wxRB_GROUP"), wxRB_GROUP 
}, 
1820   { _T("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS 
}, 
1821   { _T("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS 
}, 
1822   { _T("wxRA_HORIZONTAL"), wxRA_HORIZONTAL 
}, 
1823   { _T("wxRA_VERTICAL"), wxRA_VERTICAL 
}, 
1826   { _T("wxSL_HORIZONTAL"), wxSL_HORIZONTAL 
}, 
1827   { _T("wxSL_VERTICAL"), wxSL_VERTICAL 
}, 
1828   { _T("wxSL_AUTOTICKS"), wxSL_AUTOTICKS 
}, 
1829   { _T("wxSL_LABELS"), wxSL_LABELS 
}, 
1830   { _T("wxSL_LEFT"), wxSL_LEFT 
}, 
1831   { _T("wxSL_TOP"), wxSL_TOP 
}, 
1832   { _T("wxSL_RIGHT"), wxSL_RIGHT 
}, 
1833   { _T("wxSL_BOTTOM"), wxSL_BOTTOM 
}, 
1834   { _T("wxSL_BOTH"), wxSL_BOTH 
}, 
1835   { _T("wxSL_SELRANGE"), wxSL_SELRANGE 
}, 
1838   { _T("wxSB_HORIZONTAL"), wxSB_HORIZONTAL 
}, 
1839   { _T("wxSB_VERTICAL"), wxSB_VERTICAL 
}, 
1842   { _T("wxBU_AUTODRAW"), wxBU_AUTODRAW 
}, 
1843   { _T("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW 
}, 
1846   { _T("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS 
}, 
1847   { _T("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS 
}, 
1848   { _T("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT 
}, 
1851   { _T("wxLC_ICON"), wxLC_ICON 
}, 
1852   { _T("wxLC_SMALL_ICON"), wxLC_SMALL_ICON 
}, 
1853   { _T("wxLC_LIST"), wxLC_LIST 
}, 
1854   { _T("wxLC_REPORT"), wxLC_REPORT 
}, 
1855   { _T("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP 
}, 
1856   { _T("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT 
}, 
1857   { _T("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE 
}, 
1858   { _T("wxLC_USER_TEXT"), wxLC_USER_TEXT 
}, 
1859   { _T("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS 
}, 
1860   { _T("wxLC_NO_HEADER"), wxLC_NO_HEADER 
}, 
1861   { _T("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER 
}, 
1862   { _T("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL 
}, 
1863   { _T("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING 
}, 
1864   { _T("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING 
}, 
1867   { _T("wxSP_VERTICAL"), wxSP_VERTICAL
}, 
1868   { _T("wxSP_HORIZONTAL"), wxSP_HORIZONTAL
}, 
1869   { _T("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS
}, 
1870   { _T("wxSP_WRAP"), wxSP_WRAP
}, 
1873   { _T("wxSP_NOBORDER"), wxSP_NOBORDER
}, 
1874   { _T("wxSP_3D"), wxSP_3D
}, 
1875   { _T("wxSP_BORDER"), wxSP_BORDER
}, 
1878   { _T("wxTC_MULTILINE"), wxTC_MULTILINE
}, 
1879   { _T("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY
}, 
1880   { _T("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH
}, 
1881   { _T("wxTC_OWNERDRAW"), wxTC_OWNERDRAW
}, 
1884   { _T("wxST_SIZEGRIP"), wxST_SIZEGRIP
}, 
1887   { _T("wxFIXED_LENGTH"), wxFIXED_LENGTH
}, 
1888   { _T("wxALIGN_LEFT"), wxALIGN_LEFT
}, 
1889   { _T("wxALIGN_CENTER"), wxALIGN_CENTER
}, 
1890   { _T("wxALIGN_CENTRE"), wxALIGN_CENTRE
}, 
1891   { _T("wxALIGN_RIGHT"), wxALIGN_RIGHT
}, 
1892   { _T("wxCOLOURED"), wxCOLOURED
}, 
1895   { _T("wxTB_3DBUTTONS"), wxTB_3DBUTTONS
}, 
1896   { _T("wxTB_HORIZONTAL"), wxTB_HORIZONTAL
}, 
1897   { _T("wxTB_VERTICAL"), wxTB_VERTICAL
}, 
1898   { _T("wxTB_FLAT"), wxTB_FLAT
}, 
1901   { _T("wxDIALOG_MODAL"), wxDIALOG_MODAL 
}, 
1904   { _T("wxVSCROLL"), wxVSCROLL 
}, 
1905   { _T("wxHSCROLL"), wxHSCROLL 
}, 
1906   { _T("wxCAPTION"), wxCAPTION 
}, 
1907   { _T("wxSTAY_ON_TOP"), wxSTAY_ON_TOP
}, 
1908   { _T("wxICONIZE"), wxICONIZE
}, 
1909   { _T("wxMINIMIZE"), wxICONIZE
}, 
1910   { _T("wxMAXIMIZE"), wxMAXIMIZE
}, 
1912   { _T("wxMDI_PARENT"), 0}, 
1913   { _T("wxMDI_CHILD"), 0}, 
1914   { _T("wxTHICK_FRAME"), wxTHICK_FRAME
}, 
1915   { _T("wxRESIZE_BORDER"), wxRESIZE_BORDER
}, 
1916   { _T("wxSYSTEM_MENU"), wxSYSTEM_MENU
}, 
1917   { _T("wxMINIMIZE_BOX"), wxMINIMIZE_BOX
}, 
1918   { _T("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX
}, 
1919   { _T("wxRESIZE_BOX"), wxRESIZE_BOX
}, 
1920   { _T("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE
}, 
1921   { _T("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE
}, 
1922   { _T("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE
}, 
1923   { _T("wxBORDER"), wxBORDER
}, 
1924   { _T("wxRETAINED"), wxRETAINED
}, 
1925   { _T("wxNATIVE_IMPL"), 0}, 
1926   { _T("wxEXTENDED_IMPL"), 0}, 
1927   { _T("wxBACKINGSTORE"), wxBACKINGSTORE
}, 
1928 //  { _T("wxFLAT"), wxFLAT}, 
1929 //  { _T("wxMOTIF_RESIZE"), wxMOTIF_RESIZE}, 
1930   { _T("wxFIXED_LENGTH"), 0}, 
1931   { _T("wxDOUBLE_BORDER"), wxDOUBLE_BORDER
}, 
1932   { _T("wxSUNKEN_BORDER"), wxSUNKEN_BORDER
}, 
1933   { _T("wxRAISED_BORDER"), wxRAISED_BORDER
}, 
1934   { _T("wxSIMPLE_BORDER"), wxSIMPLE_BORDER
}, 
1935   { _T("wxSTATIC_BORDER"), wxSTATIC_BORDER
}, 
1936   { _T("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW
}, 
1937   { _T("wxNO_BORDER"), wxNO_BORDER
}, 
1938   { _T("wxCLIP_CHILDREN"), wxCLIP_CHILDREN
}, 
1940   { _T("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ
}, 
1941   { _T("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT
}, 
1943   // Text font families 
1944   { _T("wxDEFAULT"), wxDEFAULT
}, 
1945   { _T("wxDECORATIVE"), wxDECORATIVE
}, 
1946   { _T("wxROMAN"), wxROMAN
}, 
1947   { _T("wxSCRIPT"), wxSCRIPT
}, 
1948   { _T("wxSWISS"), wxSWISS
}, 
1949   { _T("wxMODERN"), wxMODERN
}, 
1950   { _T("wxTELETYPE"), wxTELETYPE
}, 
1951   { _T("wxVARIABLE"), wxVARIABLE
}, 
1952   { _T("wxFIXED"), wxFIXED
}, 
1953   { _T("wxNORMAL"), wxNORMAL
}, 
1954   { _T("wxLIGHT"), wxLIGHT
}, 
1955   { _T("wxBOLD"), wxBOLD
}, 
1956   { _T("wxITALIC"), wxITALIC
}, 
1957   { _T("wxSLANT"), wxSLANT
}, 
1958   { _T("wxSOLID"), wxSOLID
}, 
1959   { _T("wxDOT"), wxDOT
}, 
1960   { _T("wxLONG_DASH"), wxLONG_DASH
}, 
1961   { _T("wxSHORT_DASH"), wxSHORT_DASH
}, 
1962   { _T("wxDOT_DASH"), wxDOT_DASH
}, 
1963   { _T("wxUSER_DASH"), wxUSER_DASH
}, 
1964   { _T("wxTRANSPARENT"), wxTRANSPARENT
}, 
1965   { _T("wxSTIPPLE"), wxSTIPPLE
}, 
1966   { _T("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH
}, 
1967   { _T("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH
}, 
1968   { _T("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH
}, 
1969   { _T("wxCROSS_HATCH"), wxCROSS_HATCH
}, 
1970   { _T("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH
}, 
1971   { _T("wxVERTICAL_HATCH"), wxVERTICAL_HATCH
}, 
1972   { _T("wxJOIN_BEVEL"), wxJOIN_BEVEL
}, 
1973   { _T("wxJOIN_MITER"), wxJOIN_MITER
}, 
1974   { _T("wxJOIN_ROUND"), wxJOIN_ROUND
}, 
1975   { _T("wxCAP_ROUND"), wxCAP_ROUND
}, 
1976   { _T("wxCAP_PROJECTING"), wxCAP_PROJECTING
}, 
1977   { _T("wxCAP_BUTT"), wxCAP_BUTT
}, 
1980   { _T("wxCLEAR"), wxCLEAR
}, 
1981   { _T("wxXOR"), wxXOR
}, 
1982   { _T("wxINVERT"), wxINVERT
}, 
1983   { _T("wxOR_REVERSE"), wxOR_REVERSE
}, 
1984   { _T("wxAND_REVERSE"), wxAND_REVERSE
}, 
1985   { _T("wxCOPY"), wxCOPY
}, 
1986   { _T("wxAND"), wxAND
}, 
1987   { _T("wxAND_INVERT"), wxAND_INVERT
}, 
1988   { _T("wxNO_OP"), wxNO_OP
}, 
1989   { _T("wxNOR"), wxNOR
}, 
1990   { _T("wxEQUIV"), wxEQUIV
}, 
1991   { _T("wxSRC_INVERT"), wxSRC_INVERT
}, 
1992   { _T("wxOR_INVERT"), wxOR_INVERT
}, 
1993   { _T("wxNAND"), wxNAND
}, 
1994   { _T("wxOR"), wxOR
}, 
1995   { _T("wxSET"), wxSET
}, 
1997   { _T("wxFLOOD_SURFACE"), wxFLOOD_SURFACE
}, 
1998   { _T("wxFLOOD_BORDER"), wxFLOOD_BORDER
}, 
1999   { _T("wxODDEVEN_RULE"), wxODDEVEN_RULE
}, 
2000   { _T("wxWINDING_RULE"), wxWINDING_RULE
}, 
2001   { _T("wxHORIZONTAL"), wxHORIZONTAL
}, 
2002   { _T("wxVERTICAL"), wxVERTICAL
}, 
2003   { _T("wxBOTH"), wxBOTH
}, 
2004   { _T("wxCENTER_FRAME"), wxCENTER_FRAME
}, 
2005   { _T("wxOK"), wxOK
}, 
2006   { _T("wxYES_NO"), wxYES_NO
}, 
2007   { _T("wxCANCEL"), wxCANCEL
}, 
2008   { _T("wxYES"), wxYES
}, 
2009   { _T("wxNO"), wxNO
}, 
2010   { _T("wxICON_EXCLAMATION"), wxICON_EXCLAMATION
}, 
2011   { _T("wxICON_HAND"), wxICON_HAND
}, 
2012   { _T("wxICON_QUESTION"), wxICON_QUESTION
}, 
2013   { _T("wxICON_INFORMATION"), wxICON_INFORMATION
}, 
2014   { _T("wxICON_STOP"), wxICON_STOP
}, 
2015   { _T("wxICON_ASTERISK"), wxICON_ASTERISK
}, 
2016   { _T("wxICON_MASK"), wxICON_MASK
}, 
2017   { _T("wxCENTRE"), wxCENTRE
}, 
2018   { _T("wxCENTER"), wxCENTRE
}, 
2019   { _T("wxUSER_COLOURS"), wxUSER_COLOURS
}, 
2020   { _T("wxVERTICAL_LABEL"), 0}, 
2021   { _T("wxHORIZONTAL_LABEL"), 0}, 
2023   // Bitmap types (not strictly styles) 
2024   { _T("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM
}, 
2025   { _T("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM
}, 
2026   { _T("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP
}, 
2027   { _T("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
}, 
2028   { _T("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE
}, 
2029   { _T("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF
}, 
2030   { _T("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF
}, 
2031   { _T("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO
}, 
2032   { _T("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE
}, 
2033   { _T("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR
}, 
2034   { _T("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE
}, 
2035   { _T("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA
}, 
2036   { _T("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA
}, 
2037   { _T("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY
} 
2040 static int wxResourceBitListCount 
= (sizeof(wxResourceBitListTable
)/sizeof(wxResourceBitListStruct
)); 
2042 long wxParseWindowStyle(const wxString
& bitListString
) 
2047   while ((word 
= wxResourceParseWord(WXSTRINGCAST bitListString
, &i
))) 
2051     for (j 
= 0; j 
< wxResourceBitListCount
; j
++) 
2052       if (wxStrcmp(wxResourceBitListTable
[j
].word
, word
) == 0) 
2054         bitList 
|= wxResourceBitListTable
[j
].bits
; 
2060       wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word
); 
2068  * Load a bitmap from a wxWindows resource, choosing an optimum 
2069  * depth and appropriate type. 
2072 wxBitmap 
wxResourceCreateBitmap(const wxString
& resource
, wxResourceTable 
*table
) 
2075     table 
= wxDefaultResourceTable
; 
2077   wxItemResource 
*item 
= table
->FindResource(resource
); 
2080     if ((item
->GetType() == _T("")) || (item
->GetType() != _T("wxBitmap"))) 
2082       wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar
*) resource
); 
2083       return wxNullBitmap
; 
2085     int thisDepth 
= wxDisplayDepth(); 
2086     long thisNoColours 
= (long)pow(2.0, (double)thisDepth
); 
2088     wxItemResource 
*optResource 
= (wxItemResource 
*) NULL
; 
2090     // Try to find optimum bitmap for this platform/colour depth 
2091     wxNode 
*node 
= item
->GetChildren().First(); 
2094       wxItemResource 
*child 
= (wxItemResource 
*)node
->Data(); 
2095       int platform 
= (int)child
->GetValue2(); 
2096       int noColours 
= (int)child
->GetValue3(); 
2098       char *name = child->GetName(); 
2099       int bitmapType = (int)child->GetValue1(); 
2100       int xRes = child->GetWidth(); 
2101       int yRes = child->GetHeight(); 
2106         case RESOURCE_PLATFORM_ANY
: 
2108           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2109             optResource 
= child
; 
2112             // Maximise the number of colours. 
2113             // If noColours is zero (unspecified), then assume this 
2114             // is the right one. 
2115             if ((noColours 
== 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2116               optResource 
= child
; 
2121         case RESOURCE_PLATFORM_WINDOWS
: 
2123           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2124             optResource 
= child
; 
2127             // Maximise the number of colours 
2128             if ((noColours 
> 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2129               optResource 
= child
; 
2135         case RESOURCE_PLATFORM_X
: 
2137           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2138             optResource 
= child
; 
2141             // Maximise the number of colours 
2142             if ((noColours 
== 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2143               optResource 
= child
; 
2149         case RESOURCE_PLATFORM_MAC
: 
2151           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2152             optResource 
= child
; 
2155             // Maximise the number of colours 
2156             if ((noColours 
== 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2157               optResource 
= child
; 
2165       node 
= node
->Next(); 
2167     // If no matching resource, fail. 
2169       return wxNullBitmap
; 
2171     wxString name 
= optResource
->GetName(); 
2172     int bitmapType 
= (int)optResource
->GetValue1(); 
2175       case wxBITMAP_TYPE_XBM_DATA
: 
2178         wxItemResource 
*item 
= table
->FindResource(name
); 
2181           wxLogWarning(_("Failed to find XBM resource %s.\n" 
2182                          "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
); 
2183           return wxNullBitmap
; 
2185         return wxBitmap(item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()) ; 
2187         wxLogWarning(_("No XBM facility available!")); 
2191       case wxBITMAP_TYPE_XPM_DATA
: 
2193 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW) 
2194         wxItemResource 
*item 
= table
->FindResource(name
); 
2197           wxLogWarning(_("Failed to find XPM resource %s.\n" 
2198                          "Forgot to use wxResourceLoadBitmapData?"), (const wxChar
*) name
); 
2199           return wxNullBitmap
; 
2201         return wxBitmap((char **)item
->GetValue1()); 
2203         wxLogWarning(_("No XPM facility available!")); 
2209         return wxBitmap(name
, bitmapType
); 
2213     return wxNullBitmap
; 
2217     wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar
*) resource
); 
2218     return wxNullBitmap
; 
2223  * Load an icon from a wxWindows resource, choosing an optimum 
2224  * depth and appropriate type. 
2227 wxIcon 
wxResourceCreateIcon(const wxString
& resource
, wxResourceTable 
*table
) 
2230     table 
= wxDefaultResourceTable
; 
2232   wxItemResource 
*item 
= table
->FindResource(resource
); 
2235     if ((item
->GetType() == _T("")) || wxStrcmp(item
->GetType(), _T("wxIcon")) != 0) 
2237       wxLogWarning(_("%s not an icon resource specification."), (const wxChar
*) resource
); 
2240     int thisDepth 
= wxDisplayDepth(); 
2241     long thisNoColours 
= (long)pow(2.0, (double)thisDepth
); 
2243     wxItemResource 
*optResource 
= (wxItemResource 
*) NULL
; 
2245     // Try to find optimum icon for this platform/colour depth 
2246     wxNode 
*node 
= item
->GetChildren().First(); 
2249       wxItemResource 
*child 
= (wxItemResource 
*)node
->Data(); 
2250       int platform 
= (int)child
->GetValue2(); 
2251       int noColours 
= (int)child
->GetValue3(); 
2253       char *name = child->GetName(); 
2254       int bitmapType = (int)child->GetValue1(); 
2255       int xRes = child->GetWidth(); 
2256       int yRes = child->GetHeight(); 
2261         case RESOURCE_PLATFORM_ANY
: 
2263           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2264             optResource 
= child
; 
2267             // Maximise the number of colours. 
2268             // If noColours is zero (unspecified), then assume this 
2269             // is the right one. 
2270             if ((noColours 
== 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2271               optResource 
= child
; 
2276         case RESOURCE_PLATFORM_WINDOWS
: 
2278           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2279             optResource 
= child
; 
2282             // Maximise the number of colours 
2283             if ((noColours 
> 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2284               optResource 
= child
; 
2290         case RESOURCE_PLATFORM_X
: 
2292           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2293             optResource 
= child
; 
2296             // Maximise the number of colours 
2297             if ((noColours 
== 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2298               optResource 
= child
; 
2304         case RESOURCE_PLATFORM_MAC
: 
2306           if (!optResource 
&& ((noColours 
== 0) || (noColours 
<= thisNoColours
))) 
2307             optResource 
= child
; 
2310             // Maximise the number of colours 
2311             if ((noColours 
== 0) || ((noColours 
<= thisNoColours
) && (noColours 
> optResource
->GetValue3()))) 
2312               optResource 
= child
; 
2320       node 
= node
->Next(); 
2322     // If no matching resource, fail. 
2326     wxString name 
= optResource
->GetName(); 
2327     int bitmapType 
= (int)optResource
->GetValue1(); 
2330       case wxBITMAP_TYPE_XBM_DATA
: 
2333         wxItemResource 
*item 
= table
->FindResource(name
); 
2336           wxLogWarning(_("Failed to find XBM resource %s.\n" 
2337                          "Forgot to use wxResourceLoadIconData?"), (const wxChar
*) name
); 
2340         return wxIcon((const char **)item
->GetValue1(), (int)item
->GetValue2(), (int)item
->GetValue3()); 
2342         wxLogWarning(_("No XBM facility available!")); 
2346       case wxBITMAP_TYPE_XPM_DATA
: 
2348       // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS *** 
2350 #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW) 
2351         wxItemResource *item = table->FindResource(name); 
2355           sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name); 
2359         return wxIcon((char **)item->GetValue1()); 
2361         wxLogWarning(_("No XPM facility available!")); 
2364         wxLogWarning(_("No XPM icon facility available!")); 
2370         wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
); 
2372         return wxIcon(name
, bitmapType
); 
2381     wxLogWarning(_("Icon resource specification %s not found."), (const wxChar
*) resource
); 
2386 wxMenu 
*wxResourceCreateMenu(wxItemResource 
*item
) 
2388   wxMenu 
*menu 
= new wxMenu
; 
2389   wxNode 
*node 
= item
->GetChildren().First(); 
2392     wxItemResource 
*child 
= (wxItemResource 
*)node
->Data(); 
2393     if ((child
->GetType() != _T("")) && (child
->GetType() == _T("wxMenuSeparator"))) 
2394       menu
->AppendSeparator(); 
2395     else if (child
->GetChildren().Number() > 0) 
2397       wxMenu 
*subMenu 
= wxResourceCreateMenu(child
); 
2399         menu
->Append((int)child
->GetValue1(), child
->GetTitle(), subMenu
, child
->GetValue4()); 
2403       menu
->Append((int)child
->GetValue1(), child
->GetTitle(), child
->GetValue4(), (child
->GetValue2() != 0)); 
2405     node 
= node
->Next(); 
2410 wxMenuBar 
*wxResourceCreateMenuBar(const wxString
& resource
, wxResourceTable 
*table
, wxMenuBar 
*menuBar
) 
2413     table 
= wxDefaultResourceTable
; 
2415   wxItemResource 
*menuResource 
= table
->FindResource(resource
); 
2416   if (menuResource 
&& (menuResource
->GetType() != _T("")) && (menuResource
->GetType() == _T("wxMenu"))) 
2419       menuBar 
= new wxMenuBar
; 
2420     wxNode 
*node 
= menuResource
->GetChildren().First(); 
2423       wxItemResource 
*child 
= (wxItemResource 
*)node
->Data(); 
2424       wxMenu 
*menu 
= wxResourceCreateMenu(child
); 
2426         menuBar
->Append(menu
, child
->GetTitle()); 
2427       node 
= node
->Next(); 
2431   return (wxMenuBar 
*) NULL
; 
2434 wxMenu 
*wxResourceCreateMenu(const wxString
& resource
, wxResourceTable 
*table
) 
2437     table 
= wxDefaultResourceTable
; 
2439   wxItemResource 
*menuResource 
= table
->FindResource(resource
); 
2440   if (menuResource 
&& (menuResource
->GetType() != _T("")) && (menuResource
->GetType() == _T("wxMenu"))) 
2441 //  if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) 
2442     return wxResourceCreateMenu(menuResource
); 
2443   return (wxMenu 
*) NULL
; 
2446 // Global equivalents (so don't have to refer to default table explicitly) 
2447 bool wxResourceParseData(const wxString
& resource
, wxResourceTable 
*table
) 
2450     table 
= wxDefaultResourceTable
; 
2452   return table
->ParseResourceData(resource
); 
2455 bool wxResourceParseFile(const wxString
& filename
, wxResourceTable 
*table
) 
2458     table 
= wxDefaultResourceTable
; 
2460   return table
->ParseResourceFile(filename
); 
2463 // Register XBM/XPM data 
2464 bool wxResourceRegisterBitmapData(const wxString
& name
, char bits
[], int width
, int height
, wxResourceTable 
*table
) 
2467     table 
= wxDefaultResourceTable
; 
2469   return table
->RegisterResourceBitmapData(name
, bits
, width
, height
); 
2472 bool wxResourceRegisterBitmapData(const wxString
& name
, char **data
, wxResourceTable 
*table
) 
2475     table 
= wxDefaultResourceTable
; 
2477   return table
->RegisterResourceBitmapData(name
, data
); 
2480 void wxResourceClear(wxResourceTable 
*table
) 
2483     table 
= wxDefaultResourceTable
; 
2485   table
->ClearTable(); 
2492 bool wxResourceAddIdentifier(const wxString
& name
, int value
, wxResourceTable 
*table
) 
2495     table 
= wxDefaultResourceTable
; 
2497   table
->identifiers
.Put(name
, (wxObject 
*)value
); 
2501 int wxResourceGetIdentifier(const wxString
& name
, wxResourceTable 
*table
) 
2504     table 
= wxDefaultResourceTable
; 
2506   return (int)table
->identifiers
.Get(name
); 
2510  * Parse #include file for #defines (only) 
2513 bool wxResourceParseIncludeFile(const wxString
& f
, wxResourceTable 
*table
) 
2516     table 
= wxDefaultResourceTable
; 
2518   FILE *fd 
= fopen(f
.fn_str(), "r"); 
2523   while (wxGetResourceToken(fd
)) 
2525     if (strcmp(wxResourceBuffer
, "#define") == 0) 
2527       wxGetResourceToken(fd
); 
2528       wxChar 
*name 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
2529       wxGetResourceToken(fd
); 
2530       wxChar 
*value 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
2531       if (wxIsdigit(value
[0])) 
2533         int val 
= (int)wxAtol(value
); 
2534         wxResourceAddIdentifier(name
, val
, table
); 
2545  * Reading strings as if they were .wxr files 
2548 static int getc_string(char *s
) 
2550   int ch 
= s
[wxResourceStringPtr
]; 
2555     wxResourceStringPtr 
++; 
2560 static int ungetc_string() 
2562   wxResourceStringPtr 
--; 
2566 bool wxEatWhiteSpaceString(char *s
) 
2570    while ((ch 
= getc_string(s
)) != EOF
) 
2582             ch 
= getc_string(s
); 
2593                while ((ch 
= getc_string(s
)) != EOF
) 
2595                   if (ch 
== '/' && prev_ch 
== '*') 
2617 bool wxGetResourceTokenString(char *s
) 
2619   if (!wxResourceBuffer
) 
2620     wxReallocateResourceBuffer(); 
2621   wxResourceBuffer
[0] = 0; 
2622   wxEatWhiteSpaceString(s
); 
2624   int ch 
= getc_string(s
); 
2628     wxResourceBufferCount 
= 0; 
2629     ch 
= getc_string(s
); 
2635         wxResourceBuffer
[wxResourceBufferCount
] = 0; 
2638       // Escaped characters 
2639       else if (ch 
== '\\') 
2641         int newCh 
= getc_string(s
); 
2644         else if (newCh 
== 10) 
2652       if (wxResourceBufferCount 
>= wxResourceBufferSize
-1) 
2653         wxReallocateResourceBuffer(); 
2654       wxResourceBuffer
[wxResourceBufferCount
] = (char)actualCh
; 
2655       wxResourceBufferCount 
++; 
2656       ch 
= getc_string(s
); 
2658     wxResourceBuffer
[wxResourceBufferCount
] = 0; 
2662     wxResourceBufferCount 
= 0; 
2664     while (ch 
!= ' ' && ch 
!= EOF 
&& ch 
!= ' ' && ch 
!= 13 && ch 
!= 9 && ch 
!= 10) 
2666       if (wxResourceBufferCount 
>= wxResourceBufferSize
-1) 
2667         wxReallocateResourceBuffer(); 
2668       wxResourceBuffer
[wxResourceBufferCount
] = (char)ch
; 
2669       wxResourceBufferCount 
++; 
2671       ch 
= getc_string(s
); 
2673     wxResourceBuffer
[wxResourceBufferCount
] = 0; 
2681  * Files are in form: 
2682   static char *name = "...."; 
2683   with possible comments. 
2686 bool wxResourceReadOneResourceString(char *s
, wxExprDatabase
& db
, bool *eof
, wxResourceTable 
*table
) 
2689     table 
= wxDefaultResourceTable
; 
2691   // static or #define 
2692   if (!wxGetResourceTokenString(s
)) 
2698   if (strcmp(wxResourceBuffer
, "#define") == 0) 
2700     wxGetResourceTokenString(s
); 
2701     wxChar 
*name 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
2702     wxGetResourceTokenString(s
); 
2703     wxChar 
*value 
= copystring(wxConvCurrent
->cMB2WX(wxResourceBuffer
)); 
2704     if (wxIsalpha(value
[0])) 
2706       int val 
= (int)wxAtol(value
); 
2707       wxResourceAddIdentifier(name
, val
, table
); 
2711       wxLogWarning(_("#define %s must be an integer."), name
); 
2722   else if (strcmp(wxResourceBuffer, "#include") == 0) 
2724     wxGetResourceTokenString(s); 
2725     char *name = copystring(wxResourceBuffer); 
2726     char *actualName = name; 
2728       actualName = name + 1; 
2729     int len = strlen(name); 
2730     if ((len > 0) && (name[len-1] == '"')) 
2732     if (!wxResourceParseIncludeFile(actualName, table)) 
2735       sprintf(buf, _("Could not find resource include file %s."), actualName); 
2742   else if (strcmp(wxResourceBuffer
, "static") != 0) 
2745     wxStrcpy(buf
, _("Found ")); 
2746     wxStrncat(buf
, wxConvCurrent
->cMB2WX(wxResourceBuffer
), 30); 
2747     wxStrcat(buf
, _(", expected static, #include or #define\nwhilst parsing resource.")); 
2753   if (!wxGetResourceTokenString(s
)) 
2755     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
2760   if (strcmp(wxResourceBuffer
, "char") != 0) 
2762     wxLogWarning(_("Expected 'char' whilst parsing resource.")); 
2767   if (!wxGetResourceTokenString(s
)) 
2769     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
2774   if (wxResourceBuffer
[0] != '*') 
2776     wxLogWarning(_("Expected '*' whilst parsing resource.")); 
2779   wxChar nameBuf
[100]; 
2780   wxMB2WX(nameBuf
, wxResourceBuffer
+1, 99); 
2784   if (!wxGetResourceTokenString(s
)) 
2786     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
2791   if (strcmp(wxResourceBuffer
, "=") != 0) 
2793     wxLogWarning(_("Expected '=' whilst parsing resource.")); 
2798   if (!wxGetResourceTokenString(s
)) 
2800     wxLogWarning(_("Unexpected end of file whilst parsing resource.")); 
2806     if (!db
.ReadPrologFromString(wxResourceBuffer
)) 
2808       wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf
); 
2813   if (!wxGetResourceTokenString(s
)) 
2820 bool wxResourceParseString(char *s
, wxResourceTable 
*table
) 
2823     table 
= wxDefaultResourceTable
; 
2828   // Turn backslashes into spaces 
2831     int len 
= strlen(s
); 
2833     for (i 
= 0; i 
< len
; i
++) 
2834       if (s
[i
] == 92 && s
[i
+1] == 13) 
2842   wxResourceStringPtr 
= 0; 
2845   while (wxResourceReadOneResourceString(s
, db
, &eof
, table
) && !eof
) 
2849   return wxResourceInterpretResources(*table
, db
); 
2853  * resource loading facility 
2856 bool wxWindowBase::LoadFromResource(wxWindow 
*parent
, const wxString
& resourceName
, const wxResourceTable 
*table
) 
2859     table 
= wxDefaultResourceTable
; 
2861   wxItemResource 
*resource 
= table
->FindResource((const wxChar 
*)resourceName
); 
2862 //  if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX)) 
2863   if (!resource 
|| (resource
->GetType() == _T("")) || 
2864     ! ((resource
->GetType() == _T("wxDialog")) || (resource
->GetType() == _T("wxPanel")))) 
2867   wxString 
title(resource
->GetTitle()); 
2868   long theWindowStyle 
= resource
->GetStyle(); 
2869   bool isModal 
= (resource
->GetValue1() != 0); 
2870   int x 
= resource
->GetX(); 
2871   int y 
= resource
->GetY(); 
2872   int width 
= resource
->GetWidth(); 
2873   int height 
= resource
->GetHeight(); 
2874   wxString name 
= resource
->GetName(); 
2876   if (IsKindOf(CLASSINFO(wxDialog
))) 
2878     wxDialog 
*dialogBox 
= (wxDialog 
*)this; 
2879     long modalStyle 
= isModal 
? wxDIALOG_MODAL 
: 0; 
2880     if (!dialogBox
->Create(parent
, -1, title
, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
|modalStyle
, name
)) 
2883     // Only reset the client size if we know we're not going to do it again below. 
2884     if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) == 0) 
2885       dialogBox
->SetClientSize(width
, height
); 
2887   else if (IsKindOf(CLASSINFO(wxPanel
))) 
2889     wxPanel
* panel 
= (wxPanel 
*)this; 
2890     if (!panel
->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
)) 
2895     if (!((wxWindow 
*)this)->Create(parent
, -1, wxPoint(x
, y
), wxSize(width
, height
), theWindowStyle
, name
)) 
2899   if ((resource
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0) 
2901     // No need to do this since it's done in wxPanel or wxDialog constructor. 
2902     // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); 
2906     if (resource
->GetFont().Ok()) 
2907       SetFont(resource
->GetFont()); 
2908     if (resource
->GetBackgroundColour().Ok()) 
2909       SetBackgroundColour(resource
->GetBackgroundColour()); 
2912   // Should have some kind of font at this point 
2913   if (!GetFont().Ok()) 
2914       SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
)); 
2915   if (!GetBackgroundColour().Ok()) 
2916       SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
)); 
2918   // Only when we've created the window and set the font can we set the correct size, 
2919   // if based on dialog units. 
2920   if ((resource
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0) 
2922     wxSize sz 
= ConvertDialogToPixels(wxSize(width
, height
)); 
2923     SetClientSize(sz
.x
, sz
.y
); 
2925     wxPoint pt 
= ConvertDialogToPixels(wxPoint(x
, y
)); 
2929   // Now create children 
2930   wxNode 
*node 
= resource
->GetChildren().First(); 
2933     wxItemResource 
*childResource 
= (wxItemResource 
*)node
->Data(); 
2935     (void) CreateItem(childResource
, resource
, table
); 
2937     node 
= node
->Next(); 
2942 wxControl 
*wxWindowBase::CreateItem(const wxItemResource 
*resource
, const wxItemResource
* parentResource
, const wxResourceTable 
*table
) 
2945     table 
= wxDefaultResourceTable
; 
2946   return table
->CreateItem((wxWindow 
*)this, resource
, parentResource
); 
2950     #pragma warning(default:4706)   // assignment within conditional expression 
2956 #endif // wxUSE_WX_RESOURCES