]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_mdi.cpp
wxGTK1 : wx/private/eventloopsourcesmanager.h was missing in evtloop.cpp
[wxWidgets.git] / src / xrc / xh_mdi.cpp
CommitLineData
5a0348c4 1/////////////////////////////////////////////////////////////////////////////
1c067fe3 2// Name: src/xrc/xh_mdi.cpp
dd47af27 3// Purpose: XRC resource for wxMDI
5a0348c4
VS
4// Author: David M. Falkinder & Vaclav Slavik
5// Created: 14/02/2005
5a0348c4
VS
6// Copyright: (c) 2005 Vaclav Slavik
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
5a0348c4
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#if wxUSE_XRC && wxUSE_MDI
18
19#include "wx/xrc/xh_mdi.h"
de5d5cc0 20#include "wx/mdi.h"
88a7a4e1
WS
21
22#ifndef WX_PRECOMP
23 #include "wx/intl.h"
e4db172a 24 #include "wx/log.h"
fdf565fe 25 #include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE
88a7a4e1
WS
26#endif
27
5a0348c4
VS
28IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler, wxXmlResourceHandler)
29
30wxMdiXmlHandler::wxMdiXmlHandler() : wxXmlResourceHandler()
31{
32 XRC_ADD_STYLE(wxSTAY_ON_TOP);
33 XRC_ADD_STYLE(wxCAPTION);
34 XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
35 XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE);
1c067fe3 36#if WXWIN_COMPATIBILITY_2_6
5a0348c4 37 XRC_ADD_STYLE(wxTHICK_FRAME);
1c067fe3 38#endif // WXWIN_COMPATIBILITY_2_6
5a0348c4
VS
39 XRC_ADD_STYLE(wxSYSTEM_MENU);
40 XRC_ADD_STYLE(wxRESIZE_BORDER);
1c067fe3 41#if WXWIN_COMPATIBILITY_2_6
5a0348c4 42 XRC_ADD_STYLE(wxRESIZE_BOX);
1c067fe3 43#endif // WXWIN_COMPATIBILITY_2_6
5a0348c4
VS
44 XRC_ADD_STYLE(wxCLOSE_BOX);
45
46 XRC_ADD_STYLE(wxFRAME_NO_TASKBAR);
47 XRC_ADD_STYLE(wxFRAME_SHAPED);
48 XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW);
49 XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT);
50 XRC_ADD_STYLE(wxMAXIMIZE_BOX);
51 XRC_ADD_STYLE(wxMINIMIZE_BOX);
52 XRC_ADD_STYLE(wxSTAY_ON_TOP);
53
1c067fe3 54#if WXWIN_COMPATIBILITY_2_6
5a0348c4 55 XRC_ADD_STYLE(wxNO_3D);
1c067fe3 56#endif // WXWIN_COMPATIBILITY_2_6
5a0348c4
VS
57 XRC_ADD_STYLE(wxTAB_TRAVERSAL);
58 XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
59 XRC_ADD_STYLE(wxFRAME_EX_METAL);
60
61 XRC_ADD_STYLE(wxHSCROLL);
62 XRC_ADD_STYLE(wxVSCROLL);
63 XRC_ADD_STYLE(wxMAXIMIZE);
64 XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU);
65
66 AddWindowStyles();
67}
68
6def7a17 69wxWindow *wxMdiXmlHandler::CreateFrame()
5a0348c4
VS
70{
71 if (m_class == wxT("wxMDIParentFrame"))
72 {
73 XRC_MAKE_INSTANCE(frame, wxMDIParentFrame);
74
4791fafb 75 frame->Create(m_parentAsWindow,
5a0348c4
VS
76 GetID(),
77 GetText(wxT("title")),
78 wxDefaultPosition, wxDefaultSize,
79 GetStyle(wxT("style"),
80 wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL),
81 GetName());
82 return frame;
83 }
84 else // wxMDIChildFrame
85 {
86 wxMDIParentFrame *mdiParent = wxDynamicCast(m_parent, wxMDIParentFrame);
87
88 if ( !mdiParent )
1e5deeb2 89 {
819559b2 90 ReportError("parent of wxMDIChildFrame must be wxMDIParentFrame");
1e5deeb2
VZ
91 return NULL;
92 }
5a0348c4
VS
93
94 XRC_MAKE_INSTANCE(frame, wxMDIChildFrame);
95
4791fafb 96 frame->Create(mdiParent,
5a0348c4
VS
97 GetID(),
98 GetText(wxT("title")),
99 wxDefaultPosition, wxDefaultSize,
100 GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
101 GetName());
102
103 return frame;
104 }
105}
106
107wxObject *wxMdiXmlHandler::DoCreateResource()
108{
6def7a17 109 wxWindow *frame = CreateFrame();
5a0348c4
VS
110
111 if (HasParam(wxT("size")))
112 frame->SetClientSize(GetSize());
113 if (HasParam(wxT("pos")))
114 frame->Move(GetPosition());
f9bf0c65 115 if (HasParam(wxT("icon")))
6def7a17 116 {
cecbb4ec 117 wxFrame* f = wxDynamicCast(frame, wxFrame);
f9bf0c65 118 if (f)
1c60f644 119 f->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON));
6def7a17 120 }
5a0348c4
VS
121
122 SetupWindow(frame);
123
124 CreateChildren(frame);
125
126 if (GetBool(wxT("centered"), false))
127 frame->Centre();
128
129 return frame;
130}
131
132bool wxMdiXmlHandler::CanHandle(wxXmlNode *node)
133{
134 return (IsOfClass(node, wxT("wxMDIParentFrame")) ||
135 IsOfClass(node, wxT("wxMDIChildFrame")));
136}
137
88a7a4e1 138#endif // wxUSE_XRC && wxUSE_MDI