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