]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/window.h
fixes for Sun CC 5.0 (unlike 4.2 it understands bool)
[wxWidgets.git] / include / wx / gtk / window.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
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/region.h"
26#include "wx/accel.h"
27
28//-----------------------------------------------------------------------------
29// global data
30//-----------------------------------------------------------------------------
31
32extern const char *wxFrameNameStr;
33extern wxList wxTopLevelWindows;
34
35//-----------------------------------------------------------------------------
36// global function
37//-----------------------------------------------------------------------------
38
39wxWindow* wxGetActiveWindow();
40
41//-----------------------------------------------------------------------------
42// classes
43//-----------------------------------------------------------------------------
44
45class wxLayoutConstraints;
46class wxSizer;
47class wxDC;
48class wxClientData;
49class wxVoidClientData;
50class wxWindow;
51#if wxUSE_WX_RESOURCES
52class wxResourceTable;
53class wxItemResource;
54#endif
55#if wxUSE_DRAG_AND_DROP
56class wxDropTarget;
57#endif
58
59//-----------------------------------------------------------------------------
60// callback definition for inserting a window (internal)
61//-----------------------------------------------------------------------------
62
63typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
64
65//-----------------------------------------------------------------------------
66// global data
67//-----------------------------------------------------------------------------
68
69extern const char *wxPanelNameStr;
70extern const wxSize wxDefaultSize;
71extern const wxPoint wxDefaultPosition;
72
73//-----------------------------------------------------------------------------
74// wxClientData
75//-----------------------------------------------------------------------------
76
77class wxClientData
78{
79public:
80 wxClientData() { }
81 virtual ~wxClientData() { }
82};
83
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; }
95
96private:
97 wxString m_data;
98};
99
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
110//-----------------------------------------------------------------------------
111// wxWindow
112//-----------------------------------------------------------------------------
113
114class wxWindow: public wxEvtHandler
115{
116 DECLARE_DYNAMIC_CLASS(wxWindow)
117
118public:
119 wxWindow();
120 wxWindow(wxWindow *parent, wxWindowID id,
121 const wxPoint& pos = wxDefaultPosition,
122 const wxSize& size = wxDefaultSize,
123 long style = 0,
124 const wxString& name = wxPanelNameStr);
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);
130 virtual ~wxWindow();
131
132#if wxUSE_WX_RESOURCES
133 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
134 const wxResourceTable *table = (const wxResourceTable *) NULL);
135 virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
136 const wxResourceTable *table = (const wxResourceTable *) NULL);
137#endif
138
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 );
148
149 virtual void Move( int x, int y );
150
151 virtual void GetSize( int *width, int *height ) const;
152 wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); }
153
154 virtual void SetClientSize( int const width, int const height );
155
156 virtual void GetClientSize( int *width, int *height ) const;
157 wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
158
159 virtual void GetPosition( int *x, int *y ) const;
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
165 virtual void Centre( int direction = wxHORIZONTAL );
166 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
167 virtual void Fit();
168
169 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
170
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
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 );
185 virtual bool IsEnabled() const { return m_isEnabled; }
186 inline bool Enabled() const { return IsEnabled(); }
187 virtual bool OnClose();
188
189 virtual void SetFocus();
190 static wxWindow *FindFocus();
191
192 virtual void AddChild( wxWindow *child );
193 wxList& GetChildren() { return m_children; }
194
195 virtual void RemoveChild( wxWindow *child );
196 void SetReturnCode( int retCode );
197 int GetReturnCode();
198 wxWindow *GetParent() const
199 { return m_parent; }
200 wxWindow *GetGrandParent() const
201 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
202 void SetParent( wxWindow *p )
203 { m_parent = p; }
204 virtual wxWindow *ReParent( wxWindow *newParent );
205
206 wxEvtHandler *GetEventHandler() const;
207 void SetEventHandler( wxEvtHandler *handler );
208 void PushEventHandler( wxEvtHandler *handler );
209 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
210
211 virtual wxValidator *GetValidator();
212 virtual void SetValidator( const wxValidator &validator );
213
214 virtual void SetClientObject( wxClientData *data );
215 virtual wxClientData *GetClientObject();
216
217 virtual void SetClientData( void *data );
218 virtual void *GetClientData();
219
220 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
221 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
222
223 bool IsBeingDeleted();
224
225 void SetId( wxWindowID id );
226 wxWindowID GetId() const;
227
228 void SetCursor( const wxCursor &cursor );
229
230 void WarpPointer(int x, int y);
231
232 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
233 virtual void Clear();
234
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;
240
241 virtual wxColour GetBackgroundColour() const;
242 virtual void SetBackgroundColour( const wxColour &colour );
243 virtual wxColour GetForegroundColour() const;
244 virtual void SetForegroundColour( const wxColour &colour );
245
246 virtual int GetCharHeight() const;
247 virtual int GetCharWidth() const;
248 virtual void GetTextExtent( const wxString& string, int *x, int *y,
249 int *descent = (int *) NULL,
250 int *externalLeading = (int *) NULL,
251 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
252
253 virtual void SetFont( const wxFont &font );
254 virtual wxFont& GetFont() { return m_font; }
255
256 // For backward compatibility
257 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
258 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
259 inline virtual wxFont& GetLabelFont() { return GetFont(); };
260 inline virtual wxFont& GetButtonFont() { return GetFont(); };
261
262 virtual void SetWindowStyleFlag( long flag );
263 virtual long GetWindowStyleFlag() const;
264
265 virtual void CaptureMouse();
266 virtual void ReleaseMouse();
267
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;
273
274 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
275 void OnKeyDown( wxKeyEvent &event );
276
277 virtual bool IsShown() const;
278
279 virtual void Raise();
280 virtual void Lower();
281
282 virtual bool IsRetained();
283 virtual wxWindow *FindWindow( long id );
284 virtual wxWindow *FindWindow( const wxString& name );
285
286 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
287 void SetDoubleClick( bool WXUNUSED(allow) ) {};
288
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();
297
298 virtual bool PopupMenu( wxMenu *menu, int x, int y );
299
300#if wxUSE_DRAG_AND_DROP
301 virtual void SetDropTarget( wxDropTarget *dropTarget );
302 virtual wxDropTarget *GetDropTarget() const;
303#endif
304
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;
311 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
312
313 virtual bool AcceptsFocus() const;
314
315 void UpdateWindowUI();
316
317 // implementation
318
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();
323 virtual bool IsOwnGtkWindow( GdkWindow *window );
324 void ConnectWidget( GtkWidget *widget );
325
326 bool HasVMT();
327
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();
334
335
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;
345#if wxUSE_DRAG_AND_DROP
346 wxDropTarget *m_dropTarget;
347#endif
348 wxWindowID m_windowId;
349 wxCursor *m_cursor;
350 wxFont m_font;
351 wxColour m_backgroundColour;
352 wxColour m_foregroundColour;
353 wxRegion m_updateRegion;
354 long m_windowStyle;
355 bool m_isShown;
356 bool m_isEnabled;
357 wxString m_windowName;
358 wxAcceleratorTable m_acceleratorTable;
359 wxClientData *m_clientObject;
360 void *m_clientData;
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;
369 bool m_isScrolling;
370 bool m_hasVMT;
371 bool m_sizeSet;
372 bool m_resizing;
373 GdkGC *m_scrollGC;
374 GtkStyle *m_widgetStyle;
375 bool m_isStaticBox;
376 bool m_acceptsFocus;
377
378 wxInsertChildFunction m_insertCallback;
379
380public:
381
382 wxLayoutConstraints *m_constraints;
383 wxList *m_constraintsInvolvedIn;
384 wxSizer *m_windowSizer;
385 wxWindow *m_sizerParent;
386 bool m_autoLayout;
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
416private:
417 DECLARE_EVENT_TABLE()
418};
419
420#endif // __GTKWINDOWH__