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