]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/window.h
Added wxStrnicmp and to wchar.h, not yet for Unicode mode.
[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;
0dbd6262 24
519cb848
SC
25// ---------------------------------------------------------------------------
26// constants
27// ---------------------------------------------------------------------------
0dbd6262 28
519cb848
SC
29// FIXME does anybody use those? they're unused by wxWindows...
30enum
0dbd6262 31{
519cb848
SC
32 wxKEY_SHIFT = 1,
33 wxKEY_CTRL = 2
0dbd6262
SC
34};
35
519cb848 36class WXDLLEXPORT wxWindow: public wxWindowBase
0dbd6262 37{
519cb848 38 DECLARE_DYNAMIC_CLASS(wxWindow);
0dbd6262
SC
39
40 friend class wxDC;
41 friend class wxPaintDC;
42
43public:
519cb848
SC
44 typedef struct MacWindowData
45 {
46 SInt16 m_macWindowBackgroundTheme ;
47 WindowRef m_macWindow ;
48 ControlHandle m_macRootControl ;
49 wxWindow* m_macFocus ;
50 } MacWindowData ;
51
52
53 wxWindow() { Init(); }
54
55 wxWindow(wxWindow *parent,
56 wxWindowID id,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 long style = 0,
60 const wxString& name = wxPanelNameStr)
61 {
62 Init();
63 Create(parent, id, pos, size, style, name);
64 }
65
66 virtual ~wxWindow();
67
68 bool Create(wxWindow *parent,
69 wxWindowID id,
70 const wxPoint& pos = wxDefaultPosition,
71 const wxSize& size = wxDefaultSize,
72 long style = 0,
73 const wxString& name = wxPanelNameStr);
74
75
76 // implement base class pure virtuals
77 virtual void SetTitle( const wxString& title);
78 virtual wxString GetTitle() const;
79
80 virtual void Raise();
81 virtual void Lower();
82
83 virtual bool Show( bool show = TRUE );
84 virtual bool Enable( bool enable = TRUE );
85
86 virtual void SetFocus();
87
88 virtual bool Reparent( wxWindow *newParent );
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?
157 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
158 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
159 wxWindow* GetWindowChild1(wxWindowID id);
160 wxWindow* GetWindowChild(wxWindowID id);
161
162 // implementation from now on
163 // --------------------------
164
165 void MacClientToRootWindow( int *x , int *y ) const ;
166 void MacRootWindowToClient( int *x , int *y ) const ;
167
168
169 // simple accessors
170 // ----------------
171
172 WXHWND GetHWND() const { return m_hWnd; }
173 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
174 virtual WXWidget GetHandle() const { return (WXWidget) GetHWND(); }
175
176 bool GetUseCtl3D() const { return m_useCtl3D; }
177 bool GetTransparentBackground() const { return m_backgroundTransparent; }
178 void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
179
180 // event handlers
181 // --------------
182 void OnEraseBackground(wxEraseEvent& event);
183 void OnIdle(wxIdleEvent& event);
0dbd6262 184
519cb848
SC
185public:
186 // For implementation purposes - sometimes decorations make the client area
187 // smaller
188 virtual wxPoint GetClientAreaOrigin() const;
0dbd6262 189
519cb848
SC
190 // Makes an adjustment to the window position (for example, a frame that has
191 // a toolbar that it manages itself).
192 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
0dbd6262 193
519cb848
SC
194 wxWindow *FindItem(long id) const;
195 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
0dbd6262 196
519cb848
SC
197 // Make a Windows extended style from the given wxWindows window style
198 static WXDWORD MakeExtendedStyle(long style,
199 bool eliminateBorders = TRUE);
200 // Determine whether 3D effects are wanted
201 WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
0dbd6262 202
519cb848
SC
203 // MSW only: TRUE if this control is part of the main control
204 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
0dbd6262 205
519cb848
SC
206 #if WXWIN_COMPATIBILITY
207 wxObject *GetChild(int number) const;
208 virtual void MSWDeviceToLogical(float *x, float *y) const;
209#endif // WXWIN_COMPATIBILITY
0dbd6262 210
519cb848
SC
211 // Create an appropriate wxWindow from a HWND
212 virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
0dbd6262 213
519cb848
SC
214 // Make sure the window style reflects the HWND style (roughly)
215 virtual void AdoptAttributesFromHWND();
0dbd6262 216
519cb848
SC
217 // Setup background and foreground colours correctly
218 virtual void SetupColours();
0dbd6262 219
0dbd6262 220
519cb848
SC
221#if WXWIN_COMPATIBILITY
222 void SetShowing(bool show) { (void)Show(show); }
223 bool IsUserEnabled() const { return IsEnabled(); }
224#endif // WXWIN_COMPATIBILITY
0dbd6262 225
519cb848
SC
226 // Responds to colour changes: passes event on to children.
227 void OnSysColourChanged(wxSysColourChangedEvent& event);
0dbd6262 228
0dbd6262 229protected:
519cb848
SC
230 // the window handle
231 WXHWND m_hWnd;
232
233 // the old window proc (we subclass all windows)
234 WXFARPROC m_oldWndProc;
235
236 // additional (MSW specific) flags
237 bool m_useCtl3D:1; // Using CTL3D for this control
238 bool m_backgroundTransparent:1;
239 bool m_mouseInWindow:1;
240 bool m_doubleClickAllowed:1;
241 bool m_winCaptured:1;
242
243 // the size of one page for scrolling
244 int m_xThumbSize;
245 int m_yThumbSize;
246
247 WXHMENU m_hMenu; // Menu, if any
248
249 // the return value of WM_GETDLGCODE handler
250 long m_lDlgCode;
251
252 // implement the base class pure virtuals
253 virtual void DoClientToScreen( int *x, int *y ) const;
254 virtual void DoScreenToClient( int *x, int *y ) const;
255 virtual void DoGetPosition( int *x, int *y ) const;
256 virtual void DoGetSize( int *width, int *height ) const;
257 virtual void DoGetClientSize( int *width, int *height ) const;
258 virtual void DoSetSize(int x, int y,
259 int width, int height,
260 int sizeFlags = wxSIZE_AUTO);
261 virtual void DoSetClientSize(int width, int height);
262
263 // get the size which best suits the window: e.g., for a static text it
264 // will be the width and height of the text
265 virtual wxSize DoGetBestSize();
266
267 // move the window to the specified location and resize it: this is called
268 // from both DoSetSize() and DoSetClientSize() and would usually just call
269 // ::MoveWindow() except for composite controls which will want to arrange
270 // themselves inside the given rectangle
271 virtual void DoMoveWindow(int x, int y, int width, int height);
272
273#if wxUSE_TOOLTIPS
274 virtual void DoSetToolTip( wxToolTip *tip );
275#endif // wxUSE_TOOLTIPS
0dbd6262 276
519cb848
SC
277private:
278 // common part of all ctors
279 void Init();
0dbd6262 280
519cb848
SC
281 DECLARE_NO_COPY_CLASS(wxWindow);
282 DECLARE_EVENT_TABLE()
0dbd6262
SC
283};
284
519cb848
SC
285// associate mac windows with wx counterparts
286
287wxWindow* wxFindWinFromMacWindow( WindowRef inWindow ) ;
288void wxAssociateWinWithMacWindow(WindowRef inWindow, wxWindow *win) ;
289void wxRemoveMacWindowAssociation(wxWindow *win) ;
290
291class wxMacFocusHelper
292{
293public :
294 wxMacFocusHelper( wxWindow * theWindow ) ;
295 ~wxMacFocusHelper() ;
296 bool Ok() { return m_ok ; }
297
298private :
299 GrafPtr m_formerPort ;
300 GrafPtr m_currentPort ;
301 bool m_ok ;
302} ;
303
304class wxMacDrawingHelper
305{
306public :
307 wxMacDrawingHelper( wxWindow * theWindow ) ;
308 ~wxMacDrawingHelper() ;
309 bool Ok() { return m_ok ; }
310
311private :
312 GrafPtr m_formerPort ;
313 GrafPtr m_currentPort ;
314 PenState m_savedPenState ;
315 bool m_ok ;
316} ;
317
318class wxMacFocusClientHelper
319{
320public :
321 wxMacFocusClientHelper( wxWindow * theWindow ) ;
322 ~wxMacFocusClientHelper() ;
323 bool Ok() { return m_ok ; }
324
325private :
326 GrafPtr m_formerPort ;
327 GrafPtr m_currentPort ;
328 bool m_ok ;
329} ;
330
331class wxMacDrawingClientHelper
332{
333public :
334 wxMacDrawingClientHelper( wxWindow * theWindow ) ;
335 ~wxMacDrawingClientHelper() ;
336 bool Ok() { return m_ok ; }
337
338private :
339 GrafPtr m_formerPort ;
340 GrafPtr m_currentPort ;
341 PenState m_savedPenState ;
342 bool m_ok ;
343} ;
0dbd6262
SC
344
345#endif
346 // _WX_WINDOW_H_