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 // internal implementation classes
33 // ---------------------------------------------------------------------------
35 // ---------------------------------------------------------------------------
37 class WXDLLEXPORT wxWindowMac
: public wxWindowBase
39 DECLARE_DYNAMIC_CLASS(wxWindowMac
)
42 friend class wxPaintDC
;
48 wxWindowMac(wxWindowMac
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxPanelNameStr
) ;
55 virtual ~wxWindowMac();
57 bool Create(wxWindowMac
*parent
,
59 const wxPoint
& pos
= wxDefaultPosition
,
60 const wxSize
& size
= wxDefaultSize
,
62 const wxString
& name
= wxPanelNameStr
);
65 // implement base class pure virtuals
66 virtual void SetTitle( const wxString
& title
);
67 virtual wxString
GetTitle() const;
72 virtual bool Show( bool show
= TRUE
);
73 virtual bool Enable( bool enable
= TRUE
);
75 virtual void SetFocus();
77 virtual void WarpPointer(int x
, int y
);
79 virtual void Refresh( bool eraseBackground
= TRUE
,
80 const wxRect
*rect
= (const wxRect
*) NULL
);
81 virtual void Freeze() ;
84 virtual bool SetCursor( const wxCursor
&cursor
);
85 virtual bool SetFont( const wxFont
&font
) ;
86 virtual bool SetBackgroundColour( const wxColour
&colour
);
87 virtual bool SetForegroundColour( const wxColour
&colour
);
89 virtual int GetCharHeight() const;
90 virtual int GetCharWidth() const;
91 virtual void GetTextExtent(const wxString
& string
,
93 int *descent
= (int *) NULL
,
94 int *externalLeading
= (int *) NULL
,
95 const wxFont
*theFont
= (const wxFont
*) NULL
)
98 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
100 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
101 int range
, bool refresh
= TRUE
);
102 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
103 virtual int GetScrollPos( int orient
) const;
104 virtual int GetScrollThumb( int orient
) const;
105 virtual int GetScrollRange( int orient
) const;
106 virtual void ScrollWindow( int dx
, int dy
,
107 const wxRect
* rect
= (wxRect
*) NULL
);
109 #if wxUSE_DRAG_AND_DROP
110 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
111 #endif // wxUSE_DRAG_AND_DROP
113 // Accept files for dragging
114 virtual void DragAcceptFiles(bool accept
);
116 // implementation from now on
117 // --------------------------
119 void MacClientToRootWindow( int *x
, int *y
) const ;
120 void MacRootWindowToClient( int *x
, int *y
) const ;
122 void MacWindowToRootWindow( int *x
, int *y
) const ;
123 void MacWindowToRootWindow( short *x
, short *y
) const ;
125 void MacRootWindowToWindow( int *x
, int *y
) const ;
126 void MacRootWindowToWindow( short *x
, short *y
) const ;
128 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
133 virtual WXWidget
GetHandle() const ;
135 #if WXWIN_COMPATIBILITY_2_4
136 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
137 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
142 void OnSetFocus(wxFocusEvent
& event
) ;
143 void OnNcPaint(wxNcPaintEvent
& event
);
144 void OnEraseBackground(wxEraseEvent
& event
);
145 void OnMouseEvent( wxMouseEvent
&event
) ;
147 void MacOnScroll(wxScrollEvent
&event
) ;
149 bool AcceptsFocus() const ;
152 void OnInternalIdle();
154 // For implementation purposes - sometimes decorations make the client area
156 virtual wxPoint
GetClientAreaOrigin() const;
158 wxWindowMac
*FindItem(long id
) const;
159 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
162 virtual void MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool mouseStillDown
) ;
163 virtual bool MacDoRedraw( WXHRGN updatergn
, long time
) ;
164 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
165 virtual bool MacCanFocus() const ;
167 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
168 virtual void RemoveChild( wxWindowBase
*child
);
169 virtual void MacPaintBorders( int left
, int top
) ;
170 WXWindow
MacGetTopLevelWindowRef() const ;
171 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
173 virtual long MacGetLeftBorderSize() const ;
174 virtual long MacGetRightBorderSize() const ;
175 virtual long MacGetTopBorderSize() const ;
176 virtual long MacGetBottomBorderSize() const ;
178 static long MacRemoveBordersFromStyle( long style
) ;
180 virtual void MacSuperChangedPosition() ;
181 // the absolute coortinates of this window's root have changed
182 virtual void MacTopLevelWindowChangedPosition() ;
184 virtual void MacVisibilityChanged() ;
185 virtual void MacEnabledStateChanged() ;
186 virtual void MacHiliteChanged() ;
187 virtual wxInt32
MacControlHit( WXEVENTHANDLERREF handler
, WXEVENTREF event
) ;
189 bool MacIsReallyShown() ;
190 bool MacIsReallyEnabled() ;
191 bool MacIsReallyHilited() ;
193 bool MacIsUserPane() { return m_macIsUserPane
; }
195 virtual void Update() ;
196 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
198 virtual void MacSetBackgroundBrush( const wxBrush
&brush
) ;
199 const wxBrush
& MacGetBackgroundBrush() const { return m_macBackgroundBrush
; }
201 // returns the visible region of this control in window ie non-client coordinates
203 wxRegion
MacGetVisibleRegion( bool includeOuterStructures
= false ) ;
204 bool MacIsWindowScrollbar( const wxScrollBar
* sb
)
205 { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
207 wxList
& GetSubcontrols() { return m_subControls
; }
208 virtual void MacInstallEventHandler(WXWidget native
) ;
209 virtual void MacRedrawControl();
210 WXEVENTHANDLERREF
MacGetControlEventHandler() { return m_macControlEventHandler
; }
211 void MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
) ;
213 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
214 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
215 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
216 virtual void MacControlUserPaneIdleProc() ;
217 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
218 virtual void MacControlUserPaneActivateProc(bool activating
) ;
219 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
220 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
222 // translate wxWidgets coords into ones suitable to be passed to
223 // the CreateControl calls
225 // returns TRUE if non default coords are returned, FALSE otherwise
226 bool MacGetBoundsForControl(const wxPoint
& pos
,
229 int& w
, int& h
, bool adjustForOrigin
) const ;
230 // calculates the real window position and size from the native control
231 void MacGetPositionAndSizeFromControl(int& x
, int& y
,
232 int& w
, int& h
) const ;
233 // gets the inset from every part
234 virtual void MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
) ;
236 // flash the current invalid area, useful for debugging in OSX double buffered situation
237 void MacFlashInvalidAreas() ;
240 // For controls like radiobuttons which are really composite
241 wxList m_subControls
;
242 // number of calls to Freeze() minus number of calls to Thaw()
243 unsigned int m_frozenness
;
244 // the peer object, allowing for cleaner API support
245 wxMacControl
* m_peer
;
246 // true if is is not a native control but a wxWindow control
247 bool m_macIsUserPane
;
248 wxBrush m_macBackgroundBrush
;
249 // topleft inset of the mac control from the wx top left corner
250 wxPoint m_macTopLeftInset
;
251 // bottom right inset of the mac control from the wx bottom right corner
252 wxPoint m_macBottomRightInset
;
254 wxScrollBar
* m_hScrollBar
;
255 wxScrollBar
* m_vScrollBar
;
258 void MacCreateScrollBars( long style
) ;
259 void MacRepositionScrollBars() ;
260 void MacUpdateControlFont() ;
262 void MacPropagateVisibilityChanged() ;
263 void MacPropagateEnabledStateChanged() ;
264 void MacPropagateHiliteChanged() ;
267 #if WXWIN_COMPATIBILITY_2_4
268 bool m_backgroundTransparent
;
271 // implement the base class pure virtuals
272 virtual wxSize
DoGetBestSize() const;
273 virtual wxSize
DoGetSizeFromClientSize( const wxSize
& size
) const;
274 virtual void DoClientToScreen( int *x
, int *y
) const;
275 virtual void DoScreenToClient( int *x
, int *y
) const;
276 virtual void DoGetPosition( int *x
, int *y
) const;
277 virtual void DoGetSize( int *width
, int *height
) const;
278 virtual void DoGetClientSize( int *width
, int *height
) const;
279 virtual void DoSetSize(int x
, int y
,
280 int width
, int height
,
281 int sizeFlags
= wxSIZE_AUTO
);
282 virtual void DoSetClientSize(int width
, int height
);
284 virtual void DoCaptureMouse();
285 virtual void DoReleaseMouse();
287 // move the window to the specified location and resize it: this is called
288 // from both DoSetSize() and DoSetClientSize() and would usually just call
289 // ::MoveWindow() except for composite controls which will want to arrange
290 // themselves inside the given rectangle
291 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
292 virtual void DoSetWindowVariant( wxWindowVariant variant
) ;
296 virtual void DoSetToolTip( wxToolTip
*tip
);
297 #endif // wxUSE_TOOLTIPS
302 // common part of all ctors
305 WXEVENTHANDLERREF m_macControlEventHandler
;
308 DECLARE_NO_COPY_CLASS(wxWindowMac
)
309 DECLARE_EVENT_TABLE()