]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/classic/window.h
added a couple of base classes
[wxWidgets.git] / include / wx / mac / classic / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/window.h
3 // Purpose: wxWindowMac class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #include "wx/brush.h"
16
17 // ---------------------------------------------------------------------------
18 // forward declarations
19 // ---------------------------------------------------------------------------
20
21 class WXDLLEXPORT wxButton;
22 class WXDLLEXPORT wxScrollBar;
23 class WXDLLEXPORT wxTopLevelWindowMac;
24
25 // ---------------------------------------------------------------------------
26 // constants
27 // ---------------------------------------------------------------------------
28
29 class WXDLLEXPORT wxWindowMac: public wxWindowBase
30 {
31 DECLARE_DYNAMIC_CLASS(wxWindowMac)
32
33 friend class wxDC;
34 friend class wxPaintDC;
35
36 public:
37
38 wxWindowMac()
39 : m_macBackgroundBrush()
40 , m_macVisibleRegion()
41 , m_x(0), m_y(0), m_width(0), m_height(0)
42 , m_hScrollBar(NULL), m_vScrollBar(NULL)
43 , m_label(wxEmptyString)
44 { Init(); }
45
46 wxWindowMac(wxWindowMac *parent,
47 wxWindowID id,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 long style = 0,
51 const wxString& name = wxPanelNameStr)
52 {
53 Init();
54 Create(parent, id, pos, size, style, name);
55 }
56
57 virtual ~wxWindowMac();
58
59 bool Create(wxWindowMac *parent,
60 wxWindowID id,
61 const wxPoint& pos = wxDefaultPosition,
62 const wxSize& size = wxDefaultSize,
63 long style = 0,
64 const wxString& name = wxPanelNameStr);
65
66
67 // implement base class pure virtuals
68 virtual void SetLabel( const wxString& title);
69 virtual wxString GetLabel() const;
70
71 virtual void Raise();
72 virtual void Lower();
73
74 virtual bool Show( bool show = true );
75 virtual bool Enable( bool enable = true );
76
77 virtual void SetFocus();
78
79 virtual void WarpPointer(int x, int y);
80
81 virtual void Refresh( bool eraseBackground = true,
82 const wxRect *rect = (const wxRect *) NULL );
83
84 virtual bool SetCursor( const wxCursor &cursor );
85 virtual bool SetFont(const wxFont& font)
86 { return wxWindowBase::SetFont(font); }
87 virtual int GetCharHeight() const;
88 virtual int GetCharWidth() const;
89 virtual void GetTextExtent(const wxString& string,
90 int *x, int *y,
91 int *descent = (int *) NULL,
92 int *externalLeading = (int *) NULL,
93 const wxFont *theFont = (const wxFont *) NULL)
94 const;
95
96 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
97
98 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
99 int range, bool refresh = true );
100 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
101 virtual int GetScrollPos( int orient ) const;
102 virtual int GetScrollThumb( int orient ) const;
103 virtual int GetScrollRange( int orient ) const;
104 virtual void ScrollWindow( int dx, int dy,
105 const wxRect* rect = (wxRect *) NULL );
106
107 #if wxUSE_DRAG_AND_DROP
108 virtual void SetDropTarget( wxDropTarget *dropTarget );
109 #endif // wxUSE_DRAG_AND_DROP
110
111 // Accept files for dragging
112 virtual void DragAcceptFiles(bool accept);
113
114 // Native resource loading (implemented in src/msw/nativdlg.cpp)
115 // FIXME: should they really be all virtual?
116 wxWindowMac* GetWindowChild1(wxWindowID id);
117 wxWindowMac* GetWindowChild(wxWindowID id);
118
119 // implementation from now on
120 // --------------------------
121
122 void MacClientToRootWindow( int *x , int *y ) const ;
123 void MacRootWindowToClient( int *x , int *y ) const ;
124 void MacWindowToRootWindow( int *x , int *y ) const ;
125 void MacRootWindowToWindow( int *x , int *y ) const ;
126
127 virtual wxString MacGetToolTipString( wxPoint &where ) ;
128
129 // simple accessors
130 // ----------------
131
132 // WXHWND GetHWND() const { return m_hWnd; }
133 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
134 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
135
136 bool GetTransparentBackground() const { return m_backgroundTransparent; }
137 void SetTransparent(bool t = true) { m_backgroundTransparent = t; }
138
139 // event handlers
140 // --------------
141 void OnSetFocus(wxFocusEvent& event) ;
142 void OnNcPaint(wxNcPaintEvent& event);
143 void OnEraseBackground(wxEraseEvent& event);
144 void OnMouseEvent( wxMouseEvent &event ) ;
145
146 void MacOnScroll(wxScrollEvent&event ) ;
147
148 bool AcceptsFocus() const ;
149
150 public:
151 void OnInternalIdle();
152
153 // For implementation purposes - sometimes decorations make the client area
154 // smaller
155 virtual wxPoint GetClientAreaOrigin() const;
156
157 wxWindowMac *FindItem(long id) const;
158 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
159
160 // Make a Windows extended style from the given wxWidgets window style
161 static WXDWORD MakeExtendedStyle(long style,
162 bool eliminateBorders = true);
163 // Determine whether 3D effects are wanted
164 WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
165
166 // MSW only: true if this control is part of the main control
167 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; };
168
169 // Setup background and foreground colours correctly
170 virtual void SetupColours();
171
172 public:
173 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ;
174 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ;
175 virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
176 virtual bool MacCanFocus() const { return true ; }
177
178 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
179 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
180 virtual void RemoveChild( wxWindowBase *child );
181 virtual void MacPaintBorders( int left , int top ) ;
182 WXWindow MacGetRootWindow() const ;
183 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
184
185 virtual WXWidget MacGetContainerForEmbedding() ;
186
187 virtual long MacGetLeftBorderSize() const ;
188 virtual long MacGetRightBorderSize() const ;
189 virtual long MacGetTopBorderSize() const ;
190 virtual long MacGetBottomBorderSize() const ;
191
192 static long MacRemoveBordersFromStyle( long style ) ;
193 virtual void MacSuperChangedPosition() ;
194 // the absolute coordinates of this item within the toplevel window may have changed
195 virtual void MacUpdateDimensions() {}
196 // the absolute coortinates of this window's root have changed
197 virtual void MacTopLevelWindowChangedPosition() ;
198 virtual void MacSuperShown( bool show ) ;
199 virtual void MacSuperEnabled( bool enable ) ;
200 bool MacIsReallyShown() const ;
201 virtual void Update() ;
202 // for compatibility
203 void MacUpdateImmediately() { Update() ; }
204 virtual bool MacSetupCursor( const wxPoint& pt ) ;
205
206 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
207 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
208 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
209 const wxBrush& MacGetBackgroundBrush() ;
210 const wxRegion& MacGetVisibleRegion( bool respectChildrenAndSiblings = true ) ;
211 bool MacIsWindowScrollbar( const wxScrollBar* sb )
212 { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
213 static wxWindowMac* s_lastMouseWindow ;
214 private:
215 protected:
216 wxBrush m_macBackgroundBrush ;
217 wxRegion m_macVisibleRegion ;
218 int m_x ;
219 int m_y ;
220 int m_width ;
221 int m_height ;
222
223 wxScrollBar* m_hScrollBar ;
224 wxScrollBar* m_vScrollBar ;
225 wxString m_label ;
226
227 void MacCreateScrollBars( long style ) ;
228 void MacRepositionScrollBars() ;
229
230 bool m_backgroundTransparent ;
231
232 // implement the base class pure virtuals
233 virtual void DoClientToScreen( int *x, int *y ) const;
234 virtual void DoScreenToClient( int *x, int *y ) const;
235 virtual void DoGetPosition( int *x, int *y ) const;
236 virtual void DoGetSize( int *width, int *height ) const;
237 virtual void DoGetClientSize( int *width, int *height ) const;
238 virtual void DoSetSize(int x, int y,
239 int width, int height,
240 int sizeFlags = wxSIZE_AUTO);
241 virtual void DoSetClientSize(int width, int height);
242
243 virtual void DoCaptureMouse();
244 virtual void DoReleaseMouse();
245
246 // move the window to the specified location and resize it: this is called
247 // from both DoSetSize() and DoSetClientSize() and would usually just call
248 // ::MoveWindow() except for composite controls which will want to arrange
249 // themselves inside the given rectangle
250 virtual void DoMoveWindow(int x, int y, int width, int height);
251
252 #if wxUSE_TOOLTIPS
253 virtual void DoSetToolTip( wxToolTip *tip );
254 #endif // wxUSE_TOOLTIPS
255
256 private:
257 // common part of all ctors
258 void Init();
259
260 DECLARE_NO_COPY_CLASS(wxWindowMac)
261 DECLARE_EVENT_TABLE()
262 };
263
264 #endif
265 // _WX_WINDOW_H_