int xOld = x;
x += width;
- const int wText = width - 8;
+ width -= 8;
+ const int wText = width;
wxDCClipper clipper(*dc, xOld, rect.y, wText, rect.height);
if ( item->HasImage() )
}
if ( item->HasText() )
- DrawTextFormatted(dc, item->GetText(), col, xOld, yMid, wText);
+ DrawTextFormatted(dc, item->GetText(), col, xOld, yMid, width);
}
}
m_text->PushEventHandler(this);
}
-void wxListTextCtrlWrapper::EndEdit(bool discardChanges)
+void wxListTextCtrlWrapper::EndEdit(EndReason reason)
{
m_aboutToFinish = true;
- if ( discardChanges )
+ switch ( reason )
{
- m_owner->OnRenameCancelled(m_itemEdited);
+ case End_Accept:
+ // Notify the owner about the changes
+ AcceptChanges();
- Finish( true );
- }
- else
- {
- // Notify the owner about the changes
- AcceptChanges();
+ // Even if vetoed, close the control (consistent with MSW)
+ Finish( true );
+ break;
+
+ case End_Discard:
+ m_owner->OnRenameCancelled(m_itemEdited);
+
+ Finish( true );
+ break;
- // Even if vetoed, close the control (consistent with MSW)
- Finish( true );
+ case End_Destroy:
+ // Don't generate any notifications for the control being destroyed
+ // and don't set focus to it neither.
+ Finish(false);
+ break;
}
}
switch ( event.m_keyCode )
{
case WXK_RETURN:
- EndEdit( false );
+ EndEdit( End_Accept );
break;
case WXK_ESCAPE:
- EndEdit( true );
+ EndEdit( End_Discard );
break;
default:
wxListMainWindow::~wxListMainWindow()
{
+ if ( m_textctrlWrapper )
+ m_textctrlWrapper->EndEdit(wxListTextCtrlWrapper::End_Destroy);
+
DoDeleteAllItems();
WX_CLEAR_LIST(wxListHeaderDataList, m_columns);
WX_CLEAR_ARRAY(m_aColWidths);
// listctrl because the order of events is different (or something like
// that), so explicitly end the edit if it is active.
if ( event.LeftDown() && m_textctrlWrapper )
- m_textctrlWrapper->EndEdit( false );
+ m_textctrlWrapper->EndEdit(wxListTextCtrlWrapper::End_Accept);
#endif // __WXMAC__
if ( event.LeftDown() )
void wxGenericListCtrl::DoClientToScreen( int *x, int *y ) const
{
- m_mainWin->DoClientToScreen(x, y);
+ // It's not clear whether this can be called before m_mainWin is created
+ // but it seems better to be on the safe side and check.
+ if ( m_mainWin )
+ m_mainWin->DoClientToScreen(x, y);
+ else
+ wxControl::DoClientToScreen(x, y);
}
void wxGenericListCtrl::DoScreenToClient( int *x, int *y ) const
{
- m_mainWin->DoScreenToClient(x, y);
+ // At least in wxGTK/Univ build this method can be called before m_mainWin
+ // is created so avoid crashes in this case.
+ if ( m_mainWin )
+ m_mainWin->DoScreenToClient(x, y);
+ else
+ wxControl::DoScreenToClient(x, y);
}
void wxGenericListCtrl::SetFocus()