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