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
);
100 void OnSize( wxSizeEvent
&event
);
101 void OnIdle( wxIdleEvent
& event
);
103 virtual bool Show( bool show
);
104 virtual void Enable( bool enable
);
105 virtual void MakeModal( bool modal
);
106 virtual bool IsEnabled() const { return m_isEnabled
; }
107 inline bool Enabled(void) const { return IsEnabled(); }
108 virtual void SetFocus();
109 virtual bool OnClose();
111 virtual void AddChild( wxWindow
*child
);
112 wxList
*GetChildren();
113 virtual void RemoveChild( wxWindow
*child
);
114 void SetReturnCode( int retCode
);
116 wxWindow
*GetParent();
118 wxEvtHandler
*GetEventHandler();
119 void SetEventHandler( wxEvtHandler
*handler
);
120 void PushEventHandler( wxEvtHandler
*handler
);
121 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
123 virtual wxValidator
*GetValidator();
124 virtual void SetValidator( const wxValidator
&validator
);
126 bool IsBeingDeleted();
128 void SetId( wxWindowID id
);
131 void SetCursor( const wxCursor
&cursor
);
133 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= NULL
);
134 virtual void Clear();
135 virtual bool IsExposed( long x
, long y
);
136 virtual bool IsExposed( long x
, long y
, long width
, long height
);
138 virtual wxColour
GetBackgroundColour() const;
139 virtual void SetBackgroundColour( const wxColour
&colour
);
140 virtual wxColour
GetForegroundColour() const;
141 virtual void SetForegroundColour( const wxColour
&colour
);
143 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
144 { m_defaultBackgroundColour
= col
; };
145 virtual wxColour
GetDefaultBackgroundColour() const
146 { return m_defaultBackgroundColour
; };
147 virtual void SetDefaultForegroundColour( const wxColour
& col
)
148 { m_defaultForegroundColour
= col
; };
149 virtual wxColour
GetDefaultForegroundColour() const
150 { return m_defaultForegroundColour
; };
152 virtual void SetFont( const wxFont
&font
);
153 virtual wxFont
*GetFont();
154 // For backward compatibility
155 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
156 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
157 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
158 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
159 virtual void SetWindowStyleFlag( long flag
);
160 virtual long GetWindowStyleFlag() const;
161 virtual void CaptureMouse();
162 virtual void ReleaseMouse();
163 virtual void SetTitle( const wxString
&title
);
164 virtual wxString
GetTitle() const;
165 virtual void SetName( const wxString
&name
);
166 virtual wxString
GetName() const;
167 virtual wxString
GetLabel() const;
169 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
171 virtual bool IsShown() const;
173 virtual void Raise(void);
174 virtual void Lower(void);
176 virtual bool IsRetained();
177 virtual wxWindow
*FindWindow( long id
);
178 virtual wxWindow
*FindWindow( const wxString
& name
);
179 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
180 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
181 virtual void ClientToScreen( int *x
, int *y
);
182 virtual void ScreenToClient( int *x
, int *y
);
184 virtual bool Validate();
185 virtual bool TransferDataToWindow();
186 virtual bool TransferDataFromWindow();
187 void OnInitDialog( wxInitDialogEvent
&event
);
188 virtual void InitDialog();
190 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
192 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
193 virtual wxDropTarget
*GetDropTarget() const;
196 virtual GtkWidget
* GetConnectWidget(void);
197 virtual bool IsOwnGtkWindow( GdkWindow
*window
);
200 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
201 int range
, bool refresh
= TRUE
);
202 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
203 virtual int GetScrollPos( int orient
) const;
204 virtual int GetScrollThumb( int orient
) const;
205 virtual int GetScrollRange( int orient
) const;
206 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= NULL
);
208 // return FALSE from here if the window doesn't want the focus
209 virtual bool AcceptsFocus() const;
211 // update the UI state (called from OnIdle)
212 void UpdateWindowUI();
215 public: // cannot get private going yet
217 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
218 const wxSize
&size
, long style
, const wxString
&name
);
221 virtual void ImplementSetSize();
222 virtual void ImplementSetPosition();
223 void GetDrawingOffset( long *x
, long *y
);
228 int m_width
,m_height
;
230 wxEvtHandler
*m_eventHandler
;
231 wxValidator
*m_windowValidator
;
232 wxDropTarget
*m_pDropTarget
;
233 wxWindowID m_windowId
;
236 wxColour m_backgroundColour
;
237 wxColour m_defaultBackgroundColour
;
238 wxColour m_foregroundColour
;
239 wxColour m_defaultForegroundColour
;
240 wxRegion m_updateRegion
;
244 wxString m_windowName
;
245 long m_drawingOffsetX
,m_drawingOffsetY
;
248 GtkWidget
*m_wxwindow
;
249 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
250 float m_oldHorizontalPos
;
251 float m_oldVerticalPos
;
258 public: // Layout section
260 wxLayoutConstraints
* m_constraints
;
261 wxList
* m_constraintsInvolvedIn
;
262 wxSizer
* m_windowSizer
;
263 wxWindow
* m_sizerParent
;
266 wxLayoutConstraints
*GetConstraints() const;
267 void SetConstraints( wxLayoutConstraints
*constraints
);
268 void SetAutoLayout( bool autoLayout
);
269 bool GetAutoLayout() const;
271 void SetSizer( wxSizer
*sizer
);
272 wxSizer
*GetSizer() const;
273 void SetSizerParent( wxWindow
*win
);
274 wxWindow
*GetSizerParent() const;
275 void UnsetConstraints(wxLayoutConstraints
*c
);
276 inline wxList
*GetConstraintsInvolvedIn() const ;
277 void AddConstraintReference(wxWindow
*otherWin
);
278 void RemoveConstraintReference(wxWindow
*otherWin
);
279 void DeleteRelatedConstraints();
280 virtual void ResetConstraints();
281 virtual void SetConstraintSizes(bool recurse
= TRUE
);
282 virtual bool LayoutPhase1(int *noChanges
);
283 virtual bool LayoutPhase2(int *noChanges
);
284 virtual bool DoPhase(int);
285 virtual void TransformSizerToActual(int *x
, int *y
) const ;
286 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
287 virtual void SizerMove(int x
, int y
);
288 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
289 virtual void MoveConstraint(int x
, int y
);
290 virtual void GetSizeConstraint(int *w
, int *h
) const ;
291 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
292 virtual void GetPositionConstraint(int *x
, int *y
) const ;
294 DECLARE_DYNAMIC_CLASS(wxWindow
)
295 DECLARE_EVENT_TABLE()
298 #endif // __GTKWINDOWH__