]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mac/window.h
A few tweaks and cleanups
[wxWidgets.git] / include / wx / mac / window.h
... / ...
CommitLineData
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#include <wx/brush.h>
20// ---------------------------------------------------------------------------
21// forward declarations
22// ---------------------------------------------------------------------------
23
24class WXDLLEXPORT wxButton;
25class WXDLLEXPORT wxScrollBar;
26class WXDLLEXPORT wxTopLevelWindowMac;
27
28// ---------------------------------------------------------------------------
29// constants
30// ---------------------------------------------------------------------------
31
32class WXDLLEXPORT wxWindowMac: public wxWindowBase
33{
34 DECLARE_DYNAMIC_CLASS(wxWindowMac)
35
36 friend class wxDC;
37 friend class wxPaintDC;
38
39public:
40
41 wxWindowMac() { Init(); }
42
43 wxWindowMac(wxWindowMac *parent,
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
54 virtual ~wxWindowMac();
55
56 bool Create(wxWindowMac *parent,
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
76 virtual void WarpPointer(int x, int y);
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 );
83 virtual bool SetFont(const wxFont& font)
84 { return wxWindowBase::SetFont(font); }
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 );
104
105#if wxUSE_DRAG_AND_DROP
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
121 virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event);
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?
141 wxWindowMac* GetWindowChild1(wxWindowID id);
142 wxWindowMac* GetWindowChild(wxWindowID id);
143
144 // implementation from now on
145 // --------------------------
146
147 void MacClientToRootWindow( int *x , int *y ) const ;
148 void MacRootWindowToClient( int *x , int *y ) const ;
149 void MacWindowToRootWindow( int *x , int *y ) const ;
150 void MacRootWindowToWindow( int *x , int *y ) const ;
151
152 virtual wxString MacGetToolTipString( wxPoint &where ) ;
153
154 // simple accessors
155 // ----------------
156
157// WXHWND GetHWND() const { return m_hWnd; }
158// void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
159 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
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 // --------------
167 void OnSetFocus(wxFocusEvent& event) ;
168 void OnNcPaint(wxNcPaintEvent& event);
169 void OnEraseBackground(wxEraseEvent& event);
170 void OnIdle(wxIdleEvent& event);
171 void MacOnScroll(wxScrollEvent&event ) ;
172
173 bool AcceptsFocus() const ;
174
175public:
176 // For implementation purposes - sometimes decorations make the client area
177 // smaller
178 virtual wxPoint GetClientAreaOrigin() const;
179
180 wxWindowMac *FindItem(long id) const;
181 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
182
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;
188
189 // MSW only: TRUE if this control is part of the main control
190 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
191
192 #if WXWIN_COMPATIBILITY
193 wxObject *GetChild(int number) const;
194 virtual void MSWDeviceToLogical(float *x, float *y) const;
195#endif // WXWIN_COMPATIBILITY
196
197 // Setup background and foreground colours correctly
198 virtual void SetupColours();
199
200
201#if WXWIN_COMPATIBILITY
202 void SetShowing(bool show) { (void)Show(show); }
203 bool IsUserEnabled() const { return IsEnabled(); }
204#endif // WXWIN_COMPATIBILITY
205
206public :
207 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ;
208 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ;
209 virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
210 virtual bool MacCanFocus() const { return true ; }
211
212 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
213 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
214 virtual void RemoveChild( wxWindowBase *child );
215 virtual void MacPaintBorders( int left , int top ) ;
216 WXWindow MacGetRootWindow() const ;
217 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
218
219 virtual WXWidget MacGetContainerForEmbedding() ;
220
221 virtual long MacGetLeftBorderSize() const ;
222 virtual long MacGetRightBorderSize() const ;
223 virtual long MacGetTopBorderSize() const ;
224 virtual long MacGetBottomBorderSize() const ;
225
226 static long MacRemoveBordersFromStyle( long style ) ;
227 virtual void MacSuperChangedPosition() ;
228 virtual void MacTopLevelWindowChangedPosition() ;
229 virtual void MacSuperShown( bool show ) ;
230 virtual void MacSuperEnabled( bool enable ) ;
231 bool MacIsReallyShown() const ;
232 virtual void Update() ;
233 // for compatibility
234 void MacUpdateImmediately() { Update() ; }
235
236// virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
237// virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
238// virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
239 const wxBrush& MacGetBackgroundBrush() ;
240 const wxRegion& MacGetVisibleRegion() ;
241 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
242 static wxWindowMac* s_lastMouseWindow ;
243private:
244protected:
245// RgnHandle m_macUpdateRgn ;
246// bool m_macEraseOnRedraw ;
247 wxBrush m_macBackgroundBrush ;
248 wxRegion m_macVisibleRegion ;
249 int m_x ;
250 int m_y ;
251 int m_width ;
252 int m_height ;
253
254 wxScrollBar* m_hScrollBar ;
255 wxScrollBar* m_vScrollBar ;
256 wxString m_label ;
257
258 void MacCreateScrollBars( long style ) ;
259 void MacRepositionScrollBars() ;
260
261 // additional (MSW specific) flags
262 bool m_useCtl3D:1; // Using CTL3D for this control
263 bool m_backgroundTransparent:1;
264 bool m_mouseInWindow:1;
265 bool m_doubleClickAllowed:1;
266 bool m_winCaptured:1;
267
268 // the size of one page for scrolling
269 int m_xThumbSize;
270 int m_yThumbSize;
271
272// WXHMENU m_hMenu; // Menu, if any
273
274 // implement the base class pure virtuals
275 virtual void DoClientToScreen( int *x, int *y ) const;
276 virtual void DoScreenToClient( int *x, int *y ) const;
277 virtual void DoGetPosition( int *x, int *y ) const;
278 virtual void DoGetSize( int *width, int *height ) const;
279 virtual void DoGetClientSize( int *width, int *height ) const;
280 virtual void DoSetSize(int x, int y,
281 int width, int height,
282 int sizeFlags = wxSIZE_AUTO);
283 virtual void DoSetClientSize(int width, int height);
284
285 virtual void DoCaptureMouse();
286 virtual void DoReleaseMouse();
287
288 // move the window to the specified location and resize it: this is called
289 // from both DoSetSize() and DoSetClientSize() and would usually just call
290 // ::MoveWindow() except for composite controls which will want to arrange
291 // themselves inside the given rectangle
292 virtual void DoMoveWindow(int x, int y, int width, int height);
293
294#if wxUSE_TOOLTIPS
295 virtual void DoSetToolTip( wxToolTip *tip );
296#endif // wxUSE_TOOLTIPS
297
298private:
299 // common part of all ctors
300 void Init();
301
302 DECLARE_NO_COPY_CLASS(wxWindowMac)
303 DECLARE_EVENT_TABLE()
304};
305
306#endif
307 // _WX_WINDOW_H_