mdi.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/mdi.h
  3. // Purpose: MDI (Multiple Document Interface) classes.
  4. // Author: Stefan Csomor
  5. // Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // (c) 2008 Vadim Zeitlin
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_OSX_CARBON_MDI_H_
  12. #define _WX_OSX_CARBON_MDI_H_
  13. class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase
  14. {
  15. public:
  16. wxMDIParentFrame() { Init(); }
  17. wxMDIParentFrame(wxWindow *parent,
  18. wxWindowID id,
  19. const wxString& title,
  20. const wxPoint& pos = wxDefaultPosition,
  21. const wxSize& size = wxDefaultSize,
  22. long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
  23. const wxString& name = wxFrameNameStr)
  24. {
  25. Init();
  26. Create(parent, id, title, pos, size, style, name);
  27. }
  28. bool Create(wxWindow *parent,
  29. wxWindowID id,
  30. const wxString& title,
  31. const wxPoint& pos = wxDefaultPosition,
  32. const wxSize& size = wxDefaultSize,
  33. long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
  34. const wxString& name = wxFrameNameStr);
  35. virtual ~wxMDIParentFrame();
  36. // implement/override base class [pure] virtuals
  37. // ---------------------------------------------
  38. static bool IsTDI() { return false; }
  39. virtual void AddChild(wxWindowBase *child);
  40. virtual void RemoveChild(wxWindowBase *child);
  41. virtual void ActivateNext() { /* TODO */ }
  42. virtual void ActivatePrevious() { /* TODO */ }
  43. virtual bool Show(bool show = true);
  44. // Mac-specific implementation from now on
  45. // ---------------------------------------
  46. // Mac OS activate event
  47. virtual void MacActivate(long timestamp, bool activating);
  48. // wxWidgets activate event
  49. void OnActivate(wxActivateEvent& event);
  50. void OnSysColourChanged(wxSysColourChangedEvent& event);
  51. void SetMenuBar(wxMenuBar *menu_bar);
  52. // Get rect to be used to center top-level children
  53. virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
  54. protected:
  55. // common part of all ctors
  56. void Init();
  57. // returns true if this frame has some contents and so should be visible,
  58. // false if it's used solely as container for its children
  59. bool ShouldBeVisible() const;
  60. wxMenu *m_windowMenu;
  61. // true if MDI Frame is intercepting commands, not child
  62. bool m_parentFrameActive;
  63. // true if the frame should be shown but is not because it is empty and
  64. // useless otherwise than a container for its children
  65. bool m_shouldBeShown;
  66. private:
  67. friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
  68. DECLARE_EVENT_TABLE()
  69. DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
  70. };
  71. class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase
  72. {
  73. public:
  74. wxMDIChildFrame() { Init(); }
  75. wxMDIChildFrame(wxMDIParentFrame *parent,
  76. wxWindowID id,
  77. const wxString& title,
  78. const wxPoint& pos = wxDefaultPosition,
  79. const wxSize& size = wxDefaultSize,
  80. long style = wxDEFAULT_FRAME_STYLE,
  81. const wxString& name = wxFrameNameStr)
  82. {
  83. Init() ;
  84. Create(parent, id, title, pos, size, style, name);
  85. }
  86. bool Create(wxMDIParentFrame *parent,
  87. wxWindowID id,
  88. const wxString& title,
  89. const wxPoint& pos = wxDefaultPosition,
  90. const wxSize& size = wxDefaultSize,
  91. long style = wxDEFAULT_FRAME_STYLE,
  92. const wxString& name = wxFrameNameStr);
  93. virtual ~wxMDIChildFrame();
  94. // un-override the base class override
  95. virtual bool IsTopLevel() const { return true; }
  96. // implement MDI operations
  97. virtual void Activate();
  98. // Mac OS activate event
  99. virtual void MacActivate(long timestamp, bool activating);
  100. protected:
  101. // common part of all ctors
  102. void Init();
  103. DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
  104. };
  105. class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
  106. {
  107. public:
  108. wxMDIClientWindow() { }
  109. virtual ~wxMDIClientWindow();
  110. virtual bool CreateClient(wxMDIParentFrame *parent,
  111. long style = wxVSCROLL | wxHSCROLL);
  112. protected:
  113. virtual void DoGetClientSize(int *width, int *height) const;
  114. DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
  115. };
  116. #endif // _WX_OSX_CARBON_MDI_H_