1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __GTKWINDOWH__
13 #define __GTKWINDOWH__
20 #include "wx/object.h"
23 #include "wx/validate.h"
24 #include "wx/cursor.h"
27 #include "wx/region.h"
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 extern const char *wxFrameNameStr
;
36 extern wxList wxTopLevelWindows
;
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 class wxLayoutConstraints
;
44 class wxResourceTable
;
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 extern const char *wxPanelNameStr
;
55 extern const wxSize wxDefaultSize
;
56 extern const wxPoint wxDefaultPosition
;
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
62 class wxWindow
: public wxEvtHandler
66 inline wxWindow(wxWindow
*parent
, wxWindowID id
,
67 const wxPoint
& pos
= wxDefaultPosition
,
68 const wxSize
& size
= wxDefaultSize
,
70 const wxString
& name
= wxPanelNameStr
)
72 Create(parent
, id
, pos
, size
, style
, name
);
74 bool Create(wxWindow
*parent
, wxWindowID id
,
75 const wxPoint
& pos
= wxDefaultPosition
,
76 const wxSize
& size
= wxDefaultSize
,
78 const wxString
& name
= wxPanelNameStr
);
81 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
82 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
83 virtual wxControl
*CreateItem( const wxItemResource
*childResource
,
84 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
86 bool Close( bool force
= FALSE
);
87 virtual bool Destroy();
88 virtual bool DestroyChildren();
90 virtual void PrepareDC( wxDC
&dc
);
92 virtual void SetSize( int x
, int y
, int width
, int height
,
93 int sizeFlags
= wxSIZE_AUTO
);
94 virtual void SetSize( int width
, int height
);
95 virtual void Move( int x
, int y
);
96 virtual void GetSize( int *width
, int *height
) const;
97 virtual void SetClientSize( int const width
, int const height
);
98 virtual void GetClientSize( int *width
, int *height
) const;
99 virtual void GetPosition( int *x
, int *y
) const;
100 virtual void Centre( int direction
= wxHORIZONTAL
);
101 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
104 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
106 void OnSize( wxSizeEvent
&event
);
107 void OnIdle( wxIdleEvent
& event
);
109 virtual bool Show( bool show
);
110 virtual void Enable( bool enable
);
111 virtual void MakeModal( bool modal
);
112 virtual bool IsEnabled() const { return m_isEnabled
; }
113 inline bool Enabled(void) const { return IsEnabled(); }
114 virtual void SetFocus();
115 virtual bool OnClose();
117 virtual void AddChild( wxWindow
*child
);
118 wxList
*GetChildren();
119 virtual void RemoveChild( wxWindow
*child
);
120 void SetReturnCode( int retCode
);
122 wxWindow
*GetParent() const
124 wxWindow
*GetGrandParent(void) const
125 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
126 void SetParent( wxWindow
*p
)
129 wxEvtHandler
*GetEventHandler();
130 void SetEventHandler( wxEvtHandler
*handler
);
131 void PushEventHandler( wxEvtHandler
*handler
);
132 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
134 virtual wxValidator
*GetValidator();
135 virtual void SetValidator( const wxValidator
&validator
);
137 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
138 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
140 bool IsBeingDeleted();
142 void SetId( wxWindowID id
);
145 void SetCursor( const wxCursor
&cursor
);
147 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
148 virtual void Clear();
150 virtual wxRegion
GetUpdateRegion() const;
151 virtual bool IsExposed(int x
, int y
) const;
152 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
153 virtual bool IsExposed(const wxPoint
& pt
) const;
154 virtual bool IsExposed(const wxRect
& rect
) const;
156 virtual wxColour
GetBackgroundColour() const;
157 virtual void SetBackgroundColour( const wxColour
&colour
);
158 virtual wxColour
GetForegroundColour() const;
159 virtual void SetForegroundColour( const wxColour
&colour
);
161 virtual int GetCharHeight(void) const;
162 virtual int GetCharWidth(void) const;
163 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
164 int *descent
= (int *) NULL
,
165 int *externalLeading
= (int *) NULL
,
166 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
168 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
169 { m_defaultBackgroundColour
= col
; }
170 virtual wxColour
GetDefaultBackgroundColour() const
171 { return m_defaultBackgroundColour
; }
172 virtual void SetDefaultForegroundColour( const wxColour
& col
)
173 { m_defaultForegroundColour
= col
; }
174 virtual wxColour
GetDefaultForegroundColour() const
175 { return m_defaultForegroundColour
; }
177 virtual void SetFont( const wxFont
&font
);
178 virtual wxFont
*GetFont();
179 // For backward compatibility
180 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
181 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
182 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
183 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
184 virtual void SetWindowStyleFlag( long flag
);
185 virtual long GetWindowStyleFlag() const;
186 virtual void CaptureMouse();
187 virtual void ReleaseMouse();
188 virtual void SetTitle( const wxString
&title
);
189 virtual wxString
GetTitle() const;
190 virtual void SetName( const wxString
&name
);
191 virtual wxString
GetName() const;
192 virtual wxString
GetLabel() const;
194 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
196 virtual bool IsShown() const;
198 virtual void Raise(void);
199 virtual void Lower(void);
201 virtual bool IsRetained();
202 virtual wxWindow
*FindWindow( long id
);
203 virtual wxWindow
*FindWindow( const wxString
& name
);
204 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
205 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
206 virtual void ClientToScreen( int *x
, int *y
);
207 virtual void ScreenToClient( int *x
, int *y
);
209 virtual bool Validate();
210 virtual bool TransferDataToWindow();
211 virtual bool TransferDataFromWindow();
212 void OnInitDialog( wxInitDialogEvent
&event
);
213 virtual void InitDialog();
215 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
217 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
218 virtual wxDropTarget
*GetDropTarget() const;
220 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
221 int range
, bool refresh
= TRUE
);
222 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
223 virtual int GetScrollPos( int orient
) const;
224 virtual int GetScrollThumb( int orient
) const;
225 virtual int GetScrollRange( int orient
) const;
226 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
228 virtual bool AcceptsFocus() const;
229 void UpdateWindowUI();
231 public: // cannot get private going yet
233 virtual GtkWidget
* GetConnectWidget(void);
234 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
236 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
237 const wxSize
&size
, long style
, const wxString
&name
);
240 virtual void ImplementSetSize();
241 virtual void ImplementSetPosition();
246 int m_width
,m_height
;
247 int m_minWidth
,m_minHeight
;
248 int m_maxWidth
,m_maxHeight
;
250 wxEvtHandler
*m_eventHandler
;
251 wxValidator
*m_windowValidator
;
252 wxDropTarget
*m_pDropTarget
;
253 wxWindowID m_windowId
;
256 wxColour m_backgroundColour
;
257 wxColour m_defaultBackgroundColour
;
258 wxColour m_foregroundColour
;
259 wxColour m_defaultForegroundColour
;
260 wxRegion m_updateRegion
;
264 wxString m_windowName
;
265 wxAcceleratorTable m_acceleratorTable
;
268 GtkWidget
*m_wxwindow
;
269 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
270 float m_oldHorizontalPos
;
271 float m_oldVerticalPos
;
281 wxLayoutConstraints
*m_constraints
;
282 wxList
*m_constraintsInvolvedIn
;
283 wxSizer
*m_windowSizer
;
284 wxWindow
*m_sizerParent
;
287 wxLayoutConstraints
*GetConstraints() const;
288 void SetConstraints( wxLayoutConstraints
*constraints
);
289 void SetAutoLayout( bool autoLayout
);
290 bool GetAutoLayout() const;
292 void SetSizer( wxSizer
*sizer
);
293 wxSizer
*GetSizer() const;
294 void SetSizerParent( wxWindow
*win
);
295 wxWindow
*GetSizerParent() const;
296 void UnsetConstraints(wxLayoutConstraints
*c
);
297 inline wxList
*GetConstraintsInvolvedIn() const ;
298 void AddConstraintReference(wxWindow
*otherWin
);
299 void RemoveConstraintReference(wxWindow
*otherWin
);
300 void DeleteRelatedConstraints();
301 virtual void ResetConstraints();
302 virtual void SetConstraintSizes(bool recurse
= TRUE
);
303 virtual bool LayoutPhase1(int *noChanges
);
304 virtual bool LayoutPhase2(int *noChanges
);
305 virtual bool DoPhase(int);
306 virtual void TransformSizerToActual(int *x
, int *y
) const ;
307 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
308 virtual void SizerMove(int x
, int y
);
309 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
310 virtual void MoveConstraint(int x
, int y
);
311 virtual void GetSizeConstraint(int *w
, int *h
) const ;
312 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
313 virtual void GetPositionConstraint(int *x
, int *y
) const ;
315 DECLARE_DYNAMIC_CLASS(wxWindow
)
316 DECLARE_EVENT_TABLE()
319 #endif // __GTKWINDOWH__