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