]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/mdi.cpp
ae2e3a2c04cce2bb8c7b0c6da8c01e362fa098db
[wxWidgets.git] / src / palmos / mdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/mdi.cpp
3 // Purpose: MDI classes for wx
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ===========================================================================
13 // declarations
14 // ===========================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_MDI
28
29 #include "wx/mdi.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/frame.h"
33 #include "wx/menu.h"
34 #include "wx/app.h"
35 #include "wx/utils.h"
36 #include "wx/dialog.h"
37 #if wxUSE_STATUSBAR
38 #include "wx/statusbr.h"
39 #endif
40 #include "wx/settings.h"
41 #include "wx/intl.h"
42 #include "wx/log.h"
43 #include "wx/toolbar.h"
44 #endif
45
46 #include "wx/palmos/private.h"
47
48 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
49 #include "wx/palmos/statbr95.h"
50 #endif
51
52 #include <string.h>
53
54 // ---------------------------------------------------------------------------
55 // global variables
56 // ---------------------------------------------------------------------------
57
58 extern wxMenu *wxCurrentPopupMenu;
59
60 extern const wxChar *wxMDIFrameClassName; // from app.cpp
61 extern const wxChar *wxMDIChildFrameClassName;
62 extern const wxChar *wxMDIChildFrameClassNameNoRedraw;
63 extern void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
64 extern void wxRemoveHandleAssociation(wxWindow *win);
65
66
67 // ---------------------------------------------------------------------------
68 // constants
69 // ---------------------------------------------------------------------------
70
71 static const int IDM_WINDOWTILE = 4001;
72 static const int IDM_WINDOWTILEHOR = 4001;
73 static const int IDM_WINDOWCASCADE = 4002;
74 static const int IDM_WINDOWICONS = 4003;
75 static const int IDM_WINDOWNEXT = 4004;
76 static const int IDM_WINDOWTILEVERT = 4005;
77 static const int IDM_WINDOWPREV = 4006;
78
79 // This range gives a maximum of 500 MDI children. Should be enough :-)
80 static const int wxFIRST_MDI_CHILD = 4100;
81 static const int wxLAST_MDI_CHILD = 4600;
82
83 // Status border dimensions
84 static const int wxTHICK_LINE_BORDER = 3;
85 static const int wxTHICK_LINE_WIDTH = 1;
86
87 // ---------------------------------------------------------------------------
88 // private functions
89 // ---------------------------------------------------------------------------
90
91 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
92 // of the parent of win (which is supposed to be the MDI client window)
93 static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow);
94
95 // insert the window menu (subMenu) into menu just before "Help" submenu or at
96 // the very end if not found
97 static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu);
98
99 // Remove the window menu
100 static void RemoveWindowMenu(wxWindow *win, WXHMENU menu);
101
102 // is this an id of an MDI child?
103 inline bool IsMdiCommandId(int id)
104 {
105 return (id >= wxFIRST_MDI_CHILD) && (id <= wxLAST_MDI_CHILD);
106 }
107
108 // unpack the parameters of WM_MDIACTIVATE message
109 static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
110 WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact);
111
112 // return the HMENU of the MDI menu
113 static inline HMENU GetMDIWindowMenu(wxMDIParentFrame *frame)
114 {
115 wxMenu *menu = frame->GetWindowMenu();
116 return menu ? GetHmenuOf(menu) : 0;
117 }
118
119 // ===========================================================================
120 // implementation
121 // ===========================================================================
122
123 // ---------------------------------------------------------------------------
124 // wxWin macros
125 // ---------------------------------------------------------------------------
126
127 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
128 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
129 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
130
131 BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
132 EVT_SIZE(wxMDIParentFrame::OnSize)
133 END_EVENT_TABLE()
134
135 BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
136 EVT_IDLE(wxMDIChildFrame::OnIdle)
137 END_EVENT_TABLE()
138
139 BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
140 EVT_SCROLL(wxMDIClientWindow::OnScroll)
141 END_EVENT_TABLE()
142
143 // ===========================================================================
144 // wxMDIParentFrame: the frame which contains the client window which manages
145 // the children
146 // ===========================================================================
147
148 wxMDIParentFrame::wxMDIParentFrame()
149 {
150 }
151
152 bool wxMDIParentFrame::Create(wxWindow *parent,
153 wxWindowID id,
154 const wxString& title,
155 const wxPoint& pos,
156 const wxSize& size,
157 long style,
158 const wxString& name)
159 {
160 return false;
161 }
162
163 wxMDIParentFrame::~wxMDIParentFrame()
164 {
165 }
166
167 #if wxUSE_MENUS_NATIVE
168
169 void wxMDIParentFrame::InternalSetMenuBar()
170 {
171 }
172
173 #endif // wxUSE_MENUS_NATIVE
174
175 void wxMDIParentFrame::SetWindowMenu(wxMenu* menu)
176 {
177 }
178
179 void wxMDIParentFrame::OnSize(wxSizeEvent&)
180 {
181 }
182
183 // Returns the active MDI child window
184 wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
185 {
186 return NULL;
187 }
188
189 // Create the client window class (don't Create the window, just return a new
190 // class)
191 wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
192 {
193 return new wxMDIClientWindow;
194 }
195
196 WXHICON wxMDIParentFrame::GetDefaultIcon() const
197 {
198 // we don't have any standard icons (any more)
199 return (WXHICON)0;
200 }
201
202 // ---------------------------------------------------------------------------
203 // MDI operations
204 // ---------------------------------------------------------------------------
205
206 void wxMDIParentFrame::Cascade()
207 {
208 }
209
210 void wxMDIParentFrame::Tile()
211 {
212 }
213
214 void wxMDIParentFrame::ArrangeIcons()
215 {
216 }
217
218 void wxMDIParentFrame::ActivateNext()
219 {
220 }
221
222 void wxMDIParentFrame::ActivatePrevious()
223 {
224 }
225
226 // ---------------------------------------------------------------------------
227 // the MDI parent frame window proc
228 // ---------------------------------------------------------------------------
229
230 WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message,
231 WXWPARAM wParam,
232 WXLPARAM lParam)
233 {
234 return 0;
235 }
236
237 WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message,
238 WXWPARAM wParam,
239 WXLPARAM lParam)
240 {
241 return 0;
242 }
243
244 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg)
245 {
246 return false;
247 }
248
249 // ===========================================================================
250 // wxMDIChildFrame
251 // ===========================================================================
252
253 void wxMDIChildFrame::Init()
254 {
255 }
256
257 bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
258 wxWindowID id,
259 const wxString& title,
260 const wxPoint& pos,
261 const wxSize& size,
262 long style,
263 const wxString& name)
264 {
265 return false;
266 }
267
268 wxMDIChildFrame::~wxMDIChildFrame()
269 {
270 }
271
272 // Set the client size (i.e. leave the calculation of borders etc.
273 // to wxWidgets)
274 void wxMDIChildFrame::DoSetClientSize(int width, int height)
275 {
276 }
277
278 void wxMDIChildFrame::DoGetPosition(int *x, int *y) const
279 {
280 }
281
282 void wxMDIChildFrame::InternalSetMenuBar()
283 {
284 }
285
286 WXHICON wxMDIChildFrame::GetDefaultIcon() const
287 {
288 // we don't have any standard icons (any more)
289 return (WXHICON)0;
290 }
291
292 // ---------------------------------------------------------------------------
293 // MDI operations
294 // ---------------------------------------------------------------------------
295
296 void wxMDIChildFrame::Maximize(bool maximize)
297 {
298 }
299
300 void wxMDIChildFrame::Restore()
301 {
302 }
303
304 void wxMDIChildFrame::Activate()
305 {
306 }
307
308 // ---------------------------------------------------------------------------
309 // MDI window proc and message handlers
310 // ---------------------------------------------------------------------------
311
312 WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message,
313 WXWPARAM wParam,
314 WXLPARAM lParam)
315 {
316 return 0;
317 }
318
319 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate),
320 WXHWND hwndAct,
321 WXHWND hwndDeact)
322 {
323 return false;
324 }
325
326 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos)
327 {
328 return false;
329 }
330
331 // ---------------------------------------------------------------------------
332 // MDI specific message translation/preprocessing
333 // ---------------------------------------------------------------------------
334
335 WXLRESULT wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
336 {
337 return 0;
338 }
339
340 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg)
341 {
342 return false;
343 }
344
345 // ---------------------------------------------------------------------------
346 // misc
347 // ---------------------------------------------------------------------------
348
349 void wxMDIChildFrame::MSWDestroyWindow()
350 {
351 }
352
353 // Change the client window's extended style so we don't get a client edge
354 // style when a child is maximised (a double border looks silly.)
355 bool wxMDIChildFrame::ResetWindowStyle(void *vrect)
356 {
357 return false;
358 }
359
360 // ===========================================================================
361 // wxMDIClientWindow: the window of predefined (by Windows) class which
362 // contains the child frames
363 // ===========================================================================
364
365 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
366 {
367 return false;
368 }
369
370 // Explicitly call default scroll behaviour
371 void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
372 {
373 event.Skip();
374 }
375
376 void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
377 {
378 }
379
380 void wxMDIChildFrame::OnIdle(wxIdleEvent& event)
381 {
382 event.Skip();
383 }
384
385 // ---------------------------------------------------------------------------
386 // non member functions
387 // ---------------------------------------------------------------------------
388
389 static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow)
390 {
391 }
392
393 static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu)
394 {
395 }
396
397 static void RemoveWindowMenu(wxWindow *win, WXHMENU menu)
398 {
399 }
400
401 static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
402 WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact)
403 {
404 }
405
406 #endif // wxUSE_MDI