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
);
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 GetUseCtl3D() const { return m_useCtl3D
; }
169 bool GetTransparentBackground() const { return m_backgroundTransparent
; }
170 void SetTransparent(bool t
= TRUE
) { m_backgroundTransparent
= t
; }
174 void OnSetFocus(wxFocusEvent
& event
) ;
175 void OnNcPaint(wxNcPaintEvent
& event
);
176 void OnEraseBackground(wxEraseEvent
& event
);
177 void OnIdle(wxIdleEvent
& event
);
178 void MacOnScroll(wxScrollEvent
&event
) ;
180 bool AcceptsFocus() const ;
183 // For implementation purposes - sometimes decorations make the client area
185 virtual wxPoint
GetClientAreaOrigin() const;
187 wxWindowMac
*FindItem(long id
) const;
188 wxWindowMac
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
190 // Make a Windows extended style from the given wxWindows window style
191 static WXDWORD
MakeExtendedStyle(long style
,
192 bool eliminateBorders
= TRUE
);
193 // Determine whether 3D effects are wanted
194 WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
) const;
196 // MSW only: TRUE if this control is part of the main control
197 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
199 #if WXWIN_COMPATIBILITY
200 wxObject
*GetChild(int number
) const;
201 virtual void MSWDeviceToLogical(float *x
, float *y
) const;
202 #endif // WXWIN_COMPATIBILITY
204 // Setup background and foreground colours correctly
205 virtual void SetupColours();
208 #if WXWIN_COMPATIBILITY
209 void SetShowing(bool show
) { (void)Show(show
); }
210 bool IsUserEnabled() const { return IsEnabled(); }
211 #endif // WXWIN_COMPATIBILITY
214 static bool MacGetWindowFromPoint( const wxPoint
&point
, wxWindowMac
** outWin
) ;
215 virtual bool MacGetWindowFromPointSub( const wxPoint
&point
, wxWindowMac
** outWin
) ;
216 virtual void MacRedraw( WXHRGN updatergn
, long time
, bool erase
) ;
217 virtual bool MacCanFocus() const { return true ; }
219 virtual bool MacDispatchMouseEvent(wxMouseEvent
& event
) ;
221 virtual void MacPaintBorders( int left
, int top
) ;
222 WXWindow
MacGetRootWindow() const ;
223 wxTopLevelWindowMac
* MacGetTopLevelWindow() const ;
225 virtual WXWidget
MacGetContainerForEmbedding() ;
227 virtual long MacGetLeftBorderSize() const ;
228 virtual long MacGetRightBorderSize() const ;
229 virtual long MacGetTopBorderSize() const ;
230 virtual long MacGetBottomBorderSize() const ;
232 static long MacRemoveBordersFromStyle( long style
) ;
233 virtual void MacSuperChangedPosition() ;
234 virtual void MacTopLevelWindowChangedPosition() ;
235 virtual void MacSuperShown( bool show
) ;
236 virtual void MacSuperEnabled( bool enable
) ;
237 bool MacIsReallyShown() const ;
238 virtual void Update() ;
240 void MacUpdateImmediately() { Update() ; }
242 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
243 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
244 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
245 const wxBrush
& MacGetBackgroundBrush() ;
246 const wxRegion
& MacGetVisibleRegion() ;
247 bool MacIsWindowScrollbar( const wxScrollBar
* sb
) { return (m_hScrollBar
== sb
|| m_vScrollBar
== sb
) ; }
248 static wxWindowMac
* s_lastMouseWindow
;
251 // RgnHandle m_macUpdateRgn ;
252 // bool m_macEraseOnRedraw ;
253 wxBrush m_macBackgroundBrush
;
254 wxRegion m_macVisibleRegion
;
260 wxScrollBar
* m_hScrollBar
;
261 wxScrollBar
* m_vScrollBar
;
264 void MacCreateScrollBars( long style
) ;
265 void MacRepositionScrollBars() ;
267 // additional (MSW specific) flags
268 bool m_useCtl3D
:1; // Using CTL3D for this control
269 bool m_backgroundTransparent
:1;
270 bool m_mouseInWindow
:1;
271 bool m_doubleClickAllowed
:1;
272 bool m_winCaptured
:1;
274 // the size of one page for scrolling
278 // WXHMENU m_hMenu; // Menu, if any
280 // implement the base class pure virtuals
281 virtual void DoClientToScreen( int *x
, int *y
) const;
282 virtual void DoScreenToClient( int *x
, int *y
) const;
283 virtual void DoGetPosition( int *x
, int *y
) const;
284 virtual void DoGetSize( int *width
, int *height
) const;
285 virtual void DoGetClientSize( int *width
, int *height
) const;
286 virtual void DoSetSize(int x
, int y
,
287 int width
, int height
,
288 int sizeFlags
= wxSIZE_AUTO
);
289 virtual void DoSetClientSize(int width
, int height
);
291 virtual void DoCaptureMouse();
292 virtual void DoReleaseMouse();
294 // move the window to the specified location and resize it: this is called
295 // from both DoSetSize() and DoSetClientSize() and would usually just call
296 // ::MoveWindow() except for composite controls which will want to arrange
297 // themselves inside the given rectangle
298 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
301 virtual void DoSetToolTip( wxToolTip
*tip
);
302 #endif // wxUSE_TOOLTIPS
305 // common part of all ctors
308 DECLARE_NO_COPY_CLASS(wxWindowMac
)
309 DECLARE_EVENT_TABLE()