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