1. many (minor) listbox fixes
2. scrollbar thumb now has min size git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8591 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
6
TODO
6
TODO
@@ -2,6 +2,10 @@
|
|||||||
TODO
|
TODO
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
samples:
|
||||||
|
|
||||||
|
add SetString button to lboxtest
|
||||||
|
|
||||||
wxTextCtrl
|
wxTextCtrl
|
||||||
|
|
||||||
* display corrupted when typing text in quickly
|
* display corrupted when typing text in quickly
|
||||||
@@ -23,6 +27,8 @@ All
|
|||||||
|
|
||||||
MSW
|
MSW
|
||||||
|
|
||||||
|
scrollbar behaves strangely in log lbox with many strings
|
||||||
|
|
||||||
GTK
|
GTK
|
||||||
|
|
||||||
* listbox scrolling leaves unpainted areas
|
* listbox scrolling leaves unpainted areas
|
||||||
|
@@ -74,11 +74,19 @@ public:
|
|||||||
// GetSelection which only works for listboxes with single selection)
|
// GetSelection which only works for listboxes with single selection)
|
||||||
virtual int GetSelections(wxArrayInt& aSelections) const = 0;
|
virtual int GetSelections(wxArrayInt& aSelections) const = 0;
|
||||||
|
|
||||||
// Set the specified item at the first visible item or scroll to max
|
// set the specified item at the first visible item or scroll to max
|
||||||
// range.
|
// range.
|
||||||
void SetFirstItem(int n) { DoSetFirstItem(n); }
|
void SetFirstItem(int n) { DoSetFirstItem(n); }
|
||||||
void SetFirstItem(const wxString& s);
|
void SetFirstItem(const wxString& s);
|
||||||
|
|
||||||
|
// ensures that the given item is visible scrolling the listbox if
|
||||||
|
// necessary
|
||||||
|
virtual void EnsureVisible(int n);
|
||||||
|
|
||||||
|
// a combination of Append() and EnsureVisible(): appends the item to the
|
||||||
|
// listbox and ensures that it is visible i.e. not scrolled out of view
|
||||||
|
void AppendAndEnsureVisible(const wxString& s);
|
||||||
|
|
||||||
// return TRUE if the listbox allows multiple selection
|
// return TRUE if the listbox allows multiple selection
|
||||||
bool HasMultipleSelection() const
|
bool HasMultipleSelection() const
|
||||||
{
|
{
|
||||||
|
@@ -134,8 +134,8 @@ public:
|
|||||||
// select or unselect the specified or current (if -1) item
|
// select or unselect the specified or current (if -1) item
|
||||||
void Select(bool sel = TRUE, int item = -1);
|
void Select(bool sel = TRUE, int item = -1);
|
||||||
|
|
||||||
// ensure that the current item is visible by scrolling it into view
|
// ensure that the given item is visible by scrolling it into view
|
||||||
void EnsureVisible();
|
virtual void EnsureVisible(int n);
|
||||||
|
|
||||||
// find the first item after the current one which starts with the given
|
// find the first item after the current one which starts with the given
|
||||||
// string and make it the current one, return TRUE if the current item
|
// string and make it the current one, return TRUE if the current item
|
||||||
@@ -175,7 +175,6 @@ protected:
|
|||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnChar(wxKeyEvent& event);
|
|
||||||
void OnIdle(wxIdleEvent& event);
|
void OnIdle(wxIdleEvent& event);
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
|
|
||||||
@@ -202,6 +201,9 @@ protected:
|
|||||||
virtual void DoDrawRange(wxControlRenderer *renderer,
|
virtual void DoDrawRange(wxControlRenderer *renderer,
|
||||||
int itemFirst, int itemLast);
|
int itemFirst, int itemLast);
|
||||||
|
|
||||||
|
// update the scrollbars and then ensure that the item is visible
|
||||||
|
void DoEnsureVisible(int n);
|
||||||
|
|
||||||
// mark horz scrollbar for updating
|
// mark horz scrollbar for updating
|
||||||
void RefreshHorzScrollbar();
|
void RefreshHorzScrollbar();
|
||||||
|
|
||||||
|
@@ -262,6 +262,12 @@ protected:
|
|||||||
const wxSize& sizeArrow);
|
const wxSize& sizeArrow);
|
||||||
static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar,
|
static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar,
|
||||||
const wxSize& sizeArrow);
|
const wxSize& sizeArrow);
|
||||||
|
static void StandardScrollBarThumbSize(wxCoord lenBar,
|
||||||
|
int thumbPos,
|
||||||
|
int thumbSize,
|
||||||
|
int range,
|
||||||
|
wxCoord *thumbStart,
|
||||||
|
wxCoord *thumbEnd);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -115,6 +115,10 @@ void wxListBoxBase::Command(wxCommandEvent& event)
|
|||||||
(void)ProcessEvent(event);
|
(void)ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// SetFirstItem() and such
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxListBoxBase::SetFirstItem(const wxString& s)
|
void wxListBoxBase::SetFirstItem(const wxString& s)
|
||||||
{
|
{
|
||||||
int n = FindString(s);
|
int n = FindString(s);
|
||||||
@@ -124,4 +128,16 @@ void wxListBoxBase::SetFirstItem(const wxString& s)
|
|||||||
DoSetFirstItem(n);
|
DoSetFirstItem(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListBoxBase::AppendAndEnsureVisible(const wxString& s)
|
||||||
|
{
|
||||||
|
Append(s);
|
||||||
|
EnsureVisible(GetCount() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBoxBase::EnsureVisible(int WXUNUSED(n))
|
||||||
|
{
|
||||||
|
// the base class version does nothing (the only alternative would be to
|
||||||
|
// call SetFirstItem() but this is probably even more stupid)
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_LISTBOX
|
#endif // wxUSE_LISTBOX
|
||||||
|
@@ -1507,6 +1507,8 @@ long wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam
|
|||||||
|
|
||||||
bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
||||||
{
|
{
|
||||||
|
// wxUniversal implements tab traversal itself
|
||||||
|
#ifndef __WXUNIVERSAL__
|
||||||
if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) )
|
if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) )
|
||||||
{
|
{
|
||||||
// intercept dialog navigation keys
|
// intercept dialog navigation keys
|
||||||
@@ -1672,6 +1674,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
if ( m_tooltip )
|
if ( m_tooltip )
|
||||||
@@ -2425,8 +2428,15 @@ bool wxWindowMSW::MSWCreate(int id,
|
|||||||
if ( style & WS_CHILD )
|
if ( style & WS_CHILD )
|
||||||
{
|
{
|
||||||
controlId = id;
|
controlId = id;
|
||||||
// all child windows should clip their siblings
|
|
||||||
// style |= /* WS_CLIPSIBLINGS */ ;
|
#if 0 // def __WXUNIVERSAL__
|
||||||
|
// all child windows should clip their siblings except those which
|
||||||
|
// contain other controls
|
||||||
|
if ( !wxDynamicCast(this, wxStaticBox) )
|
||||||
|
{
|
||||||
|
style |= WS_CLIPSIBLINGS;
|
||||||
|
}
|
||||||
|
#endif // __WXUNIVERSAL__
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString className(wclass);
|
wxString className(wclass);
|
||||||
|
@@ -97,6 +97,23 @@ wxButton::~wxButton()
|
|||||||
// size management
|
// size management
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
wxSize wxButtonBase::GetDefaultSize()
|
||||||
|
{
|
||||||
|
static wxSize s_sizeBtn;
|
||||||
|
|
||||||
|
if ( s_sizeBtn.x == 0 )
|
||||||
|
{
|
||||||
|
wxScreenDC dc;
|
||||||
|
|
||||||
|
// this corresponds more or less to wxMSW standard
|
||||||
|
s_sizeBtn.x = (50 * dc.GetCharWidth())/4;
|
||||||
|
s_sizeBtn.y = (14 * dc.GetCharHeight())/8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_sizeBtn;
|
||||||
|
}
|
||||||
|
|
||||||
wxSize wxButton::DoGetBestClientSize() const
|
wxSize wxButton::DoGetBestClientSize() const
|
||||||
{
|
{
|
||||||
wxClientDC dc(wxConstCast(this, wxButton));
|
wxClientDC dc(wxConstCast(this, wxButton));
|
||||||
|
@@ -48,8 +48,6 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxListBox, wxListBoxBase)
|
BEGIN_EVENT_TABLE(wxListBox, wxListBoxBase)
|
||||||
EVT_CHAR(wxListBox::OnChar)
|
|
||||||
|
|
||||||
EVT_SIZE(wxListBox::OnSize)
|
EVT_SIZE(wxListBox::OnSize)
|
||||||
|
|
||||||
EVT_IDLE(wxListBox::OnIdle)
|
EVT_IDLE(wxListBox::OnIdle)
|
||||||
@@ -582,7 +580,7 @@ void wxListBox::OnIdle(wxIdleEvent& event)
|
|||||||
|
|
||||||
if ( m_currentChanged )
|
if ( m_currentChanged )
|
||||||
{
|
{
|
||||||
EnsureVisible();
|
DoEnsureVisible(m_current);
|
||||||
|
|
||||||
m_currentChanged = FALSE;
|
m_currentChanged = FALSE;
|
||||||
}
|
}
|
||||||
@@ -808,17 +806,10 @@ bool wxListBox::FindItem(const wxString& prefix)
|
|||||||
{
|
{
|
||||||
size_t len = prefix.length();
|
size_t len = prefix.length();
|
||||||
int count = GetCount();
|
int count = GetCount();
|
||||||
for ( int item = m_current + 1; item != m_current; item++ )
|
int first = m_current == count - 1 ? 0 : m_current + 1;
|
||||||
|
int last = m_current == -1 ? count : m_current;
|
||||||
|
for ( int item = first; item != last; item < count - 1 ? item++ : item = 0 )
|
||||||
{
|
{
|
||||||
if ( item == count )
|
|
||||||
{
|
|
||||||
// wrap
|
|
||||||
item = 0;
|
|
||||||
|
|
||||||
if ( m_current == -1 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( wxStrnicmp(m_strings[item], prefix, len) == 0 )
|
if ( wxStrnicmp(m_strings[item], prefix, len) == 0 )
|
||||||
{
|
{
|
||||||
SetCurrentItem(item);
|
SetCurrentItem(item);
|
||||||
@@ -840,7 +831,20 @@ bool wxListBox::FindItem(const wxString& prefix)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::EnsureVisible()
|
void wxListBox::EnsureVisible(int n)
|
||||||
|
{
|
||||||
|
if ( m_updateScrollbarY )
|
||||||
|
{
|
||||||
|
UpdateScrollbars();
|
||||||
|
|
||||||
|
m_updateScrollbarX =
|
||||||
|
m_updateScrollbarY = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DoEnsureVisible(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBox::DoEnsureVisible(int n)
|
||||||
{
|
{
|
||||||
if ( !m_showScrollbarY )
|
if ( !m_showScrollbarY )
|
||||||
{
|
{
|
||||||
@@ -850,20 +854,20 @@ void wxListBox::EnsureVisible()
|
|||||||
|
|
||||||
int first;
|
int first;
|
||||||
GetViewStart(0, &first);
|
GetViewStart(0, &first);
|
||||||
if ( first > m_current )
|
if ( first > n )
|
||||||
{
|
{
|
||||||
// we need to scroll upwards, so make the current item appear on top
|
// we need to scroll upwards, so make the current item appear on top
|
||||||
// of the shown range
|
// of the shown range
|
||||||
Scroll(0, m_current);
|
Scroll(0, n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int last = first + GetClientSize().y / GetLineHeight() - 1;
|
int last = first + GetClientSize().y / GetLineHeight() - 1;
|
||||||
if ( last < m_current )
|
if ( last < n )
|
||||||
{
|
{
|
||||||
// scroll down: the current item appears at the bottom of the
|
// scroll down: the current item appears at the bottom of the
|
||||||
// range
|
// range
|
||||||
Scroll(0, m_current - (last - first));
|
Scroll(0, n - (last - first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -953,35 +957,6 @@ void wxListBox::Activate(int item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// built-in keyboard interface (should it be implemented in the inp handler?)
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void wxListBox::OnChar(wxKeyEvent& event)
|
|
||||||
{
|
|
||||||
int keycode = event.GetKeyCode();
|
|
||||||
if ( isalnum(keycode) )
|
|
||||||
{
|
|
||||||
// find the next item after this one which starts with this letter
|
|
||||||
int count = GetCount();
|
|
||||||
int last = m_current == -1 ? count : m_current;
|
|
||||||
for ( int n = m_current + 1; n != last; n++ )
|
|
||||||
{
|
|
||||||
if ( n == count )
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
wxString str = m_strings[n];
|
|
||||||
if ( !str.empty() && (str[0u] == (wxChar)keycode) )
|
|
||||||
{
|
|
||||||
SetCurrentItem(n);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// input handling
|
// input handling
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -74,6 +74,37 @@ void wxRenderer::StandardDrawFrame(wxDC& dc,
|
|||||||
// wxRenderer: scrollbar geometry
|
// wxRenderer: scrollbar geometry
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void wxRenderer::StandardScrollBarThumbSize(wxCoord length,
|
||||||
|
int thumbPos,
|
||||||
|
int thumbSize,
|
||||||
|
int range,
|
||||||
|
wxCoord *thumbStart,
|
||||||
|
wxCoord *thumbEnd)
|
||||||
|
{
|
||||||
|
// the thumb can't be made less than this number of pixels
|
||||||
|
static const wxCoord thumbMinWidth = 8; // FIXME: should be configurable
|
||||||
|
|
||||||
|
*thumbStart = (length*thumbPos) / range;
|
||||||
|
*thumbEnd = (length*(thumbPos + thumbSize)) / range;
|
||||||
|
|
||||||
|
if ( *thumbEnd - *thumbStart < thumbMinWidth )
|
||||||
|
{
|
||||||
|
// adjust the end if possible
|
||||||
|
if ( *thumbStart <= length - thumbMinWidth )
|
||||||
|
{
|
||||||
|
// yes, just make it wider
|
||||||
|
*thumbEnd = *thumbStart + thumbMinWidth;
|
||||||
|
}
|
||||||
|
else // it is at the bottom of the scrollbar
|
||||||
|
{
|
||||||
|
// so move it a bit up
|
||||||
|
*thumbStart = length - thumbMinWidth;
|
||||||
|
*thumbEnd = length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
wxRect wxRenderer::StandardGetScrollbarRect(const wxScrollBar *scrollbar,
|
wxRect wxRenderer::StandardGetScrollbarRect(const wxScrollBar *scrollbar,
|
||||||
wxScrollBar::Element elem,
|
wxScrollBar::Element elem,
|
||||||
@@ -139,10 +170,12 @@ wxRect wxRenderer::StandardGetScrollbarRect(const wxScrollBar *scrollbar,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int thumbSize = scrollbar->GetThumbSize();
|
StandardScrollBarThumbSize(length,
|
||||||
|
thumbPos,
|
||||||
thumbStart = (length*thumbPos) / range;
|
scrollbar->GetThumbSize(),
|
||||||
thumbEnd = (length*(thumbPos + thumbSize)) / range;
|
range,
|
||||||
|
&thumbStart,
|
||||||
|
&thumbEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( elem == wxScrollBar::Element_Thumb )
|
if ( elem == wxScrollBar::Element_Thumb )
|
||||||
@@ -280,11 +313,12 @@ wxHitTest wxRenderer::StandardHitTestScrollbar(const wxScrollBar *scrollbar,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int posThumb = scrollbar->GetThumbPosition(),
|
StandardScrollBarThumbSize(sizeTotal,
|
||||||
sizeThumb = scrollbar->GetThumbSize();
|
scrollbar->GetThumbPosition(),
|
||||||
|
scrollbar->GetThumbSize(),
|
||||||
thumbStart = (sizeTotal*posThumb) / range;
|
range,
|
||||||
thumbEnd = (sizeTotal*(posThumb + sizeThumb)) / range;
|
&thumbStart,
|
||||||
|
&thumbEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now compare with the thumb position
|
// now compare with the thumb position
|
||||||
|
@@ -271,7 +271,6 @@ void wxScrollBar::OnIdle(wxIdleEvent& event)
|
|||||||
#endif // 0/1
|
#endif // 0/1
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: rect is client or win (must be client)?
|
|
||||||
Refresh(TRUE, &rect);
|
Refresh(TRUE, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1772,6 +1772,10 @@ void wxWin32Renderer::AdjustSize(wxSize *size, const wxWindow *window)
|
|||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
size->x += 3*window->GetCharWidth();
|
size->x += 3*window->GetCharWidth();
|
||||||
|
wxSize sizeDef = wxButton::GetDefaultSize();
|
||||||
|
if ( size->x < sizeDef.x )
|
||||||
|
size->x = sizeDef.x;
|
||||||
|
|
||||||
wxCoord heightBtn = (11*(window->GetCharHeight() + 8))/10;
|
wxCoord heightBtn = (11*(window->GetCharHeight() + 8))/10;
|
||||||
if ( size->y < heightBtn - 8 )
|
if ( size->y < heightBtn - 8 )
|
||||||
size->y = heightBtn;
|
size->y = heightBtn;
|
||||||
|
@@ -308,7 +308,7 @@ void wxWindow::Refresh(bool eraseBackground, const wxRect *rectClient)
|
|||||||
|
|
||||||
bool wxWindow::Enable(bool enable)
|
bool wxWindow::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( !wxWindowBase::Enable(enable) )
|
if ( !wxWindowNative::Enable(enable) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// disabled window can't keep focus
|
// disabled window can't keep focus
|
||||||
|
Reference in New Issue
Block a user