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
64 DECLARE_DYNAMIC_CLASS(wxWindow
)
68 inline wxWindow(wxWindow
*parent
, wxWindowID id
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
72 const wxString
& name
= wxPanelNameStr
)
74 Create(parent
, id
, pos
, size
, style
, name
);
76 bool Create(wxWindow
*parent
, wxWindowID id
,
77 const wxPoint
& pos
= wxDefaultPosition
,
78 const wxSize
& size
= wxDefaultSize
,
80 const wxString
& name
= wxPanelNameStr
);
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
);
88 bool Close( bool force
= FALSE
);
89 virtual bool Destroy();
90 virtual bool DestroyChildren();
92 virtual void PrepareDC( wxDC
&dc
);
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
);
103 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
106 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
108 void OnSize( wxSizeEvent
&event
);
109 void OnIdle( wxIdleEvent
& event
);
111 virtual bool Show( bool show
);
112 virtual void Enable( bool enable
);
113 virtual void MakeModal( bool modal
);
114 virtual bool IsEnabled() const { return m_isEnabled
; }
115 inline bool Enabled(void) const { return IsEnabled(); }
116 virtual void SetFocus();
117 virtual bool OnClose();
119 virtual void AddChild( wxWindow
*child
);
120 wxList
*GetChildren();
121 virtual void RemoveChild( wxWindow
*child
);
122 void SetReturnCode( int retCode
);
124 wxWindow
*GetParent() const
126 wxWindow
*GetGrandParent(void) const
127 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
128 void SetParent( wxWindow
*p
)
131 wxEvtHandler
*GetEventHandler();
132 void SetEventHandler( wxEvtHandler
*handler
);
133 void PushEventHandler( wxEvtHandler
*handler
);
134 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
136 virtual wxValidator
*GetValidator();
137 virtual void SetValidator( const wxValidator
&validator
);
139 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
140 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
142 bool IsBeingDeleted();
144 void SetId( wxWindowID id
);
147 void SetCursor( const wxCursor
&cursor
);
149 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
150 virtual void Clear();
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;
158 virtual wxColour
GetBackgroundColour() const;
159 virtual void SetBackgroundColour( const wxColour
&colour
);
160 virtual wxColour
GetForegroundColour() const;
161 virtual void SetForegroundColour( const wxColour
&colour
);
163 virtual int GetCharHeight(void) const;
164 virtual int GetCharWidth(void) const;
165 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
166 int *descent
= (int *) NULL
,
167 int *externalLeading
= (int *) NULL
,
168 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
170 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
171 { m_defaultBackgroundColour
= col
; }
172 virtual wxColour
GetDefaultBackgroundColour() const
173 { return m_defaultBackgroundColour
; }
174 virtual void SetDefaultForegroundColour( const wxColour
& col
)
175 { m_defaultForegroundColour
= col
; }
176 virtual wxColour
GetDefaultForegroundColour() const
177 { return m_defaultForegroundColour
; }
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;
196 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
198 virtual bool IsShown() const;
200 virtual void Raise(void);
201 virtual void Lower(void);
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
);
211 virtual bool Validate();
212 virtual bool TransferDataToWindow();
213 virtual bool TransferDataFromWindow();
214 void OnInitDialog( wxInitDialogEvent
&event
);
215 virtual void InitDialog();
217 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
219 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
220 virtual wxDropTarget
*GetDropTarget() const;
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;
228 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
230 virtual bool AcceptsFocus() const;
231 void UpdateWindowUI();
235 virtual GtkWidget
* GetConnectWidget(void);
236 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
237 void ConnectWidget( GtkWidget
*widget
);
238 void ConnectDnDWidget( GtkWidget
*widget
);
239 void DisconnectDnDWidget( GtkWidget
*widget
);
241 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
242 const wxSize
&size
, long style
, const wxString
&name
);
245 virtual void ImplementSetSize();
246 virtual void ImplementSetPosition();
251 int m_width
,m_height
;
252 int m_minWidth
,m_minHeight
;
253 int m_maxWidth
,m_maxHeight
;
255 wxEvtHandler
*m_eventHandler
;
256 wxValidator
*m_windowValidator
;
257 wxDropTarget
*m_pDropTarget
;
258 wxWindowID m_windowId
;
261 wxColour m_backgroundColour
;
262 wxColour m_defaultBackgroundColour
;
263 wxColour m_foregroundColour
;
264 wxColour m_defaultForegroundColour
;
265 wxRegion m_updateRegion
;
269 wxString m_windowName
;
270 wxAcceleratorTable m_acceleratorTable
;
273 GtkWidget
*m_wxwindow
;
274 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
275 float m_oldHorizontalPos
;
276 float m_oldVerticalPos
;
287 wxLayoutConstraints
*m_constraints
;
288 wxList
*m_constraintsInvolvedIn
;
289 wxSizer
*m_windowSizer
;
290 wxWindow
*m_sizerParent
;
293 wxLayoutConstraints
*GetConstraints() const;
294 void SetConstraints( wxLayoutConstraints
*constraints
);
295 void SetAutoLayout( bool autoLayout
);
296 bool GetAutoLayout() const;
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 ;
321 DECLARE_EVENT_TABLE()
324 #endif // __GTKWINDOWH__