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