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