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