]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_mdi.cpp
Really remove the droppings when there are no pages
[wxWidgets.git] / src / xrc / xh_mdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_mdi.cpp
3 // Purpose: XRC resource for dialogs
4 // Author: David M. Falkinder & Vaclav Slavik
5 // Created: 14/02/2005
6 // RCS-ID: $Id$
7 // Copyright: (c) 2005 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12 #pragma implementation "xh_mdi.h"
13 #endif
14
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
17
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 #if wxUSE_XRC && wxUSE_MDI
23
24 #include "wx/xrc/xh_mdi.h"
25 #include "wx/mdi.h"
26 #include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE
27 #include "wx/log.h"
28 #include "wx/intl.h"
29
30 IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler, wxXmlResourceHandler)
31
32 wxMdiXmlHandler::wxMdiXmlHandler() : wxXmlResourceHandler()
33 {
34 XRC_ADD_STYLE(wxSTAY_ON_TOP);
35 XRC_ADD_STYLE(wxCAPTION);
36 XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
37 XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE);
38 XRC_ADD_STYLE(wxTHICK_FRAME);
39 XRC_ADD_STYLE(wxSYSTEM_MENU);
40 XRC_ADD_STYLE(wxRESIZE_BORDER);
41 XRC_ADD_STYLE(wxRESIZE_BOX);
42 XRC_ADD_STYLE(wxCLOSE_BOX);
43
44 XRC_ADD_STYLE(wxFRAME_NO_TASKBAR);
45 XRC_ADD_STYLE(wxFRAME_SHAPED);
46 XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW);
47 XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT);
48 XRC_ADD_STYLE(wxMAXIMIZE_BOX);
49 XRC_ADD_STYLE(wxMINIMIZE_BOX);
50 XRC_ADD_STYLE(wxSTAY_ON_TOP);
51
52 XRC_ADD_STYLE(wxNO_3D);
53 XRC_ADD_STYLE(wxTAB_TRAVERSAL);
54 XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
55 XRC_ADD_STYLE(wxFRAME_EX_METAL);
56
57 XRC_ADD_STYLE(wxHSCROLL);
58 XRC_ADD_STYLE(wxVSCROLL);
59 XRC_ADD_STYLE(wxMAXIMIZE);
60 XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU);
61
62 AddWindowStyles();
63 }
64
65 wxWindow *wxMdiXmlHandler::CreateFrame()
66 {
67 if (m_class == wxT("wxMDIParentFrame"))
68 {
69 XRC_MAKE_INSTANCE(frame, wxMDIParentFrame);
70
71 frame->Create(m_parentAsWindow,
72 GetID(),
73 GetText(wxT("title")),
74 wxDefaultPosition, wxDefaultSize,
75 GetStyle(wxT("style"),
76 wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL),
77 GetName());
78 return frame;
79 }
80 else // wxMDIChildFrame
81 {
82 wxMDIParentFrame *mdiParent = wxDynamicCast(m_parent, wxMDIParentFrame);
83
84 if ( !mdiParent )
85 wxLogError(wxT("Parent is not of type wxMDIParentFrame."));
86
87 XRC_MAKE_INSTANCE(frame, wxMDIChildFrame);
88
89 frame->Create(mdiParent,
90 GetID(),
91 GetText(wxT("title")),
92 wxDefaultPosition, wxDefaultSize,
93 GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
94 GetName());
95
96 return frame;
97 }
98 }
99
100 wxObject *wxMdiXmlHandler::DoCreateResource()
101 {
102 wxWindow *frame = CreateFrame();
103
104 if (HasParam(wxT("size")))
105 frame->SetClientSize(GetSize());
106 if (HasParam(wxT("pos")))
107 frame->Move(GetPosition());
108 if (HasParam(wxT("icon")))
109 {
110 wxFrame* f = wxDynamicCast(frame, wxFrame);
111 if (f)
112 f->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON));
113 }
114
115 SetupWindow(frame);
116
117 CreateChildren(frame);
118
119 if (GetBool(wxT("centered"), false))
120 frame->Centre();
121
122 return frame;
123 }
124
125 bool wxMdiXmlHandler::CanHandle(wxXmlNode *node)
126 {
127 return (IsOfClass(node, wxT("wxMDIParentFrame")) ||
128 IsOfClass(node, wxT("wxMDIChildFrame")));
129 }
130
131 #endif // wxUSE_XRC