1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_propdlg.cpp
3 // Purpose: XRC resource handler for wxPropertySheetDialog
4 // Author: Sander Berents
7 // Copyright: (c) 2007 Sander Berents
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_BOOKCTRL
20 #include "wx/xrc/xh_propdlg.h"
28 #include "wx/bookctrl.h"
29 #include "wx/propdlg.h"
30 #include "wx/imaglist.h"
32 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler
, wxXmlResourceHandler
)
34 wxPropertySheetDialogXmlHandler::wxPropertySheetDialogXmlHandler()
35 :wxXmlResourceHandler(),
39 XRC_ADD_STYLE(wxSTAY_ON_TOP
);
40 XRC_ADD_STYLE(wxCAPTION
);
41 XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE
);
42 XRC_ADD_STYLE(wxSYSTEM_MENU
);
43 XRC_ADD_STYLE(wxRESIZE_BORDER
);
44 XRC_ADD_STYLE(wxCLOSE_BOX
);
45 XRC_ADD_STYLE(wxDIALOG_NO_PARENT
);
47 XRC_ADD_STYLE(wxTAB_TRAVERSAL
);
48 XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY
);
49 XRC_ADD_STYLE(wxDIALOG_EX_METAL
);
50 XRC_ADD_STYLE(wxMAXIMIZE_BOX
);
51 XRC_ADD_STYLE(wxMINIMIZE_BOX
);
52 XRC_ADD_STYLE(wxFRAME_SHAPED
);
53 XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP
);
58 wxObject
*wxPropertySheetDialogXmlHandler::DoCreateResource()
60 if (m_class
== wxT("propertysheetpage"))
62 wxXmlNode
*n
= GetParamNode(wxT("object"));
64 if (!n
) n
= GetParamNode(wxT("object_ref"));
68 wxBookCtrlBase
*bookctrl
= m_dialog
->GetBookCtrl();
69 bool old_ins
= m_isInside
;
71 wxObject
*item
= CreateResFromNode(n
, bookctrl
, NULL
);
73 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
77 bookctrl
->AddPage(wnd
, GetText(wxT("label")), GetBool(wxT("selected")));
78 if (HasParam(wxT("bitmap")))
80 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
81 wxImageList
*imgList
= bookctrl
->GetImageList();
84 imgList
= new wxImageList(bmp
.GetWidth(), bmp
.GetHeight());
85 bookctrl
->AssignImageList(imgList
);
87 int imgIndex
= imgList
->Add(bmp
);
88 bookctrl
->SetPageImage(bookctrl
->GetPageCount()-1, imgIndex
);
92 wxLogError(wxT("Error in resource."));
97 wxLogError(wxT("Error in resource: no control within wxPropertySheetDialog's <page> tag."));
104 XRC_MAKE_INSTANCE(dlg
, wxPropertySheetDialog
)
106 dlg
->Create(m_parentAsWindow
,
108 GetText(wxT("title")),
114 if (HasParam(wxT("icon"))) dlg
->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON
));
118 wxPropertySheetDialog
*old_par
= m_dialog
;
120 bool old_ins
= m_isInside
;
122 CreateChildren(m_dialog
, true/*only this handler*/);
123 m_isInside
= old_ins
;
126 if (GetBool(wxT("centered"), false)) dlg
->Centre();
127 wxString buttons
= GetText(wxT("buttons"));
128 if (!buttons
.IsEmpty())
131 if (buttons
.Find(wxT("wxOK")) != wxNOT_FOUND
) flags
|= wxOK
;
132 if (buttons
.Find(wxT("wxCANCEL")) != wxNOT_FOUND
) flags
|= wxCANCEL
;
133 if (buttons
.Find(wxT("wxYES")) != wxNOT_FOUND
) flags
|= wxYES
;
134 if (buttons
.Find(wxT("wxNO")) != wxNOT_FOUND
) flags
|= wxNO
;
135 if (buttons
.Find(wxT("wxHELP")) != wxNOT_FOUND
) flags
|= wxHELP
;
136 if (buttons
.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND
) flags
|= wxNO_DEFAULT
;
137 dlg
->CreateButtons(flags
);
144 bool wxPropertySheetDialogXmlHandler::CanHandle(wxXmlNode
*node
)
146 return ((!m_isInside
&& IsOfClass(node
, wxT("wxPropertySheetDialog"))) ||
147 (m_isInside
&& IsOfClass(node
, wxT("propertysheetpage"))));
150 #endif // wxUSE_XRC && wxUSE_BOOKCTRL