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