]>
Commit | Line | Data |
---|---|---|
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 FM |
25 | @library{wxcore} |
26 | @category{FIXME} | |
7c913512 | 27 | |
e54c96f1 | 28 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow |
23324ae1 | 29 | */ |
6f022dba | 30 | class wxVarScrollHelperBase |
23324ae1 FM |
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 | */ | |
6f022dba | 38 | wxVarScrollHelperBase(wxWindow* winToScroll); |
23324ae1 FM |
39 | |
40 | /** | |
6f022dba BP |
41 | Virtual destructor for detaching scroll event handlers attached with this |
42 | helper class. | |
23324ae1 | 43 | */ |
6f022dba | 44 | ~wxVarScrollHelperBase(); |
23324ae1 FM |
45 | |
46 | /** | |
6f022dba BP |
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. | |
3c4f71cc | 52 | |
6f022dba | 53 | @see CalcUnscrolledPosition() |
23324ae1 | 54 | */ |
6f022dba | 55 | int CalcScrolledPosition(int coord) const; |
23324ae1 FM |
56 | |
57 | /** | |
6f022dba BP |
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() | |
23324ae1 | 65 | */ |
6f022dba | 66 | int CalcUnscrolledPosition(int coord) const; |
23324ae1 FM |
67 | |
68 | /** | |
6f022dba BP |
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. | |
23324ae1 | 75 | */ |
6f022dba | 76 | void EnablePhysicalScrolling(bool scrolling = true); |
23324ae1 FM |
77 | |
78 | /** | |
6f022dba BP |
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 | |
23324ae1 FM |
136 | partially visible) or @false otherwise. |
137 | */ | |
6f022dba | 138 | bool IsVisible(size_t unit) const; |
23324ae1 FM |
139 | |
140 | /** | |
141 | This function must be overridden in the derived class, and should return the | |
6f022dba | 142 | size of the given unit in pixels. |
23324ae1 | 143 | */ |
6f022dba | 144 | virtual wxCoord OnGetUnitSize(size_t unit) const; |
23324ae1 FM |
145 | |
146 | /** | |
147 | This function doesn't have to be overridden but it may be useful to do so if | |
6f022dba | 148 | calculating the units' sizes is a relatively expensive operation as it gives |
23324ae1 FM |
149 | your code a chance to calculate several of them at once and cache the result |
150 | if necessary. | |
6f022dba BP |
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 | |
23324ae1 | 155 | units outside of this interval, so this is really just a hint, not a promise. |
6f022dba | 156 | Finally, note that unitMin is inclusive, while unitMax is exclusive. |
23324ae1 | 157 | */ |
6f022dba | 158 | virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const; |
23324ae1 FM |
159 | |
160 | /** | |
6f022dba | 161 | Recalculate all parameters and repaint all units. |
23324ae1 | 162 | */ |
6f022dba | 163 | virtual void RefreshAll(); |
23324ae1 FM |
164 | |
165 | /** | |
6f022dba BP |
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). | |
23324ae1 | 170 | |
6f022dba | 171 | @see GetTargetWindow() |
23324ae1 | 172 | */ |
6f022dba | 173 | void SetTargetWindow(wxWindow* target); |
23324ae1 FM |
174 | |
175 | /** | |
6f022dba | 176 | Update the thumb size shown by the scrollbar. |
23324ae1 | 177 | */ |
6f022dba | 178 | virtual void UpdateScrollbar(); |
23324ae1 FM |
179 | |
180 | /** | |
6f022dba BP |
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). | |
23324ae1 | 184 | */ |
6f022dba | 185 | int VirtualHitTest(wxCoord coord) const; |
23324ae1 FM |
186 | }; |
187 | ||
188 | ||
e54c96f1 | 189 | |
23324ae1 FM |
190 | /** |
191 | @class wxVarVScrollHelper | |
192 | @wxheader{vscroll.h} | |
7c913512 FM |
193 | |
194 | This class provides functions wrapping the | |
23324ae1 FM |
195 | wxVarScrollHelperBase class, targeted for |
196 | vertical-specific scrolling using wxVScrolledWindow. | |
7c913512 | 197 | |
23324ae1 FM |
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. | |
7c913512 | 202 | |
23324ae1 FM |
203 | @library{wxcore} |
204 | @category{FIXME} | |
7c913512 | 205 | |
e54c96f1 | 206 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow |
23324ae1 FM |
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. | |
23324ae1 FM |
224 | Please note that this function will not be called if @c EstimateTotalSize() |
225 | is overridden in your derived class. | |
226 | */ | |
328f5751 | 227 | virtual wxCoord EstimateTotalHeight() const; |
23324ae1 FM |
228 | |
229 | /** | |
230 | Returns the number of rows the target window contains. | |
3c4f71cc | 231 | |
4cc4bfaf | 232 | @see SetRowCount() |
23324ae1 | 233 | */ |
328f5751 | 234 | size_t GetRowCount() const; |
23324ae1 FM |
235 | |
236 | /** | |
237 | Returns the index of the first visible row based on the scroll position. | |
238 | */ | |
328f5751 | 239 | size_t GetVisibleRowsBegin() const; |
23324ae1 FM |
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 | */ | |
328f5751 | 245 | size_t GetVisibleRowsEnd() const; |
23324ae1 FM |
246 | |
247 | /** | |
248 | Returns @true if the given row is currently visible (even if only | |
249 | partially visible) or @false otherwise. | |
250 | */ | |
328f5751 | 251 | bool IsRowVisible(size_t row) const; |
23324ae1 FM |
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 | */ | |
328f5751 | 257 | virtual wxCoord OnGetRowHeight(size_t row) const; |
23324ae1 FM |
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. | |
23324ae1 FM |
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. | |
23324ae1 FM |
269 | Finally, note that rowMin is inclusive, while rowMax is exclusive. |
270 | */ | |
328f5751 | 271 | virtual void OnGetRowsHeightHint(size_t rowMin, size_t rowMax) const; |
23324ae1 FM |
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). | |
23324ae1 FM |
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. | |
23324ae1 FM |
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 | ||
e54c96f1 | 314 | |
23324ae1 | 315 | /** |
6f022dba | 316 | @class wxVarHScrollHelper |
23324ae1 | 317 | @wxheader{vscroll.h} |
7c913512 | 318 | |
6f022dba BP |
319 | This class provides functions wrapping the |
320 | wxVarScrollHelperBase class, targeted for | |
321 | horizontal-specific scrolling using wxHScrolledWindow. | |
7c913512 | 322 | |
6f022dba BP |
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. | |
7c913512 | 327 | |
23324ae1 FM |
328 | @library{wxcore} |
329 | @category{FIXME} | |
7c913512 | 330 | |
e54c96f1 | 331 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow |
23324ae1 | 332 | */ |
6f022dba | 333 | class wxVarHScrollHelper : public wxVarScrollHelperBase |
23324ae1 FM |
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 | */ | |
6f022dba | 341 | wxVarHScrollHelper(wxWindow* winToScroll); |
23324ae1 FM |
342 | |
343 | /** | |
6f022dba BP |
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. | |
23324ae1 | 351 | */ |
6f022dba | 352 | virtual wxCoord EstimateTotalWidth() const; |
23324ae1 FM |
353 | |
354 | /** | |
6f022dba | 355 | Returns the number of columns the target window contains. |
3c4f71cc | 356 | |
6f022dba | 357 | @see SetColumnCount() |
23324ae1 | 358 | */ |
6f022dba | 359 | size_t GetColumnCount() const; |
23324ae1 FM |
360 | |
361 | /** | |
6f022dba BP |
362 | Returns the index of the first visible column based on the scroll position. |
363 | */ | |
364 | size_t GetVisibleColumnsBegin() const; | |
3c4f71cc | 365 | |
6f022dba BP |
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. | |
23324ae1 | 369 | */ |
6f022dba | 370 | size_t GetVisibleColumnsEnd() const; |
23324ae1 FM |
371 | |
372 | /** | |
6f022dba BP |
373 | Returns @true if the given column is currently visible (even if only |
374 | partially visible) or @false otherwise. | |
23324ae1 | 375 | */ |
6f022dba | 376 | bool IsColumnVisible(size_t column) const; |
23324ae1 FM |
377 | |
378 | /** | |
6f022dba BP |
379 | This function must be overridden in the derived class, and should return the |
380 | width of the given column in pixels. | |
23324ae1 | 381 | */ |
6f022dba | 382 | virtual wxCoord OnGetColumnWidth(size_t column) const; |
23324ae1 FM |
383 | |
384 | /** | |
6f022dba BP |
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; | |
3c4f71cc | 398 | |
6f022dba BP |
399 | /** |
400 | Triggers a refresh for just the given column's area of the window if it's | |
401 | visible. | |
23324ae1 | 402 | */ |
6f022dba | 403 | virtual void RefreshColumn(size_t column); |
23324ae1 FM |
404 | |
405 | /** | |
6f022dba BP |
406 | Triggers a refresh for the area between the specified range of columns given |
407 | (inclusively). | |
23324ae1 | 408 | */ |
6f022dba | 409 | virtual void RefreshColumns(size_t from, size_t to); |
23324ae1 FM |
410 | |
411 | /** | |
6f022dba BP |
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); | |
3c4f71cc | 416 | |
6f022dba BP |
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). | |
23324ae1 | 424 | */ |
6f022dba | 425 | virtual bool ScrollColumns(int columns); |
23324ae1 FM |
426 | |
427 | /** | |
6f022dba BP |
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); | |
3c4f71cc | 433 | |
6f022dba BP |
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. | |
23324ae1 | 438 | */ |
6f022dba BP |
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} | |
23324ae1 | 466 | |
6f022dba BP |
467 | @see wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow |
468 | */ | |
469 | class wxVarHVScrollHelper : public wxVarVScrollHelper, | |
470 | public wxVarHScrollHelper | |
471 | { | |
472 | public: | |
23324ae1 | 473 | /** |
6f022dba BP |
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. | |
23324ae1 | 477 | */ |
6f022dba | 478 | wxVarHVScrollHelper(wxWindow* winToScroll); |
23324ae1 FM |
479 | |
480 | /** | |
6f022dba BP |
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. | |
23324ae1 | 494 | */ |
6f022dba BP |
495 | void EnablePhysicalScrolling(bool vscrolling = true, |
496 | bool hscrolling = true); | |
23324ae1 FM |
497 | |
498 | /** | |
6f022dba BP |
499 | Returns the number of columns and rows the target window contains. |
500 | ||
501 | @see SetRowColumnCount() | |
23324ae1 | 502 | */ |
6f022dba | 503 | wxSize GetRowColumnCount() const; |
23324ae1 FM |
504 | |
505 | /** | |
6f022dba BP |
506 | Returns the index of the first visible column and row based on the current |
507 | scroll position. | |
23324ae1 | 508 | */ |
6f022dba | 509 | wxPosition GetVisibleBegin() const; |
23324ae1 FM |
510 | |
511 | /** | |
6f022dba BP |
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. | |
23324ae1 | 514 | */ |
6f022dba | 515 | wxPosition GetVisibleEnd() const; |
23324ae1 | 516 | |
6f022dba | 517 | //@{ |
23324ae1 | 518 | /** |
6f022dba BP |
519 | Returns @true if both the given row and column are currently visible |
520 | (even if only partially visible) or @false otherwise. | |
23324ae1 | 521 | */ |
6f022dba BP |
522 | bool IsVisible(size_t row, size_t column) const; |
523 | const bool IsVisible(const wxPosition& pos) const; | |
524 | //@} | |
23324ae1 | 525 | |
6f022dba | 526 | //@{ |
23324ae1 | 527 | /** |
6f022dba BP |
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 | //@} | |
3c4f71cc | 534 | |
6f022dba BP |
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. | |
23324ae1 | 542 | */ |
6f022dba BP |
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 | //@} | |
23324ae1 | 549 | |
6f022dba | 550 | //@{ |
23324ae1 | 551 | /** |
6f022dba BP |
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. | |
23324ae1 | 555 | */ |
6f022dba BP |
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); | |
23324ae1 | 568 | |
6f022dba | 569 | //@{ |
23324ae1 FM |
570 | /** |
571 | Returns the virtual scroll unit under the device unit given accounting for | |
6f022dba BP |
572 | scroll position or @c wxNOT_FOUND (for the row, column, or possibly both |
573 | values) if none. | |
23324ae1 | 574 | */ |
6f022dba BP |
575 | wxPosition VirtualHitTest(wxCoord x, wxCoord y) const; |
576 | const wxPosition VirtualHitTest(const wxPoint& pos) const; | |
577 | //@} | |
23324ae1 FM |
578 | }; |
579 | ||
580 | ||
e54c96f1 | 581 | |
23324ae1 FM |
582 | /** |
583 | @class wxVScrolledWindow | |
584 | @wxheader{vscroll.h} | |
7c913512 | 585 | |
23324ae1 FM |
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. | |
7c913512 | 591 | |
f09b5681 BP |
592 | In any case, this is a generalization of wxScrolled which can be only used |
593 | when all rows have the same heights. It lacks some other wxScrolled | |
594 | features however, notably it can't scroll only a rectangle of the window | |
595 | and not its entire client area. | |
7c913512 | 596 | |
23324ae1 FM |
597 | To use this class, you need to derive from it and implement the |
598 | wxVarVScrollHelper::OnGetRowHeight pure virtual | |
599 | method. You also must call wxVarVScrollHelper::SetRowCount | |
600 | to let the base class know how many rows it should display, but from that | |
601 | moment on the scrolling is handled entirely by wxVScrolledWindow. You only | |
602 | need to draw the visible part of contents in your @c OnPaint() method as | |
603 | usual. You should use wxVarVScrollHelper::GetVisibleRowsBegin | |
604 | and wxVarVScrollHelper::GetVisibleRowsEnd to | |
605 | select the lines to display. Note that the device context origin is not shifted | |
606 | so the first visible row always appears at the point (0, 0) in physical as | |
607 | well as logical coordinates. | |
7c913512 | 608 | |
23324ae1 FM |
609 | @library{wxcore} |
610 | @category{miscwnd} | |
7c913512 | 611 | |
e54c96f1 | 612 | @see wxHScrolledWindow, wxHVScrolledWindow |
23324ae1 | 613 | */ |
6f022dba | 614 | class wxVScrolledWindow : public wxPanel, public wxVarVScrollHelper |
23324ae1 FM |
615 | { |
616 | public: | |
617 | //@{ | |
618 | /** | |
619 | This is the normal constructor, no need to call @c Create() after using this | |
620 | one. | |
23324ae1 FM |
621 | Note that @c wxVSCROLL is always automatically added to our style, there is |
622 | no need to specify it explicitly. | |
3c4f71cc | 623 | |
7c913512 | 624 | @param parent |
4cc4bfaf | 625 | The parent window, must not be @NULL |
7c913512 | 626 | @param id |
4cc4bfaf | 627 | The identifier of this window, wxID_ANY by default |
7c913512 | 628 | @param pos |
4cc4bfaf | 629 | The initial window position |
7c913512 | 630 | @param size |
4cc4bfaf | 631 | The initial window size |
7c913512 | 632 | @param style |
4cc4bfaf FM |
633 | The window style. There are no special style bits defined for |
634 | this class. | |
7c913512 | 635 | @param name |
4cc4bfaf | 636 | The name for this window; usually not used |
23324ae1 FM |
637 | */ |
638 | wxVScrolledWindow(); | |
7c913512 FM |
639 | wxVScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY, |
640 | const wxPoint& pos = wxDefaultPosition, | |
641 | const wxSize& size = wxDefaultSize, | |
642 | long style = 0, | |
643 | const wxString& name = wxPanelNameStr); | |
23324ae1 FM |
644 | //@} |
645 | ||
646 | /** | |
647 | Same as the @ref wxvscrolledwindow() "non-default constuctor" | |
648 | but returns status code: @true if ok, @false if the window couldn't | |
649 | be created. | |
23324ae1 FM |
650 | Just as with the constructor above, the @c wxVSCROLL style is always used, |
651 | there is no need to specify it explicitly. | |
652 | */ | |
653 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
654 | const wxPoint& pos = wxDefaultPosition, | |
655 | const wxSize& size = wxDefaultSize, | |
656 | long style = 0, | |
657 | const wxString& name = wxPanelNameStr); | |
658 | ||
659 | //@{ | |
660 | /** | |
661 | The following functions provide backwards compatibility for applications | |
662 | originally built using wxVScrolledWindow in 2.6 or 2.8. Originally, | |
663 | wxVScrolledWindow referred to scrolling "lines". We now use "units" in | |
664 | wxVarScrollHelperBase to avoid implying any orientation (since the functions | |
665 | are used for both horizontal and vertical scrolling in derived classes). And | |
666 | in the new wxVScrolledWindow and wxHScrolledWindow classes, we refer to them | |
667 | as "rows" and "columns", respectively. This is to help clear some confusion | |
668 | in not only those classes, but also in wxHVScrolledWindow where functions | |
669 | are inherited from both. | |
23324ae1 FM |
670 | You are encouraged to update any existing code using these function to use |
671 | the new replacements mentioned below, and avoid using these functions for | |
672 | any new code as they are deprecated. | |
3c4f71cc | 673 | |
23324ae1 FM |
674 | Deprecated for wxVarVScrollHelper::SetRowCount. |
675 | */ | |
676 | size_t GetFirstVisibleLine(); | |
328f5751 FM |
677 | const size_t GetLastVisibleLine(); |
678 | const size_t GetLineCount(); | |
679 | const int HitTest(wxCoord x, wxCoord y); | |
680 | const int HitTest(const wxPoint& pt); | |
681 | const virtual wxCoord OnGetLineHeight(size_t line); | |
682 | const virtual void OnGetLinesHint(size_t lineMin, | |
683 | size_t lineMax); | |
684 | const virtual void RefreshLine(size_t line); | |
7c913512 FM |
685 | virtual void RefreshLines(size_t from, size_t to); |
686 | virtual bool ScrollLines(int lines); | |
687 | virtual bool ScrollPages(int pages); | |
688 | bool ScrollToLine(size_t line); | |
689 | void SetLineCount(size_t count); | |
23324ae1 FM |
690 | //@} |
691 | }; | |
692 | ||
693 | ||
e54c96f1 | 694 | |
23324ae1 | 695 | /** |
6f022dba | 696 | @class wxHScrolledWindow |
23324ae1 | 697 | @wxheader{vscroll.h} |
7c913512 | 698 | |
6f022dba BP |
699 | In the name of this class, "H" stands for "horizontal" because it can be |
700 | used for scrolling columns of variable widths. It is not necessary to know | |
701 | the widths of all columns in advance -- only those which are shown on the | |
702 | screen need to be measured. | |
7c913512 | 703 | |
f09b5681 BP |
704 | In any case, this is a generalization of wxScrolled which can be only used |
705 | when all columns have the same widths. It lacks some other wxScrolled | |
706 | features however, notably it can't scroll only a rectangle of the window | |
707 | and not its entire client area. | |
7c913512 | 708 | |
6f022dba | 709 | To use this class, you need to derive from it and implement the |
23324ae1 | 710 | wxVarHScrollHelper::OnGetColumnWidth pure virtual |
6f022dba BP |
711 | method. You also must call wxVarHScrollHelper::SetColumnCount |
712 | to let the base class know how many columns it should display, but from that | |
713 | moment on the scrolling is handled entirely by wxHScrolledWindow. You only | |
714 | need to draw the visible part of contents in your @c OnPaint() method as | |
715 | usual. You should use wxVarHScrollHelper::GetVisibleColumnsBegin | |
716 | and wxVarHScrollHelper::GetVisibleColumnsEnd to | |
717 | select the lines to display. Note that the device context origin is not shifted | |
718 | so the first visible column always appears at the point (0, 0) in physical as | |
719 | well as logical coordinates. | |
7c913512 | 720 | |
23324ae1 FM |
721 | @library{wxcore} |
722 | @category{FIXME} | |
7c913512 | 723 | |
6f022dba | 724 | @see wxHVScrolledWindow, wxVScrolledWindow |
23324ae1 | 725 | */ |
6f022dba | 726 | class wxHScrolledWindow : public wxPanel, public wxVarHScrollHelper |
23324ae1 FM |
727 | { |
728 | public: | |
729 | //@{ | |
730 | /** | |
731 | This is the normal constructor, no need to call @c Create() after using this | |
732 | one. | |
6f022dba BP |
733 | Note that @c wxHSCROLL is always automatically added to our style, there is |
734 | no need to specify it explicitly. | |
3c4f71cc | 735 | |
7c913512 | 736 | @param parent |
4cc4bfaf | 737 | The parent window, must not be @NULL |
7c913512 | 738 | @param id |
4cc4bfaf | 739 | The identifier of this window, wxID_ANY by default |
7c913512 | 740 | @param pos |
4cc4bfaf | 741 | The initial window position |
7c913512 | 742 | @param size |
4cc4bfaf | 743 | The initial window size |
7c913512 | 744 | @param style |
4cc4bfaf FM |
745 | The window style. There are no special style bits defined for |
746 | this class. | |
7c913512 | 747 | @param name |
4cc4bfaf | 748 | The name for this window; usually not used |
23324ae1 | 749 | */ |
6f022dba BP |
750 | wxHScrolledWindow(); |
751 | wxHScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY, | |
752 | const wxPoint& pos = wxDefaultPosition, | |
753 | const wxSize& size = wxDefaultSize, | |
754 | long style = 0, | |
755 | const wxString& name = wxPanelNameStr); | |
23324ae1 FM |
756 | //@} |
757 | ||
758 | /** | |
6f022dba | 759 | Same as the @ref wxhscrolledwindow() "non-default constuctor" |
23324ae1 FM |
760 | but returns status code: @true if ok, @false if the window couldn't |
761 | be created. | |
6f022dba BP |
762 | Just as with the constructor above, the @c wxHSCROLL style is always used, |
763 | there is no need to specify it explicitly. | |
23324ae1 FM |
764 | */ |
765 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
766 | const wxPoint& pos = wxDefaultPosition, | |
767 | const wxSize& size = wxDefaultSize, | |
768 | long style = 0, | |
769 | const wxString& name = wxPanelNameStr); | |
770 | }; | |
771 | ||
772 | ||
e54c96f1 | 773 | |
23324ae1 | 774 | /** |
6f022dba | 775 | @class wxHVScrolledWindow |
23324ae1 | 776 | @wxheader{vscroll.h} |
7c913512 | 777 | |
6f022dba BP |
778 | This window inherits all functionality of both vertical and horizontal, |
779 | variable scrolled windows. It automatically handles everything needed to | |
780 | scroll both axis simultaneously with both variable row heights and variable | |
781 | column widths. | |
7c913512 | 782 | |
f09b5681 BP |
783 | In any case, this is a generalization of wxScrolled which can be only used |
784 | when all rows and columns are the same size. It lacks some other wxScrolled | |
785 | features however, notably it can't scroll only a rectangle of the window | |
786 | and not its entire client area. | |
7c913512 | 787 | |
6f022dba BP |
788 | To use this class, you must derive from it and implement both the |
789 | wxVarVScrollHelper::OnGetRowHeight and | |
23324ae1 | 790 | wxVarHScrollHelper::OnGetColumnWidth pure virtual |
6f022dba BP |
791 | methods to let the base class know how many rows and columns it should |
792 | display. You also need to set the total rows and columns the window contains, | |
793 | but from that moment on the scrolling is handled entirely by | |
794 | wxHVScrolledWindow. You only need to draw the visible part of contents in | |
795 | your @c OnPaint() method as usual. You should use | |
796 | wxVarHVScrollHelper::GetVisibleBegin | |
797 | and wxVarHVScrollHelper::GetVisibleEnd to select the | |
798 | lines to display. Note that the device context origin is not shifted so the | |
799 | first visible row and column always appear at the point (0, 0) in physical | |
800 | as well as logical coordinates. | |
7c913512 | 801 | |
23324ae1 FM |
802 | @library{wxcore} |
803 | @category{FIXME} | |
7c913512 | 804 | |
6f022dba | 805 | @see wxHScrolledWindow, wxVScrolledWindow |
23324ae1 | 806 | */ |
6f022dba | 807 | class wxHVScrolledWindow : public wxPanel, public wxVarHVScrollHelper |
23324ae1 FM |
808 | { |
809 | public: | |
810 | //@{ | |
811 | /** | |
812 | This is the normal constructor, no need to call @c Create() after using this | |
813 | one. | |
6f022dba BP |
814 | Note that @c wxHSCROLL and @c wxVSCROLL are always automatically added |
815 | to our styles, there is no need to specify it explicitly. | |
3c4f71cc | 816 | |
7c913512 | 817 | @param parent |
4cc4bfaf | 818 | The parent window, must not be @NULL |
7c913512 | 819 | @param id |
4cc4bfaf | 820 | The identifier of this window, wxID_ANY by default |
7c913512 | 821 | @param pos |
4cc4bfaf | 822 | The initial window position |
7c913512 | 823 | @param size |
4cc4bfaf | 824 | The initial window size |
7c913512 | 825 | @param style |
4cc4bfaf FM |
826 | The window style. There are no special style bits defined for |
827 | this class. | |
7c913512 | 828 | @param name |
4cc4bfaf | 829 | The name for this window; usually not used |
23324ae1 | 830 | */ |
6f022dba BP |
831 | wxHVScrolledWindow(); |
832 | wxHVScrolledWindow(wxWindow* parent, | |
833 | wxWindowID id = wxID_ANY, | |
834 | const wxPoint& pos = wxDefaultPosition, | |
835 | const wxSize& size = wxDefaultSize, | |
836 | long style = 0, | |
837 | const wxString& name = wxPanelNameStr); | |
23324ae1 FM |
838 | //@} |
839 | ||
840 | /** | |
6f022dba | 841 | Same as the @ref wxhvscrolledwindow() "non-default constuctor" |
23324ae1 FM |
842 | but returns status code: @true if ok, @false if the window couldn't |
843 | be created. | |
6f022dba BP |
844 | Just as with the constructor above, the @c wxHSCROLL and @c wxVSCROLL |
845 | styles are always used, there is no need to specify it explicitly. | |
23324ae1 FM |
846 | */ |
847 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
848 | const wxPoint& pos = wxDefaultPosition, | |
849 | const wxSize& size = wxDefaultSize, | |
850 | long style = 0, | |
851 | const wxString& name = wxPanelNameStr); | |
852 | }; | |
e54c96f1 | 853 |