]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/window.h
Added some tentative wxMotif clipboard code; did some file formatting
[wxWidgets.git] / include / wx / gtk1 / 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/region.h"
26 #include "wx/accel.h"
27
28 //-----------------------------------------------------------------------------
29 // global data
30 //-----------------------------------------------------------------------------
31
32 extern const char *wxFrameNameStr;
33 extern wxList wxTopLevelWindows;
34
35 //-----------------------------------------------------------------------------
36 // global function
37 //-----------------------------------------------------------------------------
38
39 wxWindow* wxGetActiveWindow();
40
41 //-----------------------------------------------------------------------------
42 // classes
43 //-----------------------------------------------------------------------------
44
45 class wxLayoutConstraints;
46 class wxSizer;
47 class wxDC;
48 class wxClientData;
49 class wxVoidClientData;
50 class wxWindow;
51 #if wxUSE_WX_RESOURCES
52 class wxResourceTable;
53 class wxItemResource;
54 #endif
55 #if wxUSE_DRAG_AND_DROP
56 class wxDropTarget;
57 #endif
58
59 //-----------------------------------------------------------------------------
60 // callback definition for inserting a window (internal)
61 //-----------------------------------------------------------------------------
62
63 typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
64
65 //-----------------------------------------------------------------------------
66 // global data
67 //-----------------------------------------------------------------------------
68
69 extern const char *wxPanelNameStr;
70 extern const wxSize wxDefaultSize;
71 extern const wxPoint wxDefaultPosition;
72
73 //-----------------------------------------------------------------------------
74 // wxClientData
75 //-----------------------------------------------------------------------------
76
77 class wxClientData
78 {
79 public:
80 wxClientData() { }
81 virtual ~wxClientData() { }
82 };
83
84 //-----------------------------------------------------------------------------
85 // wxStringClientData
86 //-----------------------------------------------------------------------------
87
88 class wxStringClientData: public wxClientData
89 {
90 public:
91 wxStringClientData() { }
92 wxStringClientData( wxString &data ) { m_data = data; }
93 void SetData( wxString &data ) { m_data = data; }
94 wxString GetData() const { return m_data; }
95
96 private:
97 wxString m_data;
98 };
99
100 //-----------------------------------------------------------------------------
101 // (debug)
102 //-----------------------------------------------------------------------------
103
104 #ifdef __WXDEBUG__
105
106 void debug_focus_in( GtkWidget* widget, const char* name, const char* window );
107
108 #endif
109
110 //-----------------------------------------------------------------------------
111 // wxWindow
112 //-----------------------------------------------------------------------------
113
114 class wxWindow: public wxEvtHandler
115 {
116 DECLARE_DYNAMIC_CLASS(wxWindow)
117
118 public:
119 wxWindow();
120 wxWindow(wxWindow *parent, wxWindowID id,
121 const wxPoint& pos = wxDefaultPosition,
122 const wxSize& size = wxDefaultSize,
123 long style = 0,
124 const wxString& name = wxPanelNameStr);
125 bool Create(wxWindow *parent, wxWindowID id,
126 const wxPoint& pos = wxDefaultPosition,
127 const wxSize& size = wxDefaultSize,
128 long style = 0,
129 const wxString& name = wxPanelNameStr);
130 virtual ~wxWindow();
131
132 #if wxUSE_WX_RESOURCES
133 virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
134 const wxResourceTable *table = (const wxResourceTable *) NULL);
135 virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
136 const wxResourceTable *table = (const wxResourceTable *) NULL);
137 #endif
138
139 bool Close( bool force = FALSE );
140 virtual bool Destroy();
141 virtual bool DestroyChildren();
142
143 virtual void PrepareDC( wxDC &dc );
144
145 virtual void SetSize( int x, int y, int width, int height,
146 int sizeFlags = wxSIZE_AUTO );
147 virtual void SetSize( int width, int height );
148
149 virtual void Move( int x, int y );
150
151 virtual void GetSize( int *width, int *height ) const;
152 wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); }
153
154 virtual void SetClientSize( int const width, int const height );
155
156 virtual void GetClientSize( int *width, int *height ) const;
157 wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
158
159 virtual void GetPosition( int *x, int *y ) const;
160 wxPoint GetPosition() const { int w, h; GetPosition(& w, & h); return wxPoint(w, h); }
161
162 wxRect GetRect() const
163 { int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); }
164
165 virtual void Centre( int direction = wxHORIZONTAL );
166 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
167 virtual void Fit();
168
169 virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 );
170
171 // Dialog units translations. Implemented in wincmn.cpp.
172 wxPoint ConvertPixelsToDialog(const wxPoint& pt) ;
173 wxPoint ConvertDialogToPixels(const wxPoint& pt) ;
174 inline wxSize ConvertPixelsToDialog(const wxSize& sz)
175 { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
176 inline wxSize ConvertDialogToPixels(const wxSize& sz)
177 { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
178
179 void OnSize( wxSizeEvent &event );
180 void OnIdle( wxIdleEvent& event );
181
182 virtual bool Show( bool show );
183 virtual void Enable( bool enable );
184 virtual void MakeModal( bool modal );
185 virtual bool IsEnabled() const { return m_isEnabled; }
186 inline bool Enabled() const { return IsEnabled(); }
187 virtual bool OnClose();
188
189 virtual void SetFocus();
190 static wxWindow *FindFocus();
191
192 virtual void AddChild( wxWindow *child );
193 wxList& GetChildren() { return m_children; }
194
195 virtual void RemoveChild( wxWindow *child );
196 void SetReturnCode( int retCode );
197 int GetReturnCode();
198 wxWindow *GetParent() const
199 { return m_parent; }
200 wxWindow *GetGrandParent() const
201 { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
202 void SetParent( wxWindow *p )
203 { m_parent = p; }
204 virtual wxWindow *ReParent( wxWindow *newParent );
205
206 wxEvtHandler *GetEventHandler() const;
207 void SetEventHandler( wxEvtHandler *handler );
208 void PushEventHandler( wxEvtHandler *handler );
209 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
210
211 virtual wxValidator *GetValidator();
212 virtual void SetValidator( const wxValidator &validator );
213
214 virtual void SetClientObject( wxClientData *data );
215 virtual wxClientData *GetClientObject();
216
217 virtual void SetClientData( void *data );
218 virtual void *GetClientData();
219
220 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
221 virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
222
223 bool IsBeingDeleted();
224
225 void SetId( wxWindowID id );
226 wxWindowID GetId() const;
227
228 void SetCursor( const wxCursor &cursor );
229
230 void WarpPointer(int x, int y);
231
232 virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
233 virtual void Clear();
234
235 virtual wxRegion GetUpdateRegion() const;
236 virtual bool IsExposed(int x, int y) const;
237 virtual bool IsExposed(int x, int y, int w, int h) const;
238 virtual bool IsExposed(const wxPoint& pt) const;
239 virtual bool IsExposed(const wxRect& rect) const;
240
241 virtual wxColour GetBackgroundColour() const;
242 virtual void SetBackgroundColour( const wxColour &colour );
243 virtual wxColour GetForegroundColour() const;
244 virtual void SetForegroundColour( const wxColour &colour );
245
246 virtual int GetCharHeight() const;
247 virtual int GetCharWidth() const;
248 virtual void GetTextExtent( const wxString& string, int *x, int *y,
249 int *descent = (int *) NULL,
250 int *externalLeading = (int *) NULL,
251 const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const;
252
253 virtual void SetFont( const wxFont &font );
254 virtual wxFont& GetFont() { return m_font; }
255
256 // For backward compatibility
257 inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
258 inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
259 inline virtual wxFont& GetLabelFont() { return GetFont(); };
260 inline virtual wxFont& GetButtonFont() { return GetFont(); };
261
262 virtual void SetWindowStyleFlag( long flag );
263 virtual long GetWindowStyleFlag() const;
264
265 virtual void CaptureMouse();
266 virtual void ReleaseMouse();
267
268 virtual void SetTitle( const wxString &title );
269 virtual wxString GetTitle() const;
270 virtual void SetName( const wxString &name );
271 virtual wxString GetName() const;
272 virtual wxString GetLabel() const;
273
274 void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
275
276 virtual bool IsShown() const;
277
278 virtual void Raise();
279 virtual void Lower();
280
281 virtual bool IsRetained();
282 virtual wxWindow *FindWindow( long id );
283 virtual wxWindow *FindWindow( const wxString& name );
284
285 void AllowDoubleClick( bool WXUNUSED(allow) ) {};
286 void SetDoubleClick( bool WXUNUSED(allow) ) {};
287
288 virtual void ClientToScreen( int *x, int *y );
289 virtual void ScreenToClient( int *x, int *y );
290
291 virtual bool Validate();
292 virtual bool TransferDataToWindow();
293 virtual bool TransferDataFromWindow();
294 void OnInitDialog( wxInitDialogEvent &event );
295 virtual void InitDialog();
296
297 virtual bool PopupMenu( wxMenu *menu, int x, int y );
298
299 #if wxUSE_DRAG_AND_DROP
300 virtual void SetDropTarget( wxDropTarget *dropTarget );
301 virtual wxDropTarget *GetDropTarget() const;
302 #endif
303
304 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
305 int range, bool refresh = TRUE );
306 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
307 virtual int GetScrollPos( int orient ) const;
308 virtual int GetScrollThumb( int orient ) const;
309 virtual int GetScrollRange( int orient ) const;
310 virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
311
312 virtual bool AcceptsFocus() const;
313
314 void UpdateWindowUI();
315
316 // implementation
317
318 void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
319 const wxSize &size, long style, const wxString &name );
320 void PostCreation();
321 virtual GtkWidget *GetConnectWidget();
322 virtual bool IsOwnGtkWindow( GdkWindow *window );
323 void ConnectWidget( GtkWidget *widget );
324
325 bool HasVMT();
326
327 virtual wxPoint GetClientAreaOrigin() const;
328 virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
329
330 GtkStyle *GetWidgetStyle();
331 void SetWidgetStyle();
332 virtual void ApplyWidgetStyle();
333
334
335 wxWindow *m_parent;
336 wxList m_children;
337 int m_x,m_y;
338 int m_width,m_height;
339 int m_minWidth,m_minHeight;
340 int m_maxWidth,m_maxHeight;
341 int m_retCode;
342 wxEvtHandler *m_eventHandler;
343 wxValidator *m_windowValidator;
344 #if wxUSE_DRAG_AND_DROP
345 wxDropTarget *m_dropTarget;
346 #endif
347 wxWindowID m_windowId;
348 wxCursor *m_cursor;
349 wxFont m_font;
350 wxColour m_backgroundColour;
351 wxColour m_foregroundColour;
352 wxRegion m_updateRegion;
353 long m_windowStyle;
354 bool m_isShown;
355 bool m_isEnabled;
356 wxString m_windowName;
357 wxAcceleratorTable m_acceleratorTable;
358 wxClientData *m_clientObject;
359 void *m_clientData;
360
361 GtkWidget *m_widget;
362 GtkWidget *m_wxwindow;
363 GtkAdjustment *m_hAdjust,*m_vAdjust;
364 float m_oldHorizontalPos;
365 float m_oldVerticalPos;
366 bool m_needParent;
367 bool m_hasScrolling;
368 bool m_isScrolling;
369 bool m_hasVMT;
370 bool m_sizeSet;
371 bool m_resizing;
372 GdkGC *m_scrollGC;
373 GtkStyle *m_widgetStyle;
374 bool m_isStaticBox;
375 bool m_acceptsFocus;
376
377 wxInsertChildFunction m_insertCallback;
378
379 public:
380
381 wxLayoutConstraints *m_constraints;
382 wxList *m_constraintsInvolvedIn;
383 wxSizer *m_windowSizer;
384 wxWindow *m_sizerParent;
385 bool m_autoLayout;
386
387 wxLayoutConstraints *GetConstraints() const;
388 void SetConstraints( wxLayoutConstraints *constraints );
389 void SetAutoLayout( bool autoLayout );
390 bool GetAutoLayout() const;
391 bool Layout();
392 void SetSizer( wxSizer *sizer );
393 wxSizer *GetSizer() const;
394 void SetSizerParent( wxWindow *win );
395 wxWindow *GetSizerParent() const;
396 void UnsetConstraints(wxLayoutConstraints *c);
397 inline wxList *GetConstraintsInvolvedIn() const ;
398 void AddConstraintReference(wxWindow *otherWin);
399 void RemoveConstraintReference(wxWindow *otherWin);
400 void DeleteRelatedConstraints();
401 virtual void ResetConstraints();
402 virtual void SetConstraintSizes(bool recurse = TRUE);
403 virtual bool LayoutPhase1(int *noChanges);
404 virtual bool LayoutPhase2(int *noChanges);
405 virtual bool DoPhase(int);
406 virtual void TransformSizerToActual(int *x, int *y) const ;
407 virtual void SizerSetSize(int x, int y, int w, int h);
408 virtual void SizerMove(int x, int y);
409 virtual void SetSizeConstraint(int x, int y, int w, int h);
410 virtual void MoveConstraint(int x, int y);
411 virtual void GetSizeConstraint(int *w, int *h) const ;
412 virtual void GetClientSizeConstraint(int *w, int *h) const ;
413 virtual void GetPositionConstraint(int *x, int *y) const ;
414
415 private:
416 DECLARE_EVENT_TABLE()
417 };
418
419 #endif // __GTKWINDOWH__