]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/window.h
Big color update with the newest information
[wxWidgets.git] / include / wx / gtk / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef __GTKWINDOWH__
12 #define __GTKWINDOWH__
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "wx/defs.h"
19 #include "wx/object.h"
20 #include "wx/list.h"
21 #include "wx/event.h"
22 #include "wx/validate.h"
23 #include "wx/cursor.h"
24 #include "wx/font.h"
25 #include "wx/dc.h"
26 #include "wx/region.h"
27 #include "wx/dnd.h"
28 #include "wx/accel.h"
29
30 //-----------------------------------------------------------------------------
31 // global data
32 //-----------------------------------------------------------------------------
33
34 extern const char *wxFrameNameStr;
35 extern wxList wxTopLevelWindows;
36
37 //-----------------------------------------------------------------------------
38 // classes
39 //-----------------------------------------------------------------------------
40
41 class wxLayoutConstraints;
42 class wxSizer;
43 class wxResourceTable;
44 class wxItemResource;
45
46 class wxWindow;
47 class wxCanvas;
48
49 //-----------------------------------------------------------------------------
50 // global data
51 //-----------------------------------------------------------------------------
52
53 extern const char *wxPanelNameStr;
54 extern const wxSize wxDefaultSize;
55 extern const wxPoint wxDefaultPosition;
56
57 //-----------------------------------------------------------------------------
58 // wxWindow
59 //-----------------------------------------------------------------------------
60
61 class wxWindow: public wxEvtHandler
62 {
63 DECLARE_DYNAMIC_CLASS(wxWindow)
64
65 public:
66 wxWindow();
67 inline wxWindow(wxWindow *parent, wxWindowID id,
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 long style = 0,
71 const wxString& name = wxPanelNameStr)
72 {
73 Create(parent, id, pos, size, style, name);
74 }
75 bool Create(wxWindow *parent, wxWindowID id,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0,
79 const wxString& name = wxPanelNameStr);
80 virtual ~wxWindow();
81
82 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
83 const wxResourceTable *table = (const wxResourceTable *) NULL);
84 virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
85 const wxResourceTable *table = (const wxResourceTable *) NULL);
86
87 bool Close( bool force = FALSE );
88 virtual bool Destroy();
89 virtual bool DestroyChildren();
90
91 virtual void PrepareDC( wxDC &dc );
92
93 virtual void SetSize( int x, int y, int width, int height,
94 int sizeFlags = wxSIZE_AUTO );
95 virtual void SetSize( int width, int height );
96 virtual void Move( int x, int y );
97 virtual void GetSize( int *width, int *height ) const;
98 virtual void SetClientSize( int const width, int const height );
99 virtual void GetClientSize( int *width, int *height ) const;
100 virtual void GetPosition( int *x, int *y ) const;
101 virtual void Centre( int direction = wxHORIZONTAL );
102 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
103 virtual void Fit();
104
105 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
106
107 // Dialog units translations. Implemented in wincmn.cpp.
108 wxPoint ConvertPixelsToDialog(const wxPoint& pt) ;
109 wxPoint ConvertDialogToPixels(const wxPoint& pt) ;
110 inline wxSize ConvertPixelsToDialog(const wxSize& sz)
111 { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
112 inline wxSize ConvertDialogToPixels(const wxSize& sz)
113 { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
114
115 void OnSize( wxSizeEvent &event );
116 void OnIdle( wxIdleEvent& event );
117
118 virtual bool Show( bool show );
119 virtual void Enable( bool enable );
120 virtual void MakeModal( bool modal );
121 virtual bool IsEnabled() const { return m_isEnabled; }
122 inline bool Enabled(void) const { return IsEnabled(); }
123 virtual void SetFocus();
124 virtual bool OnClose();
125
126 virtual void AddChild( wxWindow *child );
127 wxList *GetChildren();
128 virtual void RemoveChild( wxWindow *child );
129 void SetReturnCode( int retCode );
130 int GetReturnCode();
131 wxWindow *GetParent() const
132 { return m_parent; }
133 wxWindow *GetGrandParent(void) const
134 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
135 void SetParent( wxWindow *p )
136 { m_parent = p; }
137
138 wxEvtHandler *GetEventHandler();
139 void SetEventHandler( wxEvtHandler *handler );
140 void PushEventHandler( wxEvtHandler *handler );
141 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
142
143 virtual wxValidator *GetValidator();
144 virtual void SetValidator( const wxValidator &validator );
145
146 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
147 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
148
149 bool IsBeingDeleted();
150
151 void SetId( wxWindowID id );
152 wxWindowID GetId();
153
154 void SetCursor( const wxCursor &cursor );
155
156 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
157 virtual void Clear();
158
159 virtual wxRegion GetUpdateRegion() const;
160 virtual bool IsExposed(int x, int y) const;
161 virtual bool IsExposed(int x, int y, int w, int h) const;
162 virtual bool IsExposed(const wxPoint& pt) const;
163 virtual bool IsExposed(const wxRect& rect) const;
164
165 virtual wxColour GetBackgroundColour() const;
166 virtual void SetBackgroundColour( const wxColour &colour );
167 virtual wxColour GetForegroundColour() const;
168 virtual void SetForegroundColour( const wxColour &colour );
169
170 virtual int GetCharHeight(void) const;
171 virtual int GetCharWidth(void) const;
172 virtual void GetTextExtent( const wxString& string, int *x, int *y,
173 int *descent = (int *) NULL,
174 int *externalLeading = (int *) NULL,
175 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
176
177 virtual void SetFont( const wxFont &font );
178 virtual wxFont *GetFont();
179 // For backward compatibility
180 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
181 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
182 inline virtual wxFont *GetLabelFont() { return GetFont(); };
183 inline virtual wxFont *GetButtonFont() { return GetFont(); };
184 virtual void SetWindowStyleFlag( long flag );
185 virtual long GetWindowStyleFlag() const;
186 virtual void CaptureMouse();
187 virtual void ReleaseMouse();
188 virtual void SetTitle( const wxString &title );
189 virtual wxString GetTitle() const;
190 virtual void SetName( const wxString &name );
191 virtual wxString GetName() const;
192 virtual wxString GetLabel() const;
193
194 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
195
196 virtual bool IsShown() const;
197
198 virtual void Raise(void);
199 virtual void Lower(void);
200
201 virtual bool IsRetained();
202 virtual wxWindow *FindWindow( long id );
203 virtual wxWindow *FindWindow( const wxString& name );
204 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
205 void SetDoubleClick( bool WXUNUSED(allow) ) {};
206 virtual void ClientToScreen( int *x, int *y );
207 virtual void ScreenToClient( int *x, int *y );
208
209 virtual bool Validate();
210 virtual bool TransferDataToWindow();
211 virtual bool TransferDataFromWindow();
212 void OnInitDialog( wxInitDialogEvent &event );
213 virtual void InitDialog();
214
215 virtual bool PopupMenu( wxMenu *menu, int x, int y );
216
217 virtual void SetDropTarget( wxDropTarget *dropTarget );
218 virtual wxDropTarget *GetDropTarget() const;
219
220 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
221 int range, bool refresh = TRUE );
222 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
223 virtual int GetScrollPos( int orient ) const;
224 virtual int GetScrollThumb( int orient ) const;
225 virtual int GetScrollRange( int orient ) const;
226 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
227
228 virtual bool AcceptsFocus() const;
229 void UpdateWindowUI();
230
231 // implementation
232
233 virtual GtkWidget* GetConnectWidget(void);
234 virtual bool IsOwnGtkWindow( GdkWindow *window );
235 void ConnectWidget( GtkWidget *widget );
236 void ConnectDnDWidget( GtkWidget *widget );
237 void DisconnectDnDWidget( GtkWidget *widget );
238
239 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
240 const wxSize &size, long style, const wxString &name );
241 void PostCreation();
242 bool HasVMT();
243 virtual void ImplementSetSize();
244 virtual void ImplementSetPosition();
245 GtkStyle *GetWidgetStyle();
246 void SetWidgetStyle();
247 virtual void ApplyWidgetStyle();
248
249 wxWindow *m_parent;
250 wxList m_children;
251 int m_x,m_y;
252 int m_width,m_height;
253 int m_minWidth,m_minHeight;
254 int m_maxWidth,m_maxHeight;
255 int m_retCode;
256 wxEvtHandler *m_eventHandler;
257 wxValidator *m_windowValidator;
258 wxDropTarget *m_pDropTarget;
259 wxWindowID m_windowId;
260 wxCursor *m_cursor;
261 wxFont m_font;
262 wxColour m_backgroundColour;
263 wxColour m_foregroundColour ;
264 wxRegion m_updateRegion;
265 long m_windowStyle;
266 bool m_isShown;
267 bool m_isEnabled;
268 wxString m_windowName;
269 wxAcceleratorTable m_acceleratorTable;
270
271 GtkWidget *m_widget;
272 GtkWidget *m_wxwindow;
273 GtkAdjustment *m_hAdjust,*m_vAdjust;
274 float m_oldHorizontalPos;
275 float m_oldVerticalPos;
276 bool m_needParent;
277 bool m_hasScrolling;
278 bool m_isScrolling;
279 bool m_hasVMT;
280 bool m_sizeSet;
281 bool m_resizing;
282 GdkGC *m_scrollGC;
283 GtkStyle *m_widgetStyle;
284
285 public:
286
287 wxLayoutConstraints *m_constraints;
288 wxList *m_constraintsInvolvedIn;
289 wxSizer *m_windowSizer;
290 wxWindow *m_sizerParent;
291 bool m_autoLayout;
292
293 wxLayoutConstraints *GetConstraints() const;
294 void SetConstraints( wxLayoutConstraints *constraints );
295 void SetAutoLayout( bool autoLayout );
296 bool GetAutoLayout() const;
297 bool Layout();
298 void SetSizer( wxSizer *sizer );
299 wxSizer *GetSizer() const;
300 void SetSizerParent( wxWindow *win );
301 wxWindow *GetSizerParent() const;
302 void UnsetConstraints(wxLayoutConstraints *c);
303 inline wxList *GetConstraintsInvolvedIn() const ;
304 void AddConstraintReference(wxWindow *otherWin);
305 void RemoveConstraintReference(wxWindow *otherWin);
306 void DeleteRelatedConstraints();
307 virtual void ResetConstraints();
308 virtual void SetConstraintSizes(bool recurse = TRUE);
309 virtual bool LayoutPhase1(int *noChanges);
310 virtual bool LayoutPhase2(int *noChanges);
311 virtual bool DoPhase(int);
312 virtual void TransformSizerToActual(int *x, int *y) const ;
313 virtual void SizerSetSize(int x, int y, int w, int h);
314 virtual void SizerMove(int x, int y);
315 virtual void SetSizeConstraint(int x, int y, int w, int h);
316 virtual void MoveConstraint(int x, int y);
317 virtual void GetSizeConstraint(int *w, int *h) const ;
318 virtual void GetClientSizeConstraint(int *w, int *h) const ;
319 virtual void GetPositionConstraint(int *x, int *y) const ;
320
321 private:
322 DECLARE_EVENT_TABLE()
323 };
324
325 #endif // __GTKWINDOWH__