]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_notbk.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     XRC resource for wxNotebook 
   4 // Author:      Vaclav Slavik 
   7 // Copyright:   (c) 2000 Vaclav Slavik 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  12 #pragma implementation "xh_notbk.h" 
  15 // For compilers that support precompilation, includes "wx.h". 
  16 #include "wx/wxprec.h" 
  22 #if wxUSE_XRC && wxUSE_NOTEBOOK 
  24 #include "wx/xrc/xh_notbk.h" 
  27 #include "wx/notebook.h" 
  28 #include "wx/imaglist.h" 
  31 IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler
, wxXmlResourceHandler
) 
  33 wxNotebookXmlHandler::wxNotebookXmlHandler() 
  34 : wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL
) 
  36     XRC_ADD_STYLE(wxNB_DEFAULT
); 
  37     XRC_ADD_STYLE(wxNB_LEFT
); 
  38     XRC_ADD_STYLE(wxNB_RIGHT
); 
  39     XRC_ADD_STYLE(wxNB_TOP
); 
  40     XRC_ADD_STYLE(wxNB_BOTTOM
); 
  42     XRC_ADD_STYLE(wxNB_FIXEDWIDTH
); 
  43     XRC_ADD_STYLE(wxNB_MULTILINE
); 
  44     XRC_ADD_STYLE(wxNB_NOPAGETHEME
); 
  49 wxObject 
*wxNotebookXmlHandler::DoCreateResource() 
  51     if (m_class 
== wxT("notebookpage")) 
  53         wxXmlNode 
*n 
= GetParamNode(wxT("object")); 
  56             n 
= GetParamNode(wxT("object_ref")); 
  60             bool old_ins 
= m_isInside
; 
  62             wxObject 
*item 
= CreateResFromNode(n
, m_notebook
, NULL
); 
  64             wxWindow 
*wnd 
= wxDynamicCast(item
, wxWindow
); 
  68                 m_notebook
->AddPage(wnd
, GetText(wxT("label")), 
  69                                          GetBool(wxT("selected"))); 
  70                 if ( HasParam(wxT("bitmap")) ) 
  72                     wxBitmap bmp 
= GetBitmap(wxT("bitmap"), wxART_OTHER
); 
  73                     wxImageList 
*imgList 
= m_notebook
->GetImageList(); 
  74                     if ( imgList 
== NULL 
) 
  76                         imgList 
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() ); 
  77                         m_notebook
->AssignImageList( imgList 
); 
  79                     int imgIndex 
= imgList
->Add(bmp
); 
  80                     m_notebook
->SetPageImage(m_notebook
->GetPageCount()-1, imgIndex 
); 
  84                 wxLogError(wxT("Error in resource.")); 
  89             wxLogError(wxT("Error in resource: no control within notebook's <page> tag.")); 
  96         XRC_MAKE_INSTANCE(nb
, wxNotebook
) 
  98         nb
->Create(m_parentAsWindow
, 
 100                    GetPosition(), GetSize(), 
 101                    GetStyle(wxT("style")), 
 104         wxNotebook 
*old_par 
= m_notebook
; 
 106         bool old_ins 
= m_isInside
; 
 108         CreateChildren(m_notebook
, true/*only this handler*/); 
 109         m_isInside 
= old_ins
; 
 110         m_notebook 
= old_par
; 
 116 bool wxNotebookXmlHandler::CanHandle(wxXmlNode 
*node
) 
 118     return ((!m_isInside 
&& IsOfClass(node
, wxT("wxNotebook"))) || 
 119             (m_isInside 
&& IsOfClass(node
, wxT("notebookpage")))); 
 122 #endif // wxUSE_XRC && wxUSE_NOTEBOOK