1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxVScrolledWindow documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxVScrolledWindow
}}\label{wxvscrolledwindow
}
14 In the name of this class, "V" may stand for "variable" because it can be
15 used for scrolling lines of variable heights; "virtual" because it is not
16 necessary to know the heights of all lines in advance -- only those which
17 are shown on the screen need to be measured; or, even, "vertical" because
18 this class only supports scrolling in one direction currently (this could
19 and probably will change in the future however).
21 In any case, this is a generalization of the
22 \helpref{wxScrolledWindow
}{wxscrolledwindow
} class which can be only used when
23 all lines have the same height. It lacks some other wxScrolledWindow features
24 however, notably there is currently no support for horizontal scrolling; it
25 can't scroll another window nor only a rectangle of the window and not its
28 To use this class, you need to derive from it and implement
29 \helpref{OnGetLineHeight()
}{wxvscrolledwindowongetlineheight
} pure virtual
30 method. You also must call
\helpref{SetLineCount
}{wxvscrolledwindowsetlinecount
}
31 to let the base class know how many lines it should display but from that
32 moment on the scrolling is handled entirely by wxVScrolledWindow, you only
33 need to draw the visible part of contents in your
{\tt OnPaint()
} method as
34 usual. You should use
\helpref{GetFirstVisibleLine()
}{wxvscrolledwindowgetfirstvisibleline
}
35 and
\helpref{GetLastVisibleLine()
}{wxvscrolledwindowgetlastvisibleline
} to
36 select the lines to display. Note that the device context origin is not shifted
37 so the first visible line always appears at the point $(
0,
0)$ in physical as
38 well as logical coordinates.
40 \wxheading{Derived from
}
42 \helpref{wxPanel
}{wxpanel
}\\
43 \helpref{wxWindow
}{wxwindow
}\\
44 \helpref{wxEvtHandler
}{wxevthandler
}\\
45 \helpref{wxObject
}{wxobject
}
47 \wxheading{Include files
}
52 \latexignore{\rtfignore{\wxheading{Members
}}}
55 \membersection{wxVScrolledWindow::wxVScrolledWindow
}\label{wxvscrolledwindowctor
}
57 \func{}{wxVScrolledWindow
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id = wxID
\_ANY},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{long
}{style =
0},
\param{const wxString\&
}{name = wxPanelNameStr
}}
59 This is the normal constructor, no need to call Create() after using this one.
61 Note that
{\tt wxVSCROLL
} is always automatically added to our style, there is
62 no need to specify it explicitly.
64 \func{}{wxVScrolledWindow
}{\void}
66 Default constructor, you must call
\helpref{Create()
}{wxvscrolledwindowcreate
}
69 \wxheading{Parameters
}
71 \docparam{parent
}{The parent window, must not be
{\tt NULL
}}
73 \docparam{id
}{The identifier of this window,
{\tt wxID
\_ANY} by default
}
75 \docparam{pos
}{The initial window position
}
77 \docparam{size
}{The initial window size
}
79 \docparam{style
}{The window style. There are no special style bits defined for
82 \docparam{name
}{The name for this window; usually not used
}
85 \membersection{wxVScrolledWindow::Create
}\label{wxvscrolledwindowcreate
}
87 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id = wxID
\_ANY},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{long
}{style =
0},
\param{const wxString\&
}{name = wxPanelNameStr
}}
89 Same as the
\helpref{non default ctor
}{wxvscrolledwindowctor
} but returns
90 status code:
{\tt true
} if ok,
{\tt false
} if the window couldn't have been created.
92 Just as with the ctor above,
{\tt wxVSCROLL
} style is always used, there is no
93 need to specify it explicitly.
96 \membersection{wxVScrolledWindow::EstimateTotalHeight
}\label{wxvscrolledwindowestimatetotalheight
}
98 \constfunc{virtual wxCoord
}{EstimateTotalHeight
}{\void}
100 This protected function is used internally by wxVScrolledWindow to estimate the
101 total height of the window when
\helpref{SetLineCount
}{wxvscrolledwindowsetlinecount
}
102 is called. The default implementation uses the brute force approach if the
103 number of the items in the control is small enough. Otherwise, it tries to find
104 the average line height using some lines in the beginning, middle and the end.
106 If it is undesirable to access all these lines (some of which might be never
107 shown) just for the total height calculation, you may override the function and
108 provide your own guess better and/or faster.
110 Note that although returning a totally wrong value would still work, it risks
111 to result in very strange scrollbar behaviour so this function should really
112 try to make the best guess possible.
115 \membersection{wxVScrolledWindow::GetFirstVisibleLine
}\label{wxvscrolledwindowgetfirstvisibleline
}
117 \constfunc{size
\_t}{GetFirstVisibleLine
}{\void}
119 Returns the index of the first currently visible line.
121 This is same as
\helpref{GetVisibleBegin
}{wxvscrolledwindowgetvisiblebegin
} and
122 exists only for symmetry with
\helpref{GetLastVisibleLine
}{wxvscrolledwindowgetlastvisibleline
}.
125 \membersection{wxVScrolledWindow::GetLastVisibleLine
}\label{wxvscrolledwindowgetlastvisibleline
}
127 \constfunc{size
\_t}{GetLastVisibleLine
}{\void}
129 Returns the index of the last currently visible line. Note that this method
130 returns
\texttt{(size
\_t)-
1} (i.e. a huge positive number) if the control is
131 empty so if this is possible you should use
\helpref{GetVisibleEnd
}{wxvscrolledwindowgetvisibleend
}
136 \helpref{GetFirstVisibleLine
}{wxvscrolledwindowgetfirstvisibleline
}
139 \membersection{wxVScrolledWindow::GetLineCount
}\label{wxvscrolledwindowgetlinecount
}
141 \constfunc{size
\_t}{GetLineCount
}{\void}
143 Get the number of lines this window contains (previously set by
144 \helpref{SetLineCount()
}{wxvscrolledwindowsetlinecount
})
147 \membersection{wxVScrolledWindow::GetVisibleBegin
}\label{wxvscrolledwindowgetvisiblebegin
}
149 \constfunc{size
\_t}{GetVisibleBegin
}{\void}
151 Returns the index of the first currently visible line.
155 \helpref{GetVisibleEnd
}{wxvscrolledwindowgetvisibleend
}
158 \membersection{wxVScrolledWindow::GetVisibleEnd
}\label{wxvscrolledwindowgetvisibleend
}
160 \constfunc{size
\_t}{GetVisibleEnd
}{\void}
162 Returns the index of the first line after the currently visible one. If the
163 return value is $
0$ it means that no lines are currently shown (which only
164 happens if the control is empty). Note that the index returned by this method
165 is not always a valid index as it may be equal to
\helpref{GetLineCount
}{wxvscrolledwindowgetlinecount
}.
169 \helpref{GetVisibleBegin
}{wxvscrolledwindowgetvisiblebegin
}
172 \membersection{wxVScrolledWindow::HitTest
}\label{wxvscrolledwindowhittest
}
174 \constfunc{int
}{HitTest
}{\param{wxCoord
}{x
},
\param{wxCoord
}{y
}}
176 \constfunc{int
}{HitTest
}{\param{const wxPoint\&
}{pt
}}
178 Return the item at the specified (in physical coordinates) position or
179 {\tt wxNOT
\_FOUND} if none, i.e. if it is below the last item.
182 \membersection{wxVScrolledWindow::IsVisible
}\label{wxvscrolledwindowisvisible
}
184 \constfunc{bool
}{IsVisible
}{\param{size
\_t }{line
}}
186 Returns
{\tt true
} if the given line is (at least partially) visible or
187 {\tt false
} otherwise.
190 \membersection{wxVScrolledWindow::OnGetLineHeight
}\label{wxvscrolledwindowongetlineheight
}
192 \constfunc{virtual wxCoord
}{OnGetLineHeight
}{\param{size
\_t }{n
}}
194 This protected virtual function must be overridden in the derived class and it
195 should return the height of the given line in pixels.
199 \helpref{OnGetLinesHint
}{wxvscrolledwindowongetlineshint
}
202 \membersection{wxVScrolledWindow::OnGetLinesHint
}\label{wxvscrolledwindowongetlineshint
}
204 \constfunc{virtual void
}{OnGetLinesHint
}{\param{size
\_t }{lineMin
},
\param{size
\_t }{lineMax
}}
206 This function doesn't have to be overridden but it may be useful to do
207 it if calculating the lines heights is a relatively expensive operation
208 as it gives the user code a possibility to calculate several of them at
211 {\tt OnGetLinesHint()
} is normally called just before
212 \helpref{OnGetLineHeight()
}{wxvscrolledwindowongetlineheight
} but you
213 shouldn't rely on the latter being called for all lines in the interval
214 specified here. It is also possible that OnGetLineHeight() will be
215 called for the lines outside of this interval, so this is really just a
218 Finally note that
{\it lineMin
} is inclusive, while
{\it lineMax
} is exclusive,
222 \membersection{wxVScrolledWindow::RefreshLine
}\label{wxvscrolledwindowrefreshline
}
224 \func{void
}{RefreshLine
}{\param{size
\_t }{line
}}
226 Refreshes the specified line -- it will be redrawn during the next main loop
231 \helpref{RefreshLines
}{wxvscrolledwindowrefreshlines
}
234 \membersection{wxVScrolledWindow::RefreshLines
}\label{wxvscrolledwindowrefreshlines
}
236 \func{void
}{RefreshLines
}{\param{size
\_t }{from
},
\param{size
\_t }{to
}}
238 Refreshes all lines between
{\it from
} and
{\it to
}, inclusive.
{\it from
}
239 should be less than or equal to
{\it to
}.
243 \helpref{RefreshLine
}{wxvscrolledwindowrefreshline
}
246 \membersection{wxVScrolledWindow::RefreshAll
}\label{wxvscrolledwindowrefreshall
}
248 \func{void
}{RefreshAll
}{\void}
250 This function completely refreshes the control, recalculating the number of
251 items shown on screen and repainting them. It should be called when the values
252 returned by
\helpref{OnGetLineHeight
}{wxvscrolledwindowongetlineheight
} change
253 for some reason and the window must be updated to reflect this.
256 \membersection{wxVScrolledWindow::ScrollLines
}\label{wxvscrolledwindowscrolllines
}
258 \func{bool
}{ScrollLines
}{\param{int
}{lines
}}
260 Scroll by the specified number of lines which may be positive (to scroll down)
261 or negative (to scroll up).
263 Returns
{\tt true
} if the window was scrolled,
{\tt false
} otherwise (for
264 example if we're trying to scroll down but we are already showing the last
269 \helpref{LineUp
}{wxwindowlineup
},
\helpref{LineDown
}{wxwindowlinedown
}
272 \membersection{wxVScrolledWindow::ScrollPages
}\label{wxvscrolledwindowscrollpages
}
274 \func{bool
}{ScrollPages
}{\param{int
}{pages
}}
276 Scroll by the specified number of pages which may be positive (to scroll down)
277 or negative (to scroll up).
281 \helpref{ScrollLines
}{wxvscrolledwindowscrolllines
},\\
282 \helpref{PageUp
}{wxwindowpageup
},
\helpref{PageDown
}{wxwindowpagedown
}
285 \membersection{wxVScrolledWindow::ScrollToLine
}\label{wxvscrolledwindowscrolltoline
}
287 \func{bool
}{ScrollToLine
}{\param{size
\_t }{line
}}
289 Scroll to the specified line: it will become the first visible line in
292 Return
{\tt true
} if we scrolled the window,
{\tt false
} if nothing was done.
295 \membersection{wxVScrolledWindow::SetLineCount
}\label{wxvscrolledwindowsetlinecount
}
297 \func{void
}{SetLineCount
}{\param{size
\_t }{count
}}
299 Set the number of lines the window contains: the derived class must
300 provide the heights for all lines with indices up to the one given here
301 in its
\helpref{OnGetLineHeight()
}{wxvscrolledwindowongetlineheight
}.