mdi.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/mdi.h
  3. // Purpose: wxMDIParentFrame, wxMDIChildFrame, wxMDIClientWindow
  4. // Author: David Elliott
  5. // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
  6. // Created: 2003/09/08
  7. // Copyright: (c) 2003 David Elliott
  8. // (c) 2008 Vadim Zeitlin
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef __WX_COCOA_MDI_H__
  12. #define __WX_COCOA_MDI_H__
  13. #include "wx/frame.h"
  14. DECLARE_WXCOCOA_OBJC_CLASS(wxMDIParentFrameObserver);
  15. class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
  16. class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow;
  17. WX_DECLARE_EXPORTED_LIST(wxMDIChildFrame, wxCocoaMDIChildFrameList);
  18. // ========================================================================
  19. // wxMDIParentFrame
  20. // ========================================================================
  21. class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase
  22. {
  23. friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
  24. DECLARE_EVENT_TABLE()
  25. DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
  26. // ------------------------------------------------------------------------
  27. // initialization
  28. // ------------------------------------------------------------------------
  29. public:
  30. wxMDIParentFrame() { Init(); }
  31. wxMDIParentFrame(wxWindow *parent,
  32. wxWindowID winid,
  33. const wxString& title,
  34. const wxPoint& pos = wxDefaultPosition,
  35. const wxSize& size = wxDefaultSize,
  36. long style = wxDEFAULT_FRAME_STYLE,
  37. const wxString& name = wxFrameNameStr)
  38. {
  39. Init();
  40. Create(parent, winid, title, pos, size, style, name);
  41. }
  42. virtual ~wxMDIParentFrame();
  43. bool Create(wxWindow *parent,
  44. wxWindowID winid,
  45. const wxString& title,
  46. const wxPoint& pos = wxDefaultPosition,
  47. const wxSize& size = wxDefaultSize,
  48. long style = wxDEFAULT_FRAME_STYLE,
  49. const wxString& name = wxFrameNameStr);
  50. protected:
  51. void Init();
  52. // ------------------------------------------------------------------------
  53. // Cocoa specifics
  54. // ------------------------------------------------------------------------
  55. public:
  56. void WindowDidBecomeMain(NSNotification *notification);
  57. protected:
  58. virtual void CocoaDelegate_windowDidBecomeKey(void);
  59. virtual void CocoaDelegate_windowDidResignKey(void);
  60. virtual bool Cocoa_canBecomeMainWindow(bool &canBecome);
  61. virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
  62. void AddMDIChild(wxMDIChildFrame *child);
  63. void RemoveMDIChild(wxMDIChildFrame *child);
  64. wxMDIParentFrameObserver *m_observer;
  65. // ------------------------------------------------------------------------
  66. // Implementation
  67. // ------------------------------------------------------------------------
  68. public:
  69. void SetActiveChild(wxMDIChildFrame *child);
  70. // implement base class pure virtuals
  71. // ----------------------------------
  72. static bool IsTDI() { return false; }
  73. virtual void ActivateNext() { /* TODO */ }
  74. virtual void ActivatePrevious() { /* TODO */ }
  75. protected:
  76. wxMDIClientWindow *m_clientWindow;
  77. wxMDIChildFrame *m_currentChild;
  78. wxCocoaMDIChildFrameList m_mdiChildren;
  79. };
  80. // ========================================================================
  81. // wxMDIChildFrame
  82. // ========================================================================
  83. class WXDLLIMPEXP_CORE wxMDIChildFrame: public wxFrame
  84. {
  85. friend class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame;
  86. DECLARE_EVENT_TABLE()
  87. DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
  88. // ------------------------------------------------------------------------
  89. // initialization
  90. // ------------------------------------------------------------------------
  91. public:
  92. wxMDIChildFrame() { Init(); }
  93. wxMDIChildFrame(wxMDIParentFrame *parent,
  94. wxWindowID winid,
  95. const wxString& title,
  96. const wxPoint& pos = wxDefaultPosition,
  97. const wxSize& size = wxDefaultSize,
  98. long style = wxDEFAULT_FRAME_STYLE,
  99. const wxString& name = wxFrameNameStr)
  100. {
  101. Init();
  102. Create(parent, winid, title, pos, size, style, name);
  103. }
  104. virtual ~wxMDIChildFrame();
  105. bool Create(wxMDIParentFrame *parent,
  106. wxWindowID winid,
  107. const wxString& title,
  108. const wxPoint& pos = wxDefaultPosition,
  109. const wxSize& size = wxDefaultSize,
  110. long style = wxDEFAULT_FRAME_STYLE,
  111. const wxString& name = wxFrameNameStr);
  112. protected:
  113. void Init();
  114. // ------------------------------------------------------------------------
  115. // Cocoa specifics
  116. // ------------------------------------------------------------------------
  117. public:
  118. protected:
  119. virtual void CocoaDelegate_windowDidBecomeKey(void);
  120. virtual void CocoaDelegate_windowDidBecomeMain(void);
  121. virtual void CocoaDelegate_windowDidResignKey(void);
  122. // ------------------------------------------------------------------------
  123. // Implementation
  124. // ------------------------------------------------------------------------
  125. public:
  126. virtual void Activate();
  127. virtual bool Destroy();
  128. protected:
  129. wxMDIParentFrame *m_mdiParent;
  130. };
  131. // ========================================================================
  132. // wxMDIClientWindow
  133. // ========================================================================
  134. class wxMDIClientWindow : public wxMDIClientWindowBase
  135. {
  136. public:
  137. wxMDIClientWindow() { }
  138. virtual bool CreateClient(wxMDIParentFrame *parent,
  139. long style = wxHSCROLL | wxVSCROLL);
  140. DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
  141. };
  142. #endif // __WX_COCOA_MDI_H__