1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "window.h"
19 // ---------------------------------------------------------------------------
20 // forward declarations
21 // ---------------------------------------------------------------------------
23 class WXDLLEXPORT wxButton
;
24 class WXDLLEXPORT wxScrollBar
;
25 class WXDLLEXPORT wxTopLevelWindowMac
;
27 // ---------------------------------------------------------------------------
29 // ---------------------------------------------------------------------------
31 // FIXME does anybody use those? they're unused by wxWindows...
38 class WXDLLEXPORT wxWindowMac
: public wxWindowBase
40 DECLARE_DYNAMIC_CLASS(wxWindowMac
);
43 friend class wxPaintDC
;
47 wxWindowMac() { Init(); }
49 wxWindowMac(wxWindowMac
*parent
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
54 const wxString
& name
= wxPanelNameStr
)
57 Create(parent
, id
, pos
, size
, style
, name
);
60 virtual ~wxWindowMac();
62 bool Create(wxWindowMac
*parent
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
,
67 const wxString
& name
= wxPanelNameStr
);
70 // implement base class pure virtuals
71 virtual void SetTitle( const wxString
& title
);
72 virtual wxString
GetTitle() const;
77 virtual bool Show( bool show
= TRUE
);
78 virtual bool Enable( bool enable
= TRUE
);
80 virtual void SetFocus();
82 virtual void WarpPointer(int x
, int y
);
83 virtual void CaptureMouse();
84 virtual void ReleaseMouse();
86 virtual void Refresh( bool eraseBackground
= TRUE
,
87 const wxRect
*rect
= (const wxRect
*) NULL
);
90 virtual bool SetCursor( const wxCursor
&cursor
);
91 virtual bool SetFont(const wxFont
& font
)
92 { return wxWindowBase::SetFont(font
); }
93 virtual int GetCharHeight() const;
94 virtual int GetCharWidth() const;
95 virtual void GetTextExtent(const wxString
& string
,
97 int *descent
= (int *) NULL
,
98 int *externalLeading
= (int *) NULL
,
99 const wxFont
*theFont
= (const wxFont
*) NULL
)
102 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
104 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
105 int range
, bool refresh
= TRUE
);
106 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
107 virtual int GetScrollPos( int orient
) const;
108 virtual int GetScrollThumb( int orient
) const;
109 virtual int GetScrollRange( int orient
) const;
110 virtual void ScrollWindow( int dx
, int dy
,
111 const wxRect
* rect
= (wxRect
*) NULL
);
113 #if wxUSE_DRAG_AND_DROP
114 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
115 #endif // wxUSE_DRAG_AND_DROP
117 // Accept files for dragging
118 virtual void DragAcceptFiles(bool accept
);
120 #if WXWIN_COMPATIBILITY
121 // Set/get scroll attributes
122 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
123 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
124 virtual int OldGetScrollRange(int orient
) const;
125 virtual int GetScrollPage(int orient
) const;
128 // Handle a control command
129 virtual void OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
);
131 // Override to define new behaviour for default action (e.g. double
132 // clicking on a listbox)
133 virtual void OnDefaultAction(wxControl
* WXUNUSED(initiatingItem
)) { }
134 #endif // WXWIN_COMPATIBILITY
136 #if wxUSE_CARET && WXWIN_COMPATIBILITY
137 // caret manipulation (old MSW only functions, see wxCaret class for the
139 void CreateCaret(int w
, int h
);
140 void CreateCaret(const wxBitmap
*bitmap
);
142 void ShowCaret(bool show
);
143 void SetCaretPos(int x
, int y
);
144 void GetCaretPos(int *x
, int *y
) const;
145 #endif // wxUSE_CARET
147 // Native resource loading (implemented in src/msw/nativdlg.cpp)
148 // FIXME: should they really be all virtual?
149 wxWindowMac
* GetWindowChild1(wxWindowID id
);
150 wxWindowMac
* GetWindowChild(wxWindowID id
);
152 // implementation from now on
153 // --------------------------
155 void MacClientToRootWindow( int *x
, int *y
) const ;
156 void MacRootWindowToClient( int *x
, int *y
) const ;
157 void MacWindowToRootWindow( int *x
, int *y
) const ;
158 void MacRootWindowToWindow( int *x
, int *y
) const ;
160 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
165 // WXHWND GetHWND() const { return m_hWnd; }
166 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
167 virtual WXWidget
GetHandle() const { return (WXWidget
) NULL
; }
169 bool GetUseCtl3D() const { return m_useCtl3D
; }
170 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
171 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
175 void OnSetFocus(wxFocusEvent
& event
) ;
176 void OnNcPaint(wxNcPaintEvent
& event
);
177 void OnEraseBackground(wxEraseEvent
& event
);
178 void OnIdle(wxIdleEvent
& event
);
179 void MacOnScroll(wxScrollEvent
&event
) ;
181 bool AcceptsFocus() const ;
184 // For implementation purposes - sometimes decorations make the client area
186 virtual wxPoint
GetClientAreaOrigin() const;
188 wxWindowMac
*FindItem(long id
) const;
189 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
191 // Make a Windows extended style from the given wxWindows window style
192 static WXDWORD
MakeExtendedStyle(long style
,
193 bool eliminateBorders
= TRUE
);
194 // Determine whether 3D effects are wanted
195 WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
) const;
197 // MSW only: TRUE if this control is part of the main control
198 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
200 #if WXWIN_COMPATIBILITY
201 wxObject
*GetChild(int number
) const;
202 virtual void MSWDeviceToLogical(float *x
, float *y
) const;
203 #endif // WXWIN_COMPATIBILITY
205 // Setup background and foreground colours correctly
206 virtual void SetupColours();
209 #if WXWIN_COMPATIBILITY
210 void SetShowing(bool show
) { (void)Show(show
); }
211 bool IsUserEnabled() const { return IsEnabled(); }
212 #endif // WXWIN_COMPATIBILITY
215 static bool MacGetWindowFromPoint( const wxPoint
&point
, wxWindowMac
** outWin
) ;
216 virtual void MacRedraw( RgnHandle updatergn
, long time
, bool erase
) ;
217 virtual bool MacCanFocus() const { return true ; }
219 virtual bool MacDispatchMouseEvent(wxMouseEvent
& event
) ;
221 virtual void MacPaintBorders() ;
222 WindowRef
MacGetRootWindow() const ;
223 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
225 virtual ControlHandle
MacGetContainerForEmbedding() ;
227 virtual long MacGetLeftBorderSize() const ;
228 virtual long MacGetRightBorderSize() const ;
229 virtual long MacGetTopBorderSize() const ;
230 virtual long MacGetBottomBorderSize() const ;
232 static long MacRemoveBordersFromStyle( long style
) ;
233 virtual void MacSuperChangedPosition() ;
234 virtual void MacTopLevelWindowChangedPosition() ;
235 virtual void MacSuperShown( bool show
) ;
236 virtual void MacSuperEnabled( bool enable
) ;
237 bool MacIsReallyShown() const ;
238 virtual void Update() ;
240 void MacUpdateImmediately() { Update() ; }
243 bool MacSetupFocusPort() ;
244 bool MacSetupDrawingPort() ;
245 bool MacSetupFocusClientPort() ;
246 bool MacSetupDrawingClientPort() ;
248 virtual bool MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* rootwin
) ;
249 virtual bool MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* rootwin
) ;
251 virtual void MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
) ;
252 virtual void MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
) ;
253 virtual void MacDoGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
) ;
255 bool MacIsWindowScrollbar( const wxScrollBar
* sb
) { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
256 static wxWindowMac
* s_lastMouseWindow
;
258 virtual bool MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
) ;
260 // RgnHandle m_macUpdateRgn ;
261 // bool m_macEraseOnRedraw ;
268 wxScrollBar
* m_hScrollBar
;
269 wxScrollBar
* m_vScrollBar
;
272 void MacCreateScrollBars( long style
) ;
273 void MacRepositionScrollBars() ;
275 // additional (MSW specific) flags
276 bool m_useCtl3D
:1; // Using CTL3D for this control
277 bool m_backgroundTransparent
:1;
278 bool m_mouseInWindow
:1;
279 bool m_doubleClickAllowed
:1;
280 bool m_winCaptured
:1;
282 // the size of one page for scrolling
286 // WXHMENU m_hMenu; // Menu, if any
288 // implement the base class pure virtuals
289 virtual void DoClientToScreen( int *x
, int *y
) const;
290 virtual void DoScreenToClient( int *x
, int *y
) const;
291 virtual void DoGetPosition( int *x
, int *y
) const;
292 virtual void DoGetSize( int *width
, int *height
) const;
293 virtual void DoGetClientSize( int *width
, int *height
) const;
294 virtual void DoSetSize(int x
, int y
,
295 int width
, int height
,
296 int sizeFlags
= wxSIZE_AUTO
);
297 virtual void DoSetClientSize(int width
, int height
);
299 // move the window to the specified location and resize it: this is called
300 // from both DoSetSize() and DoSetClientSize() and would usually just call
301 // ::MoveWindow() except for composite controls which will want to arrange
302 // themselves inside the given rectangle
303 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
306 virtual void DoSetToolTip( wxToolTip
*tip
);
307 #endif // wxUSE_TOOLTIPS
310 // common part of all ctors
313 DECLARE_NO_COPY_CLASS(wxWindowMac
)
314 DECLARE_EVENT_TABLE()
318 class wxMacFocusHelper
321 wxMacFocusHelper( wxWindowMac * theWindow ) ;
322 ~wxMacFocusHelper() ;
323 bool Ok() { return m_ok ; }
326 GrafPtr m_formerPort ;
327 GrafPtr m_currentPort ;
332 class wxMacDrawingHelper
335 wxMacDrawingHelper( wxWindowMac
* theWindow
) ;
336 ~wxMacDrawingHelper() ;
337 bool Ok() { return m_ok
; }
340 GrafPtr m_formerPort
;
341 GrafPtr m_currentPort
;
342 PenState m_savedPenState
;
346 class wxMacFocusClientHelper
349 wxMacFocusClientHelper( wxWindowMac * theWindow ) ;
350 ~wxMacFocusClientHelper() ;
351 bool Ok() { return m_ok ; }
354 GrafPtr m_formerPort ;
355 GrafPtr m_currentPort ;
359 class wxMacDrawingClientHelper
362 wxMacDrawingClientHelper( wxWindowMac
* theWindow
) ;
363 ~wxMacDrawingClientHelper() ;
364 bool Ok() { return m_ok
; }
367 GrafPtr m_formerPort
;
368 GrafPtr m_currentPort
;
369 PenState m_savedPenState
;