]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/window.h
removing dependancy on mac headers from public wx headers (eventually adding wx/
[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 // FIXME does anybody use those? they're unused by wxWindows...
33 enum
34 {
35 wxKEY_SHIFT = 1,
36 wxKEY_CTRL = 2
37 };
38
39 class WXDLLEXPORT wxWindowMac: public wxWindowBase
40 {
41 DECLARE_DYNAMIC_CLASS(wxWindowMac);
42
43 friend class wxDC;
44 friend class wxPaintDC;
45
46 public:
47
48 wxWindowMac() { Init(); }
49
50 wxWindowMac(wxWindowMac *parent,
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
61 virtual ~wxWindowMac();
62
63 bool Create(wxWindowMac *parent,
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
83 virtual void WarpPointer(int x, int y);
84 virtual void CaptureMouse();
85 virtual void ReleaseMouse();
86
87 virtual void Refresh( bool eraseBackground = TRUE,
88 const wxRect *rect = (const wxRect *) NULL );
89 virtual void Clear();
90
91 virtual bool SetCursor( const wxCursor &cursor );
92 virtual bool SetFont(const wxFont& font)
93 { return wxWindowBase::SetFont(font); }
94 virtual int GetCharHeight() const;
95 virtual int GetCharWidth() const;
96 virtual void GetTextExtent(const wxString& string,
97 int *x, int *y,
98 int *descent = (int *) NULL,
99 int *externalLeading = (int *) NULL,
100 const wxFont *theFont = (const wxFont *) NULL)
101 const;
102
103 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
104
105 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
106 int range, bool refresh = TRUE );
107 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
108 virtual int GetScrollPos( int orient ) const;
109 virtual int GetScrollThumb( int orient ) const;
110 virtual int GetScrollRange( int orient ) const;
111 virtual void ScrollWindow( int dx, int dy,
112 const wxRect* rect = (wxRect *) NULL );
113
114 #if wxUSE_DRAG_AND_DROP
115 virtual void SetDropTarget( wxDropTarget *dropTarget );
116 #endif // wxUSE_DRAG_AND_DROP
117
118 // Accept files for dragging
119 virtual void DragAcceptFiles(bool accept);
120
121 #if WXWIN_COMPATIBILITY
122 // Set/get scroll attributes
123 virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
124 virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
125 virtual int OldGetScrollRange(int orient) const;
126 virtual int GetScrollPage(int orient) const;
127
128 // event handlers
129 // Handle a control command
130 virtual void OnCommand(wxWindowMac& win, wxCommandEvent& event);
131
132 // Override to define new behaviour for default action (e.g. double
133 // clicking on a listbox)
134 virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
135 #endif // WXWIN_COMPATIBILITY
136
137 #if wxUSE_CARET && WXWIN_COMPATIBILITY
138 // caret manipulation (old MSW only functions, see wxCaret class for the
139 // new API)
140 void CreateCaret(int w, int h);
141 void CreateCaret(const wxBitmap *bitmap);
142 void DestroyCaret();
143 void ShowCaret(bool show);
144 void SetCaretPos(int x, int y);
145 void GetCaretPos(int *x, int *y) const;
146 #endif // wxUSE_CARET
147
148 // Native resource loading (implemented in src/msw/nativdlg.cpp)
149 // FIXME: should they really be all virtual?
150 wxWindowMac* GetWindowChild1(wxWindowID id);
151 wxWindowMac* GetWindowChild(wxWindowID id);
152
153 // implementation from now on
154 // --------------------------
155
156 void MacClientToRootWindow( int *x , int *y ) const ;
157 void MacRootWindowToClient( int *x , int *y ) const ;
158 void MacWindowToRootWindow( int *x , int *y ) const ;
159 void MacRootWindowToWindow( int *x , int *y ) const ;
160
161 virtual wxString MacGetToolTipString( wxPoint &where ) ;
162
163 // simple accessors
164 // ----------------
165
166 // WXHWND GetHWND() const { return m_hWnd; }
167 // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
168 virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
169
170 bool GetUseCtl3D() const { return m_useCtl3D; }
171 bool GetTransparentBackground() const { return m_backgroundTransparent; }
172 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
173
174 // event handlers
175 // --------------
176 void OnSetFocus(wxFocusEvent& event) ;
177 void OnNcPaint(wxNcPaintEvent& event);
178 void OnEraseBackground(wxEraseEvent& event);
179 void OnIdle(wxIdleEvent& event);
180 void MacOnScroll(wxScrollEvent&event ) ;
181
182 bool AcceptsFocus() const ;
183
184 public:
185 // For implementation purposes - sometimes decorations make the client area
186 // smaller
187 virtual wxPoint GetClientAreaOrigin() const;
188
189 wxWindowMac *FindItem(long id) const;
190 wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
191
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;
197
198 // MSW only: TRUE if this control is part of the main control
199 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
200
201 #if WXWIN_COMPATIBILITY
202 wxObject *GetChild(int number) const;
203 virtual void MSWDeviceToLogical(float *x, float *y) const;
204 #endif // WXWIN_COMPATIBILITY
205
206 // Setup background and foreground colours correctly
207 virtual void SetupColours();
208
209
210 #if WXWIN_COMPATIBILITY
211 void SetShowing(bool show) { (void)Show(show); }
212 bool IsUserEnabled() const { return IsEnabled(); }
213 #endif // WXWIN_COMPATIBILITY
214
215 public :
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
223 virtual void MacPaintBorders( int left , int top ) ;
224 WXWindow MacGetRootWindow() const ;
225 wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
226
227 virtual WXWidget MacGetContainerForEmbedding() ;
228
229 virtual long MacGetLeftBorderSize() const ;
230 virtual long MacGetRightBorderSize() const ;
231 virtual long MacGetTopBorderSize() const ;
232 virtual long MacGetBottomBorderSize() const ;
233
234 static long MacRemoveBordersFromStyle( long style ) ;
235 virtual void MacSuperChangedPosition() ;
236 virtual void MacTopLevelWindowChangedPosition() ;
237 virtual void MacSuperShown( bool show ) ;
238 virtual void MacSuperEnabled( bool enable ) ;
239 bool MacIsReallyShown() const ;
240 virtual void Update() ;
241 // for compatibility
242 void MacUpdateImmediately() { Update() ; }
243
244 // virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
245 // virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
246 // virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
247 const wxBrush& MacGetBackgroundBrush() ;
248 const wxRegion& MacGetVisibleRegion() ;
249 bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
250 static wxWindowMac* s_lastMouseWindow ;
251 private:
252 protected:
253 // RgnHandle m_macUpdateRgn ;
254 // bool m_macEraseOnRedraw ;
255 wxBrush m_macBackgroundBrush ;
256 wxRegion m_macVisibleRegion ;
257 int m_x ;
258 int m_y ;
259 int m_width ;
260 int m_height ;
261
262 wxScrollBar* m_hScrollBar ;
263 wxScrollBar* m_vScrollBar ;
264 wxString m_label ;
265
266 void MacCreateScrollBars( long style ) ;
267 void MacRepositionScrollBars() ;
268
269 // additional (MSW specific) flags
270 bool m_useCtl3D:1; // Using CTL3D for this control
271 bool m_backgroundTransparent:1;
272 bool m_mouseInWindow:1;
273 bool m_doubleClickAllowed:1;
274 bool m_winCaptured:1;
275
276 // the size of one page for scrolling
277 int m_xThumbSize;
278 int m_yThumbSize;
279
280 // WXHMENU m_hMenu; // Menu, if any
281
282 // implement the base class pure virtuals
283 virtual void DoClientToScreen( int *x, int *y ) const;
284 virtual void DoScreenToClient( int *x, int *y ) const;
285 virtual void DoGetPosition( int *x, int *y ) const;
286 virtual void DoGetSize( int *width, int *height ) const;
287 virtual void DoGetClientSize( int *width, int *height ) const;
288 virtual void DoSetSize(int x, int y,
289 int width, int height,
290 int sizeFlags = wxSIZE_AUTO);
291 virtual void DoSetClientSize(int width, int height);
292
293 // move the window to the specified location and resize it: this is called
294 // from both DoSetSize() and DoSetClientSize() and would usually just call
295 // ::MoveWindow() except for composite controls which will want to arrange
296 // themselves inside the given rectangle
297 virtual void DoMoveWindow(int x, int y, int width, int height);
298
299 #if wxUSE_TOOLTIPS
300 virtual void DoSetToolTip( wxToolTip *tip );
301 #endif // wxUSE_TOOLTIPS
302
303 private:
304 // common part of all ctors
305 void Init();
306
307 DECLARE_NO_COPY_CLASS(wxWindowMac)
308 DECLARE_EVENT_TABLE()
309 };
310
311 #endif
312 // _WX_WINDOW_H_