]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/window.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / gtk1 / window.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8ef94bfc 2// Name: wx/gtk1/window.h
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
58614078 5// Copyright: (c) 1998 Robert Roebling
65571936 6// Licence: wxWindows licence
c801d85f
KB
7/////////////////////////////////////////////////////////////////////////////
8
c801d85f
KB
9#ifndef __GTKWINDOWH__
10#define __GTKWINDOWH__
11
55489584 12typedef struct _GtkTooltips GtkTooltips;
29e461a2
PC
13#ifdef HAVE_XIM
14typedef struct _GdkIC GdkIC;
15typedef struct _GdkICAttr GdkICAttr;
16#endif
55489584 17
6ca41e57 18//-----------------------------------------------------------------------------
fd0eed64 19// callback definition for inserting a window (internal)
6ca41e57
RR
20//-----------------------------------------------------------------------------
21
b5dbe15d 22class WXDLLIMPEXP_FWD_CORE wxWindowGTK;
1e6feb95 23typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
6ca41e57 24
c801d85f 25//-----------------------------------------------------------------------------
1e6feb95 26// wxWindowGTK
c801d85f
KB
27//-----------------------------------------------------------------------------
28
20123d49 29class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase
c801d85f 30{
aed8df38 31public:
bfc6fde4
VZ
32 // creating the window
33 // -------------------
1e6feb95
VZ
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);
f03fc89f
VZ
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);
1e6feb95 47 virtual ~wxWindowGTK();
cd0183ca 48
f03fc89f
VZ
49 // implement base class (pure) virtual methods
50 // -------------------------------------------
a264ece2 51
4292eeb4 52 virtual void SetLabel(const wxString& WXUNUSED(label)) { }
5bc3865f 53 virtual wxString GetLabel() const { return wxEmptyString; }
2ea5111b 54
bfc6fde4 55 virtual bool Destroy();
bfc6fde4 56
f03fc89f
VZ
57 virtual void Raise();
58 virtual void Lower();
ff8bfdbb 59
5bc3865f 60 virtual bool Show( bool show = true );
47a8a4d5 61 virtual void DoEnable( bool enable );
ff8bfdbb 62
015dca24
MR
63 virtual void SetWindowStyleFlag( long style );
64
f03fc89f 65 virtual bool IsRetained() const;
2f2aa628 66
bfc6fde4 67 virtual void SetFocus();
f03fc89f 68 virtual bool AcceptsFocus() const;
ff8bfdbb 69
fdb7dadb 70 virtual bool Reparent( wxWindowBase *newParent );
ff8bfdbb 71
f03fc89f 72 virtual void WarpPointer(int x, int y);
b1170810 73
5bc3865f 74 virtual void Refresh( bool eraseBackground = true,
f03fc89f 75 const wxRect *rect = (const wxRect *) NULL );
beab25bd 76 virtual void Update();
596f1d11 77 virtual void ClearBackground();
bfc6fde4 78
f03fc89f
VZ
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 );
cd0183ca 83
c7382f91 84 virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
f26623c8 85
bfc6fde4
VZ
86 virtual int GetCharHeight() const;
87 virtual int GetCharWidth() const;
8bbe427f 88
f03fc89f 89 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
5bc3865f
WS
90 int range, bool refresh = true );
91 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
f03fc89f
VZ
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,
d3b9f782 96 const wxRect* rect = NULL );
8bbe427f 97
f03fc89f
VZ
98#if wxUSE_DRAG_AND_DROP
99 virtual void SetDropTarget( wxDropTarget *dropTarget );
100#endif // wxUSE_DRAG_AND_DROP
f26623c8 101
2e992e06
VZ
102 virtual bool IsDoubleBuffered() const { return false; }
103
08f53168
PC
104 GdkWindow* GTKGetDrawingWindow() const;
105
f03fc89f
VZ
106 // implementation
107 // --------------
c801d85f 108
d7c24517
VZ
109 virtual WXWidget GetHandle() const { return m_widget; }
110
beab25bd
RR
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
bfc6fde4 114 virtual void OnInternalIdle();
ff8bfdbb 115
4c51a665 116 // Internal representation of Update()
010afced 117 void GtkUpdate();
f26623c8 118
beab25bd
RR
119 // For compatibility across platforms (not in event table)
120 void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
20e85460 121
beab25bd 122 // Used by all window classes in the widget creation process.
1e6feb95 123 bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
bfc6fde4 124 void PostCreation();
ff8bfdbb 125
beab25bd
RR
126 // Internal addition of child windows. differs from class
127 // to class not by using virtual functions but by using
128 // the m_insertCallback.
1e6feb95 129 void DoAddChild(wxWindowGTK *child);
f26623c8 130
beab25bd
RR
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.
90e572f1 141 // also, it is not clear which native widget is the top
beab25bd
RR
142 // widget where (most of) the input goes. even tooltips have
143 // to be applied to all subwidgets.
bfc6fde4
VZ
144 virtual GtkWidget* GetConnectWidget();
145 virtual bool IsOwnGtkWindow( GdkWindow *window );
146 void ConnectWidget( GtkWidget *widget );
8bbe427f 147
ff8bfdbb 148#if wxUSE_TOOLTIPS
74ce55e9 149 virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
ff8bfdbb 150#endif // wxUSE_TOOLTIPS
301cd871 151
87a3ebe9
VZ
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
90e572f1 156 // Called from GTK signal handlers. it indicates that
d13b34d3 157 // the layout functions have to be called later on
739730ca 158 // (i.e. in idle time, implemented in OnInternalIdle() ).
5bc3865f 159 void GtkUpdateSize() { m_sizeSet = false; }
94633ad9 160
3ae4c570
VZ
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)) { }
165
d1f2ac45 166 // is this window transparent for the mouse events (as wxStaticBox is)?
5bc3865f 167 virtual bool IsTransparentForMouse() const { return false; }
d1f2ac45 168
2b4f3c9f 169 // is this a radiobutton (used by radiobutton code itself only)?
5bc3865f 170 virtual bool IsRadioButton() const { return false; }
2b4f3c9f 171
f03fc89f
VZ
172 // position and size of the window
173 int m_x, m_y;
174 int m_width, m_height;
5b8a521e 175 int m_oldClientWidth,m_oldClientHeight;
bcf1fa6b 176
76fcf0f2
RR
177 // see the docs in src/gtk/window.cpp
178 GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
77ffb593 179 GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
94633ad9 180
76fcf0f2
RR
181 // this widget will be queried for GTK's focus events
182 GtkWidget *m_focusWidget;
f03fc89f 183
60e4975c 184#ifdef HAVE_XIM
77ffb593 185 // XIM support for wxWidgets
63081513
RR
186 GdkIC *m_ic;
187 GdkICAttr *m_icattr;
60e4975c 188#endif // HAVE_XIM
3379ed37 189
3bcc8d15 190 // The area to be cleared (and not just refreshed)
331a0b6b 191 // We cannot make this distinction under GTK 2.0.
3bcc8d15
RR
192 wxRegion m_clearRegion;
193
76fcf0f2 194 // scrolling stuff
bfc6fde4 195 GtkAdjustment *m_hAdjust,*m_vAdjust;
739730ca
RR
196 float m_oldHorizontalPos;
197 float m_oldVerticalPos;
198
f03fc89f 199 // extra (wxGTK-specific) flags
76fcf0f2
RR
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"
f03fc89f 203 bool m_hasScrolling:1;
f03fc89f
VZ
204 bool m_hasVMT:1;
205 bool m_sizeSet:1;
206 bool m_resizing:1;
6cad4f1b
VZ
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?
5bc3865f 210 bool m_clipPaintRegion:1; // true after ScrollWindow()
c7382f91
JS
211 bool m_needsStyleChange:1; // May not be able to change
212 // background style until OnIdle
7af6f327 213
d7c24517
VZ
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.
f03fc89f 217 wxInsertChildFunction m_insertCallback;
68995f26 218
f03fc89f 219 // implement the base class pure virtuals
6de70470
VZ
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
dabc0cd5
VZ
230 virtual void DoClientToScreen( int *x, int *y ) const;
231 virtual void DoScreenToClient( int *x, int *y ) const;
f03fc89f
VZ
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;
bfc6fde4
VZ
235 virtual void DoSetSize(int x, int y,
236 int width, int height,
237 int sizeFlags = wxSIZE_AUTO);
bfc6fde4 238 virtual void DoSetClientSize(int width, int height);
9d9b7755 239 virtual void DoMoveWindow(int x, int y, int width, int height);
aed8df38 240
94633ad9
VZ
241 virtual void DoCaptureMouse();
242 virtual void DoReleaseMouse();
f26623c8 243
f03fc89f
VZ
244#if wxUSE_TOOLTIPS
245 virtual void DoSetToolTip( wxToolTip *tip );
246#endif // wxUSE_TOOLTIPS
247
3ae4c570
VZ
248protected:
249 // common part of all ctors (not virtual because called from ctor)
f03fc89f 250 void Init();
f26623c8 251
f40fdaa3
VS
252 // Called by ApplyWidgetStyle (which is called by SetFont() and
253 // SetXXXColour etc to apply style changed to native widgets) to create
5edef14e
VS
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);
f40fdaa3
VS
258
259 // Overridden in many GTK widgets who have to handle subwidgets
5edef14e 260 virtual void ApplyWidgetStyle(bool forceStyle = false);
f26623c8 261
5bc3865f 262 // helper function to ease native widgets wrapping, called by
7074ce35
VS
263 // ApplyWidgetStyle -- override this, not ApplyWidgetStyle
264 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
f03fc89f 265
68dda785 266private:
1e6feb95 267 DECLARE_DYNAMIC_CLASS(wxWindowGTK)
c0c133e1 268 wxDECLARE_NO_COPY_CLASS(wxWindowGTK);
c801d85f
KB
269};
270
20123d49 271extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
3379ed37 272
c801d85f 273#endif // __GTKWINDOWH__