1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/window.h
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define __GTKWINDOWH__
12 typedef struct _GtkTooltips GtkTooltips
;
14 typedef struct _GdkIC GdkIC
;
15 typedef struct _GdkICAttr GdkICAttr
;
18 //-----------------------------------------------------------------------------
19 // callback definition for inserting a window (internal)
20 //-----------------------------------------------------------------------------
22 class WXDLLIMPEXP_FWD_CORE wxWindowGTK
;
23 typedef void (*wxInsertChildFunction
)( wxWindowGTK
*, wxWindowGTK
* );
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 class WXDLLIMPEXP_CORE wxWindowGTK
: public wxWindowBase
32 // creating the window
33 // -------------------
35 wxWindowGTK(wxWindow
*parent
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
40 const wxString
& name
= wxPanelNameStr
);
41 bool Create(wxWindow
*parent
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxString
& name
= wxPanelNameStr
);
47 virtual ~wxWindowGTK();
49 // implement base class (pure) virtual methods
50 // -------------------------------------------
52 virtual void SetLabel(const wxString
& WXUNUSED(label
)) { }
53 virtual wxString
GetLabel() const { return wxEmptyString
; }
55 virtual bool Destroy();
60 virtual bool Show( bool show
= true );
61 virtual void DoEnable( bool enable
);
63 virtual void SetWindowStyleFlag( long style
);
65 virtual bool IsRetained() const;
67 virtual void SetFocus();
68 virtual bool AcceptsFocus() const;
70 virtual bool Reparent( wxWindowBase
*newParent
);
72 virtual void WarpPointer(int x
, int y
);
74 virtual void Refresh( bool eraseBackground
= true,
75 const wxRect
*rect
= (const wxRect
*) NULL
);
76 virtual void Update();
77 virtual void ClearBackground();
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
);
84 virtual bool SetBackgroundStyle(wxBackgroundStyle style
) ;
86 virtual int GetCharHeight() const;
87 virtual int GetCharWidth() const;
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
);
98 #if wxUSE_DRAG_AND_DROP
99 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
100 #endif // wxUSE_DRAG_AND_DROP
102 virtual bool IsDoubleBuffered() const { return false; }
104 GdkWindow
* GTKGetDrawingWindow() const;
109 virtual WXWidget
GetHandle() const { return m_widget
; }
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
114 virtual void OnInternalIdle();
116 // Internal representation of Update()
119 // For compatibility across platforms (not in event table)
120 void OnIdle(wxIdleEvent
& WXUNUSED(event
)) {}
122 // Used by all window classes in the widget creation process.
123 bool PreCreation( wxWindowGTK
*parent
, const wxPoint
&pos
, const wxSize
&size
);
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
);
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();
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
);
149 virtual void ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
);
150 #endif // wxUSE_TOOLTIPS
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
);
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() ).
159 void GtkUpdateSize() { m_sizeSet
= false; }
161 // fix up the mouse event coords, used by wxListBox only so far
162 virtual void FixUpMouseEvent(GtkWidget
* WXUNUSED(widget
),
163 wxCoord
& WXUNUSED(x
),
164 wxCoord
& WXUNUSED(y
)) { }
166 // is this window transparent for the mouse events (as wxStaticBox is)?
167 virtual bool IsTransparentForMouse() const { return false; }
169 // is this a radiobutton (used by radiobutton code itself only)?
170 virtual bool IsRadioButton() const { return false; }
172 // position and size of the window
174 int m_width
, m_height
;
175 int m_oldClientWidth
,m_oldClientHeight
;
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
181 // this widget will be queried for GTK's focus events
182 GtkWidget
*m_focusWidget
;
185 // XIM support for wxWidgets
190 // The area to be cleared (and not just refreshed)
191 // We cannot make this distinction under GTK 2.0.
192 wxRegion m_clearRegion
;
195 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
196 float m_oldHorizontalPos
;
197 float m_oldVerticalPos
;
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;
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
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
;
219 // implement the base class pure virtuals
220 virtual void DoGetTextExtent(const wxString
& string
,
223 int *externalLeading
= NULL
,
224 const wxFont
*theFont
= NULL
) const;
226 #if wxUSE_MENUS_NATIVE
227 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
228 #endif // wxUSE_MENUS_NATIVE
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
);
241 virtual void DoCaptureMouse();
242 virtual void DoReleaseMouse();
245 virtual void DoSetToolTip( wxToolTip
*tip
);
246 #endif // wxUSE_TOOLTIPS
249 // common part of all ctors (not virtual because called from ctor)
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);
259 // Overridden in many GTK widgets who have to handle subwidgets
260 virtual void ApplyWidgetStyle(bool forceStyle
= false);
262 // helper function to ease native widgets wrapping, called by
263 // ApplyWidgetStyle -- override this, not ApplyWidgetStyle
264 virtual void DoApplyWidgetStyle(GtkRcStyle
*style
);
267 DECLARE_DYNAMIC_CLASS(wxWindowGTK
)
268 wxDECLARE_NO_COPY_CLASS(wxWindowGTK
);
271 extern WXDLLIMPEXP_CORE wxWindow
*wxFindFocusedChild(wxWindowGTK
*win
);
273 #endif // __GTKWINDOWH__