]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/window.h
wxMultiChoiceDialog uses now wxCheckListBox if possible, wxListBox if not
[wxWidgets.git] / include / wx / mac / carbon / window.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose: wxWindowMac class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WINDOW_H_
13#define _WX_WINDOW_H_
14
8cf73271 15#include "wx/brush.h"
20b69855 16#include "wx/dc.h"
8cf73271
SC
17
18// ---------------------------------------------------------------------------
19// forward declarations
20// ---------------------------------------------------------------------------
21
22class WXDLLEXPORT wxButton;
23class WXDLLEXPORT wxScrollBar;
24class WXDLLEXPORT wxTopLevelWindowMac;
25
6d4c54a7
SC
26// internal implementation classes
27
28class wxMacControl ;
29
8cf73271
SC
30// ---------------------------------------------------------------------------
31// constants
32// ---------------------------------------------------------------------------
33
34class WXDLLEXPORT wxWindowMac: public wxWindowBase
35{
36 DECLARE_DYNAMIC_CLASS(wxWindowMac)
37
38 friend class wxDC;
39 friend class wxPaintDC;
40
41public:
42
997e843d 43 wxWindowMac() ;
8cf73271
SC
44
45 wxWindowMac(wxWindowMac *parent,
46 wxWindowID id,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = 0,
997e843d 50 const wxString& name = wxPanelNameStr) ;
8cf73271
SC
51
52 virtual ~wxWindowMac();
53
54 bool Create(wxWindowMac *parent,
55 wxWindowID id,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 long style = 0,
59 const wxString& name = wxPanelNameStr);
60
61
62 // implement base class pure virtuals
63 virtual void SetTitle( const wxString& title);
64 virtual wxString GetTitle() const;
65
66 virtual void Raise();
67 virtual void Lower();
68
69 virtual bool Show( bool show = TRUE );
70 virtual bool Enable( bool enable = TRUE );
71
72 virtual void SetFocus();
73
74 virtual void WarpPointer(int x, int y);
75
76 virtual void Refresh( bool eraseBackground = TRUE,
77 const wxRect *rect = (const wxRect *) NULL );
79392158
SC
78 virtual void Freeze() ;
79 virtual void Thaw() ;
8cf73271 80
cb4b0966
SC
81 virtual void Update() ;
82 virtual void ClearBackground() ;
83
8cf73271 84 virtual bool SetCursor( const wxCursor &cursor );
4f305456
SC
85 virtual bool SetFont( const wxFont &font ) ;
86 virtual bool SetBackgroundColour( const wxColour &colour );
87 virtual bool SetForegroundColour( const wxColour &colour );
88
8cf73271
SC
89 virtual int GetCharHeight() const;
90 virtual int GetCharWidth() const;
91 virtual void GetTextExtent(const wxString& string,
92 int *x, int *y,
93 int *descent = (int *) NULL,
94 int *externalLeading = (int *) NULL,
95 const wxFont *theFont = (const wxFont *) NULL)
96 const;
97
98 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
99
100 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
101 int range, bool refresh = TRUE );
102 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
103 virtual int GetScrollPos( int orient ) const;
104 virtual int GetScrollThumb( int orient ) const;
105 virtual int GetScrollRange( int orient ) const;
106 virtual void ScrollWindow( int dx, int dy,
107 const wxRect* rect = (wxRect *) NULL );
50779e06 108 virtual bool Reparent( wxWindowBase *newParent );
8cf73271
SC
109
110#if wxUSE_DRAG_AND_DROP
111 virtual void SetDropTarget( wxDropTarget *dropTarget );
112#endif // wxUSE_DRAG_AND_DROP
113
114 // Accept files for dragging
115 virtual void DragAcceptFiles(bool accept);
116
8cf73271
SC
117 // implementation from now on
118 // --------------------------
119
120 void MacClientToRootWindow( int *x , int *y ) const ;
121 void MacRootWindowToClient( int *x , int *y ) const ;
4f305456 122
8cf73271 123 void MacWindowToRootWindow( int *x , int *y ) const ;
4f305456
SC
124 void MacWindowToRootWindow( short *x , short *y ) const ;
125
8cf73271 126 void MacRootWindowToWindow( int *x , int *y ) const ;
4f305456 127 void MacRootWindowToWindow( short *x , short *y ) const ;
8cf73271
SC
128
129 virtual wxString MacGetToolTipString( wxPoint &where ) ;
130
131 // simple accessors
132 // ----------------
133
6d4c54a7 134 virtual WXWidget GetHandle() const ;
8cf73271 135
4f305456 136#if WXWIN_COMPATIBILITY_2_4
8cf73271
SC
137 bool GetTransparentBackground() const { return m_backgroundTransparent; }
138 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
4f305456 139#endif
8cf73271
SC
140
141 // event handlers
142 // --------------
143 void OnSetFocus(wxFocusEvent& event) ;
ff3795ee 144 void OnPaint(wxPaintEvent& event);
8cf73271
SC
145 void OnNcPaint(wxNcPaintEvent& event);
146 void OnEraseBackground(wxEraseEvent& event);
147 void OnMouseEvent( wxMouseEvent &event ) ;
148
149 void MacOnScroll(wxScrollEvent&event ) ;
150
151 bool AcceptsFocus() const ;
152
153public:
154 void OnInternalIdle();
155
156 // For implementation purposes - sometimes decorations make the client area
157 // smaller
158 virtual wxPoint GetClientAreaOrigin() const;
159
160 wxWindowMac *FindItem(long id) const;
161 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
162
8cf73271 163public:
4f305456
SC
164 virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
165 virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ;
4f305456 166 virtual bool MacCanFocus() const ;
8cf73271 167
8cf73271 168 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
4f305456
SC
169 virtual void RemoveChild( wxWindowBase *child );
170 virtual void MacPaintBorders( int left , int top ) ;
e2f865d8
SC
171 // invalidates the borders and focus area around the control
172 // must not be virtual as it will be called during destruction
173 void MacInvalidateBorders() ;
4f305456 174 WXWindow MacGetTopLevelWindowRef() const ;
8cf73271
SC
175 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
176
4f305456
SC
177 virtual long MacGetLeftBorderSize() const ;
178 virtual long MacGetRightBorderSize() const ;
179 virtual long MacGetTopBorderSize() const ;
180 virtual long MacGetBottomBorderSize() const ;
8cf73271 181
4f305456 182 static long MacRemoveBordersFromStyle( long style ) ;
e2f865d8 183
4f305456 184 virtual void MacSuperChangedPosition() ;
8cf73271 185 // the absolute coortinates of this window's root have changed
4f305456
SC
186 virtual void MacTopLevelWindowChangedPosition() ;
187
08422003 188 virtual void MacChildAdded() ;
4f305456
SC
189 virtual void MacVisibilityChanged() ;
190 virtual void MacEnabledStateChanged() ;
8ab50549 191 virtual void MacHiliteChanged() ;
336a6aba 192 virtual wxInt32 MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
4f305456
SC
193
194 bool MacIsReallyShown() ;
195 bool MacIsReallyEnabled() ;
8ab50549 196 bool MacIsReallyHilited() ;
4f305456
SC
197
198 bool MacIsUserPane() { return m_macIsUserPane; }
199
4f305456 200 virtual bool MacSetupCursor( const wxPoint& pt ) ;
8cf73271 201
7ea087b7 202 virtual void MacSetBackgroundBrush( const wxBrush &brush ) ;
4f305456
SC
203 const wxBrush& MacGetBackgroundBrush() const { return m_macBackgroundBrush ; }
204
a45ff297
SC
205 // return the rectangle that would be visible of this control, regardless whether controls are hidden
206 // only taking into account clipping by parent windows
78df41df 207 const wxRect& MacGetClippedClientRect() const ;
a45ff297
SC
208 const wxRect& MacGetClippedRect() const ;
209 const wxRect& MacGetClippedRectWithOuterStructure() const ;
4f305456 210 // returns the visible region of this control in window ie non-client coordinates
a45ff297 211 const wxRegion& MacGetVisibleRegion( bool includeOuterStructures = false ) ;
53409666 212 // returns true if children have to clipped to the content area (eg scrolled window)
8adc196b
SC
213 bool MacClipChildren() const { return m_clipChildren ; }
214 void MacSetClipChildren( bool clip ) { m_clipChildren = clip ; }
53409666
SC
215 // returns true if the grandchildren have to be clipped to the children's content area (eg
216 // splitter window)
217 virtual bool MacClipGrandChildren() const { return false ; }
4f305456 218 bool MacIsWindowScrollbar( const wxScrollBar* sb )
8cf73271 219 { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
4f305456
SC
220
221 wxList& GetSubcontrols() { return m_subControls; }
5ca0d812 222 virtual void MacInstallEventHandler(WXWidget native) ;
4f305456
SC
223 WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; }
224 void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
20b69855 225#ifndef __WXMAC_OSX__
4f305456
SC
226 virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
227 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
228 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
229 virtual void MacControlUserPaneIdleProc() ;
230 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ;
231 virtual void MacControlUserPaneActivateProc(bool activating) ;
232 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
233 virtual void MacControlUserPaneBackgroundProc(void* info) ;
20b69855 234#endif
77ffb593 235 // translate wxWidgets coords into ones suitable to be passed to
4f305456
SC
236 // the CreateControl calls
237 //
238 // returns TRUE if non default coords are returned, FALSE otherwise
239 bool MacGetBoundsForControl(const wxPoint& pos,
240 const wxSize& size,
241 int& x, int& y,
79392158 242 int& w, int& h , bool adjustForOrigin ) const ;
4f305456
SC
243 // calculates the real window position and size from the native control
244 void MacGetPositionAndSizeFromControl(int& x, int& y,
245 int& w, int& h) const ;
f5ea731f
SC
246 // gets the inset from every part
247 virtual void MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) ;
248
8d4c4868
SC
249 // flash the current invalid area, useful for debugging in OSX double buffered situation
250 void MacFlashInvalidAreas() ;
e2f865d8
SC
251
252 // the 'true' OS level control for this wxWindow
253 wxMacControl* GetPeer() const { return m_peer ; }
20b69855
SC
254#if wxMAC_USE_CORE_GRAPHICS
255 void * MacGetCGContextRef() { return m_cgContextRef ; }
256 void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; }
257#endif
8cf73271 258protected:
4f305456
SC
259 // For controls like radiobuttons which are really composite
260 wxList m_subControls;
79392158
SC
261 // number of calls to Freeze() minus number of calls to Thaw()
262 unsigned int m_frozenness;
6d4c54a7
SC
263 // the peer object, allowing for cleaner API support
264 wxMacControl* m_peer ;
20b69855
SC
265#if wxMAC_USE_CORE_GRAPHICS
266 void * m_cgContextRef ;
267#endif
a45ff297
SC
268 // cache the clipped rectangles within the window hierarchy
269 void MacUpdateClippedRects() const ;
270 mutable bool m_cachedClippedRectValid ;
271 mutable wxRect m_cachedClippedRectWithOuterStructure ;
272 mutable wxRect m_cachedClippedRect ;
78df41df 273 mutable wxRect m_cachedClippedClientRect ;
a45ff297
SC
274 mutable wxRegion m_cachedClippedRegionWithOuterStructure ;
275 mutable wxRegion m_cachedClippedRegion ;
78df41df 276 mutable wxRegion m_cachedClippedClientRegion ;
ed8a0852 277 // true if is is not a native control but a wxWindow control
4f305456
SC
278 bool m_macIsUserPane ;
279 wxBrush m_macBackgroundBrush ;
ed8a0852
SC
280 // topleft inset of the mac control from the wx top left corner
281 wxPoint m_macTopLeftInset ;
282 // bottom right inset of the mac control from the wx bottom right corner
283 wxPoint m_macBottomRightInset ;
8cf73271 284
4f305456
SC
285 wxScrollBar* m_hScrollBar ;
286 wxScrollBar* m_vScrollBar ;
287 wxString m_label ;
8adc196b
SC
288 // returns true if we do a sharp clip at the content area of this window
289 // must be dynamic as eg a panel normally is not clipping precisely, but if
290 // it becomes the target window of a scrolled window it has to...
291 bool m_clipChildren ;
8cf73271 292
78df41df
SC
293 virtual bool MacIsChildOfClientArea( const wxWindow* child ) const ;
294
4f305456
SC
295 void MacCreateScrollBars( long style ) ;
296 void MacRepositionScrollBars() ;
297 void MacUpdateControlFont() ;
8ab50549 298
4f305456
SC
299 void MacPropagateVisibilityChanged() ;
300 void MacPropagateEnabledStateChanged() ;
8ab50549 301 void MacPropagateHiliteChanged() ;
4f305456 302
8d4c4868 303
4f305456 304#if WXWIN_COMPATIBILITY_2_4
8cf73271 305 bool m_backgroundTransparent ;
4f305456 306#endif
8cf73271
SC
307
308 // implement the base class pure virtuals
4f305456
SC
309 virtual wxSize DoGetBestSize() const;
310 virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const;
8cf73271
SC
311 virtual void DoClientToScreen( int *x, int *y ) const;
312 virtual void DoScreenToClient( int *x, int *y ) const;
313 virtual void DoGetPosition( int *x, int *y ) const;
314 virtual void DoGetSize( int *width, int *height ) const;
315 virtual void DoGetClientSize( int *width, int *height ) const;
316 virtual void DoSetSize(int x, int y,
317 int width, int height,
318 int sizeFlags = wxSIZE_AUTO);
319 virtual void DoSetClientSize(int width, int height);
320
321 virtual void DoCaptureMouse();
322 virtual void DoReleaseMouse();
323
324 // move the window to the specified location and resize it: this is called
325 // from both DoSetSize() and DoSetClientSize() and would usually just call
326 // ::MoveWindow() except for composite controls which will want to arrange
327 // themselves inside the given rectangle
328 virtual void DoMoveWindow(int x, int y, int width, int height);
4f305456
SC
329 virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
330
8cf73271
SC
331
332#if wxUSE_TOOLTIPS
333 virtual void DoSetToolTip( wxToolTip *tip );
334#endif // wxUSE_TOOLTIPS
335
4f305456
SC
336private :
337
8cf73271
SC
338private:
339 // common part of all ctors
340 void Init();
341
4f305456
SC
342 WXEVENTHANDLERREF m_macControlEventHandler ;
343
344
8cf73271
SC
345 DECLARE_NO_COPY_CLASS(wxWindowMac)
346 DECLARE_EVENT_TABLE()
347};
348
349#endif
350 // _WX_WINDOW_H_