1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "window.h"
20 // ---------------------------------------------------------------------------
21 // forward declarations
22 // ---------------------------------------------------------------------------
24 class WXDLLEXPORT wxButton
;
25 class WXDLLEXPORT wxScrollBar
;
26 class WXDLLEXPORT wxTopLevelWindowMac
;
28 // ---------------------------------------------------------------------------
30 // ---------------------------------------------------------------------------
32 // FIXME does anybody use those? they're unused by wxWindows...
39 class WXDLLEXPORT wxWindowMac
: public wxWindowBase
41 DECLARE_DYNAMIC_CLASS(wxWindowMac
);
44 friend class wxPaintDC
;
48 wxWindowMac() { Init(); }
50 wxWindowMac(wxWindowMac
*parent
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
,
55 const wxString
& name
= wxPanelNameStr
)
58 Create(parent
, id
, pos
, size
, style
, name
);
61 virtual ~wxWindowMac();
63 bool Create(wxWindowMac
*parent
,
65 const wxPoint
& pos
= wxDefaultPosition
,
66 const wxSize
& size
= wxDefaultSize
,
68 const wxString
& name
= wxPanelNameStr
);
71 // implement base class pure virtuals
72 virtual void SetTitle( const wxString
& title
);
73 virtual wxString
GetTitle() const;
78 virtual bool Show( bool show
= TRUE
);
79 virtual bool Enable( bool enable
= TRUE
);
81 virtual void SetFocus();
83 virtual void WarpPointer(int x
, int y
);
84 virtual void CaptureMouse();
85 virtual void ReleaseMouse();
87 virtual void Refresh( bool eraseBackground
= TRUE
,
88 const wxRect
*rect
= (const wxRect
*) NULL
);
91 virtual bool SetCursor( const wxCursor
&cursor
);
92 virtual bool SetFont(const wxFont
& font
)
93 { return wxWindowBase::SetFont(font
); }
94 virtual int GetCharHeight() const;
95 virtual int GetCharWidth() const;
96 virtual void GetTextExtent(const wxString
& string
,
98 int *descent
= (int *) NULL
,
99 int *externalLeading
= (int *) NULL
,
100 const wxFont
*theFont
= (const wxFont
*) NULL
)
103 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
105 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
106 int range
, bool refresh
= TRUE
);
107 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
108 virtual int GetScrollPos( int orient
) const;
109 virtual int GetScrollThumb( int orient
) const;
110 virtual int GetScrollRange( int orient
) const;
111 virtual void ScrollWindow( int dx
, int dy
,
112 const wxRect
* rect
= (wxRect
*) NULL
);
114 #if wxUSE_DRAG_AND_DROP
115 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
116 #endif // wxUSE_DRAG_AND_DROP
118 // Accept files for dragging
119 virtual void DragAcceptFiles(bool accept
);
121 #if WXWIN_COMPATIBILITY
122 // Set/get scroll attributes
123 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
124 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
125 virtual int OldGetScrollRange(int orient
) const;
126 virtual int GetScrollPage(int orient
) const;
129 // Handle a control command
130 virtual void OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
);
132 // Override to define new behaviour for default action (e.g. double
133 // clicking on a listbox)
134 virtual void OnDefaultAction(wxControl
* WXUNUSED(initiatingItem
)) { }
135 #endif // WXWIN_COMPATIBILITY
137 #if wxUSE_CARET && WXWIN_COMPATIBILITY
138 // caret manipulation (old MSW only functions, see wxCaret class for the
140 void CreateCaret(int w
, int h
);
141 void CreateCaret(const wxBitmap
*bitmap
);
143 void ShowCaret(bool show
);
144 void SetCaretPos(int x
, int y
);
145 void GetCaretPos(int *x
, int *y
) const;
146 #endif // wxUSE_CARET
148 // Native resource loading (implemented in src/msw/nativdlg.cpp)
149 // FIXME: should they really be all virtual?
150 wxWindowMac
* GetWindowChild1(wxWindowID id
);
151 wxWindowMac
* GetWindowChild(wxWindowID id
);
153 // implementation from now on
154 // --------------------------
156 void MacClientToRootWindow( int *x
, int *y
) const ;
157 void MacRootWindowToClient( int *x
, int *y
) const ;
158 void MacWindowToRootWindow( int *x
, int *y
) const ;
159 void MacRootWindowToWindow( int *x
, int *y
) const ;
161 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
166 // WXHWND GetHWND() const { return m_hWnd; }
167 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
168 virtual WXWidget
GetHandle() const { return (WXWidget
) NULL
; }
170 bool GetUseCtl3D() const { return m_useCtl3D
; }
171 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
172 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
176 void OnSetFocus(wxFocusEvent
& event
) ;
177 void OnNcPaint(wxNcPaintEvent
& event
);
178 void OnEraseBackground(wxEraseEvent
& event
);
179 void OnIdle(wxIdleEvent
& event
);
180 void MacOnScroll(wxScrollEvent
&event
) ;
182 bool AcceptsFocus() const ;
185 // For implementation purposes - sometimes decorations make the client area
187 virtual wxPoint
GetClientAreaOrigin() const;
189 wxWindowMac
*FindItem(long id
) const;
190 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
192 // Make a Windows extended style from the given wxWindows window style
193 static WXDWORD
MakeExtendedStyle(long style
,
194 bool eliminateBorders
= TRUE
);
195 // Determine whether 3D effects are wanted
196 WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
) const;
198 // MSW only: TRUE if this control is part of the main control
199 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
201 #if WXWIN_COMPATIBILITY
202 wxObject
*GetChild(int number
) const;
203 virtual void MSWDeviceToLogical(float *x
, float *y
) const;
204 #endif // WXWIN_COMPATIBILITY
206 // Setup background and foreground colours correctly
207 virtual void SetupColours();
210 #if WXWIN_COMPATIBILITY
211 void SetShowing(bool show
) { (void)Show(show
); }
212 bool IsUserEnabled() const { return IsEnabled(); }
213 #endif // WXWIN_COMPATIBILITY
216 static bool MacGetWindowFromPoint( const wxPoint
&point
, wxWindowMac
** outWin
) ;
217 virtual void MacRedraw( RgnHandle updatergn
, long time
, bool erase
) ;
218 virtual bool MacCanFocus() const { return true ; }
220 virtual bool MacDispatchMouseEvent(wxMouseEvent
& event
) ;
222 virtual void MacPaintBorders() ;
223 WindowRef
MacGetRootWindow() const ;
224 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
226 virtual ControlHandle
MacGetContainerForEmbedding() ;
228 virtual long MacGetLeftBorderSize() const ;
229 virtual long MacGetRightBorderSize() const ;
230 virtual long MacGetTopBorderSize() const ;
231 virtual long MacGetBottomBorderSize() const ;
233 static long MacRemoveBordersFromStyle( long style
) ;
234 virtual void MacSuperChangedPosition() ;
235 virtual void MacTopLevelWindowChangedPosition() ;
236 virtual void MacSuperShown( bool show
) ;
237 virtual void MacSuperEnabled( bool enable
) ;
238 bool MacIsReallyShown() const ;
239 virtual void Update() ;
241 void MacUpdateImmediately() { Update() ; }
244 bool MacSetupFocusPort() ;
245 bool MacSetupDrawingPort() ;
246 bool MacSetupFocusClientPort() ;
247 bool MacSetupDrawingClientPort() ;
249 virtual bool MacSetPortFocusParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* rootwin
) ;
250 virtual bool MacSetPortDrawingParams( const Point
& localOrigin
, const Rect
& clipRect
, WindowRef window
, wxWindowMac
* rootwin
) ;
252 virtual void MacGetPortParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
) ;
253 virtual void MacGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
) ;
254 virtual void MacDoGetPortClientParams(Point
* localOrigin
, Rect
* clipRect
, WindowRef
*window
, wxWindowMac
** rootwin
) ;
255 const wxBrush
& MacGetBackgroundBrush() ;
256 const wxRegion
& MacGetVisibleRegion() ;
257 bool MacIsWindowScrollbar( const wxScrollBar
* sb
) { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
258 static wxWindowMac
* s_lastMouseWindow
;
260 virtual bool MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
) ;
262 // RgnHandle m_macUpdateRgn ;
263 // bool m_macEraseOnRedraw ;
264 wxBrush m_macBackgroundBrush
;
265 wxRegion m_macVisibleRegion
;
271 wxScrollBar
* m_hScrollBar
;
272 wxScrollBar
* m_vScrollBar
;
275 void MacCreateScrollBars( long style
) ;
276 void MacRepositionScrollBars() ;
278 // additional (MSW specific) flags
279 bool m_useCtl3D
:1; // Using CTL3D for this control
280 bool m_backgroundTransparent
:1;
281 bool m_mouseInWindow
:1;
282 bool m_doubleClickAllowed
:1;
283 bool m_winCaptured
:1;
285 // the size of one page for scrolling
289 // WXHMENU m_hMenu; // Menu, if any
291 // implement the base class pure virtuals
292 virtual void DoClientToScreen( int *x
, int *y
) const;
293 virtual void DoScreenToClient( int *x
, int *y
) const;
294 virtual void DoGetPosition( int *x
, int *y
) const;
295 virtual void DoGetSize( int *width
, int *height
) const;
296 virtual void DoGetClientSize( int *width
, int *height
) const;
297 virtual void DoSetSize(int x
, int y
,
298 int width
, int height
,
299 int sizeFlags
= wxSIZE_AUTO
);
300 virtual void DoSetClientSize(int width
, int height
);
302 // move the window to the specified location and resize it: this is called
303 // from both DoSetSize() and DoSetClientSize() and would usually just call
304 // ::MoveWindow() except for composite controls which will want to arrange
305 // themselves inside the given rectangle
306 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
309 virtual void DoSetToolTip( wxToolTip
*tip
);
310 #endif // wxUSE_TOOLTIPS
313 // common part of all ctors
316 DECLARE_NO_COPY_CLASS(wxWindowMac
)
317 DECLARE_EVENT_TABLE()
321 class wxMacFocusHelper
324 wxMacFocusHelper( wxWindowMac * theWindow ) ;
325 ~wxMacFocusHelper() ;
326 bool Ok() { return m_ok ; }
329 GrafPtr m_formerPort ;
330 GrafPtr m_currentPort ;
335 class wxMacDrawingHelper
338 wxMacDrawingHelper( wxWindowMac
* theWindow
) ;
339 ~wxMacDrawingHelper() ;
340 bool Ok() { return m_ok
; }
343 GrafPtr m_formerPort
;
344 GrafPtr m_currentPort
;
345 PenState m_savedPenState
;
349 class wxMacFocusClientHelper
352 wxMacFocusClientHelper( wxWindowMac * theWindow ) ;
353 ~wxMacFocusClientHelper() ;
354 bool Ok() { return m_ok ; }
357 GrafPtr m_formerPort ;
358 GrafPtr m_currentPort ;
362 class wxMacDrawingClientHelper
365 wxMacDrawingClientHelper( wxWindowMac
* theWindow
) ;
366 ~wxMacDrawingClientHelper() ;
367 bool Ok() { return m_ok
; }
370 GrafPtr m_formerPort
;
371 GrafPtr m_currentPort
;
372 PenState m_savedPenState
;