]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
e766c8a9 | 3 | // Purpose: wxWindowMac class |
a31a5f85 | 4 | // Author: Stefan Csomor |
0dbd6262 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
0dbd6262 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
e40298d5 | 9 | // Licence: wxWindows licence |
0dbd6262 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_WINDOW_H_ | |
13 | #define _WX_WINDOW_H_ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
0dbd6262 SC |
16 | #pragma interface "window.h" |
17 | #endif | |
18 | ||
57530dba GD |
19 | #include "wx/brush.h" |
20 | ||
519cb848 SC |
21 | // --------------------------------------------------------------------------- |
22 | // forward declarations | |
23 | // --------------------------------------------------------------------------- | |
0dbd6262 | 24 | |
519cb848 | 25 | class WXDLLEXPORT wxButton; |
e7549107 | 26 | class WXDLLEXPORT wxScrollBar; |
88594d02 | 27 | class WXDLLEXPORT wxTopLevelWindowMac; |
0dbd6262 | 28 | |
519cb848 SC |
29 | // --------------------------------------------------------------------------- |
30 | // constants | |
31 | // --------------------------------------------------------------------------- | |
0dbd6262 | 32 | |
e766c8a9 | 33 | class WXDLLEXPORT wxWindowMac: public wxWindowBase |
0dbd6262 | 34 | { |
ba161d7e GD |
35 | DECLARE_DYNAMIC_CLASS(wxWindowMac) |
36 | ||
37 | friend class wxDC; | |
38 | friend class wxPaintDC; | |
39 | ||
0dbd6262 | 40 | public: |
e40298d5 | 41 | |
ba161d7e GD |
42 | wxWindowMac() |
43 | : m_macBackgroundBrush() | |
44 | , m_macVisibleRegion() | |
45 | , m_x(0), m_y(0), m_width(0), m_height(0) | |
46 | , m_hScrollBar(NULL), m_vScrollBar(NULL) | |
47 | , m_label(wxEmptyString) | |
48 | { Init(); } | |
519cb848 | 49 | |
e766c8a9 | 50 | wxWindowMac(wxWindowMac *parent, |
ba161d7e GD |
51 | wxWindowID id, |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | long style = 0, | |
55 | const wxString& name = wxPanelNameStr) | |
519cb848 SC |
56 | { |
57 | Init(); | |
58 | Create(parent, id, pos, size, style, name); | |
59 | } | |
60 | ||
e766c8a9 | 61 | virtual ~wxWindowMac(); |
519cb848 | 62 | |
e766c8a9 | 63 | bool Create(wxWindowMac *parent, |
519cb848 SC |
64 | wxWindowID id, |
65 | const wxPoint& pos = wxDefaultPosition, | |
66 | const wxSize& size = wxDefaultSize, | |
67 | long style = 0, | |
68 | const wxString& name = wxPanelNameStr); | |
69 | ||
70 | ||
71 | // implement base class pure virtuals | |
72 | virtual void SetTitle( const wxString& title); | |
73 | virtual wxString GetTitle() const; | |
74 | ||
75 | virtual void Raise(); | |
76 | virtual void Lower(); | |
77 | ||
78 | virtual bool Show( bool show = TRUE ); | |
79 | virtual bool Enable( bool enable = TRUE ); | |
80 | ||
81 | virtual void SetFocus(); | |
82 | ||
519cb848 | 83 | virtual void WarpPointer(int x, int y); |
519cb848 SC |
84 | |
85 | virtual void Refresh( bool eraseBackground = TRUE, | |
86 | const wxRect *rect = (const wxRect *) NULL ); | |
519cb848 SC |
87 | |
88 | virtual bool SetCursor( const wxCursor &cursor ); | |
88594d02 SC |
89 | virtual bool SetFont(const wxFont& font) |
90 | { return wxWindowBase::SetFont(font); } | |
519cb848 SC |
91 | virtual int GetCharHeight() const; |
92 | virtual int GetCharWidth() const; | |
93 | virtual void GetTextExtent(const wxString& string, | |
94 | int *x, int *y, | |
95 | int *descent = (int *) NULL, | |
96 | int *externalLeading = (int *) NULL, | |
97 | const wxFont *theFont = (const wxFont *) NULL) | |
98 | const; | |
99 | ||
100 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
101 | ||
102 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
103 | int range, bool refresh = TRUE ); | |
104 | virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); | |
105 | virtual int GetScrollPos( int orient ) const; | |
106 | virtual int GetScrollThumb( int orient ) const; | |
107 | virtual int GetScrollRange( int orient ) const; | |
108 | virtual void ScrollWindow( int dx, int dy, | |
109 | const wxRect* rect = (wxRect *) NULL ); | |
0dbd6262 SC |
110 | |
111 | #if wxUSE_DRAG_AND_DROP | |
519cb848 SC |
112 | virtual void SetDropTarget( wxDropTarget *dropTarget ); |
113 | #endif // wxUSE_DRAG_AND_DROP | |
114 | ||
115 | // Accept files for dragging | |
116 | virtual void DragAcceptFiles(bool accept); | |
117 | ||
118 | #if WXWIN_COMPATIBILITY | |
119 | // Set/get scroll attributes | |
120 | virtual void SetScrollRange(int orient, int range, bool refresh = TRUE); | |
121 | virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); | |
122 | virtual int OldGetScrollRange(int orient) const; | |
123 | virtual int GetScrollPage(int orient) const; | |
124 | ||
125 | // event handlers | |
126 | // Handle a control command | |
e766c8a9 | 127 | virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event); |
519cb848 SC |
128 | |
129 | // Override to define new behaviour for default action (e.g. double | |
130 | // clicking on a listbox) | |
131 | virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { } | |
132 | #endif // WXWIN_COMPATIBILITY | |
133 | ||
134 | #if wxUSE_CARET && WXWIN_COMPATIBILITY | |
135 | // caret manipulation (old MSW only functions, see wxCaret class for the | |
136 | // new API) | |
137 | void CreateCaret(int w, int h); | |
138 | void CreateCaret(const wxBitmap *bitmap); | |
139 | void DestroyCaret(); | |
140 | void ShowCaret(bool show); | |
141 | void SetCaretPos(int x, int y); | |
142 | void GetCaretPos(int *x, int *y) const; | |
143 | #endif // wxUSE_CARET | |
144 | ||
145 | // Native resource loading (implemented in src/msw/nativdlg.cpp) | |
146 | // FIXME: should they really be all virtual? | |
e766c8a9 SC |
147 | wxWindowMac* GetWindowChild1(wxWindowID id); |
148 | wxWindowMac* GetWindowChild(wxWindowID id); | |
519cb848 SC |
149 | |
150 | // implementation from now on | |
151 | // -------------------------- | |
152 | ||
ba161d7e GD |
153 | void MacClientToRootWindow( int *x , int *y ) const ; |
154 | void MacRootWindowToClient( int *x , int *y ) const ; | |
155 | void MacWindowToRootWindow( int *x , int *y ) const ; | |
156 | void MacRootWindowToWindow( int *x , int *y ) const ; | |
e40298d5 | 157 | |
ba161d7e | 158 | virtual wxString MacGetToolTipString( wxPoint &where ) ; |
519cb848 SC |
159 | |
160 | // simple accessors | |
161 | // ---------------- | |
162 | ||
e7549107 SC |
163 | // WXHWND GetHWND() const { return m_hWnd; } |
164 | // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
e40298d5 | 165 | virtual WXWidget GetHandle() const { return (WXWidget) NULL ; } |
519cb848 | 166 | |
519cb848 SC |
167 | bool GetTransparentBackground() const { return m_backgroundTransparent; } |
168 | void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } | |
169 | ||
170 | // event handlers | |
171 | // -------------- | |
e40298d5 | 172 | void OnSetFocus(wxFocusEvent& event) ; |
88594d02 | 173 | void OnNcPaint(wxNcPaintEvent& event); |
519cb848 | 174 | void OnEraseBackground(wxEraseEvent& event); |
853f8094 SC |
175 | void OnMouseEvent( wxMouseEvent &event ) ; |
176 | ||
7c74e7fe | 177 | void MacOnScroll(wxScrollEvent&event ) ; |
4765d335 SC |
178 | |
179 | bool AcceptsFocus() const ; | |
0dbd6262 | 180 | |
519cb848 | 181 | public: |
e39af974 JS |
182 | void OnInternalIdle(); |
183 | ||
519cb848 SC |
184 | // For implementation purposes - sometimes decorations make the client area |
185 | // smaller | |
186 | virtual wxPoint GetClientAreaOrigin() const; | |
0dbd6262 | 187 | |
e766c8a9 SC |
188 | wxWindowMac *FindItem(long id) const; |
189 | wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; | |
0dbd6262 | 190 | |
519cb848 SC |
191 | // Make a Windows extended style from the given wxWindows window style |
192 | static WXDWORD MakeExtendedStyle(long style, | |
193 | bool eliminateBorders = TRUE); | |
194 | // Determine whether 3D effects are wanted | |
195 | WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const; | |
0dbd6262 | 196 | |
519cb848 SC |
197 | // MSW only: TRUE if this control is part of the main control |
198 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
0dbd6262 | 199 | |
519cb848 SC |
200 | #if WXWIN_COMPATIBILITY |
201 | wxObject *GetChild(int number) const; | |
202 | virtual void MSWDeviceToLogical(float *x, float *y) const; | |
203 | #endif // WXWIN_COMPATIBILITY | |
0dbd6262 | 204 | |
519cb848 SC |
205 | // Setup background and foreground colours correctly |
206 | virtual void SetupColours(); | |
0dbd6262 | 207 | |
0dbd6262 | 208 | |
519cb848 SC |
209 | #if WXWIN_COMPATIBILITY |
210 | void SetShowing(bool show) { (void)Show(show); } | |
211 | bool IsUserEnabled() const { return IsEnabled(); } | |
212 | #endif // WXWIN_COMPATIBILITY | |
0dbd6262 | 213 | |
ba161d7e GD |
214 | public: |
215 | static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ; | |
216 | virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ; | |
217 | virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ; | |
218 | virtual bool MacCanFocus() const { return true ; } | |
219 | ||
220 | virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ; | |
221 | // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren | |
222 | virtual void RemoveChild( wxWindowBase *child ); | |
223 | virtual void MacPaintBorders( int left , int top ) ; | |
224 | WXWindow MacGetRootWindow() const ; | |
225 | wxTopLevelWindowMac* MacGetTopLevelWindow() const ; | |
226 | ||
227 | virtual WXWidget MacGetContainerForEmbedding() ; | |
228 | ||
229 | virtual long MacGetLeftBorderSize() const ; | |
230 | virtual long MacGetRightBorderSize() const ; | |
231 | virtual long MacGetTopBorderSize() const ; | |
232 | virtual long MacGetBottomBorderSize() const ; | |
233 | ||
234 | static long MacRemoveBordersFromStyle( long style ) ; | |
235 | virtual void MacSuperChangedPosition() ; | |
c05a5f07 | 236 | // the absolute coordinates of this item within the toplevel window may have changed |
e40298d5 | 237 | virtual void MacUpdateDimensions() {} |
c05a5f07 | 238 | // the absolute coortinates of this window's root have changed |
ba161d7e GD |
239 | virtual void MacTopLevelWindowChangedPosition() ; |
240 | virtual void MacSuperShown( bool show ) ; | |
241 | virtual void MacSuperEnabled( bool enable ) ; | |
242 | bool MacIsReallyShown() const ; | |
243 | virtual void Update() ; | |
244 | // for compatibility | |
245 | void MacUpdateImmediately() { Update() ; } | |
2b5f62a0 | 246 | virtual bool MacSetupCursor( const wxPoint& pt ) ; |
ba161d7e GD |
247 | |
248 | // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ; | |
249 | // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ; | |
250 | // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ; | |
251 | const wxBrush& MacGetBackgroundBrush() ; | |
d835f05e | 252 | const wxRegion& MacGetVisibleRegion( bool respectChildrenAndSiblings = true ) ; |
ba161d7e GD |
253 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) |
254 | { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } | |
255 | static wxWindowMac* s_lastMouseWindow ; | |
e7549107 | 256 | private: |
0dbd6262 | 257 | protected: |
ba161d7e GD |
258 | wxBrush m_macBackgroundBrush ; |
259 | wxRegion m_macVisibleRegion ; | |
260 | int m_x ; | |
261 | int m_y ; | |
262 | int m_width ; | |
263 | int m_height ; | |
264 | ||
265 | wxScrollBar* m_hScrollBar ; | |
266 | wxScrollBar* m_vScrollBar ; | |
267 | wxString m_label ; | |
268 | ||
269 | void MacCreateScrollBars( long style ) ; | |
270 | void MacRepositionScrollBars() ; | |
519cb848 | 271 | |
4241baae | 272 | bool m_backgroundTransparent ; |
519cb848 SC |
273 | |
274 | // implement the base class pure virtuals | |
275 | virtual void DoClientToScreen( int *x, int *y ) const; | |
276 | virtual void DoScreenToClient( int *x, int *y ) const; | |
277 | virtual void DoGetPosition( int *x, int *y ) const; | |
278 | virtual void DoGetSize( int *width, int *height ) const; | |
279 | virtual void DoGetClientSize( int *width, int *height ) const; | |
280 | virtual void DoSetSize(int x, int y, | |
281 | int width, int height, | |
282 | int sizeFlags = wxSIZE_AUTO); | |
283 | virtual void DoSetClientSize(int width, int height); | |
284 | ||
4116c221 VZ |
285 | virtual void DoCaptureMouse(); |
286 | virtual void DoReleaseMouse(); | |
287 | ||
519cb848 SC |
288 | // move the window to the specified location and resize it: this is called |
289 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
290 | // ::MoveWindow() except for composite controls which will want to arrange | |
291 | // themselves inside the given rectangle | |
292 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
293 | ||
294 | #if wxUSE_TOOLTIPS | |
295 | virtual void DoSetToolTip( wxToolTip *tip ); | |
296 | #endif // wxUSE_TOOLTIPS | |
0dbd6262 | 297 | |
519cb848 SC |
298 | private: |
299 | // common part of all ctors | |
300 | void Init(); | |
0dbd6262 | 301 | |
e766c8a9 | 302 | DECLARE_NO_COPY_CLASS(wxWindowMac) |
519cb848 | 303 | DECLARE_EVENT_TABLE() |
0dbd6262 SC |
304 | }; |
305 | ||
0dbd6262 SC |
306 | #endif |
307 | // _WX_WINDOW_H_ |