]>
Commit | Line | Data |
---|---|---|
aa1b2573 JS |
1 | /////////////////////////////////////////////////////////////////////////////\r |
2 | // Name: src/xrc/xh_propdlg.cpp\r | |
3 | // Purpose: XRC resource handler for wxPropertySheetDialog\r | |
4 | // Author: Sander Berents\r | |
5 | // Created: 2007/07/12\r | |
6 | // RCS-ID: $Id$\r | |
7 | // Copyright: (c) 2007 Sander Berents\r | |
8 | // Licence: wxWindows licence\r | |
9 | /////////////////////////////////////////////////////////////////////////////\r | |
10 | \r | |
11 | // For compilers that support precompilation, includes "wx.h".\r | |
12 | #include "wx/wxprec.h"\r | |
13 | \r | |
14 | #ifdef __BORLANDC__\r | |
15 | #pragma hdrstop\r | |
16 | #endif\r | |
17 | \r | |
18 | #if wxUSE_XRC && wxUSE_BOOKCTRL\r | |
19 | \r | |
20 | #include "wx/xrc/xh_propdlg.h"\r | |
21 | \r | |
22 | #ifndef WX_PRECOMP\r | |
23 | #include "wx/log.h"\r | |
24 | #include "wx/sizer.h"\r | |
25 | #endif\r | |
26 | \r | |
27 | #include "wx/bookctrl.h"\r | |
28 | #include "wx/propdlg.h"\r | |
29 | \r | |
30 | IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler, wxXmlResourceHandler)\r | |
31 | \r | |
32 | wxPropertySheetDialogXmlHandler::wxPropertySheetDialogXmlHandler()\r | |
33 | :wxXmlResourceHandler(),\r | |
34 | m_isInside(false),\r | |
35 | m_dialog(NULL)\r | |
36 | {\r | |
37 | XRC_ADD_STYLE(wxSTAY_ON_TOP);\r | |
38 | XRC_ADD_STYLE(wxCAPTION);\r | |
39 | XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);\r | |
40 | XRC_ADD_STYLE(wxSYSTEM_MENU);\r | |
41 | XRC_ADD_STYLE(wxRESIZE_BORDER);\r | |
42 | XRC_ADD_STYLE(wxCLOSE_BOX);\r | |
43 | XRC_ADD_STYLE(wxDIALOG_NO_PARENT);\r | |
44 | \r | |
45 | XRC_ADD_STYLE(wxTAB_TRAVERSAL);\r | |
46 | XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);\r | |
47 | XRC_ADD_STYLE(wxDIALOG_EX_METAL);\r | |
48 | XRC_ADD_STYLE(wxMAXIMIZE_BOX);\r | |
49 | XRC_ADD_STYLE(wxMINIMIZE_BOX);\r | |
50 | XRC_ADD_STYLE(wxFRAME_SHAPED);\r | |
51 | XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP);\r | |
52 | \r | |
53 | AddWindowStyles();\r | |
54 | }\r | |
55 | \r | |
56 | wxObject *wxPropertySheetDialogXmlHandler::DoCreateResource()\r | |
57 | {\r | |
58 | if (m_class == wxT("propertysheetpage"))\r | |
59 | {\r | |
60 | wxXmlNode *n = GetParamNode(wxT("object"));\r | |
61 | \r | |
62 | if (!n) n = GetParamNode(wxT("object_ref"));\r | |
63 | \r | |
64 | if (n)\r | |
65 | {\r | |
66 | wxBookCtrlBase *bookctrl = m_dialog->GetBookCtrl();\r | |
67 | bool old_ins = m_isInside;\r | |
68 | m_isInside = false;\r | |
69 | wxObject *item = CreateResFromNode(n, bookctrl, NULL);\r | |
70 | m_isInside = old_ins;\r | |
71 | wxWindow *wnd = wxDynamicCast(item, wxWindow);\r | |
72 | \r | |
73 | if (wnd)\r | |
74 | {\r | |
75 | bookctrl->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")));\r | |
76 | if (HasParam(wxT("bitmap")))\r | |
77 | {\r | |
78 | wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);\r | |
79 | wxImageList *imgList = bookctrl->GetImageList();\r | |
80 | if (imgList == NULL)\r | |
81 | {\r | |
82 | imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight());\r | |
83 | bookctrl->AssignImageList(imgList);\r | |
84 | }\r | |
85 | int imgIndex = imgList->Add(bmp);\r | |
86 | bookctrl->SetPageImage(bookctrl->GetPageCount()-1, imgIndex);\r | |
87 | }\r | |
88 | }\r | |
89 | else\r | |
90 | wxLogError(wxT("Error in resource."));\r | |
91 | return wnd;\r | |
92 | }\r | |
93 | else\r | |
94 | {\r | |
95 | wxLogError(wxT("Error in resource: no control within wxPropertySheetDialog's <page> tag."));\r | |
96 | return NULL;\r | |
97 | }\r | |
98 | }\r | |
99 | \r | |
100 | else\r | |
101 | {\r | |
102 | XRC_MAKE_INSTANCE(dlg, wxPropertySheetDialog)\r | |
103 | \r | |
104 | dlg->Create(m_parentAsWindow,\r | |
105 | GetID(),\r | |
106 | GetText(wxT("title")),\r | |
107 | GetPosition(),\r | |
108 | GetSize(),\r | |
109 | GetStyle(),\r | |
110 | GetName());\r | |
111 | \r | |
112 | if (HasParam(wxT("icon"))) dlg->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON));\r | |
113 | \r | |
114 | SetupWindow(dlg);\r | |
115 | \r | |
116 | wxPropertySheetDialog *old_par = m_dialog;\r | |
117 | m_dialog = dlg;\r | |
118 | bool old_ins = m_isInside;\r | |
119 | m_isInside = true;\r | |
120 | CreateChildren(m_dialog, true/*only this handler*/);\r | |
121 | m_isInside = old_ins;\r | |
122 | m_dialog = old_par;\r | |
123 | \r | |
124 | if (GetBool(wxT("centered"), false)) dlg->Centre();\r | |
125 | wxString buttons = GetText(wxT("buttons"));\r | |
126 | if (!buttons.IsEmpty())\r | |
127 | {\r | |
128 | int flags = 0;\r | |
129 | if (buttons.Find(wxT("wxOK")) != wxNOT_FOUND) flags |= wxOK;\r | |
130 | if (buttons.Find(wxT("wxCANCEL")) != wxNOT_FOUND) flags |= wxCANCEL;\r | |
131 | if (buttons.Find(wxT("wxYES")) != wxNOT_FOUND) flags |= wxYES;\r | |
132 | if (buttons.Find(wxT("wxNO")) != wxNOT_FOUND) flags |= wxNO;\r | |
133 | if (buttons.Find(wxT("wxHELP")) != wxNOT_FOUND) flags |= wxHELP;\r | |
134 | if (buttons.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND) flags |= wxNO_DEFAULT;\r | |
135 | dlg->CreateButtons(flags);\r | |
136 | }\r | |
137 | \r | |
138 | return dlg;\r | |
139 | }\r | |
140 | }\r | |
141 | \r | |
142 | bool wxPropertySheetDialogXmlHandler::CanHandle(wxXmlNode *node)\r | |
143 | {\r | |
144 | return ((!m_isInside && IsOfClass(node, wxT("wxPropertySheetDialog"))) ||\r | |
145 | (m_isInside && IsOfClass(node, wxT("propertysheetpage"))));\r | |
146 | }\r | |
147 | \r | |
148 | #endif // wxUSE_XRC && wxUSE_BOOKCTRL\r |