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
, wxWindowID id
,
67 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
68 long style
= 0, const wxString
&name
= wxPanelNameStr
);
69 bool Create( wxWindow
*parent
, wxWindowID id
,
70 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
71 long style
= 0, const wxString
&name
= wxPanelNameStr
);
72 virtual ~wxWindow(void);
73 bool Close( bool force
= FALSE
);
74 virtual bool Destroy(void);
75 virtual bool DestroyChildren(void);
77 virtual void PrepareDC( wxDC
&dc
);
79 virtual void SetSize( int x
, int y
, int width
, int height
,
80 int sizeFlags
= wxSIZE_AUTO
);
81 virtual void SetSize( int width
, int height
);
82 virtual void Move( int x
, 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( int direction
= wxHORIZONTAL
);
88 virtual void Fit(void);
90 void OnSize( wxSizeEvent
&event
);
92 virtual bool Show( bool show
);
93 virtual void Enable( bool enable
);
94 virtual void MakeModal( 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( bool eraseBackground
= TRUE
, const wxRect
*rect
= NULL
);
120 virtual void Clear(void);
121 virtual bool IsExposed( long x
, long y
);
122 virtual bool IsExposed( long x
, long y
, long width
, 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) const;
156 virtual bool IsRetained(void);
157 virtual wxWindow
*FindWindow( 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 // return FALSE from here if the window doesn't want the focus
182 virtual bool AcceptsFocus() const;
184 public: // cannot get private going yet
186 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
187 const wxSize
&size
, long style
, const wxString
&name
);
188 void PostCreation(void);
190 virtual void ImplementSetSize(void);
191 virtual void ImplementSetPosition(void);
192 void GetDrawingOffset( long *x
, long *y
);
197 int m_width
,m_height
;
199 wxEvtHandler
*m_eventHandler
;
200 wxValidator
*m_windowValidator
;
201 wxDropTarget
*m_pDropTarget
;
202 wxWindowID m_windowId
;
205 wxColour m_backgroundColour
;
206 wxColour m_defaultBackgroundColour
;
207 wxColour m_foregroundColour
;
208 wxColour m_defaultForegroundColour
;
209 wxRegion m_updateRegion
;
213 wxString m_windowName
;
214 long m_drawingOffsetX
,m_drawingOffsetY
;
217 GtkWidget
*m_wxwindow
;
218 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
219 float m_oldHorizontalPos
;
220 float m_oldVerticalPos
;
227 public: // Layout section
229 wxLayoutConstraints
* m_constraints
;
230 wxList
* m_constraintsInvolvedIn
;
231 wxSizer
* m_windowSizer
;
232 wxWindow
* m_sizerParent
;
235 wxLayoutConstraints
*GetConstraints(void) const;
236 void SetConstraints( wxLayoutConstraints
*constraints
);
237 void SetAutoLayout( bool autoLayout
);
238 bool GetAutoLayout(void) const;
240 void SetSizer( wxSizer
*sizer
);
241 wxSizer
*GetSizer(void) const;
242 void SetSizerParent( wxWindow
*win
);
243 wxWindow
*GetSizerParent(void) const;
244 void UnsetConstraints(wxLayoutConstraints
*c
);
245 inline wxList
*GetConstraintsInvolvedIn(void) const ;
246 void AddConstraintReference(wxWindow
*otherWin
);
247 void RemoveConstraintReference(wxWindow
*otherWin
);
248 void DeleteRelatedConstraints(void);
249 virtual void ResetConstraints(void);
250 virtual void SetConstraintSizes(bool recurse
= TRUE
);
251 virtual bool LayoutPhase1(int *noChanges
);
252 virtual bool LayoutPhase2(int *noChanges
);
253 virtual bool DoPhase(int);
254 virtual void TransformSizerToActual(int *x
, int *y
) const ;
255 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
256 virtual void SizerMove(int x
, int y
);
257 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
258 virtual void MoveConstraint(int x
, int y
);
259 virtual void GetSizeConstraint(int *w
, int *h
) const ;
260 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
261 virtual void GetPositionConstraint(int *x
, int *y
) const ;
263 DECLARE_EVENT_TABLE()
266 #endif // __GTKWINDOWH__