1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/gtk1/window.h 3 // Purpose: 4 // Author: Robert Roebling 5 // Copyright: (c) 1998 Robert Roebling 6 // Licence: wxWindows licence 7 ///////////////////////////////////////////////////////////////////////////// 8 9 #ifndef __GTKWINDOWH__ 10 #define __GTKWINDOWH__ 11 12 typedef struct _GtkTooltips GtkTooltips; 13 #ifdef HAVE_XIM 14 typedef struct _GdkIC GdkIC; 15 typedef struct _GdkICAttr GdkICAttr; 16 #endif 17 18 //----------------------------------------------------------------------------- 19 // callback definition for inserting a window (internal) 20 //----------------------------------------------------------------------------- 21 22 class WXDLLIMPEXP_FWD_CORE wxWindowGTK; 23 typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* ); 24 25 //----------------------------------------------------------------------------- 26 // wxWindowGTK 27 //----------------------------------------------------------------------------- 28 29 class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase 30 { 31 public: 32 // creating the window 33 // ------------------- 34 wxWindowGTK(); 35 wxWindowGTK(wxWindow *parent, 36 wxWindowID id, 37 const wxPoint& pos = wxDefaultPosition, 38 const wxSize& size = wxDefaultSize, 39 long style = 0, 40 const wxString& name = wxPanelNameStr); 41 bool Create(wxWindow *parent, 42 wxWindowID id, 43 const wxPoint& pos = wxDefaultPosition, 44 const wxSize& size = wxDefaultSize, 45 long style = 0, 46 const wxString& name = wxPanelNameStr); 47 virtual ~wxWindowGTK(); 48 49 // implement base class (pure) virtual methods 50 // ------------------------------------------- 51 SetLabel(const wxString & WXUNUSED (label))52 virtual void SetLabel(const wxString& WXUNUSED(label)) { } GetLabel()53 virtual wxString GetLabel() const { return wxEmptyString; } 54 55 virtual bool Destroy(); 56 57 virtual void Raise(); 58 virtual void Lower(); 59 60 virtual bool Show( bool show = true ); 61 virtual void DoEnable( bool enable ); 62 63 virtual void SetWindowStyleFlag( long style ); 64 65 virtual bool IsRetained() const; 66 67 virtual void SetFocus(); 68 virtual bool AcceptsFocus() const; 69 70 virtual bool Reparent( wxWindowBase *newParent ); 71 72 virtual void WarpPointer(int x, int y); 73 74 virtual void Refresh( bool eraseBackground = true, 75 const wxRect *rect = (const wxRect *) NULL ); 76 virtual void Update(); 77 virtual void ClearBackground(); 78 79 virtual bool SetBackgroundColour( const wxColour &colour ); 80 virtual bool SetForegroundColour( const wxColour &colour ); 81 virtual bool SetCursor( const wxCursor &cursor ); 82 virtual bool SetFont( const wxFont &font ); 83 84 virtual bool SetBackgroundStyle(wxBackgroundStyle style) ; 85 86 virtual int GetCharHeight() const; 87 virtual int GetCharWidth() const; 88 89 virtual void SetScrollbar( int orient, int pos, int thumbVisible, 90 int range, bool refresh = true ); 91 virtual void SetScrollPos( int orient, int pos, bool refresh = true ); 92 virtual int GetScrollPos( int orient ) const; 93 virtual int GetScrollThumb( int orient ) const; 94 virtual int GetScrollRange( int orient ) const; 95 virtual void ScrollWindow( int dx, int dy, 96 const wxRect* rect = NULL ); 97 98 #if wxUSE_DRAG_AND_DROP 99 virtual void SetDropTarget( wxDropTarget *dropTarget ); 100 #endif // wxUSE_DRAG_AND_DROP 101 IsDoubleBuffered()102 virtual bool IsDoubleBuffered() const { return false; } 103 104 GdkWindow* GTKGetDrawingWindow() const; 105 106 // implementation 107 // -------------- 108 GetHandle()109 virtual WXWidget GetHandle() const { return m_widget; } 110 111 // I don't want users to override what's done in idle so everything that 112 // has to be done in idle time in order for wxGTK to work is done in 113 // OnInternalIdle 114 virtual void OnInternalIdle(); 115 116 // Internal representation of Update() 117 void GtkUpdate(); 118 119 // For compatibility across platforms (not in event table) OnIdle(wxIdleEvent & WXUNUSED (event))120 void OnIdle(wxIdleEvent& WXUNUSED(event)) {} 121 122 // Used by all window classes in the widget creation process. 123 bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ); 124 void PostCreation(); 125 126 // Internal addition of child windows. differs from class 127 // to class not by using virtual functions but by using 128 // the m_insertCallback. 129 void DoAddChild(wxWindowGTK *child); 130 131 // This methods sends wxPaintEvents to the window. It reads the 132 // update region, breaks it up into rects and sends an event 133 // for each rect. It is also responsible for background erase 134 // events and NC paint events. It is called from "draw" and 135 // "expose" handlers as well as from ::Update() 136 void GtkSendPaintEvents(); 137 138 // The methods below are required because many native widgets 139 // are composed of several subwidgets and setting a style for 140 // the widget means setting it for all subwidgets as well. 141 // also, it is not clear which native widget is the top 142 // widget where (most of) the input goes. even tooltips have 143 // to be applied to all subwidgets. 144 virtual GtkWidget* GetConnectWidget(); 145 virtual bool IsOwnGtkWindow( GdkWindow *window ); 146 void ConnectWidget( GtkWidget *widget ); 147 148 #if wxUSE_TOOLTIPS 149 virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); 150 #endif // wxUSE_TOOLTIPS 151 152 // Call after modifing the value of m_hAdjust or m_vAdjust to bring the 153 // scrolbar in sync (this does not generate any wx events) 154 void GtkUpdateScrollbar(int orient); 155 156 // Called from GTK signal handlers. it indicates that 157 // the layout functions have to be called later on 158 // (i.e. in idle time, implemented in OnInternalIdle() ). GtkUpdateSize()159 void GtkUpdateSize() { m_sizeSet = false; } 160 161 // fix up the mouse event coords, used by wxListBox only so far FixUpMouseEvent(GtkWidget * WXUNUSED (widget),wxCoord & WXUNUSED (x),wxCoord & WXUNUSED (y))162 virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget), 163 wxCoord& WXUNUSED(x), 164 wxCoord& WXUNUSED(y)) { } 165 166 // is this window transparent for the mouse events (as wxStaticBox is)? IsTransparentForMouse()167 virtual bool IsTransparentForMouse() const { return false; } 168 169 // is this a radiobutton (used by radiobutton code itself only)? IsRadioButton()170 virtual bool IsRadioButton() const { return false; } 171 172 // position and size of the window 173 int m_x, m_y; 174 int m_width, m_height; 175 int m_oldClientWidth,m_oldClientHeight; 176 177 // see the docs in src/gtk/window.cpp 178 GtkWidget *m_widget; // mostly the widget seen by the rest of GTK 179 GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets 180 181 // this widget will be queried for GTK's focus events 182 GtkWidget *m_focusWidget; 183 184 #ifdef HAVE_XIM 185 // XIM support for wxWidgets 186 GdkIC *m_ic; 187 GdkICAttr *m_icattr; 188 #endif // HAVE_XIM 189 190 // The area to be cleared (and not just refreshed) 191 // We cannot make this distinction under GTK 2.0. 192 wxRegion m_clearRegion; 193 194 // scrolling stuff 195 GtkAdjustment *m_hAdjust,*m_vAdjust; 196 float m_oldHorizontalPos; 197 float m_oldVerticalPos; 198 199 // extra (wxGTK-specific) flags 200 bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ? 201 bool m_noExpose:1; // wxGLCanvas has its own redrawing 202 bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size" 203 bool m_hasScrolling:1; 204 bool m_hasVMT:1; 205 bool m_sizeSet:1; 206 bool m_resizing:1; 207 bool m_acceptsFocus:1; // true if not static 208 bool m_hasFocus:1; // true if == FindFocus() 209 bool m_isScrolling:1; // dragging scrollbar thumb? 210 bool m_clipPaintRegion:1; // true after ScrollWindow() 211 bool m_needsStyleChange:1; // May not be able to change 212 // background style until OnIdle 213 214 // C++ has no virtual methods in the constrcutor of any class but we need 215 // different methods of inserting a child window into a wxFrame, 216 // wxMDIFrame, wxNotebook etc. this is the callback that will get used. 217 wxInsertChildFunction m_insertCallback; 218 219 // implement the base class pure virtuals 220 virtual void DoGetTextExtent(const wxString& string, 221 int *x, int *y, 222 int *descent = NULL, 223 int *externalLeading = NULL, 224 const wxFont *theFont = NULL) const; 225 226 #if wxUSE_MENUS_NATIVE 227 virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); 228 #endif // wxUSE_MENUS_NATIVE 229 230 virtual void DoClientToScreen( int *x, int *y ) const; 231 virtual void DoScreenToClient( int *x, int *y ) const; 232 virtual void DoGetPosition( int *x, int *y ) const; 233 virtual void DoGetSize( int *width, int *height ) const; 234 virtual void DoGetClientSize( int *width, int *height ) const; 235 virtual void DoSetSize(int x, int y, 236 int width, int height, 237 int sizeFlags = wxSIZE_AUTO); 238 virtual void DoSetClientSize(int width, int height); 239 virtual void DoMoveWindow(int x, int y, int width, int height); 240 241 virtual void DoCaptureMouse(); 242 virtual void DoReleaseMouse(); 243 244 #if wxUSE_TOOLTIPS 245 virtual void DoSetToolTip( wxToolTip *tip ); 246 #endif // wxUSE_TOOLTIPS 247 248 protected: 249 // common part of all ctors (not virtual because called from ctor) 250 void Init(); 251 252 // Called by ApplyWidgetStyle (which is called by SetFont() and 253 // SetXXXColour etc to apply style changed to native widgets) to create 254 // modified GTK style with non-standard attributes. If forceStyle=true, 255 // creates empty GtkRcStyle if there are no modifications, otherwise 256 // returns NULL in such case. 257 GtkRcStyle *CreateWidgetStyle(bool forceStyle = false); 258 259 // Overridden in many GTK widgets who have to handle subwidgets 260 virtual void ApplyWidgetStyle(bool forceStyle = false); 261 262 // helper function to ease native widgets wrapping, called by 263 // ApplyWidgetStyle -- override this, not ApplyWidgetStyle 264 virtual void DoApplyWidgetStyle(GtkRcStyle *style); 265 266 private: 267 DECLARE_DYNAMIC_CLASS(wxWindowGTK) 268 wxDECLARE_NO_COPY_CLASS(wxWindowGTK); 269 }; 270 271 extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win); 272 273 #endif // __GTKWINDOWH__ 274