]>
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 | ||
af49c4b8 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
0dbd6262 SC |
16 | #pragma interface "window.h" |
17 | #endif | |
18 | ||
755d980d | 19 | #include <wx/brush.h> |
519cb848 SC |
20 | // --------------------------------------------------------------------------- |
21 | // forward declarations | |
22 | // --------------------------------------------------------------------------- | |
0dbd6262 | 23 | |
519cb848 | 24 | class WXDLLEXPORT wxButton; |
e7549107 | 25 | class WXDLLEXPORT wxScrollBar; |
88594d02 | 26 | class WXDLLEXPORT wxTopLevelWindowMac; |
0dbd6262 | 27 | |
519cb848 SC |
28 | // --------------------------------------------------------------------------- |
29 | // constants | |
30 | // --------------------------------------------------------------------------- | |
0dbd6262 | 31 | |
e766c8a9 | 32 | class WXDLLEXPORT wxWindowMac: public wxWindowBase |
0dbd6262 | 33 | { |
ba161d7e GD |
34 | DECLARE_DYNAMIC_CLASS(wxWindowMac) |
35 | ||
36 | friend class wxDC; | |
37 | friend class wxPaintDC; | |
38 | ||
0dbd6262 | 39 | public: |
519cb848 | 40 | |
ba161d7e GD |
41 | wxWindowMac() |
42 | : m_macBackgroundBrush() | |
43 | , m_macVisibleRegion() | |
44 | , m_x(0), m_y(0), m_width(0), m_height(0) | |
45 | , m_hScrollBar(NULL), m_vScrollBar(NULL) | |
46 | , m_label(wxEmptyString) | |
47 | { Init(); } | |
519cb848 | 48 | |
e766c8a9 | 49 | wxWindowMac(wxWindowMac *parent, |
ba161d7e GD |
50 | wxWindowID id, |
51 | const wxPoint& pos = wxDefaultPosition, | |
52 | const wxSize& size = wxDefaultSize, | |
53 | long style = 0, | |
54 | const wxString& name = wxPanelNameStr) | |
519cb848 SC |
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 | 82 | virtual void WarpPointer(int x, int y); |
519cb848 SC |
83 | |
84 | virtual void Refresh( bool eraseBackground = TRUE, | |
85 | const wxRect *rect = (const wxRect *) NULL ); | |
86 | virtual void Clear(); | |
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 ; | |
05adb9d2 | 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; } | |
165 | virtual WXWidget GetHandle() const { return (WXWidget) NULL ; } | |
519cb848 SC |
166 | |
167 | bool GetUseCtl3D() const { return m_useCtl3D; } | |
168 | bool GetTransparentBackground() const { return m_backgroundTransparent; } | |
169 | void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } | |
170 | ||
171 | // event handlers | |
172 | // -------------- | |
7810c95b | 173 | void OnSetFocus(wxFocusEvent& event) ; |
88594d02 | 174 | void OnNcPaint(wxNcPaintEvent& event); |
519cb848 SC |
175 | void OnEraseBackground(wxEraseEvent& event); |
176 | void OnIdle(wxIdleEvent& event); | |
7c74e7fe | 177 | void MacOnScroll(wxScrollEvent&event ) ; |
4765d335 SC |
178 | |
179 | bool AcceptsFocus() const ; | |
0dbd6262 | 180 | |
519cb848 SC |
181 | public: |
182 | // For implementation purposes - sometimes decorations make the client area | |
183 | // smaller | |
184 | virtual wxPoint GetClientAreaOrigin() const; | |
0dbd6262 | 185 | |
e766c8a9 SC |
186 | wxWindowMac *FindItem(long id) const; |
187 | wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; | |
0dbd6262 | 188 | |
519cb848 SC |
189 | // Make a Windows extended style from the given wxWindows window style |
190 | static WXDWORD MakeExtendedStyle(long style, | |
191 | bool eliminateBorders = TRUE); | |
192 | // Determine whether 3D effects are wanted | |
193 | WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const; | |
0dbd6262 | 194 | |
519cb848 SC |
195 | // MSW only: TRUE if this control is part of the main control |
196 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
0dbd6262 | 197 | |
519cb848 SC |
198 | #if WXWIN_COMPATIBILITY |
199 | wxObject *GetChild(int number) const; | |
200 | virtual void MSWDeviceToLogical(float *x, float *y) const; | |
201 | #endif // WXWIN_COMPATIBILITY | |
0dbd6262 | 202 | |
519cb848 SC |
203 | // Setup background and foreground colours correctly |
204 | virtual void SetupColours(); | |
0dbd6262 | 205 | |
0dbd6262 | 206 | |
519cb848 SC |
207 | #if WXWIN_COMPATIBILITY |
208 | void SetShowing(bool show) { (void)Show(show); } | |
209 | bool IsUserEnabled() const { return IsEnabled(); } | |
210 | #endif // WXWIN_COMPATIBILITY | |
0dbd6262 | 211 | |
ba161d7e GD |
212 | public: |
213 | static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ; | |
214 | virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ; | |
215 | virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ; | |
216 | virtual bool MacCanFocus() const { return true ; } | |
217 | ||
218 | virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ; | |
219 | // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren | |
220 | virtual void RemoveChild( wxWindowBase *child ); | |
221 | virtual void MacPaintBorders( int left , int top ) ; | |
222 | WXWindow MacGetRootWindow() const ; | |
223 | wxTopLevelWindowMac* MacGetTopLevelWindow() const ; | |
224 | ||
225 | virtual WXWidget 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() ; | |
c05a5f07 SC |
234 | // the absolute coordinates of this item within the toplevel window may have changed |
235 | virtual void MacUpdateDimensions() {} | |
236 | // the absolute coortinates of this window's root have changed | |
ba161d7e GD |
237 | virtual void MacTopLevelWindowChangedPosition() ; |
238 | virtual void MacSuperShown( bool show ) ; | |
239 | virtual void MacSuperEnabled( bool enable ) ; | |
240 | bool MacIsReallyShown() const ; | |
241 | virtual void Update() ; | |
242 | // for compatibility | |
243 | void MacUpdateImmediately() { Update() ; } | |
7e2eb710 | 244 | bool MacSetupCursor( const wxPoint& pt ) ; |
ba161d7e GD |
245 | |
246 | // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ; | |
247 | // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ; | |
248 | // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ; | |
249 | const wxBrush& MacGetBackgroundBrush() ; | |
d835f05e | 250 | const wxRegion& MacGetVisibleRegion( bool respectChildrenAndSiblings = true ) ; |
ba161d7e GD |
251 | bool MacIsWindowScrollbar( const wxScrollBar* sb ) |
252 | { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } | |
253 | static wxWindowMac* s_lastMouseWindow ; | |
e7549107 | 254 | private: |
0dbd6262 | 255 | protected: |
ba161d7e GD |
256 | // RgnHandle m_macUpdateRgn ; |
257 | // bool m_macEraseOnRedraw ; | |
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 SC |
271 | |
272 | // additional (MSW specific) flags | |
ba161d7e GD |
273 | bool m_useCtl3D:1; // Using CTL3D for this control |
274 | bool m_backgroundTransparent:1; | |
275 | bool m_mouseInWindow:1; | |
276 | bool m_doubleClickAllowed:1; | |
277 | bool m_winCaptured:1; | |
519cb848 SC |
278 | |
279 | // the size of one page for scrolling | |
ba161d7e GD |
280 | int m_xThumbSize; |
281 | int m_yThumbSize; | |
519cb848 | 282 | |
e7549107 | 283 | // WXHMENU m_hMenu; // Menu, if any |
519cb848 SC |
284 | |
285 | // implement the base class pure virtuals | |
286 | virtual void DoClientToScreen( int *x, int *y ) const; | |
287 | virtual void DoScreenToClient( int *x, int *y ) const; | |
288 | virtual void DoGetPosition( int *x, int *y ) const; | |
289 | virtual void DoGetSize( int *width, int *height ) const; | |
290 | virtual void DoGetClientSize( int *width, int *height ) const; | |
291 | virtual void DoSetSize(int x, int y, | |
292 | int width, int height, | |
293 | int sizeFlags = wxSIZE_AUTO); | |
294 | virtual void DoSetClientSize(int width, int height); | |
295 | ||
4116c221 VZ |
296 | virtual void DoCaptureMouse(); |
297 | virtual void DoReleaseMouse(); | |
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 | ||
0dbd6262 SC |
317 | #endif |
318 | // _WX_WINDOW_H_ |