]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/window.h
added port state save class
[wxWidgets.git] / include / wx / mac / carbon / window.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "window.h"
17 #endif
18
19 #include "wx/brush.h"
20
21 // ---------------------------------------------------------------------------
22 // forward declarations
23 // ---------------------------------------------------------------------------
24
25 class WXDLLEXPORT wxButton;
26 class WXDLLEXPORT wxScrollBar;
27 class WXDLLEXPORT wxTopLevelWindowMac;
28
29 // ---------------------------------------------------------------------------
30 // constants
31 // ---------------------------------------------------------------------------
32
33 class WXDLLEXPORT wxWindowMac: public wxWindowBase
34 {
35 DECLARE_DYNAMIC_CLASS(wxWindowMac)
36
37 friend class wxDC;
38 friend class wxPaintDC;
39
40 public:
41
42 wxWindowMac()
43 { Init(); }
44
45 wxWindowMac(wxWindowMac *parent,
46 wxWindowID id,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = 0,
50 const wxString& name = wxPanelNameStr)
51 {
52 Init();
53 Create(parent, id, pos, size, style, name);
54 }
55
56 virtual ~wxWindowMac();
57
58 bool Create(wxWindowMac *parent,
59 wxWindowID id,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize,
62 long style = 0,
63 const wxString& name = wxPanelNameStr);
64
65
66 // implement base class pure virtuals
67 virtual void SetTitle( const wxString& title);
68 virtual wxString GetTitle() const;
69
70 virtual void Raise();
71 virtual void Lower();
72
73 virtual bool Show( bool show = TRUE );
74 virtual bool Enable( bool enable = TRUE );
75
76 virtual void SetFocus();
77
78 virtual void WarpPointer(int x, int y);
79
80 virtual void Refresh( bool eraseBackground = TRUE,
81 const wxRect *rect = (const wxRect *) NULL );
82
83 virtual bool SetCursor( const wxCursor &cursor );
84 virtual bool SetFont( const wxFont &font ) ;
85 virtual bool SetBackgroundColour( const wxColour &colour );
86 virtual bool SetForegroundColour( const wxColour &colour );
87
88 virtual int GetCharHeight() const;
89 virtual int GetCharWidth() const;
90 virtual void GetTextExtent(const wxString& string,
91 int *x, int *y,
92 int *descent = (int *) NULL,
93 int *externalLeading = (int *) NULL,
94 const wxFont *theFont = (const wxFont *) NULL)
95 const;
96
97 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
98
99 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
100 int range, bool refresh = TRUE );
101 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
102 virtual int GetScrollPos( int orient ) const;
103 virtual int GetScrollThumb( int orient ) const;
104 virtual int GetScrollRange( int orient ) const;
105 virtual void ScrollWindow( int dx, int dy,
106 const wxRect* rect = (wxRect *) NULL );
107
108 #if wxUSE_DRAG_AND_DROP
109 virtual void SetDropTarget( wxDropTarget *dropTarget );
110 #endif // wxUSE_DRAG_AND_DROP
111
112 // Accept files for dragging
113 virtual void DragAcceptFiles(bool accept);
114
115 // implementation from now on
116 // --------------------------
117
118 void MacClientToRootWindow( int *x , int *y ) const ;
119 void MacRootWindowToClient( int *x , int *y ) const ;
120
121 void MacWindowToRootWindow( int *x , int *y ) const ;
122 void MacWindowToRootWindow( short *x , short *y ) const ;
123
124 void MacRootWindowToWindow( int *x , int *y ) const ;
125 void MacRootWindowToWindow( short *x , short *y ) const ;
126
127 virtual wxString MacGetToolTipString( wxPoint &where ) ;
128
129 // simple accessors
130 // ----------------
131
132 virtual WXWidget GetHandle() const { return m_macControl ; }
133
134 #if WXWIN_COMPATIBILITY_2_4
135 bool GetTransparentBackground() const { return m_backgroundTransparent; }
136 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
137 #endif
138
139 // event handlers
140 // --------------
141 void OnSetFocus(wxFocusEvent& event) ;
142 void OnNcPaint(wxNcPaintEvent& event);
143 void OnEraseBackground(wxEraseEvent& event);
144 void OnMouseEvent( wxMouseEvent &event ) ;
145
146 void MacOnScroll(wxScrollEvent&event ) ;
147
148 bool AcceptsFocus() const ;
149
150 public:
151 void OnInternalIdle();
152
153 // For implementation purposes - sometimes decorations make the client area
154 // smaller
155 virtual wxPoint GetClientAreaOrigin() const;
156
157 wxWindowMac *FindItem(long id) const;
158 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
159
160 public:
161 virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
162 virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ;
163 virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
164 virtual bool MacCanFocus() const ;
165
166 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
167 virtual void RemoveChild( wxWindowBase *child );
168 virtual void MacPaintBorders( int left , int top ) ;
169 WXWindow MacGetTopLevelWindowRef() const ;
170 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
171
172 virtual long MacGetLeftBorderSize() const ;
173 virtual long MacGetRightBorderSize() const ;
174 virtual long MacGetTopBorderSize() const ;
175 virtual long MacGetBottomBorderSize() const ;
176
177 static long MacRemoveBordersFromStyle( long style ) ;
178
179 virtual void MacSuperChangedPosition() ;
180 // the absolute coortinates of this window's root have changed
181 virtual void MacTopLevelWindowChangedPosition() ;
182
183 virtual void MacVisibilityChanged() ;
184 virtual void MacEnabledStateChanged() ;
185 virtual void MacHiliteChanged() ;
186
187 bool MacIsReallyShown() ;
188 bool MacIsReallyEnabled() ;
189 bool MacIsReallyHilited() ;
190
191 bool MacIsUserPane() { return m_macIsUserPane; }
192
193 virtual void Update() ;
194 virtual bool MacSetupCursor( const wxPoint& pt ) ;
195
196 virtual void MacSetBackgroundBrush( const wxBrush &brush ) { m_macBackgroundBrush = brush ; }
197 const wxBrush& MacGetBackgroundBrush() const { return m_macBackgroundBrush ; }
198
199 // returns the visible region of this control in window ie non-client coordinates
200
201 wxRegion MacGetVisibleRegion( bool includeOuterStructures = false ) ;
202 bool MacIsWindowScrollbar( const wxScrollBar* sb )
203 { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
204
205 wxList& GetSubcontrols() { return m_subControls; }
206 virtual void MacInstallEventHandler() ;
207 virtual void MacRedrawControl();
208 WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; }
209 void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ;
210
211 virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
212 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
213 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
214 virtual void MacControlUserPaneIdleProc() ;
215 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ;
216 virtual void MacControlUserPaneActivateProc(bool activating) ;
217 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
218 virtual void MacControlUserPaneBackgroundProc(void* info) ;
219
220 // translate wxWindows coords into ones suitable to be passed to
221 // the CreateControl calls
222 //
223 // returns TRUE if non default coords are returned, FALSE otherwise
224 bool MacGetBoundsForControl(const wxPoint& pos,
225 const wxSize& size,
226 int& x, int& y,
227 int& w, int& h) const ;
228 // calculates the real window position and size from the native control
229 void MacGetPositionAndSizeFromControl(int& x, int& y,
230 int& w, int& h) const ;
231 protected:
232 // For controls like radiobuttons which are really composite
233 wxList m_subControls;
234
235 WXWidget m_macControl ;
236 bool m_macIsUserPane ;
237 wxBrush m_macBackgroundBrush ;
238
239 wxScrollBar* m_hScrollBar ;
240 wxScrollBar* m_vScrollBar ;
241 wxString m_label ;
242
243 void MacCreateScrollBars( long style ) ;
244 void MacRepositionScrollBars() ;
245 void MacUpdateControlFont() ;
246
247 void MacPropagateVisibilityChanged() ;
248 void MacPropagateEnabledStateChanged() ;
249 void MacPropagateHiliteChanged() ;
250
251
252 #if WXWIN_COMPATIBILITY_2_4
253 bool m_backgroundTransparent ;
254 #endif
255
256 // implement the base class pure virtuals
257 virtual wxSize DoGetBestSize() const;
258 virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const;
259 virtual void DoClientToScreen( int *x, int *y ) const;
260 virtual void DoScreenToClient( int *x, int *y ) const;
261 virtual void DoGetPosition( int *x, int *y ) const;
262 virtual void DoGetSize( int *width, int *height ) const;
263 virtual void DoGetClientSize( int *width, int *height ) const;
264 virtual void DoSetSize(int x, int y,
265 int width, int height,
266 int sizeFlags = wxSIZE_AUTO);
267 virtual void DoSetClientSize(int width, int height);
268
269 virtual void DoCaptureMouse();
270 virtual void DoReleaseMouse();
271
272 // move the window to the specified location and resize it: this is called
273 // from both DoSetSize() and DoSetClientSize() and would usually just call
274 // ::MoveWindow() except for composite controls which will want to arrange
275 // themselves inside the given rectangle
276 virtual void DoMoveWindow(int x, int y, int width, int height);
277 virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
278
279
280 #if wxUSE_TOOLTIPS
281 virtual void DoSetToolTip( wxToolTip *tip );
282 #endif // wxUSE_TOOLTIPS
283
284 private :
285
286 private:
287 // common part of all ctors
288 void Init();
289
290 WXEVENTHANDLERREF m_macControlEventHandler ;
291
292
293 DECLARE_NO_COPY_CLASS(wxWindowMac)
294 DECLARE_EVENT_TABLE()
295 };
296
297 #endif
298 // _WX_WINDOW_H_