]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/window.h
A bit more DnD and clipbrd updates
[wxWidgets.git] / include / wx / gtk1 / window.h
CommitLineData
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
34extern const char *wxFrameNameStr;
35extern wxList wxTopLevelWindows;
36
37//-----------------------------------------------------------------------------
38// classes
39//-----------------------------------------------------------------------------
40
41class wxLayoutConstraints;
42class wxSizer;
6de97a3b
RR
43class wxResourceTable;
44class wxItemResource;
c801d85f 45
fd0eed64
RR
46class wxClientData;
47class wxVoidClientData;
c801d85f 48class wxWindow;
c801d85f 49
6ca41e57 50//-----------------------------------------------------------------------------
fd0eed64 51// callback definition for inserting a window (internal)
6ca41e57
RR
52//-----------------------------------------------------------------------------
53
54typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
55
c801d85f
KB
56//-----------------------------------------------------------------------------
57// global data
58//-----------------------------------------------------------------------------
59
60extern const char *wxPanelNameStr;
61extern const wxSize wxDefaultSize;
62extern const wxPoint wxDefaultPosition;
63
fd0eed64
RR
64//-----------------------------------------------------------------------------
65// wxClientData
66//-----------------------------------------------------------------------------
67
68class wxClientData
69{
70public:
71 wxClientData() { }
72 virtual ~wxClientData() { }
73};
74
fd0eed64
RR
75//-----------------------------------------------------------------------------
76// wxStringClientData
77//-----------------------------------------------------------------------------
78
79class wxStringClientData: public wxClientData
80{
81public:
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
87private:
88 wxString m_data;
89};
90
c801d85f
KB
91//-----------------------------------------------------------------------------
92// wxWindow
93//-----------------------------------------------------------------------------
94
95class wxWindow: public wxEvtHandler
96{
a60c99e6 97 DECLARE_DYNAMIC_CLASS(wxWindow)
8bbe427f 98
aed8df38
VZ
99public:
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
8bbe427f 113 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
bcf1fa6b 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 );
8bbe427f
VZ
158 wxList& GetChildren() { return m_children; }
159
aed8df38
VZ
160 virtual void RemoveChild( wxWindow *child );
161 void SetReturnCode( int retCode );
162 int GetReturnCode();
cd0183ca 163 wxWindow *GetParent() const
c33c4050 164 { return m_parent; }
fd0eed64 165 wxWindow *GetGrandParent() const
c33c4050 166 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
cd0183ca 167 void SetParent( wxWindow *p )
c33c4050 168 { m_parent = p; }
463c1fa1 169 virtual wxWindow *ReParent( wxWindow *newParent );
aed8df38 170
8bbe427f 171 wxEvtHandler *GetEventHandler() const;
86b29a61
RR
172 void SetEventHandler( wxEvtHandler *handler );
173 void PushEventHandler( wxEvtHandler *handler );
174 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
aed8df38
VZ
175
176 virtual wxValidator *GetValidator();
6de97a3b 177 virtual void SetValidator( const wxValidator &validator );
aed8df38 178
fd0eed64
RR
179 virtual void SetClientObject( wxClientData *data );
180 virtual wxClientData *GetClientObject();
8bbe427f 181
fd0eed64
RR
182 virtual void SetClientData( void *data );
183 virtual void *GetClientData();
8bbe427f 184
bcf1fa6b
RR
185 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
186 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
8bbe427f 187
aed8df38
VZ
188 bool IsBeingDeleted();
189
190 void SetId( wxWindowID id );
8bbe427f 191 wxWindowID GetId() const;
aed8df38
VZ
192
193 void SetCursor( const wxCursor &cursor );
194
c67daf87 195 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
aed8df38 196 virtual void Clear();
8bbe427f 197
8429bec1
RR
198 virtual wxRegion GetUpdateRegion() const;
199 virtual bool IsExposed(int x, int y) const;
200 virtual bool IsExposed(int x, int y, int w, int h) const;
201 virtual bool IsExposed(const wxPoint& pt) const;
202 virtual bool IsExposed(const wxRect& rect) const;
aed8df38
VZ
203
204 virtual wxColour GetBackgroundColour() const;
205 virtual void SetBackgroundColour( const wxColour &colour );
6de97a3b
RR
206 virtual wxColour GetForegroundColour() const;
207 virtual void SetForegroundColour( const wxColour &colour );
cd0183ca 208
fd0eed64
RR
209 virtual int GetCharHeight() const;
210 virtual int GetCharWidth() const;
c33c4050 211 virtual void GetTextExtent( const wxString& string, int *x, int *y,
c67daf87
UR
212 int *descent = (int *) NULL,
213 int *externalLeading = (int *) NULL,
214 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
aed8df38 215
aed8df38 216 virtual void SetFont( const wxFont &font );
8bbe427f
VZ
217 virtual const wxFont& GetFont() { return m_font; }
218
fd0eed64 219 // For backward compatibility
aed8df38
VZ
220 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
221 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
8bbe427f
VZ
222 inline virtual const wxFont& GetLabelFont() { return GetFont(); };
223 inline virtual const wxFont& GetButtonFont() { return GetFont(); };
224
aed8df38
VZ
225 virtual void SetWindowStyleFlag( long flag );
226 virtual long GetWindowStyleFlag() const;
8bbe427f 227
aed8df38
VZ
228 virtual void CaptureMouse();
229 virtual void ReleaseMouse();
8bbe427f 230
aed8df38
VZ
231 virtual void SetTitle( const wxString &title );
232 virtual wxString GetTitle() const;
233 virtual void SetName( const wxString &name );
234 virtual wxString GetName() const;
235 virtual wxString GetLabel() const;
c801d85f 236
aed8df38
VZ
237 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
238
239 virtual bool IsShown() const;
e149aaeb 240
fd0eed64
RR
241 virtual void Raise();
242 virtual void Lower();
e149aaeb 243
aed8df38
VZ
244 virtual bool IsRetained();
245 virtual wxWindow *FindWindow( long id );
246 virtual wxWindow *FindWindow( const wxString& name );
8bbe427f 247
aed8df38
VZ
248 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
249 void SetDoubleClick( bool WXUNUSED(allow) ) {};
8bbe427f 250
aed8df38
VZ
251 virtual void ClientToScreen( int *x, int *y );
252 virtual void ScreenToClient( int *x, int *y );
253
254 virtual bool Validate();
255 virtual bool TransferDataToWindow();
256 virtual bool TransferDataFromWindow();
257 void OnInitDialog( wxInitDialogEvent &event );
258 virtual void InitDialog();
cd0183ca 259
30dea054 260 virtual bool PopupMenu( wxMenu *menu, int x, int y );
aed8df38
VZ
261
262 virtual void SetDropTarget( wxDropTarget *dropTarget );
263 virtual wxDropTarget *GetDropTarget() const;
cd0183ca 264
aed8df38
VZ
265 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
266 int range, bool refresh = TRUE );
267 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
268 virtual int GetScrollPos( int orient ) const;
269 virtual int GetScrollThumb( int orient ) const;
270 virtual int GetScrollRange( int orient ) const;
c67daf87 271 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
aed8df38 272
aed8df38 273 virtual bool AcceptsFocus() const;
8bbe427f 274
aed8df38
VZ
275 void UpdateWindowUI();
276
a60c99e6 277 // implementation
8bbe427f 278
fd0eed64
RR
279 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
280 const wxSize &size, long style, const wxString &name );
281 void PostCreation();
282 virtual GtkWidget *GetConnectWidget();
6ca41e57
RR
283 virtual bool IsOwnGtkWindow( GdkWindow *window );
284 void ConnectWidget( GtkWidget *widget );
8bbe427f 285
6ca41e57 286 bool HasVMT();
8bbe427f 287
6ca41e57
RR
288 virtual wxPoint GetClientAreaOrigin() const;
289 virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
290
291 GtkStyle *GetWidgetStyle();
292 void SetWidgetStyle();
293 virtual void ApplyWidgetStyle();
8bbe427f 294
aed8df38 295
bcf1fa6b
RR
296 wxWindow *m_parent;
297 wxList m_children;
298 int m_x,m_y;
299 int m_width,m_height;
300 int m_minWidth,m_minHeight;
301 int m_maxWidth,m_maxHeight;
302 int m_retCode;
303 wxEvtHandler *m_eventHandler;
304 wxValidator *m_windowValidator;
fd0eed64 305 wxDropTarget *m_dropTarget;
bcf1fa6b
RR
306 wxWindowID m_windowId;
307 wxCursor *m_cursor;
308 wxFont m_font;
309 wxColour m_backgroundColour;
1ecc4d80 310 wxColour m_foregroundColour;
bcf1fa6b
RR
311 wxRegion m_updateRegion;
312 long m_windowStyle;
313 bool m_isShown;
314 bool m_isEnabled;
315 wxString m_windowName;
316 wxAcceleratorTable m_acceleratorTable;
f5e27805
RR
317 wxClientData *m_clientObject;
318 void *m_clientData;
bcf1fa6b
RR
319
320 GtkWidget *m_widget;
321 GtkWidget *m_wxwindow;
322 GtkAdjustment *m_hAdjust,*m_vAdjust;
323 float m_oldHorizontalPos;
324 float m_oldVerticalPos;
325 bool m_needParent;
326 bool m_hasScrolling;
cb43b372 327 bool m_isScrolling;
bcf1fa6b
RR
328 bool m_hasVMT;
329 bool m_sizeSet;
330 bool m_resizing;
32e9da8b 331 GdkGC *m_scrollGC;
a81258be 332 GtkStyle *m_widgetStyle;
1ecc4d80 333 bool m_isStaticBox;
8bbe427f 334
6ca41e57 335 wxInsertChildFunction m_insertCallback;
bcf1fa6b
RR
336
337public:
338
339 wxLayoutConstraints *m_constraints;
340 wxList *m_constraintsInvolvedIn;
341 wxSizer *m_windowSizer;
342 wxWindow *m_sizerParent;
343 bool m_autoLayout;
aed8df38
VZ
344
345 wxLayoutConstraints *GetConstraints() const;
346 void SetConstraints( wxLayoutConstraints *constraints );
347 void SetAutoLayout( bool autoLayout );
348 bool GetAutoLayout() const;
349 bool Layout();
350 void SetSizer( wxSizer *sizer );
351 wxSizer *GetSizer() const;
352 void SetSizerParent( wxWindow *win );
353 wxWindow *GetSizerParent() const;
354 void UnsetConstraints(wxLayoutConstraints *c);
355 inline wxList *GetConstraintsInvolvedIn() const ;
356 void AddConstraintReference(wxWindow *otherWin);
357 void RemoveConstraintReference(wxWindow *otherWin);
358 void DeleteRelatedConstraints();
359 virtual void ResetConstraints();
360 virtual void SetConstraintSizes(bool recurse = TRUE);
361 virtual bool LayoutPhase1(int *noChanges);
362 virtual bool LayoutPhase2(int *noChanges);
363 virtual bool DoPhase(int);
364 virtual void TransformSizerToActual(int *x, int *y) const ;
365 virtual void SizerSetSize(int x, int y, int w, int h);
366 virtual void SizerMove(int x, int y);
367 virtual void SetSizeConstraint(int x, int y, int w, int h);
368 virtual void MoveConstraint(int x, int y);
369 virtual void GetSizeConstraint(int *w, int *h) const ;
370 virtual void GetClientSizeConstraint(int *w, int *h) const ;
371 virtual void GetPositionConstraint(int *x, int *y) const ;
372
68dda785 373private:
c801d85f
KB
374 DECLARE_EVENT_TABLE()
375};
376
377#endif // __GTKWINDOWH__