Use RIAA wrapper for wxSpinCtrl event disabling in wxGTK.
[wxWidgets.git] / include / wx / vscroll.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/vscroll.h
3 // Purpose: Variable scrolled windows (wx[V/H/HV]ScrolledWindow)
4 // Author: Vadim Zeitlin
5 // Modified by: Brad Anderson, Bryan Petty
6 // Created: 30.05.03
7 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_VSCROLL_H_
12 #define _WX_VSCROLL_H_
13
14 #include "wx/panel.h"
15 #include "wx/position.h"
16
17 class WXDLLIMPEXP_FWD_CORE wxVarScrollHelperEvtHandler;
18
19
20 // Using the same techniques as the wxScrolledWindow class |
21 // hierarchy, the wx[V/H/HV]ScrolledWindow classes are slightly |
22 // more complex (compare with the diagram outlined in |
23 // scrolwin.h) for the purpose of reducing code duplication |
24 // through the use of mix-in classes. |
25 // |
26 // wxVarScrollHelperBase |
27 // / \ |
28 // / \ |
29 // V V |
30 // wxVarHScrollHelper wxVarVScrollHelper |
31 // | \ / | |
32 // | \ / | |
33 // | V V | |
34 // | wxVarHVScrollHelper | |
35 // | | | |
36 // | | V |
37 // | wxPanel | wxVarVScrollLegacyAdaptor |
38 // | / \ \ | | |
39 // | / \ `-----|----------. | |
40 // | / \ | \ | |
41 // | / \ | \ | |
42 // V V \ | V V |
43 // wxHScrolledWindow \ | wxVScrolledWindow |
44 // V V |
45 // wxHVScrolledWindow |
46 // |
47 // |
48 // Border added to suppress GCC multi-line comment warnings ->|
49
50
51 // ===========================================================================
52 // wxVarScrollHelperBase
53 // ===========================================================================
54
55 // Provides all base common scroll calculations needed for either orientation,
56 // automatic scrollbar functionality, saved scroll positions, functionality
57 // for changing the target window to be scrolled, as well as defining all
58 // required virtual functions that need to be implemented for any orientation
59 // specific work.
60
61 class WXDLLIMPEXP_CORE wxVarScrollHelperBase
62 {
63 public:
64 // constructors and such
65 // ---------------------
66
67 wxVarScrollHelperBase(wxWindow *winToScroll);
68 virtual ~wxVarScrollHelperBase();
69
70 // operations
71 // ----------
72
73 // with physical scrolling on, the device origin is changed properly when
74 // a wxPaintDC is prepared, children are actually moved and laid out
75 // properly, and the contents of the window (pixels) are actually moved
76 void EnablePhysicalScrolling(bool scrolling = true)
77 { m_physicalScrolling = scrolling; }
78
79 // wxNOT_FOUND if none, i.e. if it is below the last item
80 int VirtualHitTest(wxCoord coord) const;
81
82 // recalculate all our parameters and redisplay all units
83 virtual void RefreshAll();
84
85 // accessors
86 // ---------
87
88 // get the first currently visible unit
89 size_t GetVisibleBegin() const { return m_unitFirst; }
90
91 // get the last currently visible unit
92 size_t GetVisibleEnd() const
93 { return m_unitFirst + m_nUnitsVisible; }
94
95 // is this unit currently visible?
96 bool IsVisible(size_t unit) const
97 { return unit >= m_unitFirst && unit < GetVisibleEnd(); }
98
99 // translate between scrolled and unscrolled coordinates
100 int CalcScrolledPosition(int coord) const
101 { return DoCalcScrolledPosition(coord); }
102 int CalcUnscrolledPosition(int coord) const
103 { return DoCalcUnscrolledPosition(coord); }
104
105 virtual int DoCalcScrolledPosition(int coord) const;
106 virtual int DoCalcUnscrolledPosition(int coord) const;
107
108 // update the thumb size shown by the scrollbar
109 virtual void UpdateScrollbar();
110 void RemoveScrollbar();
111
112 // Normally the wxScrolledWindow will scroll itself, but in some rare
113 // occasions you might want it to scroll [part of] another window (e.g. a
114 // child of it in order to scroll only a portion the area between the
115 // scrollbars (spreadsheet: only cell area will move).
116 virtual void SetTargetWindow(wxWindow *target);
117 virtual wxWindow *GetTargetWindow() const { return m_targetWindow; }
118
119 // Override this function to draw the graphic (or just process EVT_PAINT)
120 //virtual void OnDraw(wxDC& WXUNUSED(dc)) { }
121
122 // change the DC origin according to the scroll position. To properly
123 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
124 // derived class
125 virtual void DoPrepareDC(wxDC& dc);
126
127 // the methods to be called from the window event handlers
128 void HandleOnScroll(wxScrollWinEvent& event);
129 void HandleOnSize(wxSizeEvent& event);
130 #if wxUSE_MOUSEWHEEL
131 void HandleOnMouseWheel(wxMouseEvent& event);
132 #endif // wxUSE_MOUSEWHEEL
133
134 // these functions must be overidden in the derived class to return
135 // orientation specific data (e.g. the width for vertically scrolling
136 // derivatives in the case of GetOrientationTargetSize())
137 virtual int GetOrientationTargetSize() const = 0;
138 virtual int GetNonOrientationTargetSize() const = 0;
139 virtual wxOrientation GetOrientation() const = 0;
140
141 protected:
142 // all *Unit* functions are protected to be exposed by
143 // wxVarScrollHelperBase implementations (with appropriate names)
144
145 // get the number of units this window contains (previously set by
146 // SetUnitCount())
147 size_t GetUnitCount() const { return m_unitMax; }
148
149 // set the number of units the helper contains: the derived class must
150 // provide the sizes for all units with indices up to the one given here
151 // in its OnGetUnitSize()
152 void SetUnitCount(size_t count);
153
154 // redraw the specified unit
155 virtual void RefreshUnit(size_t unit);
156
157 // redraw all units in the specified range (inclusive)
158 virtual void RefreshUnits(size_t from, size_t to);
159
160 // scroll to the specified unit: it will become the first visible unit in
161 // the window
162 //
163 // return true if we scrolled the window, false if nothing was done
164 bool DoScrollToUnit(size_t unit);
165
166 // scroll by the specified number of units/pages
167 virtual bool DoScrollUnits(int units);
168 virtual bool DoScrollPages(int pages);
169
170 // this function must be overridden in the derived class and it should
171 // return the size of the given unit in pixels
172 virtual wxCoord OnGetUnitSize(size_t n) const = 0;
173
174 // this function doesn't have to be overridden but it may be useful to do
175 // it if calculating the units' sizes is a relatively expensive operation
176 // as it gives the user code a possibility to calculate several of them at
177 // once
178 //
179 // OnGetUnitsSizeHint() is normally called just before OnGetUnitSize() but
180 // you shouldn't rely on the latter being called for all units in the
181 // interval specified here. It is also possible that OnGetUnitHeight() will
182 // be called for the units outside of this interval, so this is really just
183 // a hint, not a promise.
184 //
185 // finally note that unitMin is inclusive, while unitMax is exclusive, as
186 // usual
187 virtual void OnGetUnitsSizeHint(size_t WXUNUSED(unitMin),
188 size_t WXUNUSED(unitMax)) const
189 { }
190
191 // when the number of units changes, we try to estimate the total size
192 // of all units which is a rather expensive operation in terms of unit
193 // access, so if the user code may estimate the average size
194 // better/faster than we do, it should override this function to implement
195 // its own logic
196 //
197 // this function should return the best guess for the total size it may
198 // make
199 virtual wxCoord EstimateTotalSize() const { return DoEstimateTotalSize(); }
200
201 wxCoord DoEstimateTotalSize() const;
202
203 // find the index of the unit we need to show to fit the specified unit on
204 // the opposite side either fully or partially (depending on fullyVisible)
205 size_t FindFirstVisibleFromLast(size_t last,
206 bool fullyVisible = false) const;
207
208 // get the total size of the units between unitMin (inclusive) and
209 // unitMax (exclusive)
210 wxCoord GetUnitsSize(size_t unitMin, size_t unitMax) const;
211
212 // get the offset of the first visible unit
213 wxCoord GetScrollOffset() const
214 { return GetUnitsSize(0, GetVisibleBegin()); }
215
216 // get the size of the target window
217 wxSize GetTargetSize() const { return m_targetWindow->GetClientSize(); }
218
219 void GetTargetSize(int *w, int *h)
220 {
221 wxSize size = GetTargetSize();
222 if ( w )
223 *w = size.x;
224 if ( h )
225 *h = size.y;
226 }
227
228 // calculate the new scroll position based on scroll event type
229 size_t GetNewScrollPosition(wxScrollWinEvent& event) const;
230
231 // replacement implementation of wxWindow::Layout virtual method. To
232 // properly forward calls to wxWindow::Layout use
233 // WX_FORWARD_TO_SCROLL_HELPER() derived class
234 bool ScrollLayout();
235
236 #ifdef __WXMAC__
237 // queue mac window update after handling scroll event
238 virtual void UpdateMacScrollWindow() { }
239 #endif // __WXMAC__
240
241 // change the target window
242 void DoSetTargetWindow(wxWindow *target);
243
244 // delete the event handler we installed
245 void DeleteEvtHandler();
246
247 // helper function abstracting the orientation test: with vertical
248 // orientation, it assigns the first value to x and the second one to y,
249 // with horizontal orientation it reverses them, i.e. the first value is
250 // assigned to y and the second one to x
251 void AssignOrient(wxCoord& x, wxCoord& y, wxCoord first, wxCoord second);
252
253 // similar to "oriented assignment" above but does "oriented increment":
254 // for vertical orientation, y is incremented by the given value and x if
255 // left unchanged, for horizontal orientation x is incremented
256 void IncOrient(wxCoord& x, wxCoord& y, wxCoord inc);
257
258 private:
259
260 // the window that receives the scroll events and the window to actually
261 // scroll, respectively
262 wxWindow *m_win,
263 *m_targetWindow;
264
265 // the total number of (logical) units
266 size_t m_unitMax;
267
268 // the total (estimated) size
269 wxCoord m_sizeTotal;
270
271 // the first currently visible unit
272 size_t m_unitFirst;
273
274 // the number of currently visible units (including the last, possibly only
275 // partly, visible one)
276 size_t m_nUnitsVisible;
277
278 // accumulated mouse wheel rotation
279 #if wxUSE_MOUSEWHEEL
280 int m_sumWheelRotation;
281 #endif
282
283 // do child scrolling (used in DoPrepareDC())
284 bool m_physicalScrolling;
285
286 // handler injected into target window to forward some useful events to us
287 wxVarScrollHelperEvtHandler *m_handler;
288 };
289
290
291
292 // ===========================================================================
293 // wxVarVScrollHelper
294 // ===========================================================================
295
296 // Provides public API functions targeted for vertical-specific scrolling,
297 // wrapping the functionality of wxVarScrollHelperBase.
298
299 class WXDLLIMPEXP_CORE wxVarVScrollHelper : public wxVarScrollHelperBase
300 {
301 public:
302 // constructors and such
303 // ---------------------
304
305 // ctor must be given the associated window
306 wxVarVScrollHelper(wxWindow *winToScroll)
307 : wxVarScrollHelperBase(winToScroll)
308 {
309 }
310
311 // operators
312
313 void SetRowCount(size_t rowCount) { SetUnitCount(rowCount); }
314 bool ScrollToRow(size_t row) { return DoScrollToUnit(row); }
315
316 virtual bool ScrollRows(int rows)
317 { return DoScrollUnits(rows); }
318 virtual bool ScrollRowPages(int pages)
319 { return DoScrollPages(pages); }
320
321 virtual void RefreshRow(size_t row)
322 { RefreshUnit(row); }
323 virtual void RefreshRows(size_t from, size_t to)
324 { RefreshUnits(from, to); }
325
326 // accessors
327
328 size_t GetRowCount() const { return GetUnitCount(); }
329 size_t GetVisibleRowsBegin() const { return GetVisibleBegin(); }
330 size_t GetVisibleRowsEnd() const { return GetVisibleEnd(); }
331 bool IsRowVisible(size_t row) const { return IsVisible(row); }
332
333 virtual int GetOrientationTargetSize() const
334 { return GetTargetWindow()->GetClientSize().y; }
335 virtual int GetNonOrientationTargetSize() const
336 { return GetTargetWindow()->GetClientSize().x; }
337 virtual wxOrientation GetOrientation() const { return wxVERTICAL; }
338
339 protected:
340 // this function must be overridden in the derived class and it should
341 // return the size of the given row in pixels
342 virtual wxCoord OnGetRowHeight(size_t n) const = 0;
343 wxCoord OnGetUnitSize(size_t n) const { return OnGetRowHeight(n); }
344
345 virtual void OnGetRowsHeightHint(size_t WXUNUSED(rowMin),
346 size_t WXUNUSED(rowMax)) const { }
347
348 // forward calls to OnGetRowsHeightHint()
349 virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const
350 { OnGetRowsHeightHint(unitMin, unitMax); }
351
352 // again, if not overridden, it will fall back on default method
353 virtual wxCoord EstimateTotalHeight() const
354 { return DoEstimateTotalSize(); }
355
356 // forward calls to EstimateTotalHeight()
357 virtual wxCoord EstimateTotalSize() const { return EstimateTotalHeight(); }
358
359 wxCoord GetRowsHeight(size_t rowMin, size_t rowMax) const
360 { return GetUnitsSize(rowMin, rowMax); }
361 };
362
363
364
365 // ===========================================================================
366 // wxVarHScrollHelper
367 // ===========================================================================
368
369 // Provides public API functions targeted for horizontal-specific scrolling,
370 // wrapping the functionality of wxVarScrollHelperBase.
371
372 class WXDLLIMPEXP_CORE wxVarHScrollHelper : public wxVarScrollHelperBase
373 {
374 public:
375 // constructors and such
376 // ---------------------
377
378 // ctor must be given the associated window
379 wxVarHScrollHelper(wxWindow *winToScroll)
380 : wxVarScrollHelperBase(winToScroll)
381 {
382 }
383
384 // operators
385
386 void SetColumnCount(size_t columnCount)
387 { SetUnitCount(columnCount); }
388
389 bool ScrollToColumn(size_t column)
390 { return DoScrollToUnit(column); }
391 virtual bool ScrollColumns(int columns)
392 { return DoScrollUnits(columns); }
393 virtual bool ScrollColumnPages(int pages)
394 { return DoScrollPages(pages); }
395
396 virtual void RefreshColumn(size_t column)
397 { RefreshUnit(column); }
398 virtual void RefreshColumns(size_t from, size_t to)
399 { RefreshUnits(from, to); }
400
401 // accessors
402
403 size_t GetColumnCount() const
404 { return GetUnitCount(); }
405 size_t GetVisibleColumnsBegin() const
406 { return GetVisibleBegin(); }
407 size_t GetVisibleColumnsEnd() const
408 { return GetVisibleEnd(); }
409 bool IsColumnVisible(size_t column) const
410 { return IsVisible(column); }
411
412
413 virtual int GetOrientationTargetSize() const
414 { return GetTargetWindow()->GetClientSize().x; }
415 virtual int GetNonOrientationTargetSize() const
416 { return GetTargetWindow()->GetClientSize().y; }
417 virtual wxOrientation GetOrientation() const { return wxHORIZONTAL; }
418
419 protected:
420 // this function must be overridden in the derived class and it should
421 // return the size of the given column in pixels
422 virtual wxCoord OnGetColumnWidth(size_t n) const = 0;
423 wxCoord OnGetUnitSize(size_t n) const { return OnGetColumnWidth(n); }
424
425 virtual void OnGetColumnsWidthHint(size_t WXUNUSED(columnMin),
426 size_t WXUNUSED(columnMax)) const
427 { }
428
429 // forward calls to OnGetColumnsWidthHint()
430 virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const
431 { OnGetColumnsWidthHint(unitMin, unitMax); }
432
433 // again, if not overridden, it will fall back on default method
434 virtual wxCoord EstimateTotalWidth() const { return DoEstimateTotalSize(); }
435
436 // forward calls to EstimateTotalWidth()
437 virtual wxCoord EstimateTotalSize() const { return EstimateTotalWidth(); }
438
439 wxCoord GetColumnsWidth(size_t columnMin, size_t columnMax) const
440 { return GetUnitsSize(columnMin, columnMax); }
441 };
442
443
444
445 // ===========================================================================
446 // wxVarHVScrollHelper
447 // ===========================================================================
448
449 // Provides public API functions targeted at functions with similar names in
450 // both wxVScrollHelper and wxHScrollHelper so class scope doesn't need to be
451 // specified (since we are using multiple inheritance). It also provides
452 // functions to make changing values for both orientations at the same time
453 // easier.
454
455 class WXDLLIMPEXP_CORE wxVarHVScrollHelper : public wxVarVScrollHelper,
456 public wxVarHScrollHelper
457 {
458 public:
459 // constructors and such
460 // ---------------------
461
462 // ctor must be given the associated window
463 wxVarHVScrollHelper(wxWindow *winToScroll)
464 : wxVarVScrollHelper(winToScroll), wxVarHScrollHelper(winToScroll) { }
465
466 // operators
467 // ---------
468
469 // set the number of units the window contains for each axis: the derived
470 // class must provide the widths and heights for all units with indices up
471 // to each of the one given here in its OnGetColumnWidth() and
472 // OnGetRowHeight()
473 void SetRowColumnCount(size_t rowCount, size_t columnCount);
474
475
476 // with physical scrolling on, the device origin is changed properly when
477 // a wxPaintDC is prepared, children are actually moved and laid out
478 // properly, and the contents of the window (pixels) are actually moved
479 void EnablePhysicalScrolling(bool vscrolling = true, bool hscrolling = true)
480 {
481 wxVarVScrollHelper::EnablePhysicalScrolling(vscrolling);
482 wxVarHScrollHelper::EnablePhysicalScrolling(hscrolling);
483 }
484
485 // scroll to the specified row/column: it will become the first visible
486 // cell in the window
487 //
488 // return true if we scrolled the window, false if nothing was done
489 bool ScrollToRowColumn(size_t row, size_t column);
490 bool ScrollToRowColumn(const wxPosition &pos)
491 { return ScrollToRowColumn(pos.GetRow(), pos.GetColumn()); }
492
493 // redraw the specified cell
494 virtual void RefreshRowColumn(size_t row, size_t column);
495 virtual void RefreshRowColumn(const wxPosition &pos)
496 { RefreshRowColumn(pos.GetRow(), pos.GetColumn()); }
497
498 // redraw the specified regions (inclusive). If the target window for
499 // both orientations is the same the rectangle of cells is refreshed; if
500 // the target windows differ the entire client size opposite the
501 // orientation direction is refreshed between the specified limits
502 virtual void RefreshRowsColumns(size_t fromRow, size_t toRow,
503 size_t fromColumn, size_t toColumn);
504 virtual void RefreshRowsColumns(const wxPosition& from,
505 const wxPosition& to)
506 {
507 RefreshRowsColumns(from.GetRow(), to.GetRow(),
508 from.GetColumn(), to.GetColumn());
509 }
510
511 // locate the virtual position from the given device coordinates
512 wxPosition VirtualHitTest(wxCoord x, wxCoord y) const;
513 wxPosition VirtualHitTest(const wxPoint &pos) const
514 { return VirtualHitTest(pos.x, pos.y); }
515
516 // change the DC origin according to the scroll position. To properly
517 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
518 // derived class. We use this version to call both base classes'
519 // DoPrepareDC()
520 virtual void DoPrepareDC(wxDC& dc);
521
522 // replacement implementation of wxWindow::Layout virtual method. To
523 // properly forward calls to wxWindow::Layout use
524 // WX_FORWARD_TO_SCROLL_HELPER() derived class. We use this version to
525 // call both base classes' ScrollLayout()
526 bool ScrollLayout();
527
528 // accessors
529 // ---------
530
531 // get the number of units this window contains (previously set by
532 // Set[Column/Row/RowColumn/Unit]Count())
533 wxSize GetRowColumnCount() const;
534
535 // get the first currently visible units
536 wxPosition GetVisibleBegin() const;
537 wxPosition GetVisibleEnd() const;
538
539 // is this cell currently visible?
540 bool IsVisible(size_t row, size_t column) const;
541 bool IsVisible(const wxPosition &pos) const
542 { return IsVisible(pos.GetRow(), pos.GetColumn()); }
543 };
544
545
546
547 #if WXWIN_COMPATIBILITY_2_8
548
549 // ===========================================================================
550 // wxVarVScrollLegacyAdaptor
551 // ===========================================================================
552
553 // Provides backwards compatible API for applications originally built using
554 // wxVScrolledWindow in 2.6 or 2.8. Originally, wxVScrolledWindow referred
555 // to scrolling "lines". We use "units" in wxVarScrollHelperBase to avoid
556 // implying any orientation (since the functions are used for both horizontal
557 // and vertical scrolling in derived classes). And in the new
558 // wxVScrolledWindow and wxHScrolledWindow classes, we refer to them as
559 // "rows" and "columns", respectively. This is to help clear some confusion
560 // in not only those classes, but also in wxHVScrolledWindow where functions
561 // are inherited from both.
562
563 class WXDLLIMPEXP_CORE wxVarVScrollLegacyAdaptor : public wxVarVScrollHelper
564 {
565 public:
566 // constructors and such
567 // ---------------------
568 wxVarVScrollLegacyAdaptor(wxWindow *winToScroll)
569 : wxVarVScrollHelper(winToScroll)
570 {
571 }
572
573 // accessors
574 // ---------
575
576 // this is the same as GetVisibleRowsBegin(), exists to match
577 // GetLastVisibleLine() and for backwards compatibility only
578 wxDEPRECATED( size_t GetFirstVisibleLine() const );
579
580 // get the last currently visible line
581 //
582 // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive
583 // number) if the control is empty, use GetVisibleRowsEnd() instead, this
584 // one is kept for backwards compatibility
585 wxDEPRECATED( size_t GetLastVisibleLine() const );
586
587 // "line" to "unit" compatibility functions
588 // ----------------------------------------
589
590 // get the number of lines this window contains (set by SetLineCount())
591 wxDEPRECATED( size_t GetLineCount() const );
592
593 // set the number of lines the helper contains: the derived class must
594 // provide the sizes for all lines with indices up to the one given here
595 // in its OnGetLineHeight()
596 wxDEPRECATED( void SetLineCount(size_t count) );
597
598 // redraw the specified line
599 wxDEPRECATED( virtual void RefreshLine(size_t line) );
600
601 // redraw all lines in the specified range (inclusive)
602 wxDEPRECATED( virtual void RefreshLines(size_t from, size_t to) );
603
604 // scroll to the specified line: it will become the first visible line in
605 // the window
606 //
607 // return true if we scrolled the window, false if nothing was done
608 wxDEPRECATED( bool ScrollToLine(size_t line) );
609
610 // scroll by the specified number of lines/pages
611 wxDEPRECATED( virtual bool ScrollLines(int lines) );
612 wxDEPRECATED( virtual bool ScrollPages(int pages) );
613
614 protected:
615 // unless the code has been updated to override OnGetRowHeight() instead,
616 // this function must be overridden in the derived class and it should
617 // return the height of the given row in pixels
618 wxDEPRECATED_BUT_USED_INTERNALLY(
619 virtual wxCoord OnGetLineHeight(size_t n) const );
620
621 // forwards the calls from base class pure virtual function to pure virtual
622 // OnGetLineHeight instead (backwards compatible name)
623 // note that we don't need to forward OnGetUnitSize() as it is already
624 // forwarded to OnGetRowHeight() in wxVarVScrollHelper
625 virtual wxCoord OnGetRowHeight(size_t n) const;
626
627 // this function doesn't have to be overridden but it may be useful to do
628 // it if calculating the lines heights is a relatively expensive operation
629 // as it gives the user code a possibility to calculate several of them at
630 // once
631 //
632 // OnGetLinesHint() is normally called just before OnGetLineHeight() but you
633 // shouldn't rely on the latter being called for all lines in the interval
634 // specified here. It is also possible that OnGetLineHeight() will be
635 // called for the lines outside of this interval, so this is really just a
636 // hint, not a promise.
637 //
638 // finally note that lineMin is inclusive, while lineMax is exclusive, as
639 // usual
640 wxDEPRECATED_BUT_USED_INTERNALLY( virtual void OnGetLinesHint(
641 size_t lineMin, size_t lineMax) const );
642
643 // forwards the calls from base class pure virtual function to pure virtual
644 // OnGetLinesHint instead (backwards compatible name)
645 void OnGetRowsHeightHint(size_t rowMin, size_t rowMax) const;
646 };
647
648 #else // !WXWIN_COMPATIBILITY_2_8
649
650 // shortcut to avoid checking compatibility modes later
651 // remove this and all references to wxVarVScrollLegacyAdaptor once
652 // wxWidgets 2.6 and 2.8 compatibility is removed
653 typedef wxVarVScrollHelper wxVarVScrollLegacyAdaptor;
654
655 #endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8
656
657
658 // this macro must be used in declaration of wxVarScrollHelperBase-derived
659 // classes
660 #define WX_FORWARD_TO_VAR_SCROLL_HELPER() \
661 public: \
662 virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \
663 virtual bool Layout() { return ScrollLayout(); }
664
665
666
667 // ===========================================================================
668 // wxVScrolledWindow
669 // ===========================================================================
670
671 // In the name of this class, "V" may stand for "variable" because it can be
672 // used for scrolling rows of variable heights; "virtual", because it is not
673 // necessary to know the heights of all rows in advance -- only those which
674 // are shown on the screen need to be measured; or even "vertical", because
675 // this class only supports scrolling vertically.
676
677 // In any case, this is a generalization of the wxScrolledWindow class which
678 // can be only used when all rows have the same heights. It lacks some other
679 // wxScrolledWindow features however, notably it can't scroll only a rectangle
680 // of the window and not its entire client area.
681
682 class WXDLLIMPEXP_CORE wxVScrolledWindow : public wxPanel,
683 public wxVarVScrollLegacyAdaptor
684 {
685 public:
686 // constructors and such
687 // ---------------------
688
689 // default ctor, you must call Create() later
690 wxVScrolledWindow() : wxVarVScrollLegacyAdaptor(this) { }
691
692 // normal ctor, no need to call Create() after this one
693 //
694 // note that wxVSCROLL is always automatically added to our style, there is
695 // no need to specify it explicitly
696 wxVScrolledWindow(wxWindow *parent,
697 wxWindowID id = wxID_ANY,
698 const wxPoint& pos = wxDefaultPosition,
699 const wxSize& size = wxDefaultSize,
700 long style = 0,
701 const wxString& name = wxPanelNameStr)
702 : wxVarVScrollLegacyAdaptor(this)
703 {
704 (void)Create(parent, id, pos, size, style, name);
705 }
706
707 // same as the previous ctor but returns status code: true if ok
708 //
709 // just as with the ctor above, wxVSCROLL style is always used, there is no
710 // need to specify it
711 bool Create(wxWindow *parent,
712 wxWindowID id = wxID_ANY,
713 const wxPoint& pos = wxDefaultPosition,
714 const wxSize& size = wxDefaultSize,
715 long style = 0,
716 const wxString& name = wxPanelNameStr)
717 {
718 return wxPanel::Create(parent, id, pos, size, style | wxVSCROLL, name);
719 }
720
721 #if WXWIN_COMPATIBILITY_2_8
722 // Make sure we prefer our version of HitTest rather than wxWindow's
723 // These functions should no longer be masked in favor of VirtualHitTest()
724 int HitTest(wxCoord WXUNUSED(x), wxCoord y) const
725 { return wxVarVScrollHelper::VirtualHitTest(y); }
726 int HitTest(const wxPoint& pt) const
727 { return HitTest(pt.x, pt.y); }
728 #endif // WXWIN_COMPATIBILITY_2_8
729
730 WX_FORWARD_TO_VAR_SCROLL_HELPER()
731
732 #ifdef __WXMAC__
733 protected:
734 virtual void UpdateMacScrollWindow() { Update(); }
735 #endif // __WXMAC__
736
737 private:
738 wxDECLARE_NO_COPY_CLASS(wxVScrolledWindow);
739 DECLARE_ABSTRACT_CLASS(wxVScrolledWindow)
740 };
741
742
743
744 // ===========================================================================
745 // wxHScrolledWindow
746 // ===========================================================================
747
748 // In the name of this class, "H" stands for "horizontal" because it can be
749 // used for scrolling columns of variable widths. It is not necessary to know
750 // the widths of all columns in advance -- only those which are shown on the
751 // screen need to be measured.
752
753 // This is a generalization of the wxScrolledWindow class which can be only
754 // used when all columns have the same width. It lacks some other
755 // wxScrolledWindow features however, notably it can't scroll only a rectangle
756 // of the window and not its entire client area.
757
758 class WXDLLIMPEXP_CORE wxHScrolledWindow : public wxPanel,
759 public wxVarHScrollHelper
760 {
761 public:
762 // constructors and such
763 // ---------------------
764
765 // default ctor, you must call Create() later
766 wxHScrolledWindow() : wxVarHScrollHelper(this) { }
767
768 // normal ctor, no need to call Create() after this one
769 //
770 // note that wxHSCROLL is always automatically added to our style, there is
771 // no need to specify it explicitly
772 wxHScrolledWindow(wxWindow *parent,
773 wxWindowID id = wxID_ANY,
774 const wxPoint& pos = wxDefaultPosition,
775 const wxSize& size = wxDefaultSize,
776 long style = 0,
777 const wxString& name = wxPanelNameStr)
778 : wxVarHScrollHelper(this)
779 {
780 (void)Create(parent, id, pos, size, style, name);
781 }
782
783 // same as the previous ctor but returns status code: true if ok
784 //
785 // just as with the ctor above, wxHSCROLL style is always used, there is no
786 // need to specify it
787 bool Create(wxWindow *parent,
788 wxWindowID id = wxID_ANY,
789 const wxPoint& pos = wxDefaultPosition,
790 const wxSize& size = wxDefaultSize,
791 long style = 0,
792 const wxString& name = wxPanelNameStr)
793 {
794 return wxPanel::Create(parent, id, pos, size, style | wxHSCROLL, name);
795 }
796
797 WX_FORWARD_TO_VAR_SCROLL_HELPER()
798
799 #ifdef __WXMAC__
800 protected:
801 virtual void UpdateMacScrollWindow() { Update(); }
802 #endif // __WXMAC__
803
804 private:
805 wxDECLARE_NO_COPY_CLASS(wxHScrolledWindow);
806 DECLARE_ABSTRACT_CLASS(wxHScrolledWindow)
807 };
808
809
810
811 // ===========================================================================
812 // wxHVScrolledWindow
813 // ===========================================================================
814
815 // This window inherits all functionality of both vertical and horizontal
816 // scrolled windows automatically handling everything needed to scroll both
817 // axis simultaneously.
818
819 class WXDLLIMPEXP_CORE wxHVScrolledWindow : public wxPanel,
820 public wxVarHVScrollHelper
821 {
822 public:
823 // constructors and such
824 // ---------------------
825
826 // default ctor, you must call Create() later
827 wxHVScrolledWindow()
828 : wxPanel(),
829 wxVarHVScrollHelper(this) { }
830
831 // normal ctor, no need to call Create() after this one
832 //
833 // note that wxVSCROLL and wxHSCROLL are always automatically added to our
834 // style, there is no need to specify them explicitly
835 wxHVScrolledWindow(wxWindow *parent,
836 wxWindowID id = wxID_ANY,
837 const wxPoint& pos = wxDefaultPosition,
838 const wxSize& size = wxDefaultSize,
839 long style = 0,
840 const wxString& name = wxPanelNameStr)
841 : wxPanel(),
842 wxVarHVScrollHelper(this)
843 {
844 (void)Create(parent, id, pos, size, style, name);
845 }
846
847 // same as the previous ctor but returns status code: true if ok
848 //
849 // just as with the ctor above, wxVSCROLL and wxHSCROLL styles are always
850 // used, there is no need to specify them
851 bool Create(wxWindow *parent,
852 wxWindowID id = wxID_ANY,
853 const wxPoint& pos = wxDefaultPosition,
854 const wxSize& size = wxDefaultSize,
855 long style = 0,
856 const wxString& name = wxPanelNameStr)
857 {
858 return wxPanel::Create(parent, id, pos, size,
859 style | wxVSCROLL | wxHSCROLL, name);
860 }
861
862 WX_FORWARD_TO_VAR_SCROLL_HELPER()
863
864 #ifdef __WXMAC__
865 protected:
866 virtual void UpdateMacScrollWindow() { Update(); }
867 #endif // __WXMAC__
868
869 private:
870 wxDECLARE_NO_COPY_CLASS(wxHVScrolledWindow);
871 DECLARE_ABSTRACT_CLASS(wxHVScrolledWindow)
872 };
873
874 #endif // _WX_VSCROLL_H_
875