]>
Commit | Line | Data |
---|---|---|
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 | |
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() | |
4f305456 | 43 | { Init(); } |
8cf73271 SC |
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 ); | |
79392158 SC |
82 | virtual void Freeze() ; |
83 | virtual void Thaw() ; | |
8cf73271 SC |
84 | |
85 | virtual bool SetCursor( const wxCursor &cursor ); | |
4f305456 SC |
86 | virtual bool SetFont( const wxFont &font ) ; |
87 | virtual bool SetBackgroundColour( const wxColour &colour ); | |
88 | virtual bool SetForegroundColour( const wxColour &colour ); | |
89 | ||
8cf73271 SC |
90 | virtual int GetCharHeight() const; |
91 | virtual int GetCharWidth() const; | |
92 | virtual void GetTextExtent(const wxString& string, | |
93 | int *x, int *y, | |
94 | int *descent = (int *) NULL, | |
95 | int *externalLeading = (int *) NULL, | |
96 | const wxFont *theFont = (const wxFont *) NULL) | |
97 | const; | |
98 | ||
99 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
100 | ||
101 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
102 | int range, bool refresh = TRUE ); | |
103 | virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); | |
104 | virtual int GetScrollPos( int orient ) const; | |
105 | virtual int GetScrollThumb( int orient ) const; | |
106 | virtual int GetScrollRange( int orient ) const; | |
107 | virtual void ScrollWindow( int dx, int dy, | |
108 | const wxRect* rect = (wxRect *) NULL ); | |
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 | ||
4f305456 | 134 | virtual WXWidget GetHandle() const { return m_macControl ; } |
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) ; | |
144 | void OnNcPaint(wxNcPaintEvent& event); | |
145 | void OnEraseBackground(wxEraseEvent& event); | |
146 | void OnMouseEvent( wxMouseEvent &event ) ; | |
147 | ||
148 | void MacOnScroll(wxScrollEvent&event ) ; | |
149 | ||
150 | bool AcceptsFocus() const ; | |
151 | ||
152 | public: | |
153 | void OnInternalIdle(); | |
154 | ||
155 | // For implementation purposes - sometimes decorations make the client area | |
156 | // smaller | |
157 | virtual wxPoint GetClientAreaOrigin() const; | |
158 | ||
159 | wxWindowMac *FindItem(long id) const; | |
160 | wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; | |
161 | ||
8cf73271 | 162 | public: |
4f305456 SC |
163 | virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ; |
164 | virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ; | |
165 | virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ; | |
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 ) ; | |
171 | WXWindow MacGetTopLevelWindowRef() const ; | |
8cf73271 SC |
172 | wxTopLevelWindowMac* MacGetTopLevelWindow() const ; |
173 | ||
4f305456 SC |
174 | virtual long MacGetLeftBorderSize() const ; |
175 | virtual long MacGetRightBorderSize() const ; | |
176 | virtual long MacGetTopBorderSize() const ; | |
177 | virtual long MacGetBottomBorderSize() const ; | |
8cf73271 | 178 | |
4f305456 SC |
179 | static long MacRemoveBordersFromStyle( long style ) ; |
180 | ||
181 | virtual void MacSuperChangedPosition() ; | |
8cf73271 | 182 | // the absolute coortinates of this window's root have changed |
4f305456 SC |
183 | virtual void MacTopLevelWindowChangedPosition() ; |
184 | ||
185 | virtual void MacVisibilityChanged() ; | |
186 | virtual void MacEnabledStateChanged() ; | |
8ab50549 | 187 | virtual void MacHiliteChanged() ; |
336a6aba | 188 | virtual wxInt32 MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ; |
4f305456 SC |
189 | |
190 | bool MacIsReallyShown() ; | |
191 | bool MacIsReallyEnabled() ; | |
8ab50549 | 192 | bool MacIsReallyHilited() ; |
4f305456 SC |
193 | |
194 | bool MacIsUserPane() { return m_macIsUserPane; } | |
195 | ||
196 | virtual void Update() ; | |
197 | virtual bool MacSetupCursor( const wxPoint& pt ) ; | |
8cf73271 | 198 | |
4f305456 SC |
199 | virtual void MacSetBackgroundBrush( const wxBrush &brush ) { m_macBackgroundBrush = brush ; } |
200 | const wxBrush& MacGetBackgroundBrush() const { return m_macBackgroundBrush ; } | |
201 | ||
202 | // returns the visible region of this control in window ie non-client coordinates | |
203 | ||
204 | wxRegion MacGetVisibleRegion( bool includeOuterStructures = false ) ; | |
205 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) | |
8cf73271 | 206 | { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } |
4f305456 SC |
207 | |
208 | wxList& GetSubcontrols() { return m_subControls; } | |
209 | virtual void MacInstallEventHandler() ; | |
210 | virtual void MacRedrawControl(); | |
211 | WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; } | |
212 | void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ; | |
213 | ||
214 | virtual void MacControlUserPaneDrawProc(wxInt16 part) ; | |
215 | virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ; | |
216 | virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ; | |
217 | virtual void MacControlUserPaneIdleProc() ; | |
218 | virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ; | |
219 | virtual void MacControlUserPaneActivateProc(bool activating) ; | |
220 | virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ; | |
221 | virtual void MacControlUserPaneBackgroundProc(void* info) ; | |
222 | ||
223 | // translate wxWindows coords into ones suitable to be passed to | |
224 | // the CreateControl calls | |
225 | // | |
226 | // returns TRUE if non default coords are returned, FALSE otherwise | |
227 | bool MacGetBoundsForControl(const wxPoint& pos, | |
228 | const wxSize& size, | |
229 | int& x, int& y, | |
79392158 | 230 | int& w, int& h , bool adjustForOrigin ) const ; |
4f305456 SC |
231 | // calculates the real window position and size from the native control |
232 | void MacGetPositionAndSizeFromControl(int& x, int& y, | |
233 | int& w, int& h) const ; | |
f5ea731f SC |
234 | // gets the inset from every part |
235 | virtual void MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) ; | |
236 | ||
8cf73271 | 237 | protected: |
4f305456 SC |
238 | // For controls like radiobuttons which are really composite |
239 | wxList m_subControls; | |
79392158 SC |
240 | // number of calls to Freeze() minus number of calls to Thaw() |
241 | unsigned int m_frozenness; | |
242 | ||
4f305456 SC |
243 | WXWidget m_macControl ; |
244 | bool m_macIsUserPane ; | |
245 | wxBrush m_macBackgroundBrush ; | |
8cf73271 | 246 | |
4f305456 SC |
247 | wxScrollBar* m_hScrollBar ; |
248 | wxScrollBar* m_vScrollBar ; | |
249 | wxString m_label ; | |
8cf73271 | 250 | |
4f305456 SC |
251 | void MacCreateScrollBars( long style ) ; |
252 | void MacRepositionScrollBars() ; | |
253 | void MacUpdateControlFont() ; | |
8ab50549 | 254 | |
4f305456 SC |
255 | void MacPropagateVisibilityChanged() ; |
256 | void MacPropagateEnabledStateChanged() ; | |
8ab50549 | 257 | void MacPropagateHiliteChanged() ; |
4f305456 SC |
258 | |
259 | ||
260 | #if WXWIN_COMPATIBILITY_2_4 | |
8cf73271 | 261 | bool m_backgroundTransparent ; |
4f305456 | 262 | #endif |
8cf73271 SC |
263 | |
264 | // implement the base class pure virtuals | |
4f305456 SC |
265 | virtual wxSize DoGetBestSize() const; |
266 | virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const; | |
8cf73271 SC |
267 | virtual void DoClientToScreen( int *x, int *y ) const; |
268 | virtual void DoScreenToClient( int *x, int *y ) const; | |
269 | virtual void DoGetPosition( int *x, int *y ) const; | |
270 | virtual void DoGetSize( int *width, int *height ) const; | |
271 | virtual void DoGetClientSize( int *width, int *height ) const; | |
272 | virtual void DoSetSize(int x, int y, | |
273 | int width, int height, | |
274 | int sizeFlags = wxSIZE_AUTO); | |
275 | virtual void DoSetClientSize(int width, int height); | |
276 | ||
277 | virtual void DoCaptureMouse(); | |
278 | virtual void DoReleaseMouse(); | |
279 | ||
280 | // move the window to the specified location and resize it: this is called | |
281 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
282 | // ::MoveWindow() except for composite controls which will want to arrange | |
283 | // themselves inside the given rectangle | |
284 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
4f305456 SC |
285 | virtual void DoSetWindowVariant( wxWindowVariant variant ) ; |
286 | ||
8cf73271 SC |
287 | |
288 | #if wxUSE_TOOLTIPS | |
289 | virtual void DoSetToolTip( wxToolTip *tip ); | |
290 | #endif // wxUSE_TOOLTIPS | |
291 | ||
4f305456 SC |
292 | private : |
293 | ||
8cf73271 SC |
294 | private: |
295 | // common part of all ctors | |
296 | void Init(); | |
297 | ||
4f305456 SC |
298 | WXEVENTHANDLERREF m_macControlEventHandler ; |
299 | ||
300 | ||
8cf73271 SC |
301 | DECLARE_NO_COPY_CLASS(wxWindowMac) |
302 | DECLARE_EVENT_TABLE() | |
303 | }; | |
304 | ||
305 | #endif | |
306 | // _WX_WINDOW_H_ |