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