]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
e766c8a9 | 3 | // Purpose: wxWindowMac class |
0dbd6262 SC |
4 | // Author: AUTHOR |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_WINDOW_H_ | |
13 | #define _WX_WINDOW_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "window.h" | |
17 | #endif | |
18 | ||
519cb848 SC |
19 | // --------------------------------------------------------------------------- |
20 | // forward declarations | |
21 | // --------------------------------------------------------------------------- | |
0dbd6262 | 22 | |
519cb848 | 23 | class WXDLLEXPORT wxButton; |
e7549107 | 24 | class WXDLLEXPORT wxScrollBar; |
88594d02 | 25 | class WXDLLEXPORT wxTopLevelWindowMac; |
0dbd6262 | 26 | |
519cb848 SC |
27 | // --------------------------------------------------------------------------- |
28 | // constants | |
29 | // --------------------------------------------------------------------------- | |
0dbd6262 | 30 | |
519cb848 SC |
31 | // FIXME does anybody use those? they're unused by wxWindows... |
32 | enum | |
0dbd6262 | 33 | { |
519cb848 SC |
34 | wxKEY_SHIFT = 1, |
35 | wxKEY_CTRL = 2 | |
0dbd6262 SC |
36 | }; |
37 | ||
e766c8a9 | 38 | class WXDLLEXPORT wxWindowMac: public wxWindowBase |
0dbd6262 | 39 | { |
e766c8a9 | 40 | DECLARE_DYNAMIC_CLASS(wxWindowMac); |
0dbd6262 SC |
41 | |
42 | friend class wxDC; | |
43 | friend class wxPaintDC; | |
44 | ||
45 | public: | |
519cb848 | 46 | |
e766c8a9 | 47 | wxWindowMac() { Init(); } |
519cb848 | 48 | |
e766c8a9 | 49 | wxWindowMac(wxWindowMac *parent, |
519cb848 SC |
50 | wxWindowID id, |
51 | const wxPoint& pos = wxDefaultPosition, | |
52 | const wxSize& size = wxDefaultSize, | |
53 | long style = 0, | |
54 | const wxString& name = wxPanelNameStr) | |
55 | { | |
56 | Init(); | |
57 | Create(parent, id, pos, size, style, name); | |
58 | } | |
59 | ||
e766c8a9 | 60 | virtual ~wxWindowMac(); |
519cb848 | 61 | |
e766c8a9 | 62 | bool Create(wxWindowMac *parent, |
519cb848 SC |
63 | wxWindowID id, |
64 | const wxPoint& pos = wxDefaultPosition, | |
65 | const wxSize& size = wxDefaultSize, | |
66 | long style = 0, | |
67 | const wxString& name = wxPanelNameStr); | |
68 | ||
69 | ||
70 | // implement base class pure virtuals | |
71 | virtual void SetTitle( const wxString& title); | |
72 | virtual wxString GetTitle() const; | |
73 | ||
74 | virtual void Raise(); | |
75 | virtual void Lower(); | |
76 | ||
77 | virtual bool Show( bool show = TRUE ); | |
78 | virtual bool Enable( bool enable = TRUE ); | |
79 | ||
80 | virtual void SetFocus(); | |
81 | ||
519cb848 SC |
82 | virtual void WarpPointer(int x, int y); |
83 | virtual void CaptureMouse(); | |
84 | virtual void ReleaseMouse(); | |
85 | ||
86 | virtual void Refresh( bool eraseBackground = TRUE, | |
87 | const wxRect *rect = (const wxRect *) NULL ); | |
88 | virtual void Clear(); | |
89 | ||
90 | virtual bool SetCursor( const wxCursor &cursor ); | |
88594d02 SC |
91 | virtual bool SetFont(const wxFont& font) |
92 | { return wxWindowBase::SetFont(font); } | |
519cb848 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 ); | |
0dbd6262 SC |
112 | |
113 | #if wxUSE_DRAG_AND_DROP | |
519cb848 SC |
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 | ||
120 | #if WXWIN_COMPATIBILITY | |
121 | // Set/get scroll attributes | |
122 | virtual void SetScrollRange(int orient, int range, bool refresh = TRUE); | |
123 | virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); | |
124 | virtual int OldGetScrollRange(int orient) const; | |
125 | virtual int GetScrollPage(int orient) const; | |
126 | ||
127 | // event handlers | |
128 | // Handle a control command | |
e766c8a9 | 129 | virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event); |
519cb848 SC |
130 | |
131 | // Override to define new behaviour for default action (e.g. double | |
132 | // clicking on a listbox) | |
133 | virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { } | |
134 | #endif // WXWIN_COMPATIBILITY | |
135 | ||
136 | #if wxUSE_CARET && WXWIN_COMPATIBILITY | |
137 | // caret manipulation (old MSW only functions, see wxCaret class for the | |
138 | // new API) | |
139 | void CreateCaret(int w, int h); | |
140 | void CreateCaret(const wxBitmap *bitmap); | |
141 | void DestroyCaret(); | |
142 | void ShowCaret(bool show); | |
143 | void SetCaretPos(int x, int y); | |
144 | void GetCaretPos(int *x, int *y) const; | |
145 | #endif // wxUSE_CARET | |
146 | ||
147 | // Native resource loading (implemented in src/msw/nativdlg.cpp) | |
148 | // FIXME: should they really be all virtual? | |
e766c8a9 SC |
149 | wxWindowMac* GetWindowChild1(wxWindowID id); |
150 | wxWindowMac* GetWindowChild(wxWindowID id); | |
519cb848 SC |
151 | |
152 | // implementation from now on | |
153 | // -------------------------- | |
154 | ||
155 | void MacClientToRootWindow( int *x , int *y ) const ; | |
156 | void MacRootWindowToClient( int *x , int *y ) const ; | |
88594d02 SC |
157 | void MacWindowToRootWindow( int *x , int *y ) const ; |
158 | void MacRootWindowToWindow( int *x , int *y ) const ; | |
05adb9d2 SC |
159 | |
160 | virtual wxString MacGetToolTipString( wxPoint &where ) ; | |
519cb848 SC |
161 | |
162 | // simple accessors | |
163 | // ---------------- | |
164 | ||
e7549107 SC |
165 | // WXHWND GetHWND() const { return m_hWnd; } |
166 | // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
167 | virtual WXWidget GetHandle() const { return (WXWidget) NULL ; } | |
519cb848 SC |
168 | |
169 | bool GetUseCtl3D() const { return m_useCtl3D; } | |
170 | bool GetTransparentBackground() const { return m_backgroundTransparent; } | |
171 | void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } | |
172 | ||
173 | // event handlers | |
174 | // -------------- | |
7810c95b | 175 | void OnSetFocus(wxFocusEvent& event) ; |
88594d02 | 176 | void OnNcPaint(wxNcPaintEvent& event); |
519cb848 SC |
177 | void OnEraseBackground(wxEraseEvent& event); |
178 | void OnIdle(wxIdleEvent& event); | |
7c74e7fe | 179 | void MacOnScroll(wxScrollEvent&event ) ; |
4765d335 SC |
180 | |
181 | bool AcceptsFocus() const ; | |
0dbd6262 | 182 | |
519cb848 SC |
183 | public: |
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 | |
e7549107 | 214 | public : |
e766c8a9 | 215 | static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ; |
88594d02 | 216 | virtual void MacRedraw( RgnHandle updatergn , long time , bool erase) ; |
e7549107 SC |
217 | virtual bool MacCanFocus() const { return true ; } |
218 | ||
e7549107 | 219 | virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ; |
88594d02 | 220 | |
05adb9d2 | 221 | virtual void MacPaintBorders() ; |
88594d02 SC |
222 | WindowRef MacGetRootWindow() const ; |
223 | wxTopLevelWindowMac* MacGetTopLevelWindow() const ; | |
e7549107 | 224 | |
05adb9d2 | 225 | virtual ControlHandle MacGetContainerForEmbedding() ; |
5b781a67 SC |
226 | |
227 | virtual long MacGetLeftBorderSize() const ; | |
228 | virtual long MacGetRightBorderSize() const ; | |
229 | virtual long MacGetTopBorderSize() const ; | |
230 | virtual long MacGetBottomBorderSize() const ; | |
231 | ||
05adb9d2 | 232 | static long MacRemoveBordersFromStyle( long style ) ; |
e7549107 | 233 | virtual void MacSuperChangedPosition() ; |
4bf3cd97 | 234 | virtual void MacTopLevelWindowChangedPosition() ; |
8208e181 | 235 | virtual void MacSuperShown( bool show ) ; |
88594d02 | 236 | virtual void MacSuperEnabled( bool enable ) ; |
c809f3be | 237 | bool MacIsReallyShown() const ; |
88594d02 SC |
238 | virtual void Update() ; |
239 | // for compatibility | |
240 | void MacUpdateImmediately() { Update() ; } | |
241 | ||
05adb9d2 | 242 | /* |
e7549107 SC |
243 | bool MacSetupFocusPort() ; |
244 | bool MacSetupDrawingPort() ; | |
245 | bool MacSetupFocusClientPort() ; | |
246 | bool MacSetupDrawingClientPort() ; | |
05adb9d2 | 247 | */ |
e766c8a9 SC |
248 | virtual bool MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ; |
249 | virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ; | |
e7549107 | 250 | |
e766c8a9 SC |
251 | virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ; |
252 | virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ; | |
253 | virtual void MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ; | |
88594d02 | 254 | |
7c74e7fe | 255 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } |
e766c8a9 | 256 | static wxWindowMac* s_lastMouseWindow ; |
e7549107 | 257 | private: |
e766c8a9 | 258 | virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ; |
0dbd6262 | 259 | protected: |
88594d02 SC |
260 | // RgnHandle m_macUpdateRgn ; |
261 | // bool m_macEraseOnRedraw ; | |
e7549107 SC |
262 | |
263 | int m_x ; | |
264 | int m_y ; | |
265 | int m_width ; | |
266 | int m_height ; | |
267 | ||
268 | wxScrollBar* m_hScrollBar ; | |
269 | wxScrollBar* m_vScrollBar ; | |
270 | wxString m_label ; | |
271 | ||
272 | void MacCreateScrollBars( long style ) ; | |
273 | void MacRepositionScrollBars() ; | |
519cb848 SC |
274 | |
275 | // additional (MSW specific) flags | |
276 | bool m_useCtl3D:1; // Using CTL3D for this control | |
277 | bool m_backgroundTransparent:1; | |
278 | bool m_mouseInWindow:1; | |
279 | bool m_doubleClickAllowed:1; | |
280 | bool m_winCaptured:1; | |
281 | ||
282 | // the size of one page for scrolling | |
283 | int m_xThumbSize; | |
284 | int m_yThumbSize; | |
285 | ||
e7549107 | 286 | // WXHMENU m_hMenu; // Menu, if any |
519cb848 SC |
287 | |
288 | // implement the base class pure virtuals | |
289 | virtual void DoClientToScreen( int *x, int *y ) const; | |
290 | virtual void DoScreenToClient( int *x, int *y ) const; | |
291 | virtual void DoGetPosition( int *x, int *y ) const; | |
292 | virtual void DoGetSize( int *width, int *height ) const; | |
293 | virtual void DoGetClientSize( int *width, int *height ) const; | |
294 | virtual void DoSetSize(int x, int y, | |
295 | int width, int height, | |
296 | int sizeFlags = wxSIZE_AUTO); | |
297 | virtual void DoSetClientSize(int width, int height); | |
298 | ||
519cb848 SC |
299 | // move the window to the specified location and resize it: this is called |
300 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
301 | // ::MoveWindow() except for composite controls which will want to arrange | |
302 | // themselves inside the given rectangle | |
303 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
304 | ||
305 | #if wxUSE_TOOLTIPS | |
306 | virtual void DoSetToolTip( wxToolTip *tip ); | |
307 | #endif // wxUSE_TOOLTIPS | |
0dbd6262 | 308 | |
519cb848 SC |
309 | private: |
310 | // common part of all ctors | |
311 | void Init(); | |
0dbd6262 | 312 | |
e766c8a9 | 313 | DECLARE_NO_COPY_CLASS(wxWindowMac) |
519cb848 | 314 | DECLARE_EVENT_TABLE() |
0dbd6262 SC |
315 | }; |
316 | ||
05adb9d2 | 317 | /* |
519cb848 SC |
318 | class wxMacFocusHelper |
319 | { | |
320 | public : | |
e766c8a9 | 321 | wxMacFocusHelper( wxWindowMac * theWindow ) ; |
519cb848 SC |
322 | ~wxMacFocusHelper() ; |
323 | bool Ok() { return m_ok ; } | |
324 | ||
325 | private : | |
326 | GrafPtr m_formerPort ; | |
327 | GrafPtr m_currentPort ; | |
328 | bool m_ok ; | |
329 | } ; | |
05adb9d2 | 330 | */ |
519cb848 SC |
331 | |
332 | class wxMacDrawingHelper | |
333 | { | |
334 | public : | |
e766c8a9 | 335 | wxMacDrawingHelper( wxWindowMac * theWindow ) ; |
519cb848 SC |
336 | ~wxMacDrawingHelper() ; |
337 | bool Ok() { return m_ok ; } | |
338 | ||
339 | private : | |
340 | GrafPtr m_formerPort ; | |
341 | GrafPtr m_currentPort ; | |
342 | PenState m_savedPenState ; | |
343 | bool m_ok ; | |
344 | } ; | |
05adb9d2 | 345 | /* |
519cb848 SC |
346 | class wxMacFocusClientHelper |
347 | { | |
348 | public : | |
e766c8a9 | 349 | wxMacFocusClientHelper( wxWindowMac * theWindow ) ; |
519cb848 SC |
350 | ~wxMacFocusClientHelper() ; |
351 | bool Ok() { return m_ok ; } | |
352 | ||
353 | private : | |
354 | GrafPtr m_formerPort ; | |
355 | GrafPtr m_currentPort ; | |
356 | bool m_ok ; | |
357 | } ; | |
05adb9d2 | 358 | */ |
519cb848 SC |
359 | class wxMacDrawingClientHelper |
360 | { | |
361 | public : | |
e766c8a9 | 362 | wxMacDrawingClientHelper( wxWindowMac * theWindow ) ; |
519cb848 SC |
363 | ~wxMacDrawingClientHelper() ; |
364 | bool Ok() { return m_ok ; } | |
365 | ||
366 | private : | |
367 | GrafPtr m_formerPort ; | |
368 | GrafPtr m_currentPort ; | |
369 | PenState m_savedPenState ; | |
370 | bool m_ok ; | |
371 | } ; | |
0dbd6262 SC |
372 | |
373 | #endif | |
374 | // _WX_WINDOW_H_ |