#endif // HAVE_NATIVE_LISTCTRL/!HAVE_NATIVE_LISTCTRL
#include "wx/selstore.h"
-
#include "wx/renderer.h"
+#include "wx/math.h"
#ifdef __WXMAC__
#include "wx/mac/private.h"
#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
+
+
// ----------------------------------------------------------------------------
// events
// ----------------------------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
+#if WXWIN_COMPATIBILITY_2_4
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
+#endif
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
// private classes
// ============================================================================
+//-----------------------------------------------------------------------------
+// wxColWidthInfo (internal)
+//-----------------------------------------------------------------------------
+
+struct wxColWidthInfo
+{
+ int nMaxWidth;
+ bool bNeedsUpdate; // only set to true when an item whose
+ // width == nMaxWidth is removed
+
+ wxColWidthInfo(int w = 0, bool needsUpdate = false)
+ {
+ nMaxWidth = w;
+ bNeedsUpdate = needsUpdate;
+ }
+};
+
+WX_DEFINE_ARRAY_PTR(wxColWidthInfo *, ColWidthArray);
+
//-----------------------------------------------------------------------------
// wxListItemData (internal)
//-----------------------------------------------------------------------------
void SetItem( const wxListItem &info );
void SetImage( int image ) { m_image = image; }
- void SetData( long data ) { m_data = data; }
+ void SetData( wxUIntPtr data ) { m_data = data; }
void SetPosition( int x, int y );
void SetSize( int width, int height );
int m_image;
// user data associated with the item
- long m_data;
+ 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
// the part to be highlighted
wxRect m_rectHighlight;
- // extend all our rects to be centered inside theo ne of given width
+ // extend all our rects to be centered inside the one of given width
void ExtendWidth(wxCoord w)
{
wxASSERT_MSG( m_rectAll.width <= w,
wxString m_startValue;
size_t m_itemEdited;
bool m_finished;
+ bool m_aboutToFinish;
DECLARE_EVENT_TABLE()
};
virtual ~wxListMainWindow();
+ wxWindow *GetMainWindowOfCompositeControl() { return GetParent(); }
+
bool HasFlag(int flag) const { return m_parent->HasFlag(flag); }
// return true if this is a virtual list control
// all these functions only do something if the line is currently visible
- // change the line "selected" state, return TRUE if it really changed
- bool HighlightLine( size_t line, bool highlight = TRUE);
+ // change the line "selected" state, return true if it really changed
+ bool HighlightLine( size_t line, bool highlight = true);
// as HighlightLine() but do it for the range of lines: this is incredibly
// more efficient for virtual list controls!
//
// NB: unlike HighlightLine() this one does refresh the lines on screen
- void HighlightLines( size_t lineFrom, size_t lineTo, bool on = TRUE );
+ void HighlightLines( size_t lineFrom, size_t lineTo, bool on = true );
// toggle the line state and refresh it
void ReverseHighlight( size_t line )
void Freeze();
void Thaw();
- void SetFocus();
-
void OnRenameTimer();
bool OnRenameAccept(size_t itemEdit, const wxString& value);
void OnRenameCancelled(size_t itemEdit);
int GetTextLength( const wxString &s ) const;
void SetImageList( wxImageListType *imageList, int which );
- void SetItemSpacing( int spacing, bool isSmall = FALSE );
- int GetItemSpacing( bool isSmall = FALSE );
+ void SetItemSpacing( int spacing, bool isSmall = false );
+ int GetItemSpacing( bool isSmall = false );
void SetColumn( int col, wxListItem &item );
void SetColumnWidth( int col, int width );
void SetItem( wxListItem &item );
void GetItem( wxListItem &item ) const;
void SetItemState( long item, long state, long stateMask );
+ void SetItemStateAll( long state, long stateMask );
int GetItemState( long item, long stateMask ) const;
void GetItemRect( long index, wxRect &rect ) const;
wxRect GetViewRect() const;
}
// set the scrollbars and update the positions of the items
- void RecalculatePositions(bool noRefresh = FALSE);
+ void RecalculatePositions(bool noRefresh = false);
// refresh the window and the header
void RefreshAll();
void DeleteColumn( int col );
void DeleteEverything();
void EnsureVisible( long index );
- long FindItem( long start, const wxString& str, bool partial = FALSE );
- long FindItem( long start, long data);
+ long FindItem( long start, const wxString& str, bool partial = false );
+ long FindItem( long start, wxUIntPtr data);
+ long FindItem( const wxPoint& pt );
long HitTest( int x, int y, int &flags );
void InsertItem( wxListItem &item );
void InsertColumn( long col, wxListItem &item );
+ int GetItemWidthWithImage(wxListItem * item);
void SortItems( wxListCtrlCompare fn, long data );
size_t GetItemCount() const;
virtual bool SetFont(const wxFont& font)
{
if ( !wxScrolledWindow::SetFont(font) )
- return FALSE;
+ return false;
m_lineHeight = 0;
- return TRUE;
+ return true;
}
// these are for wxListLineData usage only
bool m_isCreated;
int m_dragCount;
wxPoint m_dragStart;
+ ColWidthArray m_aColWidths;
// for double click logic
size_t m_lineLastClicked,
- m_lineBeforeLastClicked;
+ m_lineBeforeLastClicked,
+ m_lineSelectSingleOnUp;
protected:
// the total count of items in a virtual list control
// get the colour to be used for drawing the rules
wxColour GetRuleColour() const
{
-#ifdef __WXMAC__
- return *wxWHITE;
-#else
return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
-#endif
}
private:
bool wxListItemData::IsHit( int x, int y ) const
{
- wxCHECK_MSG( m_rect, FALSE, _T("can't be called in this mode") );
+ wxCHECK_MSG( m_rect, false, _T("can't be called in this mode") );
return wxRect(GetX(), GetY(), GetWidth(), GetHeight()).Inside(x, y);
}
m_gi = new GeometryInfo;
}
- m_highlighted = FALSE;
+ m_highlighted = false;
InitItems( GetMode() == wxLC_REPORT ? m_owner->GetColumnCount() : 1 );
}
dc->SetPen( *wxTRANSPARENT_PEN );
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void wxListLineData::Draw( wxDC *dc )
bool wxListLineData::Highlight( bool on )
{
- wxCHECK_MSG( !IsVirtual(), FALSE, _T("unexpected call to Highlight") );
+ wxCHECK_MSG( !IsVirtual(), false, _T("unexpected call to Highlight") );
if ( on == m_highlighted )
- return FALSE;
+ return false;
m_highlighted = on;
- return TRUE;
+ return true;
}
void wxListLineData::ReverseHighlight( void )
void wxListHeaderWindow::Init()
{
m_currentCursor = (wxCursor *) NULL;
- m_isDragging = FALSE;
- m_dirty = FALSE;
+ m_isDragging = false;
+ m_dirty = false;
}
wxListHeaderWindow::wxListHeaderWindow()
m_owner = owner;
m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
- SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
+#if _USE_VISATTR
+ wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes();
+ SetOwnForegroundColour( attr.colFg );
+ SetOwnBackgroundColour( attr.colBg );
+ if (!m_hasFont)
+ SetOwnFont( attr.font );
+#else
+ SetOwnForegroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+ SetOwnBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
+ if (!m_hasFont)
+ SetOwnFont( wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT ));
+#endif
}
wxListHeaderWindow::~wxListHeaderWindow()
dc.SetBackgroundMode(wxTRANSPARENT);
- // do *not* use the listctrl colour for headers - one day we will have a
- // function to set it separately
- //dc.SetTextForeground( *wxBLACK );
- dc.SetTextForeground(wxSystemSettings::
- GetSystemColour( wxSYS_COLOUR_WINDOWTEXT ));
+ dc.SetTextForeground(GetForegroundColour());
int x = HEADER_OFFSET_X;
// the width of the rect to draw: make it smaller to fit entirely
// inside the column rect
+#ifdef __WXMAC__
+ int cw = wCol ;
+ int ch = h ;
+#else
int cw = wCol - 2;
-
+ int ch = h-2 ;
+#endif
wxRendererNative::Get().DrawHeaderButton
(
this,
dc,
- wxRect(x, HEADER_OFFSET_Y, cw, h - 2),
+ wxRect(x, HEADER_OFFSET_Y, cw, ch),
m_parent->IsEnabled() ? 0
- : wxCONTROL_DISABLED
+ : (int)wxCONTROL_DISABLED
);
// see if we have enough space for the column label
// for this we need the width of the text
wxCoord wLabel;
- wxCoord hLabel;
+ wxCoord hLabel;
dc.GetTextExtent(item.GetText(), &wLabel, &hLabel);
wLabel += 2*EXTRA_WIDTH;
if (event.ButtonUp())
{
ReleaseMouse();
- m_isDragging = FALSE;
- m_dirty = TRUE;
+ m_isDragging = false;
+ m_dirty = true;
m_owner->SetColumnWidth( m_column, m_currentX - m_minX );
SendListEvent(wxEVT_COMMAND_LIST_COL_END_DRAG, event.GetPosition());
}
else // not dragging
{
m_minX = 0;
- bool hit_border = FALSE;
+ bool hit_border = false;
// end of the current column
int xpos = 0;
- // find the column where this event occured
+ // find the column where this event occurred
int col,
countCol = m_owner->GetColumnCount();
for (col = 0; col < countCol; col++)
if ( (abs(x-xpos) < 3) && (y < 22) )
{
// near the column border
- hit_border = TRUE;
+ hit_border = true;
break;
}
if ( SendListEvent(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG,
event.GetPosition()) )
{
- m_isDragging = TRUE;
+ m_isDragging = true;
m_currentX = x;
CaptureMouse();
DrawCurrent();
m_itemEdited(itemEdit)
{
m_owner = owner;
- m_finished = FALSE;
+ m_finished = false;
+ m_aboutToFinish = false;
wxRect rectLabel = owner->GetLineLabelRect(itemEdit);
{
wxPendingDelete.Append(this);
- m_finished = TRUE;
+ m_finished = true;
- m_owner->SetFocus();
+ m_owner->SetFocusIgnoringChildren();
}
}
if ( value == m_startValue )
{
// nothing changed, always accept
- return TRUE;
+ return true;
}
if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
{
// vetoed by the user
- return FALSE;
+ return false;
}
// accepted, do rename the item
m_owner->SetItemText(m_itemEdited, value);
- return TRUE;
+ return true;
}
void wxListTextCtrl::OnChar( wxKeyEvent &event )
switch ( event.m_keyCode )
{
case WXK_RETURN:
- if ( !AcceptChanges() )
- {
- // vetoed by the user code
- break;
- }
- //else: fall through
+ m_aboutToFinish = true;
+ // Notify the owner about the changes
+ AcceptChanges();
+ // Even if vetoed, close the control (consistent with MSW)
+ Finish();
+ break;
case WXK_ESCAPE:
Finish();
sx = parentSize.x - myPos.x;
if (mySize.x > sx)
sx = mySize.x;
- SetSize(sx, -1);
+ SetSize(sx, wxDefaultCoord);
event.Skip();
}
void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
{
- if ( !m_finished )
+ if ( !m_finished && !m_aboutToFinish )
{
- // We must finish regardless of success, otherwise we'll get focus problems
+ // We must finish regardless of success, otherwise we'll get
+ // focus problems:
Finish();
if ( !AcceptChanges() )
m_owner->OnRenameCancelled( m_itemEdited );
}
+ // We must let the native text control handle focus, too, otherwise
+ // it could have problems with the cursor (e.g., in wxGTK).
event.Skip();
}
void wxListMainWindow::Init()
{
- m_dirty = TRUE;
+ m_dirty = true;
m_countVirt = 0;
m_lineFrom =
m_lineTo = (size_t)-1;
m_small_spacing = 30;
m_normal_spacing = 40;
- m_hasFocus = FALSE;
+ m_hasFocus = false;
m_dragCount = 0;
- m_isCreated = FALSE;
+ m_isCreated = false;
- m_lastOnSame = FALSE;
+ m_lastOnSame = false;
m_renameTimer = new wxListRenameTimer( this );
m_current =
m_lineLastClicked =
+ m_lineSelectSingleOnUp =
m_lineBeforeLastClicked = (size_t)-1;
m_freezeCount = 0;
wxSOLID
);
- wxSize sz = size;
- sz.y = 25;
-
SetScrollbars( 0, 0, 0, 0, 0, 0 );
- SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) );
+ wxVisualAttributes attr = wxGenericListCtrl::GetClassDefaultAttributes();
+ SetOwnForegroundColour( attr.colFg );
+ SetOwnBackgroundColour( attr.colBg );
+ if (!m_hasFont)
+ SetOwnFont( attr.font );
}
wxListMainWindow::~wxListMainWindow()
{
DoDeleteAllItems();
WX_CLEAR_LIST(wxListHeaderDataList, m_columns);
+ WX_CLEAR_ARRAY(m_aColWidths);
delete m_highlightBrush;
delete m_highlightUnfocusedBrush;
else // !virtual
{
wxListLineData *ld = GetLine(line);
- wxCHECK_MSG( ld, FALSE, _T("invalid index in IsHighlighted") );
+ wxCHECK_MSG( ld, false, _T("invalid index in IsHighlighted") );
return ld->IsHighlighted();
}
else // !virtual
{
wxListLineData *ld = GetLine(line);
- wxCHECK_MSG( ld, FALSE, _T("invalid index in HighlightLine") );
+ wxCHECK_MSG( ld, false, _T("invalid index in HighlightLine") );
changed = ld->Highlight(highlight);
}
else // !report
{
// TODO: how to do it more efficiently?
- m_dirty = TRUE;
+ m_dirty = true;
}
}
// we just have one item to turn off
if ( HasCurrent() && IsHighlighted(m_current) )
{
- HighlightLine(m_current, FALSE);
+ HighlightLine(m_current, false);
RefreshLine(m_current);
}
}
le.m_itemIndex = 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 );
le.m_item.m_text = value;
// let owner know that the edit was cancelled
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
- le.SetEditCanceled(TRUE);
+ le.SetEditCanceled(true);
le.SetEventObject( GetParent() );
le.m_itemIndex = itemEdit;
if ( GetParent()->GetEventHandler()->ProcessEvent( event) )
return;
+ if (event.GetEventType() == wxEVT_MOUSEWHEEL)
+ {
+ // let the base handle mouse wheel events.
+ event.Skip();
+ return;
+ }
+
if ( !HasCurrent() || IsEmpty() )
return;
wxListEvent le( command, GetParent()->GetId() );
le.SetEventObject( GetParent() );
- le.m_itemIndex = current;
+ le.m_itemIndex = m_lineLastClicked;
le.m_pointDrag = m_dragStart;
GetParent()->GetEventHandler()->ProcessEvent( le );
return;
}
- bool forceClick = FALSE;
+ bool forceClick = false;
if (event.ButtonDClick())
{
m_renameTimer->Stop();
- m_lastOnSame = FALSE;
+ m_lastOnSame = false;
if ( current == m_lineLastClicked )
{
}
else
{
- // the first click was on another item, so don't interpret this as
+ // The first click was on another item, so don't interpret this as
// a double click, but as a simple click instead
- forceClick = TRUE;
+ forceClick = true;
}
}
- if (event.LeftUp() && m_lastOnSame)
+ if (event.LeftUp())
{
- if ((current == m_current) &&
- (hitResult == wxLIST_HITTEST_ONITEMLABEL) &&
- HasFlag(wxLC_EDIT_LABELS) )
+ if(m_lineSelectSingleOnUp != (size_t) -1)
+ {
+ // select single line
+ HighlightAll( false );
+ ReverseHighlight(m_lineSelectSingleOnUp);
+ }
+ if (m_lastOnSame)
{
- m_renameTimer->Start( 100, TRUE );
+ if ((current == m_current) &&
+ (hitResult == wxLIST_HITTEST_ONITEMLABEL) &&
+ HasFlag(wxLC_EDIT_LABELS) )
+ {
+ m_renameTimer->Start( 100, true );
+ }
}
- m_lastOnSame = FALSE;
+ m_lastOnSame = false;
+ m_lineSelectSingleOnUp = (size_t) -1;
+ }
+ else
+ {
+ // This is necessary, because after a DnD operation in
+ // from and to ourself, the up event is swallowed by the
+ // DnD code. So on next non-up event (which means here and
+ // now) m_lineSelectSingleOnUp should be reset.
+ m_lineSelectSingleOnUp = (size_t) -1;
}
- else if (event.RightDown())
+ if (event.RightDown())
{
+ 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))
+ {
+ HighlightAll(false);
+ ChangeCurrent(current);
+ ReverseHighlight(m_current);
+ }
SendNotify( current, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
event.GetPosition() );
+ // Allow generation of context menu event
+ event.Skip();
}
else if (event.MiddleDown())
{
m_lineLastClicked = current;
size_t oldCurrent = m_current;
+ bool oldWasSelected = IsHighlighted(m_current);
- if ( IsSingleSel() || !(event.ControlDown() || event.ShiftDown()) )
+ bool cmdModifierDown = event.CmdDown();
+ if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) )
{
- HighlightAll( FALSE );
+ if( IsSingleSel() || !IsHighlighted(current) )
+ {
+ HighlightAll( false );
- ChangeCurrent(current);
+ ChangeCurrent(current);
- ReverseHighlight(m_current);
+ ReverseHighlight(m_current);
+ }
+ else // multi sel & current is highlighted & no mod keys
+ {
+ m_lineSelectSingleOnUp = current;
+ ChangeCurrent(current); // change focus
+ }
}
else // multi sel & either ctrl or shift is down
{
- if (event.ControlDown())
+ if (cmdModifierDown)
{
ChangeCurrent(current);
}
// forceClick is only set if the previous click was on another item
- m_lastOnSame = !forceClick && (m_current == oldCurrent);
+ m_lastOnSame = !forceClick && (m_current == oldCurrent) && oldWasSelected;
}
}
{
// all previously selected items are unselected unless ctrl is held
if ( !event.ControlDown() )
- HighlightAll(FALSE);
+ HighlightAll(false);
ChangeCurrent(newCurrent);
-
+
// refresh the old focus to remove it
RefreshLine( oldCurrent );
if ( !event.ControlDown() )
{
- HighlightLine( m_current, TRUE );
+ HighlightLine( m_current, true );
}
}
-
+
RefreshLine( m_current );
MoveToFocus();
// focus handling
// ----------------------------------------------------------------------------
-void wxListMainWindow::SetFocus()
-{
- // VS: wxListMainWindow derives from wxPanel (via wxScrolledWindow) and wxPanel
- // overrides SetFocus in such way that it does never change focus from
- // panel's child to the panel itself. Unfortunately, we must be able to change
- // focus to the panel from wxListTextCtrl because the text control should
- // disappear when the user clicks outside it.
-
- wxWindow *oldFocus = FindFocus();
-
- if ( oldFocus && oldFocus->GetParent() == this )
- {
- wxWindow::SetFocus();
- }
- else
- {
- wxScrolledWindow::SetFocus();
- }
-}
-
void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
{
if ( GetParent() )
// it
if ( !m_hasFocus )
{
- m_hasFocus = TRUE;
+ m_hasFocus = true;
RefreshSelected();
}
if ( GetParent()->GetEventHandler()->ProcessEvent( event) )
return;
}
- m_hasFocus = FALSE;
+ m_hasFocus = false;
RefreshSelected();
}
void wxListMainWindow::SetImageList( wxImageListType *imageList, int which )
{
- m_dirty = TRUE;
+ m_dirty = true;
// calc the spacing from the icon size
int width = 0,
void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall )
{
- m_dirty = TRUE;
+ m_dirty = true;
if (isSmall)
{
m_small_spacing = spacing;
wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
if ( headerWin )
- headerWin->m_dirty = TRUE;
+ headerWin->m_dirty = true;
- m_dirty = TRUE;
+ m_dirty = true;
// invalidate it as it has to be recalculated
m_headerWidth = 0;
wxCHECK_RET( InReportView(),
_T("SetColumnWidth() can only be called in report mode.") );
- m_dirty = TRUE;
+ m_dirty = true;
wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
if ( headerWin )
- headerWin->m_dirty = TRUE;
+ headerWin->m_dirty = true;
wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col );
wxCHECK_RET( node, _T("no column?") );
int max = AUTOSIZE_COL_MARGIN;
- for ( size_t i = 0; i < count; i++ )
+ // if the cached column width isn't valid then recalculate it
+ if (m_aColWidths.Item(col)->bNeedsUpdate)
{
- wxListLineData *line = GetLine(i);
- wxListItemDataList::compatibility_iterator n = line->m_items.Item( col );
-
- wxCHECK_RET( n, _T("no subitem?") );
+ for (size_t i = 0; i < count; i++)
+ {
+ wxListLineData *line = GetLine(i);
+ wxListItemDataList::compatibility_iterator n = line->m_items.Item( col );
- wxListItemData *item = n->GetData();
- int current = 0;
+ wxCHECK_RET( n, _T("no subitem?") );
- if (item->HasImage())
- {
- int ix, iy;
- GetImageSize( item->GetImage(), ix, iy );
- current += ix + 5;
- }
+ wxListItemData *itemData = n->GetData();
+ wxListItem item;
- if (item->HasText())
- {
- wxCoord w;
- dc.GetTextExtent( item->GetText(), &w, NULL );
- current += w;
+ itemData->GetItem(item);
+ int itemWidth = GetItemWidthWithImage(&item);
+ if (itemWidth > max)
+ max = itemWidth;
}
- if (current > max)
- max = current;
+ m_aColWidths.Item(col)->bNeedsUpdate = false;
+ m_aColWidths.Item(col)->nMaxWidth = max;
}
+ max = m_aColWidths.Item(col)->nMaxWidth;
width = max + AUTOSIZE_COL_MARGIN;
}
}
{
wxListLineData *line = GetLine((size_t)id);
line->SetItem( item.m_col, item );
+
+ if (InReportView())
+ {
+ // update the Max Width Cache if needed
+ int width = GetItemWidthWithImage(&item);
+
+ if (width > m_aColWidths.Item(item.m_col)->nMaxWidth)
+ m_aColWidths.Item(item.m_col)->nMaxWidth = width;
+ }
}
// update the item on screen
RefreshRect(rectItem);
}
+void wxListMainWindow::SetItemStateAll(long state, long stateMask)
+{
+ if ( IsEmpty() )
+ return;
+
+ // first deal with selection
+ if ( stateMask & wxLIST_STATE_SELECTED )
+ {
+ // set/clear select state
+ if ( IsVirtual() )
+ {
+ // optimized version for virtual listctrl.
+ m_selStore.SelectRange(0, GetItemCount() - 1, state == wxLIST_STATE_SELECTED);
+ Refresh();
+ }
+ else if ( state & wxLIST_STATE_SELECTED )
+ {
+ const long count = GetItemCount();
+ for( long i = 0; i < count; i++ )
+ {
+ SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
+ }
+
+ }
+ else
+ {
+ // clear for non virtual (somewhat optimized by using GetNextItem())
+ long i = -1;
+ while ( (i = GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1 )
+ {
+ SetItemState( i, 0, wxLIST_STATE_SELECTED );
+ }
+ }
+ }
+
+ if ( HasCurrent() && (state == 0) && (stateMask & wxLIST_STATE_FOCUSED) )
+ {
+ // unfocus all: only one item can be focussed, so clearing focus for
+ // all items is simply clearing focus of the focussed item.
+ SetItemState(m_current, state, stateMask);
+ }
+ //(setting focus to all items makes no sense, so it is not handled here.)
+}
+
void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
{
- wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(),
- _T("invalid list ctrl item index in SetItem") );
+ if ( litem == -1 )
+ {
+ SetItemStateAll(state, stateMask);
+ return;
+ }
+
+ wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(),
+ _T("invalid list ctrl item index in SetItem") );
size_t oldCurrent = m_current;
size_t item = (size_t)litem; // safe because of the check above
{
if ( IsSingleSel() )
{
- HighlightLine(oldCurrent, FALSE);
+ HighlightLine(oldCurrent, false);
}
RefreshLine(oldCurrent);
// we must unselect the old current item as well or we
// might end up with more than one selected item in a
// single selection control
- HighlightLine(oldCurrent, FALSE);
+ HighlightLine(oldCurrent, false);
}
RefreshLine( oldCurrent );
if ( oldCurrent != (size_t)-1 )
{
- HighlightLine( oldCurrent, FALSE );
+ HighlightLine( oldCurrent, false );
RefreshLine( oldCurrent );
}
}
ResetVisibleLinesRange();
// scrollbars must be reset
- m_dirty = TRUE;
+ m_dirty = true;
}
int wxListMainWindow::GetSelectedItemCount() const
// deal with the quick case first
if ( IsSingleSel() )
{
- return HasCurrent() ? IsHighlighted(m_current) : FALSE;
+ return HasCurrent() ? IsHighlighted(m_current) : false;
}
// virtual controls remmebers all its selections itself
if ( m_dirty )
{
wxConstCast(this, wxListMainWindow)->
- RecalculatePositions(TRUE /* no refresh */);
+ RecalculatePositions(true /* no refresh */);
}
rect = GetLineRect((size_t)index);
pos.x = rect.x;
pos.y = rect.y;
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
iconSpacing = 0;
// Note that we do not call GetClientSize() here but
- // GetSize() and substract the border size for sunken
+ // GetSize() and subtract the border size for sunken
// borders manually. This is technically incorrect,
// but we need to know the client area's size WITHOUT
// scrollbars here. Since we don't know if there are
(entireHeight + lineHeight - 1) / lineHeight,
GetScrollPos(wxHORIZONTAL),
GetScrollPos(wxVERTICAL),
- TRUE );
+ true );
}
else // !report
{
(y + lineHeight) / lineHeight,
GetScrollPos( wxHORIZONTAL ),
GetScrollPos( wxVERTICAL ),
- TRUE
+ true
);
}
else // "flowed" arrangement, the most complicated case
0,
GetScrollPos( wxHORIZONTAL ),
0,
- TRUE
+ true
);
}
}
void wxListMainWindow::RefreshAll()
{
- m_dirty = FALSE;
+ m_dirty = false;
Refresh();
wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
if ( headerWin && headerWin->m_dirty )
{
- headerWin->m_dirty = FALSE;
+ headerWin->m_dirty = false;
headerWin->Refresh();
}
}
if ( InReportView() )
{
+ // mark the Column Max Width cache as dirty if the items in the line
+ // we're deleting contain the Max Column Width
+ wxListLineData * const line = GetLine(index);
+ wxListItemDataList::compatibility_iterator n;
+ wxListItemData *itemData;
+ wxListItem item;
+ int itemWidth;
+
+ for (size_t i = 0; i < m_columns.GetCount(); i++)
+ {
+ n = line->m_items.Item( i );
+ itemData = n->GetData();
+ itemData->GetItem(item);
+
+ itemWidth = GetItemWidthWithImage(&item);
+
+ if (itemWidth >= m_aColWidths.Item(i)->nMaxWidth)
+ m_aColWidths.Item(i)->bNeedsUpdate = true;
+ }
+
ResetVisibleLinesRange();
}
}
// we need to refresh the (vert) scrollbar as the number of items changed
- m_dirty = TRUE;
+ m_dirty = true;
SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM );
wxCHECK_RET( node, wxT("invalid column index in DeleteColumn()") );
- m_dirty = TRUE;
+ m_dirty = true;
delete node->GetData();
m_columns.Erase( node );
}
}
+ if ( InReportView() ) // we only cache max widths when in Report View
+ {
+ delete m_aColWidths.Item(col);
+ m_aColWidths.RemoveAt(col);
+ }
+
// invalidate it as it has to be recalculated
m_headerWidth = 0;
}
if ( InReportView() )
{
ResetVisibleLinesRange();
+ for (size_t i = 0; i < m_aColWidths.GetCount(); i++)
+ {
+ m_aColWidths.Item(i)->bNeedsUpdate = true;
+ }
}
m_lines.Clear();
void wxListMainWindow::DeleteEverything()
{
WX_CLEAR_LIST(wxListHeaderDataList, m_columns);
+ WX_CLEAR_ARRAY(m_aColWidths);
DeleteAllItems();
}
// been added and its position is not known yet
if ( m_dirty )
{
- RecalculatePositions(TRUE /* no refresh */);
+ RecalculatePositions(true /* no refresh */);
}
MoveToItem((size_t)index);
return wxNOT_FOUND;
}
-long wxListMainWindow::FindItem(long start, long data)
+long wxListMainWindow::FindItem(long start, wxUIntPtr data)
{
long pos = start;
if (pos < 0)
return wxNOT_FOUND;
}
+long wxListMainWindow::FindItem( const wxPoint& pt )
+{
+ size_t topItem;
+ GetVisibleLinesRange(&topItem, NULL);
+
+ wxPoint p;
+ 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;
+
+ return wxNOT_FOUND;
+}
+
long wxListMainWindow::HitTest( int x, int y, int &flags )
{
CalcUnscrolledPosition( x, y, &x, &y );
{
wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual control") );
- size_t count = GetItemCount();
- wxCHECK_RET( item.m_itemId >= 0 && (size_t)item.m_itemId <= count,
- _T("invalid item index") );
+ int count = GetItemCount();
+ wxCHECK_RET( item.m_itemId >= 0, _T("invalid item index") );
+
+ if (item.m_itemId > count)
+ item.m_itemId = count;
size_t id = item.m_itemId;
- m_dirty = TRUE;
+ m_dirty = true;
- #if 0
- // this is unused variable
- int mode = 0;
- #endif
if ( InReportView() )
{
- #if 0
- // this is unused variable
- mode = wxLC_REPORT;
- #endif
ResetVisibleLinesRange();
- }
- else if ( HasFlag(wxLC_LIST) )
- #if 0
- // this is unused variable
- mode = wxLC_LIST;
- #else
- {}
- #endif
- else if ( HasFlag(wxLC_ICON) )
- #if 0
- // this is unused variable
- mode = wxLC_ICON;
- #else
- {}
- #endif
- else if ( HasFlag(wxLC_SMALL_ICON) )
- #if 0
- // this is unused variable
- mode = wxLC_ICON; // no typo
- #else
- {}
- #endif
- else
- {
- wxFAIL_MSG( _T("unknown mode") );
+
+ // calculate the width of the item and adjust the max column width
+ wxColWidthInfo *pWidthInfo = m_aColWidths.Item(item.GetColumn());
+ int width = GetItemWidthWithImage(&item);
+ item.SetWidth(width);
+ if (width > pWidthInfo->nMaxWidth)
+ pWidthInfo->nMaxWidth = width;
}
wxListLineData *line = new wxListLineData(this);
- line->SetItem( 0, item );
+ line->SetItem( item.m_col, item );
m_lines.Insert( line, id );
- m_dirty = TRUE;
+ m_dirty = true;
// If an item is selected at or below the point of insertion, we need to
// increment the member variables because the current row's index has gone
void wxListMainWindow::InsertColumn( long col, wxListItem &item )
{
- m_dirty = TRUE;
+ m_dirty = true;
if ( InReportView() )
{
if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
item.m_width = GetTextLength( item.m_text );
wxListHeaderData *column = new wxListHeaderData( item );
+ wxColWidthInfo *colWidthInfo = new wxColWidthInfo();
+
bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount());
if ( insert )
{
- wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col );
+ wxListHeaderDataList::compatibility_iterator
+ node = m_columns.Item( col );
m_columns.Insert( node, column );
+ m_aColWidths.Insert( colWidthInfo, col );
}
else
{
m_columns.Append( column );
+ m_aColWidths.Add( colWidthInfo );
}
if ( !IsVirtual() )
}
}
+int wxListMainWindow::GetItemWidthWithImage(wxListItem * item)
+{
+ int width = 0;
+ wxClientDC dc(this);
+
+ dc.SetFont( GetFont() );
+
+ if (item->GetImage() != -1)
+ {
+ int ix, iy;
+ GetImageSize( item->GetImage(), ix, iy );
+ width += ix + 5;
+ }
+
+ if (!item->GetText().empty())
+ {
+ wxCoord w;
+ dc.GetTextExtent( item->GetText(), &w, NULL );
+ width += w;
+ }
+
+ return width;
+}
+
// ----------------------------------------------------------------------------
// sorting
// ----------------------------------------------------------------------------
wxListLineData *line2 = *arg2;
wxListItem item;
line1->GetItem( 0, item );
- long data1 = item.m_data;
+ wxUIntPtr data1 = item.m_data;
line2->GetItem( 0, item );
- long data2 = item.m_data;
+ wxUIntPtr data2 = item.m_data;
return list_ctrl_compare_func_2( data1, data2, list_ctrl_compare_data );
}
list_ctrl_compare_func_2 = fn;
list_ctrl_compare_data = data;
m_lines.Sort( list_ctrl_compare_func_1 );
- m_dirty = TRUE;
+ m_dirty = true;
}
// ----------------------------------------------------------------------------
ResetVisibleLinesRange();
// FIXME
-#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
+#if ( defined(__WXGTK__) || defined(__WXMAC__) ) && !defined(__WXUNIVERSAL__)
wxScrolledWindow::OnScroll(event);
#else
HandleOnScroll( event );
m_ownsImageListNormal =
m_ownsImageListSmall =
- m_ownsImageListState = FALSE;
+ m_ownsImageListState = false;
m_mainWin = (wxListMainWindow*) NULL;
m_headerWin = (wxListHeaderWindow*) NULL;
{
if ( m_headerWin )
{
+#ifdef __WXMAC__
+ SInt32 h ;
+ GetThemeMetric( kThemeMetricListHeaderHeight, &h );
+#else
// we use 'g' to get the descent, too
int w, h, d;
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 )
{
m_headerWin->SetSize(m_headerWin->GetSize().x, m_headerHeight);
if ( HasHeader() )
- ResizeReportView(TRUE);
+ ResizeReportView(true);
}
}
}
{
m_headerWin = new wxListHeaderWindow
(
- this, -1, m_mainWin,
- wxPoint(0, 0),
+ this, wxID_ANY, m_mainWin,
+ wxPoint(0,0),
wxSize(GetClientSize().x, m_headerHeight),
wxTAB_TRAVERSAL
);
m_imageListState = (wxImageListType *) NULL;
m_ownsImageListNormal =
m_ownsImageListSmall =
- m_ownsImageListState = FALSE;
+ m_ownsImageListState = false;
m_mainWin = (wxListMainWindow*) NULL;
m_headerWin = (wxListHeaderWindow*) NULL;
}
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
- return FALSE;
+ return false;
// don't create the inner window with the border
style &= ~wxBORDER_MASK;
- m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, style );
+ m_mainWin = new wxListMainWindow( this, wxID_ANY, wxPoint(0,0), size, style );
-#if defined( __WXMAC__ ) && __WXMAC_CARBON__
- wxFont font ;
- font.MacCreateThemeFont( kThemeViewsFont ) ;
- SetFont( font ) ;
+#ifdef __WXMAC_CARBON__
+ // Human Interface Guidelines ask us for a special font in this case
+ if ( GetWindowVariant() == wxWINDOW_VARIANT_NORMAL )
+ {
+ wxFont font ;
+ font.MacCreateThemeFont( kThemeViewsFont ) ;
+ SetFont( font ) ;
+ }
#endif
if ( InReportView() )
{
CreateHeaderWindow();
-
+#ifdef __WXMAC_CARBON__
+ if (m_headerWin)
+ {
+ wxFont font ;
+ font.MacCreateThemeFont( kThemeSmallSystemFont ) ;
+ m_headerWin->SetFont( font );
+ CalculateAndSetHeaderHeight();
+ }
+#endif
if ( HasFlag(wxLC_NO_HEADER) )
{
// VZ: why do we create it at all then?
- m_headerWin->Show( FALSE );
+ m_headerWin->Show( false );
}
}
- return TRUE;
+ SetBestSize(size);
+
+ return true;
}
void wxGenericListCtrl::SetSingleStyle( long style, bool add )
if ( m_headerWin )
{
// don't delete, just hide, as we can reuse it later
- m_headerWin->Show(FALSE);
+ m_headerWin->Show(false);
}
//else: nothing to do
}
}
else // already have it, just show
{
- m_headerWin->Show( TRUE );
+ m_headerWin->Show( true );
}
}
bool wxGenericListCtrl::GetColumn(int col, wxListItem &item) const
{
m_mainWin->GetColumn( col, item );
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::SetColumn( int col, wxListItem& item )
{
m_mainWin->SetColumn( col, item );
- return TRUE;
+ return true;
}
int wxGenericListCtrl::GetColumnWidth( int col ) const
bool wxGenericListCtrl::SetColumnWidth( int col, int width )
{
m_mainWin->SetColumnWidth( col, width );
- return TRUE;
+ return true;
}
int wxGenericListCtrl::GetCountPerPage() const
bool wxGenericListCtrl::GetItem( wxListItem &info ) const
{
m_mainWin->GetItem( info );
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::SetItem( wxListItem &info )
{
m_mainWin->SetItem( info );
- return TRUE;
+ return true;
}
long wxGenericListCtrl::SetItem( long index, int col, const wxString& label, int imageId )
info.m_mask |= wxLIST_MASK_IMAGE;
};
m_mainWin->SetItem(info);
- return TRUE;
+ return true;
}
int wxGenericListCtrl::GetItemState( long item, long stateMask ) const
bool wxGenericListCtrl::SetItemState( long item, long state, long stateMask )
{
m_mainWin->SetItemState( item, state, stateMask );
- return TRUE;
+ return true;
}
-bool wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) )
+bool
+wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) )
{
wxListItem info;
info.m_image = image;
info.m_mask = wxLIST_MASK_IMAGE;
info.m_itemId = item;
m_mainWin->SetItem( info );
- return TRUE;
+ return true;
}
wxString wxGenericListCtrl::GetItemText( long item ) const
m_mainWin->SetItemText(item, str);
}
-long wxGenericListCtrl::GetItemData( long item ) const
+wxUIntPtr wxGenericListCtrl::GetItemData( long item ) const
{
wxListItem info;
info.m_itemId = item;
info.m_itemId = item;
info.m_data = data;
m_mainWin->SetItem( info );
- return TRUE;
+ return true;
}
wxRect wxGenericListCtrl::GetViewRect() const
m_mainWin->GetItemRect( item, rect );
if ( m_mainWin->HasHeader() )
rect.y += m_headerHeight + 1;
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::GetItemPosition( long item, wxPoint& pos ) const
{
m_mainWin->GetItemPosition( item, pos );
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::SetItemPosition( long WXUNUSED(item), const wxPoint& WXUNUSED(pos) )
return info.GetBackgroundColour();
}
+void wxGenericListCtrl::SetItemFont( long item, const wxFont &f )
+{
+ wxListItem info;
+ info.m_itemId = item;
+ info.SetFont( f );
+ m_mainWin->SetItem( info );
+}
+
+wxFont wxGenericListCtrl::GetItemFont( long item ) const
+{
+ wxListItem info;
+ info.m_itemId = item;
+ m_mainWin->GetItem( info );
+ return info.GetFont();
+}
+
int wxGenericListCtrl::GetSelectedItemCount() const
{
return m_mainWin->GetSelectedItemCount();
{
if (m_ownsImageListNormal) delete m_imageListNormal;
m_imageListNormal = imageList;
- m_ownsImageListNormal = FALSE;
+ m_ownsImageListNormal = false;
}
else if ( which == wxIMAGE_LIST_SMALL )
{
if (m_ownsImageListSmall) delete m_imageListSmall;
m_imageListSmall = imageList;
- m_ownsImageListSmall = FALSE;
+ m_ownsImageListSmall = false;
}
else if ( which == wxIMAGE_LIST_STATE )
{
if (m_ownsImageListState) delete m_imageListState;
m_imageListState = imageList;
- m_ownsImageListState = FALSE;
+ m_ownsImageListState = false;
}
m_mainWin->SetImageList( imageList, which );
{
SetImageList(imageList, which);
if ( which == wxIMAGE_LIST_NORMAL )
- m_ownsImageListNormal = TRUE;
+ m_ownsImageListNormal = true;
else if ( which == wxIMAGE_LIST_SMALL )
- m_ownsImageListSmall = TRUE;
+ m_ownsImageListSmall = true;
else if ( which == wxIMAGE_LIST_STATE )
- m_ownsImageListState = TRUE;
+ m_ownsImageListState = true;
}
bool wxGenericListCtrl::Arrange( int WXUNUSED(flag) )
bool wxGenericListCtrl::DeleteItem( long item )
{
m_mainWin->DeleteItem( item );
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::DeleteAllItems()
{
m_mainWin->DeleteAllItems();
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::DeleteAllColumns()
for ( size_t n = 0; n < count; n++ )
DeleteColumn(0);
- return TRUE;
+ return true;
}
void wxGenericListCtrl::ClearAll()
// if we don't have the header any longer, we need to relayout the window
if ( !GetColumnCount() )
{
- ResizeReportView(FALSE /* no header */);
+ ResizeReportView(false /* no header */);
}
- return TRUE;
+ return true;
}
void wxGenericListCtrl::Edit( long item )
bool wxGenericListCtrl::EnsureVisible( long item )
{
m_mainWin->EnsureVisible( item );
- return TRUE;
+ return true;
}
long wxGenericListCtrl::FindItem( long start, const wxString& str, bool partial )
return m_mainWin->FindItem( start, str, partial );
}
-long wxGenericListCtrl::FindItem( long start, long data )
+long wxGenericListCtrl::FindItem( long start, wxUIntPtr data )
{
return m_mainWin->FindItem( start, data );
}
-long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& WXUNUSED(pt),
+long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& pt,
int WXUNUSED(direction))
{
- return 0;
+ return m_mainWin->FindItem( pt );
}
long wxGenericListCtrl::HitTest( const wxPoint &point, int &flags )
// window
if ( GetColumnCount() == 1 && m_mainWin->HasHeader() )
{
- ResizeReportView(TRUE /* have header */);
+ ResizeReportView(true /* have header */);
}
m_headerWin->Refresh();
bool wxGenericListCtrl::SortItems( wxListCtrlCompare fn, long data )
{
m_mainWin->SortItems( fn, data );
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
if (m_mainWin)
{
m_mainWin->SetBackgroundColour( colour );
- m_mainWin->m_dirty = TRUE;
+ m_mainWin->m_dirty = true;
}
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::SetForegroundColour( const wxColour &colour )
{
if ( !wxWindow::SetForegroundColour( colour ) )
- return FALSE;
+ return false;
if (m_mainWin)
{
m_mainWin->SetForegroundColour( colour );
- m_mainWin->m_dirty = TRUE;
+ m_mainWin->m_dirty = true;
}
if (m_headerWin)
m_headerWin->SetForegroundColour( colour );
}
- return TRUE;
+ return true;
}
bool wxGenericListCtrl::SetFont( const wxFont &font )
{
if ( !wxWindow::SetFont( font ) )
- return FALSE;
+ return false;
if (m_mainWin)
{
m_mainWin->SetFont( font );
- m_mainWin->m_dirty = TRUE;
+ m_mainWin->m_dirty = true;
}
if (m_headerWin)
Refresh();
- return TRUE;
+ return true;
+}
+
+
+
+#if _USE_VISATTR
+#include "wx/listbox.h"
+#endif
+
+//static
+wxVisualAttributes
+wxGenericListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+{
+#if _USE_VISATTR
+ // Use the same color scheme as wxListBox
+ return wxListBox::GetClassDefaultAttributes(variant);
+#else
+ wxUnusedVar(variant);
+ wxVisualAttributes attr;
+ attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
+ attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+ return attr;
+#endif
}
// ----------------------------------------------------------------------------
bool wxGenericListCtrl::SetCursor( const wxCursor &cursor )
{
- return m_mainWin ? m_mainWin->wxWindow::SetCursor(cursor) : FALSE;
+ return m_mainWin ? m_mainWin->wxWindow::SetCursor(cursor) : false;
}
wxColour wxGenericListCtrl::GetBackgroundColour() const
#if wxUSE_MENUS
return m_mainWin->PopupMenu( menu, x, y );
#else
- return FALSE;
+ return false;
#endif // wxUSE_MENUS
}
{
/* The test in window.cpp fails as we are a composite
window, so it checks against "this", but not m_mainWin. */
- if ( FindFocus() != this )
+ if ( DoFindFocus() != this )
m_mainWin->SetFocus();
}
+wxSize wxGenericListCtrl::DoGetBestSize() const
+{
+ // Something is better than nothing...
+ // 100x80 is what the MSW version will get from the default
+ // wxControl::DoGetBestSize
+ return wxSize(100,80);
+}
+
// ----------------------------------------------------------------------------
// virtual list control support
// ----------------------------------------------------------------------------
int wxGenericListCtrl::OnGetItemImage(long WXUNUSED(item)) const
{
- // same as above
- wxFAIL_MSG( _T("wxGenericListCtrl::OnGetItemImage not supposed to be called") );
-
+ wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL),
+ -1,
+ wxT("List control has an image list, OnGetItemImage should be overridden."));
return -1;
}