]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/window.h
A few tweaks and cleanups
[wxWidgets.git] / include / wx / mac / window.h
CommitLineData
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 24class WXDLLEXPORT wxButton;
e7549107 25class WXDLLEXPORT wxScrollBar;
88594d02 26class WXDLLEXPORT wxTopLevelWindowMac;
0dbd6262 27
519cb848
SC
28// ---------------------------------------------------------------------------
29// constants
30// ---------------------------------------------------------------------------
0dbd6262 31
e766c8a9 32class WXDLLEXPORT wxWindowMac: public wxWindowBase
0dbd6262 33{
a1260bfc 34 DECLARE_DYNAMIC_CLASS(wxWindowMac)
0dbd6262
SC
35
36 friend class wxDC;
37 friend class wxPaintDC;
38
39public:
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
175public:
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 206public :
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 ) ;
412633c4
SC
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 );
5b36f53b 215 virtual void MacPaintBorders( int left , int top ) ;
5273bf2f 216 WXWindow MacGetRootWindow() const ;
88594d02 217 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
e7549107 218
5273bf2f 219 virtual WXWidget MacGetContainerForEmbedding() ;
5b781a67
SC
220
221 virtual long MacGetLeftBorderSize() const ;
222 virtual long MacGetRightBorderSize() const ;
223 virtual long MacGetTopBorderSize() const ;
224 virtual long MacGetBottomBorderSize() const ;
225
05adb9d2 226 static long MacRemoveBordersFromStyle( long style ) ;
e7549107 227 virtual void MacSuperChangedPosition() ;
4bf3cd97 228 virtual void MacTopLevelWindowChangedPosition() ;
8208e181 229 virtual void MacSuperShown( bool show ) ;
88594d02 230 virtual void MacSuperEnabled( bool enable ) ;
c809f3be 231 bool MacIsReallyShown() const ;
88594d02
SC
232 virtual void Update() ;
233 // for compatibility
234 void MacUpdateImmediately() { Update() ; }
235
24912802
SC
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) ;
755d980d
SC
239 const wxBrush& MacGetBackgroundBrush() ;
240 const wxRegion& MacGetVisibleRegion() ;
7c74e7fe 241 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
e766c8a9 242 static wxWindowMac* s_lastMouseWindow ;
e7549107 243private:
0dbd6262 244protected:
88594d02
SC
245// RgnHandle m_macUpdateRgn ;
246// bool m_macEraseOnRedraw ;
755d980d
SC
247 wxBrush m_macBackgroundBrush ;
248 wxRegion m_macVisibleRegion ;
e7549107
SC
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() ;
519cb848
SC
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
e7549107 272// WXHMENU m_hMenu; // Menu, if any
519cb848
SC
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
4116c221
VZ
285 virtual void DoCaptureMouse();
286 virtual void DoReleaseMouse();
287
519cb848
SC
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
0dbd6262 297
519cb848
SC
298private:
299 // common part of all ctors
300 void Init();
0dbd6262 301
e766c8a9 302 DECLARE_NO_COPY_CLASS(wxWindowMac)
519cb848 303 DECLARE_EVENT_TABLE()
0dbd6262
SC
304};
305
0dbd6262
SC
306#endif
307 // _WX_WINDOW_H_