void wxListHeaderData::GetItem( wxListItem& item )
{
- item.m_mask = m_mask;
- item.m_text = m_text;
- item.m_image = m_image;
- item.m_format = m_format;
- item.m_width = m_width;
- item.m_state = m_state;
+ long mask = item.m_mask;
+ if ( !mask )
+ {
+ // by default, get everything for backwards compatibility
+ mask = -1;
+ }
+
+ if ( mask & wxLIST_MASK_STATE )
+ item.m_state = m_state;
+ if ( mask & wxLIST_MASK_TEXT )
+ item.m_text = m_text;
+ if ( mask & wxLIST_MASK_IMAGE )
+ item.m_image = m_image;
+ if ( mask & wxLIST_MASK_WIDTH )
+ item.m_width = m_width;
+ if ( mask & wxLIST_MASK_FORMAT )
+ item.m_format = m_format;
}
int wxListHeaderData::GetImage() const
BEGIN_EVENT_TABLE(wxListHeaderWindow,wxWindow)
EVT_PAINT (wxListHeaderWindow::OnPaint)
EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse)
- EVT_SET_FOCUS (wxListHeaderWindow::OnSetFocus)
END_EVENT_TABLE()
void wxListHeaderWindow::Init()
}
}
-void wxListHeaderWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
-{
- m_owner->SetFocus();
- m_owner->Update();
-}
-
bool wxListHeaderWindow::SendListEvent(wxEventType type, const wxPoint& pos)
{
wxWindow *parent = GetParent();
wxListMainWindow::wxListMainWindow( wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString &name )
- : wxWindow( parent, id, pos, size, style, name )
+ const wxSize& size )
+ : wxWindow( parent, id, pos, size,
+ wxWANTS_CHARS | wxBORDER_NONE )
{
Init();
wxCHECK_MSG( (item >= 0) && ((size_t)item < GetItemCount()), NULL,
wxT("wrong index in wxGenericListCtrl::EditLabel()") );
- wxASSERT_MSG( textControlClass->IsKindOf(CLASSINFO(wxTextCtrl)),
+ wxASSERT_MSG( textControlClass->IsKindOf(wxCLASSINFO(wxTextCtrl)),
wxT("EditLabel() needs a text control") );
size_t itemEdit = (size_t)item;
if ( event.LeftDown() )
SetFocus();
- event.SetEventObject( GetParent() );
- if ( GetParent()->GetEventHandler()->ProcessEvent( event) )
+ // Pretend that the event happened in wxListCtrl itself.
+ wxMouseEvent me(event);
+ me.SetEventObject( GetParent() );
+ me.SetId(GetParent()->GetId());
+ if ( GetParent()->GetEventHandler()->ProcessEvent( me ))
return;
if (event.GetEventType() == wxEVT_MOUSEWHEEL)
}
}
+ // Update drag events counter first as we must do it even if the mouse is
+ // not on any item right now as we must keep count in case we started
+ // dragging from the empty control area but continued to do it over a valid
+ // item -- in this situation we must not start dragging this item.
if (event.Dragging())
- {
- if (m_dragCount == 0)
- {
- // we have to report the raw, physical coords as we want to be
- // able to call HitTest(event.m_pointDrag) from the user code to
- // get the item being dragged
- m_dragStart = event.GetPosition();
- }
-
m_dragCount++;
-
- if (m_dragCount != 3)
- return;
-
- int command = event.RightIsDown() ? wxEVT_COMMAND_LIST_BEGIN_RDRAG
- : wxEVT_COMMAND_LIST_BEGIN_DRAG;
-
- wxListEvent le( command, GetParent()->GetId() );
- le.SetEventObject( GetParent() );
- le.m_item.m_itemId =
- le.m_itemIndex = m_lineLastClicked;
- le.m_pointDrag = m_dragStart;
- GetParent()->GetEventHandler()->ProcessEvent( le );
-
- return;
- }
else
- {
m_dragCount = 0;
- }
+ // The only mouse event that can be generated without any valid item is
+ // wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK as it can be useful to have a global
+ // popup menu for the list control itself which should be shown even when
+ // the user clicks outside of any item.
if ( !hitResult )
{
// outside of any item
return;
}
+ if ( event.Dragging() )
+ {
+ if (m_dragCount == 1)
+ {
+ // we have to report the raw, physical coords as we want to be
+ // able to call HitTest(event.m_pointDrag) from the user code to
+ // get the item being dragged
+ m_dragStart = event.GetPosition();
+ }
+
+ if (m_dragCount != 3)
+ return;
+
+ int command = event.RightIsDown() ? wxEVT_COMMAND_LIST_BEGIN_RDRAG
+ : wxEVT_COMMAND_LIST_BEGIN_DRAG;
+
+ SendNotify( m_lineLastClicked, command, m_dragStart );
+
+ return;
+ }
+
bool forceClick = false;
if (event.ButtonDClick())
{
// propagate the key event upwards
wxKeyEvent ke(event);
ke.SetEventObject( parent );
+ ke.SetId(GetParent()->GetId());
if (parent->GetEventHandler()->ProcessEvent( ke ))
return;
// propagate the key event upwards
wxKeyEvent ke(event);
+ ke.SetEventObject( parent );
+ ke.SetId(GetParent()->GetId());
if (parent->GetEventHandler()->ProcessEvent( ke ))
return;
// propagate the char event upwards
wxKeyEvent ke(event);
ke.SetEventObject( parent );
+ ke.SetId(GetParent()->GetId());
if (parent->GetEventHandler()->ProcessEvent( ke ))
return;
RefreshLines(id, GetItemCount() - 1);
}
-void wxListMainWindow::InsertColumn( long col, const wxListItem &item )
+long wxListMainWindow::InsertColumn( long col, const wxListItem &item )
{
+ long idx = -1;
+
m_dirty = true;
if ( InReportView() )
{
node = m_columns.Item( col );
m_columns.Insert( node, column );
m_aColWidths.Insert( colWidthInfo, col );
+ idx = col;
}
else
{
+ idx = m_aColWidths.GetCount();
m_columns.Append( column );
m_aColWidths.Add( colWidthInfo );
}
// invalidate it as it has to be recalculated
m_headerWidth = 0;
}
+ return idx;
}
int wxListMainWindow::GetItemWidthWithImage(wxListItem * item)
validator, name ) )
return false;
-#ifdef __WXGTK__
- style &= ~wxBORDER_MASK;
- style |= wxBORDER_THEME;
-#endif
-
- m_mainWin = new wxListMainWindow( this, wxID_ANY, wxPoint(0, 0), size, style );
+ m_mainWin = new wxListMainWindow(this, wxID_ANY, wxPoint(0, 0), size);
SetTargetWindow( m_mainWin );
{
wxCHECK_MSG( InReportView(), -1, wxT("can't add column in non report mode") );
- m_mainWin->InsertColumn( col, item );
+ long idx = m_mainWin->InsertColumn( col, item );
// NOTE: if wxLC_NO_HEADER was given, then we are in report view mode but
// still have m_headerWin==NULL
if (m_headerWin)
m_headerWin->Refresh();
- return 0;
+ return idx;
}
bool wxGenericListCtrl::ScrollList( int dx, int dy )
wxListCtrlBase::DoScreenToClient(x, y);
}
-void wxGenericListCtrl::SetFocus()
-{
- // 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();
-}
-
wxSize wxGenericListCtrl::DoGetBestClientSize() const
{
- // Something is better than nothing even if this is completely arbitrary.
- wxSize sizeBest(100, 80);
+ // The base class version can compute the best size in report view only.
+ wxSize sizeBest = wxListCtrlBase::DoGetBestClientSize();
if ( !InReportView() )
{