]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: vscroll.h | |
3 | // Purpose: interface of wxVarHScrollHelper | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxVarScrollHelperBase | |
11 | @wxheader{vscroll.h} | |
12 | ||
13 | This class provides all common base functionality for scroll calculations | |
14 | shared among all variable scrolled window implementations as well as | |
15 | automatic scrollbar functionality, saved scroll positions, controlling | |
16 | target windows to be scrolled, as well as defining all required virtual | |
17 | functions that need to be implemented for any orientation specific work. | |
18 | ||
19 | Documentation of this class is provided specifically for referencing use | |
20 | of the functions provided by this class for use with the variable scrolled | |
21 | windows that derive from here. You will likely want to derive your window | |
22 | from one of the already implemented variable scrolled windows rather than | |
23 | from wxVarScrollHelperBase directly. | |
24 | ||
25 | @library{wxcore} | |
26 | @category{FIXME} | |
27 | ||
28 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow | |
29 | */ | |
30 | class wxVarScrollHelperBase | |
31 | { | |
32 | public: | |
33 | /** | |
34 | Constructor taking the target window to be scrolled by this helper class. | |
35 | This will attach scroll event handlers to the target window to catch and | |
36 | handle scroll events appropriately. | |
37 | */ | |
38 | wxVarScrollHelperBase(wxWindow* winToScroll); | |
39 | ||
40 | /** | |
41 | Virtual destructor for detaching scroll event handlers attached with this | |
42 | helper class. | |
43 | */ | |
44 | ~wxVarScrollHelperBase(); | |
45 | ||
46 | /** | |
47 | Translates the logical coordinate given to the current device coordinate. | |
48 | For example, if the window is scrolled 10 units and each scroll unit | |
49 | represents 10 device units (which may not be the case since this class allows | |
50 | for variable scroll unit sizes), a call to this function with a coordinate of | |
51 | 15 will return -85. | |
52 | ||
53 | @see CalcUnscrolledPosition() | |
54 | */ | |
55 | int CalcScrolledPosition(int coord) const; | |
56 | ||
57 | /** | |
58 | Translates the device coordinate given to the corresponding logical | |
59 | coordinate. For example, if the window is scrolled 10 units and each scroll | |
60 | unit represents 10 device units (which may not be the case since this class | |
61 | allows for variable scroll unit sizes), a call to this function with a | |
62 | coordinate of 15 will return 115. | |
63 | ||
64 | @see CalcScrolledPosition() | |
65 | */ | |
66 | int CalcUnscrolledPosition(int coord) const; | |
67 | ||
68 | /** | |
69 | With physical scrolling on (when this is @true), the device origin is | |
70 | changed properly when a wxPaintDC is prepared, | |
71 | children are actually moved and laid out properly, and the contents of the | |
72 | window (pixels) are actually moved. When this is @false, you are | |
73 | responsible for repainting any invalidated areas of the window yourself to | |
74 | account for the new scroll position. | |
75 | */ | |
76 | void EnablePhysicalScrolling(bool scrolling = true); | |
77 | ||
78 | /** | |
79 | When the number of scroll units change, we try to estimate the total size of | |
80 | all units when the full window size is needed (i.e. to calculate the scrollbar | |
81 | thumb size). This is a rather expensive operation in terms of unit access, so | |
82 | if the user code may estimate the average size better or faster than we do, it | |
83 | should override this function to implement its own logic. This function should | |
84 | return the best guess for the total virtual window size. | |
85 | Note that although returning a totally wrong value would still work, it risks | |
86 | resulting in very strange scrollbar behaviour so this function should really | |
87 | try to make the best guess possible. | |
88 | */ | |
89 | virtual wxCoord EstimateTotalSize() const; | |
90 | ||
91 | /** | |
92 | This function needs to be overridden in the in the derived class to return the | |
93 | window size with respect to the opposing orientation. If this is a vertical | |
94 | scrolled window, it should return the height. | |
95 | ||
96 | @see GetOrientationTargetSize() | |
97 | */ | |
98 | virtual int GetNonOrientationTargetSize() const; | |
99 | ||
100 | /** | |
101 | This function need to be overridden to return the orientation that this helper | |
102 | is working with, either @c wxHORIZONTAL or @c wxVERTICAL. | |
103 | */ | |
104 | virtual wxOrientation GetOrientation() const; | |
105 | ||
106 | /** | |
107 | This function needs to be overridden in the in the derived class to return the | |
108 | window size with respect to the orientation this helper is working with. If | |
109 | this is a vertical scrolled window, it should return the width. | |
110 | ||
111 | @see GetNonOrientationTargetSize() | |
112 | */ | |
113 | virtual int GetOrientationTargetSize() const; | |
114 | ||
115 | /** | |
116 | This function will return the target window this helper class is currently | |
117 | scrolling. | |
118 | ||
119 | @see SetTargetWindow() | |
120 | */ | |
121 | wxWindow* GetTargetWindow() const; | |
122 | ||
123 | /** | |
124 | Returns the index of the first visible unit based on the scroll position. | |
125 | */ | |
126 | size_t GetVisibleBegin() const; | |
127 | ||
128 | /** | |
129 | Returns the index of the last visible unit based on the scroll position. This | |
130 | includes the last unit even if it is only partially visible. | |
131 | */ | |
132 | size_t GetVisibleEnd() const; | |
133 | ||
134 | /** | |
135 | Returns @true if the given scroll unit is currently visible (even if only | |
136 | partially visible) or @false otherwise. | |
137 | */ | |
138 | bool IsVisible(size_t unit) const; | |
139 | ||
140 | /** | |
141 | This function must be overridden in the derived class, and should return the | |
142 | size of the given unit in pixels. | |
143 | */ | |
144 | virtual wxCoord OnGetUnitSize(size_t unit) const; | |
145 | ||
146 | /** | |
147 | This function doesn't have to be overridden but it may be useful to do so if | |
148 | calculating the units' sizes is a relatively expensive operation as it gives | |
149 | your code a chance to calculate several of them at once and cache the result | |
150 | if necessary. | |
151 | @c OnGetUnitsSizeHint() is normally called just before | |
152 | OnGetUnitSize() but you | |
153 | shouldn't rely on the latter being called for all units in the interval | |
154 | specified here. It is also possible that OnGetUnitSize() will be called for | |
155 | units outside of this interval, so this is really just a hint, not a promise. | |
156 | Finally, note that unitMin is inclusive, while unitMax is exclusive. | |
157 | */ | |
158 | virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const; | |
159 | ||
160 | /** | |
161 | Recalculate all parameters and repaint all units. | |
162 | */ | |
163 | virtual void RefreshAll(); | |
164 | ||
165 | /** | |
166 | Normally the window will scroll itself, but in some rare occasions you might | |
167 | want it to scroll (part of) another window (e.g. a child of it in order to | |
168 | scroll only a portion the area between the scrollbars like a spreadsheet where | |
169 | only the cell area will move). | |
170 | ||
171 | @see GetTargetWindow() | |
172 | */ | |
173 | void SetTargetWindow(wxWindow* target); | |
174 | ||
175 | /** | |
176 | Update the thumb size shown by the scrollbar. | |
177 | */ | |
178 | virtual void UpdateScrollbar(); | |
179 | ||
180 | /** | |
181 | Returns the virtual scroll unit under the device unit given accounting for | |
182 | scroll position or @c wxNOT_FOUND if none (i.e. if it is below the last | |
183 | item). | |
184 | */ | |
185 | int VirtualHitTest(wxCoord coord) const; | |
186 | }; | |
187 | ||
188 | ||
189 | ||
190 | /** | |
191 | @class wxVarVScrollHelper | |
192 | @wxheader{vscroll.h} | |
193 | ||
194 | This class provides functions wrapping the | |
195 | wxVarScrollHelperBase class, targeted for | |
196 | vertical-specific scrolling using wxVScrolledWindow. | |
197 | ||
198 | Like wxVarScrollHelperBase, this class is mostly only useful to those classes | |
199 | built into wxWidgets deriving from here, and this documentation is mostly | |
200 | only provided for referencing those functions provided. You will likely want | |
201 | to derive your window from wxVScrolledWindow rather than from here directly. | |
202 | ||
203 | @library{wxcore} | |
204 | @category{FIXME} | |
205 | ||
206 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow | |
207 | */ | |
208 | class wxVarVScrollHelper : public wxVarScrollHelperBase | |
209 | { | |
210 | public: | |
211 | /** | |
212 | Constructor taking the target window to be scrolled by this helper class. | |
213 | This will attach scroll event handlers to the target window to catch and | |
214 | handle scroll events appropriately. | |
215 | */ | |
216 | wxVarVScrollHelper(wxWindow* winToScroll); | |
217 | ||
218 | /** | |
219 | This class forwards calls from | |
220 | wxVarScrollHelperBase::EstimateTotalSize | |
221 | to this function so derived classes can override either just the height or | |
222 | the width estimation, or just estimate both differently if desired in any | |
223 | wxHVScrolledWindow derived class. | |
224 | Please note that this function will not be called if @c EstimateTotalSize() | |
225 | is overridden in your derived class. | |
226 | */ | |
227 | virtual wxCoord EstimateTotalHeight() const; | |
228 | ||
229 | /** | |
230 | Returns the number of rows the target window contains. | |
231 | ||
232 | @see SetRowCount() | |
233 | */ | |
234 | size_t GetRowCount() const; | |
235 | ||
236 | /** | |
237 | Returns the index of the first visible row based on the scroll position. | |
238 | */ | |
239 | size_t GetVisibleRowsBegin() const; | |
240 | ||
241 | /** | |
242 | Returns the index of the last visible row based on the scroll position. This | |
243 | includes the last row even if it is only partially visible. | |
244 | */ | |
245 | size_t GetVisibleRowsEnd() const; | |
246 | ||
247 | /** | |
248 | Returns @true if the given row is currently visible (even if only | |
249 | partially visible) or @false otherwise. | |
250 | */ | |
251 | bool IsRowVisible(size_t row) const; | |
252 | ||
253 | /** | |
254 | This function must be overridden in the derived class, and should return the | |
255 | height of the given row in pixels. | |
256 | */ | |
257 | virtual wxCoord OnGetRowHeight(size_t row) const; | |
258 | ||
259 | /** | |
260 | This function doesn't have to be overridden but it may be useful to do so if | |
261 | calculating the rows' sizes is a relatively expensive operation as it gives | |
262 | your code a chance to calculate several of them at once and cache the result | |
263 | if necessary. | |
264 | @c OnGetRowsHeightHint() is normally called just before | |
265 | OnGetRowHeight() but you | |
266 | shouldn't rely on the latter being called for all rows in the interval | |
267 | specified here. It is also possible that OnGetRowHeight() will be called for | |
268 | units outside of this interval, so this is really just a hint, not a promise. | |
269 | Finally, note that rowMin is inclusive, while rowMax is exclusive. | |
270 | */ | |
271 | virtual void OnGetRowsHeightHint(size_t rowMin, size_t rowMax) const; | |
272 | ||
273 | /** | |
274 | Triggers a refresh for just the given row's area of the window if it's visible. | |
275 | */ | |
276 | virtual void RefreshRow(size_t row); | |
277 | ||
278 | /** | |
279 | Triggers a refresh for the area between the specified range of rows given | |
280 | (inclusively). | |
281 | */ | |
282 | virtual void RefreshRows(size_t from, size_t to); | |
283 | ||
284 | /** | |
285 | Scroll by the specified number of pages which may be positive (to scroll down) | |
286 | or negative (to scroll up). | |
287 | */ | |
288 | virtual bool ScrollRowPages(int pages); | |
289 | ||
290 | /** | |
291 | Scroll by the specified number of rows which may be positive (to scroll down) | |
292 | or negative (to scroll up). | |
293 | Returns @true if the window was scrolled, @false otherwise (for | |
294 | example, if we're trying to scroll down but we are already showing the last | |
295 | row). | |
296 | */ | |
297 | virtual bool ScrollRows(int rows); | |
298 | ||
299 | /** | |
300 | Scroll to the specified row. It will become the first visible row in the window. | |
301 | Returns @true if we scrolled the window, @false if nothing was done. | |
302 | */ | |
303 | bool ScrollToRow(size_t row); | |
304 | ||
305 | /** | |
306 | Set the number of rows the window contains. The derived class must provide the | |
307 | heights for all rows with indices up to the one given here in it's | |
308 | OnGetRowHeight() implementation. | |
309 | */ | |
310 | void SetRowCount(size_t rowCount); | |
311 | }; | |
312 | ||
313 | ||
314 | ||
315 | /** | |
316 | @class wxVarHScrollHelper | |
317 | @wxheader{vscroll.h} | |
318 | ||
319 | This class provides functions wrapping the | |
320 | wxVarScrollHelperBase class, targeted for | |
321 | horizontal-specific scrolling using wxHScrolledWindow. | |
322 | ||
323 | Like wxVarScrollHelperBase, this class is mostly only useful to those classes | |
324 | built into wxWidgets deriving from here, and this documentation is mostly | |
325 | only provided for referencing those functions provided. You will likely want | |
326 | to derive your window from wxHScrolledWindow rather than from here directly. | |
327 | ||
328 | @library{wxcore} | |
329 | @category{FIXME} | |
330 | ||
331 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow | |
332 | */ | |
333 | class wxVarHScrollHelper : public wxVarScrollHelperBase | |
334 | { | |
335 | public: | |
336 | /** | |
337 | Constructor taking the target window to be scrolled by this helper class. | |
338 | This will attach scroll event handlers to the target window to catch and | |
339 | handle scroll events appropriately. | |
340 | */ | |
341 | wxVarHScrollHelper(wxWindow* winToScroll); | |
342 | ||
343 | /** | |
344 | This class forwards calls from | |
345 | wxVarScrollHelperBase::EstimateTotalSize | |
346 | to this function so derived classes can override either just the height or | |
347 | the width estimation, or just estimate both differently if desired in any | |
348 | wxHVScrolledWindow derived class. | |
349 | Please note that this function will not be called if @c EstimateTotalSize() | |
350 | is overridden in your derived class. | |
351 | */ | |
352 | virtual wxCoord EstimateTotalWidth() const; | |
353 | ||
354 | /** | |
355 | Returns the number of columns the target window contains. | |
356 | ||
357 | @see SetColumnCount() | |
358 | */ | |
359 | size_t GetColumnCount() const; | |
360 | ||
361 | /** | |
362 | Returns the index of the first visible column based on the scroll position. | |
363 | */ | |
364 | size_t GetVisibleColumnsBegin() const; | |
365 | ||
366 | /** | |
367 | Returns the index of the last visible column based on the scroll position. This | |
368 | includes the last column even if it is only partially visible. | |
369 | */ | |
370 | size_t GetVisibleColumnsEnd() const; | |
371 | ||
372 | /** | |
373 | Returns @true if the given column is currently visible (even if only | |
374 | partially visible) or @false otherwise. | |
375 | */ | |
376 | bool IsColumnVisible(size_t column) const; | |
377 | ||
378 | /** | |
379 | This function must be overridden in the derived class, and should return the | |
380 | width of the given column in pixels. | |
381 | */ | |
382 | virtual wxCoord OnGetColumnWidth(size_t column) const; | |
383 | ||
384 | /** | |
385 | This function doesn't have to be overridden but it may be useful to do so if | |
386 | calculating the columns' sizes is a relatively expensive operation as it gives | |
387 | your code a chance to calculate several of them at once and cache the result | |
388 | if necessary. | |
389 | @c OnGetColumnsWidthHint() is normally called just before | |
390 | OnGetColumnWidth() but you | |
391 | shouldn't rely on the latter being called for all columns in the interval | |
392 | specified here. It is also possible that OnGetColumnWidth() will be called for | |
393 | units outside of this interval, so this is really just a hint, not a promise. | |
394 | Finally, note that columnMin is inclusive, while columnMax is exclusive. | |
395 | */ | |
396 | virtual void OnGetColumnsWidthHint(size_t columnMin, | |
397 | size_t columnMax) const; | |
398 | ||
399 | /** | |
400 | Triggers a refresh for just the given column's area of the window if it's | |
401 | visible. | |
402 | */ | |
403 | virtual void RefreshColumn(size_t column); | |
404 | ||
405 | /** | |
406 | Triggers a refresh for the area between the specified range of columns given | |
407 | (inclusively). | |
408 | */ | |
409 | virtual void RefreshColumns(size_t from, size_t to); | |
410 | ||
411 | /** | |
412 | Scroll by the specified number of pages which may be positive (to scroll right) | |
413 | or negative (to scroll left). | |
414 | */ | |
415 | virtual bool ScrollColumnPages(int pages); | |
416 | ||
417 | /** | |
418 | Scroll by the specified number of columns which may be positive (to scroll | |
419 | right) | |
420 | or negative (to scroll left). | |
421 | Returns @true if the window was scrolled, @false otherwise (for | |
422 | example, if we're trying to scroll right but we are already showing the last | |
423 | column). | |
424 | */ | |
425 | virtual bool ScrollColumns(int columns); | |
426 | ||
427 | /** | |
428 | Scroll to the specified column. It will become the first visible column in the | |
429 | window. | |
430 | Returns @true if we scrolled the window, @false if nothing was done. | |
431 | */ | |
432 | bool ScrollToColumn(size_t column); | |
433 | ||
434 | /** | |
435 | Set the number of columns the window contains. The derived class must provide | |
436 | the widths for all columns with indices up to the one given here in it's | |
437 | OnGetColumnWidth() implementation. | |
438 | */ | |
439 | void SetColumnCount(size_t columnCount); | |
440 | }; | |
441 | ||
442 | ||
443 | ||
444 | /** | |
445 | @class wxVarHVScrollHelper | |
446 | @wxheader{vscroll.h} | |
447 | ||
448 | This class provides functions wrapping the | |
449 | wxVarHScrollHelper and | |
450 | wxVarVScrollHelper classes, targeted for | |
451 | scrolling a window in both axis using | |
452 | wxHVScrolledWindow. Since this class is also | |
453 | the join class of the horizontal and vertical scrolling functionality, it | |
454 | also addresses some wrappers that help avoid the need to specify class scope | |
455 | in your wxHVScrolledWindow-derived class when using wxVarScrollHelperBase | |
456 | functionality. | |
457 | ||
458 | Like all three of it's scroll helper base classes, this class is mostly only | |
459 | useful to those classes built into wxWidgets deriving from here, and this | |
460 | documentation is mostly only provided for referencing those functions | |
461 | provided. You will likely want to derive your window from wxHVScrolledWindow | |
462 | rather than from here directly. | |
463 | ||
464 | @library{wxcore} | |
465 | @category{FIXME} | |
466 | ||
467 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow | |
468 | */ | |
469 | class wxVarHVScrollHelper : public wxVarVScrollHelper, | |
470 | public wxVarHScrollHelper | |
471 | { | |
472 | public: | |
473 | /** | |
474 | Constructor taking the target window to be scrolled by this helper class. | |
475 | This will attach scroll event handlers to the target window to catch and | |
476 | handle scroll events appropriately. | |
477 | */ | |
478 | wxVarHVScrollHelper(wxWindow* winToScroll); | |
479 | ||
480 | /** | |
481 | With physical scrolling on (when this is @true), the device origin is | |
482 | changed properly when a wxPaintDC is prepared, | |
483 | children are actually moved and laid out properly, and the contents of the | |
484 | window (pixels) are actually moved. When this is @false, you are | |
485 | responsible for repainting any invalidated areas of the window yourself to | |
486 | account for the new scroll position. | |
487 | ||
488 | @param vscrolling | |
489 | Specifies if physical scrolling should be turned on when scrolling | |
490 | vertically. | |
491 | @param hscrolling | |
492 | Specifies if physical scrolling should be turned on when scrolling | |
493 | horizontally. | |
494 | */ | |
495 | void EnablePhysicalScrolling(bool vscrolling = true, | |
496 | bool hscrolling = true); | |
497 | ||
498 | /** | |
499 | Returns the number of columns and rows the target window contains. | |
500 | ||
501 | @see SetRowColumnCount() | |
502 | */ | |
503 | wxSize GetRowColumnCount() const; | |
504 | ||
505 | /** | |
506 | Returns the index of the first visible column and row based on the current | |
507 | scroll position. | |
508 | */ | |
509 | wxPosition GetVisibleBegin() const; | |
510 | ||
511 | /** | |
512 | Returns the index of the last visible column and row based on the scroll | |
513 | position. This includes any partially visible columns or rows. | |
514 | */ | |
515 | wxPosition GetVisibleEnd() const; | |
516 | ||
517 | //@{ | |
518 | /** | |
519 | Returns @true if both the given row and column are currently visible | |
520 | (even if only partially visible) or @false otherwise. | |
521 | */ | |
522 | bool IsVisible(size_t row, size_t column) const; | |
523 | const bool IsVisible(const wxPosition& pos) const; | |
524 | //@} | |
525 | ||
526 | //@{ | |
527 | /** | |
528 | Triggers a refresh for just the area shared between the given row and column | |
529 | of the window if it is visible. | |
530 | */ | |
531 | virtual void RefreshRowColumn(size_t row, size_t column); | |
532 | virtual void RefreshRowColumn(const wxPosition& pos); | |
533 | //@} | |
534 | ||
535 | //@{ | |
536 | /** | |
537 | Triggers a refresh for the visible area shared between all given rows and | |
538 | columns (inclusive) of the window. If the target window for both orientations | |
539 | is the same, the rectangle of cells is refreshed; if the target windows | |
540 | differ, the entire client size opposite the orientation direction is | |
541 | refreshed between the specified limits. | |
542 | */ | |
543 | virtual void RefreshRowsColumns(size_t fromRow, size_t toRow, | |
544 | size_t fromColumn, | |
545 | size_t toColumn); | |
546 | virtual void RefreshRowsColumns(const wxPosition& from, | |
547 | const wxPosition& to); | |
548 | //@} | |
549 | ||
550 | //@{ | |
551 | /** | |
552 | Scroll to the specified row and column. It will become the first visible row | |
553 | and column in the window. Returns @true if we scrolled the window, | |
554 | @false if nothing was done. | |
555 | */ | |
556 | bool ScrollToRowColumn(size_t row, size_t column); | |
557 | bool ScrollToRowColumn(const wxPosition& pos); | |
558 | //@} | |
559 | ||
560 | /** | |
561 | Set the number of rows and columns the target window will contain. The | |
562 | derived class must provide the sizes for all rows and columns with indices up | |
563 | to the ones given here in it's wxVarVScrollHelper::OnGetRowHeight | |
564 | and wxVarHScrollHelper::OnGetColumnWidth implementations, | |
565 | respectively. | |
566 | */ | |
567 | void SetRowColumnCount(size_t rowCount, size_t columnCount); | |
568 | ||
569 | //@{ | |
570 | /** | |
571 | Returns the virtual scroll unit under the device unit given accounting for | |
572 | scroll position or @c wxNOT_FOUND (for the row, column, or possibly both | |
573 | values) if none. | |
574 | */ | |
575 | wxPosition VirtualHitTest(wxCoord x, wxCoord y) const; | |
576 | const wxPosition VirtualHitTest(const wxPoint& pos) const; | |
577 | //@} | |
578 | }; | |
579 | ||
580 | ||
581 | ||
582 | /** | |
583 | @class wxVScrolledWindow | |
584 | @wxheader{vscroll.h} | |
585 | ||
586 | In the name of this class, "V" may stand for "variable" because it can be | |
587 | used for scrolling rows of variable heights; "virtual", because it is not | |
588 | necessary to know the heights of all rows in advance -- only those which | |
589 | are shown on the screen need to be measured; or even "vertical", because | |
590 | this class only supports scrolling vertically. | |
591 | ||
592 | In any case, this is a generalization of the | |
593 | wxScrolledWindow class which can be only used when | |
594 | all rows have the same heights. It lacks some other wxScrolledWindow features | |
595 | however, notably it can't scroll only a rectangle of the window and not its | |
596 | entire client area. | |
597 | ||
598 | To use this class, you need to derive from it and implement the | |
599 | wxVarVScrollHelper::OnGetRowHeight pure virtual | |
600 | method. You also must call wxVarVScrollHelper::SetRowCount | |
601 | to let the base class know how many rows it should display, but from that | |
602 | moment on the scrolling is handled entirely by wxVScrolledWindow. You only | |
603 | need to draw the visible part of contents in your @c OnPaint() method as | |
604 | usual. You should use wxVarVScrollHelper::GetVisibleRowsBegin | |
605 | and wxVarVScrollHelper::GetVisibleRowsEnd to | |
606 | select the lines to display. Note that the device context origin is not shifted | |
607 | so the first visible row always appears at the point (0, 0) in physical as | |
608 | well as logical coordinates. | |
609 | ||
610 | @library{wxcore} | |
611 | @category{miscwnd} | |
612 | ||
613 | @see wxHScrolledWindow, wxHVScrolledWindow | |
614 | */ | |
615 | class wxVScrolledWindow : public wxPanel, public wxVarVScrollHelper | |
616 | { | |
617 | public: | |
618 | //@{ | |
619 | /** | |
620 | This is the normal constructor, no need to call @c Create() after using this | |
621 | one. | |
622 | Note that @c wxVSCROLL is always automatically added to our style, there is | |
623 | no need to specify it explicitly. | |
624 | ||
625 | @param parent | |
626 | The parent window, must not be @NULL | |
627 | @param id | |
628 | The identifier of this window, wxID_ANY by default | |
629 | @param pos | |
630 | The initial window position | |
631 | @param size | |
632 | The initial window size | |
633 | @param style | |
634 | The window style. There are no special style bits defined for | |
635 | this class. | |
636 | @param name | |
637 | The name for this window; usually not used | |
638 | */ | |
639 | wxVScrolledWindow(); | |
640 | wxVScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY, | |
641 | const wxPoint& pos = wxDefaultPosition, | |
642 | const wxSize& size = wxDefaultSize, | |
643 | long style = 0, | |
644 | const wxString& name = wxPanelNameStr); | |
645 | //@} | |
646 | ||
647 | /** | |
648 | Same as the @ref wxvscrolledwindow() "non-default constuctor" | |
649 | but returns status code: @true if ok, @false if the window couldn't | |
650 | be created. | |
651 | Just as with the constructor above, the @c wxVSCROLL style is always used, | |
652 | there is no need to specify it explicitly. | |
653 | */ | |
654 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
655 | const wxPoint& pos = wxDefaultPosition, | |
656 | const wxSize& size = wxDefaultSize, | |
657 | long style = 0, | |
658 | const wxString& name = wxPanelNameStr); | |
659 | ||
660 | //@{ | |
661 | /** | |
662 | The following functions provide backwards compatibility for applications | |
663 | originally built using wxVScrolledWindow in 2.6 or 2.8. Originally, | |
664 | wxVScrolledWindow referred to scrolling "lines". We now use "units" in | |
665 | wxVarScrollHelperBase to avoid implying any orientation (since the functions | |
666 | are used for both horizontal and vertical scrolling in derived classes). And | |
667 | in the new wxVScrolledWindow and wxHScrolledWindow classes, we refer to them | |
668 | as "rows" and "columns", respectively. This is to help clear some confusion | |
669 | in not only those classes, but also in wxHVScrolledWindow where functions | |
670 | are inherited from both. | |
671 | You are encouraged to update any existing code using these function to use | |
672 | the new replacements mentioned below, and avoid using these functions for | |
673 | any new code as they are deprecated. | |
674 | ||
675 | Deprecated for wxVarVScrollHelper::SetRowCount. | |
676 | */ | |
677 | size_t GetFirstVisibleLine(); | |
678 | const size_t GetLastVisibleLine(); | |
679 | const size_t GetLineCount(); | |
680 | const int HitTest(wxCoord x, wxCoord y); | |
681 | const int HitTest(const wxPoint& pt); | |
682 | const virtual wxCoord OnGetLineHeight(size_t line); | |
683 | const virtual void OnGetLinesHint(size_t lineMin, | |
684 | size_t lineMax); | |
685 | const virtual void RefreshLine(size_t line); | |
686 | virtual void RefreshLines(size_t from, size_t to); | |
687 | virtual bool ScrollLines(int lines); | |
688 | virtual bool ScrollPages(int pages); | |
689 | bool ScrollToLine(size_t line); | |
690 | void SetLineCount(size_t count); | |
691 | //@} | |
692 | }; | |
693 | ||
694 | ||
695 | ||
696 | /** | |
697 | @class wxHScrolledWindow | |
698 | @wxheader{vscroll.h} | |
699 | ||
700 | In the name of this class, "H" stands for "horizontal" because it can be | |
701 | used for scrolling columns of variable widths. It is not necessary to know | |
702 | the widths of all columns in advance -- only those which are shown on the | |
703 | screen need to be measured. | |
704 | ||
705 | In any case, this is a generalization of the | |
706 | wxScrolledWindow class which can be only used when | |
707 | all columns have the same widths. It lacks some other wxScrolledWindow features | |
708 | however, notably it can't scroll only a rectangle of the window and not its | |
709 | entire client area. | |
710 | ||
711 | To use this class, you need to derive from it and implement the | |
712 | wxVarHScrollHelper::OnGetColumnWidth pure virtual | |
713 | method. You also must call wxVarHScrollHelper::SetColumnCount | |
714 | to let the base class know how many columns it should display, but from that | |
715 | moment on the scrolling is handled entirely by wxHScrolledWindow. You only | |
716 | need to draw the visible part of contents in your @c OnPaint() method as | |
717 | usual. You should use wxVarHScrollHelper::GetVisibleColumnsBegin | |
718 | and wxVarHScrollHelper::GetVisibleColumnsEnd to | |
719 | select the lines to display. Note that the device context origin is not shifted | |
720 | so the first visible column always appears at the point (0, 0) in physical as | |
721 | well as logical coordinates. | |
722 | ||
723 | @library{wxcore} | |
724 | @category{FIXME} | |
725 | ||
726 | @see wxHVScrolledWindow, wxVScrolledWindow | |
727 | */ | |
728 | class wxHScrolledWindow : public wxPanel, public wxVarHScrollHelper | |
729 | { | |
730 | public: | |
731 | //@{ | |
732 | /** | |
733 | This is the normal constructor, no need to call @c Create() after using this | |
734 | one. | |
735 | Note that @c wxHSCROLL is always automatically added to our style, there is | |
736 | no need to specify it explicitly. | |
737 | ||
738 | @param parent | |
739 | The parent window, must not be @NULL | |
740 | @param id | |
741 | The identifier of this window, wxID_ANY by default | |
742 | @param pos | |
743 | The initial window position | |
744 | @param size | |
745 | The initial window size | |
746 | @param style | |
747 | The window style. There are no special style bits defined for | |
748 | this class. | |
749 | @param name | |
750 | The name for this window; usually not used | |
751 | */ | |
752 | wxHScrolledWindow(); | |
753 | wxHScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY, | |
754 | const wxPoint& pos = wxDefaultPosition, | |
755 | const wxSize& size = wxDefaultSize, | |
756 | long style = 0, | |
757 | const wxString& name = wxPanelNameStr); | |
758 | //@} | |
759 | ||
760 | /** | |
761 | Same as the @ref wxhscrolledwindow() "non-default constuctor" | |
762 | but returns status code: @true if ok, @false if the window couldn't | |
763 | be created. | |
764 | Just as with the constructor above, the @c wxHSCROLL style is always used, | |
765 | there is no need to specify it explicitly. | |
766 | */ | |
767 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
768 | const wxPoint& pos = wxDefaultPosition, | |
769 | const wxSize& size = wxDefaultSize, | |
770 | long style = 0, | |
771 | const wxString& name = wxPanelNameStr); | |
772 | }; | |
773 | ||
774 | ||
775 | ||
776 | /** | |
777 | @class wxHVScrolledWindow | |
778 | @wxheader{vscroll.h} | |
779 | ||
780 | This window inherits all functionality of both vertical and horizontal, | |
781 | variable scrolled windows. It automatically handles everything needed to | |
782 | scroll both axis simultaneously with both variable row heights and variable | |
783 | column widths. | |
784 | ||
785 | This is a generalization of the wxScrolledWindow | |
786 | class which can be only used when all rows and columns are the same size. It | |
787 | lacks some other wxScrolledWindow features however, notably it can't scroll | |
788 | only a rectangle of the window and not its entire client area. | |
789 | ||
790 | To use this class, you must derive from it and implement both the | |
791 | wxVarVScrollHelper::OnGetRowHeight and | |
792 | wxVarHScrollHelper::OnGetColumnWidth pure virtual | |
793 | methods to let the base class know how many rows and columns it should | |
794 | display. You also need to set the total rows and columns the window contains, | |
795 | but from that moment on the scrolling is handled entirely by | |
796 | wxHVScrolledWindow. You only need to draw the visible part of contents in | |
797 | your @c OnPaint() method as usual. You should use | |
798 | wxVarHVScrollHelper::GetVisibleBegin | |
799 | and wxVarHVScrollHelper::GetVisibleEnd to select the | |
800 | lines to display. Note that the device context origin is not shifted so the | |
801 | first visible row and column always appear at the point (0, 0) in physical | |
802 | as well as logical coordinates. | |
803 | ||
804 | @library{wxcore} | |
805 | @category{FIXME} | |
806 | ||
807 | @see wxHScrolledWindow, wxVScrolledWindow | |
808 | */ | |
809 | class wxHVScrolledWindow : public wxPanel, public wxVarHVScrollHelper | |
810 | { | |
811 | public: | |
812 | //@{ | |
813 | /** | |
814 | This is the normal constructor, no need to call @c Create() after using this | |
815 | one. | |
816 | Note that @c wxHSCROLL and @c wxVSCROLL are always automatically added | |
817 | to our styles, there is no need to specify it explicitly. | |
818 | ||
819 | @param parent | |
820 | The parent window, must not be @NULL | |
821 | @param id | |
822 | The identifier of this window, wxID_ANY by default | |
823 | @param pos | |
824 | The initial window position | |
825 | @param size | |
826 | The initial window size | |
827 | @param style | |
828 | The window style. There are no special style bits defined for | |
829 | this class. | |
830 | @param name | |
831 | The name for this window; usually not used | |
832 | */ | |
833 | wxHVScrolledWindow(); | |
834 | wxHVScrolledWindow(wxWindow* parent, | |
835 | wxWindowID id = wxID_ANY, | |
836 | const wxPoint& pos = wxDefaultPosition, | |
837 | const wxSize& size = wxDefaultSize, | |
838 | long style = 0, | |
839 | const wxString& name = wxPanelNameStr); | |
840 | //@} | |
841 | ||
842 | /** | |
843 | Same as the @ref wxhvscrolledwindow() "non-default constuctor" | |
844 | but returns status code: @true if ok, @false if the window couldn't | |
845 | be created. | |
846 | Just as with the constructor above, the @c wxHSCROLL and @c wxVSCROLL | |
847 | styles are always used, there is no need to specify it explicitly. | |
848 | */ | |
849 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
850 | const wxPoint& pos = wxDefaultPosition, | |
851 | const wxSize& size = wxDefaultSize, | |
852 | long style = 0, | |
853 | const wxString& name = wxPanelNameStr); | |
854 | }; | |
855 |