]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/window.h
Added wxSashWindow, wxSashLayoutWindow, wxLayoutAlgorithm classes and sample
[wxWidgets.git] / include / wx / gtk / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11
12 #ifndef __GTKWINDOWH__
13 #define __GTKWINDOWH__
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/list.h"
22 #include "wx/event.h"
23 #include "wx/validate.h"
24 #include "wx/cursor.h"
25 #include "wx/font.h"
26 #include "wx/dc.h"
27 #include "wx/region.h"
28 #include "wx/dnd.h"
29 #include "wx/accel.h"
30
31 //-----------------------------------------------------------------------------
32 // global data
33 //-----------------------------------------------------------------------------
34
35 extern const char *wxFrameNameStr;
36 extern wxList wxTopLevelWindows;
37
38 //-----------------------------------------------------------------------------
39 // classes
40 //-----------------------------------------------------------------------------
41
42 class wxLayoutConstraints;
43 class wxSizer;
44 class wxResourceTable;
45 class wxItemResource;
46
47 class wxWindow;
48 class wxCanvas;
49
50 //-----------------------------------------------------------------------------
51 // global data
52 //-----------------------------------------------------------------------------
53
54 extern const char *wxPanelNameStr;
55 extern const wxSize wxDefaultSize;
56 extern const wxPoint wxDefaultPosition;
57
58 //-----------------------------------------------------------------------------
59 // wxWindow
60 //-----------------------------------------------------------------------------
61
62 class wxWindow: public wxEvtHandler
63 {
64 public:
65 wxWindow();
66 inline wxWindow(wxWindow *parent, wxWindowID id,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = 0,
70 const wxString& name = wxPanelNameStr)
71 {
72 Create(parent, id, pos, size, style, name);
73 }
74 bool Create(wxWindow *parent, wxWindowID id,
75 const wxPoint& pos = wxDefaultPosition,
76 const wxSize& size = wxDefaultSize,
77 long style = 0,
78 const wxString& name = wxPanelNameStr);
79 virtual ~wxWindow();
80
81 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
82 const wxResourceTable *table = (const wxResourceTable *) NULL);
83 virtual wxControl *CreateItem( const wxItemResource *childResource,
84 const wxResourceTable *table = (const wxResourceTable *) NULL);
85
86 bool Close( bool force = FALSE );
87 virtual bool Destroy();
88 virtual bool DestroyChildren();
89
90 virtual void PrepareDC( wxDC &dc );
91
92 virtual void SetSize( int x, int y, int width, int height,
93 int sizeFlags = wxSIZE_AUTO );
94 virtual void SetSize( int width, int height );
95 virtual void Move( int x, int y );
96 virtual void GetSize( int *width, int *height ) const;
97 virtual void SetClientSize( int const width, int const height );
98 virtual void GetClientSize( int *width, int *height ) const;
99 virtual void GetPosition( int *x, int *y ) const;
100 virtual void Centre( int direction = wxHORIZONTAL );
101 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
102 virtual void Fit();
103
104 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
105
106 void OnSize( wxSizeEvent &event );
107 void OnIdle( wxIdleEvent& event );
108
109 virtual bool Show( bool show );
110 virtual void Enable( bool enable );
111 virtual void MakeModal( bool modal );
112 virtual bool IsEnabled() const { return m_isEnabled; }
113 inline bool Enabled(void) const { return IsEnabled(); }
114 virtual void SetFocus();
115 virtual bool OnClose();
116
117 virtual void AddChild( wxWindow *child );
118 wxList *GetChildren();
119 virtual void RemoveChild( wxWindow *child );
120 void SetReturnCode( int retCode );
121 int GetReturnCode();
122 wxWindow *GetParent() const
123 { return m_parent; }
124 wxWindow *GetGrandParent(void) const
125 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
126 void SetParent( wxWindow *p )
127 { m_parent = p; }
128
129 wxEvtHandler *GetEventHandler();
130 void SetEventHandler( wxEvtHandler *handler );
131 void PushEventHandler( wxEvtHandler *handler );
132 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
133
134 virtual wxValidator *GetValidator();
135 virtual void SetValidator( const wxValidator &validator );
136
137 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
138 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
139
140 bool IsBeingDeleted();
141
142 void SetId( wxWindowID id );
143 wxWindowID GetId();
144
145 void SetCursor( const wxCursor &cursor );
146
147 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
148 virtual void Clear();
149
150 virtual wxRegion GetUpdateRegion() const;
151 virtual bool IsExposed(int x, int y) const;
152 virtual bool IsExposed(int x, int y, int w, int h) const;
153 virtual bool IsExposed(const wxPoint& pt) const;
154 virtual bool IsExposed(const wxRect& rect) const;
155
156 virtual wxColour GetBackgroundColour() const;
157 virtual void SetBackgroundColour( const wxColour &colour );
158 virtual wxColour GetForegroundColour() const;
159 virtual void SetForegroundColour( const wxColour &colour );
160
161 virtual int GetCharHeight(void) const;
162 virtual int GetCharWidth(void) const;
163 virtual void GetTextExtent( const wxString& string, int *x, int *y,
164 int *descent = (int *) NULL,
165 int *externalLeading = (int *) NULL,
166 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
167
168 virtual void SetDefaultBackgroundColour( const wxColour& col )
169 { m_defaultBackgroundColour = col; }
170 virtual wxColour GetDefaultBackgroundColour() const
171 { return m_defaultBackgroundColour; }
172 virtual void SetDefaultForegroundColour( const wxColour& col )
173 { m_defaultForegroundColour = col; }
174 virtual wxColour GetDefaultForegroundColour() const
175 { return m_defaultForegroundColour; }
176
177 virtual void SetFont( const wxFont &font );
178 virtual wxFont *GetFont();
179 // For backward compatibility
180 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
181 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
182 inline virtual wxFont *GetLabelFont() { return GetFont(); };
183 inline virtual wxFont *GetButtonFont() { return GetFont(); };
184 virtual void SetWindowStyleFlag( long flag );
185 virtual long GetWindowStyleFlag() const;
186 virtual void CaptureMouse();
187 virtual void ReleaseMouse();
188 virtual void SetTitle( const wxString &title );
189 virtual wxString GetTitle() const;
190 virtual void SetName( const wxString &name );
191 virtual wxString GetName() const;
192 virtual wxString GetLabel() const;
193
194 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
195
196 virtual bool IsShown() const;
197
198 virtual void Raise(void);
199 virtual void Lower(void);
200
201 virtual bool IsRetained();
202 virtual wxWindow *FindWindow( long id );
203 virtual wxWindow *FindWindow( const wxString& name );
204 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
205 void SetDoubleClick( bool WXUNUSED(allow) ) {};
206 virtual void ClientToScreen( int *x, int *y );
207 virtual void ScreenToClient( int *x, int *y );
208
209 virtual bool Validate();
210 virtual bool TransferDataToWindow();
211 virtual bool TransferDataFromWindow();
212 void OnInitDialog( wxInitDialogEvent &event );
213 virtual void InitDialog();
214
215 virtual bool PopupMenu( wxMenu *menu, int x, int y );
216
217 virtual void SetDropTarget( wxDropTarget *dropTarget );
218 virtual wxDropTarget *GetDropTarget() const;
219
220 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
221 int range, bool refresh = TRUE );
222 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
223 virtual int GetScrollPos( int orient ) const;
224 virtual int GetScrollThumb( int orient ) const;
225 virtual int GetScrollRange( int orient ) const;
226 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
227
228 virtual bool AcceptsFocus() const;
229 void UpdateWindowUI();
230
231 public: // cannot get private going yet
232
233 virtual GtkWidget* GetConnectWidget(void);
234 virtual bool IsOwnGtkWindow( GdkWindow *window );
235
236 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
237 const wxSize &size, long style, const wxString &name );
238 void PostCreation();
239 bool HasVMT();
240 virtual void ImplementSetSize();
241 virtual void ImplementSetPosition();
242
243 wxWindow *m_parent;
244 wxList m_children;
245 int m_x,m_y;
246 int m_width,m_height;
247 int m_minWidth,m_minHeight;
248 int m_maxWidth,m_maxHeight;
249 int m_retCode;
250 wxEvtHandler *m_eventHandler;
251 wxValidator *m_windowValidator;
252 wxDropTarget *m_pDropTarget;
253 wxWindowID m_windowId;
254 wxCursor *m_cursor;
255 wxFont m_font;
256 wxColour m_backgroundColour;
257 wxColour m_defaultBackgroundColour;
258 wxColour m_foregroundColour ;
259 wxColour m_defaultForegroundColour;
260 wxRegion m_updateRegion;
261 long m_windowStyle;
262 bool m_isShown;
263 bool m_isEnabled;
264 wxString m_windowName;
265 wxAcceleratorTable m_acceleratorTable;
266
267 GtkWidget *m_widget;
268 GtkWidget *m_wxwindow;
269 GtkAdjustment *m_hAdjust,*m_vAdjust;
270 float m_oldHorizontalPos;
271 float m_oldVerticalPos;
272 bool m_needParent;
273 bool m_hasScrolling;
274 bool m_hasOwnStyle;
275 bool m_hasVMT;
276 bool m_sizeSet;
277 bool m_resizing;
278
279 public:
280
281 wxLayoutConstraints *m_constraints;
282 wxList *m_constraintsInvolvedIn;
283 wxSizer *m_windowSizer;
284 wxWindow *m_sizerParent;
285 bool m_autoLayout;
286
287 wxLayoutConstraints *GetConstraints() const;
288 void SetConstraints( wxLayoutConstraints *constraints );
289 void SetAutoLayout( bool autoLayout );
290 bool GetAutoLayout() const;
291 bool Layout();
292 void SetSizer( wxSizer *sizer );
293 wxSizer *GetSizer() const;
294 void SetSizerParent( wxWindow *win );
295 wxWindow *GetSizerParent() const;
296 void UnsetConstraints(wxLayoutConstraints *c);
297 inline wxList *GetConstraintsInvolvedIn() const ;
298 void AddConstraintReference(wxWindow *otherWin);
299 void RemoveConstraintReference(wxWindow *otherWin);
300 void DeleteRelatedConstraints();
301 virtual void ResetConstraints();
302 virtual void SetConstraintSizes(bool recurse = TRUE);
303 virtual bool LayoutPhase1(int *noChanges);
304 virtual bool LayoutPhase2(int *noChanges);
305 virtual bool DoPhase(int);
306 virtual void TransformSizerToActual(int *x, int *y) const ;
307 virtual void SizerSetSize(int x, int y, int w, int h);
308 virtual void SizerMove(int x, int y);
309 virtual void SetSizeConstraint(int x, int y, int w, int h);
310 virtual void MoveConstraint(int x, int y);
311 virtual void GetSizeConstraint(int *w, int *h) const ;
312 virtual void GetClientSizeConstraint(int *w, int *h) const ;
313 virtual void GetPositionConstraint(int *x, int *y) const ;
314
315 DECLARE_DYNAMIC_CLASS(wxWindow)
316 DECLARE_EVENT_TABLE()
317 };
318
319 #endif // __GTKWINDOWH__