]>
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" | |
20 | ||
21 | // --------------------------------------------------------------------------- | |
22 | // forward declarations | |
23 | // --------------------------------------------------------------------------- | |
24 | ||
25 | class WXDLLEXPORT wxButton; | |
26 | class WXDLLEXPORT wxScrollBar; | |
27 | class WXDLLEXPORT wxTopLevelWindowMac; | |
28 | ||
6d4c54a7 SC |
29 | // internal implementation classes |
30 | ||
31 | class wxMacControl ; | |
32 | ||
8cf73271 SC |
33 | // --------------------------------------------------------------------------- |
34 | // constants | |
35 | // --------------------------------------------------------------------------- | |
36 | ||
37 | class WXDLLEXPORT wxWindowMac: public wxWindowBase | |
38 | { | |
39 | DECLARE_DYNAMIC_CLASS(wxWindowMac) | |
40 | ||
41 | friend class wxDC; | |
42 | friend class wxPaintDC; | |
43 | ||
44 | public: | |
45 | ||
997e843d | 46 | wxWindowMac() ; |
8cf73271 SC |
47 | |
48 | wxWindowMac(wxWindowMac *parent, | |
49 | wxWindowID id, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | long style = 0, | |
997e843d | 53 | const wxString& name = wxPanelNameStr) ; |
8cf73271 SC |
54 | |
55 | virtual ~wxWindowMac(); | |
56 | ||
57 | bool Create(wxWindowMac *parent, | |
58 | wxWindowID id, | |
59 | const wxPoint& pos = wxDefaultPosition, | |
60 | const wxSize& size = wxDefaultSize, | |
61 | long style = 0, | |
62 | const wxString& name = wxPanelNameStr); | |
63 | ||
64 | ||
65 | // implement base class pure virtuals | |
66 | virtual void SetTitle( const wxString& title); | |
67 | virtual wxString GetTitle() const; | |
68 | ||
69 | virtual void Raise(); | |
70 | virtual void Lower(); | |
71 | ||
72 | virtual bool Show( bool show = TRUE ); | |
73 | virtual bool Enable( bool enable = TRUE ); | |
74 | ||
75 | virtual void SetFocus(); | |
76 | ||
77 | virtual void WarpPointer(int x, int y); | |
78 | ||
79 | virtual void Refresh( bool eraseBackground = TRUE, | |
80 | const wxRect *rect = (const wxRect *) NULL ); | |
79392158 SC |
81 | virtual void Freeze() ; |
82 | virtual void Thaw() ; | |
8cf73271 SC |
83 | |
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 ); | |
108 | ||
109 | #if wxUSE_DRAG_AND_DROP | |
110 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
111 | #endif // wxUSE_DRAG_AND_DROP | |
112 | ||
113 | // Accept files for dragging | |
114 | virtual void DragAcceptFiles(bool accept); | |
115 | ||
8cf73271 SC |
116 | // implementation from now on |
117 | // -------------------------- | |
118 | ||
119 | void MacClientToRootWindow( int *x , int *y ) const ; | |
120 | void MacRootWindowToClient( int *x , int *y ) const ; | |
4f305456 | 121 | |
8cf73271 | 122 | void MacWindowToRootWindow( int *x , int *y ) const ; |
4f305456 SC |
123 | void MacWindowToRootWindow( short *x , short *y ) const ; |
124 | ||
8cf73271 | 125 | void MacRootWindowToWindow( int *x , int *y ) const ; |
4f305456 | 126 | void MacRootWindowToWindow( short *x , short *y ) const ; |
8cf73271 SC |
127 | |
128 | virtual wxString MacGetToolTipString( wxPoint &where ) ; | |
129 | ||
130 | // simple accessors | |
131 | // ---------------- | |
132 | ||
6d4c54a7 | 133 | virtual WXWidget GetHandle() const ; |
8cf73271 | 134 | |
4f305456 | 135 | #if WXWIN_COMPATIBILITY_2_4 |
8cf73271 SC |
136 | bool GetTransparentBackground() const { return m_backgroundTransparent; } |
137 | void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } | |
4f305456 | 138 | #endif |
8cf73271 SC |
139 | |
140 | // event handlers | |
141 | // -------------- | |
142 | void OnSetFocus(wxFocusEvent& event) ; | |
143 | void OnNcPaint(wxNcPaintEvent& event); | |
144 | void OnEraseBackground(wxEraseEvent& event); | |
145 | void OnMouseEvent( wxMouseEvent &event ) ; | |
146 | ||
147 | void MacOnScroll(wxScrollEvent&event ) ; | |
148 | ||
149 | bool AcceptsFocus() const ; | |
150 | ||
151 | public: | |
152 | void OnInternalIdle(); | |
153 | ||
154 | // For implementation purposes - sometimes decorations make the client area | |
155 | // smaller | |
156 | virtual wxPoint GetClientAreaOrigin() const; | |
157 | ||
158 | wxWindowMac *FindItem(long id) const; | |
159 | wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; | |
160 | ||
8cf73271 | 161 | public: |
4f305456 SC |
162 | virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ; |
163 | virtual bool MacDoRedraw( WXHRGN updatergn , long time ) ; | |
164 | virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ; | |
165 | virtual bool MacCanFocus() const ; | |
8cf73271 | 166 | |
8cf73271 | 167 | // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren |
4f305456 SC |
168 | virtual void RemoveChild( wxWindowBase *child ); |
169 | virtual void MacPaintBorders( int left , int top ) ; | |
170 | WXWindow MacGetTopLevelWindowRef() const ; | |
8cf73271 SC |
171 | wxTopLevelWindowMac* MacGetTopLevelWindow() const ; |
172 | ||
4f305456 SC |
173 | virtual long MacGetLeftBorderSize() const ; |
174 | virtual long MacGetRightBorderSize() const ; | |
175 | virtual long MacGetTopBorderSize() const ; | |
176 | virtual long MacGetBottomBorderSize() const ; | |
8cf73271 | 177 | |
4f305456 SC |
178 | static long MacRemoveBordersFromStyle( long style ) ; |
179 | ||
180 | virtual void MacSuperChangedPosition() ; | |
8cf73271 | 181 | // the absolute coortinates of this window's root have changed |
4f305456 SC |
182 | virtual void MacTopLevelWindowChangedPosition() ; |
183 | ||
08422003 | 184 | virtual void MacChildAdded() ; |
4f305456 SC |
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 | |
7ea087b7 | 199 | virtual void MacSetBackgroundBrush( const wxBrush &brush ) ; |
4f305456 SC |
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 ) ; | |
53409666 SC |
205 | // returns true if children have to clipped to the content area (eg scrolled window) |
206 | virtual bool MacClipChildren() const { return false ; } | |
207 | // returns true if the grandchildren have to be clipped to the children's content area (eg | |
208 | // splitter window) | |
209 | virtual bool MacClipGrandChildren() const { return false ; } | |
4f305456 | 210 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) |
8cf73271 | 211 | { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } |
4f305456 SC |
212 | |
213 | wxList& GetSubcontrols() { return m_subControls; } | |
5ca0d812 | 214 | virtual void MacInstallEventHandler(WXWidget native) ; |
4f305456 SC |
215 | virtual void MacRedrawControl(); |
216 | WXEVENTHANDLERREF MacGetControlEventHandler() { return m_macControlEventHandler ; } | |
217 | void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ; | |
218 | ||
219 | virtual void MacControlUserPaneDrawProc(wxInt16 part) ; | |
220 | virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ; | |
221 | virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ; | |
222 | virtual void MacControlUserPaneIdleProc() ; | |
223 | virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ; | |
224 | virtual void MacControlUserPaneActivateProc(bool activating) ; | |
225 | virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ; | |
226 | virtual void MacControlUserPaneBackgroundProc(void* info) ; | |
227 | ||
77ffb593 | 228 | // translate wxWidgets coords into ones suitable to be passed to |
4f305456 SC |
229 | // the CreateControl calls |
230 | // | |
231 | // returns TRUE if non default coords are returned, FALSE otherwise | |
232 | bool MacGetBoundsForControl(const wxPoint& pos, | |
233 | const wxSize& size, | |
234 | int& x, int& y, | |
79392158 | 235 | int& w, int& h , bool adjustForOrigin ) const ; |
4f305456 SC |
236 | // calculates the real window position and size from the native control |
237 | void MacGetPositionAndSizeFromControl(int& x, int& y, | |
238 | int& w, int& h) const ; | |
f5ea731f SC |
239 | // gets the inset from every part |
240 | virtual void MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) ; | |
241 | ||
8d4c4868 SC |
242 | // flash the current invalid area, useful for debugging in OSX double buffered situation |
243 | void MacFlashInvalidAreas() ; | |
244 | ||
8cf73271 | 245 | protected: |
4f305456 SC |
246 | // For controls like radiobuttons which are really composite |
247 | wxList m_subControls; | |
79392158 SC |
248 | // number of calls to Freeze() minus number of calls to Thaw() |
249 | unsigned int m_frozenness; | |
6d4c54a7 SC |
250 | // the peer object, allowing for cleaner API support |
251 | wxMacControl* m_peer ; | |
ed8a0852 | 252 | // true if is is not a native control but a wxWindow control |
4f305456 SC |
253 | bool m_macIsUserPane ; |
254 | wxBrush m_macBackgroundBrush ; | |
ed8a0852 SC |
255 | // topleft inset of the mac control from the wx top left corner |
256 | wxPoint m_macTopLeftInset ; | |
257 | // bottom right inset of the mac control from the wx bottom right corner | |
258 | wxPoint m_macBottomRightInset ; | |
8cf73271 | 259 | |
4f305456 SC |
260 | wxScrollBar* m_hScrollBar ; |
261 | wxScrollBar* m_vScrollBar ; | |
262 | wxString m_label ; | |
8cf73271 | 263 | |
4f305456 SC |
264 | void MacCreateScrollBars( long style ) ; |
265 | void MacRepositionScrollBars() ; | |
266 | void MacUpdateControlFont() ; | |
8ab50549 | 267 | |
4f305456 SC |
268 | void MacPropagateVisibilityChanged() ; |
269 | void MacPropagateEnabledStateChanged() ; | |
8ab50549 | 270 | void MacPropagateHiliteChanged() ; |
4f305456 | 271 | |
8d4c4868 | 272 | |
4f305456 | 273 | #if WXWIN_COMPATIBILITY_2_4 |
8cf73271 | 274 | bool m_backgroundTransparent ; |
4f305456 | 275 | #endif |
8cf73271 SC |
276 | |
277 | // implement the base class pure virtuals | |
4f305456 SC |
278 | virtual wxSize DoGetBestSize() const; |
279 | virtual wxSize DoGetSizeFromClientSize( const wxSize & size ) const; | |
8cf73271 SC |
280 | virtual void DoClientToScreen( int *x, int *y ) const; |
281 | virtual void DoScreenToClient( int *x, int *y ) const; | |
282 | virtual void DoGetPosition( int *x, int *y ) const; | |
283 | virtual void DoGetSize( int *width, int *height ) const; | |
284 | virtual void DoGetClientSize( int *width, int *height ) const; | |
285 | virtual void DoSetSize(int x, int y, | |
286 | int width, int height, | |
287 | int sizeFlags = wxSIZE_AUTO); | |
288 | virtual void DoSetClientSize(int width, int height); | |
289 | ||
290 | virtual void DoCaptureMouse(); | |
291 | virtual void DoReleaseMouse(); | |
292 | ||
293 | // move the window to the specified location and resize it: this is called | |
294 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
295 | // ::MoveWindow() except for composite controls which will want to arrange | |
296 | // themselves inside the given rectangle | |
297 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
4f305456 SC |
298 | virtual void DoSetWindowVariant( wxWindowVariant variant ) ; |
299 | ||
8cf73271 SC |
300 | |
301 | #if wxUSE_TOOLTIPS | |
302 | virtual void DoSetToolTip( wxToolTip *tip ); | |
303 | #endif // wxUSE_TOOLTIPS | |
304 | ||
4f305456 SC |
305 | private : |
306 | ||
8cf73271 SC |
307 | private: |
308 | // common part of all ctors | |
309 | void Init(); | |
310 | ||
4f305456 SC |
311 | WXEVENTHANDLERREF m_macControlEventHandler ; |
312 | ||
313 | ||
8cf73271 SC |
314 | DECLARE_NO_COPY_CLASS(wxWindowMac) |
315 | DECLARE_EVENT_TABLE() | |
316 | }; | |
317 | ||
318 | #endif | |
319 | // _WX_WINDOW_H_ |