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 bool MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
) ;
218 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
219 virtual bool MacCanFocus() const { return true ; }
221 virtual bool MacDispatchMouseEvent(wxMouseEvent
& event
) ;
223 virtual void MacPaintBorders( int left
, int top
) ;
224 WXWindow
MacGetRootWindow() const ;
225 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
227 virtual WXWidget
MacGetContainerForEmbedding() ;
229 virtual long MacGetLeftBorderSize() const ;
230 virtual long MacGetRightBorderSize() const ;
231 virtual long MacGetTopBorderSize() const ;
232 virtual long MacGetBottomBorderSize() const ;
234 static long MacRemoveBordersFromStyle( long style
) ;
235 virtual void MacSuperChangedPosition() ;
236 virtual void MacTopLevelWindowChangedPosition() ;
237 virtual void MacSuperShown( bool show
) ;
238 virtual void MacSuperEnabled( bool enable
) ;
239 bool MacIsReallyShown() const ;
240 virtual void Update() ;
242 void MacUpdateImmediately() { Update() ; }
244 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
245 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
246 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
247 const wxBrush
& MacGetBackgroundBrush() ;
248 const wxRegion
& MacGetVisibleRegion() ;
249 bool MacIsWindowScrollbar( const wxScrollBar
* sb
) { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
250 static wxWindowMac
* s_lastMouseWindow
;
253 // RgnHandle m_macUpdateRgn ;
254 // bool m_macEraseOnRedraw ;
255 wxBrush m_macBackgroundBrush
;
256 wxRegion m_macVisibleRegion
;
262 wxScrollBar
* m_hScrollBar
;
263 wxScrollBar
* m_vScrollBar
;
266 void MacCreateScrollBars( long style
) ;
267 void MacRepositionScrollBars() ;
269 // additional (MSW specific) flags
270 bool m_useCtl3D
:1; // Using CTL3D for this control
271 bool m_backgroundTransparent
:1;
272 bool m_mouseInWindow
:1;
273 bool m_doubleClickAllowed
:1;
274 bool m_winCaptured
:1;
276 // the size of one page for scrolling
280 // WXHMENU m_hMenu; // Menu, if any
282 // implement the base class pure virtuals
283 virtual void DoClientToScreen( int *x
, int *y
) const;
284 virtual void DoScreenToClient( int *x
, int *y
) const;
285 virtual void DoGetPosition( int *x
, int *y
) const;
286 virtual void DoGetSize( int *width
, int *height
) const;
287 virtual void DoGetClientSize( int *width
, int *height
) const;
288 virtual void DoSetSize(int x
, int y
,
289 int width
, int height
,
290 int sizeFlags
= wxSIZE_AUTO
);
291 virtual void DoSetClientSize(int width
, int height
);
293 // move the window to the specified location and resize it: this is called
294 // from both DoSetSize() and DoSetClientSize() and would usually just call
295 // ::MoveWindow() except for composite controls which will want to arrange
296 // themselves inside the given rectangle
297 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
300 virtual void DoSetToolTip( wxToolTip
*tip
);
301 #endif // wxUSE_TOOLTIPS
304 // common part of all ctors
307 DECLARE_NO_COPY_CLASS(wxWindowMac
)
308 DECLARE_EVENT_TABLE()