]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/window.h
Corrected wxWindow::GetExtent
[wxWidgets.git] / include / wx / gtk1 / window.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id:
7// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
aed8df38 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
11
12#ifndef __GTKWINDOWH__
13#define __GTKWINDOWH__
14
15#ifdef __GNUG__
16#pragma interface
17#endif
18
19#include "wx/defs.h"
20#include "wx/object.h"
21#include "wx/list.h"
22#include "wx/event.h"
23#include "wx/validate.h"
24#include "wx/cursor.h"
25#include "wx/font.h"
26#include "wx/dc.h"
27#include "wx/region.h"
28#include "wx/dnd.h"
bcf1fa6b 29#include "wx/accel.h"
c801d85f
KB
30
31//-----------------------------------------------------------------------------
32// global data
33//-----------------------------------------------------------------------------
34
35extern const char *wxFrameNameStr;
36extern wxList wxTopLevelWindows;
37
38//-----------------------------------------------------------------------------
39// classes
40//-----------------------------------------------------------------------------
41
42class wxLayoutConstraints;
43class wxSizer;
6de97a3b
RR
44class wxResourceTable;
45class wxItemResource;
c801d85f
KB
46
47class wxWindow;
48class wxCanvas;
49
50//-----------------------------------------------------------------------------
51// global data
52//-----------------------------------------------------------------------------
53
54extern const char *wxPanelNameStr;
55extern const wxSize wxDefaultSize;
56extern const wxPoint wxDefaultPosition;
57
58//-----------------------------------------------------------------------------
59// wxWindow
60//-----------------------------------------------------------------------------
61
62class wxWindow: public wxEvtHandler
63{
aed8df38
VZ
64public:
65 wxWindow();
6de97a3b
RR
66 inline wxWindow(wxWindow *parent, wxWindowID id,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = 0,
70 const wxString& name = wxPanelNameStr)
71 {
72 Create(parent, id, pos, size, style, name);
73 }
74 bool Create(wxWindow *parent, wxWindowID id,
75 const wxPoint& pos = wxDefaultPosition,
76 const wxSize& size = wxDefaultSize,
77 long style = 0,
78 const wxString& name = wxPanelNameStr);
aed8df38 79 virtual ~wxWindow();
cd0183ca 80
bcf1fa6b
RR
81 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
82 const wxResourceTable *table = (const wxResourceTable *) NULL);
83 virtual wxControl *CreateItem( const wxItemResource *childResource,
84 const wxResourceTable *table = (const wxResourceTable *) NULL);
cd0183ca 85
aed8df38
VZ
86 bool Close( bool force = FALSE );
87 virtual bool Destroy();
88 virtual bool DestroyChildren();
89
90 virtual void PrepareDC( wxDC &dc );
91
92 virtual void SetSize( int x, int y, int width, int height,
93 int sizeFlags = wxSIZE_AUTO );
94 virtual void SetSize( int width, int height );
95 virtual void Move( int x, int y );
96 virtual void GetSize( int *width, int *height ) const;
97 virtual void SetClientSize( int const width, int const height );
98 virtual void GetClientSize( int *width, int *height ) const;
99 virtual void GetPosition( int *x, int *y ) const;
100 virtual void Centre( int direction = wxHORIZONTAL );
cd0183ca 101 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
aed8df38 102 virtual void Fit();
2f2aa628
RR
103
104 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
aed8df38
VZ
105
106 void OnSize( wxSizeEvent &event );
107 void OnIdle( wxIdleEvent& event );
108
109 virtual bool Show( bool show );
110 virtual void Enable( bool enable );
111 virtual void MakeModal( bool modal );
903f689b
RR
112 virtual bool IsEnabled() const { return m_isEnabled; }
113 inline bool Enabled(void) const { return IsEnabled(); }
aed8df38
VZ
114 virtual void SetFocus();
115 virtual bool OnClose();
116
117 virtual void AddChild( wxWindow *child );
118 wxList *GetChildren();
119 virtual void RemoveChild( wxWindow *child );
120 void SetReturnCode( int retCode );
121 int GetReturnCode();
cd0183ca 122 wxWindow *GetParent() const
c33c4050
RR
123 { return m_parent; }
124 wxWindow *GetGrandParent(void) const
125 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
cd0183ca 126 void SetParent( wxWindow *p )
c33c4050 127 { m_parent = p; }
aed8df38
VZ
128
129 wxEvtHandler *GetEventHandler();
86b29a61
RR
130 void SetEventHandler( wxEvtHandler *handler );
131 void PushEventHandler( wxEvtHandler *handler );
132 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
aed8df38
VZ
133
134 virtual wxValidator *GetValidator();
6de97a3b 135 virtual void SetValidator( const wxValidator &validator );
aed8df38 136
bcf1fa6b
RR
137 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
138 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
139
aed8df38
VZ
140 bool IsBeingDeleted();
141
142 void SetId( wxWindowID id );
143 wxWindowID GetId();
144
145 void SetCursor( const wxCursor &cursor );
146
c67daf87 147 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
aed8df38 148 virtual void Clear();
8429bec1
RR
149
150 virtual wxRegion GetUpdateRegion() const;
151 virtual bool IsExposed(int x, int y) const;
152 virtual bool IsExposed(int x, int y, int w, int h) const;
153 virtual bool IsExposed(const wxPoint& pt) const;
154 virtual bool IsExposed(const wxRect& rect) const;
aed8df38
VZ
155
156 virtual wxColour GetBackgroundColour() const;
157 virtual void SetBackgroundColour( const wxColour &colour );
6de97a3b
RR
158 virtual wxColour GetForegroundColour() const;
159 virtual void SetForegroundColour( const wxColour &colour );
cd0183ca 160
c33c4050
RR
161 virtual int GetCharHeight(void) const;
162 virtual int GetCharWidth(void) const;
163 virtual void GetTextExtent( const wxString& string, int *x, int *y,
c67daf87
UR
164 int *descent = (int *) NULL,
165 int *externalLeading = (int *) NULL,
166 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
aed8df38
VZ
167
168 virtual void SetDefaultBackgroundColour( const wxColour& col )
c33c4050 169 { m_defaultBackgroundColour = col; }
aed8df38 170 virtual wxColour GetDefaultBackgroundColour() const
c33c4050 171 { return m_defaultBackgroundColour; }
aed8df38 172 virtual void SetDefaultForegroundColour( const wxColour& col )
c33c4050 173 { m_defaultForegroundColour = col; }
aed8df38 174 virtual wxColour GetDefaultForegroundColour() const
c33c4050 175 { return m_defaultForegroundColour; }
aed8df38
VZ
176
177 virtual void SetFont( const wxFont &font );
178 virtual wxFont *GetFont();
179 // For backward compatibility
180 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
181 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
182 inline virtual wxFont *GetLabelFont() { return GetFont(); };
183 inline virtual wxFont *GetButtonFont() { return GetFont(); };
184 virtual void SetWindowStyleFlag( long flag );
185 virtual long GetWindowStyleFlag() const;
186 virtual void CaptureMouse();
187 virtual void ReleaseMouse();
188 virtual void SetTitle( const wxString &title );
189 virtual wxString GetTitle() const;
190 virtual void SetName( const wxString &name );
191 virtual wxString GetName() const;
192 virtual wxString GetLabel() const;
c801d85f 193
aed8df38
VZ
194 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
195
196 virtual bool IsShown() const;
e149aaeb 197
362c6693
RR
198 virtual void Raise(void);
199 virtual void Lower(void);
e149aaeb 200
aed8df38
VZ
201 virtual bool IsRetained();
202 virtual wxWindow *FindWindow( long id );
203 virtual wxWindow *FindWindow( const wxString& name );
204 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
205 void SetDoubleClick( bool WXUNUSED(allow) ) {};
206 virtual void ClientToScreen( int *x, int *y );
207 virtual void ScreenToClient( int *x, int *y );
208
209 virtual bool Validate();
210 virtual bool TransferDataToWindow();
211 virtual bool TransferDataFromWindow();
212 void OnInitDialog( wxInitDialogEvent &event );
213 virtual void InitDialog();
cd0183ca 214
30dea054 215 virtual bool PopupMenu( wxMenu *menu, int x, int y );
aed8df38
VZ
216
217 virtual void SetDropTarget( wxDropTarget *dropTarget );
218 virtual wxDropTarget *GetDropTarget() const;
cd0183ca 219
aed8df38
VZ
220 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
221 int range, bool refresh = TRUE );
222 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
223 virtual int GetScrollPos( int orient ) const;
224 virtual int GetScrollThumb( int orient ) const;
225 virtual int GetScrollRange( int orient ) const;
c67daf87 226 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
aed8df38 227
aed8df38 228 virtual bool AcceptsFocus() const;
aed8df38
VZ
229 void UpdateWindowUI();
230
231public: // cannot get private going yet
232
bcf1fa6b
RR
233 virtual GtkWidget* GetConnectWidget(void);
234 virtual bool IsOwnGtkWindow( GdkWindow *window );
235
aed8df38
VZ
236 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
237 const wxSize &size, long style, const wxString &name );
238 void PostCreation();
239 bool HasVMT();
240 virtual void ImplementSetSize();
241 virtual void ImplementSetPosition();
aed8df38 242
bcf1fa6b
RR
243 wxWindow *m_parent;
244 wxList m_children;
245 int m_x,m_y;
246 int m_width,m_height;
247 int m_minWidth,m_minHeight;
248 int m_maxWidth,m_maxHeight;
249 int m_retCode;
250 wxEvtHandler *m_eventHandler;
251 wxValidator *m_windowValidator;
252 wxDropTarget *m_pDropTarget;
253 wxWindowID m_windowId;
254 wxCursor *m_cursor;
255 wxFont m_font;
256 wxColour m_backgroundColour;
257 wxColour m_defaultBackgroundColour;
258 wxColour m_foregroundColour ;
259 wxColour m_defaultForegroundColour;
260 wxRegion m_updateRegion;
261 long m_windowStyle;
262 bool m_isShown;
263 bool m_isEnabled;
264 wxString m_windowName;
265 wxAcceleratorTable m_acceleratorTable;
266
267 GtkWidget *m_widget;
268 GtkWidget *m_wxwindow;
269 GtkAdjustment *m_hAdjust,*m_vAdjust;
270 float m_oldHorizontalPos;
271 float m_oldVerticalPos;
272 bool m_needParent;
273 bool m_hasScrolling;
274 bool m_hasVMT;
275 bool m_sizeSet;
276 bool m_resizing;
277
278public:
279
280 wxLayoutConstraints *m_constraints;
281 wxList *m_constraintsInvolvedIn;
282 wxSizer *m_windowSizer;
283 wxWindow *m_sizerParent;
284 bool m_autoLayout;
aed8df38
VZ
285
286 wxLayoutConstraints *GetConstraints() const;
287 void SetConstraints( wxLayoutConstraints *constraints );
288 void SetAutoLayout( bool autoLayout );
289 bool GetAutoLayout() const;
290 bool Layout();
291 void SetSizer( wxSizer *sizer );
292 wxSizer *GetSizer() const;
293 void SetSizerParent( wxWindow *win );
294 wxWindow *GetSizerParent() const;
295 void UnsetConstraints(wxLayoutConstraints *c);
296 inline wxList *GetConstraintsInvolvedIn() const ;
297 void AddConstraintReference(wxWindow *otherWin);
298 void RemoveConstraintReference(wxWindow *otherWin);
299 void DeleteRelatedConstraints();
300 virtual void ResetConstraints();
301 virtual void SetConstraintSizes(bool recurse = TRUE);
302 virtual bool LayoutPhase1(int *noChanges);
303 virtual bool LayoutPhase2(int *noChanges);
304 virtual bool DoPhase(int);
305 virtual void TransformSizerToActual(int *x, int *y) const ;
306 virtual void SizerSetSize(int x, int y, int w, int h);
307 virtual void SizerMove(int x, int y);
308 virtual void SetSizeConstraint(int x, int y, int w, int h);
309 virtual void MoveConstraint(int x, int y);
310 virtual void GetSizeConstraint(int *w, int *h) const ;
311 virtual void GetClientSizeConstraint(int *w, int *h) const ;
312 virtual void GetPositionConstraint(int *x, int *y) const ;
313
314 DECLARE_DYNAMIC_CLASS(wxWindow)
c801d85f
KB
315 DECLARE_EVENT_TABLE()
316};
317
318#endif // __GTKWINDOWH__