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" 
  37     #include "wx/statusbr.h" 
  38     #include "wx/settings.h" 
  41     #include "wx/toolbar.h" 
  44 #include "wx/palmos/private.h" 
  46 #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR 
  47     #include "wx/palmos/statbr95.h" 
  52 // --------------------------------------------------------------------------- 
  54 // --------------------------------------------------------------------------- 
  56 extern wxMenu 
*wxCurrentPopupMenu
; 
  58 extern const wxChar 
*wxMDIFrameClassName
;   // from app.cpp 
  59 extern const wxChar 
*wxMDIChildFrameClassName
; 
  60 extern const wxChar 
*wxMDIChildFrameClassNameNoRedraw
; 
  61 extern void wxAssociateWinWithHandle(HWND hWnd
, wxWindow 
*win
); 
  62 extern void wxRemoveHandleAssociation(wxWindow 
*win
); 
  65 // --------------------------------------------------------------------------- 
  67 // --------------------------------------------------------------------------- 
  69 static const int IDM_WINDOWTILE  
= 4001; 
  70 static const int IDM_WINDOWTILEHOR  
= 4001; 
  71 static const int IDM_WINDOWCASCADE 
= 4002; 
  72 static const int IDM_WINDOWICONS 
= 4003; 
  73 static const int IDM_WINDOWNEXT 
= 4004; 
  74 static const int IDM_WINDOWTILEVERT 
= 4005; 
  75 static const int IDM_WINDOWPREV 
= 4006; 
  77 // This range gives a maximum of 500 MDI children. Should be enough :-) 
  78 static const int wxFIRST_MDI_CHILD 
= 4100; 
  79 static const int wxLAST_MDI_CHILD 
= 4600; 
  81 // Status border dimensions 
  82 static const int wxTHICK_LINE_BORDER 
= 3; 
  83 static const int wxTHICK_LINE_WIDTH  
= 1; 
  85 // --------------------------------------------------------------------------- 
  87 // --------------------------------------------------------------------------- 
  89 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu 
  90 // of the parent of win (which is supposed to be the MDI client window) 
  91 static void MDISetMenu(wxWindow 
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
); 
  93 // insert the window menu (subMenu) into menu just before "Help" submenu or at 
  94 // the very end if not found 
  95 static void InsertWindowMenu(wxWindow 
*win
, WXHMENU menu
, HMENU subMenu
); 
  97 // Remove the window menu 
  98 static void RemoveWindowMenu(wxWindow 
*win
, WXHMENU menu
); 
 100 // is this an id of an MDI child? 
 101 inline bool IsMdiCommandId(int id
) 
 103     return (id 
>= wxFIRST_MDI_CHILD
) && (id 
<= wxLAST_MDI_CHILD
); 
 106 // unpack the parameters of WM_MDIACTIVATE message 
 107 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
, 
 108                               WXWORD 
*activate
, WXHWND 
*hwndAct
, WXHWND 
*hwndDeact
); 
 110 // return the HMENU of the MDI menu 
 111 static inline HMENU 
GetMDIWindowMenu(wxMDIParentFrame 
*frame
) 
 113     wxMenu 
*menu 
= frame
->GetWindowMenu(); 
 114     return menu 
? GetHmenuOf(menu
) : 0; 
 117 // =========================================================================== 
 119 // =========================================================================== 
 121 // --------------------------------------------------------------------------- 
 123 // --------------------------------------------------------------------------- 
 125 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
) 
 126 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
) 
 127 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
) 
 129 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
) 
 130     EVT_SIZE(wxMDIParentFrame::OnSize
) 
 133 BEGIN_EVENT_TABLE(wxMDIChildFrame
, wxFrame
) 
 134     EVT_IDLE(wxMDIChildFrame::OnIdle
) 
 137 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
) 
 138     EVT_SCROLL(wxMDIClientWindow::OnScroll
) 
 141 // =========================================================================== 
 142 // wxMDIParentFrame: the frame which contains the client window which manages 
 144 // =========================================================================== 
 146 wxMDIParentFrame::wxMDIParentFrame() 
 150 bool wxMDIParentFrame::Create(wxWindow 
*parent
, 
 152                               const wxString
& title
, 
 156                               const wxString
& name
) 
 161 wxMDIParentFrame::~wxMDIParentFrame() 
 165 #if wxUSE_MENUS_NATIVE 
 167 void wxMDIParentFrame::InternalSetMenuBar() 
 171 #endif // wxUSE_MENUS_NATIVE 
 173 void wxMDIParentFrame::SetWindowMenu(wxMenu
* menu
) 
 177 void wxMDIParentFrame::OnSize(wxSizeEvent
&) 
 181 // Returns the active MDI child window 
 182 wxMDIChildFrame 
*wxMDIParentFrame::GetActiveChild() const 
 187 // Create the client window class (don't Create the window, just return a new 
 189 wxMDIClientWindow 
*wxMDIParentFrame::OnCreateClient() 
 191     return new wxMDIClientWindow
; 
 194 WXHICON 
wxMDIParentFrame::GetDefaultIcon() const 
 196     // we don't have any standard icons (any more) 
 200 // --------------------------------------------------------------------------- 
 202 // --------------------------------------------------------------------------- 
 204 void wxMDIParentFrame::Cascade() 
 208 void wxMDIParentFrame::Tile() 
 212 void wxMDIParentFrame::ArrangeIcons() 
 216 void wxMDIParentFrame::ActivateNext() 
 220 void wxMDIParentFrame::ActivatePrevious() 
 224 // --------------------------------------------------------------------------- 
 225 // the MDI parent frame window proc 
 226 // --------------------------------------------------------------------------- 
 228 WXLRESULT 
wxMDIParentFrame::MSWWindowProc(WXUINT message
, 
 235 WXLRESULT 
wxMDIParentFrame::MSWDefWindowProc(WXUINT message
, 
 242 bool wxMDIParentFrame::MSWTranslateMessage(WXMSG
* msg
) 
 247 // =========================================================================== 
 249 // =========================================================================== 
 251 void wxMDIChildFrame::Init() 
 255 bool wxMDIChildFrame::Create(wxMDIParentFrame 
*parent
, 
 257                              const wxString
& title
, 
 261                              const wxString
& name
) 
 266 wxMDIChildFrame::~wxMDIChildFrame() 
 270 // Set the client size (i.e. leave the calculation of borders etc. 
 272 void wxMDIChildFrame::DoSetClientSize(int width
, int height
) 
 276 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const 
 280 void wxMDIChildFrame::InternalSetMenuBar() 
 284 WXHICON 
wxMDIChildFrame::GetDefaultIcon() const 
 286     // we don't have any standard icons (any more) 
 290 // --------------------------------------------------------------------------- 
 292 // --------------------------------------------------------------------------- 
 294 void wxMDIChildFrame::Maximize(bool maximize
) 
 298 void wxMDIChildFrame::Restore() 
 302 void wxMDIChildFrame::Activate() 
 306 // --------------------------------------------------------------------------- 
 307 // MDI window proc and message handlers 
 308 // --------------------------------------------------------------------------- 
 310 WXLRESULT 
wxMDIChildFrame::MSWWindowProc(WXUINT message
, 
 317 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
), 
 324 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
) 
 329 // --------------------------------------------------------------------------- 
 330 // MDI specific message translation/preprocessing 
 331 // --------------------------------------------------------------------------- 
 333 WXLRESULT 
wxMDIChildFrame::MSWDefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
) 
 338 bool wxMDIChildFrame::MSWTranslateMessage(WXMSG
* msg
) 
 343 // --------------------------------------------------------------------------- 
 345 // --------------------------------------------------------------------------- 
 347 void wxMDIChildFrame::MSWDestroyWindow() 
 351 // Change the client window's extended style so we don't get a client edge 
 352 // style when a child is maximised (a double border looks silly.) 
 353 bool wxMDIChildFrame::ResetWindowStyle(void *vrect
) 
 358 // =========================================================================== 
 359 // wxMDIClientWindow: the window of predefined (by Windows) class which 
 360 // contains the child frames 
 361 // =========================================================================== 
 363 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame 
*parent
, long style
) 
 368 // Explicitly call default scroll behaviour 
 369 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
) 
 374 void wxMDIClientWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
) 
 378 void wxMDIChildFrame::OnIdle(wxIdleEvent
& event
) 
 383 // --------------------------------------------------------------------------- 
 384 // non member functions 
 385 // --------------------------------------------------------------------------- 
 387 static void MDISetMenu(wxWindow 
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
) 
 391 static void InsertWindowMenu(wxWindow 
*win
, WXHMENU menu
, HMENU subMenu
) 
 395 static void RemoveWindowMenu(wxWindow 
*win
, WXHMENU menu
) 
 399 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
, 
 400                               WXWORD 
*activate
, WXHWND 
*hwndAct
, WXHWND 
*hwndDeact
)