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 wxWindow
* wxGetActiveWindow();
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 class wxLayoutConstraints
;
49 class wxVoidClientData
;
51 #if wxUSE_WX_RESOURCES
52 class wxResourceTable
;
55 #if wxUSE_DRAG_AND_DROP
59 //-----------------------------------------------------------------------------
60 // callback definition for inserting a window (internal)
61 //-----------------------------------------------------------------------------
63 typedef void (*wxInsertChildFunction
)( wxWindow
*, wxWindow
* );
65 //-----------------------------------------------------------------------------
67 //-----------------------------------------------------------------------------
69 extern const char *wxPanelNameStr
;
70 extern const wxSize wxDefaultSize
;
71 extern const wxPoint wxDefaultPosition
;
73 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
81 virtual ~wxClientData() { }
84 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
88 class wxStringClientData
: public wxClientData
91 wxStringClientData() { }
92 wxStringClientData( wxString
&data
) { m_data
= data
; }
93 void SetData( wxString
&data
) { m_data
= data
; }
94 wxString
GetData() const { return m_data
; }
100 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
106 void debug_focus_in( GtkWidget
* widget
, const char* name
, const char* window
);
110 //-----------------------------------------------------------------------------
112 //-----------------------------------------------------------------------------
114 class wxWindow
: public wxEvtHandler
116 DECLARE_DYNAMIC_CLASS(wxWindow
)
120 wxWindow(wxWindow
*parent
, wxWindowID id
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
124 const wxString
& name
= wxPanelNameStr
);
125 bool Create(wxWindow
*parent
, wxWindowID id
,
126 const wxPoint
& pos
= wxDefaultPosition
,
127 const wxSize
& size
= wxDefaultSize
,
129 const wxString
& name
= wxPanelNameStr
);
132 #if wxUSE_WX_RESOURCES
133 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
134 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
135 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
136 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
139 bool Close( bool force
= FALSE
);
140 virtual bool Destroy();
141 virtual bool DestroyChildren();
143 virtual void PrepareDC( wxDC
&dc
);
145 virtual void SetSize( int x
, int y
, int width
, int height
,
146 int sizeFlags
= wxSIZE_AUTO
);
147 virtual void SetSize( int width
, int height
);
149 virtual void Move( int x
, int y
);
151 virtual void GetSize( int *width
, int *height
) const;
152 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
154 virtual void SetClientSize( int const width
, int const height
);
156 virtual void GetClientSize( int *width
, int *height
) const;
157 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
159 virtual void GetPosition( int *x
, int *y
) const;
160 wxPoint
GetPosition() const { int w
, h
; GetPosition(& w
, & h
); return wxPoint(w
, h
); }
162 wxRect
GetRect() const
163 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
165 virtual void Centre( int direction
= wxHORIZONTAL
);
166 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
169 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
171 // Dialog units translations. Implemented in wincmn.cpp.
172 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
173 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
174 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
175 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
176 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
177 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
179 void OnSize( wxSizeEvent
&event
);
180 void OnIdle( wxIdleEvent
& event
);
182 virtual bool Show( bool show
);
183 virtual void Enable( bool enable
);
184 virtual void MakeModal( bool modal
);
185 virtual bool IsEnabled() const { return m_isEnabled
; }
186 inline bool Enabled() const { return IsEnabled(); }
187 virtual bool OnClose();
189 virtual void SetFocus();
190 static wxWindow
*FindFocus();
192 virtual void AddChild( wxWindow
*child
);
193 wxList
& GetChildren() { return m_children
; }
195 virtual void RemoveChild( wxWindow
*child
);
196 void SetReturnCode( int retCode
);
198 wxWindow
*GetParent() const
200 wxWindow
*GetGrandParent() const
201 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
202 void SetParent( wxWindow
*p
)
204 virtual wxWindow
*ReParent( wxWindow
*newParent
);
206 wxEvtHandler
*GetEventHandler() const;
207 void SetEventHandler( wxEvtHandler
*handler
);
208 void PushEventHandler( wxEvtHandler
*handler
);
209 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
211 virtual wxValidator
*GetValidator();
212 virtual void SetValidator( const wxValidator
&validator
);
214 virtual void SetClientObject( wxClientData
*data
);
215 virtual wxClientData
*GetClientObject();
217 virtual void SetClientData( void *data
);
218 virtual void *GetClientData();
220 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
221 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
223 bool IsBeingDeleted();
225 void SetId( wxWindowID id
);
226 wxWindowID
GetId() const;
228 void SetCursor( const wxCursor
&cursor
);
230 void WarpPointer(int x
, int y
);
232 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
233 virtual void Clear();
235 virtual wxRegion
GetUpdateRegion() const;
236 virtual bool IsExposed(int x
, int y
) const;
237 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
238 virtual bool IsExposed(const wxPoint
& pt
) const;
239 virtual bool IsExposed(const wxRect
& rect
) const;
241 virtual wxColour
GetBackgroundColour() const;
242 virtual void SetBackgroundColour( const wxColour
&colour
);
243 virtual wxColour
GetForegroundColour() const;
244 virtual void SetForegroundColour( const wxColour
&colour
);
246 virtual int GetCharHeight() const;
247 virtual int GetCharWidth() const;
248 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
249 int *descent
= (int *) NULL
,
250 int *externalLeading
= (int *) NULL
,
251 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
253 virtual void SetFont( const wxFont
&font
);
254 virtual wxFont
& GetFont() { return m_font
; }
256 // For backward compatibility
257 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
258 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
259 inline virtual wxFont
& GetLabelFont() { return GetFont(); };
260 inline virtual wxFont
& GetButtonFont() { return GetFont(); };
262 virtual void SetWindowStyleFlag( long flag
);
263 virtual long GetWindowStyleFlag() const;
265 virtual void CaptureMouse();
266 virtual void ReleaseMouse();
268 virtual void SetTitle( const wxString
&title
);
269 virtual wxString
GetTitle() const;
270 virtual void SetName( const wxString
&name
);
271 virtual wxString
GetName() const;
272 virtual wxString
GetLabel() const;
274 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
276 virtual bool IsShown() const;
278 virtual void Raise();
279 virtual void Lower();
281 virtual bool IsRetained();
282 virtual wxWindow
*FindWindow( long id
);
283 virtual wxWindow
*FindWindow( const wxString
& name
);
285 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
286 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
288 virtual void ClientToScreen( int *x
, int *y
);
289 virtual void ScreenToClient( int *x
, int *y
);
291 virtual bool Validate();
292 virtual bool TransferDataToWindow();
293 virtual bool TransferDataFromWindow();
294 void OnInitDialog( wxInitDialogEvent
&event
);
295 virtual void InitDialog();
297 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
299 #if wxUSE_DRAG_AND_DROP
300 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
301 virtual wxDropTarget
*GetDropTarget() const;
304 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
305 int range
, bool refresh
= TRUE
);
306 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
307 virtual int GetScrollPos( int orient
) const;
308 virtual int GetScrollThumb( int orient
) const;
309 virtual int GetScrollRange( int orient
) const;
310 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
312 virtual bool AcceptsFocus() const;
314 void UpdateWindowUI();
318 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
319 const wxSize
&size
, long style
, const wxString
&name
);
321 virtual GtkWidget
*GetConnectWidget();
322 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
323 void ConnectWidget( GtkWidget
*widget
);
327 virtual wxPoint
GetClientAreaOrigin() const;
328 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
330 GtkStyle
*GetWidgetStyle();
331 void SetWidgetStyle();
332 virtual void ApplyWidgetStyle();
338 int m_width
,m_height
;
339 int m_minWidth
,m_minHeight
;
340 int m_maxWidth
,m_maxHeight
;
342 wxEvtHandler
*m_eventHandler
;
343 wxValidator
*m_windowValidator
;
344 #if wxUSE_DRAG_AND_DROP
345 wxDropTarget
*m_dropTarget
;
347 wxWindowID m_windowId
;
350 wxColour m_backgroundColour
;
351 wxColour m_foregroundColour
;
352 wxRegion m_updateRegion
;
356 wxString m_windowName
;
357 wxAcceleratorTable m_acceleratorTable
;
358 wxClientData
*m_clientObject
;
362 GtkWidget
*m_wxwindow
;
363 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
364 float m_oldHorizontalPos
;
365 float m_oldVerticalPos
;
373 GtkStyle
*m_widgetStyle
;
377 wxInsertChildFunction m_insertCallback
;
381 wxLayoutConstraints
*m_constraints
;
382 wxList
*m_constraintsInvolvedIn
;
383 wxSizer
*m_windowSizer
;
384 wxWindow
*m_sizerParent
;
387 wxLayoutConstraints
*GetConstraints() const;
388 void SetConstraints( wxLayoutConstraints
*constraints
);
389 void SetAutoLayout( bool autoLayout
);
390 bool GetAutoLayout() const;
392 void SetSizer( wxSizer
*sizer
);
393 wxSizer
*GetSizer() const;
394 void SetSizerParent( wxWindow
*win
);
395 wxWindow
*GetSizerParent() const;
396 void UnsetConstraints(wxLayoutConstraints
*c
);
397 inline wxList
*GetConstraintsInvolvedIn() const ;
398 void AddConstraintReference(wxWindow
*otherWin
);
399 void RemoveConstraintReference(wxWindow
*otherWin
);
400 void DeleteRelatedConstraints();
401 virtual void ResetConstraints();
402 virtual void SetConstraintSizes(bool recurse
= TRUE
);
403 virtual bool LayoutPhase1(int *noChanges
);
404 virtual bool LayoutPhase2(int *noChanges
);
405 virtual bool DoPhase(int);
406 virtual void TransformSizerToActual(int *x
, int *y
) const ;
407 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
408 virtual void SizerMove(int x
, int y
);
409 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
410 virtual void MoveConstraint(int x
, int y
);
411 virtual void GetSizeConstraint(int *w
, int *h
) const ;
412 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
413 virtual void GetPositionConstraint(int *x
, int *y
) const ;
416 DECLARE_EVENT_TABLE()
419 #endif // __GTKWINDOWH__