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