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