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
);
83 virtual bool SetCursor( const wxCursor
&cursor
);
84 virtual bool SetFont( const wxFont
&font
) ;
85 virtual bool SetBackgroundColour( const wxColour
&colour
);
86 virtual bool SetForegroundColour( const wxColour
&colour
);
88 virtual int GetCharHeight() const;
89 virtual int GetCharWidth() const;
90 virtual void GetTextExtent(const wxString
& string
,
92 int *descent
= (int *) NULL
,
93 int *externalLeading
= (int *) NULL
,
94 const wxFont
*theFont
= (const wxFont
*) NULL
)
97 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
99 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
100 int range
, bool refresh
= TRUE
);
101 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
102 virtual int GetScrollPos( int orient
) const;
103 virtual int GetScrollThumb( int orient
) const;
104 virtual int GetScrollRange( int orient
) const;
105 virtual void ScrollWindow( int dx
, int dy
,
106 const wxRect
* rect
= (wxRect
*) NULL
);
108 #if wxUSE_DRAG_AND_DROP
109 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
110 #endif // wxUSE_DRAG_AND_DROP
112 // Accept files for dragging
113 virtual void DragAcceptFiles(bool accept
);
115 // implementation from now on
116 // --------------------------
118 void MacClientToRootWindow( int *x
, int *y
) const ;
119 void MacRootWindowToClient( int *x
, int *y
) const ;
121 void MacWindowToRootWindow( int *x
, int *y
) const ;
122 void MacWindowToRootWindow( short *x
, short *y
) const ;
124 void MacRootWindowToWindow( int *x
, int *y
) const ;
125 void MacRootWindowToWindow( short *x
, short *y
) const ;
127 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
132 virtual WXWidget
GetHandle() const { return m_macControl
; }
134 #if WXWIN_COMPATIBILITY_2_4
135 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
136 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
141 void OnSetFocus(wxFocusEvent
& event
) ;
142 void OnNcPaint(wxNcPaintEvent
& event
);
143 void OnEraseBackground(wxEraseEvent
& event
);
144 void OnMouseEvent( wxMouseEvent
&event
) ;
146 void MacOnScroll(wxScrollEvent
&event
) ;
148 bool AcceptsFocus() const ;
151 void OnInternalIdle();
153 // For implementation purposes - sometimes decorations make the client area
155 virtual wxPoint
GetClientAreaOrigin() const;
157 wxWindowMac
*FindItem(long id
) const;
158 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
161 virtual void MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool mouseStillDown
) ;
162 virtual bool MacDoRedraw( WXHRGN updatergn
, long time
) ;
163 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
164 virtual bool MacCanFocus() const ;
166 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
167 virtual void RemoveChild( wxWindowBase
*child
);
168 virtual void MacPaintBorders( int left
, int top
) ;
169 WXWindow
MacGetTopLevelWindowRef() const ;
170 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
172 virtual long MacGetLeftBorderSize() const ;
173 virtual long MacGetRightBorderSize() const ;
174 virtual long MacGetTopBorderSize() const ;
175 virtual long MacGetBottomBorderSize() const ;
177 static long MacRemoveBordersFromStyle( long style
) ;
179 virtual void MacSuperChangedPosition() ;
180 // the absolute coortinates of this window's root have changed
181 virtual void MacTopLevelWindowChangedPosition() ;
183 virtual void MacVisibilityChanged() ;
184 virtual void MacEnabledStateChanged() ;
186 bool MacIsReallyShown() ;
187 bool MacIsReallyEnabled() ;
189 bool MacIsUserPane() { return m_macIsUserPane
; }
191 virtual void Update() ;
192 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
194 virtual void MacSetBackgroundBrush( const wxBrush
&brush
) { m_macBackgroundBrush
= brush
; }
195 const wxBrush
& MacGetBackgroundBrush() const { return m_macBackgroundBrush
; }
197 // returns the visible region of this control in window ie non-client coordinates
199 wxRegion
MacGetVisibleRegion( bool includeOuterStructures
= false ) ;
200 bool MacIsWindowScrollbar( const wxScrollBar
* sb
)
201 { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
203 wxList
& GetSubcontrols() { return m_subControls
; }
204 virtual void MacInstallEventHandler() ;
205 virtual void MacRedrawControl();
206 WXEVENTHANDLERREF
MacGetControlEventHandler() { return m_macControlEventHandler
; }
207 void MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
) ;
209 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
210 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
211 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
212 virtual void MacControlUserPaneIdleProc() ;
213 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
214 virtual void MacControlUserPaneActivateProc(bool activating
) ;
215 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
216 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
218 // translate wxWindows coords into ones suitable to be passed to
219 // the CreateControl calls
221 // returns TRUE if non default coords are returned, FALSE otherwise
222 bool MacGetBoundsForControl(const wxPoint
& pos
,
225 int& w
, int& h
) const ;
226 // calculates the real window position and size from the native control
227 void MacGetPositionAndSizeFromControl(int& x
, int& y
,
228 int& w
, int& h
) const ;
230 // For controls like radiobuttons which are really composite
231 wxList m_subControls
;
233 WXWidget m_macControl
;
234 bool m_macIsUserPane
;
235 wxBrush m_macBackgroundBrush
;
237 wxScrollBar
* m_hScrollBar
;
238 wxScrollBar
* m_vScrollBar
;
241 void MacCreateScrollBars( long style
) ;
242 void MacRepositionScrollBars() ;
243 void MacUpdateControlFont() ;
244 void MacPropagateVisibilityChanged() ;
245 void MacPropagateEnabledStateChanged() ;
248 #if WXWIN_COMPATIBILITY_2_4
249 bool m_backgroundTransparent
;
252 // implement the base class pure virtuals
253 virtual wxSize
DoGetBestSize() const;
254 virtual wxSize
DoGetSizeFromClientSize( const wxSize
& size
) const;
255 virtual void DoClientToScreen( int *x
, int *y
) const;
256 virtual void DoScreenToClient( int *x
, int *y
) const;
257 virtual void DoGetPosition( int *x
, int *y
) const;
258 virtual void DoGetSize( int *width
, int *height
) const;
259 virtual void DoGetClientSize( int *width
, int *height
) const;
260 virtual void DoSetSize(int x
, int y
,
261 int width
, int height
,
262 int sizeFlags
= wxSIZE_AUTO
);
263 virtual void DoSetClientSize(int width
, int height
);
265 virtual void DoCaptureMouse();
266 virtual void DoReleaseMouse();
268 // move the window to the specified location and resize it: this is called
269 // from both DoSetSize() and DoSetClientSize() and would usually just call
270 // ::MoveWindow() except for composite controls which will want to arrange
271 // themselves inside the given rectangle
272 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
273 virtual void DoSetWindowVariant( wxWindowVariant variant
) ;
277 virtual void DoSetToolTip( wxToolTip
*tip
);
278 #endif // wxUSE_TOOLTIPS
283 // common part of all ctors
286 WXEVENTHANDLERREF m_macControlEventHandler
;
289 DECLARE_NO_COPY_CLASS(wxWindowMac
)
290 DECLARE_EVENT_TABLE()