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