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