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