Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mdi.h | |
3 | // Purpose: MDI (Multiple Document Interface) classes. | |
4 | // This doesn't have to be implemented just like Windows, | |
5 | // it could be a tabbed design as in wxGTK. | |
75f11ad7 | 6 | // Author: David Webster |
0e320a79 | 7 | // Modified by: |
75f11ad7 | 8 | // Created: 10/10/99 |
0e320a79 | 9 | // RCS-ID: $Id$ |
75f11ad7 | 10 | // Copyright: (c) David Webster |
65571936 | 11 | // Licence: wxWindows licence |
0e320a79 DW |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_MDI_H_ | |
15 | #define _WX_MDI_H_ | |
16 | ||
0e320a79 DW |
17 | #include "wx/frame.h" |
18 | ||
0e320a79 DW |
19 | class WXDLLEXPORT wxMDIClientWindow; |
20 | class WXDLLEXPORT wxMDIChildFrame; | |
21 | ||
22 | class WXDLLEXPORT wxMDIParentFrame: public wxFrame | |
23 | { | |
24 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) | |
25 | ||
26 | friend class WXDLLEXPORT wxMDIChildFrame; | |
27 | public: | |
28 | ||
29 | wxMDIParentFrame(); | |
30 | inline wxMDIParentFrame(wxWindow *parent, | |
31 | wxWindowID id, | |
32 | const wxString& title, | |
33 | const wxPoint& pos = wxDefaultPosition, | |
34 | const wxSize& size = wxDefaultSize, | |
35 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window | |
36 | const wxString& name = wxFrameNameStr) | |
37 | { | |
38 | Create(parent, id, title, pos, size, style, name); | |
39 | } | |
40 | ||
41 | ~wxMDIParentFrame(); | |
42 | ||
43 | bool Create(wxWindow *parent, | |
44 | wxWindowID id, | |
45 | const wxString& title, | |
46 | const wxPoint& pos = wxDefaultPosition, | |
47 | const wxSize& size = wxDefaultSize, | |
48 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
49 | const wxString& name = wxFrameNameStr); | |
50 | ||
75f11ad7 DW |
51 | // accessors |
52 | // --------- | |
53 | ||
54 | // Get the active MDI child window (Windows only) | |
55 | wxMDIChildFrame *GetActiveChild() const; | |
56 | ||
57 | // Get the client window | |
58 | wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; } | |
59 | ||
60 | // Create the client window class (don't Create the window, | |
61 | // just return a new class) | |
62 | virtual wxMDIClientWindow *OnCreateClient(void); | |
63 | ||
289b2951 DW |
64 | wxMenu* GetWindowMenu() const { return m_windowMenu; } |
65 | // void SetWindowMenu(wxMwnu* pMenu); | |
0e320a79 | 66 | |
75f11ad7 DW |
67 | // MDI operations |
68 | // -------------- | |
69 | virtual void Cascade(); | |
70 | virtual void Tile(); | |
71 | virtual void ArrangeIcons(); | |
72 | virtual void ActivateNext(); | |
73 | virtual void ActivatePrevious(); | |
0e320a79 | 74 | |
75f11ad7 DW |
75 | // handlers |
76 | // -------- | |
0e320a79 | 77 | |
75f11ad7 DW |
78 | // Responds to colour changes |
79 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
0e320a79 | 80 | |
75f11ad7 | 81 | void OnSize(wxSizeEvent& event); |
0e320a79 | 82 | |
75f11ad7 DW |
83 | bool HandleActivate(int state, bool minimized, WXHWND activate); |
84 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
0e320a79 | 85 | |
75f11ad7 | 86 | // override window proc for MDI-specific message processing |
a885d89a | 87 | virtual MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
75f11ad7 | 88 | |
a885d89a | 89 | virtual MRESULT OS2DefWindowProc(WXUINT, WXWPARAM, WXLPARAM); |
75f11ad7 | 90 | virtual bool OS2TranslateMessage(WXMSG* msg); |
0e320a79 DW |
91 | |
92 | protected: | |
75f11ad7 DW |
93 | virtual void InternalSetMenuBar(); |
94 | ||
95 | wxMDIClientWindow * m_clientWindow; | |
96 | wxMDIChildFrame * m_currentChild; | |
289b2951 | 97 | wxMenu* m_windowMenu; |
0e320a79 | 98 | |
75f11ad7 DW |
99 | // TRUE if MDI Frame is intercepting commands, not child |
100 | bool m_parentFrameActive; | |
0e320a79 | 101 | |
75f11ad7 | 102 | private: |
75f11ad7 | 103 | DECLARE_EVENT_TABLE() |
0e320a79 DW |
104 | }; |
105 | ||
106 | class WXDLLEXPORT wxMDIChildFrame: public wxFrame | |
107 | { | |
108 | DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) | |
109 | public: | |
110 | ||
111 | wxMDIChildFrame(); | |
112 | inline wxMDIChildFrame(wxMDIParentFrame *parent, | |
113 | wxWindowID id, | |
114 | const wxString& title, | |
115 | const wxPoint& pos = wxDefaultPosition, | |
116 | const wxSize& size = wxDefaultSize, | |
117 | long style = wxDEFAULT_FRAME_STYLE, | |
118 | const wxString& name = wxFrameNameStr) | |
119 | { | |
120 | Create(parent, id, title, pos, size, style, name); | |
121 | } | |
122 | ||
123 | ~wxMDIChildFrame(); | |
124 | ||
125 | bool Create(wxMDIParentFrame *parent, | |
126 | wxWindowID id, | |
127 | const wxString& title, | |
128 | const wxPoint& pos = wxDefaultPosition, | |
129 | const wxSize& size = wxDefaultSize, | |
130 | long style = wxDEFAULT_FRAME_STYLE, | |
131 | const wxString& name = wxFrameNameStr); | |
132 | ||
75f11ad7 DW |
133 | // MDI operations |
134 | virtual void Maximize(bool maximize = TRUE); | |
135 | virtual void Restore(); | |
136 | virtual void Activate(); | |
0e320a79 | 137 | |
75f11ad7 DW |
138 | // Handlers |
139 | ||
140 | bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); | |
141 | bool HandleSize(int x, int y, WXUINT); | |
142 | bool HandleWindowPosChanging(void *lpPos); | |
143 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
144 | ||
a885d89a DW |
145 | virtual MRESULT OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
146 | virtual MRESULT OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
75f11ad7 DW |
147 | virtual bool OS2TranslateMessage(WXMSG *msg); |
148 | ||
149 | virtual void OS2DestroyWindow(); | |
150 | ||
151 | // Implementation | |
152 | bool ResetWindowStyle(void *vrect); | |
153 | ||
154 | protected: | |
155 | virtual void DoGetPosition(int *x, int *y) const; | |
156 | virtual void DoSetClientSize(int width, int height); | |
157 | virtual void InternalSetMenuBar(); | |
0e320a79 DW |
158 | }; |
159 | ||
160 | /* The client window is a child of the parent MDI frame, and itself | |
161 | * contains the child MDI frames. | |
162 | * However, you create the MDI children as children of the MDI parent: | |
163 | * only in the implementation does the client window become the parent | |
164 | * of the children. Phew! So the children are sort of 'adopted'... | |
165 | */ | |
166 | ||
167 | class WXDLLEXPORT wxMDIClientWindow: public wxWindow | |
168 | { | |
169 | DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) | |
75f11ad7 | 170 | |
0e320a79 DW |
171 | public: |
172 | ||
75f11ad7 DW |
173 | wxMDIClientWindow() { Init(); } |
174 | wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) | |
175 | { | |
176 | Init(); | |
0e320a79 | 177 | |
75f11ad7 DW |
178 | CreateClient(parent, style); |
179 | } | |
0e320a79 | 180 | |
75f11ad7 DW |
181 | // Note: this is virtual, to allow overridden behaviour. |
182 | virtual bool CreateClient(wxMDIParentFrame *parent, | |
183 | long style = wxVSCROLL | wxHSCROLL); | |
0e320a79 | 184 | |
75f11ad7 DW |
185 | // Explicitly call default scroll behaviour |
186 | void OnScroll(wxScrollEvent& event); | |
0e320a79 DW |
187 | |
188 | protected: | |
75f11ad7 | 189 | void Init() { m_scrollX = m_scrollY = 0; } |
0e320a79 | 190 | |
75f11ad7 DW |
191 | int m_scrollX, m_scrollY; |
192 | ||
193 | private: | |
194 | DECLARE_EVENT_TABLE() | |
0e320a79 DW |
195 | }; |
196 | ||
197 | #endif | |
198 | // _WX_MDI_H_ |