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
63 wxWindow( wxWindow
*parent
, wxWindowID id
,
64 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
65 long style
= 0, const wxString
&name
= wxPanelNameStr
);
66 bool Create( wxWindow
*parent
, wxWindowID id
,
67 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
68 long style
= 0, const wxString
&name
= wxPanelNameStr
);
70 bool Close( bool force
= FALSE
);
71 virtual bool Destroy();
72 virtual bool DestroyChildren();
74 virtual void PrepareDC( wxDC
&dc
);
76 virtual void SetSize( int x
, int y
, int width
, int height
,
77 int sizeFlags
= wxSIZE_AUTO
);
78 virtual void SetSize( int width
, int height
);
79 virtual void Move( int x
, int y
);
80 virtual void GetSize( int *width
, int *height
) const;
81 virtual void SetClientSize( int const width
, int const height
);
82 virtual void GetClientSize( int *width
, int *height
) const;
83 virtual void GetPosition( int *x
, int *y
) const;
84 virtual void Centre( int direction
= wxHORIZONTAL
);
87 void OnSize( wxSizeEvent
&event
);
88 void OnIdle( wxIdleEvent
& event
);
90 virtual bool Show( bool show
);
91 virtual void Enable( bool enable
);
92 virtual void MakeModal( bool modal
);
93 virtual bool IsEnabled() const { return m_isEnabled
; };
94 virtual void SetFocus();
95 virtual bool OnClose();
97 virtual void AddChild( wxWindow
*child
);
98 wxList
*GetChildren();
99 virtual void RemoveChild( wxWindow
*child
);
100 void SetReturnCode( int retCode
);
102 wxWindow
*GetParent();
104 wxEvtHandler
*GetEventHandler();
105 void SetEventhandler( wxEvtHandler
*handler
);
107 virtual wxValidator
*GetValidator();
108 virtual void SetValidator( wxValidator
*validator
);
110 bool IsBeingDeleted();
112 void SetId( wxWindowID id
);
115 void SetCursor( const wxCursor
&cursor
);
117 virtual void Refresh( bool eraseBackground
= TRUE
, const wxRect
*rect
= NULL
);
118 virtual void Clear();
119 virtual bool IsExposed( long x
, long y
);
120 virtual bool IsExposed( long x
, long y
, long width
, long height
);
122 virtual wxColour
GetBackgroundColour() const;
123 virtual void SetBackgroundColour( const wxColour
&colour
);
125 virtual void SetDefaultBackgroundColour( const wxColour
& col
)
126 { m_defaultBackgroundColour
= col
; };
127 virtual wxColour
GetDefaultBackgroundColour() const
128 { return m_defaultBackgroundColour
; };
129 virtual void SetDefaultForegroundColour( const wxColour
& col
)
130 { m_defaultForegroundColour
= col
; };
131 virtual wxColour
GetDefaultForegroundColour() const
132 { return m_defaultForegroundColour
; };
134 virtual void SetFont( const wxFont
&font
);
135 virtual wxFont
*GetFont();
136 // For backward compatibility
137 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
138 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
139 inline virtual wxFont
*GetLabelFont() { return GetFont(); };
140 inline virtual wxFont
*GetButtonFont() { return GetFont(); };
141 virtual void SetWindowStyleFlag( long flag
);
142 virtual long GetWindowStyleFlag() const;
143 virtual void CaptureMouse();
144 virtual void ReleaseMouse();
145 virtual void SetTitle( const wxString
&title
);
146 virtual wxString
GetTitle() const;
147 virtual void SetName( const wxString
&name
);
148 virtual wxString
GetName() const;
149 virtual wxString
GetLabel() const;
151 void OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) ) {};
153 virtual bool IsShown() const;
155 // Raise the window to the top of the Z order
156 virtual void Raise(void) {};
158 // Lower the window to the bottom of the Z order
159 virtual void Lower(void) {};
162 virtual bool IsRetained();
163 virtual wxWindow
*FindWindow( long id
);
164 virtual wxWindow
*FindWindow( const wxString
& name
);
165 void AllowDoubleClick( bool WXUNUSED(allow
) ) {};
166 void SetDoubleClick( bool WXUNUSED(allow
) ) {};
167 virtual void ClientToScreen( int *x
, int *y
);
168 virtual void ScreenToClient( int *x
, int *y
);
170 virtual bool Validate();
171 virtual bool TransferDataToWindow();
172 virtual bool TransferDataFromWindow();
173 void OnInitDialog( wxInitDialogEvent
&event
);
174 virtual void InitDialog();
176 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
);
178 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
179 virtual wxDropTarget
*GetDropTarget() const;
182 virtual GtkWidget
* GetConnectWidget(void);
185 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
186 int range
, bool refresh
= TRUE
);
187 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
188 virtual int GetScrollPos( int orient
) const;
189 virtual int GetScrollThumb( int orient
) const;
190 virtual int GetScrollRange( int orient
) const;
191 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= NULL
);
193 // return FALSE from here if the window doesn't want the focus
194 virtual bool AcceptsFocus() const;
196 // update the UI state (called from OnIdle)
197 void UpdateWindowUI();
200 public: // cannot get private going yet
202 void PreCreation( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
,
203 const wxSize
&size
, long style
, const wxString
&name
);
206 virtual void ImplementSetSize();
207 virtual void ImplementSetPosition();
208 void GetDrawingOffset( long *x
, long *y
);
213 int m_width
,m_height
;
215 wxEvtHandler
*m_eventHandler
;
216 wxValidator
*m_windowValidator
;
217 wxDropTarget
*m_pDropTarget
;
218 wxWindowID m_windowId
;
221 wxColour m_backgroundColour
;
222 wxColour m_defaultBackgroundColour
;
223 wxColour m_foregroundColour
;
224 wxColour m_defaultForegroundColour
;
225 wxRegion m_updateRegion
;
229 wxString m_windowName
;
230 long m_drawingOffsetX
,m_drawingOffsetY
;
233 GtkWidget
*m_wxwindow
;
234 GtkAdjustment
*m_hAdjust
,*m_vAdjust
;
235 float m_oldHorizontalPos
;
236 float m_oldVerticalPos
;
243 public: // Layout section
245 wxLayoutConstraints
* m_constraints
;
246 wxList
* m_constraintsInvolvedIn
;
247 wxSizer
* m_windowSizer
;
248 wxWindow
* m_sizerParent
;
251 wxLayoutConstraints
*GetConstraints() const;
252 void SetConstraints( wxLayoutConstraints
*constraints
);
253 void SetAutoLayout( bool autoLayout
);
254 bool GetAutoLayout() const;
256 void SetSizer( wxSizer
*sizer
);
257 wxSizer
*GetSizer() const;
258 void SetSizerParent( wxWindow
*win
);
259 wxWindow
*GetSizerParent() const;
260 void UnsetConstraints(wxLayoutConstraints
*c
);
261 inline wxList
*GetConstraintsInvolvedIn() const ;
262 void AddConstraintReference(wxWindow
*otherWin
);
263 void RemoveConstraintReference(wxWindow
*otherWin
);
264 void DeleteRelatedConstraints();
265 virtual void ResetConstraints();
266 virtual void SetConstraintSizes(bool recurse
= TRUE
);
267 virtual bool LayoutPhase1(int *noChanges
);
268 virtual bool LayoutPhase2(int *noChanges
);
269 virtual bool DoPhase(int);
270 virtual void TransformSizerToActual(int *x
, int *y
) const ;
271 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
272 virtual void SizerMove(int x
, int y
);
273 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
274 virtual void MoveConstraint(int x
, int y
);
275 virtual void GetSizeConstraint(int *w
, int *h
) const ;
276 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
277 virtual void GetPositionConstraint(int *x
, int *y
) const ;
279 DECLARE_DYNAMIC_CLASS(wxWindow
)
280 DECLARE_EVENT_TABLE()
283 #endif // __GTKWINDOWH__