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 wxStringClientData
: public wxClientData
82 wxStringClientData() { }
83 wxStringClientData( wxString
&data
) { m_data
= data
; }
84 void SetData( wxString
&data
) { m_data
= data
; }
85 wxString
GetData() const { return m_data
; }
91 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
97 void debug_focus_in( GtkWidget
* widget
, const char* name
, const char* window
);
101 //-----------------------------------------------------------------------------
103 //-----------------------------------------------------------------------------
105 class wxWindow
: public wxEvtHandler
107 DECLARE_DYNAMIC_CLASS(wxWindow
)
111 wxWindow(wxWindow
*parent
, wxWindowID id
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
115 const wxString
& name
= wxPanelNameStr
);
116 bool Create(wxWindow
*parent
, wxWindowID id
,
117 const wxPoint
& pos
= wxDefaultPosition
,
118 const wxSize
& size
= wxDefaultSize
,
120 const wxString
& name
= wxPanelNameStr
);
123 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
124 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
125 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
126 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
128 bool Close( bool force
= FALSE
);
129 virtual bool Destroy();
130 virtual bool DestroyChildren();
132 virtual void PrepareDC( wxDC
&dc
);
134 virtual void SetSize( int x
, int y
, int width
, int height
,
135 int sizeFlags
= wxSIZE_AUTO
);
136 virtual void SetSize( int width
, int height
);
138 virtual void Move( int x
, int y
);
140 virtual void GetSize( int *width
, int *height
) const;
141 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
143 virtual void SetClientSize( int const width
, int const height
);
145 virtual void GetClientSize( int *width
, int *height
) const;
146 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
148 virtual void GetPosition( int *x
, int *y
) const;
149 wxPoint
GetPosition() const { int w
, h
; GetPosition(& w
, & h
); return wxPoint(w
, h
); }
151 wxRect
GetRect() const
152 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
154 virtual void Centre( int direction
= wxHORIZONTAL
);
155 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
158 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
160 // Dialog units translations. Implemented in wincmn.cpp.
161 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
162 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
163 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
164 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
165 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
166 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
168 void OnSize( wxSizeEvent
&event
);
169 void OnIdle( wxIdleEvent
& event
);
171 virtual bool Show( bool show
);
172 virtual void Enable( bool enable
);
173 virtual void MakeModal( bool modal
);
174 virtual bool IsEnabled() const { return m_isEnabled
; }
175 inline bool Enabled() const { return IsEnabled(); }
176 virtual bool OnClose();
178 virtual void SetFocus();
179 static wxWindow
*FindFocus();
181 virtual void AddChild( wxWindow
*child
);
182 wxList
& GetChildren() { return m_children
; }
184 virtual void RemoveChild( wxWindow
*child
);
185 void SetReturnCode( int retCode
);
187 wxWindow
*GetParent() const
189 wxWindow
*GetGrandParent() const
190 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
191 void SetParent( wxWindow
*p
)
193 virtual wxWindow
*ReParent( wxWindow
*newParent
);
195 wxEvtHandler
*GetEventHandler() const;
196 void SetEventHandler( wxEvtHandler
*handler
);
197 void PushEventHandler( wxEvtHandler
*handler
);
198 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
200 virtual wxValidator
*GetValidator();
201 virtual void SetValidator( const wxValidator
&validator
);
203 virtual void SetClientObject( wxClientData
*data
);
204 virtual wxClientData
*GetClientObject();
206 virtual void SetClientData( void *data
);
207 virtual void *GetClientData();
209 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
210 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
212 bool IsBeingDeleted();
214 void SetId( wxWindowID id
);
215 wxWindowID
GetId() const;
217 void SetCursor( const wxCursor
&cursor
);
219 void WarpPointer(int x
, int y
);
221 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
222 virtual void Clear();
224 virtual wxRegion
GetUpdateRegion() const;
225 virtual bool IsExposed(int x
, int y
) const;
226 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
227 virtual bool IsExposed(const wxPoint
& pt
) const;
228 virtual bool IsExposed(const wxRect
& rect
) const;
230 virtual wxColour
GetBackgroundColour() const;
231 virtual void SetBackgroundColour( const wxColour
&colour
);
232 virtual wxColour
GetForegroundColour() const;
233 virtual void SetForegroundColour( const wxColour
&colour
);
235 virtual int GetCharHeight() const;
236 virtual int GetCharWidth() const;
237 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
238 int *descent
= (int *) NULL
,
239 int *externalLeading
= (int *) NULL
,
240 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
242 virtual void SetFont( const wxFont
&font
);
243 virtual wxFont
& GetFont() { return m_font
; }
245 // For backward compatibility
246 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
247 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
248 inline virtual wxFont
& GetLabelFont() { return GetFont(); };
249 inline virtual wxFont
& GetButtonFont() { return GetFont(); };
251 virtual void SetWindowStyleFlag( long flag
);
252 virtual long GetWindowStyleFlag() const;
254 virtual void CaptureMouse();
255 virtual void ReleaseMouse();
257 virtual void SetTitle( const wxString
&title
);
258 virtual wxString
GetTitle() const;
259 virtual void SetName( const wxString
&name
);
260 virtual wxString
GetName() const;
261 virtual wxString
GetLabel() const;
263 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
265 virtual bool IsShown() const;
267 virtual void Raise();
268 virtual void Lower();
270 virtual bool IsRetained();
271 virtual wxWindow
*FindWindow( long id
);
272 virtual wxWindow
*FindWindow( const wxString
& name
);
274 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
275 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
277 virtual void ClientToScreen( int *x
, int *y
);
278 virtual void ScreenToClient( int *x
, int *y
);
280 virtual bool Validate();
281 virtual bool TransferDataToWindow();
282 virtual bool TransferDataFromWindow();
283 void OnInitDialog( wxInitDialogEvent
&event
);
284 virtual void InitDialog();
286 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
288 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
289 virtual wxDropTarget
*GetDropTarget() const;
291 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
292 int range
, bool refresh
= TRUE
);
293 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
294 virtual int GetScrollPos( int orient
) const;
295 virtual int GetScrollThumb( int orient
) const;
296 virtual int GetScrollRange( int orient
) const;
297 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
299 virtual bool AcceptsFocus() const;
301 void UpdateWindowUI();
305 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
306 const wxSize
&size
, long style
, const wxString
&name
);
308 virtual GtkWidget
*GetConnectWidget();
309 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
310 void ConnectWidget( GtkWidget
*widget
);
314 virtual wxPoint
GetClientAreaOrigin() const;
315 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
317 GtkStyle
*GetWidgetStyle();
318 void SetWidgetStyle();
319 virtual void ApplyWidgetStyle();
325 int m_width
,m_height
;
326 int m_minWidth
,m_minHeight
;
327 int m_maxWidth
,m_maxHeight
;
329 wxEvtHandler
*m_eventHandler
;
330 wxValidator
*m_windowValidator
;
331 wxDropTarget
*m_dropTarget
;
332 wxWindowID m_windowId
;
335 wxColour m_backgroundColour
;
336 wxColour m_foregroundColour
;
337 wxRegion m_updateRegion
;
341 wxString m_windowName
;
342 wxAcceleratorTable m_acceleratorTable
;
343 wxClientData
*m_clientObject
;
347 GtkWidget
*m_wxwindow
;
348 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
349 float m_oldHorizontalPos
;
350 float m_oldVerticalPos
;
358 GtkStyle
*m_widgetStyle
;
362 wxInsertChildFunction m_insertCallback
;
366 wxLayoutConstraints
*m_constraints
;
367 wxList
*m_constraintsInvolvedIn
;
368 wxSizer
*m_windowSizer
;
369 wxWindow
*m_sizerParent
;
372 wxLayoutConstraints
*GetConstraints() const;
373 void SetConstraints( wxLayoutConstraints
*constraints
);
374 void SetAutoLayout( bool autoLayout
);
375 bool GetAutoLayout() const;
377 void SetSizer( wxSizer
*sizer
);
378 wxSizer
*GetSizer() const;
379 void SetSizerParent( wxWindow
*win
);
380 wxWindow
*GetSizerParent() const;
381 void UnsetConstraints(wxLayoutConstraints
*c
);
382 inline wxList
*GetConstraintsInvolvedIn() const ;
383 void AddConstraintReference(wxWindow
*otherWin
);
384 void RemoveConstraintReference(wxWindow
*otherWin
);
385 void DeleteRelatedConstraints();
386 virtual void ResetConstraints();
387 virtual void SetConstraintSizes(bool recurse
= TRUE
);
388 virtual bool LayoutPhase1(int *noChanges
);
389 virtual bool LayoutPhase2(int *noChanges
);
390 virtual bool DoPhase(int);
391 virtual void TransformSizerToActual(int *x
, int *y
) const ;
392 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
393 virtual void SizerMove(int x
, int y
);
394 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
395 virtual void MoveConstraint(int x
, int y
);
396 virtual void GetSizeConstraint(int *w
, int *h
) const ;
397 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
398 virtual void GetPositionConstraint(int *x
, int *y
) const ;
401 DECLARE_EVENT_TABLE()
404 #endif // __GTKWINDOWH__