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__)
34 #include "wx/dialog.h"
36 #include "wx/statusbr.h"
38 #include "wx/settings.h"
44 #include "wx/palmos/private.h"
46 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
47 #include "wx/palmos/statbr95.h"
51 #include "wx/toolbar.h"
52 #endif // wxUSE_TOOLBAR
56 // ---------------------------------------------------------------------------
58 // ---------------------------------------------------------------------------
60 extern wxMenu
*wxCurrentPopupMenu
;
62 extern const wxChar
*wxMDIFrameClassName
; // from app.cpp
63 extern const wxChar
*wxMDIChildFrameClassName
;
64 extern const wxChar
*wxMDIChildFrameClassNameNoRedraw
;
65 extern void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
66 extern void wxRemoveHandleAssociation(wxWindow
*win
);
69 // ---------------------------------------------------------------------------
71 // ---------------------------------------------------------------------------
73 static const int IDM_WINDOWTILE
= 4001;
74 static const int IDM_WINDOWTILEHOR
= 4001;
75 static const int IDM_WINDOWCASCADE
= 4002;
76 static const int IDM_WINDOWICONS
= 4003;
77 static const int IDM_WINDOWNEXT
= 4004;
78 static const int IDM_WINDOWTILEVERT
= 4005;
79 static const int IDM_WINDOWPREV
= 4006;
81 // This range gives a maximum of 500 MDI children. Should be enough :-)
82 static const int wxFIRST_MDI_CHILD
= 4100;
83 static const int wxLAST_MDI_CHILD
= 4600;
85 // Status border dimensions
86 static const int wxTHICK_LINE_BORDER
= 3;
87 static const int wxTHICK_LINE_WIDTH
= 1;
89 // ---------------------------------------------------------------------------
91 // ---------------------------------------------------------------------------
93 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
94 // of the parent of win (which is supposed to be the MDI client window)
95 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
);
97 // insert the window menu (subMenu) into menu just before "Help" submenu or at
98 // the very end if not found
99 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
);
101 // Remove the window menu
102 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
);
104 // is this an id of an MDI child?
105 inline bool IsMdiCommandId(int id
)
107 return (id
>= wxFIRST_MDI_CHILD
) && (id
<= wxLAST_MDI_CHILD
);
110 // unpack the parameters of WM_MDIACTIVATE message
111 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
112 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
);
114 // return the HMENU of the MDI menu
115 static inline HMENU
GetMDIWindowMenu(wxMDIParentFrame
*frame
)
117 wxMenu
*menu
= frame
->GetWindowMenu();
118 return menu
? GetHmenuOf(menu
) : 0;
121 // ===========================================================================
123 // ===========================================================================
125 // ---------------------------------------------------------------------------
127 // ---------------------------------------------------------------------------
129 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
130 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
131 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
133 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
134 EVT_SIZE(wxMDIParentFrame::OnSize
)
137 BEGIN_EVENT_TABLE(wxMDIChildFrame
, wxFrame
)
138 EVT_IDLE(wxMDIChildFrame::OnIdle
)
141 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
142 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
145 // ===========================================================================
146 // wxMDIParentFrame: the frame which contains the client window which manages
148 // ===========================================================================
150 wxMDIParentFrame::wxMDIParentFrame()
154 bool wxMDIParentFrame::Create(wxWindow
*parent
,
156 const wxString
& title
,
160 const wxString
& name
)
165 wxMDIParentFrame::~wxMDIParentFrame()
169 #if wxUSE_MENUS_NATIVE
171 void wxMDIParentFrame::InternalSetMenuBar()
175 #endif // wxUSE_MENUS_NATIVE
177 void wxMDIParentFrame::SetWindowMenu(wxMenu
* menu
)
181 void wxMDIParentFrame::OnSize(wxSizeEvent
&)
185 // Returns the active MDI child window
186 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
191 // Create the client window class (don't Create the window, just return a new
193 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
195 return new wxMDIClientWindow
;
198 WXHICON
wxMDIParentFrame::GetDefaultIcon() const
200 // we don't have any standard icons (any more)
204 // ---------------------------------------------------------------------------
206 // ---------------------------------------------------------------------------
208 void wxMDIParentFrame::Cascade()
212 void wxMDIParentFrame::Tile()
216 void wxMDIParentFrame::ArrangeIcons()
220 void wxMDIParentFrame::ActivateNext()
224 void wxMDIParentFrame::ActivatePrevious()
228 // ---------------------------------------------------------------------------
229 // the MDI parent frame window proc
230 // ---------------------------------------------------------------------------
232 WXLRESULT
wxMDIParentFrame::MSWWindowProc(WXUINT message
,
239 WXLRESULT
wxMDIParentFrame::MSWDefWindowProc(WXUINT message
,
246 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG
* msg
)
251 // ===========================================================================
253 // ===========================================================================
255 void wxMDIChildFrame::Init()
259 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
261 const wxString
& title
,
265 const wxString
& name
)
270 wxMDIChildFrame::~wxMDIChildFrame()
274 // Set the client size (i.e. leave the calculation of borders etc.
276 void wxMDIChildFrame::DoSetClientSize(int width
, int height
)
280 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const
284 void wxMDIChildFrame::InternalSetMenuBar()
288 WXHICON
wxMDIChildFrame::GetDefaultIcon() const
290 // we don't have any standard icons (any more)
294 // ---------------------------------------------------------------------------
296 // ---------------------------------------------------------------------------
298 void wxMDIChildFrame::Maximize(bool maximize
)
302 void wxMDIChildFrame::Restore()
306 void wxMDIChildFrame::Activate()
310 // ---------------------------------------------------------------------------
311 // MDI window proc and message handlers
312 // ---------------------------------------------------------------------------
314 WXLRESULT
wxMDIChildFrame::MSWWindowProc(WXUINT message
,
321 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
),
328 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
)
333 // ---------------------------------------------------------------------------
334 // MDI specific message translation/preprocessing
335 // ---------------------------------------------------------------------------
337 WXLRESULT
wxMDIChildFrame::MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
342 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG
* msg
)
347 // ---------------------------------------------------------------------------
349 // ---------------------------------------------------------------------------
351 void wxMDIChildFrame::MSWDestroyWindow()
355 // Change the client window's extended style so we don't get a client edge
356 // style when a child is maximised (a double border looks silly.)
357 bool wxMDIChildFrame::ResetWindowStyle(void *vrect
)
362 // ===========================================================================
363 // wxMDIClientWindow: the window of predefined (by Windows) class which
364 // contains the child frames
365 // ===========================================================================
367 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
372 // Explicitly call default scroll behaviour
373 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
378 void wxMDIClientWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
382 void wxMDIChildFrame::OnIdle(wxIdleEvent
& event
)
387 // ---------------------------------------------------------------------------
388 // non member functions
389 // ---------------------------------------------------------------------------
391 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
)
395 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
)
399 static void RemoveWindowMenu(wxWindow
*win
, WXHMENU menu
)
403 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
404 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
)
408 #endif // wxUSE_MDI && !defined(__WXUNIVERSAL__)