]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/window.h
Many plot window gooddies.
[wxWidgets.git] / include / wx / mac / window.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose: wxWindow 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
519cb848
SC
19// ---------------------------------------------------------------------------
20// forward declarations
21// ---------------------------------------------------------------------------
0dbd6262 22
519cb848 23class WXDLLEXPORT wxButton;
e7549107 24class WXDLLEXPORT wxScrollBar;
0dbd6262 25
519cb848
SC
26// ---------------------------------------------------------------------------
27// constants
28// ---------------------------------------------------------------------------
0dbd6262 29
519cb848
SC
30// FIXME does anybody use those? they're unused by wxWindows...
31enum
0dbd6262 32{
519cb848
SC
33 wxKEY_SHIFT = 1,
34 wxKEY_CTRL = 2
0dbd6262
SC
35};
36
519cb848 37class WXDLLEXPORT wxWindow: public wxWindowBase
0dbd6262 38{
519cb848 39 DECLARE_DYNAMIC_CLASS(wxWindow);
0dbd6262
SC
40
41 friend class wxDC;
42 friend class wxPaintDC;
43
44public:
519cb848
SC
45 typedef struct MacWindowData
46 {
47 SInt16 m_macWindowBackgroundTheme ;
48 WindowRef m_macWindow ;
49 ControlHandle m_macRootControl ;
50 wxWindow* m_macFocus ;
51 } MacWindowData ;
52
53
54 wxWindow() { Init(); }
55
56 wxWindow(wxWindow *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 Init();
64 Create(parent, id, pos, size, style, name);
65 }
66
67 virtual ~wxWindow();
68
69 bool Create(wxWindow *parent,
70 wxWindowID id,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = 0,
74 const wxString& name = wxPanelNameStr);
75
76
77 // implement base class pure virtuals
78 virtual void SetTitle( const wxString& title);
79 virtual wxString GetTitle() const;
80
81 virtual void Raise();
82 virtual void Lower();
83
84 virtual bool Show( bool show = TRUE );
85 virtual bool Enable( bool enable = TRUE );
86
87 virtual void SetFocus();
88
519cb848
SC
89
90 virtual void WarpPointer(int x, int y);
91 virtual void CaptureMouse();
92 virtual void ReleaseMouse();
93
94 virtual void Refresh( bool eraseBackground = TRUE,
95 const wxRect *rect = (const wxRect *) NULL );
96 virtual void Clear();
97
98 virtual bool SetCursor( const wxCursor &cursor );
99 virtual bool SetFont( const wxFont &font );
100
101 virtual int GetCharHeight() const;
102 virtual int GetCharWidth() const;
103 virtual void GetTextExtent(const wxString& string,
104 int *x, int *y,
105 int *descent = (int *) NULL,
106 int *externalLeading = (int *) NULL,
107 const wxFont *theFont = (const wxFont *) NULL)
108 const;
109
110 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
111
112 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
113 int range, bool refresh = TRUE );
114 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
115 virtual int GetScrollPos( int orient ) const;
116 virtual int GetScrollThumb( int orient ) const;
117 virtual int GetScrollRange( int orient ) const;
118 virtual void ScrollWindow( int dx, int dy,
119 const wxRect* rect = (wxRect *) NULL );
0dbd6262
SC
120
121#if wxUSE_DRAG_AND_DROP
519cb848
SC
122 virtual void SetDropTarget( wxDropTarget *dropTarget );
123#endif // wxUSE_DRAG_AND_DROP
124
125 // Accept files for dragging
126 virtual void DragAcceptFiles(bool accept);
127
128#if WXWIN_COMPATIBILITY
129 // Set/get scroll attributes
130 virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
131 virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
132 virtual int OldGetScrollRange(int orient) const;
133 virtual int GetScrollPage(int orient) const;
134
135 // event handlers
136 // Handle a control command
137 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
138
139 // Override to define new behaviour for default action (e.g. double
140 // clicking on a listbox)
141 virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
142#endif // WXWIN_COMPATIBILITY
143
144#if wxUSE_CARET && WXWIN_COMPATIBILITY
145 // caret manipulation (old MSW only functions, see wxCaret class for the
146 // new API)
147 void CreateCaret(int w, int h);
148 void CreateCaret(const wxBitmap *bitmap);
149 void DestroyCaret();
150 void ShowCaret(bool show);
151 void SetCaretPos(int x, int y);
152 void GetCaretPos(int *x, int *y) const;
153#endif // wxUSE_CARET
154
155 // Native resource loading (implemented in src/msw/nativdlg.cpp)
156 // FIXME: should they really be all virtual?
519cb848
SC
157 wxWindow* GetWindowChild1(wxWindowID id);
158 wxWindow* GetWindowChild(wxWindowID id);
159
160 // implementation from now on
161 // --------------------------
162
163 void MacClientToRootWindow( int *x , int *y ) const ;
164 void MacRootWindowToClient( int *x , int *y ) const ;
165
166
167 // simple accessors
168 // ----------------
169
e7549107
SC
170// WXHWND GetHWND() const { return m_hWnd; }
171// void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
172 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
519cb848
SC
173
174 bool GetUseCtl3D() const { return m_useCtl3D; }
175 bool GetTransparentBackground() const { return m_backgroundTransparent; }
176 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
177
178 // event handlers
179 // --------------
180 void OnEraseBackground(wxEraseEvent& event);
181 void OnIdle(wxIdleEvent& event);
7c74e7fe 182 void MacOnScroll(wxScrollEvent&event ) ;
4765d335
SC
183
184 bool AcceptsFocus() const ;
0dbd6262 185
519cb848
SC
186public:
187 // For implementation purposes - sometimes decorations make the client area
188 // smaller
189 virtual wxPoint GetClientAreaOrigin() const;
0dbd6262 190
519cb848
SC
191 // Makes an adjustment to the window position (for example, a frame that has
192 // a toolbar that it manages itself).
193 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
0dbd6262 194
519cb848
SC
195 wxWindow *FindItem(long id) const;
196 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
0dbd6262 197
519cb848
SC
198 // Make a Windows extended style from the given wxWindows window style
199 static WXDWORD MakeExtendedStyle(long style,
200 bool eliminateBorders = TRUE);
201 // Determine whether 3D effects are wanted
202 WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
0dbd6262 203
519cb848
SC
204 // MSW only: TRUE if this control is part of the main control
205 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
0dbd6262 206
519cb848
SC
207 #if WXWIN_COMPATIBILITY
208 wxObject *GetChild(int number) const;
209 virtual void MSWDeviceToLogical(float *x, float *y) const;
210#endif // WXWIN_COMPATIBILITY
0dbd6262 211
519cb848
SC
212 // Setup background and foreground colours correctly
213 virtual void SetupColours();
0dbd6262 214
0dbd6262 215
519cb848
SC
216#if WXWIN_COMPATIBILITY
217 void SetShowing(bool show) { (void)Show(show); }
218 bool IsUserEnabled() const { return IsEnabled(); }
219#endif // WXWIN_COMPATIBILITY
0dbd6262 220
519cb848
SC
221 // Responds to colour changes: passes event on to children.
222 void OnSysColourChanged(wxSysColourChangedEvent& event);
0dbd6262 223
e7549107
SC
224public :
225 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindow** outWin ) ;
226 virtual void MacActivate( EventRecord *ev , bool inIsActivating ) ;
227 virtual void MacUpdate( EventRecord *ev ) ;
228 virtual void MacUpdateImmediately() ;
229 virtual void MacRedraw( RgnHandle updatergn , long time) ;
230 virtual void MacMouseDown( EventRecord *ev , short windowPart ) ;
231 virtual void MacMouseUp( EventRecord *ev , short windowPart ) ;
232 virtual void MacMouseMoved( EventRecord *ev , short windowPart ) ;
233 virtual void MacKeyDown( EventRecord *ev ) ;
234 virtual bool MacCanFocus() const { return true ; }
235
236 virtual void MacFireMouseEvent( EventRecord *ev ) ;
237 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
238 virtual void MacEraseBackground( Rect *rect ) ;
8208e181 239 virtual void MacPaint( wxPaintEvent &event ) ;
e7549107
SC
240 WindowRef GetMacRootWindow() const ;
241
242 virtual ControlHandle MacGetContainerForEmbedding() ;
243 virtual void MacSuperChangedPosition() ;
8208e181 244 virtual void MacSuperShown( bool show ) ;
e7549107
SC
245
246 bool MacSetupFocusPort() ;
247 bool MacSetupDrawingPort() ;
248 bool MacSetupFocusClientPort() ;
249 bool MacSetupDrawingClientPort() ;
250
251 virtual bool MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* rootwin ) ;
252 virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* rootwin ) ;
253
254 virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin ) ;
255 virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
256 MacWindowData* MacGetWindowData() { return m_macWindowData ; }
257 static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
7c74e7fe 258 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
e7549107
SC
259 static wxWindow* s_lastMouseWindow ;
260private:
261 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) ;
0dbd6262 262protected:
519cb848 263
e7549107
SC
264 MacWindowData* m_macWindowData ;
265 static WindowRef s_macWindowInUpdate ;
266
267 int m_x ;
268 int m_y ;
269 int m_width ;
270 int m_height ;
271
272 wxScrollBar* m_hScrollBar ;
273 wxScrollBar* m_vScrollBar ;
274 wxString m_label ;
275
276 void MacCreateScrollBars( long style ) ;
277 void MacRepositionScrollBars() ;
519cb848
SC
278
279 // additional (MSW specific) flags
280 bool m_useCtl3D:1; // Using CTL3D for this control
281 bool m_backgroundTransparent:1;
282 bool m_mouseInWindow:1;
283 bool m_doubleClickAllowed:1;
284 bool m_winCaptured:1;
285
286 // the size of one page for scrolling
287 int m_xThumbSize;
288 int m_yThumbSize;
289
e7549107 290// WXHMENU m_hMenu; // Menu, if any
519cb848
SC
291
292 // implement the base class pure virtuals
293 virtual void DoClientToScreen( int *x, int *y ) const;
294 virtual void DoScreenToClient( int *x, int *y ) const;
295 virtual void DoGetPosition( int *x, int *y ) const;
296 virtual void DoGetSize( int *width, int *height ) const;
297 virtual void DoGetClientSize( int *width, int *height ) const;
298 virtual void DoSetSize(int x, int y,
299 int width, int height,
300 int sizeFlags = wxSIZE_AUTO);
301 virtual void DoSetClientSize(int width, int height);
302
519cb848
SC
303 // move the window to the specified location and resize it: this is called
304 // from both DoSetSize() and DoSetClientSize() and would usually just call
305 // ::MoveWindow() except for composite controls which will want to arrange
306 // themselves inside the given rectangle
307 virtual void DoMoveWindow(int x, int y, int width, int height);
308
309#if wxUSE_TOOLTIPS
310 virtual void DoSetToolTip( wxToolTip *tip );
311#endif // wxUSE_TOOLTIPS
0dbd6262 312
519cb848
SC
313private:
314 // common part of all ctors
315 void Init();
0dbd6262 316
519cb848
SC
317 DECLARE_NO_COPY_CLASS(wxWindow);
318 DECLARE_EVENT_TABLE()
0dbd6262
SC
319};
320
519cb848
SC
321// associate mac windows with wx counterparts
322
323wxWindow* wxFindWinFromMacWindow( WindowRef inWindow ) ;
324void wxAssociateWinWithMacWindow(WindowRef inWindow, wxWindow *win) ;
325void wxRemoveMacWindowAssociation(wxWindow *win) ;
326
327class wxMacFocusHelper
328{
329public :
330 wxMacFocusHelper( wxWindow * theWindow ) ;
331 ~wxMacFocusHelper() ;
332 bool Ok() { return m_ok ; }
333
334private :
335 GrafPtr m_formerPort ;
336 GrafPtr m_currentPort ;
337 bool m_ok ;
338} ;
339
340class wxMacDrawingHelper
341{
342public :
343 wxMacDrawingHelper( wxWindow * theWindow ) ;
344 ~wxMacDrawingHelper() ;
345 bool Ok() { return m_ok ; }
346
347private :
348 GrafPtr m_formerPort ;
349 GrafPtr m_currentPort ;
350 PenState m_savedPenState ;
351 bool m_ok ;
352} ;
353
354class wxMacFocusClientHelper
355{
356public :
357 wxMacFocusClientHelper( wxWindow * theWindow ) ;
358 ~wxMacFocusClientHelper() ;
359 bool Ok() { return m_ok ; }
360
361private :
362 GrafPtr m_formerPort ;
363 GrafPtr m_currentPort ;
364 bool m_ok ;
365} ;
366
367class wxMacDrawingClientHelper
368{
369public :
370 wxMacDrawingClientHelper( wxWindow * theWindow ) ;
371 ~wxMacDrawingClientHelper() ;
372 bool Ok() { return m_ok ; }
373
374private :
375 GrafPtr m_formerPort ;
376 GrafPtr m_currentPort ;
377 PenState m_savedPenState ;
378 bool m_ok ;
379} ;
0dbd6262
SC
380
381#endif
382 // _WX_WINDOW_H_