make access specifiers for the virtual functions match their access in the base class...
[wxWidgets.git] / include / wx / mac / carbon / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/mac/carbon/window.h
3 // Purpose: wxWindowMac class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #include "wx/brush.h"
16 #include "wx/dc.h"
17
18 class WXDLLEXPORT wxButton;
19 class WXDLLEXPORT wxScrollBar;
20 class WXDLLEXPORT wxTopLevelWindowMac;
21
22 class wxMacControl ;
23
24 class WXDLLEXPORT wxWindowMac: public wxWindowBase
25 {
26 DECLARE_DYNAMIC_CLASS(wxWindowMac)
27
28 friend class wxDC;
29 friend class wxPaintDC;
30
31 public:
32 wxWindowMac();
33
34 wxWindowMac( wxWindowMac *parent,
35 wxWindowID id,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 long style = 0,
39 const wxString& name = wxPanelNameStr );
40
41 virtual ~wxWindowMac();
42
43 bool Create( wxWindowMac *parent,
44 wxWindowID id,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = 0,
48 const wxString& name = wxPanelNameStr );
49
50 // implement base class pure virtuals
51 virtual void SetLabel( const wxString& label );
52 virtual wxString GetLabel() const;
53
54 virtual void Raise();
55 virtual void Lower();
56
57 virtual bool Show( bool show = true );
58 virtual bool Enable( bool enable = true );
59
60 virtual void SetFocus();
61
62 virtual void WarpPointer( int x, int y );
63
64 virtual void Refresh( bool eraseBackground = true,
65 const wxRect *rect = NULL );
66 virtual void Freeze();
67 virtual void Thaw();
68
69 virtual void Update() ;
70 virtual void ClearBackground();
71
72 virtual bool SetCursor( const wxCursor &cursor );
73 virtual bool SetFont( const wxFont &font );
74 virtual bool SetBackgroundColour( const wxColour &colour );
75 virtual bool SetForegroundColour( const wxColour &colour );
76
77 virtual int GetCharHeight() const;
78 virtual int GetCharWidth() const;
79 virtual void GetTextExtent( const wxString& string,
80 int *x, int *y,
81 int *descent = NULL,
82 int *externalLeading = NULL,
83 const wxFont *theFont = NULL )
84 const;
85 protected:
86 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
87 public:
88 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
89 int range, bool refresh = true );
90 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
91 virtual int GetScrollPos( int orient ) const;
92 virtual int GetScrollThumb( int orient ) const;
93 virtual int GetScrollRange( int orient ) const;
94 virtual void ScrollWindow( int dx, int dy,
95 const wxRect* rect = (wxRect *) NULL );
96 virtual bool Reparent( wxWindowBase *newParent );
97
98 #if wxUSE_DRAG_AND_DROP
99 virtual void SetDropTarget( wxDropTarget *dropTarget );
100 #endif
101
102 // Accept files for dragging
103 virtual void DragAcceptFiles( bool accept );
104
105 // implementation from now on
106 // --------------------------
107
108 void MacClientToRootWindow( int *x , int *y ) const;
109 void MacRootWindowToClient( int *x , int *y ) const;
110
111 void MacWindowToRootWindow( int *x , int *y ) const;
112 void MacWindowToRootWindow( short *x , short *y ) const;
113
114 void MacRootWindowToWindow( int *x , int *y ) const;
115 void MacRootWindowToWindow( short *x , short *y ) const;
116
117 virtual wxString MacGetToolTipString( wxPoint &where );
118
119 // simple accessors
120 // ----------------
121
122 virtual WXWidget GetHandle() const;
123
124 #if WXWIN_COMPATIBILITY_2_4
125 bool GetTransparentBackground() const { return m_backgroundTransparent; }
126 void SetTransparent(bool t = true) { m_backgroundTransparent = t; }
127 #endif
128
129 // event handlers
130 // --------------
131 void OnSetFocus( wxFocusEvent& event );
132 void OnPaint( wxPaintEvent& event );
133 void OnNcPaint( wxNcPaintEvent& event );
134 void OnEraseBackground(wxEraseEvent& event );
135 void OnMouseEvent( wxMouseEvent &event );
136
137 void MacOnScroll( wxScrollEvent&event );
138
139 bool AcceptsFocus() const;
140
141 public:
142 static long MacRemoveBordersFromStyle( long style ) ;
143
144 public:
145 void OnInternalIdle();
146
147 // For implementation purposes:
148 // sometimes decorations make the client area smaller
149 virtual wxPoint GetClientAreaOrigin() const;
150
151 wxWindowMac *FindItem(long id) const;
152 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
153
154 virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
155 virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ;
156 virtual bool MacCanFocus() const ;
157
158 // this should not be overriden in classes above wxWindowMac
159 // because it is called from its destructor via DeleteChildren
160 virtual void RemoveChild( wxWindowBase *child );
161 virtual void MacPaintBorders( int left , int top ) ;
162
163 // invalidates the borders and focus area around the control;
164 // must not be virtual as it will be called during destruction
165 void MacInvalidateBorders() ;
166
167 WXWindow MacGetTopLevelWindowRef() const ;
168 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
169
170 virtual long MacGetLeftBorderSize() const ;
171 virtual long MacGetRightBorderSize() const ;
172 virtual long MacGetTopBorderSize() const ;
173 virtual long MacGetBottomBorderSize() const ;
174
175 virtual void MacSuperChangedPosition() ;
176
177 // absolute coordinates of this window's root have changed
178 virtual void MacTopLevelWindowChangedPosition() ;
179
180 virtual void MacChildAdded() ;
181 virtual void MacVisibilityChanged() ;
182 virtual void MacEnabledStateChanged() ;
183 virtual void MacHiliteChanged() ;
184 virtual wxInt32 MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
185
186 bool MacIsReallyShown() ;
187 bool MacIsReallyEnabled() ;
188 bool MacIsReallyHilited() ;
189
190 bool MacIsUserPane() { return m_macIsUserPane; }
191
192 virtual bool MacSetupCursor( const wxPoint& pt ) ;
193 virtual void MacSetBackgroundBrush( const wxBrush &brush ) ;
194 const wxBrush& MacGetBackgroundBrush() const { return m_macBackgroundBrush ; }
195
196 // return the rectangle that would be visible of this control,
197 // regardless whether controls are hidden
198 // only taking into account clipping by parent windows
199 const wxRect& MacGetClippedClientRect() const ;
200 const wxRect& MacGetClippedRect() const ;
201 const wxRect& MacGetClippedRectWithOuterStructure() const ;
202
203 // returns the visible region of this control in window ie non-client coordinates
204 const wxRegion& MacGetVisibleRegion( bool includeOuterStructures = false ) ;
205
206 // returns true if children have to clipped to the content area
207 // (e.g., scrolled windows)
208 bool MacClipChildren() const { return m_clipChildren ; }
209 void MacSetClipChildren( bool clip ) { m_clipChildren = clip ; }
210
211 // returns true if the grandchildren need to be clipped to the children's content area
212 // (e.g., splitter windows)
213 virtual bool MacClipGrandChildren() const { return false ; }
214 bool MacIsWindowScrollbar( const wxScrollBar* sb )
215 { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
216
217 virtual void MacInstallEventHandler(WXWidget native) ;
218 void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
219 wxList& GetSubcontrols() { return m_subControls; }
220 WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; }
221
222 #ifndef __WXMAC_OSX__
223 virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
224 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
225 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
226 virtual void MacControlUserPaneIdleProc() ;
227 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ;
228 virtual void MacControlUserPaneActivateProc(bool activating) ;
229 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
230 virtual void MacControlUserPaneBackgroundProc(void* info) ;
231 #endif
232
233 // translate wxWidgets coords into ones suitable
234 // to be passed to CreateControl calls
235 //
236 // returns true if non-default coords are returned, false otherwise
237 bool MacGetBoundsForControl(const wxPoint& pos,
238 const wxSize& size,
239 int& x, int& y,
240 int& w, int& h , bool adjustForOrigin ) const ;
241
242 // calculates the real window position and size from the native control
243 void MacGetPositionAndSizeFromControl(int& x, int& y,
244 int& w, int& h) const ;
245
246 // gets the inset from every part
247 virtual void MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) ;
248
249 // visibly flash the current invalid area:
250 // useful for debugging in OSX composited (double-buffered) situation
251 void MacFlashInvalidAreas() ;
252
253 // the 'true' OS level control for this wxWindow
254 wxMacControl* GetPeer() const { return m_peer ; }
255
256 #if wxMAC_USE_CORE_GRAPHICS
257 void * MacGetCGContextRef() { return m_cgContextRef ; }
258 void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; }
259 #endif
260
261 protected:
262 // For controls like radio buttons which are genuinely composite
263 wxList m_subControls;
264
265 // number of calls to Freeze() minus number of calls to Thaw()
266 unsigned int m_frozenness;
267
268 // the peer object, allowing for cleaner API support
269 wxMacControl * m_peer ;
270
271 #if wxMAC_USE_CORE_GRAPHICS
272 void * m_cgContextRef ;
273 #endif
274
275 // cache the clipped rectangles within the window hierarchy
276 void MacUpdateClippedRects() const ;
277
278 mutable bool m_cachedClippedRectValid ;
279 mutable wxRect m_cachedClippedRectWithOuterStructure ;
280 mutable wxRect m_cachedClippedRect ;
281 mutable wxRect m_cachedClippedClientRect ;
282 mutable wxRegion m_cachedClippedRegionWithOuterStructure ;
283 mutable wxRegion m_cachedClippedRegion ;
284 mutable wxRegion m_cachedClippedClientRegion ;
285
286 // true if is is not a native control but a wxWindow control
287 bool m_macIsUserPane ;
288 wxBrush m_macBackgroundBrush ;
289
290 // insets of the mac control from the wx top left corner
291 wxPoint m_macTopLeftInset ;
292 wxPoint m_macBottomRightInset ;
293
294 wxScrollBar* m_hScrollBar ;
295 wxScrollBar* m_vScrollBar ;
296 wxString m_label ;
297
298 // set to true if we do a sharp clip at the content area of this window
299 // must be dynamic as eg a panel normally is not clipping precisely, but if
300 // it becomes the target window of a scrolled window it has to...
301 bool m_clipChildren ;
302
303 virtual bool MacIsChildOfClientArea( const wxWindow* child ) const ;
304
305 void MacCreateScrollBars( long style ) ;
306 void MacRepositionScrollBars() ;
307 void MacUpdateControlFont() ;
308
309 void MacPropagateVisibilityChanged() ;
310 void MacPropagateEnabledStateChanged() ;
311 void MacPropagateHiliteChanged() ;
312
313 #if WXWIN_COMPATIBILITY_2_4
314 bool m_backgroundTransparent ;
315 #endif
316
317 // implement the base class pure virtuals
318 virtual wxSize DoGetBestSize() const;
319 virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const;
320 virtual void DoClientToScreen( int *x, int *y ) const;
321 virtual void DoScreenToClient( int *x, int *y ) const;
322 virtual void DoGetPosition( int *x, int *y ) const;
323 virtual void DoGetSize( int *width, int *height ) const;
324 virtual void DoGetClientSize( int *width, int *height ) const;
325 virtual void DoSetSize(int x, int y,
326 int width, int height,
327 int sizeFlags = wxSIZE_AUTO);
328 virtual void DoSetClientSize(int width, int height);
329
330 virtual void DoCaptureMouse();
331 virtual void DoReleaseMouse();
332
333 // move the window to the specified location and resize it: this is called
334 // from both DoSetSize() and DoSetClientSize() and would usually just call
335 // ::MoveWindow() except for composite controls which will want to arrange
336 // themselves inside the given rectangle
337 virtual void DoMoveWindow( int x, int y, int width, int height );
338 virtual void DoSetWindowVariant( wxWindowVariant variant );
339
340 #if wxUSE_TOOLTIPS
341 virtual void DoSetToolTip( wxToolTip *tip );
342 #endif
343
344 private:
345 // common part of all ctors
346 void Init();
347
348 WXEVENTHANDLERREF m_macControlEventHandler ;
349
350 DECLARE_NO_COPY_CLASS(wxWindowMac)
351 DECLARE_EVENT_TABLE()
352 };
353
354 #endif // _WX_WINDOW_H_