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
;
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 extern const char *wxPanelNameStr
;
52 extern const wxSize wxDefaultSize
;
53 extern const wxPoint wxDefaultPosition
;
55 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
59 class wxWindow
: public wxEvtHandler
61 DECLARE_DYNAMIC_CLASS(wxWindow
)
66 wxWindow( wxWindow
*parent
, const wxWindowID id
,
67 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
68 const long style
= 0, const wxString
&name
= wxPanelNameStr
);
69 bool Create( wxWindow
*parent
, const wxWindowID id
,
70 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
71 const long style
= 0, const wxString
&name
= wxPanelNameStr
);
72 virtual ~wxWindow(void);
73 bool Close( const bool force
= FALSE
);
74 virtual bool Destroy(void);
75 virtual bool DestroyChildren(void);
77 virtual void PrepareDC( wxDC
&dc
);
79 virtual void SetSize( const int x
, const int y
, const int width
, const int height
,
80 const int sizeFlags
= wxSIZE_AUTO
);
81 virtual void SetSize( const int width
, const int height
);
82 virtual void Move( const int x
, const int y
);
83 virtual void GetSize( int *width
, int *height
) const;
84 virtual void SetClientSize( int const width
, int const height
);
85 virtual void GetClientSize( int *width
, int *height
) const;
86 virtual void GetPosition( int *x
, int *y
) const;
87 virtual void Centre( const int direction
= wxHORIZONTAL
);
88 virtual void Fit(void);
90 void OnSize( wxSizeEvent
&event
);
92 virtual bool Show( const bool show
);
93 virtual void Enable( const bool enable
);
94 virtual void MakeModal( const bool modal
);
95 virtual bool IsEnabled(void) const { return m_isEnabled
; };
96 virtual void SetFocus(void);
97 virtual bool OnClose(void);
99 virtual void AddChild( wxWindow
*child
);
100 wxList
*GetChildren(void);
101 virtual void RemoveChild( wxWindow
*child
);
102 void SetReturnCode( int retCode
);
103 int GetReturnCode(void);
104 wxWindow
*GetParent(void);
106 wxEvtHandler
*GetEventHandler(void);
107 void SetEventhandler( wxEvtHandler
*handler
);
109 virtual wxValidator
*GetValidator(void);
110 virtual void SetValidator( wxValidator
*validator
);
112 bool IsBeingDeleted(void);
114 void SetId( wxWindowID id
);
115 wxWindowID
GetId(void);
117 void SetCursor( const wxCursor
&cursor
);
119 virtual void Refresh( const bool eraseBackground
= TRUE
, const wxRect
*rect
= NULL
);
120 virtual void Clear(void);
121 virtual bool IsExposed( const long x
, const long y
);
122 virtual bool IsExposed( const long x
, const long y
, const long width
, const long height
);
124 virtual wxColour
GetBackgroundColour(void) const;
125 virtual void SetBackgroundColour( const wxColour
&colour
);
127 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
128 { m_defaultBackgroundColour
= col
; };
129 virtual wxColour
GetDefaultBackgroundColour(void) const
130 { return m_defaultBackgroundColour
; };
131 virtual void SetDefaultForegroundColour( const wxColour
& col
)
132 { m_defaultForegroundColour
= col
; };
133 virtual wxColour
GetDefaultForegroundColour(void) const
134 { return m_defaultForegroundColour
; };
136 virtual void SetFont( const wxFont
&font
);
137 virtual wxFont
*GetFont(void);
138 // For backward compatibility
139 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
140 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
141 inline virtual wxFont
*GetLabelFont(void) { return GetFont(); };
142 inline virtual wxFont
*GetButtonFont(void) { return GetFont(); };
143 virtual void SetWindowStyleFlag( long flag
);
144 virtual long GetWindowStyleFlag(void) const;
145 virtual void CaptureMouse(void);
146 virtual void ReleaseMouse(void);
147 virtual void SetTitle( const wxString
&title
);
148 virtual wxString
GetTitle(void) const;
149 virtual void SetName( const wxString
&name
);
150 virtual wxString
GetName(void) const;
151 virtual wxString
GetLabel(void) const;
153 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
155 virtual bool IsShown(void);
156 virtual bool IsRetained(void);
157 virtual wxWindow
*FindWindow( const long id
);
158 virtual wxWindow
*FindWindow( const wxString
& name
);
159 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
160 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
161 virtual void ClientToScreen( int *x
, int *y
);
162 virtual void ScreenToClient( int *x
, int *y
);
164 virtual bool Validate(void);
165 virtual bool TransferDataToWindow(void);
166 virtual bool TransferDataFromWindow(void);
167 void OnInitDialog( wxInitDialogEvent
&event
);
168 virtual void InitDialog(void);
170 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
171 virtual wxDropTarget
*GetDropTarget() const;
173 virtual void SetScrollbar( const int orient
, const int pos
, const int thumbVisible
,
174 const int range
, const bool refresh
= TRUE
);
175 virtual void SetScrollPos( const int orient
, const int pos
, const bool refresh
= TRUE
);
176 virtual int GetScrollPos( const int orient
) const;
177 virtual int GetScrollThumb( const int orient
) const;
178 virtual int GetScrollRange( const int orient
) const;
179 virtual void ScrollWindow( const int dx
, const int dy
, const wxRect
* rect
= NULL
);
181 public: // cannot get private going yet
183 void PreCreation( wxWindow
*parent
, const wxWindowID id
, const wxPoint
&pos
,
184 const wxSize
&size
, const long style
, const wxString
&name
);
185 void PostCreation(void);
187 virtual void ImplementSetSize(void);
188 virtual void ImplementSetPosition(void);
189 void GetDrawingOffset( long *x
, long *y
);
194 int m_width
,m_height
;
196 wxEvtHandler
*m_eventHandler
;
197 wxValidator
*m_windowValidator
;
198 wxDropTarget
*m_pDropTarget
;
199 wxWindowID m_windowId
;
202 wxColour m_backgroundColour
;
203 wxColour m_defaultBackgroundColour
;
204 wxColour m_foregroundColour
;
205 wxColour m_defaultForegroundColour
;
206 wxRegion m_updateRegion
;
210 wxString m_windowName
;
211 long m_drawingOffsetX
,m_drawingOffsetY
;
214 GtkWidget
*m_wxwindow
;
215 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
216 float m_oldHorizontalPos
;
217 float m_oldVerticalPos
;
223 public: // Layout section
225 wxLayoutConstraints
* m_constraints
;
226 wxList
* m_constraintsInvolvedIn
;
227 wxSizer
* m_windowSizer
;
228 wxWindow
* m_sizerParent
;
231 wxLayoutConstraints
*GetConstraints(void) const;
232 void SetConstraints( wxLayoutConstraints
*constraints
);
233 void SetAutoLayout( const bool autoLayout
);
234 bool GetAutoLayout(void) const;
236 void SetSizer( wxSizer
*sizer
);
237 wxSizer
*GetSizer(void) const;
238 void SetSizerParent( wxWindow
*win
);
239 wxWindow
*GetSizerParent(void) const;
240 void UnsetConstraints(wxLayoutConstraints
*c
);
241 inline wxList
*GetConstraintsInvolvedIn(void) const ;
242 void AddConstraintReference(wxWindow
*otherWin
);
243 void RemoveConstraintReference(wxWindow
*otherWin
);
244 void DeleteRelatedConstraints(void);
245 virtual void ResetConstraints(void);
246 virtual void SetConstraintSizes(const bool recurse
= TRUE
);
247 virtual bool LayoutPhase1(int *noChanges
);
248 virtual bool LayoutPhase2(int *noChanges
);
249 virtual bool DoPhase(const int);
250 virtual void TransformSizerToActual(int *x
, int *y
) const ;
251 virtual void SizerSetSize(const int x
, const int y
, const int w
, const int h
);
252 virtual void SizerMove(const int x
, const int y
);
253 virtual void SetSizeConstraint(const int x
, const int y
, const int w
, const int h
);
254 virtual void MoveConstraint(const int x
, const int y
);
255 virtual void GetSizeConstraint(int *w
, int *h
) const ;
256 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
257 virtual void GetPositionConstraint(int *x
, int *y
) const ;
259 DECLARE_EVENT_TABLE()
262 #endif // __GTKWINDOWH__