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