From 27d029c722b88a50f27ea912754ae3e3d4aeb190 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 11 Oct 1999 10:48:43 +0000 Subject: [PATCH] Minor doc updates, Made resizing a scrolled window function, git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/listbox.tex | 3 ++- docs/latex/wx/scrolwin.tex | 10 +++++++++- docs/latex/wx/tunicode.tex | 14 +++++++------- docs/latex/wx/window.tex | 4 ++-- samples/scroll/scroll.cpp | 2 +- src/generic/scrolwin.cpp | 21 ++++++++++++++++++++- 6 files changed, 41 insertions(+), 13 deletions(-) diff --git a/docs/latex/wx/listbox.tex b/docs/latex/wx/listbox.tex index af66b1a91c..5fb33ba364 100644 --- a/docs/latex/wx/listbox.tex +++ b/docs/latex/wx/listbox.tex @@ -7,7 +7,8 @@ is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections). -List box elements are numbered from zero. +List box elements are numbered from zero. Their number is limited in +some platforms (e.g. ca. 2000 on GTK). A listbox callback gets an event wxEVT\_COMMAND\_LISTBOX\_SELECT for single clicks, and wxEVT\_COMMAND\_LISTBOX\_DOUBLE\_CLICKED for double clicks. diff --git a/docs/latex/wx/scrolwin.tex b/docs/latex/wx/scrolwin.tex index bdc315b480..aae43b2b28 100644 --- a/docs/latex/wx/scrolwin.tex +++ b/docs/latex/wx/scrolwin.tex @@ -14,6 +14,12 @@ If you don't wish to calculate your own scrolling, you must call PrepareDC when within OnDraw, to set the device origin for the device context according to the current scroll position. +Note that the underlying system knows nothing about scrolling coordinates, so that all system +functions (mouse events, expose events, refresh calls etc) as well as the position of subwindows +are relative to the "physical" origin of the scrolled window. If the user insert a child window at +position (10,10) and scrolls the window down 100 pixels (moving the child window out of the visible +area), the child window will report a position of (10,-90). + \wxheading{Derived from} \helpref{wxPanel}{wxpanel}\\ @@ -139,7 +145,9 @@ Enable or disable physical scrolling in the given direction. Physical scrolling is the physical transfer of bits up or down the screen when a scroll event occurs. If the application scrolls by a variable amount (e.g. if there are different font sizes) then physical -scrolling will not work, and you should switch it off. +scrolling will not work, and you should switch it off. Note that you +will have to reposition child windows yourself, if physical scrolling +is disabled. \wxheading{Parameters} diff --git a/docs/latex/wx/tunicode.tex b/docs/latex/wx/tunicode.tex index 43f36eb773..870b86f894 100644 --- a/docs/latex/wx/tunicode.tex +++ b/docs/latex/wx/tunicode.tex @@ -95,11 +95,11 @@ section. \subsection{Unicode support in wxWindows} -In wxWindows, the code fragment froim above should be written instead: +In wxWindows, the code fragment from above should be written instead: \begin{verbatim} - wxChar ch = T('*'); - wxString s = T("Hello, world!"); + wxChar ch = wxT('*'); + wxString s = wxT("Hello, world!"); int len = s.Len(); \end{verbatim} @@ -114,22 +114,22 @@ a separate type for strings though, because the standard \helpref{wxString}{wxstring} supports Unicode, i.e. it stores iether ANSI or Unicode strings depending on the mode. -Finally, there is a special {\tt T()} macro which should enclose all literal +Finally, there is a special {\tt wxT()} macro which should enclose all literal strings in the program. As it's easy to see comparing the last fragment with the one above, this macro expands to nothing in the (usual) ANSI mode and prefixes {\tt 'L'} to its argument in the Unicode mode. The important conclusion is that if you use {\tt wxChar} instead of {\tt char}, avoid using C style strings and use {\tt wxString} instead and -don't forget to enclose all string literals inside {\tt T()} macro, your +don't forget to enclose all string literals inside {\tt wxT()} macro, your program automatically becomes (almost) Unicode compliant! Just let us state once again the rules: \begin{itemize} \item Always use {\tt wxChar} instead of {\tt char} -\item Always enclose literal string constants in {\tt T()} macro unless +\item Always enclose literal string constants in {\tt wxT()} macro unless they're already converted to the right representation (another standard -wxWindows macro {\tt \_()} does it, so there is no need for {\tt T()} in this +wxWindows macro {\tt \_()} does it, so there is no need for {\tt wxT()} in this case) or you intend to pass the constant directly to an external function which doesn't accept wide-character strings. \item Use {\tt wxString} instead of C style strings. diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index d877e1cf84..247b3d37cf 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -28,10 +28,10 @@ window class or on all platforms. \twocolwidtha{5cm}% \begin{twocollist}\itemsep=0pt \twocolitem{\windowstyle{wxSIMPLE\_BORDER}}{Displays a thin border around the window. wxBORDER is the old name -for this style. Windows only. } +for this style. } \twocolitem{\windowstyle{wxDOUBLE\_BORDER}}{Displays a double border. Windows only.} \twocolitem{\windowstyle{wxSUNKEN\_BORDER}}{Displays a sunken border.} -\twocolitem{\windowstyle{wxRAISED\_BORDER}}{Displays a raised border.} +\twocolitem{\windowstyle{wxRAISED\_BORDER}}{Displays a raised border. GTK only. } \twocolitem{\windowstyle{wxSTATIC\_BORDER}}{Displays a border suitable for a static control. Windows only. } \twocolitem{\windowstyle{wxTRANSPARENT\_WINDOW}}{The window is transparent, that is, it will not receive paint events. Windows only.} diff --git a/samples/scroll/scroll.cpp b/samples/scroll/scroll.cpp index c35c00e79a..3567376359 100644 --- a/samples/scroll/scroll.cpp +++ b/samples/scroll/scroll.cpp @@ -124,7 +124,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, m_button = new wxButton( this, ID_QUERYPOS, "Query position", wxPoint(10,110) ); - (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,150) ); + (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,150), wxSize(80,-1) ); (void) new wxRadioButton( this, -1, "Disable", wxPoint(10,190) ); diff --git a/src/generic/scrolwin.cpp b/src/generic/scrolwin.cpp index cc001c2d47..81a4a152de 100644 --- a/src/generic/scrolwin.cpp +++ b/src/generic/scrolwin.cpp @@ -305,10 +305,13 @@ int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event) } // Adjust the scrollbars - new version. -void wxScrolledWindow::AdjustScrollbars(void) +void wxScrolledWindow::AdjustScrollbars() { int w, h; GetClientSize(&w, &h); + + int oldXScroll = m_xScrollPosition; + int oldYScroll = m_yScrollPosition; if (m_xScrollLines > 0) { @@ -353,6 +356,22 @@ void wxScrolledWindow::AdjustScrollbars(void) m_yScrollPosition = 0; SetScrollbar (wxVERTICAL, 0, 0, 0, FALSE); } + + if (oldXScroll != m_xScrollPosition) + { + if (m_xScrollingEnabled) + ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll-m_xScrollPosition), 0, (const wxRect *) NULL ); + else + Refresh(); + } + + if (oldYScroll != m_yScrollPosition) + { + if (m_yScrollingEnabled) + ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), (const wxRect *) NULL ); + else + Refresh(); + } } // Default OnSize resets scrollbars, if any