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