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"
36 #include "wx/dialog.h"
38 #include "wx/statusbr.h"
40 #include "wx/settings.h"
43 #include "wx/toolbar.h"
46 #include "wx/palmos/private.h"
48 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
49 #include "wx/palmos/statbr95.h"
54 // ---------------------------------------------------------------------------
56 // ---------------------------------------------------------------------------
58 extern wxMenu
*wxCurrentPopupMenu
;
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
);
67 // ---------------------------------------------------------------------------
69 // ---------------------------------------------------------------------------
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;
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;
83 // Status border dimensions
84 static const int wxTHICK_LINE_BORDER
= 3;
85 static const int wxTHICK_LINE_WIDTH
= 1;
87 // ---------------------------------------------------------------------------
89 // ---------------------------------------------------------------------------
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
);
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
);
99 // Remove the window menu
100 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
);
102 // is this an id of an MDI child?
103 inline bool IsMdiCommandId(int id
)
105 return (id
>= wxFIRST_MDI_CHILD
) && (id
<= wxLAST_MDI_CHILD
);
108 // unpack the parameters of WM_MDIACTIVATE message
109 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
110 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
);
112 // return the HMENU of the MDI menu
113 static inline HMENU
GetMDIWindowMenu(wxMDIParentFrame
*frame
)
115 wxMenu
*menu
= frame
->GetWindowMenu();
116 return menu
? GetHmenuOf(menu
) : 0;
119 // ===========================================================================
121 // ===========================================================================
123 // ---------------------------------------------------------------------------
125 // ---------------------------------------------------------------------------
127 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
128 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
129 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
131 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
132 EVT_SIZE(wxMDIParentFrame::OnSize
)
135 BEGIN_EVENT_TABLE(wxMDIChildFrame
, wxFrame
)
136 EVT_IDLE(wxMDIChildFrame::OnIdle
)
139 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
140 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
143 // ===========================================================================
144 // wxMDIParentFrame: the frame which contains the client window which manages
146 // ===========================================================================
148 wxMDIParentFrame::wxMDIParentFrame()
152 bool wxMDIParentFrame::Create(wxWindow
*parent
,
154 const wxString
& title
,
158 const wxString
& name
)
163 wxMDIParentFrame::~wxMDIParentFrame()
167 #if wxUSE_MENUS_NATIVE
169 void wxMDIParentFrame::InternalSetMenuBar()
173 #endif // wxUSE_MENUS_NATIVE
175 void wxMDIParentFrame::SetWindowMenu(wxMenu
* menu
)
179 void wxMDIParentFrame::OnSize(wxSizeEvent
&)
183 // Returns the active MDI child window
184 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
189 // Create the client window class (don't Create the window, just return a new
191 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
193 return new wxMDIClientWindow
;
196 WXHICON
wxMDIParentFrame::GetDefaultIcon() const
198 // we don't have any standard icons (any more)
202 // ---------------------------------------------------------------------------
204 // ---------------------------------------------------------------------------
206 void wxMDIParentFrame::Cascade()
210 void wxMDIParentFrame::Tile()
214 void wxMDIParentFrame::ArrangeIcons()
218 void wxMDIParentFrame::ActivateNext()
222 void wxMDIParentFrame::ActivatePrevious()
226 // ---------------------------------------------------------------------------
227 // the MDI parent frame window proc
228 // ---------------------------------------------------------------------------
230 WXLRESULT
wxMDIParentFrame::MSWWindowProc(WXUINT message
,
237 WXLRESULT
wxMDIParentFrame::MSWDefWindowProc(WXUINT message
,
244 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG
* msg
)
249 // ===========================================================================
251 // ===========================================================================
253 void wxMDIChildFrame::Init()
257 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
259 const wxString
& title
,
263 const wxString
& name
)
268 wxMDIChildFrame::~wxMDIChildFrame()
272 // Set the client size (i.e. leave the calculation of borders etc.
274 void wxMDIChildFrame::DoSetClientSize(int width
, int height
)
278 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const
282 void wxMDIChildFrame::InternalSetMenuBar()
286 WXHICON
wxMDIChildFrame::GetDefaultIcon() const
288 // we don't have any standard icons (any more)
292 // ---------------------------------------------------------------------------
294 // ---------------------------------------------------------------------------
296 void wxMDIChildFrame::Maximize(bool maximize
)
300 void wxMDIChildFrame::Restore()
304 void wxMDIChildFrame::Activate()
308 // ---------------------------------------------------------------------------
309 // MDI window proc and message handlers
310 // ---------------------------------------------------------------------------
312 WXLRESULT
wxMDIChildFrame::MSWWindowProc(WXUINT message
,
319 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
),
326 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
)
331 // ---------------------------------------------------------------------------
332 // MDI specific message translation/preprocessing
333 // ---------------------------------------------------------------------------
335 WXLRESULT
wxMDIChildFrame::MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
340 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG
* msg
)
345 // ---------------------------------------------------------------------------
347 // ---------------------------------------------------------------------------
349 void wxMDIChildFrame::MSWDestroyWindow()
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
)
360 // ===========================================================================
361 // wxMDIClientWindow: the window of predefined (by Windows) class which
362 // contains the child frames
363 // ===========================================================================
365 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
370 // Explicitly call default scroll behaviour
371 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
376 void wxMDIClientWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
380 void wxMDIChildFrame::OnIdle(wxIdleEvent
& event
)
385 // ---------------------------------------------------------------------------
386 // non member functions
387 // ---------------------------------------------------------------------------
389 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
)
393 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
)
397 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
)
401 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
402 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
)