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