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