]>
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 | |
65571936 | 9 | // Licence: wxWindows licence |
8cf73271 SC |
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" | |
20b69855 | 20 | #include "wx/dc.h" |
8cf73271 SC |
21 | |
22 | // --------------------------------------------------------------------------- | |
23 | // forward declarations | |
24 | // --------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLEXPORT wxButton; | |
27 | class WXDLLEXPORT wxScrollBar; | |
28 | class WXDLLEXPORT wxTopLevelWindowMac; | |
29 | ||
6d4c54a7 SC |
30 | // internal implementation classes |
31 | ||
32 | class wxMacControl ; | |
33 | ||
8cf73271 SC |
34 | // --------------------------------------------------------------------------- |
35 | // constants | |
36 | // --------------------------------------------------------------------------- | |
37 | ||
38 | class WXDLLEXPORT wxWindowMac: public wxWindowBase | |
39 | { | |
40 | DECLARE_DYNAMIC_CLASS(wxWindowMac) | |
41 | ||
42 | friend class wxDC; | |
43 | friend class wxPaintDC; | |
44 | ||
45 | public: | |
46 | ||
997e843d | 47 | wxWindowMac() ; |
8cf73271 SC |
48 | |
49 | wxWindowMac(wxWindowMac *parent, | |
50 | wxWindowID id, | |
51 | const wxPoint& pos = wxDefaultPosition, | |
52 | const wxSize& size = wxDefaultSize, | |
53 | long style = 0, | |
997e843d | 54 | const wxString& name = wxPanelNameStr) ; |
8cf73271 SC |
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 | 84 | |
cb4b0966 SC |
85 | virtual void Update() ; |
86 | virtual void ClearBackground() ; | |
87 | ||
8cf73271 | 88 | virtual bool SetCursor( const wxCursor &cursor ); |
4f305456 SC |
89 | virtual bool SetFont( const wxFont &font ) ; |
90 | virtual bool SetBackgroundColour( const wxColour &colour ); | |
91 | virtual bool SetForegroundColour( const wxColour &colour ); | |
92 | ||
8cf73271 SC |
93 | virtual int GetCharHeight() const; |
94 | virtual int GetCharWidth() const; | |
95 | virtual void GetTextExtent(const wxString& string, | |
96 | int *x, int *y, | |
97 | int *descent = (int *) NULL, | |
98 | int *externalLeading = (int *) NULL, | |
99 | const wxFont *theFont = (const wxFont *) NULL) | |
100 | const; | |
101 | ||
102 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
103 | ||
104 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
105 | int range, bool refresh = TRUE ); | |
106 | virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); | |
107 | virtual int GetScrollPos( int orient ) const; | |
108 | virtual int GetScrollThumb( int orient ) const; | |
109 | virtual int GetScrollRange( int orient ) const; | |
110 | virtual void ScrollWindow( int dx, int dy, | |
111 | const wxRect* rect = (wxRect *) NULL ); | |
112 | ||
113 | #if wxUSE_DRAG_AND_DROP | |
114 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
115 | #endif // wxUSE_DRAG_AND_DROP | |
116 | ||
117 | // Accept files for dragging | |
118 | virtual void DragAcceptFiles(bool accept); | |
119 | ||
8cf73271 SC |
120 | // implementation from now on |
121 | // -------------------------- | |
122 | ||
123 | void MacClientToRootWindow( int *x , int *y ) const ; | |
124 | void MacRootWindowToClient( int *x , int *y ) const ; | |
4f305456 | 125 | |
8cf73271 | 126 | void MacWindowToRootWindow( int *x , int *y ) const ; |
4f305456 SC |
127 | void MacWindowToRootWindow( short *x , short *y ) const ; |
128 | ||
8cf73271 | 129 | void MacRootWindowToWindow( int *x , int *y ) const ; |
4f305456 | 130 | void MacRootWindowToWindow( short *x , short *y ) const ; |
8cf73271 SC |
131 | |
132 | virtual wxString MacGetToolTipString( wxPoint &where ) ; | |
133 | ||
134 | // simple accessors | |
135 | // ---------------- | |
136 | ||
6d4c54a7 | 137 | virtual WXWidget GetHandle() const ; |
8cf73271 | 138 | |
4f305456 | 139 | #if WXWIN_COMPATIBILITY_2_4 |
8cf73271 SC |
140 | bool GetTransparentBackground() const { return m_backgroundTransparent; } |
141 | void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } | |
4f305456 | 142 | #endif |
8cf73271 SC |
143 | |
144 | // event handlers | |
145 | // -------------- | |
146 | void OnSetFocus(wxFocusEvent& event) ; | |
ff3795ee | 147 | void OnPaint(wxPaintEvent& event); |
8cf73271 SC |
148 | void OnNcPaint(wxNcPaintEvent& event); |
149 | void OnEraseBackground(wxEraseEvent& event); | |
150 | void OnMouseEvent( wxMouseEvent &event ) ; | |
151 | ||
152 | void MacOnScroll(wxScrollEvent&event ) ; | |
153 | ||
154 | bool AcceptsFocus() const ; | |
155 | ||
156 | public: | |
157 | void OnInternalIdle(); | |
158 | ||
159 | // For implementation purposes - sometimes decorations make the client area | |
160 | // smaller | |
161 | virtual wxPoint GetClientAreaOrigin() const; | |
162 | ||
163 | wxWindowMac *FindItem(long id) const; | |
164 | wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; | |
165 | ||
8cf73271 | 166 | public: |
4f305456 SC |
167 | virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ; |
168 | virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ; | |
4f305456 | 169 | virtual bool MacCanFocus() const ; |
8cf73271 | 170 | |
8cf73271 | 171 | // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren |
4f305456 SC |
172 | virtual void RemoveChild( wxWindowBase *child ); |
173 | virtual void MacPaintBorders( int left , int top ) ; | |
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 SC |
182 | static long MacRemoveBordersFromStyle( long style ) ; |
183 | ||
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 | ||
205 | // returns the visible region of this control in window ie non-client coordinates | |
206 | ||
207 | wxRegion MacGetVisibleRegion( bool includeOuterStructures = false ) ; | |
53409666 SC |
208 | // returns true if children have to clipped to the content area (eg scrolled window) |
209 | virtual bool MacClipChildren() const { return false ; } | |
210 | // returns true if the grandchildren have to be clipped to the children's content area (eg | |
211 | // splitter window) | |
212 | virtual bool MacClipGrandChildren() const { return false ; } | |
4f305456 | 213 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) |
8cf73271 | 214 | { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } |
4f305456 SC |
215 | |
216 | wxList& GetSubcontrols() { return m_subControls; } | |
5ca0d812 | 217 | virtual void MacInstallEventHandler(WXWidget native) ; |
4f305456 SC |
218 | WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; } |
219 | void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ; | |
20b69855 | 220 | #ifndef __WXMAC_OSX__ |
4f305456 SC |
221 | virtual void MacControlUserPaneDrawProc(wxInt16 part) ; |
222 | virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ; | |
223 | virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ; | |
224 | virtual void MacControlUserPaneIdleProc() ; | |
225 | virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ; | |
226 | virtual void MacControlUserPaneActivateProc(bool activating) ; | |
227 | virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ; | |
228 | virtual void MacControlUserPaneBackgroundProc(void* info) ; | |
20b69855 | 229 | #endif |
77ffb593 | 230 | // translate wxWidgets coords into ones suitable to be passed to |
4f305456 SC |
231 | // the CreateControl calls |
232 | // | |
233 | // returns TRUE if non default coords are returned, FALSE otherwise | |
234 | bool MacGetBoundsForControl(const wxPoint& pos, | |
235 | const wxSize& size, | |
236 | int& x, int& y, | |
79392158 | 237 | int& w, int& h , bool adjustForOrigin ) const ; |
4f305456 SC |
238 | // calculates the real window position and size from the native control |
239 | void MacGetPositionAndSizeFromControl(int& x, int& y, | |
240 | int& w, int& h) const ; | |
f5ea731f SC |
241 | // gets the inset from every part |
242 | virtual void MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) ; | |
243 | ||
8d4c4868 SC |
244 | // flash the current invalid area, useful for debugging in OSX double buffered situation |
245 | void MacFlashInvalidAreas() ; | |
20b69855 SC |
246 | #if wxMAC_USE_CORE_GRAPHICS |
247 | void * MacGetCGContextRef() { return m_cgContextRef ; } | |
248 | void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; } | |
249 | #endif | |
8cf73271 | 250 | protected: |
4f305456 SC |
251 | // For controls like radiobuttons which are really composite |
252 | wxList m_subControls; | |
79392158 SC |
253 | // number of calls to Freeze() minus number of calls to Thaw() |
254 | unsigned int m_frozenness; | |
6d4c54a7 SC |
255 | // the peer object, allowing for cleaner API support |
256 | wxMacControl* m_peer ; | |
20b69855 SC |
257 | #if wxMAC_USE_CORE_GRAPHICS |
258 | void * m_cgContextRef ; | |
259 | #endif | |
ed8a0852 | 260 | // true if is is not a native control but a wxWindow control |
4f305456 SC |
261 | bool m_macIsUserPane ; |
262 | wxBrush m_macBackgroundBrush ; | |
ed8a0852 SC |
263 | // topleft inset of the mac control from the wx top left corner |
264 | wxPoint m_macTopLeftInset ; | |
265 | // bottom right inset of the mac control from the wx bottom right corner | |
266 | wxPoint m_macBottomRightInset ; | |
8cf73271 | 267 | |
4f305456 SC |
268 | wxScrollBar* m_hScrollBar ; |
269 | wxScrollBar* m_vScrollBar ; | |
270 | wxString m_label ; | |
8cf73271 | 271 | |
4f305456 SC |
272 | void MacCreateScrollBars( long style ) ; |
273 | void MacRepositionScrollBars() ; | |
274 | void MacUpdateControlFont() ; | |
8ab50549 | 275 | |
4f305456 SC |
276 | void MacPropagateVisibilityChanged() ; |
277 | void MacPropagateEnabledStateChanged() ; | |
8ab50549 | 278 | void MacPropagateHiliteChanged() ; |
4f305456 | 279 | |
8d4c4868 | 280 | |
4f305456 | 281 | #if WXWIN_COMPATIBILITY_2_4 |
8cf73271 | 282 | bool m_backgroundTransparent ; |
4f305456 | 283 | #endif |
8cf73271 SC |
284 | |
285 | // implement the base class pure virtuals | |
4f305456 SC |
286 | virtual wxSize DoGetBestSize() const; |
287 | virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const; | |
8cf73271 SC |
288 | virtual void DoClientToScreen( int *x, int *y ) const; |
289 | virtual void DoScreenToClient( int *x, int *y ) const; | |
290 | virtual void DoGetPosition( int *x, int *y ) const; | |
291 | virtual void DoGetSize( int *width, int *height ) const; | |
292 | virtual void DoGetClientSize( int *width, int *height ) const; | |
293 | virtual void DoSetSize(int x, int y, | |
294 | int width, int height, | |
295 | int sizeFlags = wxSIZE_AUTO); | |
296 | virtual void DoSetClientSize(int width, int height); | |
297 | ||
298 | virtual void DoCaptureMouse(); | |
299 | virtual void DoReleaseMouse(); | |
300 | ||
301 | // move the window to the specified location and resize it: this is called | |
302 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
303 | // ::MoveWindow() except for composite controls which will want to arrange | |
304 | // themselves inside the given rectangle | |
305 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
4f305456 SC |
306 | virtual void DoSetWindowVariant( wxWindowVariant variant ) ; |
307 | ||
8cf73271 SC |
308 | |
309 | #if wxUSE_TOOLTIPS | |
310 | virtual void DoSetToolTip( wxToolTip *tip ); | |
311 | #endif // wxUSE_TOOLTIPS | |
312 | ||
4f305456 SC |
313 | private : |
314 | ||
8cf73271 SC |
315 | private: |
316 | // common part of all ctors | |
317 | void Init(); | |
318 | ||
4f305456 SC |
319 | WXEVENTHANDLERREF m_macControlEventHandler ; |
320 | ||
321 | ||
8cf73271 SC |
322 | DECLARE_NO_COPY_CLASS(wxWindowMac) |
323 | DECLARE_EVENT_TABLE() | |
324 | }; | |
325 | ||
326 | #endif | |
327 | // _WX_WINDOW_H_ |