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