1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/window.h
3 // Purpose: wxWindowMac class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 // ---------------------------------------------------------------------------
18 // forward declarations
19 // ---------------------------------------------------------------------------
21 class WXDLLEXPORT wxButton
;
22 class WXDLLEXPORT wxScrollBar
;
23 class WXDLLEXPORT wxTopLevelWindowMac
;
25 // ---------------------------------------------------------------------------
27 // ---------------------------------------------------------------------------
29 class WXDLLEXPORT wxWindowMac
: public wxWindowBase
31 DECLARE_DYNAMIC_CLASS(wxWindowMac
)
34 friend class wxPaintDC
;
39 : m_macBackgroundBrush()
40 , m_macVisibleRegion()
41 , m_x(0), m_y(0), m_width(0), m_height(0)
42 , m_hScrollBar(NULL
), m_vScrollBar(NULL
)
43 , m_label(wxEmptyString
)
46 wxWindowMac(wxWindowMac
*parent
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
51 const wxString
& name
= wxPanelNameStr
)
54 Create(parent
, id
, pos
, size
, style
, name
);
57 virtual ~wxWindowMac();
59 bool Create(wxWindowMac
*parent
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
64 const wxString
& name
= wxPanelNameStr
);
67 // implement base class pure virtuals
68 virtual void SetLabel( const wxString
& title
);
69 virtual wxString
GetLabel() const;
74 virtual bool Show( bool show
= true );
75 virtual bool Enable( bool enable
= true );
77 virtual void SetFocus();
79 virtual void WarpPointer(int x
, int y
);
81 virtual void Refresh( bool eraseBackground
= true,
82 const wxRect
*rect
= (const wxRect
*) NULL
);
84 virtual bool SetCursor( const wxCursor
&cursor
);
85 virtual bool SetFont(const wxFont
& font
)
86 { return wxWindowBase::SetFont(font
); }
87 virtual int GetCharHeight() const;
88 virtual int GetCharWidth() const;
89 virtual void GetTextExtent(const wxString
& string
,
91 int *descent
= (int *) NULL
,
92 int *externalLeading
= (int *) NULL
,
93 const wxFont
*theFont
= (const wxFont
*) NULL
)
96 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
98 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
99 int range
, bool refresh
= true );
100 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true );
101 virtual int GetScrollPos( int orient
) const;
102 virtual int GetScrollThumb( int orient
) const;
103 virtual int GetScrollRange( int orient
) const;
104 virtual void ScrollWindow( int dx
, int dy
,
105 const wxRect
* rect
= (wxRect
*) NULL
);
107 #if wxUSE_DRAG_AND_DROP
108 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
109 #endif // wxUSE_DRAG_AND_DROP
111 // Accept files for dragging
112 virtual void DragAcceptFiles(bool accept
);
114 // Native resource loading (implemented in src/msw/nativdlg.cpp)
115 // FIXME: should they really be all virtual?
116 wxWindowMac
* GetWindowChild1(wxWindowID id
);
117 wxWindowMac
* GetWindowChild(wxWindowID id
);
119 // implementation from now on
120 // --------------------------
122 void MacClientToRootWindow( int *x
, int *y
) const ;
123 void MacRootWindowToClient( int *x
, int *y
) const ;
124 void MacWindowToRootWindow( int *x
, int *y
) const ;
125 void MacRootWindowToWindow( int *x
, int *y
) const ;
127 virtual wxString
MacGetToolTipString( wxPoint
&where
) ;
132 // WXHWND GetHWND() const { return m_hWnd; }
133 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
134 virtual WXWidget
GetHandle() const { return (WXWidget
) NULL
; }
136 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
137 void SetTransparent(bool t
= true) { m_backgroundTransparent
= t
; }
141 void OnSetFocus(wxFocusEvent
& event
) ;
142 void OnNcPaint(wxNcPaintEvent
& event
);
143 void OnEraseBackground(wxEraseEvent
& event
);
144 void OnMouseEvent( wxMouseEvent
&event
) ;
146 void MacOnScroll(wxScrollEvent
&event
) ;
148 bool AcceptsFocus() const ;
151 void OnInternalIdle();
153 // For implementation purposes - sometimes decorations make the client area
155 virtual wxPoint
GetClientAreaOrigin() const;
157 wxWindowMac
*FindItem(long id
) const;
158 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= false) const;
160 // Make a Windows extended style from the given wxWidgets window style
161 static WXDWORD
MakeExtendedStyle(long style
,
162 bool eliminateBorders
= true);
163 // Determine whether 3D effects are wanted
164 WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
) const;
166 // MSW only: true if this control is part of the main control
167 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return false; };
169 // Setup background and foreground colours correctly
170 virtual void SetupColours();
173 static bool MacGetWindowFromPoint( const wxPoint
&point
, wxWindowMac
** outWin
) ;
174 virtual bool MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
) ;
175 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
176 virtual bool MacCanFocus() const { return true ; }
178 virtual bool MacDispatchMouseEvent(wxMouseEvent
& event
) ;
179 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
180 virtual void RemoveChild( wxWindowBase
*child
);
181 virtual void MacPaintBorders( int left
, int top
) ;
182 WXWindow
MacGetRootWindow() const ;
183 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
185 virtual WXWidget
MacGetContainerForEmbedding() ;
187 virtual long MacGetLeftBorderSize() const ;
188 virtual long MacGetRightBorderSize() const ;
189 virtual long MacGetTopBorderSize() const ;
190 virtual long MacGetBottomBorderSize() const ;
192 static long MacRemoveBordersFromStyle( long style
) ;
193 virtual void MacSuperChangedPosition() ;
194 // the absolute coordinates of this item within the toplevel window may have changed
195 virtual void MacUpdateDimensions() {}
196 // the absolute coortinates of this window's root have changed
197 virtual void MacTopLevelWindowChangedPosition() ;
198 virtual void MacSuperShown( bool show
) ;
199 virtual void MacSuperEnabled( bool enable
) ;
200 bool MacIsReallyShown() const ;
201 virtual void Update() ;
203 void MacUpdateImmediately() { Update() ; }
204 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
206 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
207 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
208 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
209 const wxBrush
& MacGetBackgroundBrush() ;
210 const wxRegion
& MacGetVisibleRegion( bool respectChildrenAndSiblings
= true ) ;
211 bool MacIsWindowScrollbar( const wxScrollBar
* sb
)
212 { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
213 static wxWindowMac
* s_lastMouseWindow
;
216 wxBrush m_macBackgroundBrush
;
217 wxRegion m_macVisibleRegion
;
223 wxScrollBar
* m_hScrollBar
;
224 wxScrollBar
* m_vScrollBar
;
227 void MacCreateScrollBars( long style
) ;
228 void MacRepositionScrollBars() ;
230 bool m_backgroundTransparent
;
232 // implement the base class pure virtuals
233 virtual void DoClientToScreen( int *x
, int *y
) const;
234 virtual void DoScreenToClient( int *x
, int *y
) const;
235 virtual void DoGetPosition( int *x
, int *y
) const;
236 virtual void DoGetSize( int *width
, int *height
) const;
237 virtual void DoGetClientSize( int *width
, int *height
) const;
238 virtual void DoSetSize(int x
, int y
,
239 int width
, int height
,
240 int sizeFlags
= wxSIZE_AUTO
);
241 virtual void DoSetClientSize(int width
, int height
);
243 virtual void DoCaptureMouse();
244 virtual void DoReleaseMouse();
246 // move the window to the specified location and resize it: this is called
247 // from both DoSetSize() and DoSetClientSize() and would usually just call
248 // ::MoveWindow() except for composite controls which will want to arrange
249 // themselves inside the given rectangle
250 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
253 virtual void DoSetToolTip( wxToolTip
*tip
);
254 #endif // wxUSE_TOOLTIPS
257 // common part of all ctors
260 DECLARE_NO_COPY_CLASS(wxWindowMac
)
261 DECLARE_EVENT_TABLE()