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
); }
100 // set minimal/maxmimal size for the frame
101 virtual void SetSizeHints( int WXUNUSED(minW
), int WXUNUSED(minH
), int WXUNUSED(maxW
),
102 int WXUNUSED(maxH
), int WXUNUSED(incW
), int WXUNUSED(incH
) ) { }
104 void OnSize( wxSizeEvent
&event
);
105 void OnIdle( wxIdleEvent
& event
);
107 virtual bool Show( bool show
);
108 virtual void Enable( bool enable
);
109 virtual void MakeModal( bool modal
);
110 virtual bool IsEnabled() const { return m_isEnabled
; }
111 inline bool Enabled(void) const { return IsEnabled(); }
112 virtual void SetFocus();
113 virtual bool OnClose();
115 virtual void AddChild( wxWindow
*child
);
116 wxList
*GetChildren();
117 virtual void RemoveChild( wxWindow
*child
);
118 void SetReturnCode( int retCode
);
120 wxWindow
*GetParent() const
122 wxWindow
*GetGrandParent(void) const
123 { return (m_parent
? m_parent
->m_parent
: (wxWindow
*)NULL
); }
124 void SetParent( wxWindow
*p
)
127 wxEvtHandler
*GetEventHandler();
128 void SetEventHandler( wxEvtHandler
*handler
);
129 void PushEventHandler( wxEvtHandler
*handler
);
130 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
132 virtual wxValidator
*GetValidator();
133 virtual void SetValidator( const wxValidator
&validator
);
135 bool IsBeingDeleted();
137 void SetId( wxWindowID id
);
140 void SetCursor( const wxCursor
&cursor
);
142 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= (const wxRect
*) NULL
);
143 virtual void Clear();
144 virtual bool IsExposed( long x
, long y
);
145 virtual bool IsExposed( long x
, long y
, long width
, long height
);
147 virtual wxColour
GetBackgroundColour() const;
148 virtual void SetBackgroundColour( const wxColour
&colour
);
149 virtual wxColour
GetForegroundColour() const;
150 virtual void SetForegroundColour( const wxColour
&colour
);
152 virtual int GetCharHeight(void) const;
153 virtual int GetCharWidth(void) const;
154 virtual void GetTextExtent( const wxString
& string
, int *x
, int *y
,
155 int *descent
= (int *) NULL
,
156 int *externalLeading
= (int *) NULL
,
157 const wxFont
*theFont
= (const wxFont
*) NULL
, bool use16
= FALSE
) const;
159 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
160 { m_defaultBackgroundColour
= col
; }
161 virtual wxColour
GetDefaultBackgroundColour() const
162 { return m_defaultBackgroundColour
; }
163 virtual void SetDefaultForegroundColour( const wxColour
& col
)
164 { m_defaultForegroundColour
= col
; }
165 virtual wxColour
GetDefaultForegroundColour() const
166 { return m_defaultForegroundColour
; }
168 virtual void SetFont( const wxFont
&font
);
169 virtual wxFont
*GetFont();
170 // For backward compatibility
171 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
172 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
173 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
174 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
175 virtual void SetWindowStyleFlag( long flag
);
176 virtual long GetWindowStyleFlag() const;
177 virtual void CaptureMouse();
178 virtual void ReleaseMouse();
179 virtual void SetTitle( const wxString
&title
);
180 virtual wxString
GetTitle() const;
181 virtual void SetName( const wxString
&name
);
182 virtual wxString
GetName() const;
183 virtual wxString
GetLabel() const;
185 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
187 virtual bool IsShown() const;
189 virtual void Raise(void);
190 virtual void Lower(void);
192 virtual bool IsRetained();
193 virtual wxWindow
*FindWindow( long id
);
194 virtual wxWindow
*FindWindow( const wxString
& name
);
195 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
196 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
197 virtual void ClientToScreen( int *x
, int *y
);
198 virtual void ScreenToClient( int *x
, int *y
);
200 virtual bool Validate();
201 virtual bool TransferDataToWindow();
202 virtual bool TransferDataFromWindow();
203 void OnInitDialog( wxInitDialogEvent
&event
);
204 virtual void InitDialog();
206 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
208 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
209 virtual wxDropTarget
*GetDropTarget() const;
212 virtual GtkWidget
* GetConnectWidget(void);
213 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
216 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
217 int range
, bool refresh
= TRUE
);
218 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
219 virtual int GetScrollPos( int orient
) const;
220 virtual int GetScrollThumb( int orient
) const;
221 virtual int GetScrollRange( int orient
) const;
222 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= (wxRect
*) NULL
);
224 // return FALSE from here if the window doesn't want the focus
225 virtual bool AcceptsFocus() const;
227 // update the UI state (called from OnIdle)
228 void UpdateWindowUI();
231 public: // cannot get private going yet
233 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
234 const wxSize
&size
, long style
, const wxString
&name
);
237 virtual void ImplementSetSize();
238 virtual void ImplementSetPosition();
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
;
262 GtkWidget
*m_wxwindow
;
263 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
264 float m_oldHorizontalPos
;
265 float m_oldVerticalPos
;
272 public: // Layout section
274 wxLayoutConstraints
* m_constraints
;
275 wxList
* m_constraintsInvolvedIn
;
276 wxSizer
* m_windowSizer
;
277 wxWindow
* m_sizerParent
;
280 wxLayoutConstraints
*GetConstraints() const;
281 void SetConstraints( wxLayoutConstraints
*constraints
);
282 void SetAutoLayout( bool autoLayout
);
283 bool GetAutoLayout() const;
285 void SetSizer( wxSizer
*sizer
);
286 wxSizer
*GetSizer() const;
287 void SetSizerParent( wxWindow
*win
);
288 wxWindow
*GetSizerParent() const;
289 void UnsetConstraints(wxLayoutConstraints
*c
);
290 inline wxList
*GetConstraintsInvolvedIn() const ;
291 void AddConstraintReference(wxWindow
*otherWin
);
292 void RemoveConstraintReference(wxWindow
*otherWin
);
293 void DeleteRelatedConstraints();
294 virtual void ResetConstraints();
295 virtual void SetConstraintSizes(bool recurse
= TRUE
);
296 virtual bool LayoutPhase1(int *noChanges
);
297 virtual bool LayoutPhase2(int *noChanges
);
298 virtual bool DoPhase(int);
299 virtual void TransformSizerToActual(int *x
, int *y
) const ;
300 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
301 virtual void SizerMove(int x
, int y
);
302 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
303 virtual void MoveConstraint(int x
, int y
);
304 virtual void GetSizeConstraint(int *w
, int *h
) const ;
305 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
306 virtual void GetPositionConstraint(int *x
, int *y
) const ;
308 DECLARE_DYNAMIC_CLASS(wxWindow
)
309 DECLARE_EVENT_TABLE()
312 #endif // __GTKWINDOWH__