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