The great wxVScrolledWindow refactoring: allow using it both horizontal and

vertical directions (slightly modified patch 1671181)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-04-08 01:58:16 +00:00
parent 4e4e981fe6
commit f18eaf2687
21 changed files with 3116 additions and 756 deletions

View File

@@ -83,6 +83,7 @@ All:
All (GUI): All (GUI):
- Added wxH[V]ScrolledWindow (Brad Anderson, Bryan Petty)
- Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron) - Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron)
- Added support for labels for toolbar controls (Vince Harron) - Added support for labels for toolbar controls (Vince Harron)
- Added wxEventBlocker class (Francesco Montorsi). - Added wxEventBlocker class (Francesco Montorsi).

View File

@@ -196,6 +196,7 @@
\input hprovcnt.tex \input hprovcnt.tex
\input helpevt.tex \input helpevt.tex
\input helpprov.tex \input helpprov.tex
\input hscrolledwindow.tex
\input htcell.tex \input htcell.tex
\input htcolor.tex \input htcolor.tex
\input htcontnr.tex \input htcontnr.tex
@@ -217,6 +218,7 @@
\input htwinprs.tex \input htwinprs.tex
\input htwinhnd.tex \input htwinhnd.tex
\input http.tex \input http.tex
\input hvscrolledwindow.tex
\input hyperlink.tex \input hyperlink.tex
\input icon.tex \input icon.tex
\input iconbndl.tex \input iconbndl.tex
@@ -294,6 +296,7 @@
\input pickerbase.tex \input pickerbase.tex
\input platinfo.tex \input platinfo.tex
\input point.tex \input point.tex
\input position.tex
\input postscpt.tex \input postscpt.tex
\input powerevt.tex \input powerevt.tex
\input prevwin.tex \input prevwin.tex
@@ -430,10 +433,14 @@
\input url.tex \input url.tex
\input urldataob.tex \input urldataob.tex
\input validatr.tex \input validatr.tex
\input varhscrollhelper.tex
\input varhvscrollhelper.tex
\input variant.tex \input variant.tex
\input varscrollhelperbase.tex
\input varvscrollhelper.tex
\input view.tex \input view.tex
\input vlbox.tex \input vlbox.tex
\input vscroll.tex \input vscrolledwindow.tex
\input window.tex \input window.tex
\input wupdlock.tex \input wupdlock.tex
\input createevt.tex \input createevt.tex

View File

@@ -0,0 +1,99 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: hscrolledwindow.tex
%% Purpose: wxHScrolledWindow Documentation
%% Author: Bryan Petty
%% Modified by:
%% Created: 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxHScrolledWindow}}\label{wxhscrolledwindow}
In the name of this class, "H" stands for "horizontal" because it can be
used for scrolling columns of variable widths. It is not necessary to know
the widths of all columns in advance -- only those which are shown on the
screen need to be measured.
In any case, this is a generalization of the
\helpref{wxScrolledWindow}{wxscrolledwindow} class which can be only used when
all columns have the same widths. It lacks some other wxScrolledWindow features
however, notably it can't scroll only a rectangle of the window and not its
entire client area.
To use this class, you need to derive from it and implement the
\helpref{OnGetColumnWidth()}{wxvarhscrollhelperongetcolumnwidth} pure virtual
method. You also must call \helpref{SetColumnCount()}{wxvarhscrollhelpersetcolumncount}
to let the base class know how many columns it should display, but from that
moment on the scrolling is handled entirely by wxHScrolledWindow. You only
need to draw the visible part of contents in your {\tt OnPaint()} method as
usual. You should use \helpref{GetVisibleColumnsBegin()}{wxvarhscrollhelpergetvisiblecolumnsbegin}
and \helpref{GetVisibleColumnsEnd()}{wxvarhscrollhelpergetvisiblecolumnsend} to
select the lines to display. Note that the device context origin is not shifted
so the first visible column always appears at the point $(0, 0)$ in physical as
well as logical coordinates.
\wxheading{Derived from}
\helpref{wxPanel}{wxpanel}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\helpref{wxVarHScrollHelper}{wxvarhscrollhelper}\\
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHVScrolledWindow}{wxhvscrolledwindow},
\rtfsp\helpref{wxVScrolledWindow}{wxvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxHScrolledWindow::wxHScrolledWindow}\label{wxhscrolledwindowwxhscrolledwindow}
\func{}{wxHScrolledWindow}{\void}
Default constructor, you must call \helpref{Create()}{wxhscrolledwindowcreate}
later.
\func{}{wxHScrolledWindow}{\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}}
This is the normal constructor, no need to call {\tt Create()} after using this one.
Note that {\tt wxHSCROLL} is always automatically added to our style, there is
no need to specify it explicitly.
\wxheading{Parameters}
\docparam{parent}{The parent window, must not be {\tt NULL}}
\docparam{id}{The identifier of this window, {\tt wxID\_ANY} by default}
\docparam{pos}{The initial window position}
\docparam{size}{The initial window size}
\docparam{style}{The window style. There are no special style bits defined for
this class.}
\docparam{name}{The name for this window; usually not used}
\membersection{wxHScrolledWindow::Create}\label{wxhscrolledwindowcreate}
\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}}
Same as the \helpref{non-default constuctor}{wxhscrolledwindowwxhscrolledwindow}
but returns status code: {\tt true} if ok, {\tt false} if the window couldn't
be created.
Just as with the constructor above, the {\tt wxHSCROLL} style is always used,
there is no need to specify it explicitly.

View File

@@ -0,0 +1,105 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: hvscrolledwindow.tex
%% Purpose: wxHVScrolledWindow Documentation
%% Author: Bryan Petty
%% Modified by:
%% Created: 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxHVScrolledWindow}}\label{wxhvscrolledwindow}
This window inherits all functionality of both vertical and horizontal,
variable scrolled windows. It automatically handles everything needed to
scroll both axis simultaneously with both variable row heights and variable
column widths.
This is a generalization of the \helpref{wxScrolledWindow}{wxscrolledwindow}
class which can be only used when all rows and columns are the same size. It
lacks some other wxScrolledWindow features however, notably it can't scroll
only a rectangle of the window and not its entire client area.
To use this class, you must derive from it and implement both the
\helpref{OnGetRowHeight()}{wxvarvscrollhelperongetrowheight} and
\helpref{OnGetColumnWidth()}{wxvarhscrollhelperongetcolumnwidth} pure virtual
methods to let the base class know how many rows and columns it should
display. You also need to set the total rows and columns the window contains,
but from that moment on the scrolling is handled entirely by
wxHVScrolledWindow. You only need to draw the visible part of contents in
your {\tt OnPaint()} method as usual. You should use
\helpref{GetVisibleBegin()}{wxvarhvscrollhelpergetvisiblebegin}
and \helpref{GetVisibleEnd()}{wxvarhvscrollhelpergetvisibleend} to select the
lines to display. Note that the device context origin is not shifted so the
first visible row and column always appear at the point $(0, 0)$ in physical
as well as logical coordinates.
\wxheading{Derived from}
\helpref{wxPanel}{wxpanel}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\helpref{wxVarHVScrollHelper}{wxvarhvscrollhelper}
\helpref{wxVarVScrollHelper}{wxvarvscrollhelper}\\
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\helpref{wxVarHScrollHelper}{wxvarhscrollhelper}\\
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHScrolledWindow}{wxhscrolledwindow},
\rtfsp\helpref{wxVScrolledWindow}{wxvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxHVScrolledWindow::wxHVScrolledWindow}\label{wxhvscrolledwindowwxhvscrolledwindow}
\func{}{wxHVScrolledWindow}{\void}
Default constructor, you must call \helpref{Create()}{wxhvscrolledwindowcreate}
later.
\func{}{wxHVScrolledWindow}{\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}}
This is the normal constructor, no need to call {\tt Create()} after using this one.
Note that {\tt wxHSCROLL} and {\tt wxVSCROLL} are always automatically added
to our styles, there is no need to specify it explicitly.
\wxheading{Parameters}
\docparam{parent}{The parent window, must not be {\tt NULL}}
\docparam{id}{The identifier of this window, {\tt wxID\_ANY} by default}
\docparam{pos}{The initial window position}
\docparam{size}{The initial window size}
\docparam{style}{The window style. There are no special style bits defined for
this class.}
\docparam{name}{The name for this window; usually not used}
\membersection{wxHVScrolledWindow::Create}\label{wxhvscrolledwindowcreate}
\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}}
Same as the \helpref{non-default constuctor}{wxhvscrolledwindowwxhvscrolledwindow}
but returns status code: {\tt true} if ok, {\tt false} if the window couldn't
be created.
Just as with the constructor above, the {\tt wxHSCROLL} and {\tt wxVSCROLL}
styles are always used, there is no need to specify it explicitly.

View File

@@ -35,7 +35,7 @@
\setfooter{\thepage}{}{}{}{}{\thepage} \setfooter{\thepage}{}{}{}{}{\thepage}
% put your file(s) in an \input{} statement here % put your file(s) in an \input{} statement here
\input{arrstrng.tex} \input{locale.tex}
\addcontentsline{toc}{chapter}{Index} \addcontentsline{toc}{chapter}{Index}
\setheader{{\it INDEX}}{}{}{}{}{{\it INDEX}}% \setheader{{\it INDEX}}{}{}{}{}{{\it INDEX}}%

108
docs/latex/wx/position.tex Executable file
View File

@@ -0,0 +1,108 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: position.tex (moved from gbposition.tex)
%% Purpose: wxPosition Documentation
%% Author: Robin Dunn, Bryan Petty
%% Modified by:
%% Created: 2003-11-06, modified 2007-04-05
%% RCS-ID: $Id$
%% Copyright: (c) 2003, 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxPosition}}\label{wxposition}
This class represents the position of an item in any kind of grid of rows and
columns such as \helpref{wxGridBagSizer}{wxgridbagsizer}, or
\helpref{wxHVScrolledWindow}{wxhvscrolledwindow}.
\wxheading{Derived from}
No base class
\wxheading{Include files}
<wx/position.h>
\wxheading{See also}
\helpref{wxPoint}{wxpoint}, \helpref{wxSize}{wxsize}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxPosition::wxPosition}\label{wxpositionwxposition}
\func{}{wxPosition}{\void}
\func{}{wxPosition}{\param{int }{row}, \param{int }{col}}
Construct a new wxPosition, optionally setting the row and column. The
default value is $(0, 0)$.
\membersection{wxPosition::GetCol}\label{wxpositiongetcol}
\constfunc{int}{GetCol}{\void}
A synonym for \helpref{GetColumn()}{wxpositiongetcolumn}.
\membersection{wxPosition::GetColumn}\label{wxpositiongetcolumn}
\constfunc{int}{GetColumn}{\void}
Get the current row value.
\membersection{wxPosition::GetRow}\label{wxpositiongetrow}
\constfunc{int}{GetRow}{\void}
Get the current row value.
\membersection{wxPosition::SetCol}\label{wxpositionsetcol}
\func{void}{SetCol}{\param{int }{column}}
A synonym for \helpref{SetColumn()}{wxpositionsetcolumn}.
\membersection{wxPosition::SetColumn}\label{wxpositionsetcolumn}
\func{void}{SetColumn}{\param{int }{column}}
Set a new column value.
\membersection{wxPosition::SetRow}\label{wxpositionsetrow}
\func{void}{SetRow}{\param{int }{row}}
Set a new row value.
\membersection{Operators}\label{wxpositionoperators}
\constfunc{bool}{operator $==$}{\param{const wxPosition\& }{p}}
\constfunc{bool}{operator $!=$}{\param{const wxPosition\& }{p}}
Compare equality of two wxPositions.
\func{wxPosition\&}{operator $+=$}{\param{const wxPosition\& }{p}}
\func{wxPosition\&}{operator $-=$}{\param{const wxPosition\& }{p}}
\func{wxPosition\&}{operator $+=$}{\param{const wxSize\& }{s}}
\func{wxPosition\&}{operator $-=$}{\param{const wxSize\& }{s}}
\constfunc{wxPosition}{operator $+$}{\param{const wxPosition\& }{p}}
\constfunc{wxPosition}{operator $-$}{\param{const wxPosition\& }{p}}
\constfunc{wxPosition}{operator $+$}{\param{const wxSize\& }{s}}
\constfunc{wxPosition}{operator $-$}{\param{const wxSize\& }{s}}

View File

@@ -0,0 +1,178 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: varhscrollhelper.tex
%% Purpose: wxVarHScrollHelper Documentation
%% Author: Bryan Petty
%% Modified by:
%% Created: 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVarHScrollHelper}}\label{wxvarhscrollhelper}
This class provides functions wrapping the
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase} class, targeted for
horizontal-specific scrolling using \helpref{wxHScrolledWindow}{wxhscrolledwindow}.
Like wxVarScrollHelperBase, this class is mostly only useful to those classes
built into wxWidgets deriving from here, and this documentation is mostly
only provided for referencing those functions provided. You will likely want
to derive your window from wxHScrolledWindow rather than from here directly.
\wxheading{Derived from}
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHScrolledWindow}{wxhscrolledwindow},
\rtfsp\helpref{wxHVScrolledWindow}{wxhvscrolledwindow},
\rtfsp\helpref{wxVScrolledWindow}{wxvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxVarHScrollHelper::wxVarHScrollHelper}\label{wxvarhscrollhelperwxvarhscrollhelper}
\func{}{wxVarHScrollHelper}{\param{wxWindow* }{winToScroll}}
Constructor taking the target window to be scrolled by this helper class.
This will attach scroll event handlers to the target window to catch and
handle scroll events appropriately.
\membersection{wxVarHScrollHelper::EstimateTotalWidth}\label{wxvarhscrollhelperestimatetotalwidth}
\constfunc{virtual wxCoord}{EstimateTotalWidth}{\void}
This class forwards calls from
\helpref{wxVarScrollHelperBase::EstimateTotalSize}{wxvarscrollhelperbaseestimatetotalsize}
to this function so derived classes can override either just the height or
the width estimation, or just estimate both differently if desired in any
\helpref{wxHVScrolledWindow}{wxhvscrolledwindow} derived class.
Please note that this function will not be called if {\tt EstimateTotalSize()}
is overridden in your derived class.
\membersection{wxVarHScrollHelper::GetColumnCount}\label{wxvarhscrollhelpergetcolumncount}
\constfunc{size\_t}{GetColumnCount}{\void}
Returns the number of columns the target window contains.
\wxheading{See also}
\helpref{SetColumnCount()}{wxvarhscrollhelpersetcolumncount}
\membersection{wxVarHScrollHelper::GetVisibleColumnsBegin}\label{wxvarhscrollhelpergetvisiblecolumnsbegin}
\constfunc{size\_t}{GetVisibleColumnsBegin}{\void}
Returns the index of the first visible column based on the scroll position.
\membersection{wxVarHScrollHelper::GetVisibleColumnsEnd}\label{wxvarhscrollhelpergetvisiblecolumnsend}
\constfunc{size\_t}{GetVisibleColumnsEnd}{\void}
Returns the index of the last visible column based on the scroll position. This
includes the last column even if it is only partially visible.
\membersection{wxVarHScrollHelper::IsColumnVisible}\label{wxvarhscrollhelperiscolumnvisible}
\constfunc{bool}{IsColumnVisible}{\param{size\_t }{column}}
Returns {\tt true} if the given column is currently visible (even if only
partially visible) or {\tt false} otherwise.
\membersection{wxVarHScrollHelper::OnGetColumnWidth}\label{wxvarhscrollhelperongetcolumnwidth}
\constfunc{virtual wxCoord}{OnGetColumnWidth}{\param{size\_t }{column}}
This function must be overridden in the derived class, and should return the
width of the given column in pixels.
\membersection{wxVarHScrollHelper::OnGetColumnsWidthHint}\label{wxvarhscrollhelperongetcolumnswidthhint}
\constfunc{virtual void}{OnGetColumnsWidthHint}{\param{size\_t }{columnMin}, \param{size\_t }{columnMax}}
This function doesn't have to be overridden but it may be useful to do so if
calculating the columns' sizes is a relatively expensive operation as it gives
your code a chance to calculate several of them at once and cache the result
if necessary.
{\tt OnGetColumnsWidthHint()} is normally called just before
\helpref{OnGetColumnWidth()}{wxvarhscrollhelperongetcolumnwidth} but you
shouldn't rely on the latter being called for all columns in the interval
specified here. It is also possible that OnGetColumnWidth() will be called for
units outside of this interval, so this is really just a hint, not a promise.
Finally, note that columnMin is inclusive, while columnMax is exclusive.
\membersection{wxVarHScrollHelper::RefreshColumn}\label{wxvarhscrollhelperrefreshcolumn}
\func{virtual void}{RefreshColumn}{\param{size\_t }{column}}
Triggers a refresh for just the given column's area of the window if it's visible.
\membersection{wxVarHScrollHelper::RefreshColumns}\label{wxvarhscrollhelperrefreshcolumns}
\func{virtual void}{RefreshColumns}{\param{size\_t }{from}, \param{size\_t }{to}}
Triggers a refresh for the area between the specified range of columns given
(inclusively).
\membersection{wxVarHScrollHelper::ScrollColumnPages}\label{wxvarhscrollhelperscrollcolumnpages}
\func{virtual bool}{ScrollColumnPages}{\param{int }{pages}}
Scroll by the specified number of pages which may be positive (to scroll right)
or negative (to scroll left).
\membersection{wxVarHScrollHelper::ScrollColumns}\label{wxvarhscrollhelperscrollcolumns}
\func{virtual bool}{ScrollColumns}{\param{int }{columns}}
Scroll by the specified number of columns which may be positive (to scroll right)
or negative (to scroll left).
Returns {\tt true} if the window was scrolled, {\tt false} otherwise (for
example, if we're trying to scroll right but we are already showing the last
column).
\membersection{wxVarHScrollHelper::ScrollToColumn}\label{wxvarhscrollhelperscrolltocolumn}
\func{bool}{ScrollToColumn}{\param{size\_t }{column}}
Scroll to the specified column. It will become the first visible column in the window.
Returns {\tt true} if we scrolled the window, {\tt false} if nothing was done.
\membersection{wxVarHScrollHelper::SetColumnCount}\label{wxvarhscrollhelpersetcolumncount}
\func{void}{SetColumnCount}{\param{size\_t }{columnCount}}
Set the number of columns the window contains. The derived class must provide
the widths for all columns with indices up to the one given here in it's
\helpref{OnGetColumnWidth()}{wxvarhscrollhelperongetcolumnwidth} implementation.
\wxheading{See also}
\helpref{GetColumnCount()}{wxvarhscrollhelpergetcolumncount}

View File

@@ -0,0 +1,173 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: varhvscrollhelper.tex
%% Purpose: wxVarHVScrollHelper Documentation
%% Author: Bryan Petty
%% Modified by:
%% Created: 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVarHVScrollHelper}}\label{wxvarhvscrollhelper}
This class provides functions wrapping the
\helpref{wxVarHScrollHelper}{wxvarhscrollhelper} and
\helpref{wxVarVScrollHelper}{wxvarvscrollhelper} classes, targeted for
scrolling a window in both axis using
\helpref{wxHVScrolledWindow}{wxhvscrolledwindow}. Since this class is also
the join class of the horizontal and vertical scrolling functionality, it
also addresses some wrappers that help avoid the need to specify class scope
in your wxHVScrolledWindow-derived class when using wxVarScrollHelperBase
functionality.
Like all three of it's scroll helper base classes, this class is mostly only
useful to those classes built into wxWidgets deriving from here, and this
documentation is mostly only provided for referencing those functions
provided. You will likely want to derive your window from wxHVScrolledWindow
rather than from here directly.
\wxheading{Derived from}
\helpref{wxVarVScrollHelper}{wxvarvscrollhelper}\\
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\helpref{wxVarHScrollHelper}{wxvarhscrollhelper}\\
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHScrolledWindow}{wxhscrolledwindow},
\rtfsp\helpref{wxHVScrolledWindow}{wxhvscrolledwindow},
\rtfsp\helpref{wxVScrolledWindow}{wxvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxVarHVScrollHelper::wxVarHVScrollHelper}\label{wxvarhvscrollhelperwxvarhvscrollhelper}
\func{}{wxVarHVScrollHelper}{\param{wxWindow* }{winToScroll}}
Constructor taking the target window to be scrolled by this helper class.
This will attach scroll event handlers to the target window to catch and
handle scroll events appropriately.
\membersection{wxVarHVScrollHelper::EnablePhysicalScrolling}\label{wxvarhvscrollhelperenablephysicalscrolling}
\func{void}{EnablePhysicalScrolling}{\param{bool }{vscrolling = true}, \param{bool }{hscrolling = true}}
With physical scrolling on (when this is {\tt true}), the device origin is
changed properly when a \rtfsp\helpref{wxPaintDC}{wxpaintdc} is prepared,
children are actually moved and laid out properly, and the contents of the
window (pixels) are actually moved. When this is {\tt false}, you are
responsible for repainting any invalidated areas of the window yourself to
account for the new scroll position.
\wxheading{Parameters}
\docparam{vscrolling}{Specifies if physical scrolling should be turned on when scrolling vertically.}
\docparam{hscrolling}{Specifies if physical scrolling should be turned on when scrolling horizontally.}
\membersection{wxVarHVScrollHelper::GetRowColumnCount}\label{wxvarhvscrollhelpergetrowcolumncount}
\constfunc{wxSize}{GetRowColumnCount}{\void}
Returns the number of columns and rows the target window contains.
\wxheading{See also}
\helpref{SetRowColumnCount()}{wxvarhvscrollhelpersetrowcolumncount}
\membersection{wxVarHVScrollHelper::GetVisibleBegin}\label{wxvarhvscrollhelpergetvisiblebegin}
\constfunc{wxPosition}{GetVisibleBegin}{\void}
Returns the index of the first visible column and row based on the current
scroll position.
\membersection{wxVarHVScrollHelper::GetVisibleEnd}\label{wxvarhvscrollhelpergetvisibleend}
\constfunc{wxPosition}{GetVisibleEnd}{\void}
Returns the index of the last visible column and row based on the scroll
position. This includes any partially visible columns or rows.
\membersection{wxVarHVScrollHelper::HitTest}\label{wxvarhvscrollhelperhittest}
\constfunc{virtual wxPosition}{HitTest}{\param{wxCoord }{x}, \param{wxCoord }{y}}
\constfunc{virtual wxPosition}{HitTest}{\param{const wxPoint\& }{pos}}
Returns the scroll unit under the device unit given accounting for scroll
position or {\tt wxNOT\_FOUND} (for the row, column, or possibly both values)
if none.
\membersection{wxVarHVScrollHelper::IsVisible}\label{wxvarhvscrollhelperisvisible}
\constfunc{bool}{IsVisible}{\param{size\_t }{row}, \param{size\_t }{column}}
\constfunc{bool}{IsVisible}{\param{const wxPosition\& }{pos}}
Returns {\tt true} if both the given row and column are currently visible
(even if only partially visible) or {\tt false} otherwise.
\membersection{wxVarHVScrollHelper::RefreshRowColumn}\label{wxvarhvscrollhelperrefreshrowcolumn}
\func{virtual void}{RefreshRowColumn}{\param{size\_t }{row}, \param{size\_t }{column}}
\func{virtual void}{RefreshRowColumn}{\param{const wxPosition\& }{pos}}
Triggers a refresh for just the area shared between the given row and column
of the window if it is visible.
\membersection{wxVarHVScrollHelper::RefreshRowsColumns}\label{wxvarhvscrollhelperrefreshrowscolumns}
\func{virtual void}{RefreshRowsColumns}{\param{size\_t }{fromRow}, \param{size\_t }{toRow}, \param{size\_t }{fromColumn}, \param{size\_t }{toColumn}}
\func{virtual void}{RefreshRowsColumns}{\param{const wxPosition\& }{from}, \param{const wxPosition\& }{to}}
Triggers a refresh for the visible area shared between all given rows and
columns (inclusive) of the window. If the target window for both orientations
is the same, the rectangle of cells is refreshed; if the target windows
differ, the entire client size opposite the orientation direction is
refreshed between the specified limits.
\membersection{wxVarHVScrollHelper::ScrollToRowColumn}\label{wxvarhvscrollhelperscrolltorowcolumn}
\func{bool}{ScrollToRowColumn}{\param{size\_t }{row}, \param{size\_t }{column}}
\func{bool}{ScrollToRowColumn}{\param{const wxPosition\& }{pos}}
Scroll to the specified row and column. It will become the first visible row
and column in the window. Returns {\tt true} if we scrolled the window,
{\tt false} if nothing was done.
\membersection{wxVarHVScrollHelper::SetRowColumnCount}\label{wxvarhvscrollhelpersetrowcolumncount}
\func{void}{SetRowColumnCount}{\param{size\_t }{rowCount}, \param{size\_t }{columnCount}}
Set the number of rows and columns the target window will contain. The
derived class must provide the sizes for all rows and columns with indices up
to the ones given here in it's \helpref{OnGetRowHeight()}{wxvarvscrollhelperongetrowheight}
and \helpref{OnGetColumnWidth()}{wxvarhscrollhelperongetcolumnwidth} implementations,
respectively.
\wxheading{See also}
\helpref{GetRowColumnCount()}{wxvarhvscrollhelpergetrowcolumncount}

View File

@@ -0,0 +1,243 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: varscrollhelperbase.tex
%% Purpose: wxVarScrollHelperBase Documentation
%% Author: Bryan Petty
%% Modified by:
%% Created: 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVarScrollHelperBase}}\label{wxvarscrollhelperbase}
This class provides all common base functionality for scroll calculations
shared among all variable scrolled window implementations as well as
automatic scrollbar functionality, saved scroll positions, controlling
target windows to be scrolled, as well as defining all required virtual
functions that need to be implemented for any orientation specific work.
Documentation of this class is provided specifically for referencing use
of the functions provided by this class for use with the variable scrolled
windows that derive from here. You will likely want to derive your window
from one of the already implemented variable scrolled windows rather than
from wxVarScrollHelperBase directly.
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHScrolledWindow}{wxhscrolledwindow},
\rtfsp\helpref{wxHVScrolledWindow}{wxhvscrolledwindow},
\rtfsp\helpref{wxVScrolledWindow}{wxvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxVarScrollHelperBase::wxVarScrollHelperBase}\label{wxvarscrollhelperbasewxvarscrollhelperbase}
\func{}{wxVarScrollHelperBase}{\param{wxWindow* }{winToScroll}}
Constructor taking the target window to be scrolled by this helper class.
This will attach scroll event handlers to the target window to catch and
handle scroll events appropriately.
\membersection{wxVarScrollHelperBase::\destruct{wxVarScrollHelperBase}}\label{wxvarscrollhelperbasedtor}
\func{virtual }{\destruct{wxVarScrollHelperBase}}{\void}
Virtual destructor for detaching scroll event handlers attached with this
helper class.
\membersection{wxVarScrollHelperBase::CalcScrolledPosition}\label{wxvarscrollhelperbasecalcscrolledposition}
\constfunc{int}{CalcScrolledPosition}{\param{int }{coord}}
Translates the logical coordinate given to the current device coordinate.
For example, if the window is scrolled 10 units and each scroll unit
represents 10 device units (which may not be the case since this class allows
for variable scroll unit sizes), a call to this function with a coordinate of
15 will return -85.
\wxheading{See also}
\helpref{CalcUnscrolledPosition()}{wxvarscrollhelperbasecalcunscrolledposition}
\membersection{wxVarScrollHelperBase::CalcUnscrolledPosition}\label{wxvarscrollhelperbasecalcunscrolledposition}
\constfunc{int}{CalcUnscrolledPosition}{\param{int }{coord}}
Translates the device coordinate given to the corresponding logical
coordinate. For example, if the window is scrolled 10 units and each scroll
unit represents 10 device units (which may not be the case since this class
allows for variable scroll unit sizes), a call to this function with a
coordinate of 15 will return 115.
\wxheading{See also}
\helpref{CalcScrolledPosition()}{wxvarscrollhelperbasecalcscrolledposition}
\membersection{wxVarScrollHelperBase::EnablePhysicalScrolling}\label{wxvarscrollhelperbaseenablephysicalscrolling}
\func{void}{EnablePhysicalScrolling}{\param{bool }{scrolling = true}}
With physical scrolling on (when this is {\tt true}), the device origin is
changed properly when a \rtfsp\helpref{wxPaintDC}{wxpaintdc} is prepared,
children are actually moved and laid out properly, and the contents of the
window (pixels) are actually moved. When this is {\tt false}, you are
responsible for repainting any invalidated areas of the window yourself to
account for the new scroll position.
\membersection{wxVarScrollHelperBase::EstimateTotalSize}\label{wxvarscrollhelperbaseestimatetotalsize}
\constfunc{virtual wxCoord}{EstimateTotalSize}{\void}
When the number of scroll units change, we try to estimate the total size of
all units when the full window size is needed (i.e. to calculate the scrollbar
thumb size). This is a rather expensive operation in terms of unit access, so
if the user code may estimate the average size better or faster than we do, it
should override this function to implement its own logic. This function should
return the best guess for the total virtual window size.
Note that although returning a totally wrong value would still work, it risks
resulting in very strange scrollbar behaviour so this function should really
try to make the best guess possible.
\membersection{wxVarScrollHelperBase::GetNonOrientationTargetSize}\label{wxvarscrollhelperbasegetnonorientationtargetsize}
\constfunc{virtual int}{GetNonOrientationTargetSize}{\void}
This function needs to be overridden in the in the derived class to return the
window size with respect to the opposing orientation. If this is a vertical
scrolled window, it should return the height.
\wxheading{See also}
\helpref{GetOrientationTargetSize()}{wxvarscrollhelperbasegetorientationtargetsize}
\membersection{wxVarScrollHelperBase::GetOrientation}\label{wxvarscrollhelperbasegetorientation}
\constfunc{virtual wxOrientation}{GetOrientation}{\void}
This function need to be overridden to return the orientation that this helper
is working with, either {\tt wxHORIZONTAL} or {\tt wxVERTICAL}.
\membersection{wxVarScrollHelperBase::GetOrientationTargetSize}\label{wxvarscrollhelperbasegetorientationtargetsize}
\constfunc{virtual int}{GetOrientationTargetSize}{\void}
This function needs to be overridden in the in the derived class to return the
window size with respect to the orientation this helper is working with. If
this is a vertical scrolled window, it should return the width.
\wxheading{See also}
\helpref{GetNonOrientationTargetSize()}{wxvarscrollhelperbasegetnonorientationtargetsize}
\membersection{wxVarScrollHelperBase::GetTargetWindow}\label{wxvarscrollhelperbasegettargetwindow}
\constfunc{wxWindow*}{GetTargetWindow}{\void}
This function will return the target window this helper class is currently
scrolling.
\wxheading{See also}
\helpref{SetTargetWindow()}{wxvarscrollhelperbasesettargetwindow}
\membersection{wxVarScrollHelperBase::GetVisibleBegin}\label{wxvarscrollhelperbasegetvisiblebegin}
\constfunc{size\_t}{GetVisibleBegin}{\void}
Returns the index of the first visible unit based on the scroll position.
\membersection{wxVarScrollHelperBase::GetVisibleEnd}\label{wxvarscrollhelperbasegetvisibleend}
\constfunc{size\_t}{GetVisibleEnd}{\void}
Returns the index of the last visible unit based on the scroll position. This
includes the last unit even if it is only partially visible.
\membersection{wxVarScrollHelperBase::HitTest}\label{wxvarscrollhelperbasehittest}
\constfunc{virtual int}{HitTest}{\param{wxCoord }{coord}}
Returns the scroll unit under the device unit given accounting for scroll
position or {\tt wxNOT\_FOUND} if none (i.e. if it is below the last item).
\membersection{wxVarScrollHelperBase::IsVisible}\label{wxvarscrollhelperbaseisvisible}
\constfunc{bool}{IsVisible}{\param{size\_t }{unit}}
Returns {\tt true} if the given scroll unit is currently visible (even if only
partially visible) or {\tt false} otherwise.
\membersection{wxVarScrollHelperBase::OnGetUnitSize}\label{wxvarscrollhelperbaseongetunitsize}
\constfunc{virtual wxCoord}{OnGetUnitSize}{\param{size\_t }{unit}}
This function must be overridden in the derived class, and should return the
size of the given unit in pixels.
\membersection{wxVarScrollHelperBase::OnGetUnitsSizeHint}\label{wxvarscrollhelperbaseongetunitssizehint}
\constfunc{virtual void}{OnGetUnitsSizeHint}{\param{size\_t }{unitMin}, \param{size\_t }{unitMax}}
This function doesn't have to be overridden but it may be useful to do so if
calculating the units' sizes is a relatively expensive operation as it gives
your code a chance to calculate several of them at once and cache the result
if necessary.
{\tt OnGetUnitsSizeHint()} is normally called just before
\helpref{OnGetUnitSize()}{wxvarscrollhelperbaseongetunitsize} but you
shouldn't rely on the latter being called for all units in the interval
specified here. It is also possible that OnGetUnitSize() will be called for
units outside of this interval, so this is really just a hint, not a promise.
Finally, note that unitMin is inclusive, while unitMax is exclusive.
\membersection{wxVarScrollHelperBase::RefreshAll}\label{wxvarscrollhelperbaserefreshall}
\func{virtual void}{RefreshAll}{\void}
Recalculate all parameters and repaint all units.
\membersection{wxVarScrollHelperBase::SetTargetWindow}\label{wxvarscrollhelperbasesettargetwindow}
\func{void}{SetTargetWindow}{\param{wxWindow* }{target}}
Normally the window will scroll itself, but in some rare occasions you might
want it to scroll (part of) another window (e.g. a child of it in order to
scroll only a portion the area between the scrollbars like a spreadsheet where
only the cell area will move).
\wxheading{See also}
\helpref{GetTargetWindow()}{wxvarscrollhelperbasegettargetwindow}
\membersection{wxVarScrollHelperBase::UpdateScrollbar}\label{wxvarscrollhelperbaseupdatescrollbar}
\func{virtual void}{UpdateScrollbar}{\void}
Update the thumb size shown by the scrollbar.

View File

@@ -0,0 +1,178 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: varvscrollhelper.tex
%% Purpose: wxVarVScrollHelper Documentation
%% Author: Bryan Petty
%% Modified by:
%% Created: 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVarVScrollHelper}}\label{wxvarvscrollhelper}
This class provides functions wrapping the
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase} class, targeted for
vertical-specific scrolling using \helpref{wxVScrolledWindow}{wxvscrolledwindow}.
Like wxVarScrollHelperBase, this class is mostly only useful to those classes
built into wxWidgets deriving from here, and this documentation is mostly
only provided for referencing those functions provided. You will likely want
to derive your window from wxVScrolledWindow rather than from here directly.
\wxheading{Derived from}
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHScrolledWindow}{wxhscrolledwindow},
\rtfsp\helpref{wxHVScrolledWindow}{wxhvscrolledwindow},
\rtfsp\helpref{wxVScrolledWindow}{wxvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxVarVScrollHelper::wxVarVScrollHelper}\label{wxvarvscrollhelperwxvarvscrollhelper}
\func{}{wxVarVScrollHelper}{\param{wxWindow* }{winToScroll}}
Constructor taking the target window to be scrolled by this helper class.
This will attach scroll event handlers to the target window to catch and
handle scroll events appropriately.
\membersection{wxVarVScrollHelper::EstimateTotalHeight}\label{wxvarvscrollhelperestimatetotalheight}
\constfunc{virtual wxCoord}{EstimateTotalHeight}{\void}
This class forwards calls from
\helpref{wxVarScrollHelperBase::EstimateTotalSize}{wxvarscrollhelperbaseestimatetotalsize}
to this function so derived classes can override either just the height or
the width estimation, or just estimate both differently if desired in any
\helpref{wxHVScrolledWindow}{wxhvscrolledwindow} derived class.
Please note that this function will not be called if {\tt EstimateTotalSize()}
is overridden in your derived class.
\membersection{wxVarVScrollHelper::GetRowCount}\label{wxvarvscrollhelpergetrowcount}
\constfunc{size\_t}{GetRowCount}{\void}
Returns the number of rows the target window contains.
\wxheading{See also}
\helpref{SetRowCount()}{wxvarvscrollhelpersetrowcount}
\membersection{wxVarVScrollHelper::GetVisibleRowsBegin}\label{wxvarvscrollhelpergetvisiblerowsbegin}
\constfunc{size\_t}{GetVisibleRowsBegin}{\void}
Returns the index of the first visible row based on the scroll position.
\membersection{wxVarVScrollHelper::GetVisibleRowsEnd}\label{wxvarvscrollhelpergetvisiblerowsend}
\constfunc{size\_t}{GetVisibleRowsEnd}{\void}
Returns the index of the last visible row based on the scroll position. This
includes the last row even if it is only partially visible.
\membersection{wxVarVScrollHelper::IsRowVisible}\label{wxvarvscrollhelperisrowvisible}
\constfunc{bool}{IsRowVisible}{\param{size\_t }{row}}
Returns {\tt true} if the given row is currently visible (even if only
partially visible) or {\tt false} otherwise.
\membersection{wxVarVScrollHelper::OnGetRowHeight}\label{wxvarvscrollhelperongetrowheight}
\constfunc{virtual wxCoord}{OnGetRowHeight}{\param{size\_t }{row}}
This function must be overridden in the derived class, and should return the
height of the given row in pixels.
\membersection{wxVarVScrollHelper::OnGetRowsHeightHint}\label{wxvarvscrollhelperongetrowsheighthint}
\constfunc{virtual void}{OnGetRowsHeightHint}{\param{size\_t }{rowMin}, \param{size\_t }{rowMax}}
This function doesn't have to be overridden but it may be useful to do so if
calculating the rows' sizes is a relatively expensive operation as it gives
your code a chance to calculate several of them at once and cache the result
if necessary.
{\tt OnGetRowsHeightHint()} is normally called just before
\helpref{OnGetRowHeight()}{wxvarvscrollhelperongetrowheight} but you
shouldn't rely on the latter being called for all rows in the interval
specified here. It is also possible that OnGetRowHeight() will be called for
units outside of this interval, so this is really just a hint, not a promise.
Finally, note that rowMin is inclusive, while rowMax is exclusive.
\membersection{wxVarVScrollHelper::RefreshRow}\label{wxvarvscrollhelperrefreshrow}
\func{virtual void}{RefreshRow}{\param{size\_t }{row}}
Triggers a refresh for just the given row's area of the window if it's visible.
\membersection{wxVarVScrollHelper::RefreshRows}\label{wxvarvscrollhelperrefreshrows}
\func{virtual void}{RefreshRows}{\param{size\_t }{from}, \param{size\_t }{to}}
Triggers a refresh for the area between the specified range of rows given
(inclusively).
\membersection{wxVarVScrollHelper::ScrollRowPages}\label{wxvarvscrollhelperscrollrowpages}
\func{virtual bool}{ScrollRowPages}{\param{int }{pages}}
Scroll by the specified number of pages which may be positive (to scroll down)
or negative (to scroll up).
\membersection{wxVarVScrollHelper::ScrollRows}\label{wxvarvscrollhelperscrollrows}
\func{virtual bool}{ScrollRows}{\param{int }{rows}}
Scroll by the specified number of rows which may be positive (to scroll down)
or negative (to scroll up).
Returns {\tt true} if the window was scrolled, {\tt false} otherwise (for
example, if we're trying to scroll down but we are already showing the last
row).
\membersection{wxVarVScrollHelper::ScrollToRow}\label{wxvarvscrollhelperscrolltorow}
\func{bool}{ScrollToRow}{\param{size\_t }{row}}
Scroll to the specified row. It will become the first visible row in the window.
Returns {\tt true} if we scrolled the window, {\tt false} if nothing was done.
\membersection{wxVarVScrollHelper::SetRowCount}\label{wxvarvscrollhelpersetrowcount}
\func{void}{SetRowCount}{\param{size\_t }{rowCount}}
Set the number of rows the window contains. The derived class must provide the
heights for all rows with indices up to the one given here in it's
\helpref{OnGetRowHeight()}{wxvarvscrollhelperongetrowheight} implementation.
\wxheading{See also}
\helpref{GetRowCount()}{wxvarvscrollhelpergetrowcount}

View File

@@ -1,302 +0,0 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: vscroll.tex
%% Purpose: wxVScrolledWindow documentation
%% Author: Vadim Zeitlin
%% Modified by:
%% Created: 30.05.03
%% RCS-ID: $Id$
%% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVScrolledWindow}}\label{wxvscrolledwindow}
In the name of this class, "V" may stand for "variable" because it can be
used for scrolling lines of variable heights; "virtual" because it is not
necessary to know the heights of all lines in advance -- only those which
are shown on the screen need to be measured; or, even, "vertical" because
this class only supports scrolling in one direction currently (this could
and probably will change in the future however).
In any case, this is a generalization of the
\helpref{wxScrolledWindow}{wxscrolledwindow} class which can be only used when
all lines have the same height. It lacks some other wxScrolledWindow features
however, notably there is currently no support for horizontal scrolling; it
can't scroll another window nor only a rectangle of the window and not its
entire client area.
To use this class, you need to derive from it and implement
\helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight} pure virtual
method. You also must call \helpref{SetLineCount}{wxvscrolledwindowsetlinecount}
to let the base class know how many lines it should display but from that
moment on the scrolling is handled entirely by wxVScrolledWindow, you only
need to draw the visible part of contents in your {\tt OnPaint()} method as
usual. You should use \helpref{GetFirstVisibleLine()}{wxvscrolledwindowgetfirstvisibleline}
and \helpref{GetLastVisibleLine()}{wxvscrolledwindowgetlastvisibleline} to
select the lines to display. Note that the device context origin is not shifted
so the first visible line always appears at the point $(0, 0)$ in physical as
well as logical coordinates.
\wxheading{Derived from}
\helpref{wxPanel}{wxpanel}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/vscroll.h>
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxVScrolledWindow::wxVScrolledWindow}\label{wxvscrolledwindowctor}
\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}}
This is the normal constructor, no need to call Create() after using this one.
Note that {\tt wxVSCROLL} is always automatically added to our style, there is
no need to specify it explicitly.
\func{}{wxVScrolledWindow}{\void}
Default constructor, you must call \helpref{Create()}{wxvscrolledwindowcreate}
later.
\wxheading{Parameters}
\docparam{parent}{The parent window, must not be {\tt NULL}}
\docparam{id}{The identifier of this window, {\tt wxID\_ANY} by default}
\docparam{pos}{The initial window position}
\docparam{size}{The initial window size}
\docparam{style}{The window style. There are no special style bits defined for
this class.}
\docparam{name}{The name for this window; usually not used}
\membersection{wxVScrolledWindow::Create}\label{wxvscrolledwindowcreate}
\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}}
Same as the \helpref{non default ctor}{wxvscrolledwindowctor} but returns
status code: {\tt true} if ok, {\tt false} if the window couldn't have been created.
Just as with the ctor above, {\tt wxVSCROLL} style is always used, there is no
need to specify it explicitly.
\membersection{wxVScrolledWindow::EstimateTotalHeight}\label{wxvscrolledwindowestimatetotalheight}
\constfunc{virtual wxCoord}{EstimateTotalHeight}{\void}
This protected function is used internally by wxVScrolledWindow to estimate the
total height of the window when \helpref{SetLineCount}{wxvscrolledwindowsetlinecount}
is called. The default implementation uses the brute force approach if the
number of the items in the control is small enough. Otherwise, it tries to find
the average line height using some lines in the beginning, middle and the end.
If it is undesirable to access all these lines (some of which might be never
shown) just for the total height calculation, you may override the function and
provide your own guess better and/or faster.
Note that although returning a totally wrong value would still work, it risks
to result in very strange scrollbar behaviour so this function should really
try to make the best guess possible.
\membersection{wxVScrolledWindow::GetFirstVisibleLine}\label{wxvscrolledwindowgetfirstvisibleline}
\constfunc{size\_t}{GetFirstVisibleLine}{\void}
Returns the index of the first currently visible line.
This is same as \helpref{GetVisibleBegin}{wxvscrolledwindowgetvisiblebegin} and
exists only for symmetry with \helpref{GetLastVisibleLine}{wxvscrolledwindowgetlastvisibleline}.
\membersection{wxVScrolledWindow::GetLastVisibleLine}\label{wxvscrolledwindowgetlastvisibleline}
\constfunc{size\_t}{GetLastVisibleLine}{\void}
Returns the index of the last currently visible line. Note that this method
returns \texttt{(size\_t)-1} (i.e. a huge positive number) if the control is
empty so if this is possible you should use \helpref{GetVisibleEnd}{wxvscrolledwindowgetvisibleend}
instead.
\wxheading{See also}
\helpref{GetFirstVisibleLine}{wxvscrolledwindowgetfirstvisibleline}
\membersection{wxVScrolledWindow::GetLineCount}\label{wxvscrolledwindowgetlinecount}
\constfunc{size\_t}{GetLineCount}{\void}
Get the number of lines this window contains (previously set by
\helpref{SetLineCount()}{wxvscrolledwindowsetlinecount})
\membersection{wxVScrolledWindow::GetVisibleBegin}\label{wxvscrolledwindowgetvisiblebegin}
\constfunc{size\_t}{GetVisibleBegin}{\void}
Returns the index of the first currently visible line.
\wxheading{See also}
\helpref{GetVisibleEnd}{wxvscrolledwindowgetvisibleend}
\membersection{wxVScrolledWindow::GetVisibleEnd}\label{wxvscrolledwindowgetvisibleend}
\constfunc{size\_t}{GetVisibleEnd}{\void}
Returns the index of the first line after the currently visible one. If the
return value is $0$ it means that no lines are currently shown (which only
happens if the control is empty). Note that the index returned by this method
is not always a valid index as it may be equal to \helpref{GetLineCount}{wxvscrolledwindowgetlinecount}.
\wxheading{See also}
\helpref{GetVisibleBegin}{wxvscrolledwindowgetvisiblebegin}
\membersection{wxVScrolledWindow::HitTest}\label{wxvscrolledwindowhittest}
\constfunc{int}{HitTest}{\param{wxCoord }{x}, \param{wxCoord }{y}}
\constfunc{int}{HitTest}{\param{const wxPoint\& }{pt}}
Return the item at the specified (in physical coordinates) position or
{\tt wxNOT\_FOUND} if none, i.e. if it is below the last item.
\membersection{wxVScrolledWindow::IsVisible}\label{wxvscrolledwindowisvisible}
\constfunc{bool}{IsVisible}{\param{size\_t }{line}}
Returns {\tt true} if the given line is (at least partially) visible or
{\tt false} otherwise.
\membersection{wxVScrolledWindow::OnGetLineHeight}\label{wxvscrolledwindowongetlineheight}
\constfunc{virtual wxCoord}{OnGetLineHeight}{\param{size\_t }{n}}
This protected virtual function must be overridden in the derived class and it
should return the height of the given line in pixels.
\wxheading{See also}
\helpref{OnGetLinesHint}{wxvscrolledwindowongetlineshint}
\membersection{wxVScrolledWindow::OnGetLinesHint}\label{wxvscrolledwindowongetlineshint}
\constfunc{virtual void}{OnGetLinesHint}{\param{size\_t }{lineMin}, \param{size\_t }{lineMax}}
This function doesn't have to be overridden but it may be useful to do
it if calculating the lines heights is a relatively expensive operation
as it gives the user code a possibility to calculate several of them at
once.
{\tt OnGetLinesHint()} is normally called just before
\helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight} but you
shouldn't rely on the latter being called for all lines in the interval
specified here. It is also possible that OnGetLineHeight() will be
called for the lines outside of this interval, so this is really just a
hint, not a promise.
Finally note that {\it lineMin} is inclusive, while {\it lineMax} is exclusive,
as usual.
\membersection{wxVScrolledWindow::RefreshLine}\label{wxvscrolledwindowrefreshline}
\func{void}{RefreshLine}{\param{size\_t }{line}}
Refreshes the specified line -- it will be redrawn during the next main loop
iteration.
\wxheading{See also}
\helpref{RefreshLines}{wxvscrolledwindowrefreshlines}
\membersection{wxVScrolledWindow::RefreshLines}\label{wxvscrolledwindowrefreshlines}
\func{void}{RefreshLines}{\param{size\_t }{from}, \param{size\_t }{to}}
Refreshes all lines between {\it from} and {\it to}, inclusive. {\it from}
should be less than or equal to {\it to}.
\wxheading{See also}
\helpref{RefreshLine}{wxvscrolledwindowrefreshline}
\membersection{wxVScrolledWindow::RefreshAll}\label{wxvscrolledwindowrefreshall}
\func{void}{RefreshAll}{\void}
This function completely refreshes the control, recalculating the number of
items shown on screen and repainting them. It should be called when the values
returned by \helpref{OnGetLineHeight}{wxvscrolledwindowongetlineheight} change
for some reason and the window must be updated to reflect this.
\membersection{wxVScrolledWindow::ScrollLines}\label{wxvscrolledwindowscrolllines}
\func{bool}{ScrollLines}{\param{int }{lines}}
Scroll by the specified number of lines which may be positive (to scroll down)
or negative (to scroll up).
Returns {\tt true} if the window was scrolled, {\tt false} otherwise (for
example if we're trying to scroll down but we are already showing the last
line).
\wxheading{See also}
\helpref{LineUp}{wxwindowlineup}, \helpref{LineDown}{wxwindowlinedown}
\membersection{wxVScrolledWindow::ScrollPages}\label{wxvscrolledwindowscrollpages}
\func{bool}{ScrollPages}{\param{int }{pages}}
Scroll by the specified number of pages which may be positive (to scroll down)
or negative (to scroll up).
\wxheading{See also}
\helpref{ScrollLines}{wxvscrolledwindowscrolllines},\\
\helpref{PageUp}{wxwindowpageup}, \helpref{PageDown}{wxwindowpagedown}
\membersection{wxVScrolledWindow::ScrollToLine}\label{wxvscrolledwindowscrolltoline}
\func{bool}{ScrollToLine}{\param{size\_t }{line}}
Scroll to the specified line: it will become the first visible line in
the window.
Return {\tt true} if we scrolled the window, {\tt false} if nothing was done.
\membersection{wxVScrolledWindow::SetLineCount}\label{wxvscrolledwindowsetlinecount}
\func{void}{SetLineCount}{\param{size\_t }{count}}
Set the number of lines the window contains: the derived class must
provide the heights for all lines with indices up to the one given here
in its \helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight}.

View File

@@ -0,0 +1,173 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: vscrolledwindow.tex (moved from vscroll.tex)
%% Purpose: wxVScrolledWindow Documentation
%% Author: Vadim Zeitlin, Bryan Petty
%% Modified by:
%% Created: 2003-05-30, modified 2007-04-04
%% RCS-ID: $Id$
%% Copyright: (c) 2003, 2007 wxWidgets Team
%% License: wxWindows Licence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVScrolledWindow}}\label{wxvscrolledwindow}
In the name of this class, "V" may stand for "variable" because it can be
used for scrolling rows of variable heights; "virtual", because it is not
necessary to know the heights of all rows in advance -- only those which
are shown on the screen need to be measured; or even "vertical", because
this class only supports scrolling vertically.
In any case, this is a generalization of the
\helpref{wxScrolledWindow}{wxscrolledwindow} class which can be only used when
all rows have the same heights. It lacks some other wxScrolledWindow features
however, notably it can't scroll only a rectangle of the window and not its
entire client area.
To use this class, you need to derive from it and implement the
\helpref{OnGetRowHeight()}{wxvarvscrollhelperongetrowheight} pure virtual
method. You also must call \helpref{SetRowCount}{wxvarvscrollhelpersetrowcount}
to let the base class know how many rows it should display, but from that
moment on the scrolling is handled entirely by wxVScrolledWindow. You only
need to draw the visible part of contents in your {\tt OnPaint()} method as
usual. You should use \helpref{GetVisibleRowsBegin()}{wxvarvscrollhelpergetvisiblerowsbegin}
and \helpref{GetVisibleRowsEnd()}{wxvarvscrollhelpergetvisiblerowsend} to
select the lines to display. Note that the device context origin is not shifted
so the first visible row always appears at the point $(0, 0)$ in physical as
well as logical coordinates.
\wxheading{Derived from}
\helpref{wxPanel}{wxpanel}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\helpref{wxVarVScrollHelper}{wxvarvscrollhelper}\\
\helpref{wxVarScrollHelperBase}{wxvarscrollhelperbase}
\wxheading{Include files}
<wx/vscroll.h>
\wxheading{See also}
\helpref{wxHScrolledWindow}{wxhscrolledwindow},
\rtfsp\helpref{wxHVScrolledWindow}{wxhvscrolledwindow}
\latexignore{\rtfignore{\wxheading{Members}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% wxVarVScrollLegacyAdapter Compatibility Functions
%% This section will need to be removed when 2.8 compatibility is removed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxWidgets 2.6 and 2.8 Compatibility Functions}\label{wxvscrolledwindowbackwardcompatibility}
The following functions provide backwards compatibility for applications
originally built using wxVScrolledWindow in 2.6 or 2.8. Originally,
wxVScrolledWindow referred to scrolling "lines". We now use "units" in
wxVarScrollHelperBase to avoid implying any orientation (since the functions
are used for both horizontal and vertical scrolling in derived classes). And
in the new wxVScrolledWindow and wxHScrolledWindow classes, we refer to them
as "rows" and "columns", respectively. This is to help clear some confusion
in not only those classes, but also in wxHVScrolledWindow where functions
are inherited from both.
You are encouraged to update any existing code using these function to use
the new replacements mentioned below, and avoid using these functions for
any new code as they are deprecated.
\constfunc{size\_t}{GetFirstVisibleLine}{\void}
Deprecated for \helpref{GetVisibleRowsBegin()}{wxvarvscrollhelpergetvisiblerowsbegin}.
\constfunc{size\_t}{GetLastVisibleLine}{\void}
Deprecated for \helpref{GetVisibleRowsEnd()}{wxvarvscrollhelpergetvisiblerowsend}.
This function originally had a slight design flaw in that it was possible to
return \texttt{(size\_t)-1} (ie: a large positive number) if the scroll
position was 0 and the first line wasn't completely visible.
\constfunc{size\_t}{GetLineCount}{\void}
Deprecated for \helpref{GetRowCount()}{wxvarvscrollhelpergetrowcount}.
\constfunc{virtual wxCoord}{OnGetLineHeight}{\param{size\_t }{line}}
Deprecated for \helpref{OnGetRowHeight()}{wxvarvscrollhelperongetrowheight}.
\constfunc{virtual void}{OnGetLinesHint}{\param{size\_t }{lineMin}, \param{size\_t }{lineMax}}
Deprecated for \helpref{OnGetRowsHeightHint()}{wxvarvscrollhelperongetrowsheighthint}.
\func{virtual void}{RefreshLine}{\param{size\_t }{line}}
Deprecated for \helpref{RefreshRow()}{wxvarvscrollhelperrefreshrow}.
\func{virtual void}{RefreshLines}{\param{size\_t }{from}, \param{size\_t }{to}}
Deprecated for \helpref{RefreshRows()}{wxvarvscrollhelperrefreshrows}.
\func{virtual bool}{ScrollLines}{\param{int }{lines}}
Deprecated for \helpref{ScrollRows()}{wxvarvscrollhelperscrollrows}.
\func{virtual bool}{ScrollPages}{\param{int }{pages}}
Deprecated for \helpref{ScrollRowPages()}{wxvarvscrollhelperscrollrowpages}.
\func{bool}{ScrollToLine}{\param{size\_t }{line}}
Deprecated for \helpref{ScrollToRow()}{wxvarvscrollhelperscrolltorow}.
\func{void}{SetLineCount}{\param{size\_t }{count}}
Deprecated for \helpref{SetRowCount()}{wxvarvscrollhelpersetrowcount}.
%%%%%%%%%%%%%%%%%%%%%%% END COMPATIBILITY FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxVScrolledWindow::wxVScrolledWindow}\label{wxvscrolledwindowwxvscrolledwindow}
\func{}{wxVScrolledWindow}{\void}
Default constructor, you must call \helpref{Create()}{wxvscrolledwindowcreate}
later.
\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}}
This is the normal constructor, no need to call {\tt Create()} after using this one.
Note that {\tt wxVSCROLL} is always automatically added to our style, there is
no need to specify it explicitly.
\wxheading{Parameters}
\docparam{parent}{The parent window, must not be {\tt NULL}}
\docparam{id}{The identifier of this window, {\tt wxID\_ANY} by default}
\docparam{pos}{The initial window position}
\docparam{size}{The initial window size}
\docparam{style}{The window style. There are no special style bits defined for
this class.}
\docparam{name}{The name for this window; usually not used}
\membersection{wxVScrolledWindow::Create}\label{wxvscrolledwindowcreate}
\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}}
Same as the \helpref{non-default constuctor}{wxvscrolledwindowwxvscrolledwindow}
but returns status code: {\tt true} if ok, {\tt false} if the window couldn't
be created.
Just as with the constructor above, the {\tt wxVSCROLL} style is always used,
there is no need to specify it explicitly.

View File

@@ -305,8 +305,8 @@ protected:
// wxSimpleHtmlListBox shouldn't be allowed to call them directly! // wxSimpleHtmlListBox shouldn't be allowed to call them directly!
virtual void SetItemCount(size_t count) virtual void SetItemCount(size_t count)
{ wxHtmlListBox::SetItemCount(count); } { wxHtmlListBox::SetItemCount(count); }
virtual void SetLineCount(size_t count) virtual void SetRowCount(size_t count)
{ wxHtmlListBox::SetLineCount(count); } { wxHtmlListBox::SetRowCount(count); }
virtual wxString OnGetItem(size_t n) const virtual wxString OnGetItem(size_t n) const
{ return m_items[n]; } { return m_items[n]; }

View File

@@ -75,7 +75,7 @@ public:
// --------- // ---------
// get the number of items in the control // get the number of items in the control
size_t GetItemCount() const { return GetLineCount(); } size_t GetItemCount() const { return GetRowCount(); }
// does this control use multiple selection? // does this control use multiple selection?
bool HasMultipleSelection() const { return m_selStore != NULL; } bool HasMultipleSelection() const { return m_selStore != NULL; }
@@ -133,7 +133,7 @@ public:
// set the number of items to be shown in the control // set the number of items to be shown in the control
// //
// this is just a synonym for wxVScrolledWindow::SetLineCount() // this is just a synonym for wxVScrolledWindow::SetRowCount()
virtual void SetItemCount(size_t count); virtual void SetItemCount(size_t count);
// delete all items from the control // delete all items from the control

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
// Name: samples/vscroll/vstest.cpp // Name: samples/vscroll/vstest.cpp
// Purpose: VScroll wxWidgets sample // Purpose: VScroll wxWidgets sample
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by: Brad Anderson
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org> // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
@@ -44,12 +44,18 @@
#include "../sample.xpm" #include "../sample.xpm"
#endif #endif
// ----------------------------------------------------------------------------
// definitions
// ----------------------------------------------------------------------------
#define MAX_LINES 10000
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes // private classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Define a new application type, each program should derive a class from wxApp // Define a new application type, each program should derive a class from wxApp
class VScrollApp : public wxApp class VarScrollApp : public wxApp
{ {
public: public:
// create our main window // create our main window
@@ -57,14 +63,17 @@ public:
}; };
// Define a new frame type: this is going to be our main frame // Define a new frame type: this is going to be our main frame
class VScrollFrame : public wxFrame class VarScrollFrame : public wxFrame
{ {
public: public:
// ctor // ctor
VScrollFrame(); VarScrollFrame();
// event handlers (these functions should _not_ be virtual) // event handlers (these functions should _not_ be virtual)
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnModeVScroll(wxCommandEvent& event);
void OnModeHScroll(wxCommandEvent& event);
void OnModeHVScroll(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
void OnSize(wxSizeEvent& event) void OnSize(wxSizeEvent& event)
@@ -82,6 +91,9 @@ public:
} }
private: private:
// either a wxVScrolledWindow or a wxHVScrolled window, depending on current mode
wxPanel *m_scrollWindow;
// any class wishing to process wxWidgets events must use this macro // any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -93,7 +105,11 @@ public:
{ {
m_frame = frame; m_frame = frame;
SetLineCount(200); SetLineCount(MAX_LINES);
int i;
for ( i = 0; i < MAX_LINES; ++i )
m_heights[i] = rand()%25+16; // low: 16; high: 40
m_changed = true; m_changed = true;
} }
@@ -116,21 +132,23 @@ public:
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
dc.SetPen(*wxBLACK_DASHED_PEN); dc.SetPen(*wxBLACK_PEN);
const size_t lineFirst = GetFirstVisibleLine(), const size_t lineFirst = GetVisibleBegin(),
lineLast = GetLastVisibleLine(); lineLast = GetVisibleEnd();
const wxCoord hText = dc.GetCharHeight(); const wxCoord hText = dc.GetCharHeight();
wxSize clientSize = GetClientSize();
wxCoord y = 0; wxCoord y = 0;
for ( size_t line = lineFirst; line <= lineLast; line++ ) for ( size_t line = lineFirst; line < lineLast; line++ )
{ {
dc.DrawLine(0, y, 1000, y); dc.DrawLine(0, y, clientSize.GetWidth(), y);
wxCoord hLine = OnGetLineHeight(line); wxCoord hLine = OnGetLineHeight(line);
dc.DrawText(wxString::Format(_T("Line %lu"), (unsigned long)line), dc.DrawText(wxString::Format(_T("Line %lu"), (unsigned long)line),
0, y + (hLine - hText) / 2); 2, y + (hLine - hText) / 2);
y += hLine; y += hLine;
dc.DrawLine(0, y, 1000, y); dc.DrawLine(0, y, 1000, y);
@@ -144,17 +162,27 @@ public:
event.Skip(); event.Skip();
} }
void OnMouse(wxMouseEvent& event)
{
if(event.LeftDown())
CaptureMouse();
else if(event.LeftUp())
ReleaseMouse();
event.Skip();
}
virtual wxCoord OnGetLineHeight(size_t n) const virtual wxCoord OnGetLineHeight(size_t n) const
{ {
wxASSERT( n < GetLineCount() ); wxASSERT( n < GetLineCount() );
return n % 2 ? 15 : 30; // 15 + 2*n return m_heights[n];
} }
private: private:
wxFrame *m_frame; wxFrame *m_frame;
int m_heights[MAX_LINES];
bool m_changed; bool m_changed;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@@ -164,6 +192,233 @@ BEGIN_EVENT_TABLE(VScrollWindow, wxVScrolledWindow)
EVT_IDLE(VScrollWindow::OnIdle) EVT_IDLE(VScrollWindow::OnIdle)
EVT_PAINT(VScrollWindow::OnPaint) EVT_PAINT(VScrollWindow::OnPaint)
EVT_SCROLLWIN(VScrollWindow::OnScroll) EVT_SCROLLWIN(VScrollWindow::OnScroll)
EVT_MOUSE_EVENTS(VScrollWindow::OnMouse)
END_EVENT_TABLE()
class HScrollWindow : public wxHScrolledWindow
{
public:
HScrollWindow(wxFrame *frame) : wxHScrolledWindow(frame, wxID_ANY)
{
m_frame = frame;
SetColumnCount(MAX_LINES);
int i;
for ( i = 0; i < MAX_LINES; ++i )
m_heights[i] = rand()%25+16; // low: 15; high: 40
m_changed = true;
}
void OnIdle(wxIdleEvent&)
{
#if wxUSE_STATUSBAR
m_frame->SetStatusText(wxString::Format
(
_T("Page size = %d, pos = %d, max = %d"),
GetScrollThumb(wxVERTICAL),
GetScrollPos(wxVERTICAL),
GetScrollRange(wxVERTICAL)
));
#endif // wxUSE_STATUSBAR
m_changed = false;
}
void OnPaint(wxPaintEvent&)
{
wxPaintDC dc(this);
dc.SetPen(*wxBLACK_PEN);
const size_t lineFirst = GetVisibleBegin(),
lineLast = GetVisibleEnd();
const wxCoord hText = dc.GetCharHeight();
wxSize clientSize = GetClientSize();
wxCoord x = 0;
for ( size_t line = lineFirst; line < lineLast; line++ )
{
dc.DrawLine(x, 0, x, clientSize.GetHeight());
wxCoord wLine = OnGetColumnWidth(line);
dc.DrawRotatedText(wxString::Format(_T("Line %lu"), (unsigned long)line),
x + (wLine - hText) / 2, clientSize.GetHeight() - 5, 90);
x += wLine;
dc.DrawLine(x, 0, x, 1000);
}
}
void OnScroll(wxScrollWinEvent& event)
{
m_changed = true;
event.Skip();
}
void OnMouse(wxMouseEvent& event)
{
if(event.LeftDown())
CaptureMouse();
else if(event.LeftUp())
ReleaseMouse();
event.Skip();
}
virtual wxCoord OnGetColumnWidth(size_t n) const
{
wxASSERT( n < GetColumnCount() );
return m_heights[n];
}
private:
wxFrame *m_frame;
int m_heights[MAX_LINES];
bool m_changed;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(HScrollWindow, wxHScrolledWindow)
EVT_IDLE(HScrollWindow::OnIdle)
EVT_PAINT(HScrollWindow::OnPaint)
EVT_SCROLLWIN(HScrollWindow::OnScroll)
EVT_MOUSE_EVENTS(HScrollWindow::OnMouse)
END_EVENT_TABLE()
class HVScrollWindow : public wxHVScrolledWindow
{
public:
HVScrollWindow(wxFrame *frame) : wxHVScrolledWindow(frame, wxID_ANY)
{
m_frame = frame;
SetRowColumnCount(MAX_LINES, MAX_LINES);
int i;
for ( i = 0; i < MAX_LINES; ++i )
{
m_heights[i] = rand()%30+31; // low: 30; high: 60
m_widths[i] = rand()%30+61; // low: 60; high: 90
}
m_changed = true;
}
void OnIdle(wxIdleEvent&)
{
#if wxUSE_STATUSBAR
m_frame->SetStatusText(wxString::Format
(
_T("Page size = %d rows %d columns; pos = row: %d, column: %d; max = %d rows, %d columns"),
GetScrollThumb(wxVERTICAL),
GetScrollThumb(wxHORIZONTAL),
GetScrollPos(wxVERTICAL),
GetScrollPos(wxHORIZONTAL),
GetScrollRange(wxVERTICAL),
GetScrollRange(wxHORIZONTAL)
));
#endif // wxUSE_STATUSBAR
m_changed = false;
}
void OnPaint(wxPaintEvent&)
{
wxPaintDC dc(this);
dc.SetPen(*wxBLACK_PEN);
const size_t rowFirst = GetVisibleRowsBegin(),
rowLast = GetVisibleRowsEnd();
const size_t columnFirst = GetVisibleColumnsBegin(),
columnLast = GetVisibleColumnsEnd();
const wxCoord hText = dc.GetCharHeight();
wxSize clientSize = GetClientSize();
wxCoord y = 0;
wxCoord x = 0;
for ( size_t row = rowFirst; row < rowLast; row++ )
{
wxCoord rowHeight = OnGetRowHeight(row);
dc.DrawLine(0, y, clientSize.GetWidth(), y);
x = 0;
for ( size_t col = columnFirst; col < columnLast; col++ )
{
wxCoord colWidth = OnGetColumnWidth(col);
if ( row == rowFirst )
dc.DrawLine(x, 0, x, clientSize.GetHeight());
dc.DrawText(wxString::Format(_T("Row %lu"), (unsigned long)row),
x + 2, y + rowHeight / 2 - hText);
dc.DrawText(wxString::Format(_T("Col %lu"), (unsigned long)col),
x + 2, y + rowHeight / 2);
x += colWidth;
if ( row == rowFirst)
dc.DrawLine(x, 0, x, clientSize.GetHeight());
}
y += rowHeight;
dc.DrawLine(0, y, clientSize.GetWidth(), y);
}
}
void OnScroll(wxScrollWinEvent& event)
{
m_changed = true;
event.Skip();
}
void OnMouse(wxMouseEvent& event)
{
if(event.LeftDown())
CaptureMouse();
else if(event.LeftUp())
ReleaseMouse();
event.Skip();
}
virtual wxCoord OnGetRowHeight(size_t n) const
{
wxASSERT( n < GetRowCount() );
return m_heights[n];
}
virtual wxCoord OnGetColumnWidth(size_t n) const
{
wxASSERT( n < GetColumnCount() );
return m_widths[n];
}
private:
wxFrame *m_frame;
int m_heights[MAX_LINES];
int m_widths[MAX_LINES];
bool m_changed;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(HVScrollWindow, wxHVScrolledWindow)
EVT_IDLE(HVScrollWindow::OnIdle)
EVT_PAINT(HVScrollWindow::OnPaint)
EVT_SCROLLWIN(HVScrollWindow::OnScroll)
EVT_MOUSE_EVENTS(HVScrollWindow::OnMouse)
END_EVENT_TABLE() END_EVENT_TABLE()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -179,7 +434,11 @@ enum
// it is important for the id corresponding to the "About" command to have // it is important for the id corresponding to the "About" command to have
// this standard value as otherwise it won't be handled properly under Mac // this standard value as otherwise it won't be handled properly under Mac
// (where it is special and put into the "Apple" menu) // (where it is special and put into the "Apple" menu)
VScroll_About = wxID_ABOUT VScroll_About = wxID_ABOUT,
VScroll_VScrollMode = wxID_HIGHEST + 1,
VScroll_HScrollMode,
VScroll_HVScrollMode
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -189,18 +448,21 @@ enum
// the event tables connect the wxWidgets events with the functions (event // the event tables connect the wxWidgets events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the // handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler. // simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(VScrollFrame, wxFrame) BEGIN_EVENT_TABLE(VarScrollFrame, wxFrame)
EVT_MENU(VScroll_Quit, VScrollFrame::OnQuit) EVT_MENU(VScroll_Quit, VarScrollFrame::OnQuit)
EVT_MENU(VScroll_About, VScrollFrame::OnAbout) EVT_MENU(VScroll_VScrollMode, VarScrollFrame::OnModeVScroll)
EVT_SIZE(VScrollFrame::OnSize) EVT_MENU(VScroll_HScrollMode, VarScrollFrame::OnModeHScroll)
EVT_MENU(VScroll_HVScrollMode, VarScrollFrame::OnModeHVScroll)
EVT_MENU(VScroll_About, VarScrollFrame::OnAbout)
EVT_SIZE(VarScrollFrame::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWidgets to create // Create a new application object: this macro will allow wxWidgets to create
// the application object during program execution (it's better than using a // the application object during program execution (it's better than using a
// static object for many reasons) and also declares the accessor function // static object for many reasons) and also declares the accessor function
// wxGetApp() which will return the reference of the right type (i.e. VScrollApp and // wxGetApp() which will return the reference of the right type (i.e. VarScrollApp and
// not wxApp) // not wxApp)
IMPLEMENT_APP(VScrollApp) IMPLEMENT_APP(VarScrollApp)
// ============================================================================ // ============================================================================
// implementation // implementation
@@ -211,13 +473,13 @@ IMPLEMENT_APP(VScrollApp)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// 'Main program' equivalent: the program execution "starts" here // 'Main program' equivalent: the program execution "starts" here
bool VScrollApp::OnInit() bool VarScrollApp::OnInit()
{ {
if ( !wxApp::OnInit() ) if ( !wxApp::OnInit() )
return false; return false;
// create the main application window // create the main application window
VScrollFrame *frame = new VScrollFrame; VarScrollFrame *frame = new VarScrollFrame;
// and show it (the frames, unlike simple controls, are not shown when // and show it (the frames, unlike simple controls, are not shown when
// created initially) // created initially)
@@ -232,12 +494,13 @@ bool VScrollApp::OnInit()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// frame constructor // frame constructor
VScrollFrame::VScrollFrame() VarScrollFrame::VarScrollFrame()
: wxFrame(NULL, : wxFrame(NULL,
wxID_ANY, wxID_ANY,
_T("VScroll wxWidgets Sample"), _T("VScroll wxWidgets Sample"),
wxDefaultPosition, wxDefaultPosition,
wxSize(400, 350)) wxSize(400, 350)),
m_scrollWindow(NULL)
{ {
// set the frame icon // set the frame icon
SetIcon(wxICON(sample)); SetIcon(wxICON(sample));
@@ -246,15 +509,36 @@ VScrollFrame::VScrollFrame()
// create a menu bar // create a menu bar
wxMenu *menuFile = new wxMenu; wxMenu *menuFile = new wxMenu;
wxMenu *menuMode = new wxMenu;
// the "About" item should be in the help menu // the "About" item should be in the help menu
wxMenu *menuHelp = new wxMenu; wxMenu *menuHelp = new wxMenu;
menuHelp->Append(VScroll_About, _T("&About...\tF1"), _T("Show about dialog")); menuHelp->Append(VScroll_About, _T("&About...\tF1"), _T("Show about dialog"));
#ifdef wxHAS_RADIO_MENU_ITEMS
menuMode->AppendRadioItem(VScroll_VScrollMode, _T("&Vertical\tAlt-V"),
_T("Vertical scrolling only"));
menuMode->AppendRadioItem(VScroll_HScrollMode, _T("&Horizontal\tAlt-H"),
_T("Horizontal scrolling only"));
menuMode->AppendRadioItem(VScroll_HVScrollMode,
_T("Hori&zontal/Vertical\tAlt-Z"),
_T("Horizontal and vertical scrolling"));
menuMode->Check(VScroll_VScrollMode, true);
#else
menuMode->Append(VScroll_VScrollMode, _T("&Vertical\tAlt-V"),
_T("Vertical scrolling only"));
menuMode->Append(VScroll_HScrollMode, _T("&Horizontal\tAlt-H"),
_T("Horizontal scrolling only"));
menuMode->Append(VScroll_HVScrollMode, _T("Hori&zontal/Vertical\tAlt-Z"),
_T("Horizontal and vertical scrolling"));
#endif
menuFile->Append(VScroll_Quit, _T("E&xit\tAlt-X"), _T("Quit this program")); menuFile->Append(VScroll_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
// now append the freshly created menu to the menu bar... // now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar; wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, _T("&File")); menuBar->Append(menuFile, _T("&File"));
menuBar->Append(menuMode, _T("&Mode"));
menuBar->Append(menuHelp, _T("&Help")); menuBar->Append(menuHelp, _T("&Help"));
// ... and attach this menu bar to the frame // ... and attach this menu bar to the frame
@@ -265,26 +549,62 @@ VScrollFrame::VScrollFrame()
// create a status bar just for fun (by default with 1 pane only) // create a status bar just for fun (by default with 1 pane only)
CreateStatusBar(2); CreateStatusBar(2);
SetStatusText(_T("Welcome to wxWidgets!")); SetStatusText(_T("Welcome to wxWidgets!"));
int widths[2];
widths[0] = -1;
widths[1] = 100;
SetStatusWidths(2, widths);
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
// create our one and only child -- it will take our entire client area // create our one and only child -- it will take our entire client area
new VScrollWindow(this); if ( menuMode->IsChecked(VScroll_VScrollMode) )
m_scrollWindow = new VScrollWindow(this);
else if ( menuMode->IsChecked(VScroll_HScrollMode) )
m_scrollWindow = new HScrollWindow(this);
else
m_scrollWindow = new HVScrollWindow(this);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event handlers // event handlers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void VScrollFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void VarScrollFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{ {
// true is to force the frame to close // true is to force the frame to close
Close(true); Close(true);
} }
void VScrollFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) void VarScrollFrame::OnModeVScroll(wxCommandEvent& WXUNUSED(event))
{
if ( m_scrollWindow )
m_scrollWindow->Destroy();
m_scrollWindow = new VScrollWindow(this);
SendSizeEvent();
}
void VarScrollFrame::OnModeHScroll(wxCommandEvent& WXUNUSED(event))
{
if ( m_scrollWindow )
m_scrollWindow->Destroy();
m_scrollWindow = new HScrollWindow(this);
SendSizeEvent();
}
void VarScrollFrame::OnModeHVScroll(wxCommandEvent& WXUNUSED(event))
{
if ( m_scrollWindow )
m_scrollWindow->Destroy();
m_scrollWindow = new HVScrollWindow(this);
SendSizeEvent();
}
void VarScrollFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{ {
wxMessageBox(_T("VScroll shows how to implement scrolling with\n") wxMessageBox(_T("VScroll shows how to implement scrolling with\n")
_T("variable line heights.\n") _T("variable line widths and heights.\n")
_T("(c) 2003 Vadim Zeitlin"), _T("(c) 2003 Vadim Zeitlin"),
_T("About VScroll"), _T("About VScroll"),
wxOK | wxICON_INFORMATION, wxOK | wxICON_INFORMATION,

View File

@@ -327,14 +327,14 @@ void wxHtmlListBox::RefreshLine(size_t line)
{ {
m_cache->InvalidateRange(line, line); m_cache->InvalidateRange(line, line);
wxVListBox::RefreshLine(line); wxVListBox::RefreshRow(line);
} }
void wxHtmlListBox::RefreshLines(size_t from, size_t to) void wxHtmlListBox::RefreshLines(size_t from, size_t to)
{ {
m_cache->InvalidateRange(from, to); m_cache->InvalidateRange(from, to);
wxVListBox::RefreshLines(from, to); wxVListBox::RefreshRows(from, to);
} }
void wxHtmlListBox::RefreshAll() void wxHtmlListBox::RefreshAll()

View File

@@ -111,7 +111,7 @@ void wxVListBox::SetItemCount(size_t count)
m_selStore->SetItemCount(count); m_selStore->SetItemCount(count);
} }
SetLineCount(count); SetRowCount(count);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -312,7 +312,7 @@ void wxVListBox::RefreshSelected()
for ( size_t n = GetVisibleBegin(), end = GetVisibleEnd(); n < end; n++ ) for ( size_t n = GetVisibleBegin(), end = GetVisibleEnd(); n < end; n++ )
{ {
if ( IsSelected(n) ) if ( IsSelected(n) )
RefreshLine(n); RefreshRow(n);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -622,7 +622,7 @@ void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent& WXUNUSED(event)
{ {
if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower()) if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower())
{ {
m_faceListBox->ScrollToLine(i); m_faceListBox->ScrollToRow(i);
break; break;
} }
} }

View File

@@ -832,7 +832,7 @@ bool wxSymbolListCtrl::DoSetCurrent(int current)
} }
if ( m_current != wxNOT_FOUND ) if ( m_current != wxNOT_FOUND )
RefreshLine(SymbolValueToLineNumber(m_current)); RefreshRow(SymbolValueToLineNumber(m_current));
m_current = current; m_current = current;
@@ -844,19 +844,19 @@ bool wxSymbolListCtrl::DoSetCurrent(int current)
// don't need to refresh it -- it will be redrawn anyhow // don't need to refresh it -- it will be redrawn anyhow
if ( !IsVisible(lineNo) ) if ( !IsVisible(lineNo) )
{ {
ScrollToLine(lineNo); ScrollToRow(lineNo);
} }
else // line is at least partly visible else // line is at least partly visible
{ {
// it is, indeed, only partly visible, so scroll it into view to // it is, indeed, only partly visible, so scroll it into view to
// make it entirely visible // make it entirely visible
while ( unsigned(lineNo) == GetLastVisibleLine() && while ( unsigned(lineNo) == GetLastVisibleLine() &&
ScrollToLine(GetVisibleBegin()+1) ) ScrollToRow(GetVisibleBegin()+1) )
; ;
// but in any case refresh it as even if it was only partly visible // but in any case refresh it as even if it was only partly visible
// before we need to redraw it entirely as its background changed // before we need to redraw it entirely as its background changed
RefreshLine(lineNo); RefreshRow(lineNo);
} }
} }
@@ -1200,12 +1200,12 @@ void wxSymbolListCtrl::SetupCtrl(bool scrollToSelection)
m_symbolsPerLine = sz.x/(m_cellSize.x+m_ptMargins.x); m_symbolsPerLine = sz.x/(m_cellSize.x+m_ptMargins.x);
int noLines = (1 + SymbolValueToLineNumber(m_maxSymbolValue)); int noLines = (1 + SymbolValueToLineNumber(m_maxSymbolValue));
SetLineCount(noLines); SetRowCount(noLines);
Refresh(); Refresh();
if (scrollToSelection && m_current != wxNOT_FOUND && m_current >= m_minSymbolValue && m_current <= m_maxSymbolValue) if (scrollToSelection && m_current != wxNOT_FOUND && m_current >= m_minSymbolValue && m_current <= m_maxSymbolValue)
{ {
ScrollToLine(SymbolValueToLineNumber(m_current)); ScrollToRow(SymbolValueToLineNumber(m_current));
} }
} }
@@ -1214,7 +1214,7 @@ void wxSymbolListCtrl::EnsureVisible(int item)
{ {
if (item != wxNOT_FOUND && item >= m_minSymbolValue && item <= m_maxSymbolValue) if (item != wxNOT_FOUND && item >= m_minSymbolValue && item <= m_maxSymbolValue)
{ {
ScrollToLine(SymbolValueToLineNumber(item)); ScrollToRow(SymbolValueToLineNumber(item));
} }
} }