]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/window.h
New configure
[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
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 wxWindow;
47 class wxCanvas;
48
49 //-----------------------------------------------------------------------------
50 // global data
51 //-----------------------------------------------------------------------------
52
53 extern const char *wxPanelNameStr;
54 extern const wxSize wxDefaultSize;
55 extern const wxPoint wxDefaultPosition;
56
57 //-----------------------------------------------------------------------------
58 // wxWindow
59 //-----------------------------------------------------------------------------
60
61 class wxWindow: public wxEvtHandler
62 {
63 public:
64 wxWindow();
65 inline wxWindow(wxWindow *parent, wxWindowID id,
66 const wxPoint& pos = wxDefaultPosition,
67 const wxSize& size = wxDefaultSize,
68 long style = 0,
69 const wxString& name = wxPanelNameStr)
70 {
71 Create(parent, id, pos, size, style, name);
72 }
73 bool Create(wxWindow *parent, wxWindowID id,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize,
76 long style = 0,
77 const wxString& name = wxPanelNameStr);
78 virtual ~wxWindow();
79
80 virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = (const wxResourceTable *) NULL);
81 virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = (const wxResourceTable *) NULL);
82
83 bool Close( bool force = FALSE );
84 virtual bool Destroy();
85 virtual bool DestroyChildren();
86
87 virtual void PrepareDC( wxDC &dc );
88
89 virtual void SetSize( int x, int y, int width, int height,
90 int sizeFlags = wxSIZE_AUTO );
91 virtual void SetSize( int width, int height );
92 virtual void Move( int x, int y );
93 virtual void GetSize( int *width, int *height ) const;
94 virtual void SetClientSize( int const width, int const height );
95 virtual void GetClientSize( int *width, int *height ) const;
96 virtual void GetPosition( int *x, int *y ) const;
97 virtual void Centre( int direction = wxHORIZONTAL );
98 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
99 virtual void Fit();
100
101 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
102
103 void OnSize( wxSizeEvent &event );
104 void OnIdle( wxIdleEvent& event );
105
106 virtual bool Show( bool show );
107 virtual void Enable( bool enable );
108 virtual void MakeModal( bool modal );
109 virtual bool IsEnabled() const { return m_isEnabled; }
110 inline bool Enabled(void) const { return IsEnabled(); }
111 virtual void SetFocus();
112 virtual bool OnClose();
113
114 virtual void AddChild( wxWindow *child );
115 wxList *GetChildren();
116 virtual void RemoveChild( wxWindow *child );
117 void SetReturnCode( int retCode );
118 int GetReturnCode();
119 wxWindow *GetParent() const
120 { return m_parent; }
121 wxWindow *GetGrandParent(void) const
122 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
123 void SetParent( wxWindow *p )
124 { m_parent = p; }
125
126 wxEvtHandler *GetEventHandler();
127 void SetEventHandler( wxEvtHandler *handler );
128 void PushEventHandler( wxEvtHandler *handler );
129 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
130
131 virtual wxValidator *GetValidator();
132 virtual void SetValidator( const wxValidator &validator );
133
134 bool IsBeingDeleted();
135
136 void SetId( wxWindowID id );
137 wxWindowID GetId();
138
139 void SetCursor( const wxCursor &cursor );
140
141 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
142 virtual void Clear();
143
144 virtual wxRegion GetUpdateRegion() const;
145 virtual bool IsExposed(int x, int y) const;
146 virtual bool IsExposed(int x, int y, int w, int h) const;
147 virtual bool IsExposed(const wxPoint& pt) const;
148 virtual bool IsExposed(const wxRect& rect) const;
149
150 virtual wxColour GetBackgroundColour() const;
151 virtual void SetBackgroundColour( const wxColour &colour );
152 virtual wxColour GetForegroundColour() const;
153 virtual void SetForegroundColour( const wxColour &colour );
154
155 virtual int GetCharHeight(void) const;
156 virtual int GetCharWidth(void) const;
157 virtual void GetTextExtent( const wxString& string, int *x, int *y,
158 int *descent = (int *) NULL,
159 int *externalLeading = (int *) NULL,
160 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
161
162 virtual void SetDefaultBackgroundColour( const wxColour& col )
163 { m_defaultBackgroundColour = col; }
164 virtual wxColour GetDefaultBackgroundColour() const
165 { return m_defaultBackgroundColour; }
166 virtual void SetDefaultForegroundColour( const wxColour& col )
167 { m_defaultForegroundColour = col; }
168 virtual wxColour GetDefaultForegroundColour() const
169 { return m_defaultForegroundColour; }
170
171 virtual void SetFont( const wxFont &font );
172 virtual wxFont *GetFont();
173 // For backward compatibility
174 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
175 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
176 inline virtual wxFont *GetLabelFont() { return GetFont(); };
177 inline virtual wxFont *GetButtonFont() { return GetFont(); };
178 virtual void SetWindowStyleFlag( long flag );
179 virtual long GetWindowStyleFlag() const;
180 virtual void CaptureMouse();
181 virtual void ReleaseMouse();
182 virtual void SetTitle( const wxString &title );
183 virtual wxString GetTitle() const;
184 virtual void SetName( const wxString &name );
185 virtual wxString GetName() const;
186 virtual wxString GetLabel() const;
187
188 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
189
190 virtual bool IsShown() const;
191
192 virtual void Raise(void);
193 virtual void Lower(void);
194
195 virtual bool IsRetained();
196 virtual wxWindow *FindWindow( long id );
197 virtual wxWindow *FindWindow( const wxString& name );
198 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
199 void SetDoubleClick( bool WXUNUSED(allow) ) {};
200 virtual void ClientToScreen( int *x, int *y );
201 virtual void ScreenToClient( int *x, int *y );
202
203 virtual bool Validate();
204 virtual bool TransferDataToWindow();
205 virtual bool TransferDataFromWindow();
206 void OnInitDialog( wxInitDialogEvent &event );
207 virtual void InitDialog();
208
209 virtual bool PopupMenu( wxMenu *menu, int x, int y );
210
211 virtual void SetDropTarget( wxDropTarget *dropTarget );
212 virtual wxDropTarget *GetDropTarget() const;
213
214 //private:
215 virtual GtkWidget* GetConnectWidget(void);
216 virtual bool IsOwnGtkWindow( GdkWindow *window );
217
218 public:
219 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
220 int range, bool refresh = TRUE );
221 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
222 virtual int GetScrollPos( int orient ) const;
223 virtual int GetScrollThumb( int orient ) const;
224 virtual int GetScrollRange( int orient ) const;
225 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
226
227 // return FALSE from here if the window doesn't want the focus
228 virtual bool AcceptsFocus() const;
229
230 // update the UI state (called from OnIdle)
231 void UpdateWindowUI();
232
233
234 public: // cannot get private going yet
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
266 GtkWidget *m_widget;
267 GtkWidget *m_wxwindow;
268 GtkAdjustment *m_hAdjust,*m_vAdjust;
269 float m_oldHorizontalPos;
270 float m_oldVerticalPos;
271 bool m_needParent;
272 bool m_hasScrolling;
273 bool m_hasVMT;
274 bool m_sizeSet;
275 bool m_resizing;
276
277 public: // Layout section
278
279 wxLayoutConstraints * m_constraints;
280 wxList * m_constraintsInvolvedIn;
281 wxSizer * m_windowSizer;
282 wxWindow * m_sizerParent;
283 bool m_autoLayout;
284
285 wxLayoutConstraints *GetConstraints() const;
286 void SetConstraints( wxLayoutConstraints *constraints );
287 void SetAutoLayout( bool autoLayout );
288 bool GetAutoLayout() const;
289 bool Layout();
290 void SetSizer( wxSizer *sizer );
291 wxSizer *GetSizer() const;
292 void SetSizerParent( wxWindow *win );
293 wxWindow *GetSizerParent() const;
294 void UnsetConstraints(wxLayoutConstraints *c);
295 inline wxList *GetConstraintsInvolvedIn() const ;
296 void AddConstraintReference(wxWindow *otherWin);
297 void RemoveConstraintReference(wxWindow *otherWin);
298 void DeleteRelatedConstraints();
299 virtual void ResetConstraints();
300 virtual void SetConstraintSizes(bool recurse = TRUE);
301 virtual bool LayoutPhase1(int *noChanges);
302 virtual bool LayoutPhase2(int *noChanges);
303 virtual bool DoPhase(int);
304 virtual void TransformSizerToActual(int *x, int *y) const ;
305 virtual void SizerSetSize(int x, int y, int w, int h);
306 virtual void SizerMove(int x, int y);
307 virtual void SetSizeConstraint(int x, int y, int w, int h);
308 virtual void MoveConstraint(int x, int y);
309 virtual void GetSizeConstraint(int *w, int *h) const ;
310 virtual void GetClientSizeConstraint(int *w, int *h) const ;
311 virtual void GetPositionConstraint(int *x, int *y) const ;
312
313 DECLARE_DYNAMIC_CLASS(wxWindow)
314 DECLARE_EVENT_TABLE()
315 };
316
317 #endif // __GTKWINDOWH__