tabmdi.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/aui/tabmdi.h
  3. // Purpose: Generic MDI (Multiple Document Interface) classes
  4. // Author: Hans Van Leemputten
  5. // Modified by: Benjamin I. Williams / Kirix Corporation
  6. // Created: 29/07/2002
  7. // Copyright: (c) Hans Van Leemputten
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_AUITABMDI_H_
  11. #define _WX_AUITABMDI_H_
  12. #if wxUSE_AUI
  13. // ----------------------------------------------------------------------------
  14. // headers
  15. // ----------------------------------------------------------------------------
  16. #include "wx/frame.h"
  17. #include "wx/panel.h"
  18. #include "wx/notebook.h"
  19. #include "wx/icon.h"
  20. #include "wx/aui/auibook.h"
  21. //-----------------------------------------------------------------------------
  22. // classes
  23. //-----------------------------------------------------------------------------
  24. class WXDLLIMPEXP_FWD_AUI wxAuiMDIParentFrame;
  25. class WXDLLIMPEXP_FWD_AUI wxAuiMDIClientWindow;
  26. class WXDLLIMPEXP_FWD_AUI wxAuiMDIChildFrame;
  27. //-----------------------------------------------------------------------------
  28. // wxAuiMDIParentFrame
  29. //-----------------------------------------------------------------------------
  30. class WXDLLIMPEXP_AUI wxAuiMDIParentFrame : public wxFrame
  31. {
  32. public:
  33. wxAuiMDIParentFrame();
  34. wxAuiMDIParentFrame(wxWindow *parent,
  35. wxWindowID winid,
  36. const wxString& title,
  37. const wxPoint& pos = wxDefaultPosition,
  38. const wxSize& size = wxDefaultSize,
  39. long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
  40. const wxString& name = wxFrameNameStr);
  41. ~wxAuiMDIParentFrame();
  42. bool Create(wxWindow *parent,
  43. wxWindowID winid,
  44. const wxString& title,
  45. const wxPoint& pos = wxDefaultPosition,
  46. const wxSize& size = wxDefaultSize,
  47. long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
  48. const wxString& name = wxFrameNameStr );
  49. void SetArtProvider(wxAuiTabArt* provider);
  50. wxAuiTabArt* GetArtProvider();
  51. wxAuiNotebook* GetNotebook() const;
  52. #if wxUSE_MENUS
  53. wxMenu* GetWindowMenu() const { return m_pWindowMenu; }
  54. void SetWindowMenu(wxMenu* pMenu);
  55. virtual void SetMenuBar(wxMenuBar *pMenuBar);
  56. #endif // wxUSE_MENUS
  57. void SetChildMenuBar(wxAuiMDIChildFrame *pChild);
  58. wxAuiMDIChildFrame *GetActiveChild() const;
  59. void SetActiveChild(wxAuiMDIChildFrame* pChildFrame);
  60. wxAuiMDIClientWindow *GetClientWindow() const;
  61. virtual wxAuiMDIClientWindow *OnCreateClient();
  62. virtual void Cascade() { /* Has no effect */ }
  63. virtual void Tile(wxOrientation orient = wxHORIZONTAL);
  64. virtual void ArrangeIcons() { /* Has no effect */ }
  65. virtual void ActivateNext();
  66. virtual void ActivatePrevious();
  67. protected:
  68. wxAuiMDIClientWindow* m_pClientWindow;
  69. wxEvent* m_pLastEvt;
  70. #if wxUSE_MENUS
  71. wxMenu *m_pWindowMenu;
  72. wxMenuBar *m_pMyMenuBar;
  73. #endif // wxUSE_MENUS
  74. protected:
  75. void Init();
  76. #if wxUSE_MENUS
  77. void RemoveWindowMenu(wxMenuBar *pMenuBar);
  78. void AddWindowMenu(wxMenuBar *pMenuBar);
  79. void DoHandleMenu(wxCommandEvent &event);
  80. void DoHandleUpdateUI(wxUpdateUIEvent &event);
  81. #endif // wxUSE_MENUS
  82. virtual bool ProcessEvent(wxEvent& event);
  83. virtual void DoGetClientSize(int *width, int *height) const;
  84. private:
  85. DECLARE_EVENT_TABLE()
  86. DECLARE_DYNAMIC_CLASS(wxAuiMDIParentFrame)
  87. };
  88. //-----------------------------------------------------------------------------
  89. // wxAuiMDIChildFrame
  90. //-----------------------------------------------------------------------------
  91. class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxPanel
  92. {
  93. public:
  94. wxAuiMDIChildFrame();
  95. wxAuiMDIChildFrame(wxAuiMDIParentFrame *parent,
  96. wxWindowID winid,
  97. const wxString& title,
  98. const wxPoint& pos = wxDefaultPosition,
  99. const wxSize& size = wxDefaultSize,
  100. long style = wxDEFAULT_FRAME_STYLE,
  101. const wxString& name = wxFrameNameStr);
  102. virtual ~wxAuiMDIChildFrame();
  103. bool Create(wxAuiMDIParentFrame *parent,
  104. wxWindowID winid,
  105. const wxString& title,
  106. const wxPoint& pos = wxDefaultPosition,
  107. const wxSize& size = wxDefaultSize,
  108. long style = wxDEFAULT_FRAME_STYLE,
  109. const wxString& name = wxFrameNameStr);
  110. #if wxUSE_MENUS
  111. virtual void SetMenuBar(wxMenuBar *menuBar);
  112. virtual wxMenuBar *GetMenuBar() const;
  113. #endif // wxUSE_MENUS
  114. virtual void SetTitle(const wxString& title);
  115. virtual wxString GetTitle() const;
  116. virtual void SetIcons(const wxIconBundle& icons);
  117. virtual const wxIconBundle& GetIcons() const;
  118. virtual void SetIcon(const wxIcon& icon);
  119. virtual const wxIcon& GetIcon() const;
  120. virtual void Activate();
  121. virtual bool Destroy();
  122. virtual bool Show(bool show = true);
  123. #if wxUSE_STATUSBAR
  124. // no status bars
  125. virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1,
  126. long WXUNUSED(style) = 1,
  127. wxWindowID WXUNUSED(winid) = 1,
  128. const wxString& WXUNUSED(name) = wxEmptyString)
  129. { return NULL; }
  130. virtual wxStatusBar *GetStatusBar() const { return NULL; }
  131. virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {}
  132. virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {}
  133. #endif
  134. #if wxUSE_TOOLBAR
  135. // no toolbar bars
  136. virtual wxToolBar* CreateToolBar(long WXUNUSED(style),
  137. wxWindowID WXUNUSED(winid),
  138. const wxString& WXUNUSED(name))
  139. { return NULL; }
  140. virtual wxToolBar *GetToolBar() const { return NULL; }
  141. #endif
  142. // no maximize etc
  143. virtual void Maximize(bool WXUNUSED(maximize) = true) { /* Has no effect */ }
  144. virtual void Restore() { /* Has no effect */ }
  145. virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ }
  146. virtual bool IsMaximized() const { return true; }
  147. virtual bool IsIconized() const { return false; }
  148. virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; }
  149. virtual bool IsFullScreen() const { return false; }
  150. virtual bool IsTopLevel() const { return false; }
  151. void OnMenuHighlight(wxMenuEvent& evt);
  152. void OnActivate(wxActivateEvent& evt);
  153. void OnCloseWindow(wxCloseEvent& evt);
  154. void SetMDIParentFrame(wxAuiMDIParentFrame* parent);
  155. wxAuiMDIParentFrame* GetMDIParentFrame() const;
  156. protected:
  157. void Init();
  158. virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
  159. virtual void DoMoveWindow(int x, int y, int width, int height);
  160. // no size hints
  161. virtual void DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH),
  162. int WXUNUSED(maxW), int WXUNUSED(maxH),
  163. int WXUNUSED(incW), int WXUNUSED(incH)) {}
  164. public:
  165. // This function needs to be called when a size change is confirmed,
  166. // we needed this function to prevent anybody from the outside
  167. // changing the panel... it messes the UI layout when we would allow it.
  168. void ApplyMDIChildFrameRect();
  169. void DoShow(bool show);
  170. protected:
  171. wxAuiMDIParentFrame* m_pMDIParentFrame;
  172. wxRect m_mdiNewRect;
  173. wxRect m_mdiCurRect;
  174. wxString m_title;
  175. wxIcon m_icon;
  176. wxIconBundle m_iconBundle;
  177. bool m_activateOnCreate;
  178. #if wxUSE_MENUS
  179. wxMenuBar* m_pMenuBar;
  180. #endif // wxUSE_MENUS
  181. private:
  182. DECLARE_DYNAMIC_CLASS(wxAuiMDIChildFrame)
  183. DECLARE_EVENT_TABLE()
  184. friend class wxAuiMDIClientWindow;
  185. };
  186. //-----------------------------------------------------------------------------
  187. // wxAuiMDIClientWindow
  188. //-----------------------------------------------------------------------------
  189. class WXDLLIMPEXP_AUI wxAuiMDIClientWindow : public wxAuiNotebook
  190. {
  191. public:
  192. wxAuiMDIClientWindow();
  193. wxAuiMDIClientWindow(wxAuiMDIParentFrame *parent, long style = 0);
  194. virtual bool CreateClient(wxAuiMDIParentFrame *parent,
  195. long style = wxVSCROLL | wxHSCROLL);
  196. virtual int SetSelection(size_t page);
  197. virtual wxAuiMDIChildFrame* GetActiveChild();
  198. virtual void SetActiveChild(wxAuiMDIChildFrame* pChildFrame)
  199. {
  200. SetSelection(GetPageIndex(pChildFrame));
  201. }
  202. protected:
  203. void PageChanged(int oldSelection, int newSelection);
  204. void OnPageClose(wxAuiNotebookEvent& evt);
  205. void OnPageChanged(wxAuiNotebookEvent& evt);
  206. void OnSize(wxSizeEvent& evt);
  207. private:
  208. DECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow)
  209. DECLARE_EVENT_TABLE()
  210. };
  211. #endif // wxUSE_AUI
  212. #endif // _WX_AUITABMDI_H_