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 class WXDLLEXPORT wxWindowMac
: public wxWindowBase
34 DECLARE_DYNAMIC_CLASS(wxWindowMac
)
37 friend class wxPaintDC
;
41 wxWindowMac() { Init(); }
43 wxWindowMac(wxWindowMac
*parent
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
48 const wxString
& name
= wxPanelNameStr
)
51 Create(parent
, id
, pos
, size
, style
, name
);
54 virtual ~wxWindowMac();
56 bool Create(wxWindowMac
*parent
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxString
& name
= wxPanelNameStr
);
64 // implement base class pure virtuals
65 virtual void SetTitle( const wxString
& title
);
66 virtual wxString
GetTitle() const;
71 virtual bool Show( bool show
= TRUE
);
72 virtual bool Enable( bool enable
= TRUE
);
74 virtual void SetFocus();
76 virtual void WarpPointer(int x
, int y
);
78 virtual void Refresh( bool eraseBackground
= TRUE
,
79 const wxRect
*rect
= (const wxRect
*) NULL
);
82 virtual bool SetCursor( const wxCursor
&cursor
);
83 virtual bool SetFont(const wxFont
& font
)
84 { return wxWindowBase::SetFont(font
); }
85 virtual int GetCharHeight() const;
86 virtual int GetCharWidth() const;
87 virtual void GetTextExtent(const wxString
& string
,
89 int *descent
= (int *) NULL
,
90 int *externalLeading
= (int *) NULL
,
91 const wxFont
*theFont
= (const wxFont
*) NULL
)
94 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
96 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
97 int range
, bool refresh
= TRUE
);
98 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
99 virtual int GetScrollPos( int orient
) const;
100 virtual int GetScrollThumb( int orient
) const;
101 virtual int GetScrollRange( int orient
) const;
102 virtual void ScrollWindow( int dx
, int dy
,
103 const wxRect
* rect
= (wxRect
*) NULL
);
105 #if wxUSE_DRAG_AND_DROP
106 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
107 #endif // wxUSE_DRAG_AND_DROP
109 // Accept files for dragging
110 virtual void DragAcceptFiles(bool accept
);
112 #if WXWIN_COMPATIBILITY
113 // Set/get scroll attributes
114 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
115 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
116 virtual int OldGetScrollRange(int orient
) const;
117 virtual int GetScrollPage(int orient
) const;
120 // Handle a control command
121 virtual void OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
);
123 // Override to define new behaviour for default action (e.g. double
124 // clicking on a listbox)
125 virtual void OnDefaultAction(wxControl
* WXUNUSED(initiatingItem
)) { }
126 #endif // WXWIN_COMPATIBILITY
128 #if wxUSE_CARET && WXWIN_COMPATIBILITY
129 // caret manipulation (old MSW only functions, see wxCaret class for the
131 void CreateCaret(int w
, int h
);
132 void CreateCaret(const wxBitmap
*bitmap
);
134 void ShowCaret(bool show
);
135 void SetCaretPos(int x
, int y
);
136 void GetCaretPos(int *x
, int *y
) const;
137 #endif // wxUSE_CARET
139 // Native resource loading (implemented in src/msw/nativdlg.cpp)
140 // FIXME: should they really be all virtual?
141 wxWindowMac
* GetWindowChild1(wxWindowID id
);
142 wxWindowMac
* GetWindowChild(wxWindowID id
);
144 // implementation from now on
145 // --------------------------
147 void MacClientToRootWindow( int *x
, int *y
) const ;
148 void MacRootWindowToClient( int *x
, int *y
) const ;
149 void MacWindowToRootWindow( int *x
, int *y
) const ;
150 void MacRootWindowToWindow( int *x
, int *y
) const ;
152 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
157 // WXHWND GetHWND() const { return m_hWnd; }
158 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
159 virtual WXWidget
GetHandle() const { return (WXWidget
) NULL
; }
161 bool GetUseCtl3D() const { return m_useCtl3D
; }
162 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
163 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
167 void OnSetFocus(wxFocusEvent
& event
) ;
168 void OnNcPaint(wxNcPaintEvent
& event
);
169 void OnEraseBackground(wxEraseEvent
& event
);
170 void OnIdle(wxIdleEvent
& event
);
171 void MacOnScroll(wxScrollEvent
&event
) ;
173 bool AcceptsFocus() const ;
176 // For implementation purposes - sometimes decorations make the client area
178 virtual wxPoint
GetClientAreaOrigin() const;
180 wxWindowMac
*FindItem(long id
) const;
181 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
183 // Make a Windows extended style from the given wxWindows window style
184 static WXDWORD
MakeExtendedStyle(long style
,
185 bool eliminateBorders
= TRUE
);
186 // Determine whether 3D effects are wanted
187 WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
) const;
189 // MSW only: TRUE if this control is part of the main control
190 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
192 #if WXWIN_COMPATIBILITY
193 wxObject
*GetChild(int number
) const;
194 virtual void MSWDeviceToLogical(float *x
, float *y
) const;
195 #endif // WXWIN_COMPATIBILITY
197 // Setup background and foreground colours correctly
198 virtual void SetupColours();
201 #if WXWIN_COMPATIBILITY
202 void SetShowing(bool show
) { (void)Show(show
); }
203 bool IsUserEnabled() const { return IsEnabled(); }
204 #endif // WXWIN_COMPATIBILITY
207 static bool MacGetWindowFromPoint( const wxPoint
&point
, wxWindowMac
** outWin
) ;
208 virtual bool MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
) ;
209 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
210 virtual bool MacCanFocus() const { return true ; }
212 virtual bool MacDispatchMouseEvent(wxMouseEvent
& event
) ;
214 virtual void MacPaintBorders( int left
, int top
) ;
215 WXWindow
MacGetRootWindow() const ;
216 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
218 virtual WXWidget
MacGetContainerForEmbedding() ;
220 virtual long MacGetLeftBorderSize() const ;
221 virtual long MacGetRightBorderSize() const ;
222 virtual long MacGetTopBorderSize() const ;
223 virtual long MacGetBottomBorderSize() const ;
225 static long MacRemoveBordersFromStyle( long style
) ;
226 virtual void MacSuperChangedPosition() ;
227 virtual void MacTopLevelWindowChangedPosition() ;
228 virtual void MacSuperShown( bool show
) ;
229 virtual void MacSuperEnabled( bool enable
) ;
230 bool MacIsReallyShown() const ;
231 virtual void Update() ;
233 void MacUpdateImmediately() { Update() ; }
235 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
236 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
237 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
238 const wxBrush
& MacGetBackgroundBrush() ;
239 const wxRegion
& MacGetVisibleRegion() ;
240 bool MacIsWindowScrollbar( const wxScrollBar
* sb
) { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
241 static wxWindowMac
* s_lastMouseWindow
;
244 // RgnHandle m_macUpdateRgn ;
245 // bool m_macEraseOnRedraw ;
246 wxBrush m_macBackgroundBrush
;
247 wxRegion m_macVisibleRegion
;
253 wxScrollBar
* m_hScrollBar
;
254 wxScrollBar
* m_vScrollBar
;
257 void MacCreateScrollBars( long style
) ;
258 void MacRepositionScrollBars() ;
260 // additional (MSW specific) flags
261 bool m_useCtl3D
:1; // Using CTL3D for this control
262 bool m_backgroundTransparent
:1;
263 bool m_mouseInWindow
:1;
264 bool m_doubleClickAllowed
:1;
265 bool m_winCaptured
:1;
267 // the size of one page for scrolling
271 // WXHMENU m_hMenu; // Menu, if any
273 // implement the base class pure virtuals
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
);
294 virtual void DoSetToolTip( wxToolTip
*tip
);
295 #endif // wxUSE_TOOLTIPS
298 // common part of all ctors
301 DECLARE_NO_COPY_CLASS(wxWindowMac
)
302 DECLARE_EVENT_TABLE()