]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/window.h
oops... fixed a typo
[wxWidgets.git] / include / wx / mac / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose: wxWindow class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #ifdef __GNUG__
16 #pragma interface "window.h"
17 #endif
18
19 // ---------------------------------------------------------------------------
20 // forward declarations
21 // ---------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxButton;
24 class WXDLLEXPORT wxScrollBar;
25
26 // ---------------------------------------------------------------------------
27 // constants
28 // ---------------------------------------------------------------------------
29
30 // FIXME does anybody use those? they're unused by wxWindows...
31 enum
32 {
33 wxKEY_SHIFT = 1,
34 wxKEY_CTRL = 2
35 };
36
37 class WXDLLEXPORT wxWindow: public wxWindowBase
38 {
39 DECLARE_DYNAMIC_CLASS(wxWindow);
40
41 friend class wxDC;
42 friend class wxPaintDC;
43
44 public:
45 typedef struct MacWindowData
46 {
47 SInt16 m_macWindowBackgroundTheme ;
48 WindowRef m_macWindow ;
49 ControlHandle m_macRootControl ;
50 wxWindow* m_macFocus ;
51 } MacWindowData ;
52
53
54 wxWindow() { Init(); }
55
56 wxWindow(wxWindow *parent,
57 wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxString& name = wxPanelNameStr)
62 {
63 Init();
64 Create(parent, id, pos, size, style, name);
65 }
66
67 virtual ~wxWindow();
68
69 bool Create(wxWindow *parent,
70 wxWindowID id,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = 0,
74 const wxString& name = wxPanelNameStr);
75
76
77 // implement base class pure virtuals
78 virtual void SetTitle( const wxString& title);
79 virtual wxString GetTitle() const;
80
81 virtual void Raise();
82 virtual void Lower();
83
84 virtual bool Show( bool show = TRUE );
85 virtual bool Enable( bool enable = TRUE );
86
87 virtual void SetFocus();
88
89 virtual void WarpPointer(int x, int y);
90 virtual void CaptureMouse();
91 virtual void ReleaseMouse();
92
93 virtual void Refresh( bool eraseBackground = TRUE,
94 const wxRect *rect = (const wxRect *) NULL );
95 virtual void Clear();
96
97 virtual bool SetCursor( const wxCursor &cursor );
98 virtual bool SetFont( const wxFont &font );
99
100 virtual int GetCharHeight() const;
101 virtual int GetCharWidth() const;
102 virtual void GetTextExtent(const wxString& string,
103 int *x, int *y,
104 int *descent = (int *) NULL,
105 int *externalLeading = (int *) NULL,
106 const wxFont *theFont = (const wxFont *) NULL)
107 const;
108
109 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
110
111 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
112 int range, bool refresh = TRUE );
113 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
114 virtual int GetScrollPos( int orient ) const;
115 virtual int GetScrollThumb( int orient ) const;
116 virtual int GetScrollRange( int orient ) const;
117 virtual void ScrollWindow( int dx, int dy,
118 const wxRect* rect = (wxRect *) NULL );
119
120 #if wxUSE_DRAG_AND_DROP
121 virtual void SetDropTarget( wxDropTarget *dropTarget );
122 #endif // wxUSE_DRAG_AND_DROP
123
124 // Accept files for dragging
125 virtual void DragAcceptFiles(bool accept);
126
127 #if WXWIN_COMPATIBILITY
128 // Set/get scroll attributes
129 virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
130 virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
131 virtual int OldGetScrollRange(int orient) const;
132 virtual int GetScrollPage(int orient) const;
133
134 // event handlers
135 // Handle a control command
136 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
137
138 // Override to define new behaviour for default action (e.g. double
139 // clicking on a listbox)
140 virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
141 #endif // WXWIN_COMPATIBILITY
142
143 #if wxUSE_CARET && WXWIN_COMPATIBILITY
144 // caret manipulation (old MSW only functions, see wxCaret class for the
145 // new API)
146 void CreateCaret(int w, int h);
147 void CreateCaret(const wxBitmap *bitmap);
148 void DestroyCaret();
149 void ShowCaret(bool show);
150 void SetCaretPos(int x, int y);
151 void GetCaretPos(int *x, int *y) const;
152 #endif // wxUSE_CARET
153
154 // Native resource loading (implemented in src/msw/nativdlg.cpp)
155 // FIXME: should they really be all virtual?
156 wxWindow* GetWindowChild1(wxWindowID id);
157 wxWindow* GetWindowChild(wxWindowID id);
158
159 // implementation from now on
160 // --------------------------
161
162 void MacClientToRootWindow( int *x , int *y ) const ;
163 void MacRootWindowToClient( int *x , int *y ) const ;
164
165 virtual wxString MacGetToolTipString( wxPoint &where ) ;
166
167 // simple accessors
168 // ----------------
169
170 // WXHWND GetHWND() const { return m_hWnd; }
171 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
172 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
173
174 bool GetUseCtl3D() const { return m_useCtl3D; }
175 bool GetTransparentBackground() const { return m_backgroundTransparent; }
176 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
177
178 // event handlers
179 // --------------
180 void OnEraseBackground(wxEraseEvent& event);
181 void OnIdle(wxIdleEvent& event);
182 void MacOnScroll(wxScrollEvent&event ) ;
183
184 bool AcceptsFocus() const ;
185
186 public:
187 // For implementation purposes - sometimes decorations make the client area
188 // smaller
189 virtual wxPoint GetClientAreaOrigin() const;
190
191 // Makes an adjustment to the window position (for example, a frame that has
192 // a toolbar that it manages itself).
193 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
194
195 wxWindow *FindItem(long id) const;
196 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
197
198 // Make a Windows extended style from the given wxWindows window style
199 static WXDWORD MakeExtendedStyle(long style,
200 bool eliminateBorders = TRUE);
201 // Determine whether 3D effects are wanted
202 WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
203
204 // MSW only: TRUE if this control is part of the main control
205 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
206
207 #if WXWIN_COMPATIBILITY
208 wxObject *GetChild(int number) const;
209 virtual void MSWDeviceToLogical(float *x, float *y) const;
210 #endif // WXWIN_COMPATIBILITY
211
212 // Setup background and foreground colours correctly
213 virtual void SetupColours();
214
215
216 #if WXWIN_COMPATIBILITY
217 void SetShowing(bool show) { (void)Show(show); }
218 bool IsUserEnabled() const { return IsEnabled(); }
219 #endif // WXWIN_COMPATIBILITY
220
221 // Responds to colour changes: passes event on to children.
222 void OnSysColourChanged(wxSysColourChangedEvent& event);
223 public :
224 virtual void MacCreateRealWindow( const wxString& title,
225 const wxPoint& pos,
226 const wxSize& size,
227 long style,
228 const wxString& name ) ;
229 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindow** outWin ) ;
230 virtual void MacActivate( EventRecord *ev , bool inIsActivating ) ;
231 virtual void MacUpdate( EventRecord *ev ) ;
232 virtual void MacUpdateImmediately() ;
233 virtual void MacRedraw( RgnHandle updatergn , long time) ;
234 virtual void MacMouseDown( EventRecord *ev , short windowPart ) ;
235 virtual void MacMouseUp( EventRecord *ev , short windowPart ) ;
236 virtual void MacMouseMoved( EventRecord *ev , short windowPart ) ;
237 virtual void MacKeyDown( EventRecord *ev ) ;
238 virtual bool MacCanFocus() const { return true ; }
239
240 virtual void MacFireMouseEvent( EventRecord *ev ) ;
241 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
242 virtual void MacEraseBackground( Rect *rect ) ;
243 virtual void MacPaintBorders() ;
244 // obsolete : only for link compatibility
245 virtual void MacPaint( wxPaintEvent &event ) ;
246 WindowRef GetMacRootWindow() const ;
247
248 virtual ControlHandle MacGetContainerForEmbedding() ;
249 virtual long MacGetBorderSize() const ;
250 static long MacRemoveBordersFromStyle( long style ) ;
251 virtual void MacSuperChangedPosition() ;
252 virtual void MacSuperShown( bool show ) ;
253 /*
254 bool MacSetupFocusPort() ;
255 bool MacSetupDrawingPort() ;
256 bool MacSetupFocusClientPort() ;
257 bool MacSetupDrawingClientPort() ;
258 */
259 virtual bool MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* rootwin ) ;
260 virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* rootwin ) ;
261
262 virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin ) ;
263 virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
264 virtual void MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
265 MacWindowData* MacGetWindowData() { return m_macWindowData ; }
266 static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
267 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
268 static wxWindow* s_lastMouseWindow ;
269 private:
270 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) ;
271 protected:
272
273 MacWindowData* m_macWindowData ;
274 static WindowRef s_macWindowInUpdate ;
275 RgnHandle m_macUpdateRgn ;
276
277 int m_x ;
278 int m_y ;
279 int m_width ;
280 int m_height ;
281
282 wxScrollBar* m_hScrollBar ;
283 wxScrollBar* m_vScrollBar ;
284 wxString m_label ;
285
286 void MacCreateScrollBars( long style ) ;
287 void MacRepositionScrollBars() ;
288
289 // additional (MSW specific) flags
290 bool m_useCtl3D:1; // Using CTL3D for this control
291 bool m_backgroundTransparent:1;
292 bool m_mouseInWindow:1;
293 bool m_doubleClickAllowed:1;
294 bool m_winCaptured:1;
295
296 // the size of one page for scrolling
297 int m_xThumbSize;
298 int m_yThumbSize;
299
300 // WXHMENU m_hMenu; // Menu, if any
301
302 // implement the base class pure virtuals
303 virtual void DoClientToScreen( int *x, int *y ) const;
304 virtual void DoScreenToClient( int *x, int *y ) const;
305 virtual void DoGetPosition( int *x, int *y ) const;
306 virtual void DoGetSize( int *width, int *height ) const;
307 virtual void DoGetClientSize( int *width, int *height ) const;
308 virtual void DoSetSize(int x, int y,
309 int width, int height,
310 int sizeFlags = wxSIZE_AUTO);
311 virtual void DoSetClientSize(int width, int height);
312
313 // move the window to the specified location and resize it: this is called
314 // from both DoSetSize() and DoSetClientSize() and would usually just call
315 // ::MoveWindow() except for composite controls which will want to arrange
316 // themselves inside the given rectangle
317 virtual void DoMoveWindow(int x, int y, int width, int height);
318
319 #if wxUSE_TOOLTIPS
320 virtual void DoSetToolTip( wxToolTip *tip );
321 #endif // wxUSE_TOOLTIPS
322
323 private:
324 // common part of all ctors
325 void Init();
326
327 DECLARE_NO_COPY_CLASS(wxWindow);
328 DECLARE_EVENT_TABLE()
329 };
330
331 // associate mac windows with wx counterparts
332
333 wxWindow* wxFindWinFromMacWindow( WindowRef inWindow ) ;
334 void wxAssociateWinWithMacWindow(WindowRef inWindow, wxWindow *win) ;
335 void wxRemoveMacWindowAssociation(wxWindow *win) ;
336
337 /*
338 class wxMacFocusHelper
339 {
340 public :
341 wxMacFocusHelper( wxWindow * theWindow ) ;
342 ~wxMacFocusHelper() ;
343 bool Ok() { return m_ok ; }
344
345 private :
346 GrafPtr m_formerPort ;
347 GrafPtr m_currentPort ;
348 bool m_ok ;
349 } ;
350 */
351
352 class wxMacDrawingHelper
353 {
354 public :
355 wxMacDrawingHelper( wxWindow * theWindow ) ;
356 ~wxMacDrawingHelper() ;
357 bool Ok() { return m_ok ; }
358
359 private :
360 GrafPtr m_formerPort ;
361 GrafPtr m_currentPort ;
362 PenState m_savedPenState ;
363 bool m_ok ;
364 } ;
365 /*
366 class wxMacFocusClientHelper
367 {
368 public :
369 wxMacFocusClientHelper( wxWindow * theWindow ) ;
370 ~wxMacFocusClientHelper() ;
371 bool Ok() { return m_ok ; }
372
373 private :
374 GrafPtr m_formerPort ;
375 GrafPtr m_currentPort ;
376 bool m_ok ;
377 } ;
378 */
379 class wxMacDrawingClientHelper
380 {
381 public :
382 wxMacDrawingClientHelper( wxWindow * theWindow ) ;
383 ~wxMacDrawingClientHelper() ;
384 bool Ok() { return m_ok ; }
385
386 private :
387 GrafPtr m_formerPort ;
388 GrafPtr m_currentPort ;
389 PenState m_savedPenState ;
390 bool m_ok ;
391 } ;
392
393 #endif
394 // _WX_WINDOW_H_