frame.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/frame.h
  3. // Purpose: wxFrame class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FRAME_H_
  11. #define _WX_FRAME_H_
  12. class WXDLLIMPEXP_CORE wxFrame : public wxFrameBase
  13. {
  14. public:
  15. // construction
  16. wxFrame() { Init(); }
  17. wxFrame(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,
  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,
  34. const wxString& name = wxFrameNameStr);
  35. virtual ~wxFrame();
  36. // implement base class pure virtuals
  37. virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
  38. // implementation only from now on
  39. // -------------------------------
  40. // event handlers
  41. void OnSysColourChanged(wxSysColourChangedEvent& event);
  42. // Toolbar
  43. #if wxUSE_TOOLBAR
  44. virtual wxToolBar* CreateToolBar(long style = -1,
  45. wxWindowID id = wxID_ANY,
  46. const wxString& name = wxToolBarNameStr);
  47. #endif // wxUSE_TOOLBAR
  48. // Status bar
  49. #if wxUSE_STATUSBAR
  50. virtual wxStatusBar* OnCreateStatusBar(int number = 1,
  51. long style = wxSTB_DEFAULT_STYLE,
  52. wxWindowID id = 0,
  53. const wxString& name = wxStatusLineNameStr);
  54. // Hint to tell framework which status bar to use: the default is to use
  55. // native one for the platforms which support it (Win32), the generic one
  56. // otherwise
  57. // TODO: should this go into a wxFrameworkSettings class perhaps?
  58. static void UseNativeStatusBar(bool useNative)
  59. { m_useNativeStatusBar = useNative; }
  60. static bool UsesNativeStatusBar()
  61. { return m_useNativeStatusBar; }
  62. #endif // wxUSE_STATUSBAR
  63. // event handlers
  64. bool HandleSize(int x, int y, WXUINT flag);
  65. bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
  66. // tooltip management
  67. #if wxUSE_TOOLTIPS
  68. WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
  69. void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
  70. #endif // tooltips
  71. // override the base class function to handle iconized/maximized frames
  72. virtual void SendSizeEvent(int flags = 0);
  73. virtual wxPoint GetClientAreaOrigin() const;
  74. // override base class version to add menu bar accel processing
  75. virtual bool MSWTranslateMessage(WXMSG *msg)
  76. {
  77. return MSWDoTranslateMessage(this, msg);
  78. }
  79. // window proc for the frames
  80. virtual WXLRESULT MSWWindowProc(WXUINT message,
  81. WXWPARAM wParam,
  82. WXLPARAM lParam);
  83. #if wxUSE_MENUS
  84. // get the currently active menu: this is the same as the frame menu for
  85. // normal frames but is overridden by wxMDIParentFrame
  86. virtual WXHMENU MSWGetActiveMenu() const { return m_hMenu; }
  87. // Look up the menu in the menu bar.
  88. virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu);
  89. #endif // wxUSE_MENUS
  90. protected:
  91. // common part of all ctors
  92. void Init();
  93. // override base class virtuals
  94. virtual void DoGetClientSize(int *width, int *height) const;
  95. virtual void DoSetClientSize(int width, int height);
  96. #if wxUSE_MENUS_NATIVE
  97. // perform MSW-specific action when menubar is changed
  98. virtual void AttachMenuBar(wxMenuBar *menubar);
  99. // a plug in for MDI frame classes which need to do something special when
  100. // the menubar is set
  101. virtual void InternalSetMenuBar();
  102. #endif // wxUSE_MENUS_NATIVE
  103. // propagate our state change to all child frames
  104. void IconizeChildFrames(bool bIconize);
  105. // the real implementation of MSWTranslateMessage(), also used by
  106. // wxMDIChildFrame
  107. bool MSWDoTranslateMessage(wxFrame *frame, WXMSG *msg);
  108. virtual bool IsMDIChild() const { return false; }
  109. // get default (wxWidgets) icon for the frame
  110. virtual WXHICON GetDefaultIcon() const;
  111. #if wxUSE_TOOLBAR
  112. virtual void PositionToolBar();
  113. #endif // wxUSE_TOOLBAR
  114. #if wxUSE_STATUSBAR
  115. virtual void PositionStatusBar();
  116. static bool m_useNativeStatusBar;
  117. #endif // wxUSE_STATUSBAR
  118. #if wxUSE_MENUS
  119. // frame menu, NULL if none
  120. WXHMENU m_hMenu;
  121. #endif // wxUSE_MENUS
  122. private:
  123. #if wxUSE_TOOLTIPS
  124. WXHWND m_hwndToolTip;
  125. #endif // tooltips
  126. // used by IconizeChildFrames(), see comments there
  127. bool m_wasMinimized;
  128. DECLARE_EVENT_TABLE()
  129. DECLARE_DYNAMIC_CLASS_NO_COPY(wxFrame)
  130. };
  131. #endif
  132. // _WX_FRAME_H_