1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __GTKWINDOWH__
13 #define __GTKWINDOWH__
20 #include "wx/object.h"
23 #include "wx/validate.h"
24 #include "wx/cursor.h"
27 #include "wx/region.h"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 extern const char *wxFrameNameStr
;
35 extern wxList wxTopLevelWindows
;
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 class wxLayoutConstraints
;
43 class wxResourceTable
;
49 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
53 extern const char *wxPanelNameStr
;
54 extern const wxSize wxDefaultSize
;
55 extern const wxPoint wxDefaultPosition
;
57 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
61 class wxWindow
: public wxEvtHandler
65 inline wxWindow(wxWindow
*parent
, wxWindowID id
,
66 const wxPoint
& pos
= wxDefaultPosition
,
67 const wxSize
& size
= wxDefaultSize
,
69 const wxString
& name
= wxPanelNameStr
)
71 Create(parent
, id
, pos
, size
, style
, name
);
73 bool Create(wxWindow
*parent
, wxWindowID id
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
77 const wxString
& name
= wxPanelNameStr
);
80 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
81 virtual wxControl
*CreateItem(const wxItemResource
*childResource
, const wxResourceTable
*table
= NULL
);
83 bool Close( bool force
= FALSE
);
84 virtual bool Destroy();
85 virtual bool DestroyChildren();
87 virtual void PrepareDC( wxDC
&dc
);
89 virtual void SetSize( int x
, int y
, int width
, int height
,
90 int sizeFlags
= wxSIZE_AUTO
);
91 virtual void SetSize( int width
, int height
);
92 virtual void Move( int x
, int y
);
93 virtual void GetSize( int *width
, int *height
) const;
94 virtual void SetClientSize( int const width
, int const height
);
95 virtual void GetClientSize( int *width
, int *height
) const;
96 virtual void GetPosition( int *x
, int *y
) const;
97 virtual void Centre( int direction
= wxHORIZONTAL
);
99 // set minimal/maxmimal size for the frame
100 virtual void SetSizeHints( int WXUNUSED(minW
), int WXUNUSED(minH
), int WXUNUSED(maxW
),
101 int WXUNUSED(maxH
), int WXUNUSED(incW
) ) { }
103 void OnSize( wxSizeEvent
&event
);
104 void OnIdle( wxIdleEvent
& event
);
106 virtual bool Show( bool show
);
107 virtual void Enable( bool enable
);
108 virtual void MakeModal( bool modal
);
109 virtual bool IsEnabled() const { return m_isEnabled
; }
110 inline bool Enabled(void) const { return IsEnabled(); }
111 virtual void SetFocus();
112 virtual bool OnClose();
114 virtual void AddChild( wxWindow
*child
);
115 wxList
*GetChildren();
116 virtual void RemoveChild( wxWindow
*child
);
117 void SetReturnCode( int retCode
);
119 wxWindow
*GetParent() const
121 wxWindow
*GetGrandParent(void) const
122 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
123 void wxWindow::SetParent( wxWindow
*p
)
126 wxEvtHandler
*GetEventHandler();
127 void SetEventHandler( wxEvtHandler
*handler
);
128 void PushEventHandler( wxEvtHandler
*handler
);
129 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
131 virtual wxValidator
*GetValidator();
132 virtual void SetValidator( const wxValidator
&validator
);
134 bool IsBeingDeleted();
136 void SetId( wxWindowID id
);
139 void SetCursor( const wxCursor
&cursor
);
141 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= NULL
);
142 virtual void Clear();
143 virtual bool IsExposed( long x
, long y
);
144 virtual bool IsExposed( long x
, long y
, long width
, long height
);
146 virtual wxColour
GetBackgroundColour() const;
147 virtual void SetBackgroundColour( const wxColour
&colour
);
148 virtual wxColour
GetForegroundColour() const;
149 virtual void SetForegroundColour( const wxColour
&colour
);
151 virtual int GetCharHeight(void) const;
152 virtual int GetCharWidth(void) const;
153 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
155 int *externalLeading
= NULL
,
156 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
158 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
159 { m_defaultBackgroundColour
= col
; }
160 virtual wxColour
GetDefaultBackgroundColour() const
161 { return m_defaultBackgroundColour
; }
162 virtual void SetDefaultForegroundColour( const wxColour
& col
)
163 { m_defaultForegroundColour
= col
; }
164 virtual wxColour
GetDefaultForegroundColour() const
165 { return m_defaultForegroundColour
; }
167 virtual void SetFont( const wxFont
&font
);
168 virtual wxFont
*GetFont();
169 // For backward compatibility
170 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
171 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
172 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
173 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
174 virtual void SetWindowStyleFlag( long flag
);
175 virtual long GetWindowStyleFlag() const;
176 virtual void CaptureMouse();
177 virtual void ReleaseMouse();
178 virtual void SetTitle( const wxString
&title
);
179 virtual wxString
GetTitle() const;
180 virtual void SetName( const wxString
&name
);
181 virtual wxString
GetName() const;
182 virtual wxString
GetLabel() const;
184 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
186 virtual bool IsShown() const;
188 virtual void Raise(void);
189 virtual void Lower(void);
191 virtual bool IsRetained();
192 virtual wxWindow
*FindWindow( long id
);
193 virtual wxWindow
*FindWindow( const wxString
& name
);
194 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
195 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
196 virtual void ClientToScreen( int *x
, int *y
);
197 virtual void ScreenToClient( int *x
, int *y
);
199 virtual bool Validate();
200 virtual bool TransferDataToWindow();
201 virtual bool TransferDataFromWindow();
202 void OnInitDialog( wxInitDialogEvent
&event
);
203 virtual void InitDialog();
205 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
207 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
208 virtual wxDropTarget
*GetDropTarget() const;
211 virtual GtkWidget
* GetConnectWidget(void);
212 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
215 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
216 int range
, bool refresh
= TRUE
);
217 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
218 virtual int GetScrollPos( int orient
) const;
219 virtual int GetScrollThumb( int orient
) const;
220 virtual int GetScrollRange( int orient
) const;
221 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= NULL
);
223 // return FALSE from here if the window doesn't want the focus
224 virtual bool AcceptsFocus() const;
226 // update the UI state (called from OnIdle)
227 void UpdateWindowUI();
230 public: // cannot get private going yet
232 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
233 const wxSize
&size
, long style
, const wxString
&name
);
236 virtual void ImplementSetSize();
237 virtual void ImplementSetPosition();
238 void GetDrawingOffset( long *x
, long *y
);
243 int m_width
,m_height
;
245 wxEvtHandler
*m_eventHandler
;
246 wxValidator
*m_windowValidator
;
247 wxDropTarget
*m_pDropTarget
;
248 wxWindowID m_windowId
;
251 wxColour m_backgroundColour
;
252 wxColour m_defaultBackgroundColour
;
253 wxColour m_foregroundColour
;
254 wxColour m_defaultForegroundColour
;
255 wxRegion m_updateRegion
;
259 wxString m_windowName
;
260 long m_drawingOffsetX
,m_drawingOffsetY
;
263 GtkWidget
*m_wxwindow
;
264 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
265 float m_oldHorizontalPos
;
266 float m_oldVerticalPos
;
273 public: // Layout section
275 wxLayoutConstraints
* m_constraints
;
276 wxList
* m_constraintsInvolvedIn
;
277 wxSizer
* m_windowSizer
;
278 wxWindow
* m_sizerParent
;
281 wxLayoutConstraints
*GetConstraints() const;
282 void SetConstraints( wxLayoutConstraints
*constraints
);
283 void SetAutoLayout( bool autoLayout
);
284 bool GetAutoLayout() const;
286 void SetSizer( wxSizer
*sizer
);
287 wxSizer
*GetSizer() const;
288 void SetSizerParent( wxWindow
*win
);
289 wxWindow
*GetSizerParent() const;
290 void UnsetConstraints(wxLayoutConstraints
*c
);
291 inline wxList
*GetConstraintsInvolvedIn() const ;
292 void AddConstraintReference(wxWindow
*otherWin
);
293 void RemoveConstraintReference(wxWindow
*otherWin
);
294 void DeleteRelatedConstraints();
295 virtual void ResetConstraints();
296 virtual void SetConstraintSizes(bool recurse
= TRUE
);
297 virtual bool LayoutPhase1(int *noChanges
);
298 virtual bool LayoutPhase2(int *noChanges
);
299 virtual bool DoPhase(int);
300 virtual void TransformSizerToActual(int *x
, int *y
) const ;
301 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
302 virtual void SizerMove(int x
, int y
);
303 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
304 virtual void MoveConstraint(int x
, int y
);
305 virtual void GetSizeConstraint(int *w
, int *h
) const ;
306 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
307 virtual void GetPositionConstraint(int *x
, int *y
) const ;
309 DECLARE_DYNAMIC_CLASS(wxWindow
)
310 DECLARE_EVENT_TABLE()
313 #endif // __GTKWINDOWH__