]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: window.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | ||
11 | #ifndef __GTKWINDOWH__ | |
12 | #define __GTKWINDOWH__ | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface | |
16 | #endif | |
17 | ||
18 | #include "wx/defs.h" | |
19 | #include "wx/object.h" | |
20 | #include "wx/list.h" | |
21 | #include "wx/event.h" | |
22 | #include "wx/validate.h" | |
23 | #include "wx/cursor.h" | |
24 | #include "wx/font.h" | |
25 | #include "wx/region.h" | |
26 | #include "wx/accel.h" | |
27 | ||
28 | //----------------------------------------------------------------------------- | |
29 | // global data | |
30 | //----------------------------------------------------------------------------- | |
31 | ||
32 | extern const char *wxFrameNameStr; | |
33 | extern wxList wxTopLevelWindows; | |
34 | ||
35 | //----------------------------------------------------------------------------- | |
36 | // global function | |
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | wxWindow* wxGetActiveWindow(); | |
40 | ||
41 | //----------------------------------------------------------------------------- | |
42 | // classes | |
43 | //----------------------------------------------------------------------------- | |
44 | ||
45 | class wxLayoutConstraints; | |
46 | class wxSizer; | |
47 | class wxDC; | |
48 | class wxClientData; | |
49 | class wxVoidClientData; | |
50 | class wxWindow; | |
51 | #if wxUSE_WX_RESOURCES | |
52 | class wxResourceTable; | |
53 | class wxItemResource; | |
54 | #endif | |
55 | #if wxUSE_DRAG_AND_DROP | |
56 | class wxDropTarget; | |
57 | #endif | |
58 | ||
59 | //----------------------------------------------------------------------------- | |
60 | // callback definition for inserting a window (internal) | |
61 | //----------------------------------------------------------------------------- | |
62 | ||
63 | typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* ); | |
64 | ||
65 | //----------------------------------------------------------------------------- | |
66 | // global data | |
67 | //----------------------------------------------------------------------------- | |
68 | ||
69 | extern const char *wxPanelNameStr; | |
70 | extern const wxSize wxDefaultSize; | |
71 | extern const wxPoint wxDefaultPosition; | |
72 | ||
73 | //----------------------------------------------------------------------------- | |
74 | // wxClientData | |
75 | //----------------------------------------------------------------------------- | |
76 | ||
77 | class wxClientData | |
78 | { | |
79 | public: | |
80 | wxClientData() { } | |
81 | virtual ~wxClientData() { } | |
82 | }; | |
83 | ||
84 | //----------------------------------------------------------------------------- | |
85 | // wxStringClientData | |
86 | //----------------------------------------------------------------------------- | |
87 | ||
88 | class wxStringClientData: public wxClientData | |
89 | { | |
90 | public: | |
91 | wxStringClientData() { } | |
92 | wxStringClientData( wxString &data ) { m_data = data; } | |
93 | void SetData( wxString &data ) { m_data = data; } | |
94 | wxString GetData() const { return m_data; } | |
95 | ||
96 | private: | |
97 | wxString m_data; | |
98 | }; | |
99 | ||
100 | //----------------------------------------------------------------------------- | |
101 | // (debug) | |
102 | //----------------------------------------------------------------------------- | |
103 | ||
104 | #ifdef __WXDEBUG__ | |
105 | ||
106 | void debug_focus_in( GtkWidget* widget, const char* name, const char* window ); | |
107 | ||
108 | #endif | |
109 | ||
110 | //----------------------------------------------------------------------------- | |
111 | // wxWindow | |
112 | //----------------------------------------------------------------------------- | |
113 | ||
114 | class wxWindow: public wxEvtHandler | |
115 | { | |
116 | DECLARE_DYNAMIC_CLASS(wxWindow) | |
117 | ||
118 | public: | |
119 | wxWindow(); | |
120 | wxWindow(wxWindow *parent, wxWindowID id, | |
121 | const wxPoint& pos = wxDefaultPosition, | |
122 | const wxSize& size = wxDefaultSize, | |
123 | long style = 0, | |
124 | const wxString& name = wxPanelNameStr); | |
125 | bool Create(wxWindow *parent, wxWindowID id, | |
126 | const wxPoint& pos = wxDefaultPosition, | |
127 | const wxSize& size = wxDefaultSize, | |
128 | long style = 0, | |
129 | const wxString& name = wxPanelNameStr); | |
130 | virtual ~wxWindow(); | |
131 | ||
132 | #if wxUSE_WX_RESOURCES | |
133 | virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, | |
134 | const wxResourceTable *table = (const wxResourceTable *) NULL); | |
135 | virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, | |
136 | const wxResourceTable *table = (const wxResourceTable *) NULL); | |
137 | #endif | |
138 | ||
139 | bool Close( bool force = FALSE ); | |
140 | virtual bool Destroy(); | |
141 | virtual bool DestroyChildren(); | |
142 | ||
143 | virtual void PrepareDC( wxDC &dc ); | |
144 | ||
145 | virtual void SetSize( int x, int y, int width, int height, | |
146 | int sizeFlags = wxSIZE_AUTO ); | |
147 | virtual void SetSize( int width, int height ); | |
148 | ||
149 | virtual void Move( int x, int y ); | |
150 | ||
151 | virtual void GetSize( int *width, int *height ) const; | |
152 | wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } | |
153 | ||
154 | virtual void SetClientSize( int const width, int const height ); | |
155 | ||
156 | virtual void GetClientSize( int *width, int *height ) const; | |
157 | wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } | |
158 | ||
159 | virtual void GetPosition( int *x, int *y ) const; | |
160 | wxPoint GetPosition() const { int w, h; GetPosition(& w, & h); return wxPoint(w, h); } | |
161 | ||
162 | wxRect GetRect() const | |
163 | { int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); } | |
164 | ||
165 | virtual void Centre( int direction = wxHORIZONTAL ); | |
166 | inline void Center(int direction = wxHORIZONTAL) { Centre(direction); } | |
167 | virtual void Fit(); | |
168 | ||
169 | virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 ); | |
170 | ||
171 | // Dialog units translations. Implemented in wincmn.cpp. | |
172 | wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; | |
173 | wxPoint ConvertDialogToPixels(const wxPoint& pt) ; | |
174 | inline wxSize ConvertPixelsToDialog(const wxSize& sz) | |
175 | { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } | |
176 | inline wxSize ConvertDialogToPixels(const wxSize& sz) | |
177 | { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } | |
178 | ||
179 | void OnSize( wxSizeEvent &event ); | |
180 | ||
181 | virtual bool Show( bool show ); | |
182 | virtual void Enable( bool enable ); | |
183 | virtual void MakeModal( bool modal ); | |
184 | virtual bool IsEnabled() const { return m_isEnabled; } | |
185 | inline bool Enabled() const { return IsEnabled(); } | |
186 | virtual bool OnClose(); | |
187 | ||
188 | virtual void SetFocus(); | |
189 | static wxWindow *FindFocus(); | |
190 | ||
191 | virtual void AddChild( wxWindow *child ); | |
192 | wxList& GetChildren() { return m_children; } | |
193 | ||
194 | virtual void RemoveChild( wxWindow *child ); | |
195 | void SetReturnCode( int retCode ); | |
196 | int GetReturnCode(); | |
197 | wxWindow *GetParent() const | |
198 | { return m_parent; } | |
199 | wxWindow *GetGrandParent() const | |
200 | { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); } | |
201 | void SetParent( wxWindow *p ) | |
202 | { m_parent = p; } | |
203 | virtual wxWindow *ReParent( wxWindow *newParent ); | |
204 | ||
205 | wxEvtHandler *GetEventHandler() const; | |
206 | void SetEventHandler( wxEvtHandler *handler ); | |
207 | void PushEventHandler( wxEvtHandler *handler ); | |
208 | wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); | |
209 | ||
210 | virtual wxValidator *GetValidator(); | |
211 | virtual void SetValidator( const wxValidator &validator ); | |
212 | ||
213 | virtual void SetClientObject( wxClientData *data ); | |
214 | virtual wxClientData *GetClientObject(); | |
215 | ||
216 | virtual void SetClientData( void *data ); | |
217 | virtual void *GetClientData(); | |
218 | ||
219 | virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); | |
220 | virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } | |
221 | ||
222 | bool IsBeingDeleted(); | |
223 | ||
224 | void SetId( wxWindowID id ); | |
225 | wxWindowID GetId() const; | |
226 | ||
227 | void SetCursor( const wxCursor &cursor ); | |
228 | ||
229 | void WarpPointer(int x, int y); | |
230 | ||
231 | virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); | |
232 | virtual void Clear(); | |
233 | ||
234 | virtual wxRegion GetUpdateRegion() const; | |
235 | virtual bool IsExposed(int x, int y) const; | |
236 | virtual bool IsExposed(int x, int y, int w, int h) const; | |
237 | virtual bool IsExposed(const wxPoint& pt) const; | |
238 | virtual bool IsExposed(const wxRect& rect) const; | |
239 | ||
240 | virtual wxColour GetBackgroundColour() const; | |
241 | virtual void SetBackgroundColour( const wxColour &colour ); | |
242 | virtual wxColour GetForegroundColour() const; | |
243 | virtual void SetForegroundColour( const wxColour &colour ); | |
244 | ||
245 | virtual int GetCharHeight() const; | |
246 | virtual int GetCharWidth() const; | |
247 | virtual void GetTextExtent( const wxString& string, int *x, int *y, | |
248 | int *descent = (int *) NULL, | |
249 | int *externalLeading = (int *) NULL, | |
250 | const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const; | |
251 | ||
252 | virtual void SetFont( const wxFont &font ); | |
253 | virtual wxFont& GetFont() { return m_font; } | |
254 | ||
255 | // For backward compatibility | |
256 | inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } | |
257 | inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } | |
258 | inline virtual wxFont& GetLabelFont() { return GetFont(); }; | |
259 | inline virtual wxFont& GetButtonFont() { return GetFont(); }; | |
260 | ||
261 | virtual void SetWindowStyleFlag( long flag ); | |
262 | virtual long GetWindowStyleFlag() const; | |
263 | ||
264 | virtual void CaptureMouse(); | |
265 | virtual void ReleaseMouse(); | |
266 | ||
267 | virtual void SetTitle( const wxString &title ); | |
268 | virtual wxString GetTitle() const; | |
269 | virtual void SetName( const wxString &name ); | |
270 | virtual wxString GetName() const; | |
271 | virtual wxString GetLabel() const; | |
272 | ||
273 | void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {}; | |
274 | void OnKeyDown( wxKeyEvent &event ); | |
275 | ||
276 | virtual bool IsShown() const; | |
277 | ||
278 | virtual void Raise(); | |
279 | virtual void Lower(); | |
280 | ||
281 | virtual bool IsRetained(); | |
282 | virtual wxWindow *FindWindow( long id ); | |
283 | virtual wxWindow *FindWindow( const wxString& name ); | |
284 | ||
285 | void AllowDoubleClick( bool WXUNUSED(allow) ) {}; | |
286 | void SetDoubleClick( bool WXUNUSED(allow) ) {}; | |
287 | ||
288 | virtual void ClientToScreen( int *x, int *y ); | |
289 | virtual void ScreenToClient( int *x, int *y ); | |
290 | ||
291 | virtual bool Validate(); | |
292 | virtual bool TransferDataToWindow(); | |
293 | virtual bool TransferDataFromWindow(); | |
294 | void OnInitDialog( wxInitDialogEvent &event ); | |
295 | virtual void InitDialog(); | |
296 | ||
297 | virtual bool PopupMenu( wxMenu *menu, int x, int y ); | |
298 | ||
299 | #if wxUSE_DRAG_AND_DROP | |
300 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
301 | virtual wxDropTarget *GetDropTarget() const; | |
302 | #endif | |
303 | ||
304 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
305 | int range, bool refresh = TRUE ); | |
306 | virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); | |
307 | virtual int GetScrollPos( int orient ) const; | |
308 | virtual int GetScrollThumb( int orient ) const; | |
309 | virtual int GetScrollRange( int orient ) const; | |
310 | virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); | |
311 | ||
312 | virtual bool AcceptsFocus() const; | |
313 | ||
314 | void UpdateWindowUI(); | |
315 | ||
316 | // implementation | |
317 | ||
318 | void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, | |
319 | const wxSize &size, long style, const wxString &name ); | |
320 | void PostCreation(); | |
321 | ||
322 | virtual GtkWidget* GetConnectWidget(); | |
323 | virtual bool IsOwnGtkWindow( GdkWindow *window ); | |
324 | void ConnectWidget( GtkWidget *widget ); | |
325 | ||
326 | bool HasVMT(); | |
327 | ||
328 | virtual wxPoint GetClientAreaOrigin() const; | |
329 | virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ); | |
330 | ||
331 | GtkStyle *GetWidgetStyle(); | |
332 | void SetWidgetStyle(); | |
333 | virtual void ApplyWidgetStyle(); | |
334 | ||
335 | virtual void OnInternalIdle(); | |
336 | ||
337 | wxWindow *m_parent; | |
338 | wxList m_children; | |
339 | int m_x,m_y; | |
340 | int m_width,m_height; | |
341 | int m_minWidth,m_minHeight; | |
342 | int m_maxWidth,m_maxHeight; | |
343 | int m_retCode; | |
344 | wxEvtHandler *m_eventHandler; | |
345 | wxValidator *m_windowValidator; | |
346 | #if wxUSE_DRAG_AND_DROP | |
347 | wxDropTarget *m_dropTarget; | |
348 | #endif | |
349 | wxWindowID m_windowId; | |
350 | wxCursor *m_cursor; | |
351 | wxFont m_font; | |
352 | wxColour m_backgroundColour; | |
353 | wxColour m_foregroundColour; | |
354 | wxRegion m_updateRegion; | |
355 | long m_windowStyle; | |
356 | bool m_isShown; | |
357 | bool m_isEnabled; | |
358 | wxString m_windowName; | |
359 | wxAcceleratorTable m_acceleratorTable; | |
360 | wxClientData *m_clientObject; | |
361 | void *m_clientData; | |
362 | ||
363 | GtkWidget *m_widget; | |
364 | GtkWidget *m_wxwindow; | |
365 | GtkAdjustment *m_hAdjust,*m_vAdjust; | |
366 | float m_oldHorizontalPos; | |
367 | float m_oldVerticalPos; | |
368 | bool m_needParent; | |
369 | bool m_hasScrolling; | |
370 | bool m_isScrolling; | |
371 | bool m_hasVMT; | |
372 | bool m_sizeSet; | |
373 | bool m_resizing; | |
374 | GdkGC *m_scrollGC; | |
375 | GtkStyle *m_widgetStyle; | |
376 | bool m_isStaticBox; | |
377 | bool m_acceptsFocus; | |
378 | ||
379 | wxInsertChildFunction m_insertCallback; | |
380 | ||
381 | public: | |
382 | ||
383 | wxLayoutConstraints *m_constraints; | |
384 | wxList *m_constraintsInvolvedIn; | |
385 | wxSizer *m_windowSizer; | |
386 | wxWindow *m_sizerParent; | |
387 | bool m_autoLayout; | |
388 | ||
389 | wxLayoutConstraints *GetConstraints() const; | |
390 | void SetConstraints( wxLayoutConstraints *constraints ); | |
391 | void SetAutoLayout( bool autoLayout ); | |
392 | bool GetAutoLayout() const; | |
393 | bool Layout(); | |
394 | void SetSizer( wxSizer *sizer ); | |
395 | wxSizer *GetSizer() const; | |
396 | void SetSizerParent( wxWindow *win ); | |
397 | wxWindow *GetSizerParent() const; | |
398 | void UnsetConstraints(wxLayoutConstraints *c); | |
399 | inline wxList *GetConstraintsInvolvedIn() const ; | |
400 | void AddConstraintReference(wxWindow *otherWin); | |
401 | void RemoveConstraintReference(wxWindow *otherWin); | |
402 | void DeleteRelatedConstraints(); | |
403 | virtual void ResetConstraints(); | |
404 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
405 | virtual bool LayoutPhase1(int *noChanges); | |
406 | virtual bool LayoutPhase2(int *noChanges); | |
407 | virtual bool DoPhase(int); | |
408 | virtual void TransformSizerToActual(int *x, int *y) const ; | |
409 | virtual void SizerSetSize(int x, int y, int w, int h); | |
410 | virtual void SizerMove(int x, int y); | |
411 | virtual void SetSizeConstraint(int x, int y, int w, int h); | |
412 | virtual void MoveConstraint(int x, int y); | |
413 | virtual void GetSizeConstraint(int *w, int *h) const ; | |
414 | virtual void GetClientSizeConstraint(int *w, int *h) const ; | |
415 | virtual void GetPositionConstraint(int *x, int *y) const ; | |
416 | ||
417 | private: | |
418 | DECLARE_EVENT_TABLE() | |
419 | }; | |
420 | ||
421 | #endif // __GTKWINDOWH__ |