]>
Commit | Line | Data |
---|---|---|
5a0348c4 | 1 | ///////////////////////////////////////////////////////////////////////////// |
1c067fe3 | 2 | // Name: src/xrc/xh_mdi.cpp |
5a0348c4 VS |
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 | ||
26 | IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler, wxXmlResourceHandler) | |
27 | ||
28 | wxMdiXmlHandler::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); | |
1c067fe3 | 34 | #if WXWIN_COMPATIBILITY_2_6 |
5a0348c4 | 35 | XRC_ADD_STYLE(wxTHICK_FRAME); |
1c067fe3 | 36 | #endif // WXWIN_COMPATIBILITY_2_6 |
5a0348c4 VS |
37 | XRC_ADD_STYLE(wxSYSTEM_MENU); |
38 | XRC_ADD_STYLE(wxRESIZE_BORDER); | |
1c067fe3 | 39 | #if WXWIN_COMPATIBILITY_2_6 |
5a0348c4 | 40 | XRC_ADD_STYLE(wxRESIZE_BOX); |
1c067fe3 | 41 | #endif // WXWIN_COMPATIBILITY_2_6 |
5a0348c4 VS |
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 | ||
1c067fe3 | 52 | #if WXWIN_COMPATIBILITY_2_6 |
5a0348c4 | 53 | XRC_ADD_STYLE(wxNO_3D); |
1c067fe3 | 54 | #endif // WXWIN_COMPATIBILITY_2_6 |
5a0348c4 VS |
55 | XRC_ADD_STYLE(wxTAB_TRAVERSAL); |
56 | XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY); | |
57 | XRC_ADD_STYLE(wxFRAME_EX_METAL); | |
58 | ||
59 | XRC_ADD_STYLE(wxHSCROLL); | |
60 | XRC_ADD_STYLE(wxVSCROLL); | |
61 | XRC_ADD_STYLE(wxMAXIMIZE); | |
62 | XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU); | |
63 | ||
64 | AddWindowStyles(); | |
65 | } | |
66 | ||
6def7a17 | 67 | wxWindow *wxMdiXmlHandler::CreateFrame() |
5a0348c4 VS |
68 | { |
69 | if (m_class == wxT("wxMDIParentFrame")) | |
70 | { | |
71 | XRC_MAKE_INSTANCE(frame, wxMDIParentFrame); | |
72 | ||
4791fafb | 73 | frame->Create(m_parentAsWindow, |
5a0348c4 VS |
74 | GetID(), |
75 | GetText(wxT("title")), | |
76 | wxDefaultPosition, wxDefaultSize, | |
77 | GetStyle(wxT("style"), | |
78 | wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL), | |
79 | GetName()); | |
80 | return frame; | |
81 | } | |
82 | else // wxMDIChildFrame | |
83 | { | |
84 | wxMDIParentFrame *mdiParent = wxDynamicCast(m_parent, wxMDIParentFrame); | |
85 | ||
86 | if ( !mdiParent ) | |
1e5deeb2 VZ |
87 | { |
88 | wxLogError(wxT("Parent of wxMDIParentFrame must be wxMDIParentFrame.")); | |
89 | return NULL; | |
90 | } | |
5a0348c4 VS |
91 | |
92 | XRC_MAKE_INSTANCE(frame, wxMDIChildFrame); | |
93 | ||
4791fafb | 94 | frame->Create(mdiParent, |
5a0348c4 VS |
95 | GetID(), |
96 | GetText(wxT("title")), | |
97 | wxDefaultPosition, wxDefaultSize, | |
98 | GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE), | |
99 | GetName()); | |
100 | ||
101 | return frame; | |
102 | } | |
103 | } | |
104 | ||
105 | wxObject *wxMdiXmlHandler::DoCreateResource() | |
106 | { | |
6def7a17 | 107 | wxWindow *frame = CreateFrame(); |
5a0348c4 VS |
108 | |
109 | if (HasParam(wxT("size"))) | |
110 | frame->SetClientSize(GetSize()); | |
111 | if (HasParam(wxT("pos"))) | |
112 | frame->Move(GetPosition()); | |
f9bf0c65 | 113 | if (HasParam(wxT("icon"))) |
6def7a17 | 114 | { |
cecbb4ec | 115 | wxFrame* f = wxDynamicCast(frame, wxFrame); |
f9bf0c65 VS |
116 | if (f) |
117 | f->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON)); | |
6def7a17 | 118 | } |
5a0348c4 VS |
119 | |
120 | SetupWindow(frame); | |
121 | ||
122 | CreateChildren(frame); | |
123 | ||
124 | if (GetBool(wxT("centered"), false)) | |
125 | frame->Centre(); | |
126 | ||
127 | return frame; | |
128 | } | |
129 | ||
130 | bool wxMdiXmlHandler::CanHandle(wxXmlNode *node) | |
131 | { | |
132 | return (IsOfClass(node, wxT("wxMDIParentFrame")) || | |
133 | IsOfClass(node, wxT("wxMDIChildFrame"))); | |
134 | } | |
135 | ||
136 | #endif // wxUSE_XRC |