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