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