1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_mdi.cpp
3 // Purpose: XRC resource for dialogs
4 // Author: David M. Falkinder & Vaclav Slavik
7 // Copyright: (c) 2005 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_MDI
20 #include "wx/xrc/xh_mdi.h"
22 #include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE
26 IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler
, wxXmlResourceHandler
)
28 wxMdiXmlHandler::wxMdiXmlHandler() : wxXmlResourceHandler()
30 XRC_ADD_STYLE(wxSTAY_ON_TOP
);
31 XRC_ADD_STYLE(wxCAPTION
);
32 XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE
);
33 XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE
);
34 #if WXWIN_COMPATIBILITY_2_6
35 XRC_ADD_STYLE(wxTHICK_FRAME
);
36 #endif // WXWIN_COMPATIBILITY_2_6
37 XRC_ADD_STYLE(wxSYSTEM_MENU
);
38 XRC_ADD_STYLE(wxRESIZE_BORDER
);
39 #if WXWIN_COMPATIBILITY_2_6
40 XRC_ADD_STYLE(wxRESIZE_BOX
);
41 #endif // WXWIN_COMPATIBILITY_2_6
42 XRC_ADD_STYLE(wxCLOSE_BOX
);
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
);
52 #if WXWIN_COMPATIBILITY_2_6
53 XRC_ADD_STYLE(wxNO_3D
);
54 #endif // WXWIN_COMPATIBILITY_2_6
55 XRC_ADD_STYLE(wxTAB_TRAVERSAL
);
56 XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY
);
57 XRC_ADD_STYLE(wxFRAME_EX_METAL
);
59 XRC_ADD_STYLE(wxHSCROLL
);
60 XRC_ADD_STYLE(wxVSCROLL
);
61 XRC_ADD_STYLE(wxMAXIMIZE
);
62 XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU
);
67 wxWindow
*wxMdiXmlHandler::CreateFrame()
69 if (m_class
== wxT("wxMDIParentFrame"))
71 XRC_MAKE_INSTANCE(frame
, wxMDIParentFrame
);
73 frame
->Create(m_parentAsWindow
,
75 GetText(wxT("title")),
76 wxDefaultPosition
, wxDefaultSize
,
77 GetStyle(wxT("style"),
78 wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
),
82 else // wxMDIChildFrame
84 wxMDIParentFrame
*mdiParent
= wxDynamicCast(m_parent
, wxMDIParentFrame
);
88 wxLogError(wxT("Parent of wxMDIParentFrame must be wxMDIParentFrame."));
92 XRC_MAKE_INSTANCE(frame
, wxMDIChildFrame
);
94 frame
->Create(mdiParent
,
96 GetText(wxT("title")),
97 wxDefaultPosition
, wxDefaultSize
,
98 GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE
),
105 wxObject
*wxMdiXmlHandler::DoCreateResource()
107 wxWindow
*frame
= CreateFrame();
109 if (HasParam(wxT("size")))
110 frame
->SetClientSize(GetSize());
111 if (HasParam(wxT("pos")))
112 frame
->Move(GetPosition());
113 if (HasParam(wxT("icon")))
115 wxFrame
* f
= wxDynamicCast(frame
, wxFrame
);
117 f
->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON
));
122 CreateChildren(frame
);
124 if (GetBool(wxT("centered"), false))
130 bool wxMdiXmlHandler::CanHandle(wxXmlNode
*node
)
132 return (IsOfClass(node
, wxT("wxMDIParentFrame")) ||
133 IsOfClass(node
, wxT("wxMDIChildFrame")));