]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
58614078 RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
aed8df38 | 7 | // Licence: wxWindows licence |
c801d85f KB |
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" | |
c801d85f | 25 | #include "wx/region.h" |
bcf1fa6b | 26 | #include "wx/accel.h" |
c801d85f KB |
27 | |
28 | //----------------------------------------------------------------------------- | |
29 | // global data | |
30 | //----------------------------------------------------------------------------- | |
31 | ||
32 | extern const char *wxFrameNameStr; | |
33 | extern wxList wxTopLevelWindows; | |
34 | ||
bbe0af5b RR |
35 | //----------------------------------------------------------------------------- |
36 | // global function | |
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | wxWindow* wxGetActiveWindow(); | |
40 | ||
c801d85f KB |
41 | //----------------------------------------------------------------------------- |
42 | // classes | |
43 | //----------------------------------------------------------------------------- | |
44 | ||
45 | class wxLayoutConstraints; | |
46 | class wxSizer; | |
ac57418f | 47 | class wxDC; |
fd0eed64 RR |
48 | class wxClientData; |
49 | class wxVoidClientData; | |
c801d85f | 50 | class wxWindow; |
06cfab17 | 51 | #if wxUSE_WX_RESOURCES |
ac57418f RR |
52 | class wxResourceTable; |
53 | class wxItemResource; | |
54 | #endif | |
06cfab17 | 55 | #if wxUSE_DRAG_AND_DROP |
ac57418f RR |
56 | class wxDropTarget; |
57 | #endif | |
c801d85f | 58 | |
6ca41e57 | 59 | //----------------------------------------------------------------------------- |
fd0eed64 | 60 | // callback definition for inserting a window (internal) |
6ca41e57 RR |
61 | //----------------------------------------------------------------------------- |
62 | ||
63 | typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* ); | |
64 | ||
c801d85f KB |
65 | //----------------------------------------------------------------------------- |
66 | // global data | |
67 | //----------------------------------------------------------------------------- | |
68 | ||
69 | extern const char *wxPanelNameStr; | |
70 | extern const wxSize wxDefaultSize; | |
71 | extern const wxPoint wxDefaultPosition; | |
72 | ||
fd0eed64 RR |
73 | //----------------------------------------------------------------------------- |
74 | // wxClientData | |
75 | //----------------------------------------------------------------------------- | |
76 | ||
77 | class wxClientData | |
78 | { | |
79 | public: | |
36b3b54a RR |
80 | wxClientData() { } |
81 | virtual ~wxClientData() { } | |
fd0eed64 RR |
82 | }; |
83 | ||
fd0eed64 RR |
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; } | |
8bbe427f | 95 | |
fd0eed64 RR |
96 | private: |
97 | wxString m_data; | |
98 | }; | |
99 | ||
b292e2f5 RR |
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 | ||
c801d85f KB |
110 | //----------------------------------------------------------------------------- |
111 | // wxWindow | |
112 | //----------------------------------------------------------------------------- | |
113 | ||
114 | class wxWindow: public wxEvtHandler | |
115 | { | |
a60c99e6 | 116 | DECLARE_DYNAMIC_CLASS(wxWindow) |
8bbe427f | 117 | |
aed8df38 VZ |
118 | public: |
119 | wxWindow(); | |
6ca41e57 | 120 | wxWindow(wxWindow *parent, wxWindowID id, |
6de97a3b RR |
121 | const wxPoint& pos = wxDefaultPosition, |
122 | const wxSize& size = wxDefaultSize, | |
123 | long style = 0, | |
6ca41e57 | 124 | const wxString& name = wxPanelNameStr); |
6de97a3b RR |
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); | |
aed8df38 | 130 | virtual ~wxWindow(); |
cd0183ca | 131 | |
f5abe911 | 132 | #if wxUSE_WX_RESOURCES |
8bbe427f | 133 | virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, |
bcf1fa6b | 134 | const wxResourceTable *table = (const wxResourceTable *) NULL); |
fd71308f | 135 | virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, |
bcf1fa6b | 136 | const wxResourceTable *table = (const wxResourceTable *) NULL); |
f5abe911 | 137 | #endif |
cd0183ca | 138 | |
aed8df38 VZ |
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 ); | |
4f22cf8d | 148 | |
aed8df38 | 149 | virtual void Move( int x, int y ); |
4f22cf8d | 150 | |
aed8df38 | 151 | virtual void GetSize( int *width, int *height ) const; |
4f22cf8d RR |
152 | wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } |
153 | ||
aed8df38 | 154 | virtual void SetClientSize( int const width, int const height ); |
4f22cf8d | 155 | |
aed8df38 | 156 | virtual void GetClientSize( int *width, int *height ) const; |
4f22cf8d RR |
157 | wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } |
158 | ||
aed8df38 | 159 | virtual void GetPosition( int *x, int *y ) const; |
4f22cf8d RR |
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 | ||
aed8df38 | 165 | virtual void Centre( int direction = wxHORIZONTAL ); |
cd0183ca | 166 | inline void Center(int direction = wxHORIZONTAL) { Centre(direction); } |
aed8df38 | 167 | virtual void Fit(); |
2f2aa628 RR |
168 | |
169 | virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 ); | |
aed8df38 | 170 | |
36b3b54a RR |
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); } | |
fd71308f | 178 | |
aed8df38 | 179 | void OnSize( wxSizeEvent &event ); |
aed8df38 VZ |
180 | |
181 | virtual bool Show( bool show ); | |
182 | virtual void Enable( bool enable ); | |
183 | virtual void MakeModal( bool modal ); | |
903f689b | 184 | virtual bool IsEnabled() const { return m_isEnabled; } |
fd0eed64 | 185 | inline bool Enabled() const { return IsEnabled(); } |
aed8df38 VZ |
186 | virtual bool OnClose(); |
187 | ||
b292e2f5 RR |
188 | virtual void SetFocus(); |
189 | static wxWindow *FindFocus(); | |
190 | ||
aed8df38 | 191 | virtual void AddChild( wxWindow *child ); |
8bbe427f VZ |
192 | wxList& GetChildren() { return m_children; } |
193 | ||
aed8df38 VZ |
194 | virtual void RemoveChild( wxWindow *child ); |
195 | void SetReturnCode( int retCode ); | |
196 | int GetReturnCode(); | |
cd0183ca | 197 | wxWindow *GetParent() const |
c33c4050 | 198 | { return m_parent; } |
fd0eed64 | 199 | wxWindow *GetGrandParent() const |
c33c4050 | 200 | { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); } |
36b3b54a RR |
201 | void SetParent( wxWindow *parent ) |
202 | { m_parent = parent; } | |
463c1fa1 | 203 | virtual wxWindow *ReParent( wxWindow *newParent ); |
aed8df38 | 204 | |
8bbe427f | 205 | wxEvtHandler *GetEventHandler() const; |
86b29a61 RR |
206 | void SetEventHandler( wxEvtHandler *handler ); |
207 | void PushEventHandler( wxEvtHandler *handler ); | |
208 | wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); | |
aed8df38 VZ |
209 | |
210 | virtual wxValidator *GetValidator(); | |
6de97a3b | 211 | virtual void SetValidator( const wxValidator &validator ); |
aed8df38 | 212 | |
fd0eed64 RR |
213 | virtual void SetClientObject( wxClientData *data ); |
214 | virtual wxClientData *GetClientObject(); | |
8bbe427f | 215 | |
fd0eed64 RR |
216 | virtual void SetClientData( void *data ); |
217 | virtual void *GetClientData(); | |
8bbe427f | 218 | |
bcf1fa6b RR |
219 | virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); |
220 | virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } | |
8bbe427f | 221 | |
aed8df38 VZ |
222 | bool IsBeingDeleted(); |
223 | ||
224 | void SetId( wxWindowID id ); | |
8bbe427f | 225 | wxWindowID GetId() const; |
aed8df38 VZ |
226 | |
227 | void SetCursor( const wxCursor &cursor ); | |
228 | ||
4f22cf8d RR |
229 | void WarpPointer(int x, int y); |
230 | ||
c67daf87 | 231 | virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); |
aed8df38 | 232 | virtual void Clear(); |
8bbe427f | 233 | |
8429bec1 RR |
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; | |
aed8df38 VZ |
239 | |
240 | virtual wxColour GetBackgroundColour() const; | |
241 | virtual void SetBackgroundColour( const wxColour &colour ); | |
6de97a3b RR |
242 | virtual wxColour GetForegroundColour() const; |
243 | virtual void SetForegroundColour( const wxColour &colour ); | |
cd0183ca | 244 | |
fd0eed64 RR |
245 | virtual int GetCharHeight() const; |
246 | virtual int GetCharWidth() const; | |
c33c4050 | 247 | virtual void GetTextExtent( const wxString& string, int *x, int *y, |
c67daf87 UR |
248 | int *descent = (int *) NULL, |
249 | int *externalLeading = (int *) NULL, | |
250 | const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const; | |
aed8df38 | 251 | |
aed8df38 | 252 | virtual void SetFont( const wxFont &font ); |
4f22cf8d | 253 | virtual wxFont& GetFont() { return m_font; } |
8bbe427f | 254 | |
fd0eed64 | 255 | // For backward compatibility |
aed8df38 VZ |
256 | inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } |
257 | inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } | |
4f22cf8d RR |
258 | inline virtual wxFont& GetLabelFont() { return GetFont(); }; |
259 | inline virtual wxFont& GetButtonFont() { return GetFont(); }; | |
8bbe427f | 260 | |
aed8df38 VZ |
261 | virtual void SetWindowStyleFlag( long flag ); |
262 | virtual long GetWindowStyleFlag() const; | |
8bbe427f | 263 | |
aed8df38 VZ |
264 | virtual void CaptureMouse(); |
265 | virtual void ReleaseMouse(); | |
8bbe427f | 266 | |
aed8df38 VZ |
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; | |
c801d85f | 272 | |
aed8df38 | 273 | void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {}; |
b666df2c | 274 | void OnKeyDown( wxKeyEvent &event ); |
aed8df38 VZ |
275 | |
276 | virtual bool IsShown() const; | |
e149aaeb | 277 | |
fd0eed64 RR |
278 | virtual void Raise(); |
279 | virtual void Lower(); | |
e149aaeb | 280 | |
aed8df38 VZ |
281 | virtual bool IsRetained(); |
282 | virtual wxWindow *FindWindow( long id ); | |
283 | virtual wxWindow *FindWindow( const wxString& name ); | |
8bbe427f | 284 | |
aed8df38 VZ |
285 | void AllowDoubleClick( bool WXUNUSED(allow) ) {}; |
286 | void SetDoubleClick( bool WXUNUSED(allow) ) {}; | |
8bbe427f | 287 | |
aed8df38 VZ |
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(); | |
cd0183ca | 296 | |
30dea054 | 297 | virtual bool PopupMenu( wxMenu *menu, int x, int y ); |
aed8df38 | 298 | |
06cfab17 | 299 | #if wxUSE_DRAG_AND_DROP |
aed8df38 VZ |
300 | virtual void SetDropTarget( wxDropTarget *dropTarget ); |
301 | virtual wxDropTarget *GetDropTarget() const; | |
ac57418f | 302 | #endif |
cd0183ca | 303 | |
aed8df38 VZ |
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; | |
c67daf87 | 310 | virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); |
aed8df38 | 311 | |
aed8df38 | 312 | virtual bool AcceptsFocus() const; |
8bbe427f | 313 | |
aed8df38 VZ |
314 | void UpdateWindowUI(); |
315 | ||
a60c99e6 | 316 | // implementation |
8bbe427f | 317 | |
9390a202 RR |
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 ); | |
8bbe427f | 325 | |
9390a202 | 326 | bool HasVMT(); |
6ca41e57 | 327 | |
9390a202 RR |
328 | virtual wxPoint GetClientAreaOrigin() const; |
329 | virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ); | |
8bbe427f | 330 | |
9390a202 RR |
331 | GtkStyle *GetWidgetStyle(); |
332 | void SetWidgetStyle(); | |
333 | virtual void ApplyWidgetStyle(); | |
334 | ||
335 | virtual void OnInternalIdle(); | |
aed8df38 | 336 | |
bcf1fa6b RR |
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; | |
06cfab17 | 346 | #if wxUSE_DRAG_AND_DROP |
fd0eed64 | 347 | wxDropTarget *m_dropTarget; |
ac57418f | 348 | #endif |
bcf1fa6b RR |
349 | wxWindowID m_windowId; |
350 | wxCursor *m_cursor; | |
351 | wxFont m_font; | |
352 | wxColour m_backgroundColour; | |
1ecc4d80 | 353 | wxColour m_foregroundColour; |
bcf1fa6b RR |
354 | wxRegion m_updateRegion; |
355 | long m_windowStyle; | |
356 | bool m_isShown; | |
357 | bool m_isEnabled; | |
358 | wxString m_windowName; | |
359 | wxAcceleratorTable m_acceleratorTable; | |
f5e27805 RR |
360 | wxClientData *m_clientObject; |
361 | void *m_clientData; | |
bcf1fa6b RR |
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; | |
cb43b372 | 370 | bool m_isScrolling; |
bcf1fa6b RR |
371 | bool m_hasVMT; |
372 | bool m_sizeSet; | |
373 | bool m_resizing; | |
32e9da8b | 374 | GdkGC *m_scrollGC; |
a81258be | 375 | GtkStyle *m_widgetStyle; |
1ecc4d80 | 376 | bool m_isStaticBox; |
b292e2f5 | 377 | bool m_acceptsFocus; |
8bbe427f | 378 | |
6ca41e57 | 379 | wxInsertChildFunction m_insertCallback; |
bcf1fa6b RR |
380 | |
381 | public: | |
382 | ||
383 | wxLayoutConstraints *m_constraints; | |
384 | wxList *m_constraintsInvolvedIn; | |
385 | wxSizer *m_windowSizer; | |
386 | wxWindow *m_sizerParent; | |
387 | bool m_autoLayout; | |
aed8df38 VZ |
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 | ||
68dda785 | 417 | private: |
c801d85f KB |
418 | DECLARE_EVENT_TABLE() |
419 | }; | |
420 | ||
421 | #endif // __GTKWINDOWH__ |