]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_mdi.cpp
Compile fixes for the const patch
[wxWidgets.git] / src / xrc / xh_mdi.cpp
CommitLineData
5a0348c4
VS
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
5a0348c4
VS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#if wxUSE_XRC && wxUSE_MDI
19
20#include "wx/xrc/xh_mdi.h"
21#include "wx/mdi.h"
22#include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE
23#include "wx/log.h"
24#include "wx/intl.h"
25
26IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler, wxXmlResourceHandler)
27
28wxMdiXmlHandler::wxMdiXmlHandler() : wxXmlResourceHandler()
29{
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 XRC_ADD_STYLE(wxTHICK_FRAME);
35 XRC_ADD_STYLE(wxSYSTEM_MENU);
36 XRC_ADD_STYLE(wxRESIZE_BORDER);
37 XRC_ADD_STYLE(wxRESIZE_BOX);
38 XRC_ADD_STYLE(wxCLOSE_BOX);
39
40 XRC_ADD_STYLE(wxFRAME_NO_TASKBAR);
41 XRC_ADD_STYLE(wxFRAME_SHAPED);
42 XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW);
43 XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT);
44 XRC_ADD_STYLE(wxMAXIMIZE_BOX);
45 XRC_ADD_STYLE(wxMINIMIZE_BOX);
46 XRC_ADD_STYLE(wxSTAY_ON_TOP);
47
48 XRC_ADD_STYLE(wxNO_3D);
49 XRC_ADD_STYLE(wxTAB_TRAVERSAL);
50 XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
51 XRC_ADD_STYLE(wxFRAME_EX_METAL);
52
53 XRC_ADD_STYLE(wxHSCROLL);
54 XRC_ADD_STYLE(wxVSCROLL);
55 XRC_ADD_STYLE(wxMAXIMIZE);
56 XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU);
57
58 AddWindowStyles();
59}
60
6def7a17 61wxWindow *wxMdiXmlHandler::CreateFrame()
5a0348c4
VS
62{
63 if (m_class == wxT("wxMDIParentFrame"))
64 {
65 XRC_MAKE_INSTANCE(frame, wxMDIParentFrame);
66
4791fafb 67 frame->Create(m_parentAsWindow,
5a0348c4
VS
68 GetID(),
69 GetText(wxT("title")),
70 wxDefaultPosition, wxDefaultSize,
71 GetStyle(wxT("style"),
72 wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL),
73 GetName());
74 return frame;
75 }
76 else // wxMDIChildFrame
77 {
78 wxMDIParentFrame *mdiParent = wxDynamicCast(m_parent, wxMDIParentFrame);
79
80 if ( !mdiParent )
81 wxLogError(wxT("Parent is not of type wxMDIParentFrame."));
82
83 XRC_MAKE_INSTANCE(frame, wxMDIChildFrame);
84
4791fafb 85 frame->Create(mdiParent,
5a0348c4
VS
86 GetID(),
87 GetText(wxT("title")),
88 wxDefaultPosition, wxDefaultSize,
89 GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
90 GetName());
91
92 return frame;
93 }
94}
95
96wxObject *wxMdiXmlHandler::DoCreateResource()
97{
6def7a17 98 wxWindow *frame = CreateFrame();
5a0348c4
VS
99
100 if (HasParam(wxT("size")))
101 frame->SetClientSize(GetSize());
102 if (HasParam(wxT("pos")))
103 frame->Move(GetPosition());
f9bf0c65 104 if (HasParam(wxT("icon")))
6def7a17 105 {
cecbb4ec 106 wxFrame* f = wxDynamicCast(frame, wxFrame);
f9bf0c65
VS
107 if (f)
108 f->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON));
6def7a17 109 }
5a0348c4
VS
110
111 SetupWindow(frame);
112
113 CreateChildren(frame);
114
115 if (GetBool(wxT("centered"), false))
116 frame->Centre();
117
118 return frame;
119}
120
121bool wxMdiXmlHandler::CanHandle(wxXmlNode *node)
122{
123 return (IsOfClass(node, wxT("wxMDIParentFrame")) ||
124 IsOfClass(node, wxT("wxMDIChildFrame")));
125}
126
127#endif // wxUSE_XRC