1. kbd interface for wxScrolledWindow
2. wxWindow::Set/GetExtraStyle() 3. wxWS_EX_VALIDATE_RECURSIVELY added and implemented 4. docs updated to reflect (2) an (3) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5659 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,6 +48,8 @@ all (GUI):
|
|||||||
- TIFF support added (libtiff required and included in the distribution)
|
- TIFF support added (libtiff required and included in the distribution)
|
||||||
- PCX files can now be written (24 bit only so far)
|
- PCX files can now be written (24 bit only so far)
|
||||||
|
|
||||||
|
- validators may work recursively if wxWS_EX_VALIDATE_RECURSIVELY is set
|
||||||
|
- wxScrolledWindow now has keyboard interface
|
||||||
- wxTextEntryDialog may be used for entering passwords (supports wxTE_PASSWORD)
|
- wxTextEntryDialog may be used for entering passwords (supports wxTE_PASSWORD)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
@@ -536,6 +536,12 @@ own event handler.
|
|||||||
\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent},\rtfsp
|
\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent},\rtfsp
|
||||||
\helpref{wxEvtHandler}{wxevthandler}\rtfsp
|
\helpref{wxEvtHandler}{wxevthandler}\rtfsp
|
||||||
|
|
||||||
|
\membersection{wxWindow::GetExtraStyle}\label{wxwindowgetextrastyle}
|
||||||
|
|
||||||
|
\constfunc{long}{GetExtraStyle}{\void}
|
||||||
|
|
||||||
|
Returns the extra style bits for the window.
|
||||||
|
|
||||||
\membersection{wxWindow::GetFont}\label{wxwindowgetfont}
|
\membersection{wxWindow::GetFont}\label{wxwindowgetfont}
|
||||||
|
|
||||||
\constfunc{wxFont\&}{GetFont}{\void}
|
\constfunc{wxFont\&}{GetFont}{\void}
|
||||||
@@ -773,12 +779,12 @@ only be called within an \helpref{OnPaint}{wxwindowonpaint} event handler.
|
|||||||
|
|
||||||
Returns a pointer to the current validator for the window, or NULL if there is none.
|
Returns a pointer to the current validator for the window, or NULL if there is none.
|
||||||
|
|
||||||
\membersection{wxWindow::GetWindowStyleFlag}
|
\membersection{wxWindow::GetWindowStyleFlag}\label{wxwindowgetwindowstyleflag}
|
||||||
|
|
||||||
\constfunc{long}{GetWindowStyleFlag}{\void}
|
\constfunc{long}{GetWindowStyleFlag}{\void}
|
||||||
|
|
||||||
Gets the window style that was passed to the consructor or {\bf Create} member.
|
Gets the window style that was passed to the constructor or {\bf Create}
|
||||||
{\bf GetWindowStyle} is synonymous.
|
method. {\bf GetWindowStyle()} is another name for the same function.
|
||||||
|
|
||||||
\membersection{wxWindow::InitDialog}\label{wxwindowinitdialog}
|
\membersection{wxWindow::InitDialog}\label{wxwindowinitdialog}
|
||||||
|
|
||||||
@@ -1883,6 +1889,20 @@ If the window already has a drop target, it is deleted.
|
|||||||
\helpref{wxWindow::GetDropTarget}{wxwindowgetdroptarget},
|
\helpref{wxWindow::GetDropTarget}{wxwindowgetdroptarget},
|
||||||
\helpref{Drag and drop overview}{wxdndoverview}
|
\helpref{Drag and drop overview}{wxdndoverview}
|
||||||
|
|
||||||
|
\membersection{wxWindow::SetExtraStyle}\label{wxwindowsetextrastyle}
|
||||||
|
|
||||||
|
\func{void}{SetExtraStyle}{\param{long }{exStyle}}
|
||||||
|
|
||||||
|
Sets the extra style bits for the window. The currently defined extra style
|
||||||
|
bits are:
|
||||||
|
|
||||||
|
\twocolwidtha{5cm}%
|
||||||
|
\begin{twocollist}\itemsep=0pt
|
||||||
|
\twocolitem{\windowstyle{wxWS\_EX\_VALIDATE\_RECURSIVELY}}{TransferDataTo/FromWindow()
|
||||||
|
and Validate() methods will recursively descend into all children of the
|
||||||
|
window if it has this style flag set.}
|
||||||
|
\end{twocollist}
|
||||||
|
|
||||||
\membersection{wxWindow::SetFocus}\label{wxwindowsetfocus}
|
\membersection{wxWindow::SetFocus}\label{wxwindowsetfocus}
|
||||||
|
|
||||||
\func{virtual void}{SetFocus}{\void}
|
\func{virtual void}{SetFocus}{\void}
|
||||||
@@ -2253,6 +2273,30 @@ Sets the window's title. Applicable only to frames and dialogs.
|
|||||||
Deletes the current validator (if any) and sets the window validator, having called wxValidator::Clone to
|
Deletes the current validator (if any) and sets the window validator, having called wxValidator::Clone to
|
||||||
create a new validator of this type.
|
create a new validator of this type.
|
||||||
|
|
||||||
|
\membersection{wxWindow::SetWindowStyleFlag}\label{wxwindowsetwindowstyleflag}
|
||||||
|
|
||||||
|
\func{virtual void}{SetWindowStyleFlag}{\param{long}{ style}}
|
||||||
|
|
||||||
|
\membersection{wxWindow::SetWindowStyle}\label{wxwindowsetwindowstyle}
|
||||||
|
|
||||||
|
\func{void}{SetWindowStyle}{\param{long}{ style}}
|
||||||
|
|
||||||
|
Identical to \helpref{SetWindowStyleFlag}{wxwindowsetwindowstyleflag}.
|
||||||
|
|
||||||
|
\membersection{wxWindow::SetWindowStyleFlag}\label{wxwindowsetwindowstyleflag}
|
||||||
|
|
||||||
|
\func{virtual void}{SetWindowStyleFlag}{\param{long}{ style}}
|
||||||
|
|
||||||
|
Sets the style of the window. Please note that some styles cannot be changed
|
||||||
|
after the window creation and that \helpref{Refresh()}{wxwindowrefresh} might
|
||||||
|
be called after changing the others for the change to take place immediately.
|
||||||
|
|
||||||
|
See \helpref{Windowstyles}{windowstyles} for more information about flags.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{GetWindowStyleFlag}{wxwindowgetwindowstyleflag}
|
||||||
|
|
||||||
\membersection{wxWindow::Show}\label{wxwindowshow}
|
\membersection{wxWindow::Show}\label{wxwindowshow}
|
||||||
|
|
||||||
\func{virtual bool}{Show}{\param{bool}{ show}}
|
\func{virtual bool}{Show}{\param{bool}{ show}}
|
||||||
@@ -2275,6 +2319,9 @@ hides the window.}
|
|||||||
Transfers values from child controls to data areas specified by their validators. Returns
|
Transfers values from child controls to data areas specified by their validators. Returns
|
||||||
FALSE if a transfer failed.
|
FALSE if a transfer failed.
|
||||||
|
|
||||||
|
If the window has {\tt wxWS\_EX\_VALIDATE\_RECURSIVELY} extra style flag set,
|
||||||
|
the method will also call TransferDataFromWindow() of all child windows.
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow},\rtfsp
|
\helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow},\rtfsp
|
||||||
@@ -2286,6 +2333,9 @@ FALSE if a transfer failed.
|
|||||||
|
|
||||||
Transfers values to child controls from data areas specified by their validators.
|
Transfers values to child controls from data areas specified by their validators.
|
||||||
|
|
||||||
|
If the window has {\tt wxWS\_EX\_VALIDATE\_RECURSIVELY} extra style flag set,
|
||||||
|
the method will also call TransferDataToWindow() of all child windows.
|
||||||
|
|
||||||
\wxheading{Return value}
|
\wxheading{Return value}
|
||||||
|
|
||||||
Returns FALSE if a transfer failed.
|
Returns FALSE if a transfer failed.
|
||||||
@@ -2301,6 +2351,9 @@ Returns FALSE if a transfer failed.
|
|||||||
|
|
||||||
Validates the current values of the child controls using their validators.
|
Validates the current values of the child controls using their validators.
|
||||||
|
|
||||||
|
If the window has {\tt wxWS\_EX\_VALIDATE\_RECURSIVELY} extra style flag set,
|
||||||
|
the method will also call Validate() of all child windows.
|
||||||
|
|
||||||
\wxheading{Return value}
|
\wxheading{Return value}
|
||||||
|
|
||||||
Returns FALSE if any of the validations failed.
|
Returns FALSE if any of the validations failed.
|
||||||
|
@@ -842,20 +842,20 @@ enum wxStretch
|
|||||||
#define wxTRANSPARENT_WINDOW 0x00100000
|
#define wxTRANSPARENT_WINDOW 0x00100000
|
||||||
#define wxNO_BORDER 0x00200000
|
#define wxNO_BORDER 0x00200000
|
||||||
|
|
||||||
|
// Override CTL3D etc. control colour processing to allow own background
|
||||||
|
// colour.
|
||||||
|
// OBSOLETE - use wxNO_3D instead
|
||||||
#define wxUSER_COLOURS 0x00800000
|
#define wxUSER_COLOURS 0x00800000
|
||||||
// Override CTL3D etc. control colour processing to
|
// Override CTL3D or native 3D styles for children
|
||||||
// allow own background colour
|
|
||||||
// OBSOLETE - use wxNO_3D instead
|
|
||||||
#define wxNO_3D 0x00800000
|
#define wxNO_3D 0x00800000
|
||||||
// Override CTL3D or native 3D styles for children
|
|
||||||
#define wxCLIP_CHILDREN 0x00400000
|
|
||||||
// Clip children when painting, which reduces flicker in
|
|
||||||
// e.g. frames and splitter windows, but can't be used in
|
|
||||||
// a panel where a static box must be 'transparent' (panel
|
|
||||||
// paints the background for it)
|
|
||||||
|
|
||||||
// Add this style to a panel to get tab traversal working
|
// Clip children when painting, which reduces flicker in e.g. frames and
|
||||||
// outside of dialogs.
|
// splitter windows, but can't be used in a panel where a static box must be
|
||||||
|
// 'transparent' (panel paints the background for it)
|
||||||
|
#define wxCLIP_CHILDREN 0x00400000
|
||||||
|
|
||||||
|
// Add this style to a panel to get tab traversal working outside of dialogs
|
||||||
|
// (on by default for wxPanel, wxDialog, wxScrolledWindow)
|
||||||
#define wxTAB_TRAVERSAL 0x00080000
|
#define wxTAB_TRAVERSAL 0x00080000
|
||||||
|
|
||||||
// Add this style if the control wants to get all keyboard messages (under
|
// Add this style if the control wants to get all keyboard messages (under
|
||||||
@@ -869,6 +869,17 @@ enum wxStretch
|
|||||||
// don't invalidate the whole window (resulting in a PAINT event) when the
|
// don't invalidate the whole window (resulting in a PAINT event) when the
|
||||||
// window is resized (currently, makes sense for wxMSW only)
|
// window is resized (currently, makes sense for wxMSW only)
|
||||||
#define wxNO_FULL_REPAINT_ON_RESIZE 0x00010000
|
#define wxNO_FULL_REPAINT_ON_RESIZE 0x00010000
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extra window style flags (use wxWS_EX prefix to make it clear that they
|
||||||
|
* should be passed to wxWindow::SetExtraStyle(), not SetWindowStyle())
|
||||||
|
*/
|
||||||
|
|
||||||
|
// by default, TransferDataTo/FromWindow() only work on direct children of the
|
||||||
|
// window (compatible behaviour), set this flag to make them recursively
|
||||||
|
// descend into all subwindows
|
||||||
|
#define wxWS_EX_VALIDATE_RECURSIVELY 0x00000001
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxFrame/wxDialog style flags
|
* wxFrame/wxDialog style flags
|
||||||
*/
|
*/
|
||||||
|
@@ -123,6 +123,7 @@ public:
|
|||||||
void OnScroll(wxScrollWinEvent& event);
|
void OnScroll(wxScrollWinEvent& event);
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
|
|
||||||
// Calculate scroll increment
|
// Calculate scroll increment
|
||||||
virtual int CalcScrollInc(wxScrollWinEvent& event);
|
virtual int CalcScrollInc(wxScrollWinEvent& event);
|
||||||
|
@@ -315,9 +315,12 @@ public:
|
|||||||
long GetWindowStyle() const { return GetWindowStyleFlag(); }
|
long GetWindowStyle() const { return GetWindowStyleFlag(); }
|
||||||
|
|
||||||
bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
|
bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
|
||||||
|
virtual bool IsRetained() const { return HasFlag(wxRETAINED); }
|
||||||
|
|
||||||
virtual bool IsRetained() const
|
// extra style: the less often used style bits which can't be set with
|
||||||
{ return (m_windowStyle & wxRETAINED) != 0; }
|
// SetWindowStyleFlag()
|
||||||
|
void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
|
||||||
|
long GetExtraStyle() const { return m_exStyle; }
|
||||||
|
|
||||||
// make the window modal (all other windows unresponsive)
|
// make the window modal (all other windows unresponsive)
|
||||||
virtual void MakeModal(bool modal = TRUE);
|
virtual void MakeModal(bool modal = TRUE);
|
||||||
@@ -739,7 +742,8 @@ protected:
|
|||||||
bool m_isBeingDeleted:1;
|
bool m_isBeingDeleted:1;
|
||||||
|
|
||||||
// window attributes
|
// window attributes
|
||||||
long m_windowStyle;
|
long m_windowStyle,
|
||||||
|
m_exStyle;
|
||||||
wxString m_windowName;
|
wxString m_windowName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -126,7 +126,9 @@ void wxWindowBase::InitBase()
|
|||||||
#else
|
#else
|
||||||
m_font = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
m_font = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// no style bits
|
// no style bits
|
||||||
|
m_exStyle =
|
||||||
m_windowStyle = 0;
|
m_windowStyle = 0;
|
||||||
|
|
||||||
// an optimization for the event processing: checking this flag is much
|
// an optimization for the event processing: checking this flag is much
|
||||||
@@ -704,6 +706,8 @@ void wxWindowBase::MakeModal(bool modal)
|
|||||||
bool wxWindowBase::Validate()
|
bool wxWindowBase::Validate()
|
||||||
{
|
{
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
|
bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
|
||||||
|
|
||||||
wxWindowList::Node *node;
|
wxWindowList::Node *node;
|
||||||
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
|
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
@@ -713,6 +717,11 @@ bool wxWindowBase::Validate()
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( recurse && !child->Validate() )
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_VALIDATORS
|
#endif // wxUSE_VALIDATORS
|
||||||
|
|
||||||
@@ -722,22 +731,29 @@ bool wxWindowBase::Validate()
|
|||||||
bool wxWindowBase::TransferDataToWindow()
|
bool wxWindowBase::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
|
bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
|
||||||
|
|
||||||
wxWindowList::Node *node;
|
wxWindowList::Node *node;
|
||||||
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
|
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
wxWindowBase *child = node->GetData();
|
wxWindowBase *child = node->GetData();
|
||||||
wxValidator *validator = child->GetValidator();
|
wxValidator *validator = child->GetValidator();
|
||||||
if ( validator && !validator->TransferToWindow() )
|
if ( validator && !validator->TransferToWindow() )
|
||||||
{
|
|
||||||
wxLog *log = wxLog::GetActiveTarget();
|
|
||||||
if ( log )
|
|
||||||
{
|
{
|
||||||
wxLogWarning(_("Could not transfer data to window"));
|
wxLogWarning(_("Could not transfer data to window"));
|
||||||
log->Flush();
|
wxLog::FlushActive();
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( recurse )
|
||||||
|
{
|
||||||
|
if ( !child->TransferToWindow() )
|
||||||
|
{
|
||||||
|
// warning already given
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_VALIDATORS
|
#endif // wxUSE_VALIDATORS
|
||||||
|
|
||||||
@@ -747,15 +763,29 @@ bool wxWindowBase::TransferDataToWindow()
|
|||||||
bool wxWindowBase::TransferDataFromWindow()
|
bool wxWindowBase::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
|
bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
|
||||||
|
|
||||||
wxWindowList::Node *node;
|
wxWindowList::Node *node;
|
||||||
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
|
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
wxWindow *child = node->GetData();
|
wxWindow *child = node->GetData();
|
||||||
if ( child->GetValidator() &&
|
wxValidator *validator = child->GetValidator();
|
||||||
!child->GetValidator()->TransferFromWindow() )
|
if ( validator && !validator->TransferFromWindow() )
|
||||||
{
|
{
|
||||||
|
// nop warning here because the application is supposed to give
|
||||||
|
// one itself - we don't know here what might have gone wrongly
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( recurse )
|
||||||
|
{
|
||||||
|
if ( !child->TransferFromWindow() )
|
||||||
|
{
|
||||||
|
// warning already given
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_VALIDATORS
|
#endif // wxUSE_VALIDATORS
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: scrolwin.cpp
|
// Name: generic/scrolwin.cpp
|
||||||
// Purpose: wxScrolledWindow implementation
|
// Purpose: wxScrolledWindow implementation
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -9,34 +9,33 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation "scrolwin.h"
|
||||||
#pragma implementation "scrolwin.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/generic/scrolwin.h"
|
#include "wx/generic/scrolwin.h"
|
||||||
#include "wx/panel.h"
|
#include "wx/panel.h"
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
|
|
||||||
EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
|
|
||||||
EVT_SIZE(wxScrolledWindow::OnSize)
|
|
||||||
EVT_PAINT(wxScrolledWindow::OnPaint)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
|
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXMOTIF__
|
#ifdef __WXMOTIF__
|
||||||
@@ -51,6 +50,27 @@ IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// event tables
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
|
||||||
|
EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
|
||||||
|
EVT_SIZE(wxScrolledWindow::OnSize)
|
||||||
|
EVT_PAINT(wxScrolledWindow::OnPaint)
|
||||||
|
EVT_KEY_DOWN(wxScrolledWindow::OnKeyDown)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxScrolledWindow creation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxScrolledWindow::wxScrolledWindow()
|
wxScrolledWindow::wxScrolledWindow()
|
||||||
{
|
{
|
||||||
m_xScrollPixelsPerLine = 0;
|
m_xScrollPixelsPerLine = 0;
|
||||||
@@ -67,7 +87,8 @@ wxScrolledWindow::wxScrolledWindow()
|
|||||||
m_scaleY = 1.0;
|
m_scaleY = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxScrolledWindow::Create(wxWindow *parent, wxWindowID id,
|
bool wxScrolledWindow::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
@@ -91,6 +112,14 @@ bool wxScrolledWindow::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return wxPanel::Create(parent, id, pos, size, style, name);
|
return wxPanel::Create(parent, id, pos, size, style, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxScrolledWindow::~wxScrolledWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// setting scrolling parameters
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line)
|
* pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line)
|
||||||
* noUnitsX/noUnitsY: : no. units per scrollbar
|
* noUnitsX/noUnitsY: : no. units per scrollbar
|
||||||
@@ -149,7 +178,7 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Motif
|
||||||
|
|
||||||
AdjustScrollbars();
|
AdjustScrollbars();
|
||||||
|
|
||||||
@@ -171,9 +200,9 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxScrolledWindow::~wxScrolledWindow()
|
// ----------------------------------------------------------------------------
|
||||||
{
|
// target window handling
|
||||||
}
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxScrolledWindow::SetTargetWindow( wxWindow *target )
|
void wxScrolledWindow::SetTargetWindow( wxWindow *target )
|
||||||
{
|
{
|
||||||
@@ -186,6 +215,10 @@ wxWindow *wxScrolledWindow::GetTargetWindow()
|
|||||||
return m_targetWindow;
|
return m_targetWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// scrolling implementation itself
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxScrolledWindow::OnScroll(wxScrollWinEvent& event)
|
void wxScrolledWindow::OnScroll(wxScrollWinEvent& event)
|
||||||
{
|
{
|
||||||
int orient = event.GetOrientation();
|
int orient = event.GetOrientation();
|
||||||
@@ -410,26 +443,6 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default OnSize resets scrollbars, if any
|
|
||||||
void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
#if wxUSE_CONSTRAINTS
|
|
||||||
if (GetAutoLayout()) Layout();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AdjustScrollbars();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This calls OnDraw, having adjusted the origin according to the current
|
|
||||||
// scroll position
|
|
||||||
void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxPaintDC dc(this);
|
|
||||||
PrepareDC(dc);
|
|
||||||
|
|
||||||
OnDraw(dc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override this function if you don't want to have wxScrolledWindow
|
// Override this function if you don't want to have wxScrolledWindow
|
||||||
// automatically change the origin according to the scroll position.
|
// automatically change the origin according to the scroll position.
|
||||||
void wxScrolledWindow::PrepareDC(wxDC& dc)
|
void wxScrolledWindow::PrepareDC(wxDC& dc)
|
||||||
@@ -573,3 +586,89 @@ void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) co
|
|||||||
if ( yy )
|
if ( yy )
|
||||||
*yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
|
*yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// event handlers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Default OnSize resets scrollbars, if any
|
||||||
|
void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
#if wxUSE_CONSTRAINTS
|
||||||
|
if (GetAutoLayout())
|
||||||
|
Layout();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AdjustScrollbars();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This calls OnDraw, having adjusted the origin according to the current
|
||||||
|
// scroll position
|
||||||
|
void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxPaintDC dc(this);
|
||||||
|
PrepareDC(dc);
|
||||||
|
|
||||||
|
OnDraw(dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// kbd handling
|
||||||
|
void wxScrolledWindow::OnKeyDown(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
int stx, sty, // view origin
|
||||||
|
szx, szy, // view size (total)
|
||||||
|
clix, cliy; // view size (on screen)
|
||||||
|
|
||||||
|
ViewStart(&stx, &sty);
|
||||||
|
GetClientSize(&clix, &cliy);
|
||||||
|
clix /= m_xScrollPixelsPerLine;
|
||||||
|
cliy /= m_yScrollPixelsPerLine;
|
||||||
|
GetVirtualSize(&szx, &szy);
|
||||||
|
szx /= m_xScrollPixelsPerLine;
|
||||||
|
szy /= m_yScrollPixelsPerLine;
|
||||||
|
|
||||||
|
switch ( event.KeyCode() )
|
||||||
|
{
|
||||||
|
case WXK_PAGEUP:
|
||||||
|
case WXK_PRIOR:
|
||||||
|
Scroll(-1, sty - (5 * cliy / 6));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_PAGEDOWN:
|
||||||
|
case WXK_NEXT:
|
||||||
|
Scroll(-1, sty + (5 * cliy / 6));
|
||||||
|
break;
|
||||||
|
|
||||||
|
// notice that handling of Ctrl-Home/End is asymmetrical: Home goes to
|
||||||
|
// the beginning of the current line, Ctrl-Home returns to the origin
|
||||||
|
// while End goes to the bottom without changing horizontal position
|
||||||
|
// and only Ctrl-End does go to the most rightmost position as well
|
||||||
|
case WXK_HOME:
|
||||||
|
Scroll(0, event.ControlDown() ? 0 : -1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_END:
|
||||||
|
Scroll(event.ControlDown() ? szx - clix : -1, szy - cliy);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_UP:
|
||||||
|
Scroll(-1, sty - 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_DOWN:
|
||||||
|
Scroll(-1, sty + 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_LEFT:
|
||||||
|
Scroll(stx - 1, -1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_RIGHT:
|
||||||
|
Scroll(stx + 1, -1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// not for us
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user