1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "window.h"
21 // ---------------------------------------------------------------------------
22 // forward declarations
23 // ---------------------------------------------------------------------------
25 class WXDLLEXPORT wxButton
;
26 class WXDLLEXPORT wxScrollBar
;
27 class WXDLLEXPORT wxTopLevelWindowMac
;
29 // ---------------------------------------------------------------------------
31 // ---------------------------------------------------------------------------
33 class WXDLLEXPORT wxWindowMac
: public wxWindowBase
35 DECLARE_DYNAMIC_CLASS(wxWindowMac
)
38 friend class wxPaintDC
;
45 wxWindowMac(wxWindowMac
*parent
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
50 const wxString
& name
= wxPanelNameStr
)
53 Create(parent
, id
, pos
, size
, style
, name
);
56 virtual ~wxWindowMac();
58 bool Create(wxWindowMac
*parent
,
60 const wxPoint
& pos
= wxDefaultPosition
,
61 const wxSize
& size
= wxDefaultSize
,
63 const wxString
& name
= wxPanelNameStr
);
66 // implement base class pure virtuals
67 virtual void SetTitle( const wxString
& title
);
68 virtual wxString
GetTitle() const;
73 virtual bool Show( bool show
= TRUE
);
74 virtual bool Enable( bool enable
= TRUE
);
76 virtual void SetFocus();
78 virtual void WarpPointer(int x
, int y
);
80 virtual void Refresh( bool eraseBackground
= TRUE
,
81 const wxRect
*rect
= (const wxRect
*) NULL
);
82 virtual void Freeze() ;
85 virtual bool SetCursor( const wxCursor
&cursor
);
86 virtual bool SetFont( const wxFont
&font
) ;
87 virtual bool SetBackgroundColour( const wxColour
&colour
);
88 virtual bool SetForegroundColour( const wxColour
&colour
);
90 virtual int GetCharHeight() const;
91 virtual int GetCharWidth() const;
92 virtual void GetTextExtent(const wxString
& string
,
94 int *descent
= (int *) NULL
,
95 int *externalLeading
= (int *) NULL
,
96 const wxFont
*theFont
= (const wxFont
*) NULL
)
99 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
101 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
102 int range
, bool refresh
= TRUE
);
103 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
104 virtual int GetScrollPos( int orient
) const;
105 virtual int GetScrollThumb( int orient
) const;
106 virtual int GetScrollRange( int orient
) const;
107 virtual void ScrollWindow( int dx
, int dy
,
108 const wxRect
* rect
= (wxRect
*) NULL
);
110 #if wxUSE_DRAG_AND_DROP
111 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
112 #endif // wxUSE_DRAG_AND_DROP
114 // Accept files for dragging
115 virtual void DragAcceptFiles(bool accept
);
117 // implementation from now on
118 // --------------------------
120 void MacClientToRootWindow( int *x
, int *y
) const ;
121 void MacRootWindowToClient( int *x
, int *y
) const ;
123 void MacWindowToRootWindow( int *x
, int *y
) const ;
124 void MacWindowToRootWindow( short *x
, short *y
) const ;
126 void MacRootWindowToWindow( int *x
, int *y
) const ;
127 void MacRootWindowToWindow( short *x
, short *y
) const ;
129 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
134 virtual WXWidget
GetHandle() const { return m_macControl
; }
136 #if WXWIN_COMPATIBILITY_2_4
137 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
138 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
143 void OnSetFocus(wxFocusEvent
& event
) ;
144 void OnNcPaint(wxNcPaintEvent
& event
);
145 void OnEraseBackground(wxEraseEvent
& event
);
146 void OnMouseEvent( wxMouseEvent
&event
) ;
148 void MacOnScroll(wxScrollEvent
&event
) ;
150 bool AcceptsFocus() const ;
153 void OnInternalIdle();
155 // For implementation purposes - sometimes decorations make the client area
157 virtual wxPoint
GetClientAreaOrigin() const;
159 wxWindowMac
*FindItem(long id
) const;
160 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
163 virtual void MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool mouseStillDown
) ;
164 virtual bool MacDoRedraw( WXHRGN updatergn
, long time
) ;
165 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
166 virtual bool MacCanFocus() const ;
168 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
169 virtual void RemoveChild( wxWindowBase
*child
);
170 virtual void MacPaintBorders( int left
, int top
) ;
171 WXWindow
MacGetTopLevelWindowRef() const ;
172 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
174 virtual long MacGetLeftBorderSize() const ;
175 virtual long MacGetRightBorderSize() const ;
176 virtual long MacGetTopBorderSize() const ;
177 virtual long MacGetBottomBorderSize() const ;
179 static long MacRemoveBordersFromStyle( long style
) ;
181 virtual void MacSuperChangedPosition() ;
182 // the absolute coortinates of this window's root have changed
183 virtual void MacTopLevelWindowChangedPosition() ;
185 virtual void MacVisibilityChanged() ;
186 virtual void MacEnabledStateChanged() ;
187 virtual void MacHiliteChanged() ;
188 virtual wxInt32
MacControlHit( WXEVENTHANDLERREF handler
, WXEVENTREF event
) ;
190 bool MacIsReallyShown() ;
191 bool MacIsReallyEnabled() ;
192 bool MacIsReallyHilited() ;
194 bool MacIsUserPane() { return m_macIsUserPane
; }
196 virtual void Update() ;
197 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
199 virtual void MacSetBackgroundBrush( const wxBrush
&brush
) { m_macBackgroundBrush
= brush
; }
200 const wxBrush
& MacGetBackgroundBrush() const { return m_macBackgroundBrush
; }
202 // returns the visible region of this control in window ie non-client coordinates
204 wxRegion
MacGetVisibleRegion( bool includeOuterStructures
= false ) ;
205 bool MacIsWindowScrollbar( const wxScrollBar
* sb
)
206 { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
208 wxList
& GetSubcontrols() { return m_subControls
; }
209 virtual void MacInstallEventHandler() ;
210 virtual void MacRedrawControl();
211 WXEVENTHANDLERREF
MacGetControlEventHandler() { return m_macControlEventHandler
; }
212 void MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
) ;
214 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
215 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
216 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
217 virtual void MacControlUserPaneIdleProc() ;
218 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
219 virtual void MacControlUserPaneActivateProc(bool activating
) ;
220 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
221 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
223 // translate wxWidgets coords into ones suitable to be passed to
224 // the CreateControl calls
226 // returns TRUE if non default coords are returned, FALSE otherwise
227 bool MacGetBoundsForControl(const wxPoint
& pos
,
230 int& w
, int& h
, bool adjustForOrigin
) const ;
231 // calculates the real window position and size from the native control
232 void MacGetPositionAndSizeFromControl(int& x
, int& y
,
233 int& w
, int& h
) const ;
234 // gets the inset from every part
235 virtual void MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
) ;
237 // flash the current invalid area, useful for debugging in OSX double buffered situation
238 void MacFlashInvalidAreas() ;
241 // For controls like radiobuttons which are really composite
242 wxList m_subControls
;
243 // number of calls to Freeze() minus number of calls to Thaw()
244 unsigned int m_frozenness
;
245 // the true native ControlRef / = HIViewRef on OSX
246 WXWidget m_macControl
;
247 // true if is is not a native control but a wxWindow control
248 bool m_macIsUserPane
;
249 wxBrush m_macBackgroundBrush
;
250 // topleft inset of the mac control from the wx top left corner
251 wxPoint m_macTopLeftInset
;
252 // bottom right inset of the mac control from the wx bottom right corner
253 wxPoint m_macBottomRightInset
;
255 wxScrollBar
* m_hScrollBar
;
256 wxScrollBar
* m_vScrollBar
;
259 void MacCreateScrollBars( long style
) ;
260 void MacRepositionScrollBars() ;
261 void MacUpdateControlFont() ;
263 void MacPropagateVisibilityChanged() ;
264 void MacPropagateEnabledStateChanged() ;
265 void MacPropagateHiliteChanged() ;
268 #if WXWIN_COMPATIBILITY_2_4
269 bool m_backgroundTransparent
;
272 // implement the base class pure virtuals
273 virtual wxSize
DoGetBestSize() const;
274 virtual wxSize
DoGetSizeFromClientSize( const wxSize
& size
) const;
275 virtual void DoClientToScreen( int *x
, int *y
) const;
276 virtual void DoScreenToClient( int *x
, int *y
) const;
277 virtual void DoGetPosition( int *x
, int *y
) const;
278 virtual void DoGetSize( int *width
, int *height
) const;
279 virtual void DoGetClientSize( int *width
, int *height
) const;
280 virtual void DoSetSize(int x
, int y
,
281 int width
, int height
,
282 int sizeFlags
= wxSIZE_AUTO
);
283 virtual void DoSetClientSize(int width
, int height
);
285 virtual void DoCaptureMouse();
286 virtual void DoReleaseMouse();
288 // move the window to the specified location and resize it: this is called
289 // from both DoSetSize() and DoSetClientSize() and would usually just call
290 // ::MoveWindow() except for composite controls which will want to arrange
291 // themselves inside the given rectangle
292 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
293 virtual void DoSetWindowVariant( wxWindowVariant variant
) ;
297 virtual void DoSetToolTip( wxToolTip
*tip
);
298 #endif // wxUSE_TOOLTIPS
303 // common part of all ctors
306 WXEVENTHANDLERREF m_macControlEventHandler
;
309 DECLARE_NO_COPY_CLASS(wxWindowMac
)
310 DECLARE_EVENT_TABLE()