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
;
49 //-----------------------------------------------------------------------------
50 // callback definition for inserting a window
51 //-----------------------------------------------------------------------------
53 typedef void (*wxInsertChildFunction
)( wxWindow
*, wxWindow
* );
55 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
59 extern const char *wxPanelNameStr
;
60 extern const wxSize wxDefaultSize
;
61 extern const wxPoint wxDefaultPosition
;
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 class wxWindow
: public wxEvtHandler
69 DECLARE_DYNAMIC_CLASS(wxWindow
)
73 wxWindow(wxWindow
*parent
, wxWindowID id
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
77 const wxString
& name
= wxPanelNameStr
);
78 bool Create(wxWindow
*parent
, wxWindowID id
,
79 const wxPoint
& pos
= wxDefaultPosition
,
80 const wxSize
& size
= wxDefaultSize
,
82 const wxString
& name
= wxPanelNameStr
);
85 virtual bool LoadFromResource( wxWindow
*parent
, const wxString
& resourceName
,
86 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
87 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
,
88 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
90 bool Close( bool force
= FALSE
);
91 virtual bool Destroy();
92 virtual bool DestroyChildren();
94 virtual void PrepareDC( wxDC
&dc
);
96 virtual void SetSize( int x
, int y
, int width
, int height
,
97 int sizeFlags
= wxSIZE_AUTO
);
98 virtual void SetSize( int width
, int height
);
99 virtual void Move( int x
, int y
);
100 virtual void GetSize( int *width
, int *height
) const;
101 virtual void SetClientSize( int const width
, int const height
);
102 virtual void GetClientSize( int *width
, int *height
) const;
103 virtual void GetPosition( int *x
, int *y
) const;
104 virtual void Centre( int direction
= wxHORIZONTAL
);
105 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
108 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
110 // Dialog units translations. Implemented in wincmn.cpp.
111 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
112 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
113 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
114 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
115 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
116 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
118 void OnSize( wxSizeEvent
&event
);
119 void OnIdle( wxIdleEvent
& event
);
121 virtual bool Show( bool show
);
122 virtual void Enable( bool enable
);
123 virtual void MakeModal( bool modal
);
124 virtual bool IsEnabled() const { return m_isEnabled
; }
125 inline bool Enabled(void) const { return IsEnabled(); }
126 virtual void SetFocus();
127 virtual bool OnClose();
129 virtual void AddChild( wxWindow
*child
);
130 wxList
*GetChildren();
131 virtual void RemoveChild( wxWindow
*child
);
132 void SetReturnCode( int retCode
);
134 wxWindow
*GetParent() const
136 wxWindow
*GetGrandParent(void) const
137 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
138 void SetParent( wxWindow
*p
)
141 wxEvtHandler
*GetEventHandler();
142 void SetEventHandler( wxEvtHandler
*handler
);
143 void PushEventHandler( wxEvtHandler
*handler
);
144 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
146 virtual wxValidator
*GetValidator();
147 virtual void SetValidator( const wxValidator
&validator
);
149 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
);
150 virtual wxAcceleratorTable
*GetAcceleratorTable() { return &m_acceleratorTable
; }
152 bool IsBeingDeleted();
154 void SetId( wxWindowID id
);
157 void SetCursor( const wxCursor
&cursor
);
159 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
160 virtual void Clear();
162 virtual wxRegion
GetUpdateRegion() const;
163 virtual bool IsExposed(int x
, int y
) const;
164 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
165 virtual bool IsExposed(const wxPoint
& pt
) const;
166 virtual bool IsExposed(const wxRect
& rect
) const;
168 virtual wxColour
GetBackgroundColour() const;
169 virtual void SetBackgroundColour( const wxColour
&colour
);
170 virtual wxColour
GetForegroundColour() const;
171 virtual void SetForegroundColour( const wxColour
&colour
);
173 virtual int GetCharHeight(void) const;
174 virtual int GetCharWidth(void) const;
175 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
176 int *descent
= (int *) NULL
,
177 int *externalLeading
= (int *) NULL
,
178 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
180 virtual void SetFont( const wxFont
&font
);
181 virtual wxFont
*GetFont();
182 // For backward compatibility
183 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
184 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
185 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
186 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
187 virtual void SetWindowStyleFlag( long flag
);
188 virtual long GetWindowStyleFlag() const;
189 virtual void CaptureMouse();
190 virtual void ReleaseMouse();
191 virtual void SetTitle( const wxString
&title
);
192 virtual wxString
GetTitle() const;
193 virtual void SetName( const wxString
&name
);
194 virtual wxString
GetName() const;
195 virtual wxString
GetLabel() const;
197 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
199 virtual bool IsShown() const;
201 virtual void Raise(void);
202 virtual void Lower(void);
204 virtual bool IsRetained();
205 virtual wxWindow
*FindWindow( long id
);
206 virtual wxWindow
*FindWindow( const wxString
& name
);
207 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
208 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
209 virtual void ClientToScreen( int *x
, int *y
);
210 virtual void ScreenToClient( int *x
, int *y
);
212 virtual bool Validate();
213 virtual bool TransferDataToWindow();
214 virtual bool TransferDataFromWindow();
215 void OnInitDialog( wxInitDialogEvent
&event
);
216 virtual void InitDialog();
218 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
220 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
221 virtual wxDropTarget
*GetDropTarget() const;
223 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
224 int range
, bool refresh
= TRUE
);
225 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
226 virtual int GetScrollPos( int orient
) const;
227 virtual int GetScrollThumb( int orient
) const;
228 virtual int GetScrollRange( int orient
) const;
229 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
231 virtual bool AcceptsFocus() const;
232 void UpdateWindowUI();
236 virtual GtkWidget
*GetConnectWidget(void);
237 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
238 void ConnectWidget( GtkWidget
*widget
);
239 void ConnectDnDWidget( GtkWidget
*widget
);
240 void DisconnectDnDWidget( GtkWidget
*widget
);
242 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
243 const wxSize
&size
, long style
, const wxString
&name
);
247 virtual void ImplementSetSize();
248 virtual void ImplementSetPosition();
250 virtual wxPoint
GetClientAreaOrigin() const;
251 virtual void AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
);
253 GtkStyle
*GetWidgetStyle();
254 void SetWidgetStyle();
255 virtual void ApplyWidgetStyle();
261 int m_width
,m_height
;
262 int m_minWidth
,m_minHeight
;
263 int m_maxWidth
,m_maxHeight
;
265 wxEvtHandler
*m_eventHandler
;
266 wxValidator
*m_windowValidator
;
267 wxDropTarget
*m_pDropTarget
;
268 wxWindowID m_windowId
;
271 wxColour m_backgroundColour
;
272 wxColour m_foregroundColour
;
273 wxRegion m_updateRegion
;
277 wxString m_windowName
;
278 wxAcceleratorTable m_acceleratorTable
;
281 GtkWidget
*m_wxwindow
;
282 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
283 float m_oldHorizontalPos
;
284 float m_oldVerticalPos
;
292 GtkStyle
*m_widgetStyle
;
294 wxInsertChildFunction m_insertCallback
;
298 wxLayoutConstraints
*m_constraints
;
299 wxList
*m_constraintsInvolvedIn
;
300 wxSizer
*m_windowSizer
;
301 wxWindow
*m_sizerParent
;
304 wxLayoutConstraints
*GetConstraints() const;
305 void SetConstraints( wxLayoutConstraints
*constraints
);
306 void SetAutoLayout( bool autoLayout
);
307 bool GetAutoLayout() const;
309 void SetSizer( wxSizer
*sizer
);
310 wxSizer
*GetSizer() const;
311 void SetSizerParent( wxWindow
*win
);
312 wxWindow
*GetSizerParent() const;
313 void UnsetConstraints(wxLayoutConstraints
*c
);
314 inline wxList
*GetConstraintsInvolvedIn() const ;
315 void AddConstraintReference(wxWindow
*otherWin
);
316 void RemoveConstraintReference(wxWindow
*otherWin
);
317 void DeleteRelatedConstraints();
318 virtual void ResetConstraints();
319 virtual void SetConstraintSizes(bool recurse
= TRUE
);
320 virtual bool LayoutPhase1(int *noChanges
);
321 virtual bool LayoutPhase2(int *noChanges
);
322 virtual bool DoPhase(int);
323 virtual void TransformSizerToActual(int *x
, int *y
) const ;
324 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
325 virtual void SizerMove(int x
, int y
);
326 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
327 virtual void MoveConstraint(int x
, int y
);
328 virtual void GetSizeConstraint(int *w
, int *h
) const ;
329 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
330 virtual void GetPositionConstraint(int *x
, int *y
) const ;
333 DECLARE_EVENT_TABLE()
336 #endif // __GTKWINDOWH__