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