1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/mdi.cpp
3 // Purpose: MDI classes for wx
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #if wxUSE_MDI && !defined(__WXUNIVERSAL__)
35 #include "wx/dialog.h"
37 #include "wx/statusbr.h"
39 #include "wx/settings.h"
45 #include "wx/palmos/private.h"
47 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
48 #include "wx/palmos/statbr95.h"
52 #include "wx/toolbar.h"
53 #endif // wxUSE_TOOLBAR
57 // ---------------------------------------------------------------------------
59 // ---------------------------------------------------------------------------
61 extern wxMenu
*wxCurrentPopupMenu
;
63 extern const wxChar
*wxMDIFrameClassName
; // from app.cpp
64 extern const wxChar
*wxMDIChildFrameClassName
;
65 extern const wxChar
*wxMDIChildFrameClassNameNoRedraw
;
66 extern void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
67 extern void wxRemoveHandleAssociation(wxWindow
*win
);
70 // ---------------------------------------------------------------------------
72 // ---------------------------------------------------------------------------
74 static const int IDM_WINDOWTILE
= 4001;
75 static const int IDM_WINDOWTILEHOR
= 4001;
76 static const int IDM_WINDOWCASCADE
= 4002;
77 static const int IDM_WINDOWICONS
= 4003;
78 static const int IDM_WINDOWNEXT
= 4004;
79 static const int IDM_WINDOWTILEVERT
= 4005;
80 static const int IDM_WINDOWPREV
= 4006;
82 // This range gives a maximum of 500 MDI children. Should be enough :-)
83 static const int wxFIRST_MDI_CHILD
= 4100;
84 static const int wxLAST_MDI_CHILD
= 4600;
86 // Status border dimensions
87 static const int wxTHICK_LINE_BORDER
= 3;
88 static const int wxTHICK_LINE_WIDTH
= 1;
90 // ---------------------------------------------------------------------------
92 // ---------------------------------------------------------------------------
94 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
95 // of the parent of win (which is supposed to be the MDI client window)
96 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
);
98 // insert the window menu (subMenu) into menu just before "Help" submenu or at
99 // the very end if not found
100 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
);
102 // Remove the window menu
103 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
);
105 // is this an id of an MDI child?
106 inline bool IsMdiCommandId(int id
)
108 return (id
>= wxFIRST_MDI_CHILD
) && (id
<= wxLAST_MDI_CHILD
);
111 // unpack the parameters of WM_MDIACTIVATE message
112 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
113 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
);
115 // return the HMENU of the MDI menu
116 static inline HMENU
GetMDIWindowMenu(wxMDIParentFrame
*frame
)
118 wxMenu
*menu
= frame
->GetWindowMenu();
119 return menu
? GetHmenuOf(menu
) : 0;
122 // ===========================================================================
124 // ===========================================================================
126 // ---------------------------------------------------------------------------
128 // ---------------------------------------------------------------------------
130 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
131 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
132 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
134 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
135 EVT_SIZE(wxMDIParentFrame::OnSize
)
138 BEGIN_EVENT_TABLE(wxMDIChildFrame
, wxFrame
)
139 EVT_IDLE(wxMDIChildFrame::OnIdle
)
142 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
143 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
146 // ===========================================================================
147 // wxMDIParentFrame: the frame which contains the client window which manages
149 // ===========================================================================
151 wxMDIParentFrame::wxMDIParentFrame()
155 bool wxMDIParentFrame::Create(wxWindow
*parent
,
157 const wxString
& title
,
161 const wxString
& name
)
166 wxMDIParentFrame::~wxMDIParentFrame()
170 #if wxUSE_MENUS_NATIVE
172 void wxMDIParentFrame::InternalSetMenuBar()
176 #endif // wxUSE_MENUS_NATIVE
178 void wxMDIParentFrame::SetWindowMenu(wxMenu
* menu
)
182 void wxMDIParentFrame::OnSize(wxSizeEvent
&)
186 // Returns the active MDI child window
187 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
192 // Create the client window class (don't Create the window, just return a new
194 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
196 return new wxMDIClientWindow
;
199 WXHICON
wxMDIParentFrame::GetDefaultIcon() const
201 // we don't have any standard icons (any more)
205 // ---------------------------------------------------------------------------
207 // ---------------------------------------------------------------------------
209 void wxMDIParentFrame::Cascade()
213 void wxMDIParentFrame::Tile()
217 void wxMDIParentFrame::ArrangeIcons()
221 void wxMDIParentFrame::ActivateNext()
225 void wxMDIParentFrame::ActivatePrevious()
229 // ---------------------------------------------------------------------------
230 // the MDI parent frame window proc
231 // ---------------------------------------------------------------------------
233 WXLRESULT
wxMDIParentFrame::MSWWindowProc(WXUINT message
,
240 WXLRESULT
wxMDIParentFrame::MSWDefWindowProc(WXUINT message
,
247 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG
* msg
)
252 // ===========================================================================
254 // ===========================================================================
256 void wxMDIChildFrame::Init()
260 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
262 const wxString
& title
,
266 const wxString
& name
)
271 wxMDIChildFrame::~wxMDIChildFrame()
275 // Set the client size (i.e. leave the calculation of borders etc.
277 void wxMDIChildFrame::DoSetClientSize(int width
, int height
)
281 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const
285 void wxMDIChildFrame::InternalSetMenuBar()
289 WXHICON
wxMDIChildFrame::GetDefaultIcon() const
291 // we don't have any standard icons (any more)
295 // ---------------------------------------------------------------------------
297 // ---------------------------------------------------------------------------
299 void wxMDIChildFrame::Maximize(bool maximize
)
303 void wxMDIChildFrame::Restore()
307 void wxMDIChildFrame::Activate()
311 // ---------------------------------------------------------------------------
312 // MDI window proc and message handlers
313 // ---------------------------------------------------------------------------
315 WXLRESULT
wxMDIChildFrame::MSWWindowProc(WXUINT message
,
322 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
),
329 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
)
334 // ---------------------------------------------------------------------------
335 // MDI specific message translation/preprocessing
336 // ---------------------------------------------------------------------------
338 WXLRESULT
wxMDIChildFrame::MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
343 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG
* msg
)
348 // ---------------------------------------------------------------------------
350 // ---------------------------------------------------------------------------
352 void wxMDIChildFrame::MSWDestroyWindow()
356 // Change the client window's extended style so we don't get a client edge
357 // style when a child is maximised (a double border looks silly.)
358 bool wxMDIChildFrame::ResetWindowStyle(void *vrect
)
363 // ===========================================================================
364 // wxMDIClientWindow: the window of predefined (by Windows) class which
365 // contains the child frames
366 // ===========================================================================
368 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
373 // Explicitly call default scroll behaviour
374 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
379 void wxMDIClientWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
383 void wxMDIChildFrame::OnIdle(wxIdleEvent
& event
)
388 // ---------------------------------------------------------------------------
389 // non member functions
390 // ---------------------------------------------------------------------------
392 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
)
396 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
)
400 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
)
404 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
405 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
)
409 #endif // wxUSE_MDI && !defined(__WXUNIVERSAL__)