]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/window.h
Added validation support
[wxWidgets.git] / include / wx / gtk1 / 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 = NULL);
81 virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = 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 virtual void Fit();
99
100 void OnSize( wxSizeEvent &event );
101 void OnIdle( wxIdleEvent& event );
102
103 virtual bool Show( bool show );
104 virtual void Enable( bool enable );
105 virtual void MakeModal( bool modal );
106 virtual bool IsEnabled() const { return m_isEnabled; }
107 inline bool Enabled(void) const { return IsEnabled(); }
108 virtual void SetFocus();
109 virtual bool OnClose();
110
111 virtual void AddChild( wxWindow *child );
112 wxList *GetChildren();
113 virtual void RemoveChild( wxWindow *child );
114 void SetReturnCode( int retCode );
115 int GetReturnCode();
116 wxWindow *GetParent();
117
118 wxEvtHandler *GetEventHandler();
119 void SetEventHandler( wxEvtHandler *handler );
120 void PushEventHandler( wxEvtHandler *handler );
121 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
122
123 virtual wxValidator *GetValidator();
124 virtual void SetValidator( const wxValidator &validator );
125
126 bool IsBeingDeleted();
127
128 void SetId( wxWindowID id );
129 wxWindowID GetId();
130
131 void SetCursor( const wxCursor &cursor );
132
133 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = NULL );
134 virtual void Clear();
135 virtual bool IsExposed( long x, long y );
136 virtual bool IsExposed( long x, long y, long width, long height );
137
138 virtual wxColour GetBackgroundColour() const;
139 virtual void SetBackgroundColour( const wxColour &colour );
140 virtual wxColour GetForegroundColour() const;
141 virtual void SetForegroundColour( const wxColour &colour );
142
143 virtual void SetDefaultBackgroundColour( const wxColour& col )
144 { m_defaultBackgroundColour = col; };
145 virtual wxColour GetDefaultBackgroundColour() const
146 { return m_defaultBackgroundColour; };
147 virtual void SetDefaultForegroundColour( const wxColour& col )
148 { m_defaultForegroundColour = col; };
149 virtual wxColour GetDefaultForegroundColour() const
150 { return m_defaultForegroundColour; };
151
152 virtual void SetFont( const wxFont &font );
153 virtual wxFont *GetFont();
154 // For backward compatibility
155 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
156 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
157 inline virtual wxFont *GetLabelFont() { return GetFont(); };
158 inline virtual wxFont *GetButtonFont() { return GetFont(); };
159 virtual void SetWindowStyleFlag( long flag );
160 virtual long GetWindowStyleFlag() const;
161 virtual void CaptureMouse();
162 virtual void ReleaseMouse();
163 virtual void SetTitle( const wxString &title );
164 virtual wxString GetTitle() const;
165 virtual void SetName( const wxString &name );
166 virtual wxString GetName() const;
167 virtual wxString GetLabel() const;
168
169 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
170
171 virtual bool IsShown() const;
172
173 virtual void Raise(void);
174 virtual void Lower(void);
175
176 virtual bool IsRetained();
177 virtual wxWindow *FindWindow( long id );
178 virtual wxWindow *FindWindow( const wxString& name );
179 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
180 void SetDoubleClick( bool WXUNUSED(allow) ) {};
181 virtual void ClientToScreen( int *x, int *y );
182 virtual void ScreenToClient( int *x, int *y );
183
184 virtual bool Validate();
185 virtual bool TransferDataToWindow();
186 virtual bool TransferDataFromWindow();
187 void OnInitDialog( wxInitDialogEvent &event );
188 virtual void InitDialog();
189
190 virtual bool PopupMenu( wxMenu *menu, int x, int y );
191
192 virtual void SetDropTarget( wxDropTarget *dropTarget );
193 virtual wxDropTarget *GetDropTarget() const;
194
195 //private:
196 virtual GtkWidget* GetConnectWidget(void);
197 virtual bool IsOwnGtkWindow( GdkWindow *window );
198
199 public:
200 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
201 int range, bool refresh = TRUE );
202 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
203 virtual int GetScrollPos( int orient ) const;
204 virtual int GetScrollThumb( int orient ) const;
205 virtual int GetScrollRange( int orient ) const;
206 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = NULL );
207
208 // return FALSE from here if the window doesn't want the focus
209 virtual bool AcceptsFocus() const;
210
211 // update the UI state (called from OnIdle)
212 void UpdateWindowUI();
213
214
215 public: // cannot get private going yet
216
217 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
218 const wxSize &size, long style, const wxString &name );
219 void PostCreation();
220 bool HasVMT();
221 virtual void ImplementSetSize();
222 virtual void ImplementSetPosition();
223 void GetDrawingOffset( long *x, long *y );
224
225 wxWindow *m_parent;
226 wxList m_children;
227 int m_x,m_y;
228 int m_width,m_height;
229 int m_retCode;
230 wxEvtHandler *m_eventHandler;
231 wxValidator *m_windowValidator;
232 wxDropTarget *m_pDropTarget;
233 wxWindowID m_windowId;
234 wxCursor *m_cursor;
235 wxFont m_font;
236 wxColour m_backgroundColour;
237 wxColour m_defaultBackgroundColour;
238 wxColour m_foregroundColour ;
239 wxColour m_defaultForegroundColour;
240 wxRegion m_updateRegion;
241 long m_windowStyle;
242 bool m_isShown;
243 bool m_isEnabled;
244 wxString m_windowName;
245 long m_drawingOffsetX,m_drawingOffsetY;
246
247 GtkWidget *m_widget;
248 GtkWidget *m_wxwindow;
249 GtkAdjustment *m_hAdjust,*m_vAdjust;
250 float m_oldHorizontalPos;
251 float m_oldVerticalPos;
252 bool m_needParent;
253 bool m_hasScrolling;
254 bool m_hasVMT;
255 bool m_sizeSet;
256 bool m_resizing;
257
258 public: // Layout section
259
260 wxLayoutConstraints * m_constraints;
261 wxList * m_constraintsInvolvedIn;
262 wxSizer * m_windowSizer;
263 wxWindow * m_sizerParent;
264 bool m_autoLayout;
265
266 wxLayoutConstraints *GetConstraints() const;
267 void SetConstraints( wxLayoutConstraints *constraints );
268 void SetAutoLayout( bool autoLayout );
269 bool GetAutoLayout() const;
270 bool Layout();
271 void SetSizer( wxSizer *sizer );
272 wxSizer *GetSizer() const;
273 void SetSizerParent( wxWindow *win );
274 wxWindow *GetSizerParent() const;
275 void UnsetConstraints(wxLayoutConstraints *c);
276 inline wxList *GetConstraintsInvolvedIn() const ;
277 void AddConstraintReference(wxWindow *otherWin);
278 void RemoveConstraintReference(wxWindow *otherWin);
279 void DeleteRelatedConstraints();
280 virtual void ResetConstraints();
281 virtual void SetConstraintSizes(bool recurse = TRUE);
282 virtual bool LayoutPhase1(int *noChanges);
283 virtual bool LayoutPhase2(int *noChanges);
284 virtual bool DoPhase(int);
285 virtual void TransformSizerToActual(int *x, int *y) const ;
286 virtual void SizerSetSize(int x, int y, int w, int h);
287 virtual void SizerMove(int x, int y);
288 virtual void SetSizeConstraint(int x, int y, int w, int h);
289 virtual void MoveConstraint(int x, int y);
290 virtual void GetSizeConstraint(int *w, int *h) const ;
291 virtual void GetClientSizeConstraint(int *w, int *h) const ;
292 virtual void GetPositionConstraint(int *x, int *y) const ;
293
294 DECLARE_DYNAMIC_CLASS(wxWindow)
295 DECLARE_EVENT_TABLE()
296 };
297
298 #endif // __GTKWINDOWH__