| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: wx/msw/mdi.h |
| 3 | // Purpose: MDI (Multiple Document Interface) classes |
| 4 | // Author: Julian Smart |
| 5 | // Modified by: |
| 6 | // Created: 01/02/97 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Julian Smart |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef _WX_MDI_H_ |
| 13 | #define _WX_MDI_H_ |
| 14 | |
| 15 | #include "wx/frame.h" |
| 16 | |
| 17 | extern WXDLLEXPORT_DATA(const wxChar) wxStatusLineNameStr[]; |
| 18 | |
| 19 | class WXDLLEXPORT wxMDIClientWindow; |
| 20 | class WXDLLEXPORT wxMDIChildFrame; |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | // wxMDIParentFrame |
| 24 | // --------------------------------------------------------------------------- |
| 25 | |
| 26 | class WXDLLEXPORT wxMDIParentFrame : public wxFrame |
| 27 | { |
| 28 | public: |
| 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 | virtual void DoMenuUpdates(wxMenu* menu = NULL); |
| 68 | |
| 69 | // MDI operations |
| 70 | // -------------- |
| 71 | virtual void Cascade(); |
| 72 | virtual void Tile(wxOrientation orient = wxHORIZONTAL); |
| 73 | virtual void ArrangeIcons(); |
| 74 | virtual void ActivateNext(); |
| 75 | virtual void ActivatePrevious(); |
| 76 | |
| 77 | // handlers |
| 78 | // -------- |
| 79 | |
| 80 | // Responds to colour changes |
| 81 | void OnSysColourChanged(wxSysColourChangedEvent& event); |
| 82 | |
| 83 | void OnSize(wxSizeEvent& event); |
| 84 | void OnIconized(wxIconizeEvent& event); |
| 85 | |
| 86 | bool HandleActivate(int state, bool minimized, WXHWND activate); |
| 87 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); |
| 88 | |
| 89 | // override window proc for MDI-specific message processing |
| 90 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
| 91 | |
| 92 | virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM); |
| 93 | virtual bool MSWTranslateMessage(WXMSG* msg); |
| 94 | |
| 95 | protected: |
| 96 | #if wxUSE_MENUS_NATIVE |
| 97 | virtual void InternalSetMenuBar(); |
| 98 | #endif // wxUSE_MENUS_NATIVE |
| 99 | |
| 100 | virtual WXHICON GetDefaultIcon() const; |
| 101 | |
| 102 | // set the size of the MDI client window to match the frame size |
| 103 | void UpdateClientSize(); |
| 104 | |
| 105 | |
| 106 | wxMDIClientWindow * m_clientWindow; |
| 107 | wxMDIChildFrame * m_currentChild; |
| 108 | wxMenu* m_windowMenu; |
| 109 | |
| 110 | // true if MDI Frame is intercepting commands, not child |
| 111 | bool m_parentFrameActive; |
| 112 | |
| 113 | private: |
| 114 | friend class WXDLLEXPORT wxMDIChildFrame; |
| 115 | |
| 116 | DECLARE_EVENT_TABLE() |
| 117 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) |
| 118 | DECLARE_NO_COPY_CLASS(wxMDIParentFrame) |
| 119 | }; |
| 120 | |
| 121 | // --------------------------------------------------------------------------- |
| 122 | // wxMDIChildFrame |
| 123 | // --------------------------------------------------------------------------- |
| 124 | |
| 125 | class WXDLLEXPORT wxMDIChildFrame : public wxFrame |
| 126 | { |
| 127 | public: |
| 128 | wxMDIChildFrame() { Init(); } |
| 129 | wxMDIChildFrame(wxMDIParentFrame *parent, |
| 130 | wxWindowID id, |
| 131 | const wxString& title, |
| 132 | const wxPoint& pos = wxDefaultPosition, |
| 133 | const wxSize& size = wxDefaultSize, |
| 134 | long style = wxDEFAULT_FRAME_STYLE, |
| 135 | const wxString& name = wxFrameNameStr) |
| 136 | { |
| 137 | Init(); |
| 138 | |
| 139 | Create(parent, id, title, pos, size, style, name); |
| 140 | } |
| 141 | |
| 142 | virtual ~wxMDIChildFrame(); |
| 143 | |
| 144 | bool Create(wxMDIParentFrame *parent, |
| 145 | wxWindowID id, |
| 146 | const wxString& title, |
| 147 | const wxPoint& pos = wxDefaultPosition, |
| 148 | const wxSize& size = wxDefaultSize, |
| 149 | long style = wxDEFAULT_FRAME_STYLE, |
| 150 | const wxString& name = wxFrameNameStr); |
| 151 | |
| 152 | virtual bool IsTopLevel() const { return false; } |
| 153 | |
| 154 | // MDI operations |
| 155 | virtual void Maximize(bool maximize = true); |
| 156 | virtual void Restore(); |
| 157 | virtual void Activate(); |
| 158 | |
| 159 | // Implementation only from now on |
| 160 | // ------------------------------- |
| 161 | |
| 162 | // Handlers |
| 163 | bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); |
| 164 | bool HandleWindowPosChanging(void *lpPos); |
| 165 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); |
| 166 | bool HandleGetMinMaxInfo(void *mmInfo); |
| 167 | |
| 168 | virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
| 169 | virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
| 170 | virtual bool MSWTranslateMessage(WXMSG *msg); |
| 171 | |
| 172 | virtual void MSWDestroyWindow(); |
| 173 | |
| 174 | bool ResetWindowStyle(void *vrect); |
| 175 | |
| 176 | void OnIdle(wxIdleEvent& event); |
| 177 | |
| 178 | virtual bool Show(bool show = true); |
| 179 | |
| 180 | protected: |
| 181 | virtual void DoGetScreenPosition(int *x, int *y) const; |
| 182 | virtual void DoGetPosition(int *x, int *y) const; |
| 183 | virtual void DoSetClientSize(int width, int height); |
| 184 | virtual void InternalSetMenuBar(); |
| 185 | virtual bool IsMDIChild() const { return true; } |
| 186 | virtual void DetachMenuBar(); |
| 187 | |
| 188 | virtual WXHICON GetDefaultIcon() const; |
| 189 | |
| 190 | // common part of all ctors |
| 191 | void Init(); |
| 192 | |
| 193 | private: |
| 194 | bool m_needsInitialShow; // Show must be called in idle time after Creation |
| 195 | bool m_needsResize; // flag which tells us to artificially resize the frame |
| 196 | |
| 197 | DECLARE_EVENT_TABLE() |
| 198 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame) |
| 199 | }; |
| 200 | |
| 201 | // --------------------------------------------------------------------------- |
| 202 | // wxMDIClientWindow |
| 203 | // --------------------------------------------------------------------------- |
| 204 | |
| 205 | class WXDLLEXPORT wxMDIClientWindow : public wxWindow |
| 206 | { |
| 207 | public: |
| 208 | wxMDIClientWindow() { Init(); } |
| 209 | wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) |
| 210 | { |
| 211 | Init(); |
| 212 | |
| 213 | CreateClient(parent, style); |
| 214 | } |
| 215 | |
| 216 | // Note: this is virtual, to allow overridden behaviour. |
| 217 | virtual bool CreateClient(wxMDIParentFrame *parent, |
| 218 | long style = wxVSCROLL | wxHSCROLL); |
| 219 | |
| 220 | // Explicitly call default scroll behaviour |
| 221 | void OnScroll(wxScrollEvent& event); |
| 222 | |
| 223 | protected: |
| 224 | virtual void DoSetSize(int x, int y, |
| 225 | int width, int height, |
| 226 | int sizeFlags = wxSIZE_AUTO); |
| 227 | |
| 228 | void Init() { m_scrollX = m_scrollY = 0; } |
| 229 | |
| 230 | int m_scrollX, m_scrollY; |
| 231 | |
| 232 | private: |
| 233 | DECLARE_EVENT_TABLE() |
| 234 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow) |
| 235 | }; |
| 236 | |
| 237 | #endif |
| 238 | // _WX_MDI_H_ |