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 wxVoidClientData
: public wxClientData
82 wxVoidClientData() { m_data
= NULL
; }
83 wxVoidClientData( void *data
) { m_data
= data
; }
84 void SetData( void* data
) { m_data
= data
; }
85 void *GetData() const { return m_data
; }
91 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
95 class wxStringClientData
: public wxClientData
98 wxStringClientData() { }
99 wxStringClientData( wxString
&data
) { m_data
= data
; }
100 void SetData( wxString
&data
) { m_data
= data
; }
101 wxString
GetData() const { return m_data
; }
107 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
111 class wxWindow
: public wxEvtHandler
113 DECLARE_DYNAMIC_CLASS(wxWindow
)
117 wxWindow(wxWindow
*parent
, wxWindowID id
,
118 const wxPoint
& pos
= wxDefaultPosition
,
119 const wxSize
& size
= wxDefaultSize
,
121 const wxString
& name
= wxPanelNameStr
);
122 bool Create(wxWindow
*parent
, wxWindowID id
,
123 const wxPoint
& pos
= wxDefaultPosition
,
124 const wxSize
& size
= wxDefaultSize
,
126 const wxString
& name
= wxPanelNameStr
);
129 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
130 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
131 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
132 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
134 bool Close( bool force
= FALSE
);
135 virtual bool Destroy();
136 virtual bool DestroyChildren();
138 virtual void PrepareDC( wxDC
&dc
);
140 virtual void SetSize( int x
, int y
, int width
, int height
,
141 int sizeFlags
= wxSIZE_AUTO
);
142 virtual void SetSize( int width
, int height
);
143 virtual void Move( int x
, int y
);
144 virtual void GetSize( int *width
, int *height
) const;
145 virtual void SetClientSize( int const width
, int const height
);
146 virtual void GetClientSize( int *width
, int *height
) const;
147 virtual void GetPosition( int *x
, int *y
) const;
148 virtual void Centre( int direction
= wxHORIZONTAL
);
149 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
152 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
154 // Dialog units translations. Implemented in wincmn.cpp.
155 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
156 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
157 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
158 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
159 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
160 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
162 void OnSize( wxSizeEvent
&event
);
163 void OnIdle( wxIdleEvent
& event
);
165 virtual bool Show( bool show
);
166 virtual void Enable( bool enable
);
167 virtual void MakeModal( bool modal
);
168 virtual bool IsEnabled() const { return m_isEnabled
; }
169 inline bool Enabled() const { return IsEnabled(); }
170 virtual void SetFocus();
171 virtual bool OnClose();
173 virtual void AddChild( wxWindow
*child
);
174 wxList
*GetChildren();
175 virtual void RemoveChild( wxWindow
*child
);
176 void SetReturnCode( int retCode
);
178 wxWindow
*GetParent() const
180 wxWindow
*GetGrandParent() const
181 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
182 void SetParent( wxWindow
*p
)
185 wxEvtHandler
*GetEventHandler();
186 void SetEventHandler( wxEvtHandler
*handler
);
187 void PushEventHandler( wxEvtHandler
*handler
);
188 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
190 virtual wxValidator
*GetValidator();
191 virtual void SetValidator( const wxValidator
&validator
);
193 virtual void SetClientObject( wxClientData
*data
);
194 virtual wxClientData
*GetClientObject();
196 virtual void SetClientData( void *data
);
197 virtual void *GetClientData();
200 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
201 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
203 bool IsBeingDeleted();
205 void SetId( wxWindowID id
);
208 void SetCursor( const wxCursor
&cursor
);
210 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
211 virtual void Clear();
213 virtual wxRegion
GetUpdateRegion() const;
214 virtual bool IsExposed(int x
, int y
) const;
215 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
216 virtual bool IsExposed(const wxPoint
& pt
) const;
217 virtual bool IsExposed(const wxRect
& rect
) const;
219 virtual wxColour
GetBackgroundColour() const;
220 virtual void SetBackgroundColour( const wxColour
&colour
);
221 virtual wxColour
GetForegroundColour() const;
222 virtual void SetForegroundColour( const wxColour
&colour
);
224 virtual int GetCharHeight() const;
225 virtual int GetCharWidth() const;
226 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
227 int *descent
= (int *) NULL
,
228 int *externalLeading
= (int *) NULL
,
229 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
231 virtual void SetFont( const wxFont
&font
);
232 virtual wxFont
*GetFont();
234 // For backward compatibility
235 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
236 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
237 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
238 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
240 virtual void SetWindowStyleFlag( long flag
);
241 virtual long GetWindowStyleFlag() const;
243 virtual void CaptureMouse();
244 virtual void ReleaseMouse();
246 virtual void SetTitle( const wxString
&title
);
247 virtual wxString
GetTitle() const;
248 virtual void SetName( const wxString
&name
);
249 virtual wxString
GetName() const;
250 virtual wxString
GetLabel() const;
252 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
254 virtual bool IsShown() const;
256 virtual void Raise();
257 virtual void Lower();
259 virtual bool IsRetained();
260 virtual wxWindow
*FindWindow( long id
);
261 virtual wxWindow
*FindWindow( const wxString
& name
);
263 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
264 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
266 virtual void ClientToScreen( int *x
, int *y
);
267 virtual void ScreenToClient( int *x
, int *y
);
269 virtual bool Validate();
270 virtual bool TransferDataToWindow();
271 virtual bool TransferDataFromWindow();
272 void OnInitDialog( wxInitDialogEvent
&event
);
273 virtual void InitDialog();
275 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
277 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
278 virtual wxDropTarget
*GetDropTarget() const;
280 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
281 int range
, bool refresh
= TRUE
);
282 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
283 virtual int GetScrollPos( int orient
) const;
284 virtual int GetScrollThumb( int orient
) const;
285 virtual int GetScrollRange( int orient
) const;
286 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
288 virtual bool AcceptsFocus() const;
290 void UpdateWindowUI();
294 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
295 const wxSize
&size
, long style
, const wxString
&name
);
297 virtual GtkWidget
*GetConnectWidget();
298 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
299 void ConnectWidget( GtkWidget
*widget
);
300 void ConnectDnDWidget( GtkWidget
*widget
);
301 void DisconnectDnDWidget( GtkWidget
*widget
);
305 virtual void ImplementSetSize();
306 virtual void ImplementSetPosition();
308 virtual wxPoint
GetClientAreaOrigin() const;
309 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
311 GtkStyle
*GetWidgetStyle();
312 void SetWidgetStyle();
313 virtual void ApplyWidgetStyle();
319 int m_width
,m_height
;
320 int m_minWidth
,m_minHeight
;
321 int m_maxWidth
,m_maxHeight
;
323 wxEvtHandler
*m_eventHandler
;
324 wxValidator
*m_windowValidator
;
325 wxDropTarget
*m_dropTarget
;
326 wxWindowID m_windowId
;
329 wxColour m_backgroundColour
;
330 wxColour m_foregroundColour
;
331 wxRegion m_updateRegion
;
335 wxString m_windowName
;
336 wxAcceleratorTable m_acceleratorTable
;
337 wxClientData
*m_clientData
;
340 GtkWidget
*m_wxwindow
;
341 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
342 float m_oldHorizontalPos
;
343 float m_oldVerticalPos
;
351 GtkStyle
*m_widgetStyle
;
353 wxInsertChildFunction m_insertCallback
;
357 wxLayoutConstraints
*m_constraints
;
358 wxList
*m_constraintsInvolvedIn
;
359 wxSizer
*m_windowSizer
;
360 wxWindow
*m_sizerParent
;
363 wxLayoutConstraints
*GetConstraints() const;
364 void SetConstraints( wxLayoutConstraints
*constraints
);
365 void SetAutoLayout( bool autoLayout
);
366 bool GetAutoLayout() const;
368 void SetSizer( wxSizer
*sizer
);
369 wxSizer
*GetSizer() const;
370 void SetSizerParent( wxWindow
*win
);
371 wxWindow
*GetSizerParent() const;
372 void UnsetConstraints(wxLayoutConstraints
*c
);
373 inline wxList
*GetConstraintsInvolvedIn() const ;
374 void AddConstraintReference(wxWindow
*otherWin
);
375 void RemoveConstraintReference(wxWindow
*otherWin
);
376 void DeleteRelatedConstraints();
377 virtual void ResetConstraints();
378 virtual void SetConstraintSizes(bool recurse
= TRUE
);
379 virtual bool LayoutPhase1(int *noChanges
);
380 virtual bool LayoutPhase2(int *noChanges
);
381 virtual bool DoPhase(int);
382 virtual void TransformSizerToActual(int *x
, int *y
) const ;
383 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
384 virtual void SizerMove(int x
, int y
);
385 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
386 virtual void MoveConstraint(int x
, int y
);
387 virtual void GetSizeConstraint(int *w
, int *h
) const ;
388 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
389 virtual void GetPositionConstraint(int *x
, int *y
) const ;
392 DECLARE_EVENT_TABLE()
395 #endif // __GTKWINDOWH__