]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: window.h | |
3 | // Purpose: wxWindowMac class | |
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 | ||
19 | // --------------------------------------------------------------------------- | |
20 | // forward declarations | |
21 | // --------------------------------------------------------------------------- | |
22 | ||
23 | class WXDLLEXPORT wxButton; | |
24 | class WXDLLEXPORT wxScrollBar; | |
25 | class WXDLLEXPORT wxTopLevelWindowMac; | |
26 | ||
27 | // --------------------------------------------------------------------------- | |
28 | // constants | |
29 | // --------------------------------------------------------------------------- | |
30 | ||
31 | // FIXME does anybody use those? they're unused by wxWindows... | |
32 | enum | |
33 | { | |
34 | wxKEY_SHIFT = 1, | |
35 | wxKEY_CTRL = 2 | |
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 | ||
47 | wxWindowMac() { Init(); } | |
48 | ||
49 | wxWindowMac(wxWindowMac *parent, | |
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 | ||
60 | virtual ~wxWindowMac(); | |
61 | ||
62 | bool Create(wxWindowMac *parent, | |
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 | ||
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 ); | |
91 | virtual bool SetFont(const wxFont& font) | |
92 | { return wxWindowBase::SetFont(font); } | |
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 | ||
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 | |
129 | virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event); | |
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? | |
149 | wxWindowMac* GetWindowChild1(wxWindowID id); | |
150 | wxWindowMac* GetWindowChild(wxWindowID id); | |
151 | ||
152 | // implementation from now on | |
153 | // -------------------------- | |
154 | ||
155 | void MacClientToRootWindow( int *x , int *y ) const ; | |
156 | void MacRootWindowToClient( int *x , int *y ) const ; | |
157 | void MacWindowToRootWindow( int *x , int *y ) const ; | |
158 | void MacRootWindowToWindow( int *x , int *y ) const ; | |
159 | ||
160 | virtual wxString MacGetToolTipString( wxPoint &where ) ; | |
161 | ||
162 | // simple accessors | |
163 | // ---------------- | |
164 | ||
165 | // WXHWND GetHWND() const { return m_hWnd; } | |
166 | // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
167 | virtual WXWidget GetHandle() const { return (WXWidget) NULL ; } | |
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 | // -------------- | |
175 | void OnSetFocus(wxFocusEvent& event) ; | |
176 | void OnNcPaint(wxNcPaintEvent& event); | |
177 | void OnEraseBackground(wxEraseEvent& event); | |
178 | void OnIdle(wxIdleEvent& event); | |
179 | void MacOnScroll(wxScrollEvent&event ) ; | |
180 | ||
181 | bool AcceptsFocus() const ; | |
182 | ||
183 | public: | |
184 | // For implementation purposes - sometimes decorations make the client area | |
185 | // smaller | |
186 | virtual wxPoint GetClientAreaOrigin() const; | |
187 | ||
188 | wxWindowMac *FindItem(long id) const; | |
189 | wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; | |
190 | ||
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; | |
196 | ||
197 | // MSW only: TRUE if this control is part of the main control | |
198 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
199 | ||
200 | #if WXWIN_COMPATIBILITY | |
201 | wxObject *GetChild(int number) const; | |
202 | virtual void MSWDeviceToLogical(float *x, float *y) const; | |
203 | #endif // WXWIN_COMPATIBILITY | |
204 | ||
205 | // Setup background and foreground colours correctly | |
206 | virtual void SetupColours(); | |
207 | ||
208 | ||
209 | #if WXWIN_COMPATIBILITY | |
210 | void SetShowing(bool show) { (void)Show(show); } | |
211 | bool IsUserEnabled() const { return IsEnabled(); } | |
212 | #endif // WXWIN_COMPATIBILITY | |
213 | ||
214 | public : | |
215 | static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ; | |
216 | virtual void MacRedraw( RgnHandle updatergn , long time , bool erase) ; | |
217 | virtual bool MacCanFocus() const { return true ; } | |
218 | ||
219 | virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ; | |
220 | ||
221 | virtual void MacPaintBorders() ; | |
222 | WindowRef MacGetRootWindow() const ; | |
223 | wxTopLevelWindowMac* MacGetTopLevelWindow() const ; | |
224 | ||
225 | virtual ControlHandle MacGetContainerForEmbedding() ; | |
226 | ||
227 | virtual long MacGetLeftBorderSize() const ; | |
228 | virtual long MacGetRightBorderSize() const ; | |
229 | virtual long MacGetTopBorderSize() const ; | |
230 | virtual long MacGetBottomBorderSize() const ; | |
231 | ||
232 | static long MacRemoveBordersFromStyle( long style ) ; | |
233 | virtual void MacSuperChangedPosition() ; | |
234 | virtual void MacTopLevelWindowChangedPosition() ; | |
235 | virtual void MacSuperShown( bool show ) ; | |
236 | virtual void MacSuperEnabled( bool enable ) ; | |
237 | bool MacIsReallyShown() const ; | |
238 | virtual void Update() ; | |
239 | // for compatibility | |
240 | void MacUpdateImmediately() { Update() ; } | |
241 | ||
242 | /* | |
243 | bool MacSetupFocusPort() ; | |
244 | bool MacSetupDrawingPort() ; | |
245 | bool MacSetupFocusClientPort() ; | |
246 | bool MacSetupDrawingClientPort() ; | |
247 | */ | |
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 ) ; | |
250 | ||
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) ; | |
254 | ||
255 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } | |
256 | static wxWindowMac* s_lastMouseWindow ; | |
257 | private: | |
258 | virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ; | |
259 | protected: | |
260 | // RgnHandle m_macUpdateRgn ; | |
261 | // bool m_macEraseOnRedraw ; | |
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() ; | |
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 | ||
286 | // WXHMENU m_hMenu; // Menu, if any | |
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 | ||
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 | |
308 | ||
309 | private: | |
310 | // common part of all ctors | |
311 | void Init(); | |
312 | ||
313 | DECLARE_NO_COPY_CLASS(wxWindowMac) | |
314 | DECLARE_EVENT_TABLE() | |
315 | }; | |
316 | ||
317 | /* | |
318 | class wxMacFocusHelper | |
319 | { | |
320 | public : | |
321 | wxMacFocusHelper( wxWindowMac * theWindow ) ; | |
322 | ~wxMacFocusHelper() ; | |
323 | bool Ok() { return m_ok ; } | |
324 | ||
325 | private : | |
326 | GrafPtr m_formerPort ; | |
327 | GrafPtr m_currentPort ; | |
328 | bool m_ok ; | |
329 | } ; | |
330 | */ | |
331 | ||
332 | class wxMacDrawingHelper | |
333 | { | |
334 | public : | |
335 | wxMacDrawingHelper( wxWindowMac * theWindow ) ; | |
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 | } ; | |
345 | /* | |
346 | class wxMacFocusClientHelper | |
347 | { | |
348 | public : | |
349 | wxMacFocusClientHelper( wxWindowMac * theWindow ) ; | |
350 | ~wxMacFocusClientHelper() ; | |
351 | bool Ok() { return m_ok ; } | |
352 | ||
353 | private : | |
354 | GrafPtr m_formerPort ; | |
355 | GrafPtr m_currentPort ; | |
356 | bool m_ok ; | |
357 | } ; | |
358 | */ | |
359 | class wxMacDrawingClientHelper | |
360 | { | |
361 | public : | |
362 | wxMacDrawingClientHelper( wxWindowMac * theWindow ) ; | |
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 | } ; | |
372 | ||
373 | #endif | |
374 | // _WX_WINDOW_H_ |