]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/window.h
include "ToolUtils.h" for LoWord and friends
[wxWidgets.git] / include / wx / mac / window.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
e766c8a9 3// Purpose: wxWindowMac class
a31a5f85 4// Author: Stefan Csomor
0dbd6262 5// Modified by:
a31a5f85 6// Created: 1998-01-01
0dbd6262 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
e40298d5 9// Licence: wxWindows licence
0dbd6262
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WINDOW_H_
13#define _WX_WINDOW_H_
14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
0dbd6262
SC
16#pragma interface "window.h"
17#endif
18
57530dba
GD
19#include "wx/brush.h"
20
519cb848
SC
21// ---------------------------------------------------------------------------
22// forward declarations
23// ---------------------------------------------------------------------------
0dbd6262 24
519cb848 25class WXDLLEXPORT wxButton;
e7549107 26class WXDLLEXPORT wxScrollBar;
88594d02 27class WXDLLEXPORT wxTopLevelWindowMac;
0dbd6262 28
519cb848
SC
29// ---------------------------------------------------------------------------
30// constants
31// ---------------------------------------------------------------------------
0dbd6262 32
e766c8a9 33class WXDLLEXPORT wxWindowMac: public wxWindowBase
0dbd6262 34{
ba161d7e
GD
35 DECLARE_DYNAMIC_CLASS(wxWindowMac)
36
37 friend class wxDC;
38 friend class wxPaintDC;
39
0dbd6262 40public:
e40298d5 41
ba161d7e
GD
42 wxWindowMac()
43 : m_macBackgroundBrush()
44 , m_macVisibleRegion()
45 , m_x(0), m_y(0), m_width(0), m_height(0)
46 , m_hScrollBar(NULL), m_vScrollBar(NULL)
47 , m_label(wxEmptyString)
48 { Init(); }
519cb848 49
e766c8a9 50 wxWindowMac(wxWindowMac *parent,
ba161d7e
GD
51 wxWindowID id,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 long style = 0,
55 const wxString& name = wxPanelNameStr)
519cb848
SC
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 83 virtual void WarpPointer(int x, int y);
519cb848
SC
84
85 virtual void Refresh( bool eraseBackground = TRUE,
86 const wxRect *rect = (const wxRect *) NULL );
87 virtual void Clear();
88
89 virtual bool SetCursor( const wxCursor &cursor );
88594d02
SC
90 virtual bool SetFont(const wxFont& font)
91 { return wxWindowBase::SetFont(font); }
519cb848
SC
92 virtual int GetCharHeight() const;
93 virtual int GetCharWidth() const;
94 virtual void GetTextExtent(const wxString& string,
95 int *x, int *y,
96 int *descent = (int *) NULL,
97 int *externalLeading = (int *) NULL,
98 const wxFont *theFont = (const wxFont *) NULL)
99 const;
100
101 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
102
103 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
104 int range, bool refresh = TRUE );
105 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
106 virtual int GetScrollPos( int orient ) const;
107 virtual int GetScrollThumb( int orient ) const;
108 virtual int GetScrollRange( int orient ) const;
109 virtual void ScrollWindow( int dx, int dy,
110 const wxRect* rect = (wxRect *) NULL );
0dbd6262
SC
111
112#if wxUSE_DRAG_AND_DROP
519cb848
SC
113 virtual void SetDropTarget( wxDropTarget *dropTarget );
114#endif // wxUSE_DRAG_AND_DROP
115
116 // Accept files for dragging
117 virtual void DragAcceptFiles(bool accept);
118
119#if WXWIN_COMPATIBILITY
120 // Set/get scroll attributes
121 virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
122 virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
123 virtual int OldGetScrollRange(int orient) const;
124 virtual int GetScrollPage(int orient) const;
125
126 // event handlers
127 // Handle a control command
e766c8a9 128 virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event);
519cb848
SC
129
130 // Override to define new behaviour for default action (e.g. double
131 // clicking on a listbox)
132 virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
133#endif // WXWIN_COMPATIBILITY
134
135#if wxUSE_CARET && WXWIN_COMPATIBILITY
136 // caret manipulation (old MSW only functions, see wxCaret class for the
137 // new API)
138 void CreateCaret(int w, int h);
139 void CreateCaret(const wxBitmap *bitmap);
140 void DestroyCaret();
141 void ShowCaret(bool show);
142 void SetCaretPos(int x, int y);
143 void GetCaretPos(int *x, int *y) const;
144#endif // wxUSE_CARET
145
146 // Native resource loading (implemented in src/msw/nativdlg.cpp)
147 // FIXME: should they really be all virtual?
e766c8a9
SC
148 wxWindowMac* GetWindowChild1(wxWindowID id);
149 wxWindowMac* GetWindowChild(wxWindowID id);
519cb848
SC
150
151 // implementation from now on
152 // --------------------------
153
ba161d7e
GD
154 void MacClientToRootWindow( int *x , int *y ) const ;
155 void MacRootWindowToClient( int *x , int *y ) const ;
156 void MacWindowToRootWindow( int *x , int *y ) const ;
157 void MacRootWindowToWindow( int *x , int *y ) const ;
e40298d5 158
ba161d7e 159 virtual wxString MacGetToolTipString( wxPoint &where ) ;
519cb848
SC
160
161 // simple accessors
162 // ----------------
163
e7549107
SC
164// WXHWND GetHWND() const { return m_hWnd; }
165// void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
e40298d5 166 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
519cb848
SC
167
168 bool GetUseCtl3D() const { return m_useCtl3D; }
169 bool GetTransparentBackground() const { return m_backgroundTransparent; }
170 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
171
172 // event handlers
173 // --------------
e40298d5 174 void OnSetFocus(wxFocusEvent& event) ;
88594d02 175 void OnNcPaint(wxNcPaintEvent& event);
519cb848
SC
176 void OnEraseBackground(wxEraseEvent& event);
177 void OnIdle(wxIdleEvent& event);
853f8094
SC
178 void OnMouseEvent( wxMouseEvent &event ) ;
179
7c74e7fe 180 void MacOnScroll(wxScrollEvent&event ) ;
4765d335
SC
181
182 bool AcceptsFocus() const ;
0dbd6262 183
519cb848
SC
184public:
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
ba161d7e
GD
215public:
216 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ;
217 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ;
218 virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
219 virtual bool MacCanFocus() const { return true ; }
220
221 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
222 // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
223 virtual void RemoveChild( wxWindowBase *child );
224 virtual void MacPaintBorders( int left , int top ) ;
225 WXWindow MacGetRootWindow() const ;
226 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
227
228 virtual WXWidget MacGetContainerForEmbedding() ;
229
230 virtual long MacGetLeftBorderSize() const ;
231 virtual long MacGetRightBorderSize() const ;
232 virtual long MacGetTopBorderSize() const ;
233 virtual long MacGetBottomBorderSize() const ;
234
235 static long MacRemoveBordersFromStyle( long style ) ;
236 virtual void MacSuperChangedPosition() ;
c05a5f07 237 // the absolute coordinates of this item within the toplevel window may have changed
e40298d5 238 virtual void MacUpdateDimensions() {}
c05a5f07 239 // the absolute coortinates of this window's root have changed
ba161d7e
GD
240 virtual void MacTopLevelWindowChangedPosition() ;
241 virtual void MacSuperShown( bool show ) ;
242 virtual void MacSuperEnabled( bool enable ) ;
243 bool MacIsReallyShown() const ;
244 virtual void Update() ;
245 // for compatibility
246 void MacUpdateImmediately() { Update() ; }
2b5f62a0 247 virtual bool MacSetupCursor( const wxPoint& pt ) ;
ba161d7e
GD
248
249// virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
250// virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
251// virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
252 const wxBrush& MacGetBackgroundBrush() ;
d835f05e 253 const wxRegion& MacGetVisibleRegion( bool respectChildrenAndSiblings = true ) ;
ba161d7e
GD
254 bool MacIsWindowScrollbar( const wxScrollBar* sb )
255 { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
256 static wxWindowMac* s_lastMouseWindow ;
e7549107 257private:
0dbd6262 258protected:
ba161d7e
GD
259// RgnHandle m_macUpdateRgn ;
260// bool m_macEraseOnRedraw ;
261 wxBrush m_macBackgroundBrush ;
262 wxRegion m_macVisibleRegion ;
263 int m_x ;
264 int m_y ;
265 int m_width ;
266 int m_height ;
267
268 wxScrollBar* m_hScrollBar ;
269 wxScrollBar* m_vScrollBar ;
270 wxString m_label ;
271
272 void MacCreateScrollBars( long style ) ;
273 void MacRepositionScrollBars() ;
519cb848
SC
274
275 // additional (MSW specific) flags
ba161d7e
GD
276 bool m_useCtl3D:1; // Using CTL3D for this control
277 bool m_backgroundTransparent:1;
278 bool m_mouseInWindow:1;
279 bool m_doubleClickAllowed:1;
280 bool m_winCaptured:1;
519cb848
SC
281
282 // the size of one page for scrolling
ba161d7e
GD
283 int m_xThumbSize;
284 int m_yThumbSize;
519cb848 285
e7549107 286// WXHMENU m_hMenu; // Menu, if any
519cb848
SC
287
288 // implement the base class pure virtuals
289 virtual void DoClientToScreen( int *x, int *y ) const;
290 virtual void DoScreenToClient( int *x, int *y ) const;
291 virtual void DoGetPosition( int *x, int *y ) const;
292 virtual void DoGetSize( int *width, int *height ) const;
293 virtual void DoGetClientSize( int *width, int *height ) const;
294 virtual void DoSetSize(int x, int y,
295 int width, int height,
296 int sizeFlags = wxSIZE_AUTO);
297 virtual void DoSetClientSize(int width, int height);
298
4116c221
VZ
299 virtual void DoCaptureMouse();
300 virtual void DoReleaseMouse();
301
519cb848
SC
302 // move the window to the specified location and resize it: this is called
303 // from both DoSetSize() and DoSetClientSize() and would usually just call
304 // ::MoveWindow() except for composite controls which will want to arrange
305 // themselves inside the given rectangle
306 virtual void DoMoveWindow(int x, int y, int width, int height);
307
308#if wxUSE_TOOLTIPS
309 virtual void DoSetToolTip( wxToolTip *tip );
310#endif // wxUSE_TOOLTIPS
0dbd6262 311
519cb848
SC
312private:
313 // common part of all ctors
314 void Init();
0dbd6262 315
e766c8a9 316 DECLARE_NO_COPY_CLASS(wxWindowMac)
519cb848 317 DECLARE_EVENT_TABLE()
0dbd6262
SC
318};
319
0dbd6262
SC
320#endif
321 // _WX_WINDOW_H_