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