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
60 //-----------------------------------------------------------------------------
61 // callback definition for inserting a window (internal)
62 //-----------------------------------------------------------------------------
64 typedef void (*wxInsertChildFunction
)( wxWindow
*, wxWindow
* );
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
70 extern const char *wxPanelNameStr
;
71 extern const wxSize wxDefaultSize
;
72 extern const wxPoint wxDefaultPosition
;
74 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
82 virtual ~wxClientData() { }
85 //-----------------------------------------------------------------------------
87 //-----------------------------------------------------------------------------
89 class wxStringClientData
: public wxClientData
92 wxStringClientData() { }
93 wxStringClientData( wxString
&data
) { m_data
= data
; }
94 void SetData( wxString
&data
) { m_data
= data
; }
95 wxString
GetData() const { return m_data
; }
101 //-----------------------------------------------------------------------------
103 //-----------------------------------------------------------------------------
107 void debug_focus_in( GtkWidget
* widget
, const char* name
, const char* window
);
111 //-----------------------------------------------------------------------------
113 //-----------------------------------------------------------------------------
115 class wxWindow
: public wxEvtHandler
117 DECLARE_DYNAMIC_CLASS(wxWindow
)
121 wxWindow(wxWindow
*parent
, wxWindowID id
,
122 const wxPoint
& pos
= wxDefaultPosition
,
123 const wxSize
& size
= wxDefaultSize
,
125 const wxString
& name
= wxPanelNameStr
);
126 bool Create(wxWindow
*parent
, wxWindowID id
,
127 const wxPoint
& pos
= wxDefaultPosition
,
128 const wxSize
& size
= wxDefaultSize
,
130 const wxString
& name
= wxPanelNameStr
);
133 #if wxUSE_WX_RESOURCES
134 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
135 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
136 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
137 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
140 bool Close( bool force
= FALSE
);
141 virtual bool Destroy();
142 virtual bool DestroyChildren();
144 virtual void PrepareDC( wxDC
&dc
);
146 virtual void SetSize( int x
, int y
, int width
, int height
,
147 int sizeFlags
= wxSIZE_AUTO
);
148 virtual void SetSize( int width
, int height
);
150 virtual void Move( int x
, int y
);
152 virtual void GetSize( int *width
, int *height
) const;
153 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
155 virtual void SetClientSize( int const width
, int const height
);
157 virtual void GetClientSize( int *width
, int *height
) const;
158 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
160 virtual void GetPosition( int *x
, int *y
) const;
161 wxPoint
GetPosition() const { int w
, h
; GetPosition(& w
, & h
); return wxPoint(w
, h
); }
163 wxRect
GetRect() const
164 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
166 virtual void Centre( int direction
= wxHORIZONTAL
);
167 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
170 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
172 /* Dialog units translations. Implemented in wincmn.cpp. */
173 wxPoint
ConvertPixelsToDialog( const wxPoint
& pt
);
174 wxPoint
ConvertDialogToPixels( const wxPoint
& pt
);
175 inline wxSize
ConvertPixelsToDialog( const wxSize
& sz
)
176 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
177 inline wxSize
ConvertDialogToPixels( const wxSize
& sz
)
178 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
180 void OnSize( wxSizeEvent
&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
*parent
)
203 { m_parent
= parent
; }
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 void SetValidator( const wxValidator
&validator
);
212 virtual wxValidator
*GetValidator();
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 SetToolTip( const wxString
&tip
);
233 virtual void SetToolTip( wxToolTip
*tip
);
234 virtual wxToolTip
& GetToolTip();
236 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
237 virtual void Clear();
239 virtual wxRegion
GetUpdateRegion() const;
240 virtual bool IsExposed(int x
, int y
) const;
241 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
242 virtual bool IsExposed(const wxPoint
& pt
) const;
243 virtual bool IsExposed(const wxRect
& rect
) const;
245 virtual wxColour
GetBackgroundColour() const;
246 virtual void SetBackgroundColour( const wxColour
&colour
);
247 virtual wxColour
GetForegroundColour() const;
248 virtual void SetForegroundColour( const wxColour
&colour
);
250 virtual int GetCharHeight() const;
251 virtual int GetCharWidth() const;
252 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
253 int *descent
= (int *) NULL
,
254 int *externalLeading
= (int *) NULL
,
255 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
257 virtual void SetFont( const wxFont
&font
);
258 virtual wxFont
& GetFont() { return m_font
; }
260 // For backward compatibility
261 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
262 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
263 inline virtual wxFont
& GetLabelFont() { return GetFont(); };
264 inline virtual wxFont
& GetButtonFont() { return GetFont(); };
266 virtual void SetWindowStyleFlag( long flag
);
267 virtual long GetWindowStyleFlag() const;
269 virtual void CaptureMouse();
270 virtual void ReleaseMouse();
272 virtual void SetTitle( const wxString
&title
);
273 virtual wxString
GetTitle() const;
274 virtual void SetName( const wxString
&name
);
275 virtual wxString
GetName() const;
276 virtual wxString
GetLabel() const;
278 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
279 void OnKeyDown( wxKeyEvent
&event
);
281 virtual bool IsShown() const;
283 virtual void Raise();
284 virtual void Lower();
286 virtual bool IsRetained();
287 virtual wxWindow
*FindWindow( long id
);
288 virtual wxWindow
*FindWindow( const wxString
& name
);
290 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
291 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
293 virtual void ClientToScreen( int *x
, int *y
);
294 virtual void ScreenToClient( int *x
, int *y
);
296 virtual bool Validate();
297 virtual bool TransferDataToWindow();
298 virtual bool TransferDataFromWindow();
299 void OnInitDialog( wxInitDialogEvent
&event
);
300 virtual void InitDialog();
302 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
304 #if wxUSE_DRAG_AND_DROP
305 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
306 virtual wxDropTarget
*GetDropTarget() const;
309 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
310 int range
, bool refresh
= TRUE
);
311 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
312 virtual int GetScrollPos( int orient
) const;
313 virtual int GetScrollThumb( int orient
) const;
314 virtual int GetScrollRange( int orient
) const;
315 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
317 virtual bool AcceptsFocus() const;
319 void UpdateWindowUI();
323 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
324 const wxSize
&size
, long style
, const wxString
&name
);
327 virtual GtkWidget
* GetConnectWidget();
328 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
329 void ConnectWidget( GtkWidget
*widget
);
333 virtual wxPoint
GetClientAreaOrigin() const;
334 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
336 GtkStyle
*GetWidgetStyle();
337 void SetWidgetStyle();
338 virtual void ApplyWidgetStyle();
340 virtual void OnInternalIdle();
345 int m_width
,m_height
;
346 int m_minWidth
,m_minHeight
;
347 int m_maxWidth
,m_maxHeight
;
349 wxEvtHandler
*m_eventHandler
;
350 wxValidator
*m_windowValidator
;
351 #if wxUSE_DRAG_AND_DROP
352 wxDropTarget
*m_dropTarget
;
354 wxWindowID m_windowId
;
357 wxColour m_backgroundColour
;
358 wxColour m_foregroundColour
;
359 wxRegion m_updateRegion
;
363 wxString m_windowName
;
364 wxAcceleratorTable m_acceleratorTable
;
365 wxClientData
*m_clientObject
;
367 wxToolTip
*m_toolTip
;
370 GtkWidget
*m_wxwindow
;
371 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
372 float m_oldHorizontalPos
;
373 float m_oldVerticalPos
;
381 GtkStyle
*m_widgetStyle
;
385 wxInsertChildFunction m_insertCallback
;
389 wxLayoutConstraints
*m_constraints
;
390 wxList
*m_constraintsInvolvedIn
;
391 wxSizer
*m_windowSizer
;
392 wxWindow
*m_sizerParent
;
395 wxLayoutConstraints
*GetConstraints() const;
396 void SetConstraints( wxLayoutConstraints
*constraints
);
397 void SetAutoLayout( bool autoLayout
);
398 bool GetAutoLayout() const;
400 void SetSizer( wxSizer
*sizer
);
401 wxSizer
*GetSizer() const;
402 void SetSizerParent( wxWindow
*win
);
403 wxWindow
*GetSizerParent() const;
404 void UnsetConstraints(wxLayoutConstraints
*c
);
405 inline wxList
*GetConstraintsInvolvedIn() const ;
406 void AddConstraintReference(wxWindow
*otherWin
);
407 void RemoveConstraintReference(wxWindow
*otherWin
);
408 void DeleteRelatedConstraints();
409 virtual void ResetConstraints();
410 virtual void SetConstraintSizes(bool recurse
= TRUE
);
411 virtual bool LayoutPhase1(int *noChanges
);
412 virtual bool LayoutPhase2(int *noChanges
);
413 virtual bool DoPhase(int);
414 virtual void TransformSizerToActual(int *x
, int *y
) const ;
415 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
416 virtual void SizerMove(int x
, int y
);
417 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
418 virtual void MoveConstraint(int x
, int y
);
419 virtual void GetSizeConstraint(int *w
, int *h
) const ;
420 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
421 virtual void GetPositionConstraint(int *x
, int *y
) const ;
424 DECLARE_EVENT_TABLE()
427 #endif // __GTKWINDOWH__