toplevel.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/univ/toplevel.h
  3. // Purpose: Top level window, abstraction of wxFrame and wxDialog
  4. // Author: Vaclav Slavik
  5. // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef __WX_UNIV_TOPLEVEL_H__
  9. #define __WX_UNIV_TOPLEVEL_H__
  10. #include "wx/univ/inpcons.h"
  11. #include "wx/univ/inphand.h"
  12. #include "wx/icon.h"
  13. // ----------------------------------------------------------------------------
  14. // constants
  15. // ----------------------------------------------------------------------------
  16. // frame decorations type flags used in wxRenderer and wxColourScheme
  17. enum
  18. {
  19. wxTOPLEVEL_ACTIVE = 0x00000001,
  20. wxTOPLEVEL_MAXIMIZED = 0x00000002,
  21. wxTOPLEVEL_TITLEBAR = 0x00000004,
  22. wxTOPLEVEL_ICON = 0x00000008,
  23. wxTOPLEVEL_RESIZEABLE = 0x00000010,
  24. wxTOPLEVEL_BORDER = 0x00000020,
  25. wxTOPLEVEL_BUTTON_CLOSE = 0x01000000,
  26. wxTOPLEVEL_BUTTON_MAXIMIZE = 0x02000000,
  27. wxTOPLEVEL_BUTTON_ICONIZE = 0x04000000,
  28. wxTOPLEVEL_BUTTON_RESTORE = 0x08000000,
  29. wxTOPLEVEL_BUTTON_HELP = 0x10000000
  30. };
  31. // frame hit test return values:
  32. enum
  33. {
  34. wxHT_TOPLEVEL_NOWHERE = 0x00000000,
  35. wxHT_TOPLEVEL_CLIENT_AREA = 0x00000001,
  36. wxHT_TOPLEVEL_ICON = 0x00000002,
  37. wxHT_TOPLEVEL_TITLEBAR = 0x00000004,
  38. wxHT_TOPLEVEL_BORDER_N = 0x00000010,
  39. wxHT_TOPLEVEL_BORDER_S = 0x00000020,
  40. wxHT_TOPLEVEL_BORDER_E = 0x00000040,
  41. wxHT_TOPLEVEL_BORDER_W = 0x00000080,
  42. wxHT_TOPLEVEL_BORDER_NE = wxHT_TOPLEVEL_BORDER_N | wxHT_TOPLEVEL_BORDER_E,
  43. wxHT_TOPLEVEL_BORDER_SE = wxHT_TOPLEVEL_BORDER_S | wxHT_TOPLEVEL_BORDER_E,
  44. wxHT_TOPLEVEL_BORDER_NW = wxHT_TOPLEVEL_BORDER_N | wxHT_TOPLEVEL_BORDER_W,
  45. wxHT_TOPLEVEL_BORDER_SW = wxHT_TOPLEVEL_BORDER_S | wxHT_TOPLEVEL_BORDER_W,
  46. wxHT_TOPLEVEL_ANY_BORDER = 0x000000F0,
  47. wxHT_TOPLEVEL_BUTTON_CLOSE = /*0x01000000*/ wxTOPLEVEL_BUTTON_CLOSE,
  48. wxHT_TOPLEVEL_BUTTON_MAXIMIZE = /*0x02000000*/ wxTOPLEVEL_BUTTON_MAXIMIZE,
  49. wxHT_TOPLEVEL_BUTTON_ICONIZE = /*0x04000000*/ wxTOPLEVEL_BUTTON_ICONIZE,
  50. wxHT_TOPLEVEL_BUTTON_RESTORE = /*0x08000000*/ wxTOPLEVEL_BUTTON_RESTORE,
  51. wxHT_TOPLEVEL_BUTTON_HELP = /*0x10000000*/ wxTOPLEVEL_BUTTON_HELP,
  52. wxHT_TOPLEVEL_ANY_BUTTON = 0x1F000000
  53. };
  54. // Flags for interactive frame manipulation functions (only in wxUniversal):
  55. enum
  56. {
  57. wxINTERACTIVE_MOVE = 0x00000001,
  58. wxINTERACTIVE_RESIZE = 0x00000002,
  59. wxINTERACTIVE_RESIZE_S = 0x00000010,
  60. wxINTERACTIVE_RESIZE_N = 0x00000020,
  61. wxINTERACTIVE_RESIZE_W = 0x00000040,
  62. wxINTERACTIVE_RESIZE_E = 0x00000080,
  63. wxINTERACTIVE_WAIT_FOR_INPUT = 0x10000000
  64. };
  65. // ----------------------------------------------------------------------------
  66. // the actions supported by this control
  67. // ----------------------------------------------------------------------------
  68. #define wxACTION_TOPLEVEL_ACTIVATE wxT("activate") // (de)activate the frame
  69. #define wxACTION_TOPLEVEL_BUTTON_PRESS wxT("pressbtn") // press titlebar btn
  70. #define wxACTION_TOPLEVEL_BUTTON_RELEASE wxT("releasebtn") // press titlebar btn
  71. #define wxACTION_TOPLEVEL_BUTTON_CLICK wxT("clickbtn") // press titlebar btn
  72. #define wxACTION_TOPLEVEL_MOVE wxT("move") // move the frame
  73. #define wxACTION_TOPLEVEL_RESIZE wxT("resize") // resize the frame
  74. //-----------------------------------------------------------------------------
  75. // wxTopLevelWindow
  76. //-----------------------------------------------------------------------------
  77. class WXDLLIMPEXP_CORE wxTopLevelWindow : public wxTopLevelWindowNative,
  78. public wxInputConsumer
  79. {
  80. public:
  81. // construction
  82. wxTopLevelWindow() { Init(); }
  83. wxTopLevelWindow(wxWindow *parent,
  84. wxWindowID id,
  85. const wxString& title,
  86. const wxPoint& pos = wxDefaultPosition,
  87. const wxSize& size = wxDefaultSize,
  88. long style = wxDEFAULT_FRAME_STYLE,
  89. const wxString& name = wxFrameNameStr)
  90. {
  91. Init();
  92. Create(parent, id, title, pos, size, style, name);
  93. }
  94. bool Create(wxWindow *parent,
  95. wxWindowID id,
  96. const wxString& title,
  97. const wxPoint& pos = wxDefaultPosition,
  98. const wxSize& size = wxDefaultSize,
  99. long style = wxDEFAULT_FRAME_STYLE,
  100. const wxString& name = wxFrameNameStr);
  101. // wxUniv-specific methods: do [not] use native decorations for this (or
  102. // all) window(s)
  103. //
  104. // notice that this has no effect if the system doesn't support any native
  105. // decorations anyhow and that by default native decorations are used
  106. //
  107. // if UseNativeDecorations() is used, it must be called before Create()
  108. static void UseNativeDecorationsByDefault(bool native = true);
  109. void UseNativeDecorations(bool native = true);
  110. bool IsUsingNativeDecorations() const;
  111. // implement base class pure virtuals
  112. virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
  113. virtual wxPoint GetClientAreaOrigin() const;
  114. virtual void SetIcons(const wxIconBundle& icons);
  115. // implementation from now on
  116. // --------------------------
  117. // tests for frame's part at given point
  118. long HitTest(const wxPoint& pt) const;
  119. virtual bool PerformAction(const wxControlAction& action,
  120. long numArg = -1,
  121. const wxString& strArg = wxEmptyString);
  122. static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
  123. virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
  124. {
  125. return GetStdInputHandler(handlerDef);
  126. }
  127. // move/resize the frame interactively, i.e. let the user do it
  128. virtual void InteractiveMove(int flags = wxINTERACTIVE_MOVE);
  129. virtual wxSize GetMinSize() const;
  130. virtual wxWindow *GetInputWindow() const { return const_cast<wxTopLevelWindow*>(this); }
  131. protected:
  132. virtual void DoGetClientSize(int *width, int *height) const;
  133. virtual void DoSetClientSize(int width, int height);
  134. // handle titlebar button click event
  135. virtual void ClickTitleBarButton(long button);
  136. // return wxTOPLEVEL_xxx combination based on current state of the frame
  137. long GetDecorationsStyle() const;
  138. // common part of all ctors
  139. void Init();
  140. void RefreshTitleBar();
  141. void OnNcPaint(wxNcPaintEvent& event);
  142. void OnSystemMenu(wxCommandEvent& event);
  143. // true if wxTLW should render decorations (aka titlebar) itself
  144. static int ms_drawDecorations;
  145. // true if wxTLW can be iconized
  146. static int ms_canIconize;
  147. // true if we're using native decorations
  148. bool m_usingNativeDecorations;
  149. // true for currently active frame
  150. bool m_isActive;
  151. // version of icon for titlebar (16x16)
  152. wxIcon m_titlebarIcon;
  153. // saved window style in fullscreen mdoe
  154. long m_fsSavedStyle;
  155. // currently pressed titlebar button
  156. long m_pressedButton;
  157. DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
  158. DECLARE_EVENT_TABLE()
  159. WX_DECLARE_INPUT_CONSUMER()
  160. };
  161. #endif // __WX_UNIV_TOPLEVEL_H__