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