]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: scrolwin.h | |
f09b5681 | 3 | // Purpose: interface of wxScrolled template |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
6362d82b VZ |
9 | /** |
10 | Possible values for the second argument of wxScrolled::ShowScrollbars(). | |
11 | */ | |
12 | enum wxScrollbarVisibility | |
13 | { | |
14 | wxSHOW_SB_NEVER = -1, ///< Never show the scrollbar at all. | |
15 | wxSHOW_SB_DEFAULT, ///< Show scrollbar only if it is needed. | |
16 | wxSHOW_SB_ALWAYS ///< Always show scrollbar, even if not needed. | |
17 | }; | |
18 | ||
23324ae1 | 19 | /** |
7c913512 | 20 | |
f09b5681 | 21 | The wxScrolled class manages scrolling for its client area, transforming |
23324ae1 FM |
22 | the coordinates according to the scrollbar positions, and setting the |
23 | scroll positions, thumb sizes and ranges according to the area in view. | |
7c913512 | 24 | |
16361ec9 VS |
25 | There are two commonly used (but not the only possible!) specializations of |
26 | this class: | |
27 | ||
28 | - ::wxScrolledWindow, aka wxScrolled<wxPanel>, is equivalent to | |
29 | ::wxScrolledWindow from earlier versions. Derived from wxPanel, it shares | |
30 | wxPanel's behaviour with regard to TAB traversal and focus handling. Use | |
d2ddc77d | 31 | this if the scrolled window will have child controls. |
16361ec9 VS |
32 | |
33 | - ::wxScrolledCanvas, aka wxScrolled<wxWindow>, derives from wxWindow and | |
34 | so doesn't handle children specially. This is suitable e.g. for | |
35 | implementating scrollable controls such as tree or list controls. | |
36 | ||
23324ae1 | 37 | Starting from version 2.4 of wxWidgets, there are several ways to use a |
d2ddc77d RR |
38 | ::wxScrolledWindow (and now wxScrolled). In particular, there are |
39 | three ways to set the size of the scrolling area: | |
7c913512 | 40 | |
16361ec9 VS |
41 | One way is to set the scrollbars directly using a call to SetScrollbars(). |
42 | This is the way it used to be in any previous version of wxWidgets and it | |
43 | will be kept for backwards compatibility. | |
7c913512 | 44 | |
23324ae1 FM |
45 | An additional method of manual control, which requires a little less |
46 | computation of your own, is to set the total size of the scrolling area by | |
16361ec9 VS |
47 | calling either wxWindow::SetVirtualSize(), or wxWindow::FitInside(), and |
48 | setting the scrolling increments for it by calling SetScrollRate(). | |
23324ae1 FM |
49 | Scrolling in some orientation is enabled by setting a non-zero increment |
50 | for it. | |
7c913512 | 51 | |
23324ae1 | 52 | The most automatic and newest way is to simply let sizers determine the |
16361ec9 | 53 | scrolling area. This is now the default when you set an interior sizer into |
f09b5681 | 54 | a wxScrolled with wxWindow::SetSizer(). The scrolling area will be |
16361ec9 VS |
55 | set to the size requested by the sizer and the scrollbars will be assigned |
56 | for each orientation according to the need for them and the scrolling | |
57 | increment set by SetScrollRate(). As above, scrolling is only enabled in | |
58 | orientations with a non-zero increment. You can influence the minimum size | |
59 | of the scrolled area controlled by a sizer by calling | |
60 | wxWindow::SetVirtualSizeHints(). (Calling SetScrollbars() has analogous | |
61 | effects in wxWidgets 2.4 -- in later versions it may not continue to | |
62 | override the sizer.) | |
63 | ||
64 | Note that if maximum size hints are still supported by | |
65 | wxWindow::SetVirtualSizeHints(), use them at your own dire risk. They may | |
66 | or may not have been removed for 2.4, but it really only makes sense to set | |
67 | minimum size hints here. We should probably replace | |
68 | wxWindow::SetVirtualSizeHints() with wxWindow::SetMinVirtualSize() or | |
69 | similar and remove it entirely in future. | |
70 | ||
3e0e3895 FM |
71 | @todo review docs for this class replacing SetVirtualSizeHints() with |
72 | SetMinClientSize(). | |
73 | ||
f09b5681 BP |
74 | As with all windows, an application can draw onto a wxScrolled using a |
75 | @ref overview_dc "device context". | |
7c913512 | 76 | |
16361ec9 | 77 | You have the option of handling the OnPaint handler or overriding the |
f09b5681 BP |
78 | wxScrolled::OnDraw() function, which is passed a pre-scrolled device |
79 | context (prepared by wxScrolled::DoPrepareDC()). | |
16361ec9 VS |
80 | |
81 | If you don't wish to calculate your own scrolling, you must call | |
82 | DoPrepareDC() when not drawing from within OnDraw(), to set the device | |
83 | origin for the device context according to the current scroll position. | |
84 | ||
f09b5681 | 85 | A wxScrolled will normally scroll itself and therefore its child windows |
16361ec9 VS |
86 | as well. It might however be desired to scroll a different window than |
87 | itself: e.g. when designing a spreadsheet, you will normally only have to | |
88 | scroll the (usually white) cell area, whereas the (usually grey) label area | |
89 | will scroll very differently. For this special purpose, you can call | |
90 | SetTargetWindow() which means that pressing the scrollbars will scroll a | |
91 | different window. | |
92 | ||
93 | Note that the underlying system knows nothing about scrolling coordinates, | |
94 | so that all system functions (mouse events, expose events, refresh calls | |
95 | etc) as well as the position of subwindows are relative to the "physical" | |
96 | origin of the scrolled window. If the user insert a child window at | |
23324ae1 | 97 | position (10,10) and scrolls the window down 100 pixels (moving the child |
16361ec9 VS |
98 | window out of the visible area), the child window will report a position |
99 | of (10,-90). | |
7c913512 | 100 | |
23324ae1 | 101 | @beginStyleTable |
8c6791e4 | 102 | @style{wxRETAINED} |
23324ae1 FM |
103 | Uses a backing pixmap to speed refreshes. Motif only. |
104 | @endStyleTable | |
7c913512 | 105 | |
16361ec9 | 106 | @remarks |
f09b5681 BP |
107 | Use wxScrolled for applications where the user scrolls by a fixed amount, |
108 | and where a 'page' can be interpreted to be the current visible portion of | |
109 | the window. For more sophisticated applications, use the wxScrolled | |
110 | implementation as a guide to build your own scroll behaviour or use | |
111 | wxVScrolledWindow or its variants. | |
16361ec9 | 112 | |
d2ddc77d | 113 | @since The wxScrolled template exists since version 2.9.0. In older versions, |
f09b5681 BP |
114 | only ::wxScrolledWindow (equivalent of wxScrolled<wxPanel>) was |
115 | available. | |
16361ec9 | 116 | |
23324ae1 FM |
117 | @library{wxcore} |
118 | @category{miscwnd} | |
7c913512 | 119 | |
16361ec9 VS |
120 | @see wxScrollBar, wxClientDC, wxPaintDC, |
121 | wxVScrolledWindow, wxHScrolledWindow, wxHVScrolledWindow, | |
23324ae1 | 122 | */ |
16361ec9 VS |
123 | template<class T> |
124 | class wxScrolled : public T | |
23324ae1 FM |
125 | { |
126 | public: | |
16361ec9 VS |
127 | /// Default constructor. |
128 | wxScrolled(); | |
129 | ||
23324ae1 FM |
130 | /** |
131 | Constructor. | |
3c4f71cc | 132 | |
7c913512 | 133 | @param parent |
4cc4bfaf | 134 | Parent window. |
7c913512 | 135 | @param id |
16361ec9 | 136 | Window identifier. The value @c wxID_ANY indicates a default value. |
7c913512 | 137 | @param pos |
76e2b570 | 138 | Window position. If a position of ::wxDefaultPosition is specified |
16361ec9 | 139 | then a default position is chosen. |
7c913512 | 140 | @param size |
76e2b570 | 141 | Window size. If a size of ::wxDefaultSize is specified then the |
16361ec9 | 142 | window is sized appropriately. |
7c913512 | 143 | @param style |
f09b5681 | 144 | Window style. See wxScrolled. |
7c913512 | 145 | @param name |
4cc4bfaf | 146 | Window name. |
3c4f71cc | 147 | |
16361ec9 VS |
148 | @remarks The window is initially created without visible scrollbars. |
149 | Call SetScrollbars() to specify how big the virtual window | |
150 | size should be. | |
23324ae1 | 151 | */ |
16361ec9 VS |
152 | wxScrolled(wxWindow* parent, wxWindowID id = -1, |
153 | const wxPoint& pos = wxDefaultPosition, | |
154 | const wxSize& size = wxDefaultSize, | |
155 | long style = wxHSCROLL | wxVSCROLL, | |
156 | const wxString& name = "scrolledWindow"); | |
23324ae1 | 157 | |
23324ae1 FM |
158 | |
159 | /** | |
16361ec9 VS |
160 | Translates the logical coordinates to the device ones. For example, if |
161 | a window is scrolled 10 pixels to the bottom, the device coordinates of | |
162 | the origin are (0, 0) (as always), but the logical coordinates are (0, | |
163 | 10) and so the call to CalcScrolledPosition(0, 10, xx, yy) will return | |
164 | 0 in yy. | |
3c4f71cc | 165 | |
1058f652 MB |
166 | @beginWxPerlOnly |
167 | In wxPerl this method takes two parameters and returns a | |
168 | 2-element list (xx, yy). | |
169 | @endWxPerlOnly | |
170 | ||
4cc4bfaf | 171 | @see CalcUnscrolledPosition() |
23324ae1 | 172 | */ |
328f5751 | 173 | void CalcScrolledPosition(int x, int y, int* xx, int* yy) const; |
23324ae1 FM |
174 | |
175 | /** | |
16361ec9 VS |
176 | Translates the device coordinates to the logical ones. For example, if |
177 | a window is scrolled 10 pixels to the bottom, the device coordinates of | |
178 | the origin are (0, 0) (as always), but the logical coordinates are (0, | |
179 | 10) and so the call to CalcUnscrolledPosition(0, 0, xx, yy) will return | |
180 | 10 in yy. | |
3c4f71cc | 181 | |
1058f652 MB |
182 | @beginWxPerlOnly |
183 | In wxPerl this method takes two parameters and returns a | |
184 | 2-element list (xx, yy). | |
185 | @endWxPerlOnly | |
186 | ||
4cc4bfaf | 187 | @see CalcScrolledPosition() |
23324ae1 | 188 | */ |
328f5751 | 189 | void CalcUnscrolledPosition(int x, int y, int* xx, int* yy) const; |
23324ae1 FM |
190 | |
191 | /** | |
192 | Creates the window for two-step construction. Derived classes | |
f09b5681 | 193 | should call or replace this function. See wxScrolled::wxScrolled() |
23324ae1 FM |
194 | for details. |
195 | */ | |
196 | bool Create(wxWindow* parent, wxWindowID id = -1, | |
197 | const wxPoint& pos = wxDefaultPosition, | |
198 | const wxSize& size = wxDefaultSize, | |
4cc4bfaf | 199 | long style = wxHSCROLL | wxVSCROLL, |
23324ae1 FM |
200 | const wxString& name = "scrolledWindow"); |
201 | ||
202 | /** | |
16361ec9 VS |
203 | Call this function to prepare the device context for drawing a scrolled |
204 | image. | |
205 | ||
206 | It sets the device origin according to the current scroll position. | |
60a14f1b VZ |
207 | DoPrepareDC() is called automatically within the default @c wxEVT_PAINT |
208 | event handler, so your OnDraw() override will be passed an already | |
16361ec9 | 209 | 'pre-scrolled' device context. However, if you wish to draw from |
60a14f1b VZ |
210 | outside of OnDraw() (e.g. from your own @c wxEVT_PAINT handler), you |
211 | must call this function yourself. | |
16361ec9 VS |
212 | |
213 | For example: | |
214 | @code | |
215 | void MyWindow::OnEvent(wxMouseEvent& event) | |
216 | { | |
217 | wxClientDC dc(this); | |
218 | DoPrepareDC(dc); | |
219 | ||
220 | dc.SetPen(*wxBLACK_PEN); | |
221 | float x, y; | |
222 | event.Position(&x, &y); | |
223 | if (xpos > -1 && ypos > -1 && event.Dragging()) | |
224 | { | |
225 | dc.DrawLine(xpos, ypos, x, y); | |
226 | } | |
227 | xpos = x; | |
228 | ypos = y; | |
229 | } | |
230 | @endcode | |
231 | ||
60a14f1b VZ |
232 | Notice that the function sets the origin by moving it relatively to the |
233 | current origin position, so you shouldn't change the origin before | |
234 | calling DoPrepareDC() or, if you do, reset it to (0, 0) later. If you | |
235 | call DoPrepareDC() immediately after device context creation, as in the | |
236 | example above, this problem doesn't arise, of course, so it is | |
237 | customary to do it like this. | |
23324ae1 FM |
238 | */ |
239 | void DoPrepareDC(wxDC& dc); | |
240 | ||
241 | /** | |
242 | Enable or disable physical scrolling in the given direction. Physical | |
243 | scrolling is the physical transfer of bits up or down the | |
244 | screen when a scroll event occurs. If the application scrolls by a | |
245 | variable amount (e.g. if there are different font sizes) then physical | |
246 | scrolling will not work, and you should switch it off. Note that you | |
247 | will have to reposition child windows yourself, if physical scrolling | |
248 | is disabled. | |
3c4f71cc | 249 | |
7c913512 | 250 | @param xScrolling |
4cc4bfaf | 251 | If @true, enables physical scrolling in the x direction. |
7c913512 | 252 | @param yScrolling |
4cc4bfaf | 253 | If @true, enables physical scrolling in the y direction. |
3c4f71cc | 254 | |
23324ae1 | 255 | @remarks Physical scrolling may not be available on all platforms. Where |
4cc4bfaf | 256 | it is available, it is enabled by default. |
23324ae1 FM |
257 | */ |
258 | void EnableScrolling(bool xScrolling, bool yScrolling); | |
259 | ||
6362d82b VZ |
260 | /** |
261 | Set the scrollbar visibility. | |
262 | ||
263 | By default the scrollbar in the corresponding direction is only shown | |
264 | if it is needed, i.e. if the virtual size of the scrolled window in | |
265 | this direction is greater than the current physical window size. Using | |
266 | this function the scrollbar visibility can be changed to be: | |
267 | - wxSHOW_SB_ALWAYS: To always show the scrollbar, even if it is | |
268 | not needed currently (wxALWAYS_SHOW_SB style can be used during | |
269 | the window creation to achieve the same effect but it applies | |
270 | in both directions). | |
271 | - wxSHOW_SB_NEVER: To never show the scrollbar at all. In this case | |
272 | the program should presumably provide some other way for the | |
273 | user to scroll the window. | |
274 | - wxSHOW_SB_DEFAULT: To restore the default behaviour described | |
275 | above. | |
276 | ||
277 | @param horz | |
278 | The desired visibility for the horizontal scrollbar. | |
279 | @param vert | |
280 | The desired visibility for the vertical scrollbar. | |
281 | ||
282 | @since 2.9.0 | |
283 | */ | |
284 | void ShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert); | |
285 | ||
23324ae1 | 286 | /** |
16361ec9 VS |
287 | Get the number of pixels per scroll unit (line), in each direction, as |
288 | set by SetScrollbars(). A value of zero indicates no scrolling in that | |
289 | direction. | |
3c4f71cc | 290 | |
7c913512 | 291 | @param xUnit |
4cc4bfaf | 292 | Receives the number of pixels per horizontal unit. |
7c913512 | 293 | @param yUnit |
4cc4bfaf | 294 | Receives the number of pixels per vertical unit. |
3c4f71cc | 295 | |
1058f652 MB |
296 | @beginWxPerlOnly |
297 | In wxPerl this method takes no parameters and returns a | |
298 | 2-element list (xUnit, yUnit). | |
299 | @endWxPerlOnly | |
300 | ||
4cc4bfaf | 301 | @see SetScrollbars(), GetVirtualSize() |
23324ae1 | 302 | */ |
328f5751 | 303 | void GetScrollPixelsPerUnit(int* xUnit, int* yUnit) const; |
23324ae1 FM |
304 | |
305 | /** | |
306 | Get the position at which the visible portion of the window starts. | |
3c4f71cc | 307 | |
7c913512 | 308 | @param x |
4cc4bfaf | 309 | Receives the first visible x position in scroll units. |
7c913512 | 310 | @param y |
4cc4bfaf | 311 | Receives the first visible y position in scroll units. |
3c4f71cc | 312 | |
f8f31de6 FM |
313 | @remarks |
314 | If either of the scrollbars is not at the home position, @a x | |
315 | and/or @a y will be greater than zero. | |
316 | Combined with wxWindow::GetClientSize(), the application can use this | |
317 | function to efficiently redraw only the visible portion of the window. | |
318 | The positions are in logical scroll units, not pixels, so to convert | |
319 | to pixels you will have to multiply by the number of pixels per scroll | |
320 | increment. | |
3c4f71cc | 321 | |
1058f652 MB |
322 | @beginWxPerlOnly |
323 | In wxPerl this method takes no parameters and returns a | |
324 | 2-element list (x, y). | |
325 | @endWxPerlOnly | |
326 | ||
0b0f6f87 | 327 | @see SetScrollbars(), Scroll() |
23324ae1 | 328 | */ |
328f5751 | 329 | void GetViewStart(int* x, int* y) const; |
f8f31de6 FM |
330 | |
331 | /** | |
332 | This is a simple overload of GetViewStart(int*,int*); see that function | |
333 | for more info. | |
334 | */ | |
0b0f6f87 | 335 | wxPoint GetViewStart() const; |
23324ae1 FM |
336 | |
337 | /** | |
338 | Gets the size in device units of the scrollable window area (as | |
339 | opposed to the client size, which is the area of the window currently | |
340 | visible). | |
3c4f71cc | 341 | |
7c913512 | 342 | @param x |
4cc4bfaf | 343 | Receives the length of the scrollable window, in pixels. |
7c913512 | 344 | @param y |
4cc4bfaf | 345 | Receives the height of the scrollable window, in pixels. |
3c4f71cc | 346 | |
16361ec9 | 347 | @remarks Use wxDC::DeviceToLogicalX() and wxDC::DeviceToLogicalY() to |
4cc4bfaf | 348 | translate these units to logical units. |
3c4f71cc | 349 | |
1058f652 MB |
350 | @beginWxPerlOnly |
351 | In wxPerl this method takes no parameters and returns a | |
352 | 2-element list (xUnit, yUnit). | |
353 | @endWxPerlOnly | |
354 | ||
4cc4bfaf | 355 | @see SetScrollbars(), GetScrollPixelsPerUnit() |
23324ae1 | 356 | */ |
328f5751 | 357 | void GetVirtualSize(int* x, int* y) const; |
23324ae1 FM |
358 | |
359 | /** | |
360 | Motif only: @true if the window has a backing bitmap. | |
361 | */ | |
328f5751 | 362 | bool IsRetained() const; |
23324ae1 FM |
363 | |
364 | /** | |
16361ec9 VS |
365 | Called by the default paint event handler to allow the application to |
366 | define painting behaviour without having to worry about calling | |
23324ae1 | 367 | DoPrepareDC(). |
16361ec9 VS |
368 | |
369 | Instead of overriding this function you may also just process the paint | |
370 | event in the derived class as usual, but then you will have to call | |
371 | DoPrepareDC() yourself. | |
23324ae1 FM |
372 | */ |
373 | virtual void OnDraw(wxDC& dc); | |
374 | ||
375 | /** | |
7c913512 | 376 | This function is for backwards compatibility only and simply calls |
16361ec9 VS |
377 | DoPrepareDC() now. Notice that it is not called by the default paint |
378 | event handle (DoPrepareDC() is), so overriding this method in your | |
379 | derived class is useless. | |
23324ae1 FM |
380 | */ |
381 | void PrepareDC(wxDC& dc); | |
382 | ||
383 | /** | |
384 | Scrolls a window so the view start is at the given point. | |
3c4f71cc | 385 | |
7c913512 | 386 | @param x |
4cc4bfaf | 387 | The x position to scroll to, in scroll units. |
7c913512 | 388 | @param y |
4cc4bfaf | 389 | The y position to scroll to, in scroll units. |
3c4f71cc | 390 | |
23324ae1 | 391 | @remarks The positions are in scroll units, not pixels, so to convert to |
4cc4bfaf | 392 | pixels you will have to multiply by the number of |
0b0f6f87 | 393 | pixels per scroll increment. If either parameter is |
f8f31de6 | 394 | ::wxDefaultCoord (-1), that position will be ignored (no change |
0b0f6f87 | 395 | in that direction). |
3c4f71cc | 396 | |
4cc4bfaf | 397 | @see SetScrollbars(), GetScrollPixelsPerUnit() |
23324ae1 FM |
398 | */ |
399 | void Scroll(int x, int y); | |
f8f31de6 FM |
400 | |
401 | /** | |
402 | This is an overload of Scroll(int,int); see that function for more info. | |
403 | */ | |
0b0f6f87 | 404 | void Scroll(const wxPoint& pt); |
23324ae1 FM |
405 | |
406 | /** | |
16361ec9 VS |
407 | Set the horizontal and vertical scrolling increment only. See the |
408 | pixelsPerUnit parameter in SetScrollbars(). | |
23324ae1 FM |
409 | */ |
410 | void SetScrollRate(int xstep, int ystep); | |
411 | ||
412 | /** | |
413 | Sets up vertical and/or horizontal scrollbars. | |
3c4f71cc | 414 | |
16361ec9 VS |
415 | The first pair of parameters give the number of pixels per 'scroll |
416 | step', i.e. amount moved when the up or down scroll arrows are pressed. | |
417 | The second pair gives the length of scrollbar in scroll steps, which | |
418 | sets the size of the virtual window. | |
419 | ||
420 | @a xPos and @a yPos optionally specify a position to scroll to | |
421 | immediately. | |
422 | ||
423 | For example, the following gives a window horizontal and vertical | |
424 | scrollbars with 20 pixels per scroll step, and a size of 50 steps (1000 | |
425 | pixels) in each direction: | |
426 | @code | |
427 | window->SetScrollbars(20, 20, 50, 50); | |
428 | @endcode | |
429 | ||
f09b5681 | 430 | wxScrolled manages the page size itself, using the current client |
16361ec9 VS |
431 | window size as the page size. |
432 | ||
433 | Note that for more sophisticated scrolling applications, for example | |
434 | where scroll steps may be variable according to the position in the | |
435 | document, it will be necessary to derive a new class from wxWindow, | |
436 | overriding OnSize() and adjusting the scrollbars appropriately. | |
437 | ||
7c913512 | 438 | @param pixelsPerUnitX |
4cc4bfaf | 439 | Pixels per scroll unit in the horizontal direction. |
7c913512 | 440 | @param pixelsPerUnitY |
4cc4bfaf | 441 | Pixels per scroll unit in the vertical direction. |
7c913512 | 442 | @param noUnitsX |
4cc4bfaf | 443 | Number of units in the horizontal direction. |
7c913512 | 444 | @param noUnitsY |
4cc4bfaf | 445 | Number of units in the vertical direction. |
7c913512 | 446 | @param xPos |
16361ec9 VS |
447 | Position to initialize the scrollbars in the horizontal direction, |
448 | in scroll units. | |
7c913512 | 449 | @param yPos |
16361ec9 VS |
450 | Position to initialize the scrollbars in the vertical direction, in |
451 | scroll units. | |
7c913512 | 452 | @param noRefresh |
4cc4bfaf | 453 | Will not refresh window if @true. |
3c4f71cc | 454 | |
16361ec9 | 455 | @see wxWindow::SetVirtualSize() |
23324ae1 FM |
456 | */ |
457 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
458 | int noUnitsX, | |
459 | int noUnitsY, | |
460 | int xPos = 0, | |
461 | int yPos = 0, | |
4cc4bfaf | 462 | bool noRefresh = false); |
23324ae1 FM |
463 | |
464 | /** | |
1d7b600d VZ |
465 | Call this function to tell wxScrolled to perform the actual scrolling |
466 | on a different window (and not on itself). | |
467 | ||
468 | This method is useful when only a part of the window should be | |
469 | scrolled. A typical example is a control consisting of a fixed header | |
470 | and the scrollable contents window: the scrollbars are attached to the | |
471 | main window itself, hence it, and not the contents window must be | |
472 | derived from wxScrolled, but only the contents window scrolls when the | |
473 | scrollbars are used. To implement such setup, you need to call this | |
474 | method with the contents window as argument. | |
475 | ||
476 | Notice that if this method is used, GetSizeAvailableForScrollTarget() | |
477 | method must be overridden. | |
23324ae1 | 478 | */ |
1d7b600d VZ |
479 | void SetTargetWindow(wxWindow *window); |
480 | ||
481 | protected: | |
482 | /** | |
483 | Function which must be overridden to implement the size available for | |
484 | the scroll target for the given size of the main window. | |
485 | ||
486 | This method must be overridden if SetTargetWindow() is used (it is | |
487 | never called otherwise). The implementation should decrease the @a size | |
488 | to account for the size of the non-scrollable parts of the main window | |
489 | and return only the size available for the scrollable window itself. | |
490 | E.g. in the example given in SetTargetWindow() documentation the | |
491 | function would subtract the height of the header window from the | |
492 | vertical component of @a size. | |
493 | */ | |
494 | virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); | |
23324ae1 | 495 | }; |
e54c96f1 | 496 | |
16361ec9 VS |
497 | |
498 | /** | |
499 | Scrolled window derived from wxPanel. | |
500 | ||
f09b5681 | 501 | See wxScrolled for detailed description. |
16361ec9 VS |
502 | |
503 | @note Note that because this class derives from wxPanel, it shares its | |
504 | behavior with regard to TAB traversal and focus handling (in | |
505 | particular, it forwards focus to its children). If you don't want | |
506 | this behaviour, use ::wxScrolledCanvas instead. | |
507 | ||
f09b5681 | 508 | @note ::wxScrolledWindow is an alias for wxScrolled<wxPanel> since version |
16361ec9 VS |
509 | 2.9.0. In older versions, it was a standalone class. |
510 | ||
511 | @library{wxcore} | |
512 | @category{miscwnd} | |
513 | ||
f09b5681 | 514 | @see wxScrolled, ::wxScrolledCanvas |
16361ec9 VS |
515 | */ |
516 | typedef wxScrolled<wxPanel> wxScrolledWindow; | |
517 | ||
518 | /** | |
519 | Alias for wxScrolled<wxWindow>. Scrolled window that doesn't have children | |
520 | and so doesn't need or want special handling of TAB traversal. | |
521 | ||
522 | @since 2.9.0 | |
523 | ||
524 | @library{wxcore} | |
525 | @category{miscwnd} | |
526 | ||
527 | @see wxScrolled, ::wxScrolledWindow | |
528 | */ | |
529 | typedef wxScrolled<wxWindow> wxScrolledCanvas; |