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