mdi.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/os2/mdi.h
  3. // Purpose: MDI (Multiple Document Interface) classes.
  4. // This doesn't have to be implemented just like Windows,
  5. // it could be a tabbed design as in wxGTK.
  6. // Author: David Webster
  7. // Modified by:
  8. // Created: 10/10/99
  9. // Copyright: (c) David Webster
  10. // Licence: wxWindows licence
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef _WX_MDI_H_
  13. #define _WX_MDI_H_
  14. #include "wx/frame.h"
  15. class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow;
  16. class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
  17. class WXDLLIMPEXP_CORE wxMDIParentFrame: public wxFrame
  18. {
  19. DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
  20. friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
  21. public:
  22. wxMDIParentFrame();
  23. inline wxMDIParentFrame(wxWindow *parent,
  24. wxWindowID id,
  25. const wxString& title,
  26. const wxPoint& pos = wxDefaultPosition,
  27. const wxSize& size = wxDefaultSize,
  28. long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window
  29. const wxString& name = wxFrameNameStr)
  30. {
  31. Create(parent, id, title, pos, size, style, name);
  32. }
  33. virtual ~wxMDIParentFrame();
  34. bool Create(wxWindow *parent,
  35. wxWindowID id,
  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. // accessors
  42. // ---------
  43. // Get the active MDI child window (Windows only)
  44. wxMDIChildFrame *GetActiveChild() const;
  45. // Get the client window
  46. wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
  47. // Create the client window class (don't Create the window,
  48. // just return a new class)
  49. virtual wxMDIClientWindow *OnCreateClient(void);
  50. wxMenu* GetWindowMenu() const { return m_windowMenu; }
  51. // void SetWindowMenu(wxMwnu* pMenu);
  52. // MDI operations
  53. // --------------
  54. virtual void Cascade();
  55. virtual void Tile();
  56. virtual void ArrangeIcons();
  57. virtual void ActivateNext();
  58. virtual void ActivatePrevious();
  59. // handlers
  60. // --------
  61. // Responds to colour changes
  62. void OnSysColourChanged(wxSysColourChangedEvent& event);
  63. void OnSize(wxSizeEvent& event);
  64. bool HandleActivate(int state, bool minimized, WXHWND activate);
  65. bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
  66. // override window proc for MDI-specific message processing
  67. virtual MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
  68. virtual MRESULT OS2DefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
  69. virtual bool OS2TranslateMessage(WXMSG* msg);
  70. protected:
  71. virtual void InternalSetMenuBar();
  72. wxMDIClientWindow * m_clientWindow;
  73. wxMDIChildFrame * m_currentChild;
  74. wxMenu* m_windowMenu;
  75. // TRUE if MDI Frame is intercepting commands, not child
  76. bool m_parentFrameActive;
  77. private:
  78. DECLARE_EVENT_TABLE()
  79. };
  80. class WXDLLIMPEXP_CORE wxMDIChildFrame: public wxFrame
  81. {
  82. DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
  83. public:
  84. wxMDIChildFrame();
  85. inline wxMDIChildFrame(wxMDIParentFrame *parent,
  86. wxWindowID id,
  87. const wxString& title,
  88. const wxPoint& pos = wxDefaultPosition,
  89. const wxSize& size = wxDefaultSize,
  90. long style = wxDEFAULT_FRAME_STYLE,
  91. const wxString& name = wxFrameNameStr)
  92. {
  93. Create(parent, id, title, pos, size, style, name);
  94. }
  95. virtual ~wxMDIChildFrame();
  96. bool Create(wxMDIParentFrame *parent,
  97. wxWindowID id,
  98. const wxString& title,
  99. const wxPoint& pos = wxDefaultPosition,
  100. const wxSize& size = wxDefaultSize,
  101. long style = wxDEFAULT_FRAME_STYLE,
  102. const wxString& name = wxFrameNameStr);
  103. // MDI operations
  104. virtual void Maximize(bool maximize = TRUE);
  105. virtual void Restore();
  106. virtual void Activate();
  107. // Handlers
  108. bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
  109. bool HandleSize(int x, int y, WXUINT);
  110. bool HandleWindowPosChanging(void *lpPos);
  111. bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
  112. virtual MRESULT OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
  113. virtual MRESULT OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
  114. virtual bool OS2TranslateMessage(WXMSG *msg);
  115. virtual void OS2DestroyWindow();
  116. // Implementation
  117. bool ResetWindowStyle(void *vrect);
  118. protected:
  119. virtual void DoGetPosition(int *x, int *y) const;
  120. virtual void DoSetClientSize(int width, int height);
  121. virtual void InternalSetMenuBar();
  122. };
  123. /* The client window is a child of the parent MDI frame, and itself
  124. * contains the child MDI frames.
  125. * However, you create the MDI children as children of the MDI parent:
  126. * only in the implementation does the client window become the parent
  127. * of the children. Phew! So the children are sort of 'adopted'...
  128. */
  129. class WXDLLIMPEXP_CORE wxMDIClientWindow: public wxWindow
  130. {
  131. DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
  132. public:
  133. wxMDIClientWindow() { Init(); }
  134. wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
  135. {
  136. Init();
  137. CreateClient(parent, style);
  138. }
  139. // Note: this is virtual, to allow overridden behaviour.
  140. virtual bool CreateClient(wxMDIParentFrame *parent,
  141. long style = wxVSCROLL | wxHSCROLL);
  142. // Explicitly call default scroll behaviour
  143. void OnScroll(wxScrollEvent& event);
  144. protected:
  145. void Init() { m_scrollX = m_scrollY = 0; }
  146. int m_scrollX, m_scrollY;
  147. private:
  148. DECLARE_EVENT_TABLE()
  149. };
  150. #endif
  151. // _WX_MDI_H_