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
);
137 virtual void Move( int x
, int y
);
138 virtual void GetSize( int *width
, int *height
) const;
139 virtual void SetClientSize( int const width
, int const height
);
140 virtual void GetClientSize( int *width
, int *height
) const;
141 virtual void GetPosition( int *x
, int *y
) const;
142 virtual void Centre( int direction
= wxHORIZONTAL
);
143 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
146 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
148 // Dialog units translations. Implemented in wincmn.cpp.
149 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
150 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
151 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
152 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
153 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
154 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
156 void OnSize( wxSizeEvent
&event
);
157 void OnIdle( wxIdleEvent
& event
);
159 virtual bool Show( bool show
);
160 virtual void Enable( bool enable
);
161 virtual void MakeModal( bool modal
);
162 virtual bool IsEnabled() const { return m_isEnabled
; }
163 inline bool Enabled() const { return IsEnabled(); }
164 virtual bool OnClose();
166 virtual void SetFocus();
167 static wxWindow
*FindFocus();
169 virtual void AddChild( wxWindow
*child
);
170 wxList
& GetChildren() { return m_children
; }
172 virtual void RemoveChild( wxWindow
*child
);
173 void SetReturnCode( int retCode
);
175 wxWindow
*GetParent() const
177 wxWindow
*GetGrandParent() const
178 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
179 void SetParent( wxWindow
*p
)
181 virtual wxWindow
*ReParent( wxWindow
*newParent
);
183 wxEvtHandler
*GetEventHandler() const;
184 void SetEventHandler( wxEvtHandler
*handler
);
185 void PushEventHandler( wxEvtHandler
*handler
);
186 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
188 virtual wxValidator
*GetValidator();
189 virtual void SetValidator( const wxValidator
&validator
);
191 virtual void SetClientObject( wxClientData
*data
);
192 virtual wxClientData
*GetClientObject();
194 virtual void SetClientData( void *data
);
195 virtual void *GetClientData();
197 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
198 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
200 bool IsBeingDeleted();
202 void SetId( wxWindowID id
);
203 wxWindowID
GetId() const;
205 void SetCursor( const wxCursor
&cursor
);
207 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
208 virtual void Clear();
210 virtual wxRegion
GetUpdateRegion() const;
211 virtual bool IsExposed(int x
, int y
) const;
212 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
213 virtual bool IsExposed(const wxPoint
& pt
) const;
214 virtual bool IsExposed(const wxRect
& rect
) const;
216 virtual wxColour
GetBackgroundColour() const;
217 virtual void SetBackgroundColour( const wxColour
&colour
);
218 virtual wxColour
GetForegroundColour() const;
219 virtual void SetForegroundColour( const wxColour
&colour
);
221 virtual int GetCharHeight() const;
222 virtual int GetCharWidth() const;
223 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
224 int *descent
= (int *) NULL
,
225 int *externalLeading
= (int *) NULL
,
226 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
228 virtual void SetFont( const wxFont
&font
);
229 virtual const wxFont
& GetFont() { return m_font
; }
231 // For backward compatibility
232 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
233 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
234 inline virtual const wxFont
& GetLabelFont() { return GetFont(); };
235 inline virtual const wxFont
& GetButtonFont() { return GetFont(); };
237 virtual void SetWindowStyleFlag( long flag
);
238 virtual long GetWindowStyleFlag() const;
240 virtual void CaptureMouse();
241 virtual void ReleaseMouse();
243 virtual void SetTitle( const wxString
&title
);
244 virtual wxString
GetTitle() const;
245 virtual void SetName( const wxString
&name
);
246 virtual wxString
GetName() const;
247 virtual wxString
GetLabel() const;
249 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
251 virtual bool IsShown() const;
253 virtual void Raise();
254 virtual void Lower();
256 virtual bool IsRetained();
257 virtual wxWindow
*FindWindow( long id
);
258 virtual wxWindow
*FindWindow( const wxString
& name
);
260 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
261 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
263 virtual void ClientToScreen( int *x
, int *y
);
264 virtual void ScreenToClient( int *x
, int *y
);
266 virtual bool Validate();
267 virtual bool TransferDataToWindow();
268 virtual bool TransferDataFromWindow();
269 void OnInitDialog( wxInitDialogEvent
&event
);
270 virtual void InitDialog();
272 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
274 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
275 virtual wxDropTarget
*GetDropTarget() const;
277 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
278 int range
, bool refresh
= TRUE
);
279 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
280 virtual int GetScrollPos( int orient
) const;
281 virtual int GetScrollThumb( int orient
) const;
282 virtual int GetScrollRange( int orient
) const;
283 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
285 virtual bool AcceptsFocus() const;
287 void UpdateWindowUI();
291 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
292 const wxSize
&size
, long style
, const wxString
&name
);
294 virtual GtkWidget
*GetConnectWidget();
295 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
296 void ConnectWidget( GtkWidget
*widget
);
300 virtual wxPoint
GetClientAreaOrigin() const;
301 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
303 GtkStyle
*GetWidgetStyle();
304 void SetWidgetStyle();
305 virtual void ApplyWidgetStyle();
311 int m_width
,m_height
;
312 int m_minWidth
,m_minHeight
;
313 int m_maxWidth
,m_maxHeight
;
315 wxEvtHandler
*m_eventHandler
;
316 wxValidator
*m_windowValidator
;
317 wxDropTarget
*m_dropTarget
;
318 wxWindowID m_windowId
;
321 wxColour m_backgroundColour
;
322 wxColour m_foregroundColour
;
323 wxRegion m_updateRegion
;
327 wxString m_windowName
;
328 wxAcceleratorTable m_acceleratorTable
;
329 wxClientData
*m_clientObject
;
333 GtkWidget
*m_wxwindow
;
334 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
335 float m_oldHorizontalPos
;
336 float m_oldVerticalPos
;
344 GtkStyle
*m_widgetStyle
;
348 wxInsertChildFunction m_insertCallback
;
352 wxLayoutConstraints
*m_constraints
;
353 wxList
*m_constraintsInvolvedIn
;
354 wxSizer
*m_windowSizer
;
355 wxWindow
*m_sizerParent
;
358 wxLayoutConstraints
*GetConstraints() const;
359 void SetConstraints( wxLayoutConstraints
*constraints
);
360 void SetAutoLayout( bool autoLayout
);
361 bool GetAutoLayout() const;
363 void SetSizer( wxSizer
*sizer
);
364 wxSizer
*GetSizer() const;
365 void SetSizerParent( wxWindow
*win
);
366 wxWindow
*GetSizerParent() const;
367 void UnsetConstraints(wxLayoutConstraints
*c
);
368 inline wxList
*GetConstraintsInvolvedIn() const ;
369 void AddConstraintReference(wxWindow
*otherWin
);
370 void RemoveConstraintReference(wxWindow
*otherWin
);
371 void DeleteRelatedConstraints();
372 virtual void ResetConstraints();
373 virtual void SetConstraintSizes(bool recurse
= TRUE
);
374 virtual bool LayoutPhase1(int *noChanges
);
375 virtual bool LayoutPhase2(int *noChanges
);
376 virtual bool DoPhase(int);
377 virtual void TransformSizerToActual(int *x
, int *y
) const ;
378 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
379 virtual void SizerMove(int x
, int y
);
380 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
381 virtual void MoveConstraint(int x
, int y
);
382 virtual void GetSizeConstraint(int *w
, int *h
) const ;
383 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
384 virtual void GetPositionConstraint(int *x
, int *y
) const ;
387 DECLARE_EVENT_TABLE()
390 #endif // __GTKWINDOWH__