cleanup - reformatting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37115 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -8,20 +8,11 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
// TODO
|
||||||
TODO
|
//
|
||||||
|
// 1. we need to implement searching/sorting for virtual controls somehow
|
||||||
|
// 2. when changing selection the lines are refreshed twice
|
||||||
|
|
||||||
1. we need to implement searching/sorting for virtual controls somehow
|
|
||||||
?2. when changing selection the lines are refreshed twice
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// declarations
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// headers
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
@@ -34,11 +25,8 @@
|
|||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
|
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
|
|
||||||
#include "wx/dcscreen.h"
|
#include "wx/dcscreen.h"
|
||||||
|
|
||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -72,7 +60,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: If using the wxListBox visual attributes works everywhere then this can
|
// NOTE: If using the wxListBox visual attributes works everywhere then this can
|
||||||
// be removed, as well as the #else case below.
|
// be removed, as well as the #else case below.
|
||||||
#define _USE_VISATTR 0
|
#define _USE_VISATTR 0
|
||||||
@@ -219,9 +206,8 @@ public:
|
|||||||
// user data associated with the item
|
// user data associated with the item
|
||||||
wxUIntPtr m_data;
|
wxUIntPtr m_data;
|
||||||
|
|
||||||
// the item coordinates are not used in report mode, instead this pointer
|
// the item coordinates are not used in report mode; instead this pointer is
|
||||||
// is NULL and the owner window is used to retrieve the item position and
|
// NULL and the owner window is used to retrieve the item position and size
|
||||||
// size
|
|
||||||
wxRect *m_rect;
|
wxRect *m_rect;
|
||||||
|
|
||||||
// the list ctrl we are in
|
// the list ctrl we are in
|
||||||
@@ -318,7 +304,8 @@ public:
|
|||||||
m_rectIcon.x = m_rectAll.x + (w - m_rectIcon.width) / 2;
|
m_rectIcon.x = m_rectAll.x + (w - m_rectIcon.width) / 2;
|
||||||
m_rectHighlight.x = m_rectAll.x + (w - m_rectHighlight.width) / 2;
|
m_rectHighlight.x = m_rectAll.x + (w - m_rectHighlight.width) / 2;
|
||||||
}
|
}
|
||||||
} *m_gi;
|
}
|
||||||
|
*m_gi;
|
||||||
|
|
||||||
// is this item selected? [NB: not used in virtual mode]
|
// is this item selected? [NB: not used in virtual mode]
|
||||||
bool m_highlighted;
|
bool m_highlighted;
|
||||||
@@ -432,8 +419,8 @@ protected:
|
|||||||
// divider line position in logical (unscrolled) coords
|
// divider line position in logical (unscrolled) coords
|
||||||
int m_currentX;
|
int m_currentX;
|
||||||
|
|
||||||
// minimal position beyond which the divider line can't be dragged in
|
// minimal position beyond which the divider line
|
||||||
// logical coords
|
// can't be dragged in logical coords
|
||||||
int m_minX;
|
int m_minX;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -813,7 +800,6 @@ protected:
|
|||||||
if ( IsVirtual() )
|
if ( IsVirtual() )
|
||||||
{
|
{
|
||||||
wxConstCast(this, wxListMainWindow)->CacheLineData(n);
|
wxConstCast(this, wxListMainWindow)->CacheLineData(n);
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,22 +857,13 @@ private:
|
|||||||
friend class wxGenericListCtrl;
|
friend class wxGenericListCtrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// implementation
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// wxListItemData
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxListItemData::~wxListItemData()
|
wxListItemData::~wxListItemData()
|
||||||
{
|
{
|
||||||
// in the virtual list control the attributes are managed by the main
|
// in the virtual list control the attributes are managed by the main
|
||||||
// program, so don't delete them
|
// program, so don't delete them
|
||||||
if ( !m_owner->IsVirtual() )
|
if ( !m_owner->IsVirtual() )
|
||||||
{
|
|
||||||
delete m_attr;
|
delete m_attr;
|
||||||
}
|
|
||||||
|
|
||||||
delete m_rect;
|
delete m_rect;
|
||||||
}
|
}
|
||||||
@@ -906,14 +883,10 @@ wxListItemData::wxListItemData(wxListMainWindow *owner)
|
|||||||
m_owner = owner;
|
m_owner = owner;
|
||||||
|
|
||||||
if ( owner->InReportView() )
|
if ( owner->InReportView() )
|
||||||
{
|
|
||||||
m_rect = NULL;
|
m_rect = NULL;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_rect = new wxRect;
|
m_rect = new wxRect;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void wxListItemData::SetItem( const wxListItem &info )
|
void wxListItemData::SetItem( const wxListItem &info )
|
||||||
{
|
{
|
||||||
@@ -998,10 +971,8 @@ void wxListItemData::GetItem( wxListItem &info ) const
|
|||||||
{
|
{
|
||||||
long mask = info.m_mask;
|
long mask = info.m_mask;
|
||||||
if ( !mask )
|
if ( !mask )
|
||||||
{
|
|
||||||
// by default, get everything for backwards compatibility
|
// by default, get everything for backwards compatibility
|
||||||
mask = -1;
|
mask = -1;
|
||||||
}
|
|
||||||
|
|
||||||
if ( mask & wxLIST_MASK_TEXT )
|
if ( mask & wxLIST_MASK_TEXT )
|
||||||
info.m_text = m_text;
|
info.m_text = m_text;
|
||||||
@@ -1144,13 +1115,9 @@ wxListLineData::wxListLineData( wxListMainWindow *owner )
|
|||||||
m_owner = owner;
|
m_owner = owner;
|
||||||
|
|
||||||
if ( InReportView() )
|
if ( InReportView() )
|
||||||
{
|
|
||||||
m_gi = NULL;
|
m_gi = NULL;
|
||||||
}
|
|
||||||
else // !report
|
else // !report
|
||||||
{
|
|
||||||
m_gi = new GeometryInfo;
|
m_gi = new GeometryInfo;
|
||||||
}
|
|
||||||
|
|
||||||
m_highlighted = false;
|
m_highlighted = false;
|
||||||
|
|
||||||
@@ -1255,6 +1222,7 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing )
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( _T("unknown mode") );
|
wxFAIL_MSG( _T("unknown mode") );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1322,6 +1290,7 @@ void wxListLineData::SetPosition( int x, int y, int spacing )
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( _T("unknown mode") );
|
wxFAIL_MSG( _T("unknown mode") );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1423,33 +1392,20 @@ bool wxListLineData::SetAttributes(wxDC *dc,
|
|||||||
// arithmetics on wxColour, unfortunately)
|
// arithmetics on wxColour, unfortunately)
|
||||||
wxColour colText;
|
wxColour colText;
|
||||||
if ( highlighted )
|
if ( highlighted )
|
||||||
{
|
|
||||||
colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||||
}
|
else if ( attr && attr->HasTextColour() )
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( attr && attr->HasTextColour() )
|
|
||||||
{
|
|
||||||
colText = attr->GetTextColour();
|
colText = attr->GetTextColour();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
colText = listctrl->GetForegroundColour();
|
colText = listctrl->GetForegroundColour();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dc->SetTextForeground(colText);
|
dc->SetTextForeground(colText);
|
||||||
|
|
||||||
// font
|
// font
|
||||||
wxFont font;
|
wxFont font;
|
||||||
if ( attr && attr->HasFont() )
|
if ( attr && attr->HasFont() )
|
||||||
{
|
|
||||||
font = attr->GetFont();
|
font = attr->GetFont();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
font = listctrl->GetFont();
|
font = listctrl->GetFont();
|
||||||
}
|
|
||||||
|
|
||||||
dc->SetFont(font);
|
dc->SetFont(font);
|
||||||
|
|
||||||
@@ -1458,13 +1414,9 @@ bool wxListLineData::SetAttributes(wxDC *dc,
|
|||||||
if ( highlighted || hasBgCol )
|
if ( highlighted || hasBgCol )
|
||||||
{
|
{
|
||||||
if ( highlighted )
|
if ( highlighted )
|
||||||
{
|
|
||||||
dc->SetBrush( *m_owner->GetHighlightBrush() );
|
dc->SetBrush( *m_owner->GetHighlightBrush() );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
dc->SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
|
dc->SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
|
||||||
}
|
|
||||||
|
|
||||||
dc->SetPen( *wxTRANSPARENT_PEN );
|
dc->SetPen( *wxTRANSPARENT_PEN );
|
||||||
|
|
||||||
@@ -1484,9 +1436,7 @@ void wxListLineData::Draw( wxDC *dc )
|
|||||||
wxListItemAttr *attr = GetAttr();
|
wxListItemAttr *attr = GetAttr();
|
||||||
|
|
||||||
if ( SetAttributes(dc, attr, highlighted) )
|
if ( SetAttributes(dc, attr, highlighted) )
|
||||||
{
|
|
||||||
dc->DrawRectangle( m_gi->m_rectHighlight );
|
dc->DrawRectangle( m_gi->m_rectHighlight );
|
||||||
}
|
|
||||||
|
|
||||||
// just for debugging to better see where the items are
|
// just for debugging to better see where the items are
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1495,7 +1445,7 @@ void wxListLineData::Draw( wxDC *dc )
|
|||||||
dc->DrawRectangle( m_gi->m_rectAll );
|
dc->DrawRectangle( m_gi->m_rectAll );
|
||||||
dc->SetPen(*wxGREEN_PEN);
|
dc->SetPen(*wxGREEN_PEN);
|
||||||
dc->DrawRectangle( m_gi->m_rectIcon );
|
dc->DrawRectangle( m_gi->m_rectIcon );
|
||||||
#endif // 0
|
#endif
|
||||||
|
|
||||||
wxListItemData *item = node->GetData();
|
wxListItemData *item = node->GetData();
|
||||||
if (item->HasImage())
|
if (item->HasImage())
|
||||||
@@ -1526,9 +1476,7 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
|
|||||||
// GetAttr() and move these lines into the loop below
|
// GetAttr() and move these lines into the loop below
|
||||||
wxListItemAttr *attr = GetAttr();
|
wxListItemAttr *attr = GetAttr();
|
||||||
if ( SetAttributes(dc, attr, highlighted) )
|
if ( SetAttributes(dc, attr, highlighted) )
|
||||||
{
|
|
||||||
dc->DrawRectangle( rectHL );
|
dc->DrawRectangle( rectHL );
|
||||||
}
|
|
||||||
|
|
||||||
wxCoord x = rect.x + HEADER_OFFSET_X,
|
wxCoord x = rect.x + HEADER_OFFSET_X,
|
||||||
y = rect.y + (LINE_SPACING + EXTRA_HEIGHT) / 2;
|
y = rect.y + (LINE_SPACING + EXTRA_HEIGHT) / 2;
|
||||||
@@ -1559,11 +1507,9 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
|
|||||||
wxDCClipper clipper(*dc, xOld, y, width - 8, rect.height);
|
wxDCClipper clipper(*dc, xOld, y, width - 8, rect.height);
|
||||||
|
|
||||||
if ( item->HasText() )
|
if ( item->HasText() )
|
||||||
{
|
|
||||||
DrawTextFormatted(dc, item->GetText(), col, xOld, y, width - 8);
|
DrawTextFormatted(dc, item->GetText(), col, xOld, y, width - 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void wxListLineData::DrawTextFormatted(wxDC *dc,
|
void wxListLineData::DrawTextFormatted(wxDC *dc,
|
||||||
const wxString &text,
|
const wxString &text,
|
||||||
@@ -1584,10 +1530,6 @@ void wxListLineData::DrawTextFormatted(wxDC *dc,
|
|||||||
m_owner->GetColumn(col, item);
|
m_owner->GetColumn(col, item);
|
||||||
switch ( item.GetAlign() )
|
switch ( item.GetAlign() )
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
wxFAIL_MSG( _T("unknown list item format") );
|
|
||||||
// fall through
|
|
||||||
|
|
||||||
case wxLIST_FORMAT_LEFT:
|
case wxLIST_FORMAT_LEFT:
|
||||||
// nothing to do
|
// nothing to do
|
||||||
break;
|
break;
|
||||||
@@ -1599,6 +1541,10 @@ void wxListLineData::DrawTextFormatted(wxDC *dc,
|
|||||||
case wxLIST_FORMAT_CENTER:
|
case wxLIST_FORMAT_CENTER:
|
||||||
x += (width - w) / 2;
|
x += (width - w) / 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( _T("unknown list item format") );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->DrawText(text, x, y);
|
dc->DrawText(text, x, y);
|
||||||
@@ -1749,11 +1695,9 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
|
m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
|
||||||
|
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
|
||||||
dc.SetTextForeground(GetForegroundColour());
|
dc.SetTextForeground(GetForegroundColour());
|
||||||
|
|
||||||
int x = HEADER_OFFSET_X;
|
int x = HEADER_OFFSET_X;
|
||||||
|
|
||||||
int numColumns = m_owner->GetColumnCount();
|
int numColumns = m_owner->GetColumnCount();
|
||||||
wxListItem item;
|
wxListItem item;
|
||||||
for ( int i = 0; i < numColumns && x < w; i++ )
|
for ( int i = 0; i < numColumns && x < w; i++ )
|
||||||
@@ -1770,6 +1714,7 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
int cw = wCol - 2;
|
int cw = wCol - 2;
|
||||||
int ch = h - 2;
|
int ch = h - 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxRendererNative::Get().DrawHeaderButton
|
wxRendererNative::Get().DrawHeaderButton
|
||||||
(
|
(
|
||||||
this,
|
this,
|
||||||
@@ -1789,8 +1734,7 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
|
|
||||||
// and the width of the icon, if any
|
// and the width of the icon, if any
|
||||||
static const int MARGIN_BETWEEN_TEXT_AND_ICON = 2;
|
static const int MARGIN_BETWEEN_TEXT_AND_ICON = 2;
|
||||||
int ix = 0, // init them just to suppress the compiler warnings
|
int ix = 0, iy = 0; // init them just to suppress the compiler warnings
|
||||||
iy = 0;
|
|
||||||
const int image = item.m_image;
|
const int image = item.m_image;
|
||||||
wxImageListType *imageList;
|
wxImageListType *imageList;
|
||||||
if ( image != -1 )
|
if ( image != -1 )
|
||||||
@@ -1828,7 +1772,6 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if we have an image, draw it on the right of the label
|
// if we have an image, draw it on the right of the label
|
||||||
if ( imageList )
|
if ( imageList )
|
||||||
{
|
{
|
||||||
@@ -2085,16 +2028,12 @@ bool wxListTextCtrl::AcceptChanges()
|
|||||||
const wxString value = GetValue();
|
const wxString value = GetValue();
|
||||||
|
|
||||||
if ( value == m_startValue )
|
if ( value == m_startValue )
|
||||||
{
|
|
||||||
// nothing changed, always accept
|
// nothing changed, always accept
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
|
if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
|
||||||
{
|
|
||||||
// vetoed by the user
|
// vetoed by the user
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// accepted, do rename the item
|
// accepted, do rename the item
|
||||||
m_owner->SetItemText(m_itemEdited, value);
|
m_owner->SetItemText(m_itemEdited, value);
|
||||||
@@ -2105,8 +2044,10 @@ bool wxListTextCtrl::AcceptChanges()
|
|||||||
void wxListTextCtrl::AcceptChangesAndFinish()
|
void wxListTextCtrl::AcceptChangesAndFinish()
|
||||||
{
|
{
|
||||||
m_aboutToFinish = true;
|
m_aboutToFinish = true;
|
||||||
|
|
||||||
// Notify the owner about the changes
|
// Notify the owner about the changes
|
||||||
AcceptChanges();
|
AcceptChanges();
|
||||||
|
|
||||||
// Even if vetoed, close the control (consistent with MSW)
|
// Even if vetoed, close the control (consistent with MSW)
|
||||||
Finish();
|
Finish();
|
||||||
}
|
}
|
||||||
@@ -2272,7 +2213,6 @@ wxListMainWindow::~wxListMainWindow()
|
|||||||
|
|
||||||
delete m_highlightBrush;
|
delete m_highlightBrush;
|
||||||
delete m_highlightUnfocusedBrush;
|
delete m_highlightUnfocusedBrush;
|
||||||
|
|
||||||
delete m_renameTimer;
|
delete m_renameTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2295,7 +2235,6 @@ void wxListMainWindow::CacheLineData(size_t line)
|
|||||||
wxListLineData *wxListMainWindow::GetDummyLine() const
|
wxListLineData *wxListMainWindow::GetDummyLine() const
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !IsEmpty(), _T("invalid line index") );
|
wxASSERT_MSG( !IsEmpty(), _T("invalid line index") );
|
||||||
|
|
||||||
wxASSERT_MSG( IsVirtual(), _T("GetDummyLine() shouldn't be called") );
|
wxASSERT_MSG( IsVirtual(), _T("GetDummyLine() shouldn't be called") );
|
||||||
|
|
||||||
wxListMainWindow *self = wxConstCast(this, wxListMainWindow);
|
wxListMainWindow *self = wxConstCast(this, wxListMainWindow);
|
||||||
@@ -2341,8 +2280,7 @@ wxCoord wxListMainWindow::GetLineHeight() const
|
|||||||
|
|
||||||
if ( m_small_image_list && m_small_image_list->GetImageCount() )
|
if ( m_small_image_list && m_small_image_list->GetImageCount() )
|
||||||
{
|
{
|
||||||
int iw = 0;
|
int iw = 0, ih = 0;
|
||||||
int ih = 0;
|
|
||||||
m_small_image_list->GetSize(0, iw, ih);
|
m_small_image_list->GetSize(0, iw, ih);
|
||||||
y = wxMax(y, ih);
|
y = wxMax(y, ih);
|
||||||
}
|
}
|
||||||
@@ -2481,12 +2419,10 @@ void wxListMainWindow::HighlightLines( size_t lineFrom,
|
|||||||
for ( size_t line = lineFrom; line <= lineTo; line++ )
|
for ( size_t line = lineFrom; line <= lineTo; line++ )
|
||||||
{
|
{
|
||||||
if ( HighlightLine(line, highlight) )
|
if ( HighlightLine(line, highlight) )
|
||||||
{
|
|
||||||
RefreshLine(line);
|
RefreshLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool wxListMainWindow::HighlightLine( size_t line, bool highlight )
|
bool wxListMainWindow::HighlightLine( size_t line, bool highlight )
|
||||||
{
|
{
|
||||||
@@ -2585,6 +2521,7 @@ void wxListMainWindow::RefreshAfter( size_t lineFrom )
|
|||||||
|
|
||||||
wxSize size = GetClientSize();
|
wxSize size = GetClientSize();
|
||||||
rect.width = size.x;
|
rect.width = size.x;
|
||||||
|
|
||||||
// refresh till the bottom of the window
|
// refresh till the bottom of the window
|
||||||
rect.height = size.y - rect.y;
|
rect.height = size.y - rect.y;
|
||||||
|
|
||||||
@@ -2614,19 +2551,15 @@ void wxListMainWindow::RefreshSelected()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( HasCurrent() && m_current >= from && m_current <= to )
|
if ( HasCurrent() && m_current >= from && m_current <= to )
|
||||||
{
|
|
||||||
RefreshLine(m_current);
|
RefreshLine(m_current);
|
||||||
}
|
|
||||||
|
|
||||||
for ( size_t line = from; line <= to; line++ )
|
for ( size_t line = from; line <= to; line++ )
|
||||||
{
|
{
|
||||||
// NB: the test works as expected even if m_current == -1
|
// NB: the test works as expected even if m_current == -1
|
||||||
if ( line != m_current && IsHighlighted(line) )
|
if ( line != m_current && IsHighlighted(line) )
|
||||||
{
|
|
||||||
RefreshLine(line);
|
RefreshLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void wxListMainWindow::Freeze()
|
void wxListMainWindow::Freeze()
|
||||||
{
|
{
|
||||||
@@ -2638,10 +2571,8 @@ void wxListMainWindow::Thaw()
|
|||||||
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") );
|
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") );
|
||||||
|
|
||||||
if ( !--m_freezeCount )
|
if ( !--m_freezeCount )
|
||||||
{
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
@@ -2650,16 +2581,12 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
wxPaintDC dc( this );
|
wxPaintDC dc( this );
|
||||||
|
|
||||||
if ( IsEmpty() || m_freezeCount )
|
if ( IsEmpty() || m_freezeCount )
|
||||||
{
|
|
||||||
// nothing to draw or not the moment to draw it
|
// nothing to draw or not the moment to draw it
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_dirty )
|
if ( m_dirty )
|
||||||
{
|
|
||||||
// delay the repainting until we calculate all the items positions
|
// delay the repainting until we calculate all the items positions
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
PrepareDC( dc );
|
PrepareDC( dc );
|
||||||
|
|
||||||
@@ -2737,14 +2664,14 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
if ( HasFlag(wxLC_VRULES) && !IsEmpty() )
|
if ( HasFlag(wxLC_VRULES) && !IsEmpty() )
|
||||||
{
|
{
|
||||||
wxPen pen(GetRuleColour(), 1, wxSOLID);
|
wxPen pen(GetRuleColour(), 1, wxSOLID);
|
||||||
|
wxRect firstItemRect, lastItemRect;
|
||||||
|
|
||||||
wxRect firstItemRect;
|
|
||||||
wxRect lastItemRect;
|
|
||||||
GetItemRect(visibleFrom, firstItemRect);
|
GetItemRect(visibleFrom, firstItemRect);
|
||||||
GetItemRect(visibleTo, lastItemRect);
|
GetItemRect(visibleTo, lastItemRect);
|
||||||
int x = firstItemRect.GetX();
|
int x = firstItemRect.GetX();
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
dc.SetBrush(* wxTRANSPARENT_BRUSH);
|
dc.SetBrush(* wxTRANSPARENT_BRUSH);
|
||||||
|
|
||||||
for (int col = 0; col < GetColumnCount(); col++)
|
for (int col = 0; col < GetColumnCount(); col++)
|
||||||
{
|
{
|
||||||
int colWidth = GetColumnWidth(col);
|
int colWidth = GetColumnWidth(col);
|
||||||
@@ -2783,7 +2710,7 @@ void wxListMainWindow::HighlightAll( bool on )
|
|||||||
{
|
{
|
||||||
if ( IsSingleSel() )
|
if ( IsSingleSel() )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !on, _T("can't do this in a single sel control") );
|
wxASSERT_MSG( !on, _T("can't do this in a single selection control") );
|
||||||
|
|
||||||
// we just have one item to turn off
|
// we just have one item to turn off
|
||||||
if ( HasCurrent() && IsHighlighted(m_current) )
|
if ( HasCurrent() && IsHighlighted(m_current) )
|
||||||
@@ -2847,11 +2774,10 @@ void wxListMainWindow::EditLabel( long item )
|
|||||||
wxListLineData *data = GetLine(itemEdit);
|
wxListLineData *data = GetLine(itemEdit);
|
||||||
wxCHECK_RET( data, _T("invalid index in EditLabel()") );
|
wxCHECK_RET( data, _T("invalid index in EditLabel()") );
|
||||||
data->GetItem( 0, le.m_item );
|
data->GetItem( 0, le.m_item );
|
||||||
|
|
||||||
if ( GetParent()->GetEventHandler()->ProcessEvent( le ) && !le.IsAllowed() )
|
if ( GetParent()->GetEventHandler()->ProcessEvent( le ) && !le.IsAllowed() )
|
||||||
{
|
|
||||||
// vetoed by user code
|
// vetoed by user code
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// We have to call this here because the label in question might just have
|
// We have to call this here because the label in question might just have
|
||||||
// been added and no screen update taken place.
|
// been added and no screen update taken place.
|
||||||
@@ -2876,6 +2802,7 @@ bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value)
|
|||||||
le.m_itemIndex = itemEdit;
|
le.m_itemIndex = itemEdit;
|
||||||
|
|
||||||
wxListLineData *data = GetLine(itemEdit);
|
wxListLineData *data = GetLine(itemEdit);
|
||||||
|
|
||||||
wxCHECK_MSG( data, false, _T("invalid index in OnRenameAccept()") );
|
wxCHECK_MSG( data, false, _T("invalid index in OnRenameAccept()") );
|
||||||
|
|
||||||
data->GetItem( 0, le.m_item );
|
data->GetItem( 0, le.m_item );
|
||||||
@@ -2898,7 +2825,6 @@ void wxListMainWindow::OnRenameCancelled(size_t itemEdit)
|
|||||||
wxCHECK_RET( data, _T("invalid index in OnRenameCancelled()") );
|
wxCHECK_RET( data, _T("invalid index in OnRenameCancelled()") );
|
||||||
|
|
||||||
data->GetItem( 0, le.m_item );
|
data->GetItem( 0, le.m_item );
|
||||||
|
|
||||||
GetEventHandler()->ProcessEvent( le );
|
GetEventHandler()->ProcessEvent( le );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2908,11 +2834,9 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
// On wxMac we can't depend on the EVT_KILL_FOCUS event to properly
|
// On wxMac we can't depend on the EVT_KILL_FOCUS event to properly
|
||||||
// shutdown the edit control when the mouse is clicked elsewhere on the
|
// shutdown the edit control when the mouse is clicked elsewhere on the
|
||||||
// listctrl because the order of events is different (or something like
|
// listctrl because the order of events is different (or something like
|
||||||
// that,) so explicitly end the edit if it is active.
|
// that), so explicitly end the edit if it is active.
|
||||||
if ( event.LeftDown() && m_textctrl)
|
if ( event.LeftDown() && m_textctrl)
|
||||||
{
|
|
||||||
m_textctrl->AcceptChangesAndFinish();
|
m_textctrl->AcceptChangesAndFinish();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
event.SetEventObject( GetParent() );
|
event.SetEventObject( GetParent() );
|
||||||
@@ -3029,6 +2953,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
HighlightAll( false );
|
HighlightAll( false );
|
||||||
ReverseHighlight(m_lineSelectSingleOnUp);
|
ReverseHighlight(m_lineSelectSingleOnUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_lastOnSame)
|
if (m_lastOnSame)
|
||||||
{
|
{
|
||||||
if ((current == m_current) &&
|
if ((current == m_current) &&
|
||||||
@@ -3038,6 +2963,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
m_renameTimer->Start( 100, true );
|
m_renameTimer->Start( 100, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastOnSame = false;
|
m_lastOnSame = false;
|
||||||
m_lineSelectSingleOnUp = (size_t)-1;
|
m_lineSelectSingleOnUp = (size_t)-1;
|
||||||
}
|
}
|
||||||
@@ -3053,6 +2979,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
{
|
{
|
||||||
m_lineBeforeLastClicked = m_lineLastClicked;
|
m_lineBeforeLastClicked = m_lineLastClicked;
|
||||||
m_lineLastClicked = current;
|
m_lineLastClicked = current;
|
||||||
|
|
||||||
// If the item is already selected, do not update the selection.
|
// If the item is already selected, do not update the selection.
|
||||||
// Multi-selections should not be cleared if a selected item is clicked.
|
// Multi-selections should not be cleared if a selected item is clicked.
|
||||||
if (!IsHighlighted(current))
|
if (!IsHighlighted(current))
|
||||||
@@ -3061,8 +2988,9 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
ChangeCurrent(current);
|
ChangeCurrent(current);
|
||||||
ReverseHighlight(m_current);
|
ReverseHighlight(m_current);
|
||||||
}
|
}
|
||||||
SendNotify( current, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
|
|
||||||
event.GetPosition() );
|
SendNotify( current, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, event.GetPosition() );
|
||||||
|
|
||||||
// Allow generation of context menu event
|
// Allow generation of context menu event
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
@@ -3126,9 +3054,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_current != oldCurrent)
|
if (m_current != oldCurrent)
|
||||||
{
|
|
||||||
RefreshLine( oldCurrent );
|
RefreshLine( oldCurrent );
|
||||||
}
|
|
||||||
|
|
||||||
// forceClick is only set if the previous click was on another item
|
// forceClick is only set if the previous click was on another item
|
||||||
m_lastOnSame = !forceClick && (m_current == oldCurrent) && oldWasSelected;
|
m_lastOnSame = !forceClick && (m_current == oldCurrent) && oldWasSelected;
|
||||||
@@ -3152,8 +3078,8 @@ void wxListMainWindow::MoveToItem(size_t item)
|
|||||||
|
|
||||||
if ( InReportView() )
|
if ( InReportView() )
|
||||||
{
|
{
|
||||||
// the next we need the range of lines shown it might be different, so
|
// the next we need the range of lines shown it might be different,
|
||||||
// recalculate it
|
// so recalculate it
|
||||||
ResetVisibleLinesRange();
|
ResetVisibleLinesRange();
|
||||||
|
|
||||||
if (rect.y < view_y)
|
if (rect.y < view_y)
|
||||||
@@ -3225,7 +3151,7 @@ void wxListMainWindow::OnKeyDown( wxKeyEvent &event )
|
|||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
/* we propagate the key event up */
|
// propagate the key event upwards
|
||||||
wxKeyEvent ke( wxEVT_KEY_DOWN );
|
wxKeyEvent ke( wxEVT_KEY_DOWN );
|
||||||
ke.m_shiftDown = event.m_shiftDown;
|
ke.m_shiftDown = event.m_shiftDown;
|
||||||
ke.m_controlDown = event.m_controlDown;
|
ke.m_controlDown = event.m_controlDown;
|
||||||
@@ -3244,7 +3170,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
/* we send a list_key event up */
|
// send a list_key event up
|
||||||
if ( HasCurrent() )
|
if ( HasCurrent() )
|
||||||
{
|
{
|
||||||
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() );
|
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() );
|
||||||
@@ -3255,7 +3181,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
parent->GetEventHandler()->ProcessEvent( le );
|
parent->GetEventHandler()->ProcessEvent( le );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we propagate the char event up */
|
// propagate the char event upwards
|
||||||
wxKeyEvent ke( wxEVT_CHAR );
|
wxKeyEvent ke( wxEVT_CHAR );
|
||||||
ke.m_shiftDown = event.m_shiftDown;
|
ke.m_shiftDown = event.m_shiftDown;
|
||||||
ke.m_controlDown = event.m_controlDown;
|
ke.m_controlDown = event.m_controlDown;
|
||||||
@@ -3278,7 +3204,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no item -> nothing to do */
|
// no item -> nothing to do
|
||||||
if (!HasCurrent())
|
if (!HasCurrent())
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
@@ -3419,6 +3345,7 @@ void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
|
|||||||
if ( GetParent()->GetEventHandler()->ProcessEvent( event) )
|
if ( GetParent()->GetEventHandler()->ProcessEvent( event) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hasFocus = false;
|
m_hasFocus = false;
|
||||||
RefreshSelected();
|
RefreshSelected();
|
||||||
}
|
}
|
||||||
@@ -3484,12 +3411,10 @@ void wxListMainWindow::SetImageList( wxImageListType *imageList, int which )
|
|||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
|
||||||
// calc the spacing from the icon size
|
// calc the spacing from the icon size
|
||||||
int width = 0,
|
int width = 0, height = 0;
|
||||||
height = 0;
|
|
||||||
if ((imageList) && (imageList->GetImageCount()) )
|
if ((imageList) && (imageList->GetImageCount()) )
|
||||||
{
|
|
||||||
imageList->GetSize(0, width, height);
|
imageList->GetSize(0, width, height);
|
||||||
}
|
|
||||||
|
|
||||||
if (which == wxIMAGE_LIST_NORMAL)
|
if (which == wxIMAGE_LIST_NORMAL)
|
||||||
{
|
{
|
||||||
@@ -3509,14 +3434,10 @@ void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall )
|
|||||||
{
|
{
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
if (isSmall)
|
if (isSmall)
|
||||||
{
|
|
||||||
m_small_spacing = spacing;
|
m_small_spacing = spacing;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_normal_spacing = spacing;
|
m_normal_spacing = spacing;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int wxListMainWindow::GetItemSpacing( bool isSmall )
|
int wxListMainWindow::GetItemSpacing( bool isSmall )
|
||||||
{
|
{
|
||||||
@@ -3888,9 +3809,7 @@ int wxListMainWindow::GetSelectedItemCount() const
|
|||||||
{
|
{
|
||||||
// deal with the quick case first
|
// deal with the quick case first
|
||||||
if ( IsSingleSel() )
|
if ( IsSingleSel() )
|
||||||
{
|
|
||||||
return HasCurrent() ? IsHighlighted(m_current) : false;
|
return HasCurrent() ? IsHighlighted(m_current) : false;
|
||||||
}
|
|
||||||
|
|
||||||
// virtual controls remmebers all its selections itself
|
// virtual controls remmebers all its selections itself
|
||||||
if ( IsVirtual() )
|
if ( IsVirtual() )
|
||||||
@@ -3919,8 +3838,7 @@ wxRect wxListMainWindow::GetViewRect() const
|
|||||||
_T("wxListCtrl::GetViewRect() only works in icon mode") );
|
_T("wxListCtrl::GetViewRect() only works in icon mode") );
|
||||||
|
|
||||||
// we need to find the longest/tallest label
|
// we need to find the longest/tallest label
|
||||||
wxCoord xMax = 0,
|
wxCoord xMax = 0, yMax = 0;
|
||||||
yMax = 0;
|
|
||||||
const int count = GetItemCount();
|
const int count = GetItemCount();
|
||||||
if ( count )
|
if ( count )
|
||||||
{
|
{
|
||||||
@@ -4084,7 +4002,6 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetScrollbars
|
SetScrollbars
|
||||||
(
|
(
|
||||||
SCROLL_UNIT_X,
|
SCROLL_UNIT_X,
|
||||||
@@ -4204,10 +4121,8 @@ void wxListMainWindow::RefreshAll()
|
|||||||
void wxListMainWindow::UpdateCurrent()
|
void wxListMainWindow::UpdateCurrent()
|
||||||
{
|
{
|
||||||
if ( !HasCurrent() && !IsEmpty() )
|
if ( !HasCurrent() && !IsEmpty() )
|
||||||
{
|
|
||||||
ChangeCurrent(0);
|
ChangeCurrent(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
long wxListMainWindow::GetNextItem( long item,
|
long wxListMainWindow::GetNextItem( long item,
|
||||||
int WXUNUSED(geometry),
|
int WXUNUSED(geometry),
|
||||||
@@ -4223,17 +4138,13 @@ long wxListMainWindow::GetNextItem( long item,
|
|||||||
// all selected items
|
// all selected items
|
||||||
ret++;
|
ret++;
|
||||||
if ( ret == max )
|
if ( ret == max )
|
||||||
{
|
// this is not an error because the index was OK initially,
|
||||||
// this is not an error because the index was ok initially, just no
|
// just no such item
|
||||||
// such item
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if ( !state )
|
if ( !state )
|
||||||
{
|
|
||||||
// any will do
|
// any will do
|
||||||
return (size_t)ret;
|
return (size_t)ret;
|
||||||
}
|
|
||||||
|
|
||||||
size_t count = GetItemCount();
|
size_t count = GetItemCount();
|
||||||
for ( size_t line = (size_t)ret; line < count; line++ )
|
for ( size_t line = (size_t)ret; line < count; line++ )
|
||||||
@@ -4268,10 +4179,8 @@ void wxListMainWindow::DeleteItem( long lindex )
|
|||||||
// become selected - unless there is no next one - so don't adjust
|
// become selected - unless there is no next one - so don't adjust
|
||||||
// m_current in this case
|
// m_current in this case
|
||||||
if ( m_current != index || m_current == count - 1 )
|
if ( m_current != index || m_current == count - 1 )
|
||||||
{
|
|
||||||
m_current--;
|
m_current--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( InReportView() )
|
if ( InReportView() )
|
||||||
{
|
{
|
||||||
@@ -4301,7 +4210,6 @@ void wxListMainWindow::DeleteItem( long lindex )
|
|||||||
if ( IsVirtual() )
|
if ( IsVirtual() )
|
||||||
{
|
{
|
||||||
m_countVirt--;
|
m_countVirt--;
|
||||||
|
|
||||||
m_selStore.OnItemDelete(index);
|
m_selStore.OnItemDelete(index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -4352,10 +4260,8 @@ void wxListMainWindow::DeleteColumn( int col )
|
|||||||
void wxListMainWindow::DoDeleteAllItems()
|
void wxListMainWindow::DoDeleteAllItems()
|
||||||
{
|
{
|
||||||
if ( IsEmpty() )
|
if ( IsEmpty() )
|
||||||
{
|
|
||||||
// nothing to do - in particular, don't send the event
|
// nothing to do - in particular, don't send the event
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
ResetCurrent();
|
ResetCurrent();
|
||||||
|
|
||||||
@@ -4371,7 +4277,6 @@ void wxListMainWindow::DoDeleteAllItems()
|
|||||||
if ( IsVirtual() )
|
if ( IsVirtual() )
|
||||||
{
|
{
|
||||||
m_countVirt = 0;
|
m_countVirt = 0;
|
||||||
|
|
||||||
m_selStore.Clear();
|
m_selStore.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4414,9 +4319,7 @@ void wxListMainWindow::EnsureVisible( long index )
|
|||||||
// We have to call this here because the label in question might just have
|
// We have to call this here because the label in question might just have
|
||||||
// been added and its position is not known yet
|
// been added and its position is not known yet
|
||||||
if ( m_dirty )
|
if ( m_dirty )
|
||||||
{
|
|
||||||
RecalculatePositions(true /* no refresh */);
|
RecalculatePositions(true /* no refresh */);
|
||||||
}
|
|
||||||
|
|
||||||
MoveToItem((size_t)index);
|
MoveToItem((size_t)index);
|
||||||
}
|
}
|
||||||
@@ -4467,6 +4370,7 @@ long wxListMainWindow::FindItem( const wxPoint& pt )
|
|||||||
GetItemPosition( GetItemCount() - 1, p );
|
GetItemPosition( GetItemCount() - 1, p );
|
||||||
if ( p.y == 0 )
|
if ( p.y == 0 )
|
||||||
return topItem;
|
return topItem;
|
||||||
|
|
||||||
long id = (long)floor( pt.y * double(GetItemCount() - topItem - 1) / p.y + topItem );
|
long id = (long)floor( pt.y * double(GetItemCount() - topItem - 1) / p.y + topItem );
|
||||||
if ( id >= 0 && id < (long)GetItemCount() )
|
if ( id >= 0 && id < (long)GetItemCount() )
|
||||||
return id;
|
return id;
|
||||||
@@ -4547,9 +4451,7 @@ void wxListMainWindow::InsertItem( wxListItem &item )
|
|||||||
// increment the member variables because the current row's index has gone
|
// increment the member variables because the current row's index has gone
|
||||||
// up by one
|
// up by one
|
||||||
if ( HasCurrent() && m_current >= id )
|
if ( HasCurrent() && m_current >= id )
|
||||||
{
|
|
||||||
m_current++;
|
m_current++;
|
||||||
}
|
|
||||||
|
|
||||||
SendNotify(id, wxEVT_COMMAND_LIST_INSERT_ITEM);
|
SendNotify(id, wxEVT_COMMAND_LIST_INSERT_ITEM);
|
||||||
|
|
||||||
@@ -4775,6 +4677,7 @@ void wxGenericListCtrl::CalculateAndSetHeaderHeight()
|
|||||||
m_headerWin->GetTextExtent(wxT("Hg"), &w, &h, &d);
|
m_headerWin->GetTextExtent(wxT("Hg"), &w, &h, &d);
|
||||||
h += d + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT;
|
h += d + 2 * HEADER_OFFSET_Y + EXTRA_HEIGHT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// only update if changed
|
// only update if changed
|
||||||
if ( h != m_headerHeight )
|
if ( h != m_headerHeight )
|
||||||
{
|
{
|
||||||
@@ -4842,9 +4745,11 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
|
|||||||
SetFont( font );
|
SetFont( font );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( InReportView() )
|
if ( InReportView() )
|
||||||
{
|
{
|
||||||
CreateHeaderWindow();
|
CreateHeaderWindow();
|
||||||
|
|
||||||
#ifdef __WXMAC_CARBON__
|
#ifdef __WXMAC_CARBON__
|
||||||
if (m_headerWin)
|
if (m_headerWin)
|
||||||
{
|
{
|
||||||
@@ -4854,12 +4759,11 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
|
|||||||
CalculateAndSetHeaderHeight();
|
CalculateAndSetHeaderHeight();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( HasFlag(wxLC_NO_HEADER) )
|
if ( HasFlag(wxLC_NO_HEADER) )
|
||||||
{
|
|
||||||
// VZ: why do we create it at all then?
|
// VZ: why do we create it at all then?
|
||||||
m_headerWin->Show( false );
|
m_headerWin->Show( false );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SetBestSize(size);
|
SetBestSize(size);
|
||||||
|
|
||||||
@@ -4884,13 +4788,9 @@ void wxGenericListCtrl::SetSingleStyle( long style, bool add )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (add)
|
if (add)
|
||||||
{
|
|
||||||
flag |= style;
|
flag |= style;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
flag &= ~style;
|
flag &= ~style;
|
||||||
}
|
|
||||||
|
|
||||||
SetWindowStyleFlag( flag );
|
SetWindowStyleFlag( flag );
|
||||||
}
|
}
|
||||||
@@ -4987,7 +4887,8 @@ long wxGenericListCtrl::SetItem( long index, int col, const wxString& label, int
|
|||||||
{
|
{
|
||||||
info.m_image = imageId;
|
info.m_image = imageId;
|
||||||
info.m_mask |= wxLIST_MASK_IMAGE;
|
info.m_mask |= wxLIST_MASK_IMAGE;
|
||||||
};
|
}
|
||||||
|
|
||||||
m_mainWin->SetItem(info);
|
m_mainWin->SetItem(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5172,17 +5073,12 @@ long wxGenericListCtrl::GetNextItem( long item, int geom, int state ) const
|
|||||||
wxImageListType *wxGenericListCtrl::GetImageList(int which) const
|
wxImageListType *wxGenericListCtrl::GetImageList(int which) const
|
||||||
{
|
{
|
||||||
if (which == wxIMAGE_LIST_NORMAL)
|
if (which == wxIMAGE_LIST_NORMAL)
|
||||||
{
|
|
||||||
return m_imageListNormal;
|
return m_imageListNormal;
|
||||||
}
|
|
||||||
else if (which == wxIMAGE_LIST_SMALL)
|
else if (which == wxIMAGE_LIST_SMALL)
|
||||||
{
|
|
||||||
return m_imageListSmall;
|
return m_imageListSmall;
|
||||||
}
|
|
||||||
else if (which == wxIMAGE_LIST_STATE)
|
else if (which == wxIMAGE_LIST_STATE)
|
||||||
{
|
|
||||||
return m_imageListState;
|
return m_imageListState;
|
||||||
}
|
|
||||||
return (wxImageListType *) NULL;
|
return (wxImageListType *) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5190,19 +5086,22 @@ void wxGenericListCtrl::SetImageList( wxImageListType *imageList, int which )
|
|||||||
{
|
{
|
||||||
if ( which == wxIMAGE_LIST_NORMAL )
|
if ( which == wxIMAGE_LIST_NORMAL )
|
||||||
{
|
{
|
||||||
if (m_ownsImageListNormal) delete m_imageListNormal;
|
if (m_ownsImageListNormal)
|
||||||
|
delete m_imageListNormal;
|
||||||
m_imageListNormal = imageList;
|
m_imageListNormal = imageList;
|
||||||
m_ownsImageListNormal = false;
|
m_ownsImageListNormal = false;
|
||||||
}
|
}
|
||||||
else if ( which == wxIMAGE_LIST_SMALL )
|
else if ( which == wxIMAGE_LIST_SMALL )
|
||||||
{
|
{
|
||||||
if (m_ownsImageListSmall) delete m_imageListSmall;
|
if (m_ownsImageListSmall)
|
||||||
|
delete m_imageListSmall;
|
||||||
m_imageListSmall = imageList;
|
m_imageListSmall = imageList;
|
||||||
m_ownsImageListSmall = false;
|
m_ownsImageListSmall = false;
|
||||||
}
|
}
|
||||||
else if ( which == wxIMAGE_LIST_STATE )
|
else if ( which == wxIMAGE_LIST_STATE )
|
||||||
{
|
{
|
||||||
if (m_ownsImageListState) delete m_imageListState;
|
if (m_ownsImageListState)
|
||||||
|
delete m_imageListState;
|
||||||
m_imageListState = imageList;
|
m_imageListState = imageList;
|
||||||
m_ownsImageListState = false;
|
m_ownsImageListState = false;
|
||||||
}
|
}
|
||||||
@@ -5243,7 +5142,6 @@ bool wxGenericListCtrl::DeleteAllColumns()
|
|||||||
size_t count = m_mainWin->m_columns.GetCount();
|
size_t count = m_mainWin->m_columns.GetCount();
|
||||||
for ( size_t n = 0; n < count; n++ )
|
for ( size_t n = 0; n < count; n++ )
|
||||||
DeleteColumn( 0 );
|
DeleteColumn( 0 );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5258,10 +5156,7 @@ bool wxGenericListCtrl::DeleteColumn( int col )
|
|||||||
|
|
||||||
// if we don't have the header any longer, we need to relayout the window
|
// if we don't have the header any longer, we need to relayout the window
|
||||||
if ( !GetColumnCount() )
|
if ( !GetColumnCount() )
|
||||||
{
|
|
||||||
ResizeReportView(false /* no header */);
|
ResizeReportView(false /* no header */);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5337,12 +5232,10 @@ long wxGenericListCtrl::InsertColumn( long col, wxListItem &item )
|
|||||||
|
|
||||||
m_mainWin->InsertColumn( col, item );
|
m_mainWin->InsertColumn( col, item );
|
||||||
|
|
||||||
// if we hadn't had header before and have it now we need to relayout the
|
// if we hadn't had a header before but have one now
|
||||||
// window
|
// then we need to relayout the window
|
||||||
if ( GetColumnCount() == 1 && m_mainWin->HasHeader() )
|
if ( GetColumnCount() == 1 && m_mainWin->HasHeader() )
|
||||||
{
|
|
||||||
ResizeReportView(true /* have header */);
|
ResizeReportView(true /* have header */);
|
||||||
}
|
|
||||||
|
|
||||||
m_headerWin->Refresh();
|
m_headerWin->Refresh();
|
||||||
|
|
||||||
@@ -5360,6 +5253,7 @@ long wxGenericListCtrl::InsertColumn( long col, const wxString &heading,
|
|||||||
item.m_mask |= wxLIST_MASK_WIDTH;
|
item.m_mask |= wxLIST_MASK_WIDTH;
|
||||||
item.m_width = width;
|
item.m_width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.m_format = format;
|
item.m_format = format;
|
||||||
|
|
||||||
return InsertColumn( col, item );
|
return InsertColumn( col, item );
|
||||||
@@ -5396,7 +5290,6 @@ void wxGenericListCtrl::OnSize(wxSizeEvent& WXUNUSED(event))
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ResizeReportView(m_mainWin->HasHeader());
|
ResizeReportView(m_mainWin->HasHeader());
|
||||||
|
|
||||||
m_mainWin->RecalculatePositions();
|
m_mainWin->RecalculatePositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5454,9 +5347,7 @@ bool wxGenericListCtrl::SetForegroundColour( const wxColour &colour )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_headerWin)
|
if (m_headerWin)
|
||||||
{
|
|
||||||
m_headerWin->SetForegroundColour( colour );
|
m_headerWin->SetForegroundColour( colour );
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5483,8 +5374,6 @@ bool wxGenericListCtrl::SetFont( const wxFont &font )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if _USE_VISATTR
|
#if _USE_VISATTR
|
||||||
#include "wx/listbox.h"
|
#include "wx/listbox.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -5522,7 +5411,7 @@ wxDropTarget *wxGenericListCtrl::GetDropTarget() const
|
|||||||
return m_mainWin->GetDropTarget();
|
return m_mainWin->GetDropTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif
|
||||||
|
|
||||||
bool wxGenericListCtrl::SetCursor( const wxCursor &cursor )
|
bool wxGenericListCtrl::SetCursor( const wxCursor &cursor )
|
||||||
{
|
{
|
||||||
@@ -5545,13 +5434,13 @@ bool wxGenericListCtrl::DoPopupMenu( wxMenu *menu, int x, int y )
|
|||||||
return m_mainWin->PopupMenu( menu, x, y );
|
return m_mainWin->PopupMenu( menu, x, y );
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // wxUSE_MENUS
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericListCtrl::SetFocus()
|
void wxGenericListCtrl::SetFocus()
|
||||||
{
|
{
|
||||||
/* The test in window.cpp fails as we are a composite
|
// The test in window.cpp fails as we are a composite
|
||||||
window, so it checks against "this", but not m_mainWin. */
|
// window, so it checks against "this", but not m_mainWin.
|
||||||
if ( DoFindFocus() != this )
|
if ( DoFindFocus() != this )
|
||||||
m_mainWin->SetFocus();
|
m_mainWin->SetFocus();
|
||||||
}
|
}
|
||||||
@@ -5581,7 +5470,8 @@ int wxGenericListCtrl::OnGetItemImage(long WXUNUSED(item)) const
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
|
wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
|
||||||
-1,
|
-1,
|
||||||
wxT("List control has an image list, OnGetItemImage should be overridden."));
|
wxT("List control has an image list: OnGetItemImage should be overridden."));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5612,13 +5502,12 @@ void wxGenericListCtrl::RefreshItems(long itemFrom, long itemTo)
|
|||||||
m_mainWin->RefreshLines(itemFrom, itemTo);
|
m_mainWin->RefreshLines(itemFrom, itemTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Generic wxListCtrl is more or less a container for two other
|
||||||
* Generic wxListCtrl is more or less a container for two other
|
// windows which drawings are done upon. These are namely
|
||||||
* windows which drawings are done upon. These are namely
|
// 'm_headerWin' and 'm_mainWin'.
|
||||||
* 'm_headerWin' and 'm_mainWin'.
|
// Here we override 'virtual wxWindow::Refresh()' to mimic the
|
||||||
* Here we override 'virtual wxWindow::Refresh()' to mimic the
|
// behaviour wxListCtrl has under wxMSW.
|
||||||
* behaviour wxListCtrl has under wxMSW.
|
//
|
||||||
*/
|
|
||||||
void wxGenericListCtrl::Refresh(bool eraseBackground, const wxRect *rect)
|
void wxGenericListCtrl::Refresh(bool eraseBackground, const wxRect *rect)
|
||||||
{
|
{
|
||||||
if (!rect)
|
if (!rect)
|
||||||
|
Reference in New Issue
Block a user