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