1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKWINDOWH__
12 #define __GTKWINDOWH__
19 #include "wx/object.h"
22 #include "wx/validate.h"
23 #include "wx/cursor.h"
26 #include "wx/region.h"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 extern const char *wxFrameNameStr
;
35 extern wxList wxTopLevelWindows
;
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 class wxLayoutConstraints
;
43 class wxResourceTable
;
47 class wxVoidClientData
;
50 //-----------------------------------------------------------------------------
51 // callback definition for inserting a window (internal)
52 //-----------------------------------------------------------------------------
54 typedef void (*wxInsertChildFunction
)( wxWindow
*, wxWindow
* );
56 //-----------------------------------------------------------------------------
58 //-----------------------------------------------------------------------------
60 extern const char *wxPanelNameStr
;
61 extern const wxSize wxDefaultSize
;
62 extern const wxPoint wxDefaultPosition
;
64 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
72 virtual ~wxClientData() { }
75 //-----------------------------------------------------------------------------
77 //-----------------------------------------------------------------------------
79 class wxStringClientData
: public wxClientData
82 wxStringClientData() { }
83 wxStringClientData( wxString
&data
) { m_data
= data
; }
84 void SetData( wxString
&data
) { m_data
= data
; }
85 wxString
GetData() const { return m_data
; }
91 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
95 class wxWindow
: public wxEvtHandler
97 DECLARE_DYNAMIC_CLASS(wxWindow
)
101 wxWindow(wxWindow
*parent
, wxWindowID id
,
102 const wxPoint
& pos
= wxDefaultPosition
,
103 const wxSize
& size
= wxDefaultSize
,
105 const wxString
& name
= wxPanelNameStr
);
106 bool Create(wxWindow
*parent
, wxWindowID id
,
107 const wxPoint
& pos
= wxDefaultPosition
,
108 const wxSize
& size
= wxDefaultSize
,
110 const wxString
& name
= wxPanelNameStr
);
113 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
114 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
115 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
116 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
118 bool Close( bool force
= FALSE
);
119 virtual bool Destroy();
120 virtual bool DestroyChildren();
122 virtual void PrepareDC( wxDC
&dc
);
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
);
133 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
136 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
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
); }
146 void OnSize( wxSizeEvent
&event
);
147 void OnIdle( wxIdleEvent
& event
);
149 virtual bool Show( bool show
);
150 virtual void Enable( bool enable
);
151 virtual void MakeModal( bool modal
);
152 virtual bool IsEnabled() const { return m_isEnabled
; }
153 inline bool Enabled() const { return IsEnabled(); }
154 virtual void SetFocus();
155 virtual bool OnClose();
157 virtual void AddChild( wxWindow
*child
);
158 wxList
*GetChildren();
159 virtual void RemoveChild( wxWindow
*child
);
160 void SetReturnCode( int retCode
);
162 wxWindow
*GetParent() const
164 wxWindow
*GetGrandParent() const
165 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
166 void SetParent( wxWindow
*p
)
168 virtual wxWindow
*ReParent( wxWindow
*newParent
);
170 wxEvtHandler
*GetEventHandler();
171 void SetEventHandler( wxEvtHandler
*handler
);
172 void PushEventHandler( wxEvtHandler
*handler
);
173 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
175 virtual wxValidator
*GetValidator();
176 virtual void SetValidator( const wxValidator
&validator
);
178 virtual void SetClientObject( wxClientData
*data
);
179 virtual wxClientData
*GetClientObject();
181 virtual void SetClientData( void *data
);
182 virtual void *GetClientData();
184 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
185 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
187 bool IsBeingDeleted();
189 void SetId( wxWindowID id
);
192 void SetCursor( const wxCursor
&cursor
);
194 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
195 virtual void Clear();
197 virtual wxRegion
GetUpdateRegion() const;
198 virtual bool IsExposed(int x
, int y
) const;
199 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
200 virtual bool IsExposed(const wxPoint
& pt
) const;
201 virtual bool IsExposed(const wxRect
& rect
) const;
203 virtual wxColour
GetBackgroundColour() const;
204 virtual void SetBackgroundColour( const wxColour
&colour
);
205 virtual wxColour
GetForegroundColour() const;
206 virtual void SetForegroundColour( const wxColour
&colour
);
208 virtual int GetCharHeight() const;
209 virtual int GetCharWidth() const;
210 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
211 int *descent
= (int *) NULL
,
212 int *externalLeading
= (int *) NULL
,
213 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
215 virtual void SetFont( const wxFont
&font
);
216 virtual wxFont
*GetFont();
218 // For backward compatibility
219 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
220 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
221 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
222 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
224 virtual void SetWindowStyleFlag( long flag
);
225 virtual long GetWindowStyleFlag() const;
227 virtual void CaptureMouse();
228 virtual void ReleaseMouse();
230 virtual void SetTitle( const wxString
&title
);
231 virtual wxString
GetTitle() const;
232 virtual void SetName( const wxString
&name
);
233 virtual wxString
GetName() const;
234 virtual wxString
GetLabel() const;
236 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
238 virtual bool IsShown() const;
240 virtual void Raise();
241 virtual void Lower();
243 virtual bool IsRetained();
244 virtual wxWindow
*FindWindow( long id
);
245 virtual wxWindow
*FindWindow( const wxString
& name
);
247 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
248 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
250 virtual void ClientToScreen( int *x
, int *y
);
251 virtual void ScreenToClient( int *x
, int *y
);
253 virtual bool Validate();
254 virtual bool TransferDataToWindow();
255 virtual bool TransferDataFromWindow();
256 void OnInitDialog( wxInitDialogEvent
&event
);
257 virtual void InitDialog();
259 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
261 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
262 virtual wxDropTarget
*GetDropTarget() const;
264 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
265 int range
, bool refresh
= TRUE
);
266 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
267 virtual int GetScrollPos( int orient
) const;
268 virtual int GetScrollThumb( int orient
) const;
269 virtual int GetScrollRange( int orient
) const;
270 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
272 virtual bool AcceptsFocus() const;
274 void UpdateWindowUI();
278 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
279 const wxSize
&size
, long style
, const wxString
&name
);
281 virtual GtkWidget
*GetConnectWidget();
282 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
283 void ConnectWidget( GtkWidget
*widget
);
287 virtual wxPoint
GetClientAreaOrigin() const;
288 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
290 GtkStyle
*GetWidgetStyle();
291 void SetWidgetStyle();
292 virtual void ApplyWidgetStyle();
298 int m_width
,m_height
;
299 int m_minWidth
,m_minHeight
;
300 int m_maxWidth
,m_maxHeight
;
302 wxEvtHandler
*m_eventHandler
;
303 wxValidator
*m_windowValidator
;
304 wxDropTarget
*m_dropTarget
;
305 wxWindowID m_windowId
;
308 wxColour m_backgroundColour
;
309 wxColour m_foregroundColour
;
310 wxRegion m_updateRegion
;
314 wxString m_windowName
;
315 wxAcceleratorTable m_acceleratorTable
;
316 wxClientData
*m_clientObject
;
320 GtkWidget
*m_wxwindow
;
321 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
322 float m_oldHorizontalPos
;
323 float m_oldVerticalPos
;
331 GtkStyle
*m_widgetStyle
;
333 wxInsertChildFunction m_insertCallback
;
337 wxLayoutConstraints
*m_constraints
;
338 wxList
*m_constraintsInvolvedIn
;
339 wxSizer
*m_windowSizer
;
340 wxWindow
*m_sizerParent
;
343 wxLayoutConstraints
*GetConstraints() const;
344 void SetConstraints( wxLayoutConstraints
*constraints
);
345 void SetAutoLayout( bool autoLayout
);
346 bool GetAutoLayout() const;
348 void SetSizer( wxSizer
*sizer
);
349 wxSizer
*GetSizer() const;
350 void SetSizerParent( wxWindow
*win
);
351 wxWindow
*GetSizerParent() const;
352 void UnsetConstraints(wxLayoutConstraints
*c
);
353 inline wxList
*GetConstraintsInvolvedIn() const ;
354 void AddConstraintReference(wxWindow
*otherWin
);
355 void RemoveConstraintReference(wxWindow
*otherWin
);
356 void DeleteRelatedConstraints();
357 virtual void ResetConstraints();
358 virtual void SetConstraintSizes(bool recurse
= TRUE
);
359 virtual bool LayoutPhase1(int *noChanges
);
360 virtual bool LayoutPhase2(int *noChanges
);
361 virtual bool DoPhase(int);
362 virtual void TransformSizerToActual(int *x
, int *y
) const ;
363 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
364 virtual void SizerMove(int x
, int y
);
365 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
366 virtual void MoveConstraint(int x
, int y
);
367 virtual void GetSizeConstraint(int *w
, int *h
) const ;
368 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
369 virtual void GetPositionConstraint(int *x
, int *y
) const ;
372 DECLARE_EVENT_TABLE()
375 #endif // __GTKWINDOWH__