1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/mdi.cpp
3 // Purpose: MDI classes for wx
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "mdi.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
31 #if wxUSE_MDI && !defined(__WXUNIVERSAL__)
39 #include "wx/dialog.h"
41 #include "wx/statusbr.h"
43 #include "wx/settings.h"
49 #include "wx/palmos/private.h"
51 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
52 #include "wx/palmos/statbr95.h"
56 #include "wx/toolbar.h"
57 #endif // wxUSE_TOOLBAR
61 // ---------------------------------------------------------------------------
63 // ---------------------------------------------------------------------------
65 extern wxMenu
*wxCurrentPopupMenu
;
67 extern const wxChar
*wxMDIFrameClassName
; // from app.cpp
68 extern const wxChar
*wxMDIChildFrameClassName
;
69 extern const wxChar
*wxMDIChildFrameClassNameNoRedraw
;
70 extern void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
71 extern void wxRemoveHandleAssociation(wxWindow
*win
);
74 // ---------------------------------------------------------------------------
76 // ---------------------------------------------------------------------------
78 static const int IDM_WINDOWTILE
= 4001;
79 static const int IDM_WINDOWTILEHOR
= 4001;
80 static const int IDM_WINDOWCASCADE
= 4002;
81 static const int IDM_WINDOWICONS
= 4003;
82 static const int IDM_WINDOWNEXT
= 4004;
83 static const int IDM_WINDOWTILEVERT
= 4005;
84 static const int IDM_WINDOWPREV
= 4006;
86 // This range gives a maximum of 500 MDI children. Should be enough :-)
87 static const int wxFIRST_MDI_CHILD
= 4100;
88 static const int wxLAST_MDI_CHILD
= 4600;
90 // Status border dimensions
91 static const int wxTHICK_LINE_BORDER
= 3;
92 static const int wxTHICK_LINE_WIDTH
= 1;
94 // ---------------------------------------------------------------------------
96 // ---------------------------------------------------------------------------
98 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
99 // of the parent of win (which is supposed to be the MDI client window)
100 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
);
102 // insert the window menu (subMenu) into menu just before "Help" submenu or at
103 // the very end if not found
104 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
);
106 // Remove the window menu
107 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
);
109 // is this an id of an MDI child?
110 inline bool IsMdiCommandId(int id
)
112 return (id
>= wxFIRST_MDI_CHILD
) && (id
<= wxLAST_MDI_CHILD
);
115 // unpack the parameters of WM_MDIACTIVATE message
116 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
117 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
);
119 // return the HMENU of the MDI menu
120 static inline HMENU
GetMDIWindowMenu(wxMDIParentFrame
*frame
)
122 wxMenu
*menu
= frame
->GetWindowMenu();
123 return menu
? GetHmenuOf(menu
) : 0;
126 // ===========================================================================
128 // ===========================================================================
130 // ---------------------------------------------------------------------------
132 // ---------------------------------------------------------------------------
134 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
135 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
136 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
138 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
139 EVT_SIZE(wxMDIParentFrame::OnSize
)
140 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged
)
143 BEGIN_EVENT_TABLE(wxMDIChildFrame
, wxFrame
)
144 EVT_IDLE(wxMDIChildFrame::OnIdle
)
147 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
148 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
151 // ===========================================================================
152 // wxMDIParentFrame: the frame which contains the client window which manages
154 // ===========================================================================
156 wxMDIParentFrame::wxMDIParentFrame()
160 bool wxMDIParentFrame::Create(wxWindow
*parent
,
162 const wxString
& title
,
166 const wxString
& name
)
171 wxMDIParentFrame::~wxMDIParentFrame()
175 #if wxUSE_MENUS_NATIVE
177 void wxMDIParentFrame::InternalSetMenuBar()
181 #endif // wxUSE_MENUS_NATIVE
183 void wxMDIParentFrame::SetWindowMenu(wxMenu
* menu
)
187 void wxMDIParentFrame::OnSize(wxSizeEvent
&)
191 // Returns the active MDI child window
192 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
197 // Create the client window class (don't Create the window, just return a new
199 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
201 return new wxMDIClientWindow
;
204 // Responds to colour changes, and passes event on to children.
205 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
210 WXHICON
wxMDIParentFrame::GetDefaultIcon() const
212 // we don't have any standard icons (any more)
216 // ---------------------------------------------------------------------------
218 // ---------------------------------------------------------------------------
220 void wxMDIParentFrame::Cascade()
224 void wxMDIParentFrame::Tile()
228 void wxMDIParentFrame::ArrangeIcons()
232 void wxMDIParentFrame::ActivateNext()
236 void wxMDIParentFrame::ActivatePrevious()
240 // ---------------------------------------------------------------------------
241 // the MDI parent frame window proc
242 // ---------------------------------------------------------------------------
244 WXLRESULT
wxMDIParentFrame::MSWWindowProc(WXUINT message
,
251 bool wxMDIParentFrame::HandleActivate(int state
, bool minimized
, WXHWND activate
)
256 bool wxMDIParentFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND hwnd
)
261 WXLRESULT
wxMDIParentFrame::MSWDefWindowProc(WXUINT message
,
268 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG
* msg
)
273 // ===========================================================================
275 // ===========================================================================
277 void wxMDIChildFrame::Init()
281 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
283 const wxString
& title
,
287 const wxString
& name
)
292 wxMDIChildFrame::~wxMDIChildFrame()
296 // Set the client size (i.e. leave the calculation of borders etc.
298 void wxMDIChildFrame::DoSetClientSize(int width
, int height
)
302 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const
306 void wxMDIChildFrame::InternalSetMenuBar()
310 WXHICON
wxMDIChildFrame::GetDefaultIcon() const
312 // we don't have any standard icons (any more)
316 // ---------------------------------------------------------------------------
318 // ---------------------------------------------------------------------------
320 void wxMDIChildFrame::Maximize(bool maximize
)
324 void wxMDIChildFrame::Restore()
328 void wxMDIChildFrame::Activate()
332 // ---------------------------------------------------------------------------
333 // MDI window proc and message handlers
334 // ---------------------------------------------------------------------------
336 WXLRESULT
wxMDIChildFrame::MSWWindowProc(WXUINT message
,
343 bool wxMDIChildFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND hwnd
)
348 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
),
355 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
)
360 bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo
)
365 // ---------------------------------------------------------------------------
366 // MDI specific message translation/preprocessing
367 // ---------------------------------------------------------------------------
369 WXLRESULT
wxMDIChildFrame::MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
374 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG
* msg
)
379 // ---------------------------------------------------------------------------
381 // ---------------------------------------------------------------------------
383 void wxMDIChildFrame::MSWDestroyWindow()
387 // Change the client window's extended style so we don't get a client edge
388 // style when a child is maximised (a double border looks silly.)
389 bool wxMDIChildFrame::ResetWindowStyle(void *vrect
)
394 // ===========================================================================
395 // wxMDIClientWindow: the window of predefined (by Windows) class which
396 // contains the child frames
397 // ===========================================================================
399 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
404 // Explicitly call default scroll behaviour
405 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
410 void wxMDIClientWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
414 void wxMDIChildFrame::OnIdle(wxIdleEvent
& event
)
419 // ---------------------------------------------------------------------------
420 // non member functions
421 // ---------------------------------------------------------------------------
423 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
)
427 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
)
431 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
)
435 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
436 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
)
440 #endif // wxUSE_MDI && !defined(__WXUNIVERSAL__)