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"
25 #include "wx/region.h"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
32 extern const char *wxFrameNameStr
;
33 extern wxList wxTopLevelWindows
;
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 class wxLayoutConstraints
;
43 class wxVoidClientData
;
45 #if wxUSE_WX_RESOURCES
46 class wxResourceTable
;
49 #if wxUSE_DRAG_AND_DROP
53 //-----------------------------------------------------------------------------
54 // callback definition for inserting a window (internal)
55 //-----------------------------------------------------------------------------
57 typedef void (*wxInsertChildFunction
)( wxWindow
*, wxWindow
* );
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
63 extern const char *wxPanelNameStr
;
64 extern const wxSize wxDefaultSize
;
65 extern const wxPoint wxDefaultPosition
;
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
75 virtual ~wxClientData() { }
78 //-----------------------------------------------------------------------------
80 //-----------------------------------------------------------------------------
82 class wxStringClientData
: public wxClientData
85 wxStringClientData() { }
86 wxStringClientData( wxString
&data
) { m_data
= data
; }
87 void SetData( wxString
&data
) { m_data
= data
; }
88 wxString
GetData() const { return m_data
; }
94 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
100 void debug_focus_in( GtkWidget
* widget
, const char* name
, const char* window
);
104 //-----------------------------------------------------------------------------
106 //-----------------------------------------------------------------------------
108 class wxWindow
: public wxEvtHandler
110 DECLARE_DYNAMIC_CLASS(wxWindow
)
114 wxWindow(wxWindow
*parent
, wxWindowID id
,
115 const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
,
118 const wxString
& name
= wxPanelNameStr
);
119 bool Create(wxWindow
*parent
, wxWindowID id
,
120 const wxPoint
& pos
= wxDefaultPosition
,
121 const wxSize
& size
= wxDefaultSize
,
123 const wxString
& name
= wxPanelNameStr
);
126 #if wxUSE_WX_RESOURCES
127 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
128 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
129 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
130 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
133 bool Close( bool force
= FALSE
);
134 virtual bool Destroy();
135 virtual bool DestroyChildren();
137 virtual void PrepareDC( wxDC
&dc
);
139 virtual void SetSize( int x
, int y
, int width
, int height
,
140 int sizeFlags
= wxSIZE_AUTO
);
141 virtual void SetSize( int width
, int height
);
143 virtual void Move( int x
, int y
);
145 virtual void GetSize( int *width
, int *height
) const;
146 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
148 virtual void SetClientSize( int const width
, int const height
);
150 virtual void GetClientSize( int *width
, int *height
) const;
151 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
153 virtual void GetPosition( int *x
, int *y
) const;
154 wxPoint
GetPosition() const { int w
, h
; GetPosition(& w
, & h
); return wxPoint(w
, h
); }
156 wxRect
GetRect() const
157 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
159 virtual void Centre( int direction
= wxHORIZONTAL
);
160 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
163 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
165 // Dialog units translations. Implemented in wincmn.cpp.
166 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
167 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
168 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
169 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
170 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
171 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
173 void OnSize( wxSizeEvent
&event
);
174 void OnIdle( wxIdleEvent
& event
);
176 virtual bool Show( bool show
);
177 virtual void Enable( bool enable
);
178 virtual void MakeModal( bool modal
);
179 virtual bool IsEnabled() const { return m_isEnabled
; }
180 inline bool Enabled() const { return IsEnabled(); }
181 virtual bool OnClose();
183 virtual void SetFocus();
184 static wxWindow
*FindFocus();
186 virtual void AddChild( wxWindow
*child
);
187 wxList
& GetChildren() { return m_children
; }
189 virtual void RemoveChild( wxWindow
*child
);
190 void SetReturnCode( int retCode
);
192 wxWindow
*GetParent() const
194 wxWindow
*GetGrandParent() const
195 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
196 void SetParent( wxWindow
*p
)
198 virtual wxWindow
*ReParent( wxWindow
*newParent
);
200 wxEvtHandler
*GetEventHandler() const;
201 void SetEventHandler( wxEvtHandler
*handler
);
202 void PushEventHandler( wxEvtHandler
*handler
);
203 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
205 virtual wxValidator
*GetValidator();
206 virtual void SetValidator( const wxValidator
&validator
);
208 virtual void SetClientObject( wxClientData
*data
);
209 virtual wxClientData
*GetClientObject();
211 virtual void SetClientData( void *data
);
212 virtual void *GetClientData();
214 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
215 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
217 bool IsBeingDeleted();
219 void SetId( wxWindowID id
);
220 wxWindowID
GetId() const;
222 void SetCursor( const wxCursor
&cursor
);
224 void WarpPointer(int x
, int y
);
226 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
227 virtual void Clear();
229 virtual wxRegion
GetUpdateRegion() const;
230 virtual bool IsExposed(int x
, int y
) const;
231 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
232 virtual bool IsExposed(const wxPoint
& pt
) const;
233 virtual bool IsExposed(const wxRect
& rect
) const;
235 virtual wxColour
GetBackgroundColour() const;
236 virtual void SetBackgroundColour( const wxColour
&colour
);
237 virtual wxColour
GetForegroundColour() const;
238 virtual void SetForegroundColour( const wxColour
&colour
);
240 virtual int GetCharHeight() const;
241 virtual int GetCharWidth() const;
242 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
243 int *descent
= (int *) NULL
,
244 int *externalLeading
= (int *) NULL
,
245 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
247 virtual void SetFont( const wxFont
&font
);
248 virtual wxFont
& GetFont() { return m_font
; }
250 // For backward compatibility
251 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
252 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
253 inline virtual wxFont
& GetLabelFont() { return GetFont(); };
254 inline virtual wxFont
& GetButtonFont() { return GetFont(); };
256 virtual void SetWindowStyleFlag( long flag
);
257 virtual long GetWindowStyleFlag() const;
259 virtual void CaptureMouse();
260 virtual void ReleaseMouse();
262 virtual void SetTitle( const wxString
&title
);
263 virtual wxString
GetTitle() const;
264 virtual void SetName( const wxString
&name
);
265 virtual wxString
GetName() const;
266 virtual wxString
GetLabel() const;
268 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
270 virtual bool IsShown() const;
272 virtual void Raise();
273 virtual void Lower();
275 virtual bool IsRetained();
276 virtual wxWindow
*FindWindow( long id
);
277 virtual wxWindow
*FindWindow( const wxString
& name
);
279 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
280 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
282 virtual void ClientToScreen( int *x
, int *y
);
283 virtual void ScreenToClient( int *x
, int *y
);
285 virtual bool Validate();
286 virtual bool TransferDataToWindow();
287 virtual bool TransferDataFromWindow();
288 void OnInitDialog( wxInitDialogEvent
&event
);
289 virtual void InitDialog();
291 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
293 #if wxUSE_DRAG_AND_DROP
294 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
295 virtual wxDropTarget
*GetDropTarget() const;
298 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
299 int range
, bool refresh
= TRUE
);
300 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
301 virtual int GetScrollPos( int orient
) const;
302 virtual int GetScrollThumb( int orient
) const;
303 virtual int GetScrollRange( int orient
) const;
304 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
306 virtual bool AcceptsFocus() const;
308 void UpdateWindowUI();
312 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
313 const wxSize
&size
, long style
, const wxString
&name
);
315 virtual GtkWidget
*GetConnectWidget();
316 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
317 void ConnectWidget( GtkWidget
*widget
);
321 virtual wxPoint
GetClientAreaOrigin() const;
322 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
324 GtkStyle
*GetWidgetStyle();
325 void SetWidgetStyle();
326 virtual void ApplyWidgetStyle();
332 int m_width
,m_height
;
333 int m_minWidth
,m_minHeight
;
334 int m_maxWidth
,m_maxHeight
;
336 wxEvtHandler
*m_eventHandler
;
337 wxValidator
*m_windowValidator
;
338 #if wxUSE_DRAG_AND_DROP
339 wxDropTarget
*m_dropTarget
;
341 wxWindowID m_windowId
;
344 wxColour m_backgroundColour
;
345 wxColour m_foregroundColour
;
346 wxRegion m_updateRegion
;
350 wxString m_windowName
;
351 wxAcceleratorTable m_acceleratorTable
;
352 wxClientData
*m_clientObject
;
356 GtkWidget
*m_wxwindow
;
357 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
358 float m_oldHorizontalPos
;
359 float m_oldVerticalPos
;
367 GtkStyle
*m_widgetStyle
;
371 wxInsertChildFunction m_insertCallback
;
375 wxLayoutConstraints
*m_constraints
;
376 wxList
*m_constraintsInvolvedIn
;
377 wxSizer
*m_windowSizer
;
378 wxWindow
*m_sizerParent
;
381 wxLayoutConstraints
*GetConstraints() const;
382 void SetConstraints( wxLayoutConstraints
*constraints
);
383 void SetAutoLayout( bool autoLayout
);
384 bool GetAutoLayout() const;
386 void SetSizer( wxSizer
*sizer
);
387 wxSizer
*GetSizer() const;
388 void SetSizerParent( wxWindow
*win
);
389 wxWindow
*GetSizerParent() const;
390 void UnsetConstraints(wxLayoutConstraints
*c
);
391 inline wxList
*GetConstraintsInvolvedIn() const ;
392 void AddConstraintReference(wxWindow
*otherWin
);
393 void RemoveConstraintReference(wxWindow
*otherWin
);
394 void DeleteRelatedConstraints();
395 virtual void ResetConstraints();
396 virtual void SetConstraintSizes(bool recurse
= TRUE
);
397 virtual bool LayoutPhase1(int *noChanges
);
398 virtual bool LayoutPhase2(int *noChanges
);
399 virtual bool DoPhase(int);
400 virtual void TransformSizerToActual(int *x
, int *y
) const ;
401 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
402 virtual void SizerMove(int x
, int y
);
403 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
404 virtual void MoveConstraint(int x
, int y
);
405 virtual void GetSizeConstraint(int *w
, int *h
) const ;
406 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
407 virtual void GetPositionConstraint(int *x
, int *y
) const ;
410 DECLARE_EVENT_TABLE()
413 #endif // __GTKWINDOWH__