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