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