X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/50a1f2615497fd70659614559e62d0b70ac46a70..65baafba0e8cd74f2264b7e2f7625ff5bea84864:/docs/latex/wx/scrolwin.tex diff --git a/docs/latex/wx/scrolwin.tex b/docs/latex/wx/scrolwin.tex index 8224091442..dd1273f9ce 100644 --- a/docs/latex/wx/scrolwin.tex +++ b/docs/latex/wx/scrolwin.tex @@ -4,19 +4,60 @@ The wxScrolledWindow class manages scrolling for its client area, transforming the coordinates according to the scrollbar positions, and setting the scroll positions, thumb sizes and ranges according to the area in view. -As with all windows, an application can draw onto a wxScrolledWindow using a \helpref{device context}{dcoverview}. +Starting from version 2.4 of wxWidgets, there are several ways to use a +wxScrolledWindow. In particular, there are now three ways to set the +size of the scrolling area: + +One way is to set the scrollbars directly using a call to +\helpref{wxScrolledWindow::SetScrollbars}{wxscrolledwindowsetscrollbars}. +This is the way it used to be in any previous version of wxWidgets +and it will be kept for backwards compatibility. + +An additional method of manual control, which requires a little less +computation of your own, is to set the total size of the scrolling area by +calling either \helpref{wxWindow::SetVirtualSize}{wxwindowsetvirtualsize}, +or \helpref{wxWindow::FitInside}{wxwindowfitinside}, and setting the +scrolling increments for it by calling +\helpref{wxScrolledWindow::SetScrollRate}{wxscrolledwindowsetscrollrate}. +Scrolling in some orientation is enabled by setting a non zero increment +for it. + +The most automatic and newest way is to simply let sizers determine the +scrolling area. This is now the default when you set an interior sizer +into a wxScrolledWindow with \helpref{wxWindow::SetSizer}{wxwindowsetsizer}. +The scrolling area will be set to the size requested by the sizer and +the scrollbars will be assigned for each orientation according to the need +for them and the scrolling increment set by +\helpref{wxScrolledWindow::SetScrollRate}{wxscrolledwindowsetscrollrate}. +As above, scrolling is only enabled in orientations with a non-zero +increment. You can influence the minimum size of the scrolled area +controlled by a sizer by calling +\helpref{wxWindow::SetVirtualSizeHints}{wxwindowsetvirtualsizehints}. +(calling \helpref{wxScrolledWindow::SetScrollbars}{wxscrolledwindowsetscrollbars} + has analogous effects in wxWidgets 2.4 -- in later versions it may not continue + to override the sizer) + +Note: if Maximum size hints are still supported by SetVirtualSizeHints, use +them at your own dire risk. They may or may not have been removed for 2.4, +but it really only makes sense to set minimum size hints here. We should +probably replace SetVirtualSizeHints with SetMinVirtualSize or similar +and remove it entirely in future. + +As with all windows, an application can draw onto a wxScrolledWindow using +a \helpref{device context}{dcoverview}. You have the option of handling the OnPaint handler -or overriding the \helpref{OnDraw}{wxscrolledwindowondraw} function, which is passed -a pre-scrolled device context (prepared by \helpref{PrepareDC}{wxscrolledwindowpreparedc}). +or overriding the \helpref{OnDraw}{wxscrolledwindowondraw} function, which is +passed a pre-scrolled device context (prepared by +\helpref{DoPrepareDC}{wxscrolledwindowdopreparedc}). -If you don't wish to calculate your own scrolling, you must call PrepareDC when not drawing from +If you don't wish to calculate your own scrolling, you must call DoPrepareDC when not drawing from within OnDraw, to set the device origin for the device context according to the current scroll position. A wxScrolledWindow will normally scroll itself and therefore its child windows as well. It might however be desired to scroll a different window than itself: e.g. when designing a -spreadsheet, you'll normally only have to scroll the (usually white) cell area, whereas the +spreadsheet, you will normally only have to scroll the (usually white) cell area, whereas the (usually grey) label area will scroll very differently. For this special purpose, you can call \helpref{SetTargetWindow}{wxscrolledwindowsettargetwindow} which means that pressing the scrollbars will scroll a different window. @@ -57,11 +98,13 @@ to build your own scroll behaviour. \wxheading{See also} -\helpref{wxScrollBar}{wxscrollbar}, \helpref{wxClientDC}{wxclientdc}, \helpref{wxPaintDC}{wxpaintdc} +\helpref{wxScrollBar}{wxscrollbar}, \helpref{wxClientDC}{wxclientdc},\\ +\helpref{wxPaintDC}{wxpaintdc}, \helpref{wxVScrolledWindow}{wxvscrolledwindow} \latexignore{\rtfignore{\wxheading{Members}}} -\membersection{wxScrolledWindow::wxScrolledWindow}\label{wxscrolledwindowconstr} + +\membersection{wxScrolledWindow::wxScrolledWindow}\label{wxscrolledwindowctor} \func{}{wxScrolledWindow}{\void} @@ -95,12 +138,14 @@ The window is initially created without visible scrollbars. Call \helpref{wxScrolledWindow::SetScrollbars}{wxscrolledwindowsetscrollbars} to specify how big the virtual window size should be. -\membersection{wxScrolledWindow::\destruct{wxScrolledWindow}} + +\membersection{wxScrolledWindow::\destruct{wxScrolledWindow}}\label{wxscrolledwindowdtor} \func{}{\destruct{wxScrolledWindow}}{\void} Destructor. + \membersection{wxScrolledWindow::CalcScrolledPosition}\label{wxscrolledwindowcalcscrolledposition} \constfunc{void}{CalcScrolledPosition}{ @@ -112,7 +157,7 @@ Destructor. Translates the logical coordinates to the device ones. For example, if a window is scrolled 10 pixels to the bottom, the device coordinates of the origin are (0, 0) (as always), but the logical coordinates are (0, 10) and so the call to -CalcScrolledPosition(0, 0, \&xx, \&yy) will return 10 in yy. +CalcScrolledPosition(0, 10, \&xx, \&yy) will return 0 in yy. \wxheading{See also} @@ -121,6 +166,10 @@ CalcScrolledPosition(0, 0, \&xx, \&yy) will return 10 in yy. \pythonnote{The wxPython version of this methods accepts only two parameters and returns xx and yy as a tuple of values.} +\perlnote{In wxPerl this method takes two parameters and returns a +2-element list {\tt ( xx, yy )}.} + + \membersection{wxScrolledWindow::CalcUnscrolledPosition}\label{wxscrolledwindowcalcunscrolledposition} \constfunc{void}{CalcUnscrolledPosition}{ @@ -132,7 +181,7 @@ parameters and returns xx and yy as a tuple of values.} Translates the device coordinates to the logical ones. For example, if a window is scrolled 10 pixels to the bottom, the device coordinates of the origin are (0, 0) (as always), but the logical coordinates are (0, 10) and so the call to -CalcUnscrolledPosition(0, 10, \&xx, \&yy) will return 0 in yy. +CalcUnscrolledPosition(0, 0, \&xx, \&yy) will return 10 in yy. \wxheading{See also} @@ -141,6 +190,10 @@ CalcUnscrolledPosition(0, 10, \&xx, \&yy) will return 0 in yy. \pythonnote{The wxPython version of this methods accepts only two parameters and returns xx and yy as a tuple of values.} +\perlnote{In wxPerl this method takes two parameters and returns a +2-element list {\tt ( xx, yy )}.} + + \membersection{wxScrolledWindow::Create}\label{wxscrolledwindowcreate} \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id = -1},\rtfsp @@ -148,9 +201,10 @@ parameters and returns xx and yy as a tuple of values.} \param{long}{ style = wxHSCROLL \pipe wxVSCROLL}, \param{const wxString\& }{name = ``scrolledWindow"}} Creates the window for two-step construction. Derived classes -should call or replace this function. See \helpref{wxScrolledWindow::wxScrolledWindow}{wxscrolledwindowconstr}\rtfsp +should call or replace this function. See \helpref{wxScrolledWindow::wxScrolledWindow}{wxscrolledwindowctor}\rtfsp for details. + \membersection{wxScrolledWindow::EnableScrolling}\label{wxscrolledwindowenablescrolling} \func{void}{EnableScrolling}{\param{const bool}{ xScrolling}, \param{const bool}{ yScrolling}} @@ -165,15 +219,16 @@ is disabled. \wxheading{Parameters} -\docparam{xScrolling}{If TRUE, enables physical scrolling in the x direction.} +\docparam{xScrolling}{If true, enables physical scrolling in the x direction.} -\docparam{yScrolling}{If TRUE, enables physical scrolling in the y direction.} +\docparam{yScrolling}{If true, enables physical scrolling in the y direction.} \wxheading{Remarks} Physical scrolling may not be available on all platforms. Where it is available, it is enabled by default. + \membersection{wxScrolledWindow::GetScrollPixelsPerUnit}\label{wxscrolledwindowgetscrollpixelsperunit} \constfunc{void}{GetScrollPixelsPerUnit}{\param{int* }{xUnit}, \param{int* }{yUnit}} @@ -196,6 +251,41 @@ scrolling in that direction. \pythonnote{The wxPython version of this methods accepts no parameters and returns a tuple of values for xUnit and yUnit.} +\perlnote{In wxPerl this method takes no parameters and returns a +2-element list {\tt ( xUnit, yUnit )}.} + + +\membersection{wxScrolledWindow::GetViewStart}\label{wxscrolledwindowgetviewstart} + +\constfunc{void}{GetViewStart}{\param{int* }{x}, \param{int* }{ y}} + +Get the position at which the visible portion of the window starts. + +\wxheading{Parameters} + +\docparam{x}{Receives the first visible x position in scroll units.} + +\docparam{y}{Receives the first visible y position in scroll units.} + +\wxheading{Remarks} + +If either of the scrollbars is not at the home position, {\it x} and/or +\rtfsp{\it y} will be greater than zero. Combined with \helpref{wxWindow::GetClientSize}{wxwindowgetclientsize}, +the application can use this function to efficiently redraw only the +visible portion of the window. The positions are in logical scroll +units, not pixels, so to convert to pixels you will have to multiply +by the number of pixels per scroll increment. + +\wxheading{See also} + +\helpref{wxScrolledWindow::SetScrollbars}{wxscrolledwindowsetscrollbars} + +\pythonnote{The wxPython version of this methods accepts no +parameters and returns a tuple of values for x and y.} + +\perlnote{In wxPerl this method takes no parameters and returns a +2-element list {\tt ( x, y )}.} + \membersection{wxScrolledWindow::GetVirtualSize}\label{wxscrolledwindowgetvirtualsize} @@ -224,20 +314,25 @@ to translate these units to logical units. \pythonnote{The wxPython version of this methods accepts no parameters and returns a tuple of values for x and y.} +\perlnote{In wxPerl this method takes no parameters and returns a +2-element list {\tt ( x, y )}.} + + \membersection{wxScrolledWindow::IsRetained}\label{wxscrolledwindowisretained} \constfunc{bool}{IsRetained}{\void} -Motif only: TRUE if the window has a backing bitmap. +Motif only: true if the window has a backing bitmap. -\membersection{wxScrolledWindow::PrepareDC}\label{wxscrolledwindowpreparedc} -\func{void}{PrepareDC}{\param{wxDC\& }{dc}} +\membersection{wxScrolledWindow::DoPrepareDC}\label{wxscrolledwindowdopreparedc} + +\func{void}{DoPrepareDC}{\param{wxDC\& }{dc}} Call this function to prepare the device context for drawing a scrolled image. It sets the device origin according to the current scroll position. -PrepareDC is called automatically within the default wxScrolledWindow::OnPaint event +DoPrepareDC is called automatically within the default wxScrolledWindow::OnPaint event handler, so your \helpref{wxScrolledWindow::OnDraw}{wxscrolledwindowondraw} override will be passed a 'pre-scrolled' device context. However, if you wish to draw from outside of OnDraw (via OnPaint), or you wish to implement OnPaint yourself, you must @@ -247,7 +342,7 @@ call this function yourself. For example: void MyWindow::OnEvent(wxMouseEvent& event) { wxClientDC dc(this); - PrepareDC(dc); + DoPrepareDC(dc); dc.SetPen(*wxBLACK_PEN); float x, y; @@ -261,18 +356,30 @@ void MyWindow::OnEvent(wxMouseEvent& event) } \end{verbatim} + \membersection{wxScrolledWindow::OnDraw}\label{wxscrolledwindowondraw} \func{virtual void}{OnDraw}{\param{wxDC\& }{dc}} Called by the default paint event handler to allow the application to define -painting behaviour without having to worry about calling -\helpref{wxScrolledWindow::PrepareDC}{wxscrolledwindowpreparedc}. +painting behaviour without having to worry about calling +\helpref{wxScrolledWindow::DoPrepareDC}{wxscrolledwindowdopreparedc}. Instead of overriding this function you may also just process the paint event -in the derived class as usual, but then you will have to call PrepareDC() +in the derived class as usual, but then you will have to call DoPrepareDC() yourself. + +\membersection{wxScrolledWindow::PrepareDC}\label{wxscrolledwindowpreparedc} + +\func{void}{PrepareDC}{\param{wxDC\& }{dc}} + +This function is for backwards compatibility only and simply calls +\helpref{DoPrepareDC}{wxscrolledwindowdopreparedc} now. Notice that it is +\emph{not} called by the default paint event handle (DoPrepareDC() is), so +overriding this method in your derived class is useless. + + \membersection{wxScrolledWindow::Scroll}\label{wxscrolledwindowscroll} \func{void}{Scroll}{\param{int}{ x}, \param{int}{ y}} @@ -297,12 +404,13 @@ that direction). \helpref{wxScrolledWindow::SetScrollbars}{wxscrolledwindowsetscrollbars},\rtfsp \helpref{wxScrolledWindow::GetScrollPixelsPerUnit}{wxscrolledwindowgetscrollpixelsperunit} + \membersection{wxScrolledWindow::SetScrollbars}\label{wxscrolledwindowsetscrollbars} \func{void}{SetScrollbars}{\param{int}{ pixelsPerUnitX}, \param{int}{ pixelsPerUnitY},\rtfsp \param{int}{ noUnitsX}, \param{int}{ noUnitsY},\rtfsp \param{int }{xPos = 0}, \param{int}{ yPos = 0},\rtfsp -\param{bool }{noRefresh = FALSE}} +\param{bool }{noRefresh = false}} Sets up vertical and/or horizontal scrollbars. @@ -320,7 +428,7 @@ Sets up vertical and/or horizontal scrollbars. \docparam{yPos}{Position to initialize the scrollbars in the vertical direction, in scroll units.} -\docparam{noRefresh}{Will not refresh window if TRUE.} +\docparam{noRefresh}{Will not refresh window if true.} \wxheading{Remarks} @@ -347,38 +455,23 @@ scroll steps may be variable according to the position in the document, it will necessary to derive a new class from wxWindow, overriding {\bf OnSize} and adjusting the scrollbars appropriately. -\membersection{wxScrolledWindow::SetTargetWindow}\label{wxscrolledwindowsettargetwindow} - -\func{void}{SetTargetWindow}{\param{wxWindow* }{window}} - -Call this function to tell wxScrolledWindow to perform the actually scrolling on -a different window (not on itself). - -\membersection{wxScrolledWindow::GetViewStart}\label{wxscrolledwindowgetviewstart} - -\constfunc{void}{GetViewStart}{\param{int* }{x}, \param{int* }{ y}} +\wxheading{See also} -Get the position at which the visible portion of the window starts. +\helpref{wxWindow::SetVirtualSize}{wxwindowsetvirtualsize} -\wxheading{Parameters} -\docparam{x}{Receives the first visible x position in scroll units.} +\membersection{wxScrolledWindow::SetScrollRate}\label{wxscrolledwindowsetscrollrate} -\docparam{y}{Receives the first visible y position in scroll units.} +\func{void}{SetScrollRate}{\param{int}{ xstep}, \param{int}{ ystep}} -\wxheading{Remarks} +Set the horizontal and vertical scrolling increment only. See the pixelsPerUnit +parameter in SetScrollbars. -If either of the scrollbars is not at the home position, {\it x} and/or -\rtfsp{\it y} will be greater than zero. Combined with \helpref{wxWindow::GetClientSize}{wxwindowgetclientsize}, -the application can use this function to efficiently redraw only the -visible portion of the window. The positions are in logical scroll -units, not pixels, so to convert to pixels you will have to multiply -by the number of pixels per scroll increment. -\wxheading{See also} +\membersection{wxScrolledWindow::SetTargetWindow}\label{wxscrolledwindowsettargetwindow} -\helpref{wxScrolledWindow::SetScrollbars}{wxscrolledwindowsetscrollbars} +\func{void}{SetTargetWindow}{\param{wxWindow* }{window}} -\pythonnote{The wxPython version of this methods accepts no -parameters and returns a tuple of values for x and y.} +Call this function to tell wxScrolledWindow to perform the actual scrolling on +a different window (and not on itself).