1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/xrc/xmlres.cpp 
   3 // Purpose:     XRC resources 
   4 // Author:      Vaclav Slavik 
   7 // Copyright:   (c) 2000 Vaclav Slavik 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 // For compilers that support precompilation, includes "wx.h". 
  12 #include "wx/wxprec.h" 
  20 #include "wx/xrc/xmlres.h" 
  30 #include "wx/dialog.h" 
  33 #include "wx/wfstream.h" 
  34 #include "wx/filesys.h" 
  35 #include "wx/filename.h" 
  37 #include "wx/tokenzr.h" 
  38 #include "wx/fontenum.h" 
  39 #include "wx/module.h" 
  40 #include "wx/bitmap.h" 
  42 #include "wx/fontmap.h" 
  43 #include "wx/artprov.h" 
  44 #include "wx/settings.h" 
  46 #include "wx/xml/xml.h" 
  48 #include "wx/arrimpl.cpp" 
  49 WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords
) 
  52 wxXmlResource 
*wxXmlResource::ms_instance 
= NULL
; 
  54 /*static*/ wxXmlResource 
*wxXmlResource::Get() 
  57         ms_instance 
= new wxXmlResource
; 
  61 /*static*/ wxXmlResource 
*wxXmlResource::Set(wxXmlResource 
*res
) 
  63     wxXmlResource 
*old 
= ms_instance
; 
  68 wxXmlResource::wxXmlResource(int flags
) 
  74 wxXmlResource::wxXmlResource(const wxString
& filemask
, int flags
) 
  81 wxXmlResource::~wxXmlResource() 
  88 wxString 
wxXmlResource::ConvertFileNameToURL(const wxString
& filename
) 
  90     wxString 
fnd(filename
); 
  92     // NB: as Load() and Unload() accept both filenames and URLs (should 
  93     //     probably be changed to filenames only, but embedded resources 
  94     //     currently rely on its ability to handle URLs - FIXME) we need to 
  95     //     determine whether found name is filename and not URL and this is the 
  96     //     fastest/simplest way to do it 
  97     if (wxFileName::FileExists(fnd
)) 
  99         // Make the name absolute filename, because the app may 
 100         // change working directory later: 
 105             fnd 
= fn
.GetFullPath(); 
 108         fnd 
= wxFileSystem::FileNameToURL(fnd
); 
 118 bool wxXmlResource::IsArchive(const wxString
& filename
) 
 120     const wxString fnd 
= filename
.Lower(); 
 122     return fnd
.Matches(wxT("*.zip")) || fnd
.Matches(wxT("*.xrs")); 
 125 #endif // wxUSE_FILESYSTEM 
 127 bool wxXmlResource::Load(const wxString
& filemask
) 
 130     wxXmlResourceDataRecord 
*drec
; 
 131     bool iswild 
= wxIsWild(filemask
); 
 136 #   define wxXmlFindFirst  fsys.FindFirst(filemask, wxFILE) 
 137 #   define wxXmlFindNext   fsys.FindNext() 
 139 #   define wxXmlFindFirst  wxFindFirstFile(filemask, wxFILE) 
 140 #   define wxXmlFindNext   wxFindNextFile() 
 143         fnd 
= wxXmlFindFirst
; 
 148         fnd 
= ConvertFileNameToURL(fnd
); 
 151         if ( IsArchive(fnd
) ) 
 153             rt 
= rt 
&& Load(fnd 
+ wxT("#zip:*.xrc")); 
 155         else // a single resource URL 
 156 #endif // wxUSE_FILESYSTEM 
 158             drec 
= new wxXmlResourceDataRecord
; 
 168 #   undef wxXmlFindFirst 
 169 #   undef wxXmlFindNext 
 170     return rt 
&& UpdateResources(); 
 173 bool wxXmlResource::Unload(const wxString
& filename
) 
 175     wxASSERT_MSG( !wxIsWild(filename
), 
 176                     _T("wildcards not supported by wxXmlResource::Unload()") ); 
 178     wxString fnd 
= ConvertFileNameToURL(filename
); 
 180     const bool isArchive 
= IsArchive(fnd
); 
 183 #endif // wxUSE_FILESYSTEM 
 185     bool unloaded 
= false; 
 186     const size_t count 
= m_data
.GetCount(); 
 187     for ( size_t i 
= 0; i 
< count
; i
++ ) 
 192             if ( m_data
[i
].File
.StartsWith(fnd
) ) 
 194             // don't break from the loop, we can have other matching files 
 196         else // a single resource URL 
 197 #endif // wxUSE_FILESYSTEM 
 199             if ( m_data
[i
].File 
== fnd 
) 
 204                 // no sense in continuing, there is only one file with this URL 
 214 IMPLEMENT_ABSTRACT_CLASS(wxXmlResourceHandler
, wxObject
) 
 216 void wxXmlResource::AddHandler(wxXmlResourceHandler 
*handler
) 
 218     m_handlers
.Append(handler
); 
 219     handler
->SetParentResource(this); 
 222 void wxXmlResource::InsertHandler(wxXmlResourceHandler 
*handler
) 
 224     m_handlers
.Insert(handler
); 
 225     handler
->SetParentResource(this); 
 230 void wxXmlResource::ClearHandlers() 
 232     WX_CLEAR_LIST(wxList
, m_handlers
); 
 236 wxMenu 
*wxXmlResource::LoadMenu(const wxString
& name
) 
 238     return (wxMenu
*)CreateResFromNode(FindResource(name
, wxT("wxMenu")), NULL
, NULL
); 
 243 wxMenuBar 
*wxXmlResource::LoadMenuBar(wxWindow 
*parent
, const wxString
& name
) 
 245     return (wxMenuBar
*)CreateResFromNode(FindResource(name
, wxT("wxMenuBar")), parent
, NULL
); 
 251 wxToolBar 
*wxXmlResource::LoadToolBar(wxWindow 
*parent
, const wxString
& name
) 
 253     return (wxToolBar
*)CreateResFromNode(FindResource(name
, wxT("wxToolBar")), parent
, NULL
); 
 258 wxDialog 
*wxXmlResource::LoadDialog(wxWindow 
*parent
, const wxString
& name
) 
 260     return (wxDialog
*)CreateResFromNode(FindResource(name
, wxT("wxDialog")), parent
, NULL
); 
 263 bool wxXmlResource::LoadDialog(wxDialog 
*dlg
, wxWindow 
*parent
, const wxString
& name
) 
 265     return CreateResFromNode(FindResource(name
, wxT("wxDialog")), parent
, dlg
) != NULL
; 
 270 wxPanel 
*wxXmlResource::LoadPanel(wxWindow 
*parent
, const wxString
& name
) 
 272     return (wxPanel
*)CreateResFromNode(FindResource(name
, wxT("wxPanel")), parent
, NULL
); 
 275 bool wxXmlResource::LoadPanel(wxPanel 
*panel
, wxWindow 
*parent
, const wxString
& name
) 
 277     return CreateResFromNode(FindResource(name
, wxT("wxPanel")), parent
, panel
) != NULL
; 
 280 wxFrame 
*wxXmlResource::LoadFrame(wxWindow
* parent
, const wxString
& name
) 
 282     return (wxFrame
*)CreateResFromNode(FindResource(name
, wxT("wxFrame")), parent
, NULL
); 
 285 bool wxXmlResource::LoadFrame(wxFrame
* frame
, wxWindow 
*parent
, const wxString
& name
) 
 287     return CreateResFromNode(FindResource(name
, wxT("wxFrame")), parent
, frame
) != NULL
; 
 290 wxBitmap 
wxXmlResource::LoadBitmap(const wxString
& name
) 
 292     wxBitmap 
*bmp 
= (wxBitmap
*)CreateResFromNode( 
 293                                FindResource(name
, wxT("wxBitmap")), NULL
, NULL
); 
 296     if (bmp
) { rt 
= *bmp
; delete bmp
; } 
 300 wxIcon 
wxXmlResource::LoadIcon(const wxString
& name
) 
 302     wxIcon 
*icon 
= (wxIcon
*)CreateResFromNode( 
 303                             FindResource(name
, wxT("wxIcon")), NULL
, NULL
); 
 306     if (icon
) { rt 
= *icon
; delete icon
; } 
 311 wxObject 
*wxXmlResource::LoadObject(wxWindow 
*parent
, const wxString
& name
, const wxString
& classname
) 
 313     return CreateResFromNode(FindResource(name
, classname
), parent
, NULL
); 
 316 bool wxXmlResource::LoadObject(wxObject 
*instance
, wxWindow 
*parent
, const wxString
& name
, const wxString
& classname
) 
 318     return CreateResFromNode(FindResource(name
, classname
), parent
, instance
) != NULL
; 
 322 bool wxXmlResource::AttachUnknownControl(const wxString
& name
, 
 323                                          wxWindow 
*control
, wxWindow 
*parent
) 
 326         parent 
= control
->GetParent(); 
 327     wxWindow 
*container 
= parent
->FindWindow(name 
+ wxT("_container")); 
 330         wxLogError(_("Cannot find container for unknown control '%s'."), name
.c_str()); 
 333     return control
->Reparent(container
); 
 337 static void ProcessPlatformProperty(wxXmlNode 
*node
) 
 342     wxXmlNode 
*c 
= node
->GetChildren(); 
 346         if (!c
->GetPropVal(wxT("platform"), &s
)) 
 350             wxStringTokenizer 
tkn(s
, wxT(" |")); 
 352             while (tkn
.HasMoreTokens()) 
 354                 s 
= tkn
.GetNextToken(); 
 356                 if (s 
== wxT("win")) isok 
= true; 
 358 #if defined(__MAC__) || defined(__APPLE__) 
 359                 if (s 
== wxT("mac")) isok 
= true; 
 360 #elif defined(__UNIX__) 
 361                 if (s 
== wxT("unix")) isok 
= true; 
 364                 if (s 
== wxT("os2")) isok 
= true; 
 374             ProcessPlatformProperty(c
); 
 379             wxXmlNode 
*c2 
= c
->GetNext(); 
 380             node
->RemoveChild(c
); 
 389 bool wxXmlResource::UpdateResources() 
 393 #   if wxUSE_FILESYSTEM 
 394     wxFSFile 
*file 
= NULL
; 
 399     wxString 
encoding(wxT("UTF-8")); 
 400 #if !wxUSE_UNICODE && wxUSE_INTL 
 401     if ( (GetFlags() & wxXRC_USE_LOCALE
) == 0 ) 
 403         // In case we are not using wxLocale to translate strings, convert the 
 404         // strings GUI's charset. This must not be done when wxXRC_USE_LOCALE 
 405         // is on, because it could break wxGetTranslation lookup. 
 406         encoding 
= wxLocale::GetSystemEncodingName(); 
 410     for (size_t i 
= 0; i 
< m_data
.GetCount(); i
++) 
 412         modif 
= (m_data
[i
].Doc 
== NULL
); 
 414         if (!modif 
&& !(m_flags 
& wxXRC_NO_RELOADING
)) 
 416 #           if wxUSE_FILESYSTEM 
 417             file 
= fsys
.OpenFile(m_data
[i
].File
); 
 419             modif 
= file 
&& file
->GetModificationTime() > m_data
[i
].Time
; 
 420 #           else // wxUSE_DATETIME 
 422 #           endif // wxUSE_DATETIME 
 425                 wxLogError(_("Cannot open file '%s'."), m_data
[i
].File
.c_str()); 
 430 #           else // wxUSE_FILESYSTEM 
 432             modif 
= wxDateTime(wxFileModificationTime(m_data
[i
].File
)) > m_data
[i
].Time
; 
 433 #           else // wxUSE_DATETIME 
 435 #           endif // wxUSE_DATETIME 
 436 #           endif // wxUSE_FILESYSTEM 
 441             wxLogTrace(_T("xrc"), 
 442                        _T("opening file '%s'"), m_data
[i
].File
.c_str()); 
 444             wxInputStream 
*stream 
= NULL
; 
 446 #           if wxUSE_FILESYSTEM 
 447             file 
= fsys
.OpenFile(m_data
[i
].File
); 
 449                 stream 
= file
->GetStream(); 
 451             stream 
= new wxFileInputStream(m_data
[i
].File
); 
 456                 delete m_data
[i
].Doc
; 
 457                 m_data
[i
].Doc 
= new wxXmlDocument
; 
 459             if (!stream 
|| !m_data
[i
].Doc
->Load(*stream
, encoding
)) 
 461                 wxLogError(_("Cannot load resources from file '%s'."), 
 462                            m_data
[i
].File
.c_str()); 
 463                 wxDELETE(m_data
[i
].Doc
); 
 466             else if (m_data
[i
].Doc
->GetRoot()->GetName() != wxT("resource")) 
 468                 wxLogError(_("Invalid XRC resource '%s': doesn't have root node 'resource'."), m_data
[i
].File
.c_str()); 
 469                 wxDELETE(m_data
[i
].Doc
); 
 476                 wxString verstr 
= m_data
[i
].Doc
->GetRoot()->GetPropVal( 
 477                                       wxT("version"), wxT("0.0.0.0")); 
 478                 if (wxSscanf(verstr
.c_str(), wxT("%i.%i.%i.%i"), 
 479                     &v1
, &v2
, &v3
, &v4
) == 4) 
 480                     version 
= v1
*256*256*256+v2
*256*256+v3
*256+v4
; 
 485                 if (m_version 
!= version
) 
 487                     wxLogError(_("Resource files must have same version number!")); 
 491                 ProcessPlatformProperty(m_data
[i
].Doc
->GetRoot()); 
 494                 m_data
[i
].Time 
= file
->GetModificationTime(); 
 495 #else // wxUSE_FILESYSTEM 
 496                 m_data
[i
].Time 
= wxDateTime(wxFileModificationTime(m_data
[i
].File
)); 
 497 #endif // wxUSE_FILESYSTEM 
 498 #endif // wxUSE_DATETIME 
 501 #           if wxUSE_FILESYSTEM 
 514 wxXmlNode 
*wxXmlResource::DoFindResource(wxXmlNode 
*parent
, 
 515                                          const wxString
& name
, 
 516                                          const wxString
& classname
, 
 522     // first search for match at the top-level nodes (as this is 
 523     // where the resource is most commonly looked for): 
 524     for (node 
= parent
->GetChildren(); node
; node 
= node
->GetNext()) 
 526         if ( node
->GetType() == wxXML_ELEMENT_NODE 
&& 
 527                  (node
->GetName() == wxT("object") || 
 528                   node
->GetName() == wxT("object_ref")) && 
 529              node
->GetPropVal(wxT("name"), &dummy
) && dummy 
== name 
) 
 531             wxString 
cls(node
->GetPropVal(wxT("class"), wxEmptyString
)); 
 532             if (!classname 
|| cls 
== classname
) 
 534             // object_ref may not have 'class' property: 
 535             if (cls
.empty() && node
->GetName() == wxT("object_ref")) 
 537                 wxString refName 
= node
->GetPropVal(wxT("ref"), wxEmptyString
); 
 540                 wxXmlNode
* refNode 
= FindResource(refName
, wxEmptyString
, true); 
 542                     refNode
->GetPropVal(wxT("class"), wxEmptyString
) == classname
) 
 551         for (node 
= parent
->GetChildren(); node
; node 
= node
->GetNext()) 
 553             if ( node
->GetType() == wxXML_ELEMENT_NODE 
&& 
 554                  (node
->GetName() == wxT("object") || 
 555                   node
->GetName() == wxT("object_ref")) ) 
 557                 wxXmlNode
* found 
= DoFindResource(node
, name
, classname
, true); 
 566 wxXmlNode 
*wxXmlResource::FindResource(const wxString
& name
, 
 567                                        const wxString
& classname
, 
 570     UpdateResources(); //ensure everything is up-to-date 
 573     for (size_t f 
= 0; f 
< m_data
.GetCount(); f
++) 
 575         if ( m_data
[f
].Doc 
== NULL 
|| m_data
[f
].Doc
->GetRoot() == NULL 
) 
 578         wxXmlNode
* found 
= DoFindResource(m_data
[f
].Doc
->GetRoot(), 
 579                                           name
, classname
, recursive
); 
 583             m_curFileSystem
.ChangePathTo(m_data
[f
].File
); 
 589     wxLogError(_("XRC resource '%s' (class '%s') not found!"), 
 590                name
.c_str(), classname
.c_str()); 
 594 static void MergeNodes(wxXmlNode
& dest
, wxXmlNode
& with
) 
 597     for (wxXmlProperty 
*prop 
= with
.GetProperties(); prop
; prop 
= prop
->GetNext()) 
 599         wxXmlProperty 
*dprop
; 
 600         for (dprop 
= dest
.GetProperties(); dprop
; dprop 
= dprop
->GetNext()) 
 603             if ( dprop
->GetName() == prop
->GetName() ) 
 605                 dprop
->SetValue(prop
->GetValue()); 
 611             dest
.AddProperty(prop
->GetName(), prop
->GetValue()); 
 614     // Merge child nodes: 
 615     for (wxXmlNode
* node 
= with
.GetChildren(); node
; node 
= node
->GetNext()) 
 617         wxString name 
= node
->GetPropVal(wxT("name"), wxEmptyString
); 
 620         for (dnode 
= dest
.GetChildren(); dnode
; dnode 
= dnode
->GetNext() ) 
 622             if ( dnode
->GetName() == node
->GetName() && 
 623                  dnode
->GetPropVal(wxT("name"), wxEmptyString
) == name 
&& 
 624                  dnode
->GetType() == node
->GetType() ) 
 626                 MergeNodes(*dnode
, *node
); 
 633             static const wxChar 
*AT_END 
= wxT("end"); 
 634             wxString insert_pos 
= node
->GetPropVal(wxT("insert_at"), AT_END
); 
 635             if ( insert_pos 
== AT_END 
) 
 637                 dest
.AddChild(new wxXmlNode(*node
)); 
 639             else if ( insert_pos 
== wxT("begin") ) 
 641                 dest
.InsertChild(new wxXmlNode(*node
), dest
.GetChildren()); 
 646     if ( dest
.GetType() == wxXML_TEXT_NODE 
&& with
.GetContent().Length() ) 
 647          dest
.SetContent(with
.GetContent()); 
 650 wxObject 
*wxXmlResource::CreateResFromNode(wxXmlNode 
*node
, wxObject 
*parent
, 
 652                                            wxXmlResourceHandler 
*handlerToUse
) 
 654     if (node 
== NULL
) return NULL
; 
 656     // handling of referenced resource 
 657     if ( node
->GetName() == wxT("object_ref") ) 
 659         wxString refName 
= node
->GetPropVal(wxT("ref"), wxEmptyString
); 
 660         wxXmlNode
* refNode 
= FindResource(refName
, wxEmptyString
, true); 
 664             wxLogError(_("Referenced object node with ref=\"%s\" not found!"), 
 669         wxXmlNode 
copy(*refNode
); 
 670         MergeNodes(copy
, *node
); 
 672         return CreateResFromNode(©
, parent
, instance
); 
 675     wxXmlResourceHandler 
*handler
; 
 679         if (handlerToUse
->CanHandle(node
)) 
 681             return handlerToUse
->CreateResource(node
, parent
, instance
); 
 684     else if (node
->GetName() == wxT("object")) 
 686         wxList::compatibility_iterator ND 
= m_handlers
.GetFirst(); 
 689             handler 
= (wxXmlResourceHandler
*)ND
->GetData(); 
 690             if (handler
->CanHandle(node
)) 
 692                 return handler
->CreateResource(node
, parent
, instance
); 
 698     wxLogError(_("No handler found for XML node '%s', class '%s'!"), 
 699                node
->GetName().c_str(), 
 700                node
->GetPropVal(wxT("class"), wxEmptyString
).c_str()); 
 705 #include "wx/listimpl.cpp" 
 706 WX_DECLARE_LIST(wxXmlSubclassFactory
, wxXmlSubclassFactoriesList
); 
 707 WX_DEFINE_LIST(wxXmlSubclassFactoriesList
) 
 709 wxXmlSubclassFactoriesList 
*wxXmlResource::ms_subclassFactories 
= NULL
; 
 711 /*static*/ void wxXmlResource::AddSubclassFactory(wxXmlSubclassFactory 
*factory
) 
 713     if (!ms_subclassFactories
) 
 715         ms_subclassFactories 
= new wxXmlSubclassFactoriesList
; 
 717     ms_subclassFactories
->Append(factory
); 
 720 class wxXmlSubclassFactoryCXX 
: public wxXmlSubclassFactory
 
 723     ~wxXmlSubclassFactoryCXX() {} 
 725     wxObject 
*Create(const wxString
& className
) 
 727         wxClassInfo
* classInfo 
= wxClassInfo::FindClass(className
); 
 730             return classInfo
->CreateObject(); 
 739 wxXmlResourceHandler::wxXmlResourceHandler() 
 740         : m_node(NULL
), m_parent(NULL
), m_instance(NULL
), 
 741           m_parentAsWindow(NULL
) 
 746 wxObject 
*wxXmlResourceHandler::CreateResource(wxXmlNode 
*node
, wxObject 
*parent
, wxObject 
*instance
) 
 748     wxXmlNode 
*myNode 
= m_node
; 
 749     wxString myClass 
= m_class
; 
 750     wxObject 
*myParent 
= m_parent
, *myInstance 
= m_instance
; 
 751     wxWindow 
*myParentAW 
= m_parentAsWindow
; 
 753     m_instance 
= instance
; 
 754     if (!m_instance 
&& node
->HasProp(wxT("subclass")) && 
 755         !(m_resource
->GetFlags() & wxXRC_NO_SUBCLASSING
)) 
 757         wxString subclass 
= node
->GetPropVal(wxT("subclass"), wxEmptyString
); 
 758         if (!subclass
.empty()) 
 760             for (wxXmlSubclassFactoriesList::compatibility_iterator i 
= wxXmlResource::ms_subclassFactories
->GetFirst(); 
 763                 m_instance 
= i
->GetData()->Create(subclass
); 
 770                 wxString name 
= node
->GetPropVal(wxT("name"), wxEmptyString
); 
 771                 wxLogError(_("Subclass '%s' not found for resource '%s', not subclassing!"), 
 772                            subclass
.c_str(), name
.c_str()); 
 778     m_class 
= node
->GetPropVal(wxT("class"), wxEmptyString
); 
 780     m_parentAsWindow 
= wxDynamicCast(m_parent
, wxWindow
); 
 782     wxObject 
*returned 
= DoCreateResource(); 
 786     m_parent 
= myParent
; m_parentAsWindow 
= myParentAW
; 
 787     m_instance 
= myInstance
; 
 793 void wxXmlResourceHandler::AddStyle(const wxString
& name
, int value
) 
 795     m_styleNames
.Add(name
); 
 796     m_styleValues
.Add(value
); 
 801 void wxXmlResourceHandler::AddWindowStyles() 
 803     XRC_ADD_STYLE(wxCLIP_CHILDREN
); 
 805     // the border styles all have the old and new names, recognize both for now 
 806     XRC_ADD_STYLE(wxSIMPLE_BORDER
); XRC_ADD_STYLE(wxBORDER_SIMPLE
); 
 807     XRC_ADD_STYLE(wxSUNKEN_BORDER
); XRC_ADD_STYLE(wxBORDER_SUNKEN
); 
 808     XRC_ADD_STYLE(wxDOUBLE_BORDER
); XRC_ADD_STYLE(wxBORDER_DOUBLE
); 
 809     XRC_ADD_STYLE(wxRAISED_BORDER
); XRC_ADD_STYLE(wxBORDER_RAISED
); 
 810     XRC_ADD_STYLE(wxSTATIC_BORDER
); XRC_ADD_STYLE(wxBORDER_STATIC
); 
 811     XRC_ADD_STYLE(wxNO_BORDER
);     XRC_ADD_STYLE(wxBORDER_NONE
); 
 813     XRC_ADD_STYLE(wxTRANSPARENT_WINDOW
); 
 814     XRC_ADD_STYLE(wxWANTS_CHARS
); 
 815     XRC_ADD_STYLE(wxTAB_TRAVERSAL
); 
 816     XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE
); 
 817     XRC_ADD_STYLE(wxFULL_REPAINT_ON_RESIZE
); 
 818     XRC_ADD_STYLE(wxALWAYS_SHOW_SB
); 
 819     XRC_ADD_STYLE(wxWS_EX_BLOCK_EVENTS
); 
 820     XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY
); 
 825 bool wxXmlResourceHandler::HasParam(const wxString
& param
) 
 827     return (GetParamNode(param
) != NULL
); 
 831 int wxXmlResourceHandler::GetStyle(const wxString
& param
, int defaults
) 
 833     wxString s 
= GetParamValue(param
); 
 835     if (!s
) return defaults
; 
 837     wxStringTokenizer 
tkn(s
, wxT("| \t\n"), wxTOKEN_STRTOK
); 
 841     while (tkn
.HasMoreTokens()) 
 843         fl 
= tkn
.GetNextToken(); 
 844         index 
= m_styleNames
.Index(fl
); 
 845         if (index 
!= wxNOT_FOUND
) 
 846             style 
|= m_styleValues
[index
]; 
 848             wxLogError(_("Unknown style flag ") + fl
); 
 855 wxString 
wxXmlResourceHandler::GetText(const wxString
& param
, bool translate
) 
 857     wxXmlNode 
*parNode 
= GetParamNode(param
); 
 858     wxString 
str1(GetNodeContent(parNode
)); 
 863     // VS: First version of XRC resources used $ instead of & (which is 
 864     //     illegal in XML), but later I realized that '_' fits this purpose 
 865     //     much better (because &File means "File with F underlined"). 
 866     if (m_resource
->CompareVersion(2,3,0,1) < 0) 
 871     for (dt 
= str1
.c_str(); *dt
; dt
++) 
 873         // Remap amp_char to &, map double amp_char to amp_char (for things 
 874         // like "&File..." -- this is illegal in XML, so we use "_File..."): 
 877             if ( *(++dt
) == amp_char 
) 
 880                 str2 
<< wxT('&') << *dt
; 
 882         // Remap \n to CR, \r to LF, \t to TAB, \\ to \: 
 883         else if (*dt 
== wxT('\\')) 
 899                     // "\\" wasn't translated to "\" prior to 2.5.3.0: 
 900                     if (m_resource
->CompareVersion(2,5,3,0) >= 0) 
 905                     // else fall-through to default: branch below 
 908                     str2 
<< wxT('\\') << *dt
; 
 914     if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
) 
 916         if (translate 
&& parNode 
&& 
 917             parNode
->GetPropVal(wxT("translate"), wxEmptyString
) != wxT("0")) 
 919             return wxGetTranslation(str2
); 
 926             // The string is internally stored as UTF-8, we have to convert 
 927             // it into system's default encoding so that it can be displayed: 
 928             return wxString(str2
.mb_str(wxConvUTF8
), wxConvLocal
); 
 933     // If wxXRC_USE_LOCALE is not set, then the string is already in 
 934     // system's default encoding in ANSI build, so we don't have to 
 935     // do anything special here. 
 941 long wxXmlResourceHandler::GetLong(const wxString
& param
, long defaultv
) 
 944     wxString str1 
= GetParamValue(param
); 
 946     if (!str1
.ToLong(&value
)) 
 952 float wxXmlResourceHandler::GetFloat(const wxString
& param
, float defaultv
) 
 955     wxString str1 
= GetParamValue(param
); 
 958     const char *prevlocale 
= setlocale(LC_NUMERIC
, "C"); 
 961     if (!str1
.ToDouble(&value
)) 
 965     setlocale(LC_NUMERIC
, prevlocale
); 
 968     return wx_truncate_cast(float, value
); 
 972 int wxXmlResourceHandler::GetID() 
 974     return wxXmlResource::GetXRCID(GetName()); 
 979 wxString 
wxXmlResourceHandler::GetName() 
 981     return m_node
->GetPropVal(wxT("name"), wxT("-1")); 
 986 bool wxXmlResourceHandler::GetBool(const wxString
& param
, bool defaultv
) 
 988     wxString v 
= GetParamValue(param
); 
 990     if (!v
) return defaultv
; 
 992     return (v 
== wxT("1")); 
 996 static wxColour 
GetSystemColour(const wxString
& name
) 
1000         #define SYSCLR(clr) \ 
1001             if (name == _T(#clr)) return wxSystemSettings::GetColour(clr); 
1002         SYSCLR(wxSYS_COLOUR_SCROLLBAR
) 
1003         SYSCLR(wxSYS_COLOUR_BACKGROUND
) 
1004         SYSCLR(wxSYS_COLOUR_DESKTOP
) 
1005         SYSCLR(wxSYS_COLOUR_ACTIVECAPTION
) 
1006         SYSCLR(wxSYS_COLOUR_INACTIVECAPTION
) 
1007         SYSCLR(wxSYS_COLOUR_MENU
) 
1008         SYSCLR(wxSYS_COLOUR_WINDOW
) 
1009         SYSCLR(wxSYS_COLOUR_WINDOWFRAME
) 
1010         SYSCLR(wxSYS_COLOUR_MENUTEXT
) 
1011         SYSCLR(wxSYS_COLOUR_WINDOWTEXT
) 
1012         SYSCLR(wxSYS_COLOUR_CAPTIONTEXT
) 
1013         SYSCLR(wxSYS_COLOUR_ACTIVEBORDER
) 
1014         SYSCLR(wxSYS_COLOUR_INACTIVEBORDER
) 
1015         SYSCLR(wxSYS_COLOUR_APPWORKSPACE
) 
1016         SYSCLR(wxSYS_COLOUR_HIGHLIGHT
) 
1017         SYSCLR(wxSYS_COLOUR_HIGHLIGHTTEXT
) 
1018         SYSCLR(wxSYS_COLOUR_BTNFACE
) 
1019         SYSCLR(wxSYS_COLOUR_3DFACE
) 
1020         SYSCLR(wxSYS_COLOUR_BTNSHADOW
) 
1021         SYSCLR(wxSYS_COLOUR_3DSHADOW
) 
1022         SYSCLR(wxSYS_COLOUR_GRAYTEXT
) 
1023         SYSCLR(wxSYS_COLOUR_BTNTEXT
) 
1024         SYSCLR(wxSYS_COLOUR_INACTIVECAPTIONTEXT
) 
1025         SYSCLR(wxSYS_COLOUR_BTNHIGHLIGHT
) 
1026         SYSCLR(wxSYS_COLOUR_BTNHILIGHT
) 
1027         SYSCLR(wxSYS_COLOUR_3DHIGHLIGHT
) 
1028         SYSCLR(wxSYS_COLOUR_3DHILIGHT
) 
1029         SYSCLR(wxSYS_COLOUR_3DDKSHADOW
) 
1030         SYSCLR(wxSYS_COLOUR_3DLIGHT
) 
1031         SYSCLR(wxSYS_COLOUR_INFOTEXT
) 
1032         SYSCLR(wxSYS_COLOUR_INFOBK
) 
1033         SYSCLR(wxSYS_COLOUR_LISTBOX
) 
1034         SYSCLR(wxSYS_COLOUR_HOTLIGHT
) 
1035         SYSCLR(wxSYS_COLOUR_GRADIENTACTIVECAPTION
) 
1036         SYSCLR(wxSYS_COLOUR_GRADIENTINACTIVECAPTION
) 
1037         SYSCLR(wxSYS_COLOUR_MENUHILIGHT
) 
1038         SYSCLR(wxSYS_COLOUR_MENUBAR
) 
1042     return wxNullColour
; 
1045 wxColour 
wxXmlResourceHandler::GetColour(const wxString
& param
) 
1047     wxString v 
= GetParamValue(param
); 
1049     // find colour using HTML syntax (#RRGGBB) 
1050     unsigned long tmp 
= 0; 
1052     if (v
.length() != 7 || v
[0u] != wxT('#') || 
1053         wxSscanf(v
.c_str(), wxT("#%lX"), &tmp
) != 1) 
1055         // the colour doesn't use #RRGGBB format, check if it is symbolic 
1057         wxColour clr 
= GetSystemColour(v
); 
1061         wxLogError(_("XRC resource: Incorrect colour specification '%s' for property '%s'."), 
1062                    v
.c_str(), param
.c_str()); 
1063         return wxNullColour
; 
1066     return wxColour((unsigned char) ((tmp 
& 0xFF0000) >> 16) , 
1067                     (unsigned char) ((tmp 
& 0x00FF00) >> 8), 
1068                     (unsigned char) ((tmp 
& 0x0000FF))); 
1073 wxBitmap 
wxXmlResourceHandler::GetBitmap(const wxString
& param
, 
1074                                          const wxArtClient
& defaultArtClient
, 
1077     /* If the bitmap is specified as stock item, query wxArtProvider for it: */ 
1078     wxXmlNode 
*bmpNode 
= GetParamNode(param
); 
1081         wxString sid 
= bmpNode
->GetPropVal(wxT("stock_id"), wxEmptyString
); 
1084             wxString scl 
= bmpNode
->GetPropVal(wxT("stock_client"), wxEmptyString
); 
1086                 scl 
= defaultArtClient
; 
1088                 scl 
= wxART_MAKE_CLIENT_ID_FROM_STR(scl
); 
1091                 wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid
), 
1093             if ( stockArt
.Ok() ) 
1098     /* ...or load the bitmap from file: */ 
1099     wxString name 
= GetParamValue(param
); 
1100     if (name
.empty()) return wxNullBitmap
; 
1101 #if wxUSE_FILESYSTEM 
1102     wxFSFile 
*fsfile 
= GetCurFileSystem().OpenFile(name
); 
1105         wxLogError(_("XRC resource: Cannot create bitmap from '%s'."), 
1107         return wxNullBitmap
; 
1109     wxImage 
img(*(fsfile
->GetStream())); 
1117         wxLogError(_("XRC resource: Cannot create bitmap from '%s'."), 
1119         return wxNullBitmap
; 
1121     if (!(size 
== wxDefaultSize
)) img
.Rescale(size
.x
, size
.y
); 
1122     return wxBitmap(img
); 
1127 wxIcon 
wxXmlResourceHandler::GetIcon(const wxString
& param
, 
1128                                      const wxArtClient
& defaultArtClient
, 
1132     icon
.CopyFromBitmap(GetBitmap(param
, defaultArtClient
, size
)); 
1138 wxXmlNode 
*wxXmlResourceHandler::GetParamNode(const wxString
& param
) 
1140     wxCHECK_MSG(m_node
, NULL
, wxT("You can't access handler data before it was initialized!")); 
1142     wxXmlNode 
*n 
= m_node
->GetChildren(); 
1146         if (n
->GetType() == wxXML_ELEMENT_NODE 
&& n
->GetName() == param
) 
1154 wxString 
wxXmlResourceHandler::GetNodeContent(wxXmlNode 
*node
) 
1156     wxXmlNode 
*n 
= node
; 
1157     if (n 
== NULL
) return wxEmptyString
; 
1158     n 
= n
->GetChildren(); 
1162         if (n
->GetType() == wxXML_TEXT_NODE 
|| 
1163             n
->GetType() == wxXML_CDATA_SECTION_NODE
) 
1164             return n
->GetContent(); 
1167     return wxEmptyString
; 
1172 wxString 
wxXmlResourceHandler::GetParamValue(const wxString
& param
) 
1175         return GetNodeContent(m_node
); 
1177         return GetNodeContent(GetParamNode(param
)); 
1182 wxSize 
wxXmlResourceHandler::GetSize(const wxString
& param
, 
1183                                      wxWindow 
*windowToUse
) 
1185     wxString s 
= GetParamValue(param
); 
1186     if (s
.empty()) s 
= wxT("-1,-1"); 
1190     is_dlg 
= s
[s
.length()-1] == wxT('d'); 
1191     if (is_dlg
) s
.RemoveLast(); 
1193     if (!s
.BeforeFirst(wxT(',')).ToLong(&sx
) || 
1194         !s
.AfterLast(wxT(',')).ToLong(&sy
)) 
1196         wxLogError(_("Cannot parse coordinates from '%s'."), s
.c_str()); 
1197         return wxDefaultSize
; 
1204             return wxDLG_UNIT(windowToUse
, wxSize(sx
, sy
)); 
1206         else if (m_parentAsWindow
) 
1208             return wxDLG_UNIT(m_parentAsWindow
, wxSize(sx
, sy
)); 
1212             wxLogError(_("Cannot convert dialog units: dialog unknown.")); 
1213             return wxDefaultSize
; 
1217     return wxSize(sx
, sy
); 
1222 wxPoint 
wxXmlResourceHandler::GetPosition(const wxString
& param
) 
1224     wxSize sz 
= GetSize(param
); 
1225     return wxPoint(sz
.x
, sz
.y
); 
1230 wxCoord 
wxXmlResourceHandler::GetDimension(const wxString
& param
, 
1232                                            wxWindow 
*windowToUse
) 
1234     wxString s 
= GetParamValue(param
); 
1235     if (s
.empty()) return defaultv
; 
1239     is_dlg 
= s
[s
.length()-1] == wxT('d'); 
1240     if (is_dlg
) s
.RemoveLast(); 
1244         wxLogError(_("Cannot parse dimension from '%s'."), s
.c_str()); 
1252             return wxDLG_UNIT(windowToUse
, wxSize(sx
, 0)).x
; 
1254         else if (m_parentAsWindow
) 
1256             return wxDLG_UNIT(m_parentAsWindow
, wxSize(sx
, 0)).x
; 
1260             wxLogError(_("Cannot convert dialog units: dialog unknown.")); 
1269 // Get system font index using indexname 
1270 static wxFont 
GetSystemFont(const wxString
& name
) 
1274         #define SYSFNT(fnt) \ 
1275             if (name == _T(#fnt)) return wxSystemSettings::GetFont(fnt); 
1276         SYSFNT(wxSYS_OEM_FIXED_FONT
) 
1277         SYSFNT(wxSYS_ANSI_FIXED_FONT
) 
1278         SYSFNT(wxSYS_ANSI_VAR_FONT
) 
1279         SYSFNT(wxSYS_SYSTEM_FONT
) 
1280         SYSFNT(wxSYS_DEVICE_DEFAULT_FONT
) 
1281         SYSFNT(wxSYS_DEFAULT_PALETTE
) 
1282         SYSFNT(wxSYS_SYSTEM_FIXED_FONT
) 
1283         SYSFNT(wxSYS_DEFAULT_GUI_FONT
) 
1290 wxFont 
wxXmlResourceHandler::GetFont(const wxString
& param
) 
1292     wxXmlNode 
*font_node 
= GetParamNode(param
); 
1293     if (font_node 
== NULL
) 
1295         wxLogError(_("Cannot find font node '%s'."), param
.c_str()); 
1299     wxXmlNode 
*oldnode 
= m_node
; 
1306     bool hasSize 
= HasParam(wxT("size")); 
1308         isize 
= GetLong(wxT("size"), -1); 
1311     int istyle 
= wxNORMAL
; 
1312     bool hasStyle 
= HasParam(wxT("style")); 
1315         wxString style 
= GetParamValue(wxT("style")); 
1316         if (style 
== wxT("italic")) 
1318         else if (style 
== wxT("slant")) 
1323     int iweight 
= wxNORMAL
; 
1324     bool hasWeight 
= HasParam(wxT("weight")); 
1327         wxString weight 
= GetParamValue(wxT("weight")); 
1328         if (weight 
== wxT("bold")) 
1330         else if (weight 
== wxT("light")) 
1335     bool hasUnderlined 
= HasParam(wxT("underlined")); 
1336     bool underlined 
= hasUnderlined 
? GetBool(wxT("underlined"), false) : false; 
1338     // family and facename 
1339     int ifamily 
= wxDEFAULT
; 
1340     bool hasFamily 
= HasParam(wxT("family")); 
1343         wxString family 
= GetParamValue(wxT("family")); 
1344              if (family 
== wxT("decorative")) ifamily 
= wxDECORATIVE
; 
1345         else if (family 
== wxT("roman")) ifamily 
= wxROMAN
; 
1346         else if (family 
== wxT("script")) ifamily 
= wxSCRIPT
; 
1347         else if (family 
== wxT("swiss")) ifamily 
= wxSWISS
; 
1348         else if (family 
== wxT("modern")) ifamily 
= wxMODERN
; 
1349         else if (family 
== wxT("teletype")) ifamily 
= wxTELETYPE
; 
1354     bool hasFacename 
= HasParam(wxT("face")); 
1357         wxString faces 
= GetParamValue(wxT("face")); 
1358         wxFontEnumerator enu
; 
1359         enu
.EnumerateFacenames(); 
1360         wxStringTokenizer 
tk(faces
, wxT(",")); 
1361         while (tk
.HasMoreTokens()) 
1363             int index 
= enu
.GetFacenames()->Index(tk
.GetNextToken(), false); 
1364             if (index 
!= wxNOT_FOUND
) 
1366                 facename 
= (*enu
.GetFacenames())[index
]; 
1373     wxFontEncoding enc 
= wxFONTENCODING_DEFAULT
; 
1374     bool hasEncoding 
= HasParam(wxT("encoding")); 
1377         wxString encoding 
= GetParamValue(wxT("encoding")); 
1378         wxFontMapper mapper
; 
1379         if (!encoding
.empty()) 
1380             enc 
= mapper
.CharsetToEncoding(encoding
); 
1381         if (enc 
== wxFONTENCODING_SYSTEM
) 
1382             enc 
= wxFONTENCODING_DEFAULT
; 
1385     // is this font based on a system font? 
1386     wxFont font 
= GetSystemFont(GetParamValue(wxT("sysfont"))); 
1390         if (hasSize 
&& isize 
!= -1) 
1391             font
.SetPointSize(isize
); 
1392         else if (HasParam(wxT("relativesize"))) 
1393             font
.SetPointSize(int(font
.GetPointSize() * 
1394                                      GetFloat(wxT("relativesize")))); 
1397             font
.SetStyle(istyle
); 
1399             font
.SetWeight(iweight
); 
1401             font
.SetUnderlined(underlined
); 
1403             font
.SetFamily(ifamily
); 
1405             font
.SetFaceName(facename
); 
1407             font
.SetDefaultEncoding(enc
); 
1409     else // not based on system font 
1411         font 
= wxFont(isize 
== -1 ? wxNORMAL_FONT
->GetPointSize() : isize
, 
1412                       ifamily
, istyle
, iweight
, 
1413                       underlined
, facename
, enc
); 
1421 void wxXmlResourceHandler::SetupWindow(wxWindow 
*wnd
) 
1423     //FIXME : add cursor 
1425     if (HasParam(wxT("exstyle"))) 
1426         // Have to OR it with existing style, since 
1427         // some implementations (e.g. wxGTK) use the extra style 
1429         wnd
->SetExtraStyle(wnd
->GetExtraStyle() | GetStyle(wxT("exstyle"))); 
1430     if (HasParam(wxT("bg"))) 
1431         wnd
->SetBackgroundColour(GetColour(wxT("bg"))); 
1432     if (HasParam(wxT("fg"))) 
1433         wnd
->SetForegroundColour(GetColour(wxT("fg"))); 
1434     if (GetBool(wxT("enabled"), 1) == 0) 
1436     if (GetBool(wxT("focused"), 0) == 1) 
1438     if (GetBool(wxT("hidden"), 0) == 1) 
1441     if (HasParam(wxT("tooltip"))) 
1442         wnd
->SetToolTip(GetText(wxT("tooltip"))); 
1444     if (HasParam(wxT("font"))) 
1445         wnd
->SetFont(GetFont()); 
1446     if (HasParam(wxT("help"))) 
1447         wnd
->SetHelpText(GetText(wxT("help"))); 
1451 void wxXmlResourceHandler::CreateChildren(wxObject 
*parent
, bool this_hnd_only
) 
1453     wxXmlNode 
*n 
= m_node
->GetChildren(); 
1457         if (n
->GetType() == wxXML_ELEMENT_NODE 
&& 
1458            (n
->GetName() == wxT("object") || n
->GetName() == wxT("object_ref"))) 
1460             m_resource
->CreateResFromNode(n
, parent
, NULL
, 
1461                                           this_hnd_only 
? this : NULL
); 
1468 void wxXmlResourceHandler::CreateChildrenPrivately(wxObject 
*parent
, wxXmlNode 
*rootnode
) 
1471     if (rootnode 
== NULL
) root 
= m_node
; else root 
= rootnode
; 
1472     wxXmlNode 
*n 
= root
->GetChildren(); 
1476         if (n
->GetType() == wxXML_ELEMENT_NODE 
&& CanHandle(n
)) 
1478             CreateResource(n
, parent
, NULL
); 
1490 // --------------- XRCID implementation ----------------------------- 
1492 #define XRCID_TABLE_SIZE     1024 
1502 static XRCID_record 
*XRCID_Records
[XRCID_TABLE_SIZE
] = {NULL
}; 
1504 static int XRCID_Lookup(const wxChar 
*str_id
, int value_if_not_found 
= -2) 
1508     for (const wxChar 
*c 
= str_id
; *c 
!= wxT('\0'); c
++) index 
+= (int)*c
; 
1509     index 
%= XRCID_TABLE_SIZE
; 
1511     XRCID_record 
*oldrec 
= NULL
; 
1512     for (XRCID_record 
*rec 
= XRCID_Records
[index
]; rec
; rec 
= rec
->next
) 
1514         if (wxStrcmp(rec
->key
, str_id
) == 0) 
1521     XRCID_record 
**rec_var 
= (oldrec 
== NULL
) ? 
1522                               &XRCID_Records
[index
] : &oldrec
->next
; 
1523     *rec_var 
= new XRCID_record
; 
1524     (*rec_var
)->key 
= wxStrdup(str_id
); 
1525     (*rec_var
)->next 
= NULL
; 
1528     if (value_if_not_found 
!= -2) 
1529         (*rec_var
)->id 
= value_if_not_found
; 
1532         int asint 
= wxStrtol(str_id
, &end
, 10); 
1533         if (*str_id 
&& *end 
== 0) 
1535             // if str_id was integer, keep it verbosely: 
1536             (*rec_var
)->id 
= asint
; 
1540             (*rec_var
)->id 
= wxNewId(); 
1544     return (*rec_var
)->id
; 
1547 static void AddStdXRCID_Records(); 
1549 /*static*/ int wxXmlResource::GetXRCID(const wxChar 
*str_id
) 
1551     static bool s_stdIDsAdded 
= false; 
1553     if ( !s_stdIDsAdded 
) 
1555         s_stdIDsAdded 
= true; 
1556         AddStdXRCID_Records(); 
1559     return XRCID_Lookup(str_id
); 
1563 static void CleanXRCID_Record(XRCID_record 
*rec
) 
1567         CleanXRCID_Record(rec
->next
); 
1573 static void CleanXRCID_Records() 
1575     for (int i 
= 0; i 
< XRCID_TABLE_SIZE
; i
++) 
1577         CleanXRCID_Record(XRCID_Records
[i
]); 
1578         XRCID_Records
[i
] = NULL
; 
1582 static void AddStdXRCID_Records() 
1584 #define stdID(id) XRCID_Lookup(wxT(#id), id) 
1588     stdID(wxID_SEPARATOR
); 
1601     stdID(wxID_PRINT_SETUP
); 
1602     stdID(wxID_PREVIEW
); 
1604     stdID(wxID_HELP_CONTENTS
); 
1605     stdID(wxID_HELP_COMMANDS
); 
1606     stdID(wxID_HELP_PROCEDURES
); 
1607     stdID(wxID_HELP_CONTEXT
); 
1608     stdID(wxID_CLOSE_ALL
); 
1609     stdID(wxID_PREFERENCES
); 
1615     stdID(wxID_DUPLICATE
); 
1616     stdID(wxID_SELECTALL
); 
1618     stdID(wxID_REPLACE
); 
1619     stdID(wxID_REPLACE_ALL
); 
1620     stdID(wxID_PROPERTIES
); 
1621     stdID(wxID_VIEW_DETAILS
); 
1622     stdID(wxID_VIEW_LARGEICONS
); 
1623     stdID(wxID_VIEW_SMALLICONS
); 
1624     stdID(wxID_VIEW_LIST
); 
1625     stdID(wxID_VIEW_SORTDATE
); 
1626     stdID(wxID_VIEW_SORTNAME
); 
1627     stdID(wxID_VIEW_SORTSIZE
); 
1628     stdID(wxID_VIEW_SORTTYPE
); 
1644     stdID(wxID_FORWARD
); 
1645     stdID(wxID_BACKWARD
); 
1646     stdID(wxID_DEFAULT
); 
1650     stdID(wxID_CONTEXT_HELP
); 
1651     stdID(wxID_YESTOALL
); 
1652     stdID(wxID_NOTOALL
); 
1661     stdID(wxID_REFRESH
); 
1666     stdID(wxID_JUSTIFY_CENTER
); 
1667     stdID(wxID_JUSTIFY_FILL
); 
1668     stdID(wxID_JUSTIFY_RIGHT
); 
1669     stdID(wxID_JUSTIFY_LEFT
); 
1670     stdID(wxID_UNDERLINE
); 
1672     stdID(wxID_UNINDENT
); 
1673     stdID(wxID_ZOOM_100
); 
1674     stdID(wxID_ZOOM_FIT
); 
1675     stdID(wxID_ZOOM_IN
); 
1676     stdID(wxID_ZOOM_OUT
); 
1677     stdID(wxID_UNDELETE
); 
1678     stdID(wxID_REVERT_TO_SAVED
); 
1679     stdID(wxID_SYSTEM_MENU
); 
1680     stdID(wxID_CLOSE_FRAME
); 
1681     stdID(wxID_MOVE_FRAME
); 
1682     stdID(wxID_RESIZE_FRAME
); 
1683     stdID(wxID_MAXIMIZE_FRAME
); 
1684     stdID(wxID_ICONIZE_FRAME
); 
1685     stdID(wxID_RESTORE_FRAME
); 
1694 // --------------- module and globals ----------------------------- 
1696 class wxXmlResourceModule
: public wxModule
 
1698 DECLARE_DYNAMIC_CLASS(wxXmlResourceModule
) 
1700     wxXmlResourceModule() {} 
1703         wxXmlResource::AddSubclassFactory(new wxXmlSubclassFactoryCXX
); 
1708         delete wxXmlResource::Set(NULL
); 
1709         if(wxXmlResource::ms_subclassFactories
) 
1710             WX_CLEAR_LIST(wxXmlSubclassFactoriesList
, *wxXmlResource::ms_subclassFactories
); 
1711         wxDELETE(wxXmlResource::ms_subclassFactories
); 
1712         CleanXRCID_Records(); 
1716 IMPLEMENT_DYNAMIC_CLASS(wxXmlResourceModule
, wxModule
) 
1719 // When wxXml is loaded dynamically after the application is already running 
1720 // then the built-in module system won't pick this one up.  Add it manually. 
1721 void wxXmlInitResourceModule() 
1723     wxModule
* module = new wxXmlResourceModule
; 
1725     wxModule::RegisterModule(module);