]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/window.h | |
3 | // Purpose: wxWindow class which is the base class for all | |
4 | // wxUniv port controls, it supports the customization of the | |
5 | // window drawing and input processing. | |
6 | // Author: Vadim Zeitlin | |
7 | // Modified by: | |
8 | // Created: 06.08.00 | |
9 | // RCS-ID: $Id$ | |
442b35b5 | 10 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 11 | // Licence: wxWindows licence |
1e6feb95 VZ |
12 | /////////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_UNIV_WINDOW_H_ | |
15 | #define _WX_UNIV_WINDOW_H_ | |
16 | ||
1e6feb95 VZ |
17 | #include "wx/bitmap.h" // for m_bitmapBg |
18 | ||
19 | class WXDLLEXPORT wxControlRenderer; | |
20 | class WXDLLEXPORT wxEventLoop; | |
21 | class WXDLLEXPORT wxMenu; | |
22 | class WXDLLEXPORT wxMenuBar; | |
23 | class WXDLLEXPORT wxRenderer; | |
24 | class WXDLLEXPORT wxScrollBar; | |
25 | ||
ab6b6b15 RR |
26 | #ifdef __WXX11__ |
27 | #define wxUSE_TWO_WINDOWS 1 | |
28 | #else | |
29 | #define wxUSE_TWO_WINDOWS 0 | |
30 | #endif | |
31 | ||
1e6feb95 VZ |
32 | // ---------------------------------------------------------------------------- |
33 | // wxWindow | |
34 | // ---------------------------------------------------------------------------- | |
35 | ||
24ce4c18 JS |
36 | #if defined(__WXMSW__) |
37 | #define wxWindowNative wxWindowMSW | |
38 | #elif defined(__WXGTK__) | |
39 | #define wxWindowNative wxWindowGTK | |
40 | #elif defined(__WXMGL__) | |
41 | #define wxWindowNative wxWindowMGL | |
1b0b798d RR |
42 | #elif defined(__WXX11__) |
43 | #define wxWindowNative wxWindowX11 | |
e766c8a9 SC |
44 | #elif defined(__WXMAC__) |
45 | #define wxWindowNative wxWindowMac | |
24ce4c18 JS |
46 | #endif |
47 | ||
1e6feb95 VZ |
48 | class WXDLLEXPORT wxWindow : public wxWindowNative |
49 | { | |
50 | public: | |
1a77875b | 51 | // ctors and create functions |
1e6feb95 VZ |
52 | // --------------------------- |
53 | ||
6463b9f5 | 54 | wxWindow() { Init(); } |
1e6feb95 VZ |
55 | |
56 | wxWindow(wxWindow *parent, | |
57 | wxWindowID id, | |
58 | const wxPoint& pos = wxDefaultPosition, | |
59 | const wxSize& size = wxDefaultSize, | |
60 | long style = 0, | |
6463b9f5 JS |
61 | const wxString& name = wxPanelNameStr) |
62 | : wxWindowNative(parent, id, pos, size, style | wxCLIP_CHILDREN, name) | |
63 | { Init(); } | |
1e6feb95 VZ |
64 | |
65 | bool Create(wxWindow *parent, | |
66 | wxWindowID id, | |
67 | const wxPoint& pos = wxDefaultPosition, | |
68 | const wxSize& size = wxDefaultSize, | |
69 | long style = 0, | |
70 | const wxString& name = wxPanelNameStr); | |
71 | ||
8da1f9a9 VZ |
72 | virtual ~wxWindow(); |
73 | ||
1e6feb95 VZ |
74 | // background pixmap support |
75 | // ------------------------- | |
76 | ||
77 | virtual void SetBackground(const wxBitmap& bitmap, | |
78 | int alignment = wxALIGN_CENTRE, | |
79 | wxStretch stretch = wxSTRETCH_NOT); | |
80 | ||
81 | const wxBitmap& GetBackgroundBitmap(int *alignment = NULL, | |
82 | wxStretch *stretch = NULL) const; | |
83 | ||
84 | // scrollbars: we (re)implement it ourselves using our own scrollbars | |
85 | // instead of the native ones | |
86 | // ------------------------------------------------------------------ | |
87 | ||
88 | virtual void SetScrollbar(int orient, | |
89 | int pos, | |
90 | int page, | |
91 | int range, | |
a290fa5a WS |
92 | bool refresh = true ); |
93 | virtual void SetScrollPos(int orient, int pos, bool refresh = true); | |
1e6feb95 VZ |
94 | virtual int GetScrollPos(int orient) const; |
95 | virtual int GetScrollThumb(int orient) const; | |
96 | virtual int GetScrollRange(int orient) const; | |
97 | virtual void ScrollWindow(int dx, int dy, | |
98 | const wxRect* rect = (wxRect *) NULL); | |
99 | ||
100 | // take into account the borders here | |
101 | virtual wxPoint GetClientAreaOrigin() const; | |
102 | ||
103 | // popup menu support | |
104 | // ------------------ | |
105 | ||
106 | // NB: all menu related functions are implemented in menu.cpp | |
107 | ||
108 | #if wxUSE_MENUS | |
109 | virtual bool DoPopupMenu(wxMenu *menu, int x, int y); | |
110 | ||
111 | // this is wxUniv-specific private method to be used only by wxMenu | |
112 | void DismissPopupMenu(); | |
113 | #endif // wxUSE_MENUS | |
114 | ||
115 | // miscellaneous other methods | |
116 | // --------------------------- | |
117 | ||
118 | // get the state information | |
119 | virtual bool IsFocused() const; | |
120 | virtual bool IsCurrent() const; | |
121 | virtual bool IsPressed() const; | |
122 | virtual bool IsDefault() const; | |
123 | ||
124 | // return all state flags at once (combination of wxCONTROL_XXX values) | |
125 | int GetStateFlags() const; | |
126 | ||
a290fa5a WS |
127 | // set the "highlighted" flag and return true if it changed |
128 | virtual bool SetCurrent(bool doit = true); | |
1e6feb95 VZ |
129 | |
130 | // get the scrollbar (may be NULL) for the given orientation | |
131 | wxScrollBar *GetScrollbar(int orient) const | |
132 | { | |
133 | return orient & wxVERTICAL ? m_scrollbarVert : m_scrollbarHorz; | |
134 | } | |
135 | ||
136 | // methods used by wxColourScheme to choose the colours for this window | |
137 | // -------------------------------------------------------------------- | |
138 | ||
a290fa5a | 139 | // return true if this is a panel/canvas window which contains other |
1e6feb95 | 140 | // controls only |
a290fa5a | 141 | virtual bool IsCanvasWindow() const { return false; } |
1e6feb95 | 142 | |
a290fa5a | 143 | // return true if this control can be highlighted when the mouse is over |
1e6feb95 | 144 | // it (the theme decides itself whether it is really highlighted or not) |
a290fa5a | 145 | virtual bool CanBeHighlighted() const { return false; } |
1e6feb95 | 146 | |
a290fa5a | 147 | // return true if we should use the colours/fonts returned by the |
1e6feb95 | 148 | // corresponding GetXXX() methods instead of the default ones |
1e6feb95 VZ |
149 | bool UseFgCol() const { return m_hasFgCol; } |
150 | bool UseFont() const { return m_hasFont; } | |
151 | ||
a290fa5a | 152 | // return true if this window serves as a container for the other windows |
30827629 | 153 | // only and doesn't get any input itself |
a290fa5a | 154 | virtual bool IsStaticBox() const { return false; } |
30827629 | 155 | |
1e6feb95 VZ |
156 | // returns the (low level) renderer to use for drawing the control by |
157 | // querying the current theme | |
158 | wxRenderer *GetRenderer() const { return m_renderer; } | |
159 | ||
160 | // scrolling helper: like ScrollWindow() except that it doesn't refresh the | |
161 | // uncovered window areas but returns the rectangle to update (don't call | |
162 | // this with both dx and dy non zero) | |
163 | wxRect ScrollNoRefresh(int dx, int dy, const wxRect *rect = NULL); | |
164 | ||
165 | // after scrollbars are added or removed they must be refreshed by calling | |
166 | // this function | |
167 | void RefreshScrollbars(); | |
168 | ||
169 | // erase part of the control | |
170 | virtual void EraseBackground(wxDC& dc, const wxRect& rect); | |
4cc4e7b6 | 171 | |
1e6feb95 VZ |
172 | // overridden base class methods |
173 | // ----------------------------- | |
174 | ||
175 | // the rect coordinates are, for us, in client coords, but if no rect is | |
176 | // specified, the entire window is refreshed | |
a290fa5a | 177 | virtual void Refresh(bool eraseBackground = true, |
1e6feb95 VZ |
178 | const wxRect *rect = (const wxRect *) NULL); |
179 | ||
180 | // we refresh the window when it is dis/enabled | |
a290fa5a | 181 | virtual bool Enable(bool enable = true); |
1e6feb95 | 182 | |
b2d22a3f VZ |
183 | // should we use the standard control colours or not? |
184 | virtual bool ShouldInheritColours() const { return false; } | |
185 | ||
1e6feb95 VZ |
186 | protected: |
187 | // common part of all ctors | |
188 | void Init(); | |
189 | ||
190 | // overridden base class virtuals | |
191 | ||
192 | // we deal with the scrollbars in these functions | |
193 | virtual void DoSetClientSize(int width, int height); | |
194 | virtual void DoGetClientSize(int *width, int *height) const; | |
195 | virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const; | |
196 | ||
197 | // event handlers | |
198 | void OnSize(wxSizeEvent& event); | |
3795cdba | 199 | void OnNcPaint(wxNcPaintEvent& event); |
1e6feb95 VZ |
200 | void OnPaint(wxPaintEvent& event); |
201 | void OnErase(wxEraseEvent& event); | |
202 | ||
203 | #if wxUSE_ACCEL || wxUSE_MENUS | |
204 | void OnKeyDown(wxKeyEvent& event); | |
205 | #endif // wxUSE_ACCEL | |
206 | ||
207 | #if wxUSE_MENUS | |
208 | void OnChar(wxKeyEvent& event); | |
209 | void OnKeyUp(wxKeyEvent& event); | |
210 | #endif // wxUSE_MENUS | |
211 | ||
a290fa5a | 212 | // draw the control background, return true if done |
1e6feb95 VZ |
213 | virtual bool DoDrawBackground(wxDC& dc); |
214 | ||
215 | // draw the controls border | |
216 | virtual void DoDrawBorder(wxDC& dc, const wxRect& rect); | |
217 | ||
218 | // draw the controls contents | |
219 | virtual void DoDraw(wxControlRenderer *renderer); | |
220 | ||
221 | // calculate the best size for the client area of the window: default | |
222 | // implementation of DoGetBestSize() uses this method and adds the border | |
223 | // width to the result | |
224 | virtual wxSize DoGetBestClientSize() const; | |
225 | virtual wxSize DoGetBestSize() const; | |
226 | ||
227 | // adjust the size of the window to take into account its borders | |
228 | wxSize AdjustSize(const wxSize& size) const; | |
229 | ||
230 | // put the scrollbars along the edges of the window | |
231 | void PositionScrollbars(); | |
232 | ||
233 | #if wxUSE_MENUS | |
234 | // return the menubar of the parent frame or NULL | |
235 | wxMenuBar *GetParentFrameMenuBar() const; | |
236 | #endif // wxUSE_MENUS | |
237 | ||
238 | // the renderer we use | |
239 | wxRenderer *m_renderer; | |
4cc4e7b6 | 240 | |
1e6feb95 VZ |
241 | // background bitmap info |
242 | wxBitmap m_bitmapBg; | |
243 | int m_alignBgBitmap; | |
244 | wxStretch m_stretchBgBitmap; | |
4cc4e7b6 | 245 | |
aae73669 RR |
246 | // old size |
247 | wxSize m_oldSize; | |
1e6feb95 | 248 | |
23895080 VZ |
249 | // is the mouse currently inside the window? |
250 | bool m_isCurrent:1; | |
1e6feb95 | 251 | |
30827629 | 252 | #ifdef __WXMSW__ |
bd33d4ac WS |
253 | |
254 | #if wxABI_VERSION >= 20602 | |
255 | public: | |
256 | #endif | |
30827629 | 257 | // override MSWWindowProc() to process WM_NCHITTEST |
c140b7e7 | 258 | WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
bd33d4ac | 259 | |
30827629 VZ |
260 | #endif // __WXMSW__ |
261 | ||
1e6feb95 VZ |
262 | private: |
263 | // the window scrollbars | |
264 | wxScrollBar *m_scrollbarHorz, | |
265 | *m_scrollbarVert; | |
266 | ||
1e6feb95 VZ |
267 | #if wxUSE_MENUS |
268 | // the current modal event loop for the popup menu we show or NULL | |
269 | static wxEventLoop *ms_evtLoopPopup; | |
270 | ||
271 | // the last window over which Alt was pressed (used by OnKeyUp) | |
272 | static wxWindow *ms_winLastAltPress; | |
273 | #endif // wxUSE_MENUS | |
274 | ||
275 | DECLARE_DYNAMIC_CLASS(wxWindow) | |
276 | DECLARE_EVENT_TABLE() | |
277 | }; | |
278 | ||
279 | #endif // _WX_UNIV_WINDOW_H_ | |
280 |