toplevel.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/toplevel.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling, Julian Smart
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_GTK_TOPLEVEL_H_
  9. #define _WX_GTK_TOPLEVEL_H_
  10. //-----------------------------------------------------------------------------
  11. // wxTopLevelWindowGTK
  12. //-----------------------------------------------------------------------------
  13. class WXDLLIMPEXP_CORE wxTopLevelWindowGTK : public wxTopLevelWindowBase
  14. {
  15. typedef wxTopLevelWindowBase base_type;
  16. public:
  17. // construction
  18. wxTopLevelWindowGTK() { Init(); }
  19. wxTopLevelWindowGTK(wxWindow *parent,
  20. wxWindowID id,
  21. const wxString& title,
  22. const wxPoint& pos = wxDefaultPosition,
  23. const wxSize& size = wxDefaultSize,
  24. long style = wxDEFAULT_FRAME_STYLE,
  25. const wxString& name = wxFrameNameStr)
  26. {
  27. Init();
  28. Create(parent, id, title, pos, size, style, name);
  29. }
  30. bool Create(wxWindow *parent,
  31. wxWindowID id,
  32. const wxString& title,
  33. const wxPoint& pos = wxDefaultPosition,
  34. const wxSize& size = wxDefaultSize,
  35. long style = wxDEFAULT_FRAME_STYLE,
  36. const wxString& name = wxFrameNameStr);
  37. virtual ~wxTopLevelWindowGTK();
  38. // implement base class pure virtuals
  39. virtual void Maximize(bool maximize = true);
  40. virtual bool IsMaximized() const;
  41. virtual void Iconize(bool iconize = true);
  42. virtual bool IsIconized() const;
  43. virtual void SetIcons(const wxIconBundle& icons);
  44. virtual void Restore();
  45. virtual bool EnableCloseButton(bool enable = true);
  46. virtual void ShowWithoutActivating();
  47. virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
  48. virtual bool IsFullScreen() const { return m_fsIsShowing; }
  49. virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
  50. virtual void SetWindowStyleFlag( long style );
  51. virtual bool Show(bool show = true);
  52. virtual void Raise();
  53. virtual bool IsActive();
  54. virtual void SetTitle( const wxString &title );
  55. virtual wxString GetTitle() const { return m_title; }
  56. virtual void SetLabel(const wxString& label) { SetTitle( label ); }
  57. virtual wxString GetLabel() const { return GetTitle(); }
  58. virtual bool SetTransparent(wxByte alpha);
  59. virtual bool CanSetTransparent();
  60. // Experimental, to allow help windows to be
  61. // viewable from within modal dialogs
  62. virtual void AddGrab();
  63. virtual void RemoveGrab();
  64. virtual bool IsGrabbed() const { return m_grabbed; }
  65. virtual void Refresh( bool eraseBackground = true,
  66. const wxRect *rect = (const wxRect *) NULL );
  67. // implementation from now on
  68. // --------------------------
  69. // GTK callbacks
  70. virtual void OnInternalIdle();
  71. virtual void GTKHandleRealized();
  72. void GTKConfigureEvent(int x, int y);
  73. // do *not* call this to iconize the frame, this is a private function!
  74. void SetIconizeState(bool iconic);
  75. GtkWidget *m_mainWidget;
  76. bool m_fsIsShowing; /* full screen */
  77. int m_fsSaveGdkFunc, m_fsSaveGdkDecor;
  78. wxRect m_fsSaveFrame;
  79. // m_windowStyle translated to GDK's terms
  80. int m_gdkFunc,
  81. m_gdkDecor;
  82. // size of WM decorations
  83. struct DecorSize
  84. {
  85. int left, right, top, bottom;
  86. };
  87. DecorSize m_decorSize;
  88. // private gtk_timeout_add result for mimicing wxUSER_ATTENTION_INFO and
  89. // wxUSER_ATTENTION_ERROR difference, -2 for no hint, -1 for ERROR hint, rest for GtkTimeout handle.
  90. int m_urgency_hint;
  91. // timer for detecting WM with broken _NET_REQUEST_FRAME_EXTENTS handling
  92. unsigned m_netFrameExtentsTimerId;
  93. // return the size of the window without WM decorations
  94. void GTKDoGetSize(int *width, int *height) const;
  95. void GTKUpdateDecorSize(const DecorSize& decorSize);
  96. protected:
  97. // give hints to the Window Manager for how the size
  98. // of the TLW can be changed by dragging
  99. virtual void DoSetSizeHints( int minW, int minH,
  100. int maxW, int maxH,
  101. int incW, int incH);
  102. // move the window to the specified location and resize it
  103. virtual void DoMoveWindow(int x, int y, int width, int height);
  104. // take into account WM decorations here
  105. virtual void DoSetSize(int x, int y,
  106. int width, int height,
  107. int sizeFlags = wxSIZE_AUTO);
  108. virtual void DoSetClientSize(int width, int height);
  109. virtual void DoGetClientSize(int *width, int *height) const;
  110. // string shown in the title bar
  111. wxString m_title;
  112. bool m_deferShow;
  113. private:
  114. void Init();
  115. DecorSize& GetCachedDecorSize();
  116. // size hint increments
  117. int m_incWidth, m_incHeight;
  118. // is the frame currently iconized?
  119. bool m_isIconized;
  120. // is the frame currently grabbed explicitly by the application?
  121. bool m_grabbed;
  122. bool m_updateDecorSize;
  123. bool m_deferShowAllowed;
  124. };
  125. #endif // _WX_GTK_TOPLEVEL_H_