1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(__APPLE__)
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
;
43 : m_macBackgroundBrush()
44 , m_macVisibleRegion()
45 , m_x(0), m_y(0), m_width(0), m_height(0)
46 , m_hScrollBar(NULL
), m_vScrollBar(NULL
)
47 , m_label(wxEmptyString
)
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
);
85 virtual void Refresh( bool eraseBackground
= TRUE
,
86 const wxRect
*rect
= (const wxRect
*) NULL
);
89 virtual bool SetCursor( const wxCursor
&cursor
);
90 virtual bool SetFont(const wxFont
& font
)
91 { return wxWindowBase::SetFont(font
); }
92 virtual int GetCharHeight() const;
93 virtual int GetCharWidth() const;
94 virtual void GetTextExtent(const wxString
& string
,
96 int *descent
= (int *) NULL
,
97 int *externalLeading
= (int *) NULL
,
98 const wxFont
*theFont
= (const wxFont
*) NULL
)
101 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
103 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
104 int range
, bool refresh
= TRUE
);
105 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
106 virtual int GetScrollPos( int orient
) const;
107 virtual int GetScrollThumb( int orient
) const;
108 virtual int GetScrollRange( int orient
) const;
109 virtual void ScrollWindow( int dx
, int dy
,
110 const wxRect
* rect
= (wxRect
*) NULL
);
112 #if wxUSE_DRAG_AND_DROP
113 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
114 #endif // wxUSE_DRAG_AND_DROP
116 // Accept files for dragging
117 virtual void DragAcceptFiles(bool accept
);
119 #if WXWIN_COMPATIBILITY
120 // Set/get scroll attributes
121 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
122 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
123 virtual int OldGetScrollRange(int orient
) const;
124 virtual int GetScrollPage(int orient
) const;
127 // Handle a control command
128 virtual void OnCommand(wxWindowMac
& win
, wxCommandEvent
& event
);
130 // Override to define new behaviour for default action (e.g. double
131 // clicking on a listbox)
132 virtual void OnDefaultAction(wxControl
* WXUNUSED(initiatingItem
)) { }
133 #endif // WXWIN_COMPATIBILITY
135 #if wxUSE_CARET && WXWIN_COMPATIBILITY
136 // caret manipulation (old MSW only functions, see wxCaret class for the
138 void CreateCaret(int w
, int h
);
139 void CreateCaret(const wxBitmap
*bitmap
);
141 void ShowCaret(bool show
);
142 void SetCaretPos(int x
, int y
);
143 void GetCaretPos(int *x
, int *y
) const;
144 #endif // wxUSE_CARET
146 // Native resource loading (implemented in src/msw/nativdlg.cpp)
147 // FIXME: should they really be all virtual?
148 wxWindowMac
* GetWindowChild1(wxWindowID id
);
149 wxWindowMac
* GetWindowChild(wxWindowID id
);
151 // implementation from now on
152 // --------------------------
154 void MacClientToRootWindow( int *x
, int *y
) const ;
155 void MacRootWindowToClient( int *x
, int *y
) const ;
156 void MacWindowToRootWindow( int *x
, int *y
) const ;
157 void MacRootWindowToWindow( int *x
, int *y
) const ;
159 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
164 // WXHWND GetHWND() const { return m_hWnd; }
165 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
166 virtual WXWidget
GetHandle() const { return (WXWidget
) NULL
; }
168 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
169 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
173 void OnSetFocus(wxFocusEvent
& event
) ;
174 void OnNcPaint(wxNcPaintEvent
& event
);
175 void OnEraseBackground(wxEraseEvent
& event
);
176 void OnMouseEvent( wxMouseEvent
&event
) ;
178 void MacOnScroll(wxScrollEvent
&event
) ;
180 bool AcceptsFocus() const ;
183 void OnInternalIdle();
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
) ;
222 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
223 virtual void RemoveChild( wxWindowBase
*child
);
224 virtual void MacPaintBorders( int left
, int top
) ;
225 WXWindow
MacGetRootWindow() const ;
226 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
228 virtual WXWidget
MacGetContainerForEmbedding() ;
230 virtual long MacGetLeftBorderSize() const ;
231 virtual long MacGetRightBorderSize() const ;
232 virtual long MacGetTopBorderSize() const ;
233 virtual long MacGetBottomBorderSize() const ;
235 static long MacRemoveBordersFromStyle( long style
) ;
236 virtual void MacSuperChangedPosition() ;
237 // the absolute coordinates of this item within the toplevel window may have changed
238 virtual void MacUpdateDimensions() {}
239 // the absolute coortinates of this window's root have changed
240 virtual void MacTopLevelWindowChangedPosition() ;
241 virtual void MacSuperShown( bool show
) ;
242 virtual void MacSuperEnabled( bool enable
) ;
243 bool MacIsReallyShown() const ;
244 virtual void Update() ;
246 void MacUpdateImmediately() { Update() ; }
247 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
249 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
250 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
251 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
252 const wxBrush
& MacGetBackgroundBrush() ;
253 const wxRegion
& MacGetVisibleRegion( bool respectChildrenAndSiblings
= true ) ;
254 bool MacIsWindowScrollbar( const wxScrollBar
* sb
)
255 { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
256 static wxWindowMac
* s_lastMouseWindow
;
259 wxBrush m_macBackgroundBrush
;
260 wxRegion m_macVisibleRegion
;
266 wxScrollBar
* m_hScrollBar
;
267 wxScrollBar
* m_vScrollBar
;
270 void MacCreateScrollBars( long style
) ;
271 void MacRepositionScrollBars() ;
273 bool m_backgroundTransparent
;
275 // implement the base class pure virtuals
276 virtual void DoClientToScreen( int *x
, int *y
) const;
277 virtual void DoScreenToClient( int *x
, int *y
) const;
278 virtual void DoGetPosition( int *x
, int *y
) const;
279 virtual void DoGetSize( int *width
, int *height
) const;
280 virtual void DoGetClientSize( int *width
, int *height
) const;
281 virtual void DoSetSize(int x
, int y
,
282 int width
, int height
,
283 int sizeFlags
= wxSIZE_AUTO
);
284 virtual void DoSetClientSize(int width
, int height
);
286 virtual void DoCaptureMouse();
287 virtual void DoReleaseMouse();
289 // move the window to the specified location and resize it: this is called
290 // from both DoSetSize() and DoSetClientSize() and would usually just call
291 // ::MoveWindow() except for composite controls which will want to arrange
292 // themselves inside the given rectangle
293 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
296 virtual void DoSetToolTip( wxToolTip
*tip
);
297 #endif // wxUSE_TOOLTIPS
300 // common part of all ctors
303 DECLARE_NO_COPY_CLASS(wxWindowMac
)
304 DECLARE_EVENT_TABLE()