1///////////////////////////////////////////////////////////////////////////// 2// Name: wx/palmos/mdi.h 3// Purpose: MDI (Multiple Document Interface) classes 4// Author: William Osborne - minimal working wxPalmOS port 5// Modified by: 6// Created: 10/13/04 7// RCS-ID: $Id: mdi.h 41223 2006-09-14 17:36:18Z PC $ 8// Copyright: (c) William Osborne 9// Licence: wxWindows licence 10///////////////////////////////////////////////////////////////////////////// 11 12#ifndef _WX_MDI_H_ 13#define _WX_MDI_H_ 14 15#include "wx/frame.h" 16 17WXDLLEXPORT_DATA(extern const wxChar) wxStatusLineNameStr[]; 18 19class WXDLLEXPORT wxMDIClientWindow; 20class WXDLLEXPORT wxMDIChildFrame; 21 22// --------------------------------------------------------------------------- 23// wxMDIParentFrame 24// --------------------------------------------------------------------------- 25 26class WXDLLEXPORT wxMDIParentFrame : public wxFrame 27{ 28public: 29 wxMDIParentFrame(); 30 wxMDIParentFrame(wxWindow *parent, 31 wxWindowID id, 32 const wxString& title, 33 const wxPoint& pos = wxDefaultPosition, 34 const wxSize& size = wxDefaultSize, 35 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, 36 const wxString& name = wxFrameNameStr) 37 { 38 Create(parent, id, title, pos, size, style, name); 39 } 40 41 virtual ~wxMDIParentFrame(); 42 43 bool Create(wxWindow *parent, 44 wxWindowID id, 45 const wxString& title, 46 const wxPoint& pos = wxDefaultPosition, 47 const wxSize& size = wxDefaultSize, 48 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, 49 const wxString& name = wxFrameNameStr); 50 51 // accessors 52 // --------- 53 54 // Get the active MDI child window (Windows only) 55 wxMDIChildFrame *GetActiveChild() const; 56 57 // Get the client window 58 wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; } 59 60 // Create the client window class (don't Create the window, 61 // just return a new class) 62 virtual wxMDIClientWindow *OnCreateClient(void); 63 64 // MDI windows menu 65 wxMenu* GetWindowMenu() const { return m_windowMenu; }; 66 void SetWindowMenu(wxMenu* menu) ; 67 68 // MDI operations 69 // -------------- 70 virtual void Cascade(); 71 virtual void Tile(); 72 virtual void ArrangeIcons(); 73 virtual void ActivateNext(); 74 virtual void ActivatePrevious(); 75 76 // handlers 77 // -------- 78 79 void OnSize(wxSizeEvent& event); 80 81 // override window proc for MDI-specific message processing 82 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); 83 84 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); 85 virtual bool MSWTranslateMessage(WXMSG* msg); 86 87protected: 88#if wxUSE_MENUS_NATIVE 89 virtual void InternalSetMenuBar(); 90#endif // wxUSE_MENUS_NATIVE 91 92 virtual WXHICON GetDefaultIcon() const; 93 94 wxMDIClientWindow * m_clientWindow; 95 wxMDIChildFrame * m_currentChild; 96 wxMenu* m_windowMenu; 97 98 // true if MDI Frame is intercepting commands, not child 99 bool m_parentFrameActive; 100 101private: 102 friend class WXDLLEXPORT wxMDIChildFrame; 103 104 DECLARE_EVENT_TABLE() 105 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) 106 DECLARE_NO_COPY_CLASS(wxMDIParentFrame) 107}; 108 109// --------------------------------------------------------------------------- 110// wxMDIChildFrame 111// --------------------------------------------------------------------------- 112 113class WXDLLEXPORT wxMDIChildFrame : public wxFrame 114{ 115public: 116 wxMDIChildFrame() { Init(); } 117 wxMDIChildFrame(wxMDIParentFrame *parent, 118 wxWindowID id, 119 const wxString& title, 120 const wxPoint& pos = wxDefaultPosition, 121 const wxSize& size = wxDefaultSize, 122 long style = wxDEFAULT_FRAME_STYLE, 123 const wxString& name = wxFrameNameStr) 124 { 125 Init(); 126 127 Create(parent, id, title, pos, size, style, name); 128 } 129 130 virtual ~wxMDIChildFrame(); 131 132 bool Create(wxMDIParentFrame *parent, 133 wxWindowID id, 134 const wxString& title, 135 const wxPoint& pos = wxDefaultPosition, 136 const wxSize& size = wxDefaultSize, 137 long style = wxDEFAULT_FRAME_STYLE, 138 const wxString& name = wxFrameNameStr); 139 140 virtual bool IsTopLevel() const { return false; } 141 142 // MDI operations 143 virtual void Maximize(bool maximize = true); 144 virtual void Restore(); 145 virtual void Activate(); 146 147 // Implementation only from now on 148 // ------------------------------- 149 150 // Handlers 151 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); 152 bool HandleWindowPosChanging(void *lpPos); 153 154 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); 155 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); 156 virtual bool MSWTranslateMessage(WXMSG *msg); 157 158 virtual void MSWDestroyWindow(); 159 160 bool ResetWindowStyle(void *vrect); 161 162 void OnIdle(wxIdleEvent& event); 163 164protected: 165 virtual void DoGetPosition(int *x, int *y) const; 166 virtual void DoSetClientSize(int width, int height); 167 virtual void InternalSetMenuBar(); 168 virtual bool IsMDIChild() const { return true; } 169 170 virtual WXHICON GetDefaultIcon() const; 171 172 // common part of all ctors 173 void Init(); 174 175private: 176 bool m_needsResize; // flag which tells us to artificially resize the frame 177 178 DECLARE_EVENT_TABLE() 179 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame) 180}; 181 182// --------------------------------------------------------------------------- 183// wxMDIClientWindow 184// --------------------------------------------------------------------------- 185 186class WXDLLEXPORT wxMDIClientWindow : public wxWindow 187{ 188public: 189 wxMDIClientWindow() { Init(); } 190 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) 191 { 192 Init(); 193 194 CreateClient(parent, style); 195 } 196 197 // Note: this is virtual, to allow overridden behaviour. 198 virtual bool CreateClient(wxMDIParentFrame *parent, 199 long style = wxVSCROLL | wxHSCROLL); 200 201 // Explicitly call default scroll behaviour 202 void OnScroll(wxScrollEvent& event); 203 204 virtual void DoSetSize(int x, int y, 205 int width, int height, 206 int sizeFlags = wxSIZE_AUTO); 207protected: 208 void Init() { m_scrollX = m_scrollY = 0; } 209 210 int m_scrollX, m_scrollY; 211 212private: 213 DECLARE_EVENT_TABLE() 214 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) 215}; 216 217#endif 218 // _WX_MDI_H_ 219