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
= (const wxResourceTable
*) NULL
);
81 virtual wxControl
*CreateItem(const wxItemResource
*childResource
, const wxResourceTable
*table
= (const wxResourceTable
*) 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
);
98 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
101 virtual void SetSizeHints( int minW
, int minH
, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1 );
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 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
= (const wxRect
*) NULL
);
142 virtual void Clear();
144 virtual wxRegion
GetUpdateRegion() const;
145 virtual bool IsExposed(int x
, int y
) const;
146 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
147 virtual bool IsExposed(const wxPoint
& pt
) const;
148 virtual bool IsExposed(const wxRect
& rect
) const;
150 virtual wxColour
GetBackgroundColour() const;
151 virtual void SetBackgroundColour( const wxColour
&colour
);
152 virtual wxColour
GetForegroundColour() const;
153 virtual void SetForegroundColour( const wxColour
&colour
);
155 virtual int GetCharHeight(void) const;
156 virtual int GetCharWidth(void) const;
157 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
158 int *descent
= (int *) NULL
,
159 int *externalLeading
= (int *) NULL
,
160 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
162 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
163 { m_defaultBackgroundColour
= col
; }
164 virtual wxColour
GetDefaultBackgroundColour() const
165 { return m_defaultBackgroundColour
; }
166 virtual void SetDefaultForegroundColour( const wxColour
& col
)
167 { m_defaultForegroundColour
= col
; }
168 virtual wxColour
GetDefaultForegroundColour() const
169 { return m_defaultForegroundColour
; }
171 virtual void SetFont( const wxFont
&font
);
172 virtual wxFont
*GetFont();
173 // For backward compatibility
174 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
175 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
176 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
177 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
178 virtual void SetWindowStyleFlag( long flag
);
179 virtual long GetWindowStyleFlag() const;
180 virtual void CaptureMouse();
181 virtual void ReleaseMouse();
182 virtual void SetTitle( const wxString
&title
);
183 virtual wxString
GetTitle() const;
184 virtual void SetName( const wxString
&name
);
185 virtual wxString
GetName() const;
186 virtual wxString
GetLabel() const;
188 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
190 virtual bool IsShown() const;
192 virtual void Raise(void);
193 virtual void Lower(void);
195 virtual bool IsRetained();
196 virtual wxWindow
*FindWindow( long id
);
197 virtual wxWindow
*FindWindow( const wxString
& name
);
198 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
199 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
200 virtual void ClientToScreen( int *x
, int *y
);
201 virtual void ScreenToClient( int *x
, int *y
);
203 virtual bool Validate();
204 virtual bool TransferDataToWindow();
205 virtual bool TransferDataFromWindow();
206 void OnInitDialog( wxInitDialogEvent
&event
);
207 virtual void InitDialog();
209 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
211 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
212 virtual wxDropTarget
*GetDropTarget() const;
215 virtual GtkWidget
* GetConnectWidget(void);
216 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
219 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
220 int range
, bool refresh
= TRUE
);
221 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
222 virtual int GetScrollPos( int orient
) const;
223 virtual int GetScrollThumb( int orient
) const;
224 virtual int GetScrollRange( int orient
) const;
225 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
227 // return FALSE from here if the window doesn't want the focus
228 virtual bool AcceptsFocus() const;
230 // update the UI state (called from OnIdle)
231 void UpdateWindowUI();
234 public: // cannot get private going yet
236 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
237 const wxSize
&size
, long style
, const wxString
&name
);
240 virtual void ImplementSetSize();
241 virtual void ImplementSetPosition();
246 int m_width
,m_height
;
247 int m_minWidth
,m_minHeight
;
248 int m_maxWidth
,m_maxHeight
;
250 wxEvtHandler
*m_eventHandler
;
251 wxValidator
*m_windowValidator
;
252 wxDropTarget
*m_pDropTarget
;
253 wxWindowID m_windowId
;
256 wxColour m_backgroundColour
;
257 wxColour m_defaultBackgroundColour
;
258 wxColour m_foregroundColour
;
259 wxColour m_defaultForegroundColour
;
260 wxRegion m_updateRegion
;
264 wxString m_windowName
;
267 GtkWidget
*m_wxwindow
;
268 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
269 float m_oldHorizontalPos
;
270 float m_oldVerticalPos
;
277 public: // Layout section
279 wxLayoutConstraints
* m_constraints
;
280 wxList
* m_constraintsInvolvedIn
;
281 wxSizer
* m_windowSizer
;
282 wxWindow
* m_sizerParent
;
285 wxLayoutConstraints
*GetConstraints() const;
286 void SetConstraints( wxLayoutConstraints
*constraints
);
287 void SetAutoLayout( bool autoLayout
);
288 bool GetAutoLayout() const;
290 void SetSizer( wxSizer
*sizer
);
291 wxSizer
*GetSizer() const;
292 void SetSizerParent( wxWindow
*win
);
293 wxWindow
*GetSizerParent() const;
294 void UnsetConstraints(wxLayoutConstraints
*c
);
295 inline wxList
*GetConstraintsInvolvedIn() const ;
296 void AddConstraintReference(wxWindow
*otherWin
);
297 void RemoveConstraintReference(wxWindow
*otherWin
);
298 void DeleteRelatedConstraints();
299 virtual void ResetConstraints();
300 virtual void SetConstraintSizes(bool recurse
= TRUE
);
301 virtual bool LayoutPhase1(int *noChanges
);
302 virtual bool LayoutPhase2(int *noChanges
);
303 virtual bool DoPhase(int);
304 virtual void TransformSizerToActual(int *x
, int *y
) const ;
305 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
306 virtual void SizerMove(int x
, int y
);
307 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
308 virtual void MoveConstraint(int x
, int y
);
309 virtual void GetSizeConstraint(int *w
, int *h
) const ;
310 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
311 virtual void GetPositionConstraint(int *x
, int *y
) const ;
313 DECLARE_DYNAMIC_CLASS(wxWindow
)
314 DECLARE_EVENT_TABLE()
317 #endif // __GTKWINDOWH__