]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/window.h
moving down for non-precomp build
[wxWidgets.git] / include / wx / osx / window.h
CommitLineData
6762286d
SC
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 wxNonOwnedWindow;
21
22class WXDLLIMPEXP_FWD_CORE wxMacControl ;
23class WXDLLIMPEXP_FWD_CORE wxWidgetImpl ;
24
25class WXDLLIMPEXP_CORE wxWindowMac: public wxWindowBase
26{
27 DECLARE_DYNAMIC_CLASS(wxWindowMac)
28
29 friend class wxDC;
30 friend class wxPaintDC;
31
32public:
33 wxWindowMac();
34
35 wxWindowMac( wxWindowMac *parent,
36 wxWindowID id,
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize,
39 long style = 0,
40 const wxString& name = wxPanelNameStr );
41
42 virtual ~wxWindowMac();
43
44 bool Create( wxWindowMac *parent,
45 wxWindowID id,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxString& name = wxPanelNameStr );
50
51 // implement base class pure virtuals
52 virtual void SetLabel( const wxString& label );
53 virtual wxString GetLabel() const;
54
55 virtual void Raise();
56 virtual void Lower();
57
58 virtual bool Show( bool show = true );
59
60 virtual bool IsShownOnScreen() const;
61
62 virtual void SetFocus();
63
64 virtual void WarpPointer( int x, int y );
65
66 virtual void Refresh( bool eraseBackground = true,
67 const wxRect *rect = NULL );
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#if wxUSE_MENUS
88 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
89#endif
90
91 virtual void DoFreeze();
92 virtual void DoThaw();
93
94public:
95 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
96 int range, bool refresh = true );
97 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
98 virtual int GetScrollPos( int orient ) const;
99 virtual int GetScrollThumb( int orient ) const;
100 virtual int GetScrollRange( int orient ) const;
101 virtual void ScrollWindow( int dx, int dy,
d3b9f782 102 const wxRect* rect = NULL );
6762286d
SC
103 virtual void AlwaysShowScrollbars(bool horz = true, bool vert = true);
104 virtual bool IsScrollbarAlwaysShown(int orient) const
105 {
106 return orient == wxHORIZONTAL ? m_hScrollBarAlwaysShown
107 : m_vScrollBarAlwaysShown;
108 }
109
110 virtual bool Reparent( wxWindowBase *newParent );
111
112#if wxUSE_DRAG_AND_DROP
113 virtual void SetDropTarget( wxDropTarget *dropTarget );
114#endif
115
116 // Accept files for dragging
117 virtual void DragAcceptFiles( bool accept );
118
119 // implementation from now on
120 // --------------------------
121
122 void MacClientToRootWindow( int *x , int *y ) const;
123
124 void MacWindowToRootWindow( int *x , int *y ) const;
125
126 void MacRootWindowToWindow( int *x , int *y ) const;
127
128 virtual wxString MacGetToolTipString( wxPoint &where );
129
130 // simple accessors
131 // ----------------
132
133 virtual WXWidget GetHandle() const;
134
135 virtual bool SetTransparent(wxByte alpha);
136 virtual bool CanSetTransparent();
137 virtual wxByte GetTransparent() const ;
138
139 // event handlers
140 // --------------
4dd9fdf8 141
6762286d
SC
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
19c7ac3d 165 virtual void TriggerScrollEvent( wxEventType scrollEvent ) ;
6762286d
SC
166 // this should not be overriden in classes above wxWindowMac
167 // because it is called from its destructor via DeleteChildren
168 virtual void RemoveChild( wxWindowBase *child );
5398a2e0
SC
169
170 virtual bool MacDoRedraw( long time ) ;
171 virtual void MacPaintChildrenBorders();
6762286d
SC
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 wxNonOwnedWindow* 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 MacIsReallyEnabled() ;
199 bool MacIsReallyHilited() ;
200
938fbc8f 201#if WXWIN_COMPATIBILITY_2_8
6762286d 202 bool MacIsUserPane() { return m_macIsUserPane; }
938fbc8f
SC
203#endif
204 bool MacIsUserPane() const { return m_macIsUserPane; }
6762286d
SC
205
206 virtual bool MacSetupCursor( const wxPoint& pt ) ;
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 void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
235 wxList& GetSubcontrols() { return m_subControls; }
236
237 // translate wxWidgets coords into ones suitable
238 // to be passed to CreateControl calls
239 //
240 // returns true if non-default coords are returned, false otherwise
241 bool MacGetBoundsForControl(const wxPoint& pos,
242 const wxSize& size,
243 int& x, int& y,
244 int& w, int& h , bool adjustForOrigin ) const ;
245
246 // the 'true' OS level control for this wxWindow
247#if wxOSX_USE_CARBON
248 wxMacControl* GetPeer() const { return m_peer ; }
5c6eb3a8 249#else
6762286d
SC
250 wxWidgetImpl* GetPeer() const { return m_peer ; }
251#endif
252
253 void * MacGetCGContextRef() { return m_cgContextRef ; }
254 void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; }
255
256 // osx specific event handling common for all osx-ports
257
4eb5a0ec
RR
258 virtual bool OSXHandleClicked( double timestampsec );
259 virtual bool OSXHandleKeyEvent( wxKeyEvent& event );
6762286d
SC
260protected:
261 // For controls like radio buttons which are genuinely composite
262 wxList m_subControls;
263
264#if wxOSX_USE_CARBON
265 // the peer object, allowing for cleaner API support
266 wxMacControl * m_peer ;
267#else
268 wxWidgetImpl * m_peer ;
269#endif
270 void * m_cgContextRef ;
271
272 // cache the clipped rectangles within the window hierarchy
273 void MacUpdateClippedRects() const ;
274
275 mutable bool m_cachedClippedRectValid ;
276 mutable wxRect m_cachedClippedRectWithOuterStructure ;
277 mutable wxRect m_cachedClippedRect ;
278 mutable wxRect m_cachedClippedClientRect ;
279 mutable wxRegion m_cachedClippedRegionWithOuterStructure ;
280 mutable wxRegion m_cachedClippedRegion ;
281 mutable wxRegion m_cachedClippedClientRegion ;
282
283 // true if is is not a native control but a wxWindow control
284 bool m_macIsUserPane ;
285
286 // insets of the mac control from the wx top left corner
287 wxPoint m_macTopLeftInset ;
288 wxPoint m_macBottomRightInset ;
289 wxByte m_macAlpha ;
290
291 wxScrollBar* m_hScrollBar ;
292 wxScrollBar* m_vScrollBar ;
293 bool m_hScrollBarAlwaysShown;
294 bool m_vScrollBarAlwaysShown;
295 wxString m_label ;
296
297 // set to true if we do a sharp clip at the content area of this window
298 // must be dynamic as eg a panel normally is not clipping precisely, but if
299 // it becomes the target window of a scrolled window it has to...
300 bool m_clipChildren ;
301
302 virtual bool MacIsChildOfClientArea( const wxWindow* child ) const ;
303
304 bool MacHasScrollBarCorner() const;
305 void MacCreateScrollBars( long style ) ;
306 void MacRepositionScrollBars() ;
307 void MacUpdateControlFont() ;
308
309 // implement the base class pure virtuals
310 virtual wxSize DoGetBestSize() const;
311 virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const;
312 virtual void DoClientToScreen( int *x, int *y ) const;
313 virtual void DoScreenToClient( int *x, int *y ) const;
314 virtual void DoGetPosition( int *x, int *y ) const;
315 virtual void DoGetSize( int *width, int *height ) const;
316 virtual void DoGetClientSize( int *width, int *height ) const;
317 virtual void DoSetSize(int x, int y,
318 int width, int height,
319 int sizeFlags = wxSIZE_AUTO);
320 virtual void DoSetClientSize(int width, int height);
321
322 virtual void DoCaptureMouse();
323 virtual void DoReleaseMouse();
324
325 // move the window to the specified location and resize it: this is called
326 // from both DoSetSize() and DoSetClientSize() and would usually just call
327 // ::MoveWindow() except for composite controls which will want to arrange
328 // themselves inside the given rectangle
329 virtual void DoMoveWindow( int x, int y, int width, int height );
330 virtual void DoSetWindowVariant( wxWindowVariant variant );
331
332#if wxUSE_TOOLTIPS
333 virtual void DoSetToolTip( wxToolTip *tip );
5c6eb3a8 334#endif
6762286d
SC
335
336private:
337 // common part of all ctors
338 void Init();
339
340 // show/hide scrollbars as needed, common part of SetScrollbar() and
341 // AlwaysShowScrollbars()
342 void DoUpdateScrollbarVisibility();
343
344
c0c133e1 345 wxDECLARE_NO_COPY_CLASS(wxWindowMac);
6762286d
SC
346 DECLARE_EVENT_TABLE()
347};
348
349#endif // _WX_WINDOW_H_