]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/window.h
Added a Python-specific Append method to the wxListCtrl
[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
519cb848
SC
32// FIXME does anybody use those? they're unused by wxWindows...
33enum
0dbd6262 34{
519cb848
SC
35 wxKEY_SHIFT = 1,
36 wxKEY_CTRL = 2
0dbd6262
SC
37};
38
e766c8a9 39class WXDLLEXPORT wxWindowMac: public wxWindowBase
0dbd6262 40{
e766c8a9 41 DECLARE_DYNAMIC_CLASS(wxWindowMac);
0dbd6262
SC
42
43 friend class wxDC;
44 friend class wxPaintDC;
45
46public:
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 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
154 void MacClientToRootWindow( int *x , int *y ) const ;
155 void MacRootWindowToClient( int *x , int *y ) const ;
88594d02
SC
156 void MacWindowToRootWindow( int *x , int *y ) const ;
157 void MacRootWindowToWindow( int *x , int *y ) const ;
05adb9d2
SC
158
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; }
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 // --------------
7810c95b 174 void OnSetFocus(wxFocusEvent& event) ;
88594d02 175 void OnNcPaint(wxNcPaintEvent& event);
519cb848
SC
176 void OnEraseBackground(wxEraseEvent& event);
177 void OnIdle(wxIdleEvent& event);
7c74e7fe 178 void MacOnScroll(wxScrollEvent&event ) ;
4765d335
SC
179
180 bool AcceptsFocus() const ;
0dbd6262 181
519cb848
SC
182public:
183 // For implementation purposes - sometimes decorations make the client area
184 // smaller
185 virtual wxPoint GetClientAreaOrigin() const;
0dbd6262 186
e766c8a9
SC
187 wxWindowMac *FindItem(long id) const;
188 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
0dbd6262 189
519cb848
SC
190 // Make a Windows extended style from the given wxWindows window style
191 static WXDWORD MakeExtendedStyle(long style,
192 bool eliminateBorders = TRUE);
193 // Determine whether 3D effects are wanted
194 WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
0dbd6262 195
519cb848
SC
196 // MSW only: TRUE if this control is part of the main control
197 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
0dbd6262 198
519cb848
SC
199 #if WXWIN_COMPATIBILITY
200 wxObject *GetChild(int number) const;
201 virtual void MSWDeviceToLogical(float *x, float *y) const;
202#endif // WXWIN_COMPATIBILITY
0dbd6262 203
519cb848
SC
204 // Setup background and foreground colours correctly
205 virtual void SetupColours();
0dbd6262 206
0dbd6262 207
519cb848
SC
208#if WXWIN_COMPATIBILITY
209 void SetShowing(bool show) { (void)Show(show); }
210 bool IsUserEnabled() const { return IsEnabled(); }
211#endif // WXWIN_COMPATIBILITY
0dbd6262 212
e7549107 213public :
e766c8a9 214 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ;
8400ad1e 215 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ;
5273bf2f 216 virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
e7549107
SC
217 virtual bool MacCanFocus() const { return true ; }
218
e7549107 219 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
88594d02 220
5b36f53b 221 virtual void MacPaintBorders( int left , int top ) ;
5273bf2f 222 WXWindow MacGetRootWindow() const ;
88594d02 223 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
e7549107 224
5273bf2f 225 virtual WXWidget MacGetContainerForEmbedding() ;
5b781a67
SC
226
227 virtual long MacGetLeftBorderSize() const ;
228 virtual long MacGetRightBorderSize() const ;
229 virtual long MacGetTopBorderSize() const ;
230 virtual long MacGetBottomBorderSize() const ;
231
05adb9d2 232 static long MacRemoveBordersFromStyle( long style ) ;
e7549107 233 virtual void MacSuperChangedPosition() ;
4bf3cd97 234 virtual void MacTopLevelWindowChangedPosition() ;
8208e181 235 virtual void MacSuperShown( bool show ) ;
88594d02 236 virtual void MacSuperEnabled( bool enable ) ;
c809f3be 237 bool MacIsReallyShown() const ;
88594d02
SC
238 virtual void Update() ;
239 // for compatibility
240 void MacUpdateImmediately() { Update() ; }
241
24912802
SC
242// virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
243// virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
244// virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
755d980d
SC
245 const wxBrush& MacGetBackgroundBrush() ;
246 const wxRegion& MacGetVisibleRegion() ;
7c74e7fe 247 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
e766c8a9 248 static wxWindowMac* s_lastMouseWindow ;
e7549107 249private:
0dbd6262 250protected:
88594d02
SC
251// RgnHandle m_macUpdateRgn ;
252// bool m_macEraseOnRedraw ;
755d980d
SC
253 wxBrush m_macBackgroundBrush ;
254 wxRegion m_macVisibleRegion ;
e7549107
SC
255 int m_x ;
256 int m_y ;
257 int m_width ;
258 int m_height ;
259
260 wxScrollBar* m_hScrollBar ;
261 wxScrollBar* m_vScrollBar ;
262 wxString m_label ;
263
264 void MacCreateScrollBars( long style ) ;
265 void MacRepositionScrollBars() ;
519cb848
SC
266
267 // additional (MSW specific) flags
268 bool m_useCtl3D:1; // Using CTL3D for this control
269 bool m_backgroundTransparent:1;
270 bool m_mouseInWindow:1;
271 bool m_doubleClickAllowed:1;
272 bool m_winCaptured:1;
273
274 // the size of one page for scrolling
275 int m_xThumbSize;
276 int m_yThumbSize;
277
e7549107 278// WXHMENU m_hMenu; // Menu, if any
519cb848
SC
279
280 // implement the base class pure virtuals
281 virtual void DoClientToScreen( int *x, int *y ) const;
282 virtual void DoScreenToClient( int *x, int *y ) const;
283 virtual void DoGetPosition( int *x, int *y ) const;
284 virtual void DoGetSize( int *width, int *height ) const;
285 virtual void DoGetClientSize( int *width, int *height ) const;
286 virtual void DoSetSize(int x, int y,
287 int width, int height,
288 int sizeFlags = wxSIZE_AUTO);
289 virtual void DoSetClientSize(int width, int height);
290
4116c221
VZ
291 virtual void DoCaptureMouse();
292 virtual void DoReleaseMouse();
293
519cb848
SC
294 // move the window to the specified location and resize it: this is called
295 // from both DoSetSize() and DoSetClientSize() and would usually just call
296 // ::MoveWindow() except for composite controls which will want to arrange
297 // themselves inside the given rectangle
298 virtual void DoMoveWindow(int x, int y, int width, int height);
299
300#if wxUSE_TOOLTIPS
301 virtual void DoSetToolTip( wxToolTip *tip );
302#endif // wxUSE_TOOLTIPS
0dbd6262 303
519cb848
SC
304private:
305 // common part of all ctors
306 void Init();
0dbd6262 307
e766c8a9 308 DECLARE_NO_COPY_CLASS(wxWindowMac)
519cb848 309 DECLARE_EVENT_TABLE()
0dbd6262
SC
310};
311
0dbd6262
SC
312#endif
313 // _WX_WINDOW_H_