Improve comment
[amule.git] / src / MuleListCtrl.cpp
blob81bf72403991ed318d2ca1a81645605c4fdb8cdb
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include <wx/menu.h> // Needed for wxMenu
27 #include <wx/fileconf.h> // Needed for wxConfig
28 #include <wx/tokenzr.h> // Needed for wxStringTokenizer
29 #include <wx/imaglist.h> // Needed for wxImageList
31 #include <common/MuleDebug.h> // Needed for MULE_VALIDATE_
32 #include <common/StringFunctions.h> // Needed for StrToLong
34 #include <common/MenuIDs.h>
36 #include "MuleListCtrl.h" // Interface declarations
37 #include "GetTickCount.h" // Needed for GetTickCount()
38 #include "OtherFunctions.h"
41 // For arrow-pixmaps
42 #include "pixmaps/sort_dn.xpm"
43 #include "pixmaps/sort_up.xpm"
44 #include "pixmaps/sort_dnx2.xpm"
45 #include "pixmaps/sort_upx2.xpm"
48 // Global constants
49 #ifdef __WXGTK__
50 const int COL_SIZE_MIN = 10;
51 #elif defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXCOCOA__)
52 const int COL_SIZE_MIN = 0;
53 #else
54 #error Need to define COL_SIZE_MIN for your OS
55 #endif
58 BEGIN_EVENT_TABLE(CMuleListCtrl, MuleExtern::wxGenericListCtrl)
59 EVT_LIST_COL_CLICK( -1, CMuleListCtrl::OnColumnLClick)
60 EVT_LIST_COL_RIGHT_CLICK( -1, CMuleListCtrl::OnColumnRClick)
61 EVT_LIST_ITEM_SELECTED(-1, CMuleListCtrl::OnItemSelected)
62 EVT_LIST_ITEM_DESELECTED(-1, CMuleListCtrl::OnItemSelected)
63 EVT_LIST_DELETE_ITEM(-1, CMuleListCtrl::OnItemDeleted)
64 EVT_LIST_DELETE_ALL_ITEMS(-1, CMuleListCtrl::OnAllItemsDeleted)
65 EVT_CHAR( CMuleListCtrl::OnChar)
66 EVT_MENU_RANGE(MP_LISTCOL_1, MP_LISTCOL_15, CMuleListCtrl::OnMenuSelected)
67 EVT_MOUSEWHEEL(CMuleListCtrl::OnMouseWheel)
68 END_EVENT_TABLE()
71 //! Shared list of arrow-pixmaps
72 static wxImageList imgList(16, 16, true, 0);
75 CMuleListCtrl::CMuleListCtrl(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name)
76 : MuleExtern::wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
78 m_sort_func = NULL;
79 m_tts_time = 0;
80 m_tts_item = -1;
81 m_isSorting = false;
83 if (imgList.GetImageCount() == 0) {
84 imgList.Add(wxBitmap(sort_dn_xpm));
85 imgList.Add(wxBitmap(sort_up_xpm));
86 imgList.Add(wxBitmap(sort_dnx2_xpm));
87 imgList.Add(wxBitmap(sort_upx2_xpm));
90 // Default sort-order is to sort by the first column (asc).
91 m_sort_orders.push_back(CColPair(0, 0));
93 SetImageList(&imgList, wxIMAGE_LIST_SMALL);
97 CMuleListCtrl::~CMuleListCtrl()
99 if (!m_name.IsEmpty()) {
100 SaveSettings();
104 long CMuleListCtrl::InsertColumn(long col, const wxString& heading, int format, int width, const wxString& name)
106 if (!name.IsEmpty()) {
107 #ifdef __DEBUG__
108 // Check for valid names
109 wxASSERT_MSG(name.Find(wxT(':')) == wxNOT_FOUND, wxT("Column name \"") + name + wxT("\" contains invalid characters!"));
110 wxASSERT_MSG(name.Find(wxT(',')) == wxNOT_FOUND, wxT("Column name \"") + name + wxT("\" contains invalid characters!"));
112 // Check for uniqueness of names.
113 for (ColNameList::const_iterator it = m_column_names.begin(); it != m_column_names.end(); ++it) {
114 if (name == it->name) {
115 wxFAIL_MSG(wxT("Column name \"") + name + wxT("\" is not unique!"));
118 #endif
119 // Insert name at position col.
120 ColNameList::iterator it = m_column_names.begin();
121 while (it != m_column_names.end() && it->index < col) {
122 ++it;
124 m_column_names.insert(it, ColNameEntry(col, width, name));
125 while (it != m_column_names.end()) {
126 ++it;
127 ++(it->index);
131 return MuleExtern::wxGenericListCtrl::InsertColumn(col, heading, format, width);
134 void CMuleListCtrl::SaveSettings()
136 wxCHECK_RET(!m_name.IsEmpty(), wxT("Cannot save settings for unnamed list"));
138 wxConfigBase* cfg = wxConfigBase::Get();
140 // Save sorting, column and order
141 wxString sortOrder;
142 for (CSortingList::iterator it = m_sort_orders.begin(); it != m_sort_orders.end();) {
143 wxString columnName = GetColumnName(it->first);
144 if (!columnName.IsEmpty()) {
145 sortOrder += columnName;
146 sortOrder += wxT(":");
147 sortOrder += it->second & SORT_DES ? wxT("1") : wxT("0");
148 sortOrder += wxT(":");
149 sortOrder += it->second & SORT_ALT ? wxT("1") : wxT("0");
150 if (++it != m_sort_orders.end()) {
151 sortOrder += wxT(",");
153 } else {
154 ++it;
158 cfg->Write(wxT("/eMule/TableOrdering") + m_name, sortOrder);
160 // Save column widths. ATM this is also used to signify hidden columns.
161 wxString buffer;
162 for (int i = 0; i < GetColumnCount(); ++i) {
163 wxString columnName = GetColumnName(i);
164 if (!columnName.IsEmpty()) {
165 if (!buffer.IsEmpty()) {
166 buffer << wxT(",");
168 int currentwidth = GetColumnWidth(i);
169 int savedsize = (m_column_sizes.size() && (i < (int) m_column_sizes.size())) ? m_column_sizes[i] : 0;
170 buffer << columnName << wxT(":") << ((currentwidth > 0) ? currentwidth : (-1 * savedsize));
174 cfg->Write(wxT("/eMule/TableWidths") + m_name, buffer);
177 void CMuleListCtrl::ParseOldConfigEntries(const wxString& sortOrders, const wxString& columnWidths)
179 // Set sort order (including sort column)
180 wxStringTokenizer tokens(sortOrders, wxT(","));
181 while (tokens.HasMoreTokens()) {
182 wxString token = tokens.GetNextToken();
184 long column = 0;
185 unsigned long order = 0;
187 if (token.BeforeFirst(wxT(' ')).Strip(wxString::both).ToLong(&column)) {
188 if (token.AfterFirst(wxT(' ')).Strip(wxString::both).ToULong(&order)) {
189 column = GetNewColumnIndex(column);
190 // Sanity checking, to avoid asserting if column count changes.
191 if (column >= 0 && column < GetColumnCount()) {
192 // Sanity checking, to avoid asserting if data-format changes.
193 if ((order & ~SORTING_MASK) == 0) {
194 // SetSorting will take care of duplicate entries
195 SetSorting(column, order);
202 // Set column widths
203 int counter = 0;
204 wxStringTokenizer tokenizer(columnWidths, wxT(","));
205 while (tokenizer.HasMoreTokens()) {
206 long idx = GetNewColumnIndex(counter++);
207 long width = StrToLong(tokenizer.GetNextToken());
208 if (idx >= 0) {
209 SetColumnWidth(idx, width);
214 void CMuleListCtrl::LoadSettings()
216 wxCHECK_RET(!m_name.IsEmpty(), wxT("Cannot load settings for unnamed list"));
218 wxConfigBase* cfg = wxConfigBase::Get();
220 // Load sort order (including sort-column)
221 m_sort_orders.clear();
222 wxString sortOrders = cfg->Read(wxT("/eMule/TableOrdering") + m_name, wxEmptyString);
223 wxString columnWidths = cfg->Read(wxT("/eMule/TableWidths") + m_name, wxEmptyString);
225 // Prevent sorting from occuring when calling SetSorting
226 MuleListCtrlCompare sortFunc = m_sort_func;
227 m_sort_func = NULL;
229 if (columnWidths.Find(wxT(':')) == wxNOT_FOUND) {
230 // Old-style config entries...
231 ParseOldConfigEntries(sortOrders, columnWidths);
232 } else {
233 // Sort orders
234 wxStringTokenizer tokens(sortOrders, wxT(","));
235 while (tokens.HasMoreTokens()) {
236 wxString token = tokens.GetNextToken();
237 wxString name = token.BeforeFirst(wxT(':'));
238 long order = StrToLong(token.AfterFirst(wxT(':')).BeforeLast(wxT(':')));
239 long alt = StrToLong(token.AfterLast(wxT(':')));
240 int col = GetColumnIndex(name);
241 if (col > 0) {
242 SetSorting(col, (order ? SORT_DES : 0) | (alt ? SORT_ALT : 0));
246 // Column widths
247 wxStringTokenizer tkz(columnWidths, wxT(","));
248 while (tkz.HasMoreTokens()) {
249 wxString token = tkz.GetNextToken();
250 wxString name = token.BeforeFirst(wxT(':'));
251 long width = StrToLong(token.AfterFirst(wxT(':')));
252 int col = GetColumnIndex(name);
253 if (col >= 0) {
254 if (col >= (int) m_column_sizes.size()) {
255 m_column_sizes.resize(col + 1, 0);
257 m_column_sizes[col] = abs(width);
258 SetColumnWidth(col, (width > 0) ? width : 0);
263 // Must have at least one sort-order specified
264 if (m_sort_orders.empty()) {
265 m_sort_orders.push_back(CColPair(0, 0));
268 // Re-enable sorting and resort the contents (if any).
269 m_sort_func = sortFunc;
270 SortList();
274 const wxString& CMuleListCtrl::GetColumnName(int index) const
276 for (ColNameList::const_iterator it = m_column_names.begin(); it != m_column_names.end(); ++it) {
277 if (it->index == index) {
278 return it->name;
281 return EmptyString;
284 int CMuleListCtrl::GetColumnDefaultWidth(int index) const
286 for (ColNameList::const_iterator it = m_column_names.begin(); it != m_column_names.end(); ++it) {
287 if (it->index == index) {
288 return it->defaultWidth;
291 return wxLIST_AUTOSIZE;
294 int CMuleListCtrl::GetColumnIndex(const wxString& name) const
296 for (ColNameList::const_iterator it = m_column_names.begin(); it != m_column_names.end(); ++it) {
297 if (it->name == name) {
298 return it->index;
301 return -1;
304 int CMuleListCtrl::GetNewColumnIndex(int oldindex) const
306 wxStringTokenizer oldcolumns(GetOldColumnOrder(), wxT(","), wxTOKEN_RET_EMPTY_ALL);
308 while (oldcolumns.HasMoreTokens()) {
309 wxString name = oldcolumns.GetNextToken();
310 if (oldindex == 0) {
311 return GetColumnIndex(name);
313 --oldindex;
315 return -1;
318 long CMuleListCtrl::GetInsertPos(wxUIntPtr data)
320 // Find the best place to position the item through a binary search
321 int Min = 0;
322 int Max = GetItemCount();
324 // Only do this if there are any items and a sorter function.
325 // Otherwise insert at end.
326 if (Max && m_sort_func) {
327 // This search will find the place to position the new item
328 // so it matches current sorting.
329 // The result will be the position the new item will have
330 // after insertion, which is the format expected by the InsertItem function.
331 // If the item equals another item it will be inserted after it.
332 do {
333 int cur_pos = ( Max - Min ) / 2 + Min;
334 int cmp = CompareItems(data, GetItemData(cur_pos));
336 // Value is less than the one at the current pos
337 if ( cmp < 0 ) {
338 Max = cur_pos;
339 } else {
340 Min = cur_pos + 1;
342 } while ((Min != Max));
345 return Max;
349 int CMuleListCtrl::CompareItems(wxUIntPtr item1, wxUIntPtr item2)
351 CSortingList::const_iterator it = m_sort_orders.begin();
352 for (; it != m_sort_orders.end(); ++it) {
353 int result = m_sort_func(item1, item2, it->first | it->second);
354 if (result != 0) {
355 return result;
359 // Ensure that different items are never considered equal.
360 return CmpAny(item1, item2);
363 int CMuleListCtrl::SortProc(wxUIntPtr item1, wxUIntPtr item2, long data)
365 MuleSortData* sortdata = (MuleSortData*) data;
366 const CSortingList& orders = sortdata->m_sort_orders;
368 CSortingList::const_iterator it = orders.begin();
369 for (; it != orders.end(); ++it) {
370 int result = sortdata->m_sort_func(item1, item2, it->first | it->second);
371 if (result != 0) {
372 return result;
376 // Ensure that different items are never considered equal.
377 return CmpAny(item1, item2);
380 void CMuleListCtrl::SortList()
382 if (!IsSorting() && (m_sort_func && GetColumnCount())) {
384 m_isSorting = true;
386 // Positions are likely to be invalid after sorting.
387 ResetTTS();
389 MuleSortData sortdata(m_sort_orders, m_sort_func);
391 // Store the current selected items
392 ItemDataList selectedItems = GetSelectedItems();
393 // Store the focused item
394 long pos = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED );
395 wxUIntPtr focused = (pos == -1) ? 0 : GetItemData(pos);
397 SortItems(SortProc, (long int)&sortdata);
399 // Re-select the selected items.
400 for (unsigned i = 0; i < selectedItems.size(); ++i) {
401 long it_pos = FindItem(-1, selectedItems[i]);
402 if (it_pos != -1) {
403 SetItemState(it_pos, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
407 // Set focus on item if any was focused
408 if (focused) {
409 long it_pos = FindItem(-1, focused);
410 if (it_pos != -1) {
411 SetItemState(it_pos, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
415 m_isSorting = false;
419 CMuleListCtrl::ItemDataList CMuleListCtrl::GetSelectedItems() const
421 // Create the initial vector with as many items as are selected
422 ItemDataList list( GetSelectedItemCount() );
424 // Current item being located
425 unsigned int current = 0;
427 long pos = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
428 while ( pos != -1 ) {
429 wxASSERT( current < list.size() );
431 list[ current++ ] = GetItemData( pos );
433 pos = GetNextItem( pos, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
436 return list;
440 void CMuleListCtrl::OnColumnRClick(wxListEvent& evt)
442 wxMenu menu;
443 wxListItem item;
445 for ( int i = 0; i < GetColumnCount() && i < 15; ++i) {
446 GetColumn(i, item);
448 menu.AppendCheckItem(i + MP_LISTCOL_1, item.GetText() );
449 menu.Check( i + MP_LISTCOL_1, GetColumnWidth(i) > COL_SIZE_MIN );
452 PopupMenu(&menu, evt.GetPoint());
456 void CMuleListCtrl::OnMenuSelected( wxCommandEvent& evt )
458 unsigned int col = evt.GetId() - MP_LISTCOL_1;
460 if (col >= m_column_sizes.size()) {
461 m_column_sizes.resize(col + 1, 0);
464 if (GetColumnWidth(col) > COL_SIZE_MIN) {
465 m_column_sizes[col] = GetColumnWidth(col);
466 SetColumnWidth(col, 0);
467 } else {
468 int oldsize = m_column_sizes[col];
469 SetColumnWidth(col, (oldsize > 0) ? oldsize : GetColumnDefaultWidth(col));
474 void CMuleListCtrl::OnColumnLClick(wxListEvent& evt)
476 // Stop if no sorter-function has been defined
477 if (!m_sort_func) {
478 return;
479 } else if (evt.GetColumn() == -1) {
480 // This happens if a user clicks past the last column header.
481 return;
484 unsigned sort_order = 0;
485 if (m_sort_orders.front().first == (unsigned)evt.GetColumn()) {
486 // Same column as before, flip the sort-order
487 sort_order = m_sort_orders.front().second;
489 if (sort_order & SORT_DES) {
490 if (AltSortAllowed(evt.GetColumn())) {
491 sort_order = (~sort_order) & SORT_ALT;
492 } else {
493 sort_order = 0;
495 } else {
496 sort_order = SORT_DES | (sort_order & SORT_ALT);
499 m_sort_orders.pop_front();
500 } else {
501 // Check if the column has already been set
502 CSortingList::iterator it = m_sort_orders.begin();
503 for (; it != m_sort_orders.end(); ++it) {
504 if ((unsigned)evt.GetColumn() == it->first) {
505 sort_order = it->second;
506 break;
512 SetSorting(evt.GetColumn(), sort_order);
516 void CMuleListCtrl::ClearSelection()
518 if (GetSelectedItemCount()) {
519 long index = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
520 while (index != -1) {
521 SetItemState(index, 0, wxLIST_STATE_SELECTED);
522 index = GetNextItem(index, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
528 bool CMuleListCtrl::AltSortAllowed(unsigned WXUNUSED(column)) const
530 return false;
534 void CMuleListCtrl::SetSorting(unsigned column, unsigned order)
536 MULE_VALIDATE_PARAMS(column < (unsigned)GetColumnCount(), wxT("Invalid column to sort by."));
537 MULE_VALIDATE_PARAMS(!(order & ~SORTING_MASK), wxT("Sorting order contains invalid data."));
539 if (!m_sort_orders.empty()) {
540 SetColumnImage(m_sort_orders.front().first, -1);
542 CSortingList::iterator it = m_sort_orders.begin();
543 for (; it != m_sort_orders.end(); ++it) {
544 if (it->first == column) {
545 m_sort_orders.erase(it);
546 break;
551 m_sort_orders.push_front(CColPair(column, order));
553 if (order & SORT_DES) {
554 SetColumnImage(column, (order & SORT_ALT) ? 2 : 0);
555 } else {
556 SetColumnImage(column, (order & SORT_ALT) ? 3 : 1);
559 SortList();
563 bool CMuleListCtrl::IsItemSorted(long item)
565 wxCHECK_MSG(m_sort_func, true, wxT("No sort function specified!"));
566 wxCHECK_MSG((item >= 0) && (item < GetItemCount()), true, wxT("Invalid item"));
568 bool sorted = true;
569 wxUIntPtr data = GetItemData(item);
571 // Check that the item before the current item is smaller (or equal)
572 if (item > 0) {
573 sorted &= (CompareItems(GetItemData(item - 1), data) <= 0);
576 // Check that the item after the current item is greater (or equal)
577 if (sorted && (item < GetItemCount() - 1)) {
578 sorted &= (CompareItems(GetItemData(item + 1), data) >= 0);
581 return sorted;
585 void CMuleListCtrl::OnMouseWheel(wxMouseEvent &event)
587 // This enables scrolling with the mouse wheel
588 event.Skip();
592 void CMuleListCtrl::SetColumnImage(unsigned col, int image)
594 wxListItem item;
595 item.SetMask(wxLIST_MASK_IMAGE);
596 item.SetImage(image);
597 SetColumn(col, item);
601 long CMuleListCtrl::CheckSelection(wxMouseEvent& event)
603 int flags = 0;
604 wxListEvent evt;
605 evt.m_itemIndex = HitTest(event.GetPosition(), flags);
607 return CheckSelection(evt);
611 long CMuleListCtrl::CheckSelection(wxListEvent& event)
613 long item = event.GetIndex();
615 // Check if clicked item is selected. If not, unselect all and select it.
616 if ((item != -1) && !GetItemState(item, wxLIST_STATE_SELECTED)) {
617 ClearSelection();
619 SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
622 return item;
626 wxString CMuleListCtrl::GetTTSText(unsigned item) const
628 MULE_VALIDATE_PARAMS(item < (unsigned)GetItemCount(), wxT("Invalid row."));
629 MULE_VALIDATE_STATE((GetWindowStyle() & wxLC_OWNERDRAW) == 0,
630 wxT("GetTTSText must be overwritten for owner-drawn lists."));
632 return GetItemText(item);
636 void CMuleListCtrl::OnChar(wxKeyEvent& evt)
638 int key = evt.GetKeyCode();
639 if (key == 0) {
640 // We prefer GetKeyCode() to GetUnicodeKey(), in order to work
641 // around a bug in the GetUnicodeKey(), that causes values to
642 // be returned untranslated. This means for instance, that if
643 // shift and '1' is pressed, the result is '1' rather than '!'
644 // (as it should be on my keyboard). This has been reported:
645 // http://sourceforge.net/tracker/index.php?func=detail&aid=1864810&group_id=9863&atid=109863
646 key = evt.GetUnicodeKey();
647 } else if (key >= WXK_START) {
648 // wxKeycodes are ignored, as they signify events such as the 'home'
649 // button. Unicoded chars are not checked as there is an overlap valid
650 // chars and the wx keycodes.
651 evt.Skip();
652 return;
655 // We wish to avoid handling shortcuts, with the exception of 'select-all'.
656 if (evt.AltDown() || evt.ControlDown() || evt.MetaDown()) {
657 if (evt.CmdDown() && (evt.GetKeyCode() == 0x01)) {
658 // Ctrl+a (Command+a on Mac) was pressed, select all items
659 for (int i = 0; i < GetItemCount(); ++i) {
660 SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
664 evt.Skip();
665 return;
666 } else if (m_tts_time + 1500u < GetTickCount()) {
667 m_tts_text.Clear();
670 m_tts_time = GetTickCount();
671 m_tts_text.Append(wxTolower(key));
673 // May happen if the subclass does not forward deletion events.
674 // Or rather when single-char-repeated (see below) wraps around, so don't assert.
675 if (m_tts_item >= GetItemCount()) {
676 m_tts_item = -1;
679 unsigned next = (m_tts_item == -1) ? 0 : m_tts_item;
680 for (unsigned i = 0, count = GetItemCount(); i < count; ++i) {
681 wxString text = GetTTSText((next + i) % count).MakeLower();
683 if (text.StartsWith(m_tts_text)) {
684 ClearSelection();
686 m_tts_item = (next + i) % count;
687 SetItemState(m_tts_item, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
688 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
689 EnsureVisible(m_tts_item);
691 return;
695 if (m_tts_item != -1) {
696 // Crop the string so that it matches the old item (avoid typos).
697 wxString text = GetTTSText(m_tts_item).MakeLower();
699 // If the last key didn't result in a hit, then we skip the event.
700 if (!text.StartsWith(m_tts_text)) {
701 if ((m_tts_text.Length() == 2) && (m_tts_text[0] == m_tts_text[1])) {
702 // Special case, single-char, repeated. This allows toggeling
703 // between items starting with a specific letter.
704 m_tts_text.Clear();
705 // Increment, so the next will be selected (or wrap around).
706 m_tts_item++;
707 OnChar(evt);
708 } else {
709 m_tts_text.RemoveLast();
710 evt.Skip(true);
713 } else {
714 evt.Skip(true);
719 void CMuleListCtrl::OnItemSelected(wxListEvent& evt)
721 if (IsSorting()) {
722 // Selection/Deselection that happened while sorting.
723 evt.Veto();
724 } else {
725 // We reset the current TTS session if the user manually changes the selection
726 if (m_tts_item != evt.GetIndex()) {
727 ResetTTS();
729 // The item is changed so that the next TTS starts from the selected item.
730 m_tts_item = evt.GetIndex();
732 evt.Skip();
737 void CMuleListCtrl::OnItemDeleted(wxListEvent& evt)
739 if (evt.GetIndex() <= m_tts_item) {
740 m_tts_item--;
743 evt.Skip();
747 void CMuleListCtrl::OnAllItemsDeleted(wxListEvent& evt)
749 ResetTTS();
751 evt.Skip();
755 void CMuleListCtrl::ResetTTS()
757 m_tts_item = -1;
758 m_tts_time = 0;
761 wxString CMuleListCtrl::GetOldColumnOrder() const
763 return wxEmptyString;
765 // File_checked_for_headers