]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_mdi.cpp
use wxHAVE_U_ESCAPE to accomodate old compilers
[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 )
1e5deeb2
VZ
81 {
82 wxLogError(wxT("Parent of wxMDIParentFrame must be wxMDIParentFrame."));
83 return NULL;
84 }
5a0348c4
VS
85
86 XRC_MAKE_INSTANCE(frame, wxMDIChildFrame);
87
4791fafb 88 frame->Create(mdiParent,
5a0348c4
VS
89 GetID(),
90 GetText(wxT("title")),
91 wxDefaultPosition, wxDefaultSize,
92 GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
93 GetName());
94
95 return frame;
96 }
97}
98
99wxObject *wxMdiXmlHandler::DoCreateResource()
100{
6def7a17 101 wxWindow *frame = CreateFrame();
5a0348c4
VS
102
103 if (HasParam(wxT("size")))
104 frame->SetClientSize(GetSize());
105 if (HasParam(wxT("pos")))
106 frame->Move(GetPosition());
f9bf0c65 107 if (HasParam(wxT("icon")))
6def7a17 108 {
cecbb4ec 109 wxFrame* f = wxDynamicCast(frame, wxFrame);
f9bf0c65
VS
110 if (f)
111 f->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON));
6def7a17 112 }
5a0348c4
VS
113
114 SetupWindow(frame);
115
116 CreateChildren(frame);
117
118 if (GetBool(wxT("centered"), false))
119 frame->Centre();
120
121 return frame;
122}
123
124bool wxMdiXmlHandler::CanHandle(wxXmlNode *node)
125{
126 return (IsOfClass(node, wxT("wxMDIParentFrame")) ||
127 IsOfClass(node, wxT("wxMDIChildFrame")));
128}
129
130#endif // wxUSE_XRC