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