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 #if wxUSE_WX_RESOURCES
44 class wxResourceTable
;
49 class wxVoidClientData
;
52 //-----------------------------------------------------------------------------
53 // callback definition for inserting a window (internal)
54 //-----------------------------------------------------------------------------
56 typedef void (*wxInsertChildFunction
)( wxWindow
*, wxWindow
* );
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
62 extern const char *wxPanelNameStr
;
63 extern const wxSize wxDefaultSize
;
64 extern const wxPoint wxDefaultPosition
;
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
74 virtual ~wxClientData() { }
77 //-----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
81 class wxStringClientData
: public wxClientData
84 wxStringClientData() { }
85 wxStringClientData( wxString
&data
) { m_data
= data
; }
86 void SetData( wxString
&data
) { m_data
= data
; }
87 wxString
GetData() const { return m_data
; }
93 //-----------------------------------------------------------------------------
95 //-----------------------------------------------------------------------------
99 void debug_focus_in( GtkWidget
* widget
, const char* name
, const char* window
);
103 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
107 class wxWindow
: public wxEvtHandler
109 DECLARE_DYNAMIC_CLASS(wxWindow
)
113 wxWindow(wxWindow
*parent
, wxWindowID id
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
117 const wxString
& name
= wxPanelNameStr
);
118 bool Create(wxWindow
*parent
, wxWindowID id
,
119 const wxPoint
& pos
= wxDefaultPosition
,
120 const wxSize
& size
= wxDefaultSize
,
122 const wxString
& name
= wxPanelNameStr
);
125 #if wxUSE_WX_RESOURCES
126 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
127 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
128 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
129 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
132 bool Close( bool force
= FALSE
);
133 virtual bool Destroy();
134 virtual bool DestroyChildren();
136 virtual void PrepareDC( wxDC
&dc
);
138 virtual void SetSize( int x
, int y
, int width
, int height
,
139 int sizeFlags
= wxSIZE_AUTO
);
140 virtual void SetSize( int width
, int height
);
142 virtual void Move( int x
, int y
);
144 virtual void GetSize( int *width
, int *height
) const;
145 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
147 virtual void SetClientSize( int const width
, int const height
);
149 virtual void GetClientSize( int *width
, int *height
) const;
150 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
152 virtual void GetPosition( int *x
, int *y
) const;
153 wxPoint
GetPosition() const { int w
, h
; GetPosition(& w
, & h
); return wxPoint(w
, h
); }
155 wxRect
GetRect() const
156 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
158 virtual void Centre( int direction
= wxHORIZONTAL
);
159 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
162 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
164 // Dialog units translations. Implemented in wincmn.cpp.
165 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
166 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
167 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
168 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
169 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
170 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
172 void OnSize( wxSizeEvent
&event
);
173 void OnIdle( wxIdleEvent
& event
);
175 virtual bool Show( bool show
);
176 virtual void Enable( bool enable
);
177 virtual void MakeModal( bool modal
);
178 virtual bool IsEnabled() const { return m_isEnabled
; }
179 inline bool Enabled() const { return IsEnabled(); }
180 virtual bool OnClose();
182 virtual void SetFocus();
183 static wxWindow
*FindFocus();
185 virtual void AddChild( wxWindow
*child
);
186 wxList
& GetChildren() { return m_children
; }
188 virtual void RemoveChild( wxWindow
*child
);
189 void SetReturnCode( int retCode
);
191 wxWindow
*GetParent() const
193 wxWindow
*GetGrandParent() const
194 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
195 void SetParent( wxWindow
*p
)
197 virtual wxWindow
*ReParent( wxWindow
*newParent
);
199 wxEvtHandler
*GetEventHandler() const;
200 void SetEventHandler( wxEvtHandler
*handler
);
201 void PushEventHandler( wxEvtHandler
*handler
);
202 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
204 virtual wxValidator
*GetValidator();
205 virtual void SetValidator( const wxValidator
&validator
);
207 virtual void SetClientObject( wxClientData
*data
);
208 virtual wxClientData
*GetClientObject();
210 virtual void SetClientData( void *data
);
211 virtual void *GetClientData();
213 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
214 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
216 bool IsBeingDeleted();
218 void SetId( wxWindowID id
);
219 wxWindowID
GetId() const;
221 void SetCursor( const wxCursor
&cursor
);
223 void WarpPointer(int x
, int y
);
225 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
226 virtual void Clear();
228 virtual wxRegion
GetUpdateRegion() const;
229 virtual bool IsExposed(int x
, int y
) const;
230 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
231 virtual bool IsExposed(const wxPoint
& pt
) const;
232 virtual bool IsExposed(const wxRect
& rect
) const;
234 virtual wxColour
GetBackgroundColour() const;
235 virtual void SetBackgroundColour( const wxColour
&colour
);
236 virtual wxColour
GetForegroundColour() const;
237 virtual void SetForegroundColour( const wxColour
&colour
);
239 virtual int GetCharHeight() const;
240 virtual int GetCharWidth() const;
241 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
242 int *descent
= (int *) NULL
,
243 int *externalLeading
= (int *) NULL
,
244 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
246 virtual void SetFont( const wxFont
&font
);
247 virtual wxFont
& GetFont() { return m_font
; }
249 // For backward compatibility
250 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
251 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
252 inline virtual wxFont
& GetLabelFont() { return GetFont(); };
253 inline virtual wxFont
& GetButtonFont() { return GetFont(); };
255 virtual void SetWindowStyleFlag( long flag
);
256 virtual long GetWindowStyleFlag() const;
258 virtual void CaptureMouse();
259 virtual void ReleaseMouse();
261 virtual void SetTitle( const wxString
&title
);
262 virtual wxString
GetTitle() const;
263 virtual void SetName( const wxString
&name
);
264 virtual wxString
GetName() const;
265 virtual wxString
GetLabel() const;
267 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
269 virtual bool IsShown() const;
271 virtual void Raise();
272 virtual void Lower();
274 virtual bool IsRetained();
275 virtual wxWindow
*FindWindow( long id
);
276 virtual wxWindow
*FindWindow( const wxString
& name
);
278 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
279 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
281 virtual void ClientToScreen( int *x
, int *y
);
282 virtual void ScreenToClient( int *x
, int *y
);
284 virtual bool Validate();
285 virtual bool TransferDataToWindow();
286 virtual bool TransferDataFromWindow();
287 void OnInitDialog( wxInitDialogEvent
&event
);
288 virtual void InitDialog();
290 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
292 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
293 virtual wxDropTarget
*GetDropTarget() const;
295 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
296 int range
, bool refresh
= TRUE
);
297 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
298 virtual int GetScrollPos( int orient
) const;
299 virtual int GetScrollThumb( int orient
) const;
300 virtual int GetScrollRange( int orient
) const;
301 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
303 virtual bool AcceptsFocus() const;
305 void UpdateWindowUI();
309 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
310 const wxSize
&size
, long style
, const wxString
&name
);
312 virtual GtkWidget
*GetConnectWidget();
313 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
314 void ConnectWidget( GtkWidget
*widget
);
318 virtual wxPoint
GetClientAreaOrigin() const;
319 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
321 GtkStyle
*GetWidgetStyle();
322 void SetWidgetStyle();
323 virtual void ApplyWidgetStyle();
329 int m_width
,m_height
;
330 int m_minWidth
,m_minHeight
;
331 int m_maxWidth
,m_maxHeight
;
333 wxEvtHandler
*m_eventHandler
;
334 wxValidator
*m_windowValidator
;
335 wxDropTarget
*m_dropTarget
;
336 wxWindowID m_windowId
;
339 wxColour m_backgroundColour
;
340 wxColour m_foregroundColour
;
341 wxRegion m_updateRegion
;
345 wxString m_windowName
;
346 wxAcceleratorTable m_acceleratorTable
;
347 wxClientData
*m_clientObject
;
351 GtkWidget
*m_wxwindow
;
352 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
353 float m_oldHorizontalPos
;
354 float m_oldVerticalPos
;
362 GtkStyle
*m_widgetStyle
;
366 wxInsertChildFunction m_insertCallback
;
370 wxLayoutConstraints
*m_constraints
;
371 wxList
*m_constraintsInvolvedIn
;
372 wxSizer
*m_windowSizer
;
373 wxWindow
*m_sizerParent
;
376 wxLayoutConstraints
*GetConstraints() const;
377 void SetConstraints( wxLayoutConstraints
*constraints
);
378 void SetAutoLayout( bool autoLayout
);
379 bool GetAutoLayout() const;
381 void SetSizer( wxSizer
*sizer
);
382 wxSizer
*GetSizer() const;
383 void SetSizerParent( wxWindow
*win
);
384 wxWindow
*GetSizerParent() const;
385 void UnsetConstraints(wxLayoutConstraints
*c
);
386 inline wxList
*GetConstraintsInvolvedIn() const ;
387 void AddConstraintReference(wxWindow
*otherWin
);
388 void RemoveConstraintReference(wxWindow
*otherWin
);
389 void DeleteRelatedConstraints();
390 virtual void ResetConstraints();
391 virtual void SetConstraintSizes(bool recurse
= TRUE
);
392 virtual bool LayoutPhase1(int *noChanges
);
393 virtual bool LayoutPhase2(int *noChanges
);
394 virtual bool DoPhase(int);
395 virtual void TransformSizerToActual(int *x
, int *y
) const ;
396 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
397 virtual void SizerMove(int x
, int y
);
398 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
399 virtual void MoveConstraint(int x
, int y
);
400 virtual void GetSizeConstraint(int *w
, int *h
) const ;
401 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
402 virtual void GetPositionConstraint(int *x
, int *y
) const ;
405 DECLARE_EVENT_TABLE()
408 #endif // __GTKWINDOWH__