]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/window.h
Added "metal" theme.
[wxWidgets.git] / include / wx / mac / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose: wxWindowMac 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
19 #include <wx/brush.h>
20 // ---------------------------------------------------------------------------
21 // forward declarations
22 // ---------------------------------------------------------------------------
23
24 class WXDLLEXPORT wxButton;
25 class WXDLLEXPORT wxScrollBar;
26 class WXDLLEXPORT wxTopLevelWindowMac;
27
28 // ---------------------------------------------------------------------------
29 // constants
30 // ---------------------------------------------------------------------------
31
32 class WXDLLEXPORT wxWindowMac: public wxWindowBase
33 {
34 DECLARE_DYNAMIC_CLASS(wxWindowMac)
35
36 friend class wxDC;
37 friend class wxPaintDC;
38
39 public:
40
41 wxWindowMac() { Init(); }
42
43 wxWindowMac(wxWindowMac *parent,
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
54 virtual ~wxWindowMac();
55
56 bool Create(wxWindowMac *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
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
76 virtual void WarpPointer(int x, int y);
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 );
83 virtual bool SetFont(const wxFont& font)
84 { return wxWindowBase::SetFont(font); }
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 );
104
105 #if wxUSE_DRAG_AND_DROP
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
121 virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event);
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?
141 wxWindowMac* GetWindowChild1(wxWindowID id);
142 wxWindowMac* GetWindowChild(wxWindowID id);
143
144 // implementation from now on
145 // --------------------------
146
147 void MacClientToRootWindow( int *x , int *y ) const ;
148 void MacRootWindowToClient( int *x , int *y ) const ;
149 void MacWindowToRootWindow( int *x , int *y ) const ;
150 void MacRootWindowToWindow( int *x , int *y ) const ;
151
152 virtual wxString MacGetToolTipString( wxPoint &where ) ;
153
154 // simple accessors
155 // ----------------
156
157 // WXHWND GetHWND() const { return m_hWnd; }
158 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
159 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
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 // --------------
167 void OnSetFocus(wxFocusEvent& event) ;
168 void OnNcPaint(wxNcPaintEvent& event);
169 void OnEraseBackground(wxEraseEvent& event);
170 void OnIdle(wxIdleEvent& event);
171 void MacOnScroll(wxScrollEvent&event ) ;
172
173 bool AcceptsFocus() const ;
174
175 public:
176 // For implementation purposes - sometimes decorations make the client area
177 // smaller
178 virtual wxPoint GetClientAreaOrigin() const;
179
180 wxWindowMac *FindItem(long id) const;
181 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
182
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;
188
189 // MSW only: TRUE if this control is part of the main control
190 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
191
192 #if WXWIN_COMPATIBILITY
193 wxObject *GetChild(int number) const;
194 virtual void MSWDeviceToLogical(float *x, float *y) const;
195 #endif // WXWIN_COMPATIBILITY
196
197 // Setup background and foreground colours correctly
198 virtual void SetupColours();
199
200
201 #if WXWIN_COMPATIBILITY
202 void SetShowing(bool show) { (void)Show(show); }
203 bool IsUserEnabled() const { return IsEnabled(); }
204 #endif // WXWIN_COMPATIBILITY
205
206 public :
207 static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ;
208 virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ;
209 virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
210 virtual bool MacCanFocus() const { return true ; }
211
212 virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
213
214 virtual void MacPaintBorders( int left , int top ) ;
215 WXWindow MacGetRootWindow() const ;
216 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
217
218 virtual WXWidget MacGetContainerForEmbedding() ;
219
220 virtual long MacGetLeftBorderSize() const ;
221 virtual long MacGetRightBorderSize() const ;
222 virtual long MacGetTopBorderSize() const ;
223 virtual long MacGetBottomBorderSize() const ;
224
225 static long MacRemoveBordersFromStyle( long style ) ;
226 virtual void MacSuperChangedPosition() ;
227 virtual void MacTopLevelWindowChangedPosition() ;
228 virtual void MacSuperShown( bool show ) ;
229 virtual void MacSuperEnabled( bool enable ) ;
230 bool MacIsReallyShown() const ;
231 virtual void Update() ;
232 // for compatibility
233 void MacUpdateImmediately() { Update() ; }
234
235 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
236 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
237 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
238 const wxBrush& MacGetBackgroundBrush() ;
239 const wxRegion& MacGetVisibleRegion() ;
240 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
241 static wxWindowMac* s_lastMouseWindow ;
242 private:
243 protected:
244 // RgnHandle m_macUpdateRgn ;
245 // bool m_macEraseOnRedraw ;
246 wxBrush m_macBackgroundBrush ;
247 wxRegion m_macVisibleRegion ;
248 int m_x ;
249 int m_y ;
250 int m_width ;
251 int m_height ;
252
253 wxScrollBar* m_hScrollBar ;
254 wxScrollBar* m_vScrollBar ;
255 wxString m_label ;
256
257 void MacCreateScrollBars( long style ) ;
258 void MacRepositionScrollBars() ;
259
260 // additional (MSW specific) flags
261 bool m_useCtl3D:1; // Using CTL3D for this control
262 bool m_backgroundTransparent:1;
263 bool m_mouseInWindow:1;
264 bool m_doubleClickAllowed:1;
265 bool m_winCaptured:1;
266
267 // the size of one page for scrolling
268 int m_xThumbSize;
269 int m_yThumbSize;
270
271 // WXHMENU m_hMenu; // Menu, if any
272
273 // implement the base class pure virtuals
274 virtual void DoClientToScreen( int *x, int *y ) const;
275 virtual void DoScreenToClient( int *x, int *y ) const;
276 virtual void DoGetPosition( int *x, int *y ) const;
277 virtual void DoGetSize( int *width, int *height ) const;
278 virtual void DoGetClientSize( int *width, int *height ) const;
279 virtual void DoSetSize(int x, int y,
280 int width, int height,
281 int sizeFlags = wxSIZE_AUTO);
282 virtual void DoSetClientSize(int width, int height);
283
284 virtual void DoCaptureMouse();
285 virtual void DoReleaseMouse();
286
287 // move the window to the specified location and resize it: this is called
288 // from both DoSetSize() and DoSetClientSize() and would usually just call
289 // ::MoveWindow() except for composite controls which will want to arrange
290 // themselves inside the given rectangle
291 virtual void DoMoveWindow(int x, int y, int width, int height);
292
293 #if wxUSE_TOOLTIPS
294 virtual void DoSetToolTip( wxToolTip *tip );
295 #endif // wxUSE_TOOLTIPS
296
297 private:
298 // common part of all ctors
299 void Init();
300
301 DECLARE_NO_COPY_CLASS(wxWindowMac)
302 DECLARE_EVENT_TABLE()
303 };
304
305 #endif
306 // _WX_WINDOW_H_