]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/window.h
Various small fixes
[wxWidgets.git] / include / wx / gtk1 / window.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose:
4// Author: Robert Roebling
58614078
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
aed8df38 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifndef __GTKWINDOWH__
12#define __GTKWINDOWH__
13
14#ifdef __GNUG__
15#pragma interface
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
20#include "wx/list.h"
21#include "wx/event.h"
22#include "wx/validate.h"
23#include "wx/cursor.h"
24#include "wx/font.h"
c801d85f 25#include "wx/region.h"
bcf1fa6b 26#include "wx/accel.h"
c801d85f
KB
27
28//-----------------------------------------------------------------------------
29// global data
30//-----------------------------------------------------------------------------
31
32extern const char *wxFrameNameStr;
33extern wxList wxTopLevelWindows;
34
bbe0af5b
RR
35//-----------------------------------------------------------------------------
36// global function
37//-----------------------------------------------------------------------------
38
39wxWindow* wxGetActiveWindow();
40
c801d85f
KB
41//-----------------------------------------------------------------------------
42// classes
43//-----------------------------------------------------------------------------
44
45class wxLayoutConstraints;
46class wxSizer;
ac57418f 47class wxDC;
fd0eed64
RR
48class wxClientData;
49class wxVoidClientData;
c801d85f 50class wxWindow;
06cfab17 51#if wxUSE_WX_RESOURCES
ac57418f
RR
52class wxResourceTable;
53class wxItemResource;
54#endif
06cfab17 55#if wxUSE_DRAG_AND_DROP
ac57418f
RR
56class wxDropTarget;
57#endif
b1170810 58class wxToolTip;
c801d85f 59
6ca41e57 60//-----------------------------------------------------------------------------
fd0eed64 61// callback definition for inserting a window (internal)
6ca41e57
RR
62//-----------------------------------------------------------------------------
63
64typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
65
c801d85f
KB
66//-----------------------------------------------------------------------------
67// global data
68//-----------------------------------------------------------------------------
69
70extern const char *wxPanelNameStr;
71extern const wxSize wxDefaultSize;
72extern const wxPoint wxDefaultPosition;
73
fd0eed64
RR
74//-----------------------------------------------------------------------------
75// wxClientData
76//-----------------------------------------------------------------------------
77
78class wxClientData
79{
80public:
36b3b54a
RR
81 wxClientData() { }
82 virtual ~wxClientData() { }
fd0eed64
RR
83};
84
fd0eed64
RR
85//-----------------------------------------------------------------------------
86// wxStringClientData
87//-----------------------------------------------------------------------------
88
89class wxStringClientData: public wxClientData
90{
91public:
92 wxStringClientData() { }
93 wxStringClientData( wxString &data ) { m_data = data; }
94 void SetData( wxString &data ) { m_data = data; }
95 wxString GetData() const { return m_data; }
8bbe427f 96
fd0eed64
RR
97private:
98 wxString m_data;
99};
100
b292e2f5
RR
101//-----------------------------------------------------------------------------
102// (debug)
103//-----------------------------------------------------------------------------
104
105#ifdef __WXDEBUG__
106
107void debug_focus_in( GtkWidget* widget, const char* name, const char* window );
108
109#endif
110
c801d85f
KB
111//-----------------------------------------------------------------------------
112// wxWindow
113//-----------------------------------------------------------------------------
114
115class wxWindow: public wxEvtHandler
116{
a60c99e6 117 DECLARE_DYNAMIC_CLASS(wxWindow)
8bbe427f 118
aed8df38
VZ
119public:
120 wxWindow();
6ca41e57 121 wxWindow(wxWindow *parent, wxWindowID id,
6de97a3b
RR
122 const wxPoint& pos = wxDefaultPosition,
123 const wxSize& size = wxDefaultSize,
124 long style = 0,
6ca41e57 125 const wxString& name = wxPanelNameStr);
6de97a3b
RR
126 bool Create(wxWindow *parent, wxWindowID id,
127 const wxPoint& pos = wxDefaultPosition,
128 const wxSize& size = wxDefaultSize,
129 long style = 0,
130 const wxString& name = wxPanelNameStr);
aed8df38 131 virtual ~wxWindow();
cd0183ca 132
f5abe911 133#if wxUSE_WX_RESOURCES
8bbe427f 134 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
bcf1fa6b 135 const wxResourceTable *table = (const wxResourceTable *) NULL);
fd71308f 136 virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
bcf1fa6b 137 const wxResourceTable *table = (const wxResourceTable *) NULL);
f5abe911 138#endif
cd0183ca 139
aed8df38
VZ
140 bool Close( bool force = FALSE );
141 virtual bool Destroy();
142 virtual bool DestroyChildren();
143
144 virtual void PrepareDC( wxDC &dc );
145
146 virtual void SetSize( int x, int y, int width, int height,
147 int sizeFlags = wxSIZE_AUTO );
148 virtual void SetSize( int width, int height );
4f22cf8d 149
aed8df38 150 virtual void Move( int x, int y );
4f22cf8d 151
aed8df38 152 virtual void GetSize( int *width, int *height ) const;
4f22cf8d
RR
153 wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); }
154
aed8df38 155 virtual void SetClientSize( int const width, int const height );
4f22cf8d 156
aed8df38 157 virtual void GetClientSize( int *width, int *height ) const;
4f22cf8d
RR
158 wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
159
aed8df38 160 virtual void GetPosition( int *x, int *y ) const;
4f22cf8d
RR
161 wxPoint GetPosition() const { int w, h; GetPosition(& w, & h); return wxPoint(w, h); }
162
163 wxRect GetRect() const
164 { int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); }
165
aed8df38 166 virtual void Centre( int direction = wxHORIZONTAL );
cd0183ca 167 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
aed8df38 168 virtual void Fit();
2f2aa628
RR
169
170 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
aed8df38 171
36b3b54a
RR
172 /* Dialog units translations. Implemented in wincmn.cpp. */
173 wxPoint ConvertPixelsToDialog( const wxPoint& pt );
174 wxPoint ConvertDialogToPixels( const wxPoint& pt );
175 inline wxSize ConvertPixelsToDialog( const wxSize& sz )
176 { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
177 inline wxSize ConvertDialogToPixels( const wxSize& sz )
178 { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
fd71308f 179
aed8df38 180 void OnSize( wxSizeEvent &event );
aed8df38
VZ
181
182 virtual bool Show( bool show );
183 virtual void Enable( bool enable );
184 virtual void MakeModal( bool modal );
903f689b 185 virtual bool IsEnabled() const { return m_isEnabled; }
fd0eed64 186 inline bool Enabled() const { return IsEnabled(); }
aed8df38
VZ
187 virtual bool OnClose();
188
b292e2f5
RR
189 virtual void SetFocus();
190 static wxWindow *FindFocus();
191
aed8df38 192 virtual void AddChild( wxWindow *child );
8bbe427f
VZ
193 wxList& GetChildren() { return m_children; }
194
aed8df38
VZ
195 virtual void RemoveChild( wxWindow *child );
196 void SetReturnCode( int retCode );
197 int GetReturnCode();
cd0183ca 198 wxWindow *GetParent() const
c33c4050 199 { return m_parent; }
fd0eed64 200 wxWindow *GetGrandParent() const
c33c4050 201 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
36b3b54a
RR
202 void SetParent( wxWindow *parent )
203 { m_parent = parent; }
463c1fa1 204 virtual wxWindow *ReParent( wxWindow *newParent );
aed8df38 205
8bbe427f 206 wxEvtHandler *GetEventHandler() const;
86b29a61
RR
207 void SetEventHandler( wxEvtHandler *handler );
208 void PushEventHandler( wxEvtHandler *handler );
209 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
aed8df38 210
6de97a3b 211 virtual void SetValidator( const wxValidator &validator );
b1170810 212 virtual wxValidator *GetValidator();
aed8df38 213
fd0eed64
RR
214 virtual void SetClientObject( wxClientData *data );
215 virtual wxClientData *GetClientObject();
8bbe427f 216
fd0eed64
RR
217 virtual void SetClientData( void *data );
218 virtual void *GetClientData();
8bbe427f 219
bcf1fa6b
RR
220 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
221 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
8bbe427f 222
aed8df38
VZ
223 bool IsBeingDeleted();
224
225 void SetId( wxWindowID id );
8bbe427f 226 wxWindowID GetId() const;
aed8df38
VZ
227
228 void SetCursor( const wxCursor &cursor );
b1170810 229
4f22cf8d
RR
230 void WarpPointer(int x, int y);
231
b1170810
RR
232 virtual void SetToolTip( const wxString &tip );
233 virtual void SetToolTip( wxToolTip *tip );
234 virtual wxToolTip& GetToolTip();
235
c67daf87 236 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
aed8df38 237 virtual void Clear();
8bbe427f 238
8429bec1
RR
239 virtual wxRegion GetUpdateRegion() const;
240 virtual bool IsExposed(int x, int y) const;
241 virtual bool IsExposed(int x, int y, int w, int h) const;
242 virtual bool IsExposed(const wxPoint& pt) const;
243 virtual bool IsExposed(const wxRect& rect) const;
aed8df38
VZ
244
245 virtual wxColour GetBackgroundColour() const;
246 virtual void SetBackgroundColour( const wxColour &colour );
6de97a3b
RR
247 virtual wxColour GetForegroundColour() const;
248 virtual void SetForegroundColour( const wxColour &colour );
cd0183ca 249
fd0eed64
RR
250 virtual int GetCharHeight() const;
251 virtual int GetCharWidth() const;
c33c4050 252 virtual void GetTextExtent( const wxString& string, int *x, int *y,
c67daf87
UR
253 int *descent = (int *) NULL,
254 int *externalLeading = (int *) NULL,
255 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
aed8df38 256
aed8df38 257 virtual void SetFont( const wxFont &font );
4f22cf8d 258 virtual wxFont& GetFont() { return m_font; }
8bbe427f 259
fd0eed64 260 // For backward compatibility
aed8df38
VZ
261 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
262 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
4f22cf8d
RR
263 inline virtual wxFont& GetLabelFont() { return GetFont(); };
264 inline virtual wxFont& GetButtonFont() { return GetFont(); };
8bbe427f 265
aed8df38
VZ
266 virtual void SetWindowStyleFlag( long flag );
267 virtual long GetWindowStyleFlag() const;
8bbe427f 268
aed8df38
VZ
269 virtual void CaptureMouse();
270 virtual void ReleaseMouse();
8bbe427f 271
aed8df38
VZ
272 virtual void SetTitle( const wxString &title );
273 virtual wxString GetTitle() const;
274 virtual void SetName( const wxString &name );
275 virtual wxString GetName() const;
276 virtual wxString GetLabel() const;
c801d85f 277
aed8df38 278 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
b666df2c 279 void OnKeyDown( wxKeyEvent &event );
aed8df38
VZ
280
281 virtual bool IsShown() const;
e149aaeb 282
fd0eed64
RR
283 virtual void Raise();
284 virtual void Lower();
e149aaeb 285
aed8df38
VZ
286 virtual bool IsRetained();
287 virtual wxWindow *FindWindow( long id );
288 virtual wxWindow *FindWindow( const wxString& name );
8bbe427f 289
aed8df38
VZ
290 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
291 void SetDoubleClick( bool WXUNUSED(allow) ) {};
8bbe427f 292
aed8df38
VZ
293 virtual void ClientToScreen( int *x, int *y );
294 virtual void ScreenToClient( int *x, int *y );
295
296 virtual bool Validate();
297 virtual bool TransferDataToWindow();
298 virtual bool TransferDataFromWindow();
299 void OnInitDialog( wxInitDialogEvent &event );
300 virtual void InitDialog();
cd0183ca 301
30dea054 302 virtual bool PopupMenu( wxMenu *menu, int x, int y );
aed8df38 303
06cfab17 304#if wxUSE_DRAG_AND_DROP
aed8df38
VZ
305 virtual void SetDropTarget( wxDropTarget *dropTarget );
306 virtual wxDropTarget *GetDropTarget() const;
ac57418f 307#endif
cd0183ca 308
aed8df38
VZ
309 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
310 int range, bool refresh = TRUE );
311 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
312 virtual int GetScrollPos( int orient ) const;
313 virtual int GetScrollThumb( int orient ) const;
314 virtual int GetScrollRange( int orient ) const;
c67daf87 315 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
aed8df38 316
aed8df38 317 virtual bool AcceptsFocus() const;
8bbe427f 318
aed8df38
VZ
319 void UpdateWindowUI();
320
a60c99e6 321 // implementation
8bbe427f 322
9390a202
RR
323 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
324 const wxSize &size, long style, const wxString &name );
325 void PostCreation();
326
327 virtual GtkWidget* GetConnectWidget();
328 virtual bool IsOwnGtkWindow( GdkWindow *window );
329 void ConnectWidget( GtkWidget *widget );
8bbe427f 330
9390a202 331 bool HasVMT();
6ca41e57 332
9390a202
RR
333 virtual wxPoint GetClientAreaOrigin() const;
334 virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
8bbe427f 335
9390a202
RR
336 GtkStyle *GetWidgetStyle();
337 void SetWidgetStyle();
338 virtual void ApplyWidgetStyle();
339
340 virtual void OnInternalIdle();
aed8df38 341
bcf1fa6b
RR
342 wxWindow *m_parent;
343 wxList m_children;
344 int m_x,m_y;
345 int m_width,m_height;
346 int m_minWidth,m_minHeight;
347 int m_maxWidth,m_maxHeight;
348 int m_retCode;
349 wxEvtHandler *m_eventHandler;
350 wxValidator *m_windowValidator;
06cfab17 351#if wxUSE_DRAG_AND_DROP
fd0eed64 352 wxDropTarget *m_dropTarget;
ac57418f 353#endif
bcf1fa6b
RR
354 wxWindowID m_windowId;
355 wxCursor *m_cursor;
356 wxFont m_font;
357 wxColour m_backgroundColour;
1ecc4d80 358 wxColour m_foregroundColour;
bcf1fa6b
RR
359 wxRegion m_updateRegion;
360 long m_windowStyle;
361 bool m_isShown;
362 bool m_isEnabled;
363 wxString m_windowName;
364 wxAcceleratorTable m_acceleratorTable;
f5e27805
RR
365 wxClientData *m_clientObject;
366 void *m_clientData;
b1170810 367 wxToolTip *m_toolTip;
bcf1fa6b
RR
368
369 GtkWidget *m_widget;
370 GtkWidget *m_wxwindow;
371 GtkAdjustment *m_hAdjust,*m_vAdjust;
372 float m_oldHorizontalPos;
373 float m_oldVerticalPos;
374 bool m_needParent;
375 bool m_hasScrolling;
cb43b372 376 bool m_isScrolling;
bcf1fa6b
RR
377 bool m_hasVMT;
378 bool m_sizeSet;
379 bool m_resizing;
32e9da8b 380 GdkGC *m_scrollGC;
a81258be 381 GtkStyle *m_widgetStyle;
1ecc4d80 382 bool m_isStaticBox;
b292e2f5 383 bool m_acceptsFocus;
8bbe427f 384
6ca41e57 385 wxInsertChildFunction m_insertCallback;
bcf1fa6b
RR
386
387public:
388
389 wxLayoutConstraints *m_constraints;
390 wxList *m_constraintsInvolvedIn;
391 wxSizer *m_windowSizer;
392 wxWindow *m_sizerParent;
393 bool m_autoLayout;
aed8df38
VZ
394
395 wxLayoutConstraints *GetConstraints() const;
396 void SetConstraints( wxLayoutConstraints *constraints );
397 void SetAutoLayout( bool autoLayout );
398 bool GetAutoLayout() const;
399 bool Layout();
400 void SetSizer( wxSizer *sizer );
401 wxSizer *GetSizer() const;
402 void SetSizerParent( wxWindow *win );
403 wxWindow *GetSizerParent() const;
404 void UnsetConstraints(wxLayoutConstraints *c);
405 inline wxList *GetConstraintsInvolvedIn() const ;
406 void AddConstraintReference(wxWindow *otherWin);
407 void RemoveConstraintReference(wxWindow *otherWin);
408 void DeleteRelatedConstraints();
409 virtual void ResetConstraints();
410 virtual void SetConstraintSizes(bool recurse = TRUE);
411 virtual bool LayoutPhase1(int *noChanges);
412 virtual bool LayoutPhase2(int *noChanges);
413 virtual bool DoPhase(int);
414 virtual void TransformSizerToActual(int *x, int *y) const ;
415 virtual void SizerSetSize(int x, int y, int w, int h);
416 virtual void SizerMove(int x, int y);
417 virtual void SetSizeConstraint(int x, int y, int w, int h);
418 virtual void MoveConstraint(int x, int y);
419 virtual void GetSizeConstraint(int *w, int *h) const ;
420 virtual void GetClientSizeConstraint(int *w, int *h) const ;
421 virtual void GetPositionConstraint(int *x, int *y) const ;
422
68dda785 423private:
c801d85f
KB
424 DECLARE_EVENT_TABLE()
425};
426
427#endif // __GTKWINDOWH__