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