Exemplo n.º 1
0
void EngagementTrigramsListCtrl::SortOnDocument ()
{
  if (_lastsort == sortDoc) return;
  _lastsort = sortDoc;

  std::vector<int> newIndices;

  for (int i = 0 ; i < _sortedIndices.size (); ++i)
  {
    newIndices.push_back (_sortedIndices[i]);
  }

  // cache the names
  std::vector<wxString> names;
  for (int i=0; i<_ferretparent->GetDocumentList().GroupSize (); i++)
  {
    names.push_back (_ferretparent->GetDocumentList().GetGroupName (i));
  }
  // set up sort
  namecmp comparer;
  comparer.names = &names;
  std::sort (newIndices.begin(), newIndices.end (), comparer);
  _sortedIndices = newIndices;
  RefreshItems (0, _sortedIndices.size()-1);
  _ferretparent->SetStatusText ("Rearranged table by name", 0);

}
Exemplo n.º 2
0
void CWndGHTeleporter::OnInitialUpdate()	
{
	CWndNeuz::OnInitialUpdate();

	RestoreDeviceObjects();
	
	m_pOK = (CWndButton*)GetDlgItem( WIDC_BUTTON_OK );
	m_pFire = (CWndButton*)GetDlgItem( WIDC_BUTTON_FIRE );

	m_nCtrlId[0] = WIDC_SLOT1;
	m_nCtrlId[1] = WIDC_SLOT2;
	m_nCtrlId[2] = WIDC_SLOT3;
	m_nCtrlId[3] = WIDC_SLOT4;
	m_nCtrlId[4] = WIDC_SLOT5;

	HOUSING_ITEM kItem;
	kItem.m_nType = EMPTY_SLOT;
	m_cWndItems.resize( MAX_TELEPORTER_SLOT, kItem );

	RefreshItems( );

	// 윈도를 중앙으로 옮기는 부분.
	CRect rectRoot = m_pWndRoot->GetLayoutRect();
	CRect rectWindow = GetWindowRect();
	CPoint point( rectRoot.right - rectWindow.Width(), 110 );
	Move( point );
	MoveParentCenter();
}
Exemplo n.º 3
0
void CDuiTabCtrl::SetControlRect(CRect rc)
{
	__super::SetControlRect(rc);

	// 重新计算所有Tab页的位置
	RefreshItems();
}
void LIBRARY_LISTBOX::SetLibraryList( const wxArrayString& aList )
{
    int oldSelection = GetSelection();

    m_libraryList = aList;

    SetItemCount( m_libraryList.GetCount() );

    if(  GetCount() == 0 || oldSelection < 0 || oldSelection >= GetCount() )
        SetSelection( 0, true );

    if( m_libraryList.Count() )
    {
        RefreshItems( 0L, m_libraryList.Count()-1 );

#if defined (__WXGTK__ ) && wxMINOR_VERSION == 8
        // @bug On GTK and wxWidgets 2.8.x, this will assert in debug builds because the
        //      column parameter is -1.  This was the only way to prevent GTK3 from
        //      ellipsizing long strings down to a few characters.  It still doesn't set
        //      the scroll bars correctly (too short) but it's better than any of the
        //      other alternatives.  If someone knows how to fix this, please do.
        SetColumnWidth( -1, wxLIST_AUTOSIZE );
#else
        SetColumnWidth( 0, wxLIST_AUTOSIZE );
#endif
    }
}
Exemplo n.º 5
0
// 删除指定tab页
void CDuiTabCtrl::DeleteItem(int nItem)
{
	if((nItem < 0) || (nItem >= (int)m_vecItemInfo.size()))
	{
		return;
	}

	int nIndex = 0;
	vector<TabItemInfo>::iterator it;
	for(it=m_vecItemInfo.begin();it!=m_vecItemInfo.end();++it)
	{
		if(nIndex == nItem)
		{
			TabItemInfo &itemInfo = *it;
			if(itemInfo.pControl != NULL)
			{
				RemoveControl(itemInfo.pControl);
			}
			m_vecItemInfo.erase(it);
			break;
		}
		nIndex++;
	}

	// 重新计算每个tab页的位置,并刷新界面
	RefreshItems();
}
Exemplo n.º 6
0
void PoeditListCtrl::ReadCatalog()
{
    wxWindowUpdateLocker no_updates(this);

    // clear the list and its sort order too:
    SetItemCount(0);
    m_mapListToCatalog.clear();
    m_mapCatalogToList.clear();

    if (m_catalog == NULL)
    {
        Refresh();
        return;
    }

    // sort catalog items, create indexes mapping
    CreateSortMap();

    // now that everything is prepared, we may set the item count
    SetItemCount(m_catalog->GetCount());

    // scroll to the top and refresh everything:
    if ( m_catalog->GetCount() )
    {
        Select(0);
        RefreshItems(0, m_catalog->GetCount()-1);
    }
    else
    {
        Refresh();
    }
}
Exemplo n.º 7
0
bool
CProject::Open(const char* filename)
{
  Destroy();
  // set the game directory
  m_Directory = filename;
  if (m_Directory.rfind('\\') != std::string::npos)
    m_Directory[m_Directory.rfind('\\')] = 0;
  // set the game filename
  m_Filename = filename;
  if (1) {
    char directory[MAX_PATH];
    GetCurrentDirectory(MAX_PATH, directory);
    if (SetCurrentDirectory(m_Directory.c_str()) == 0)
      return false;
    FILE* file = fopen(m_Filename.c_str(), "a");
    if (!file) return false;
    fclose(file);
    SetCurrentDirectory(directory);
  }
  // load the game.sgm
  CConfigFile config;
  if (!config.Load(m_Filename.c_str()))
    return false;
  m_GameTitle   = config.ReadString("", "name",        "Untitled");
  m_Author      = config.ReadString("", "author",      "Unknown");
  m_Description = config.ReadString("", "description", "");
  m_GameScript = config.ReadString("", "script", "");
  // screen dimensions
  m_ScreenWidth  = config.ReadInt("", "screen_width", 320);
  m_ScreenHeight = config.ReadInt("", "screen_height", 240);
  RefreshItems();
  return true;
}
void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
                                        COMPONENT* aComponent, int aFilterType )
{
    wxArrayString   newList;
    wxString        msg;
    wxString        oldSelection;

    if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() )
        oldSelection = m_footprintList[ GetSelection() ];

    for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
    {
        if( aFilterType == UNFILTERED )
        {
            msg.Printf( wxT( "%3d %s:%s" ), int( newList.GetCount() + 1 ),
                        GetChars( aList.GetItem( ii ).GetNickname() ),
                        GetChars( aList.GetItem( ii ).GetFootprintName() ) );
            newList.Add( msg );
            continue;
        }

        if( (aFilterType & BY_LIBRARY) && !aLibName.IsEmpty()
                && !aList.GetItem( ii ).InLibrary( aLibName ) )
            continue;

        if( (aFilterType & BY_COMPONENT) && aComponent
                && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).GetFootprintName() ) )
            continue;

        if( (aFilterType & BY_PIN_COUNT) && aComponent
                && aComponent->GetNetCount() != aList.GetItem( ii ).GetUniquePadCount() )
            continue;

        msg.Printf( wxT( "%3d %s:%s" ), int( newList.GetCount() + 1 ),
                    GetChars( aList.GetItem( ii ).GetNickname() ),
                    GetChars( aList.GetItem( ii ).GetFootprintName() ) );
        newList.Add( msg );
    }

    if( newList == m_footprintList )
        return;

    m_footprintList = newList;

    int selection = m_footprintList.Index( oldSelection );

    if( selection == wxNOT_FOUND )
        selection = 0;

    DeleteAllItems();

    if( m_footprintList.GetCount() )
    {
        SetItemCount( m_footprintList.GetCount() );
        SetSelection( selection, true );
        RefreshItems( 0L, m_footprintList.GetCount()-1 );
        UpdateWidth();
    }
}
Exemplo n.º 9
0
void mmAssetsListCtrl::OnEndLabelEdit(wxListEvent& event)
{
    if (event.IsEditCancelled()) return;
    Model_Asset::Data* asset = &m_panel->m_assets[event.GetIndex()];
    asset->ASSETNAME = event.m_item.m_text;
    Model_Asset::instance().save(asset);
    RefreshItems(event.GetIndex(), event.GetIndex());
}
Exemplo n.º 10
0
void DictionaryListCtrl::ClearDictionaries()
{
    m_items.Clear();
    SetItemCount(0);
    RefreshItems(0, 0);
    DeleteAllItems();
    SetColumnWidths(wxLIST_AUTOSIZE_USEHEADER);
}
Exemplo n.º 11
0
void DictionaryListCtrl::SetDictionaries(DictionaryArray items)
{
    m_items = items;
    DeleteAllItems();
    SetItemCount(m_items.GetCount());
    RefreshItems(0, GetItemCount());
    SetColumnWidths(wxLIST_AUTOSIZE);
}
Exemplo n.º 12
0
void CustomVirtListCtrl<T,L>::RefreshVisibleItems()
{
	if ( m_data.empty() )
		return;
	const long topItemIndex = GetTopItem();
	const long range = topItemIndex + GetCountPerPage();
	RefreshItems( topItemIndex,  LSL::Util::Clamp( range, topItemIndex, (long) m_data.size() -1 ) );
}
Exemplo n.º 13
0
void CDuiTabCtrl::SetControlRect(CRect rc)
{
	__super::SetControlRect(rc);

	// 调整tab页签的宽度
	SetItemWidth(m_nTabItemMaxWidth, m_nTabItemMinWidth, FALSE);

	// 重新计算所有Tab页的位置
	RefreshItems();
}
Exemplo n.º 14
0
void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
                                        COMPONENT* aComponent,
                                        const wxString &aFootPrintFilterPattern,
                                        int aFilterType )
{
    wxArrayString   newList;
    wxString        msg;
    wxString        oldSelection;

    FOOTPRINT_FILTER filter( aList );

    if( aFilterType & FILTERING_BY_COMPONENT_KEYWORD && aComponent )
        filter.FilterByFootprintFilters( aComponent->GetFootprintFilters() );

    if( aFilterType & FILTERING_BY_PIN_COUNT && aComponent )
        filter.FilterByPinCount( aComponent->GetNetCount() );

    if( aFilterType & FILTERING_BY_LIBRARY )
        filter.FilterByLibrary( aLibName );

    if( aFilterType & FILTERING_BY_NAME )
        filter.FilterByPattern( aFootPrintFilterPattern );

    if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() )
        oldSelection = m_footprintList[ GetSelection() ];

    for( auto& i: filter )
    {
        msg.Printf( "%3d %s:%s", int( newList.GetCount() + 1 ),
                    GetChars( i.GetNickname() ),
                    GetChars( i.GetFootprintName() ) );
        newList.Add( msg );
    }

    if( newList == m_footprintList )
        return;

    m_footprintList = newList;

    int selection = m_footprintList.Index( oldSelection );

    if( selection == wxNOT_FOUND )
        selection = 0;

    wxWindowUpdateLocker freeze( this );
    DeleteAllItems();

    if( m_footprintList.GetCount() )
    {
        SetItemCount( m_footprintList.GetCount() );
        SetSelection( selection, true );
        RefreshItems( 0L, m_footprintList.GetCount()-1 );
        UpdateWidth();
    }
}
Exemplo n.º 15
0
// 设置tab页的可见性
void CDuiTabCtrl::SetItemVisible(int nItem, BOOL bVisible)
{
	if((nItem < 0) || (nItem >= (int)m_vecItemInfo.size()))
	{
		return;
	}

	TabItemInfo &itemInfo = m_vecItemInfo.at(nItem);
	itemInfo.bVisible = bVisible;

	// 重新计算每个tab页的位置,并刷新界面
	RefreshItems();
}
Exemplo n.º 16
0
bool CustomVirtListCtrl<T,L>::RemoveItem( const T& item )
{
	int index = GetIndexFromData( item );
	if ( (index >= 0) && (index<(long)m_data.size()) ) {
		SelectionSaver<ThisType>(*this);
		m_data.erase( m_data.begin() + index );
		SetItemCount( m_data.size() );
		if (index>(long)m_data.size()-1)
			index--;
		RefreshItems( index, m_data.size() -1 );
		return true;
	}
	return false;
}
Exemplo n.º 17
0
void PoeditListCtrl::Sort()
{
    if ( m_catalog && m_catalog->GetCount() )
    {
        SelectionPreserver preserve(this);

        CreateSortMap();
        RefreshItems(0, m_catalog->GetCount()-1);
    }
    else
    {
        Refresh();
    }
}
Exemplo n.º 18
0
void PoeditListCtrl::ReadCatalog()
{
    wxWindowUpdateLocker no_updates(this);

    // clear the list and its sort order too:
    SetItemCount(0);
    m_mapListToCatalog.clear();
    m_mapCatalogToList.clear();

    if (m_catalog == NULL)
    {
        Refresh();
        return;
    }

    auto lang = m_catalog->GetLanguage();
    auto isRTL = lang.IsRTL();
#ifdef __WXMSW__
    // a quirk of wx API: if the current locale is RTL, the meaning of L and R is reversed
    if (m_appIsRTL)
        isRTL = !isRTL;
#endif
    m_isRTL = isRTL;

    wxString langname = lang.IsValid() ? lang.DisplayName() : _("unknown language");
    wxListItem colInfo;
    colInfo.SetMask(wxLIST_MASK_TEXT);
    colInfo.SetText(wxString::Format(_(L"Translation — %s"), langname));
    colInfo.SetAlign(isRTL ? wxLIST_FORMAT_RIGHT : wxLIST_FORMAT_LEFT);
    SetColumn(1, colInfo);

    // sort catalog items, create indexes mapping
    CreateSortMap();

    // now that everything is prepared, we may set the item count
    SetItemCount(m_catalog->GetCount());

    // scroll to the top and refresh everything:
    if ( m_catalog->GetCount() )
    {
        SelectOnly(0);
        RefreshItems(0, m_catalog->GetCount()-1);
    }
    else
    {
        Refresh();
    }
}
Exemplo n.º 19
0
void DictionaryListCtrl::SetType(ListType t)
{
    m_type = t;
    for (int i = GetColumnCount() - 1; i >= 0; --i) {
        DeleteColumn(i);
    }
    InsertColumn(0, _("Filename"));
    if (m_type == wxLOCAL) {
        InsertColumn(1, _("Size"));
        SetColumnWidths(60);
    } else {
        SetColumnWidths(0);
    }
    SetFont(wxFont(8, 76, 90, 90, false, wxEmptyString));
    RefreshItems(0, GetItemCount());
}
Exemplo n.º 20
0
void PoeditListCtrl::Sort()
{
    if ( m_catalog && m_catalog->GetCount() )
    {
        auto sel = GetSelectedCatalogItems();

        CreateSortMap();
        RefreshItems(0, m_catalog->GetCount()-1);

        SetSelectedCatalogItems(sel);
    }
    else
    {
        Refresh();
    }
}
Exemplo n.º 21
0
// 从嵌套的xml文件中加载tab页
BOOL CDuiTabCtrl::LoadTabXml(CString strFileName)
{
	// 首先将所有tab页都隐藏
	for(size_t i = 0; i < m_vecItemInfo.size(); i++)
	{
		TabItemInfo &itemInfo = m_vecItemInfo.at(i);
		if(itemInfo.pControl != NULL)
		{
			itemInfo.pControl->SetVisible(FALSE);
		}
	}

	DuiXmlDocument xmlDoc;
	DuiXmlNode pTabElem;

	if(DuiSystem::Instance()->LoadXmlFile(xmlDoc, strFileName))
	{
		pTabElem = xmlDoc.child(GetClassName());
		if(pTabElem != NULL)
		{
			// 加载下层tab页
			Load(pTabElem, FALSE);
		}
	}

	// 只显示当前活动的tab页对应的Panel对象,其他页面的Panel对象都隐藏
	for(size_t i = 0; i < m_vecItemInfo.size(); i++)
	{
		TabItemInfo &itemInfo = m_vecItemInfo.at(i);
		if(itemInfo.pControl != NULL)
		{
			if(i == m_nDownItem)
			{
				itemInfo.pControl->SetVisible(TRUE);
			}else
			{
				itemInfo.pControl->SetVisible(FALSE);
			}
		}
	}

	// 重新计算每个tab页的位置,并刷新界面
	RefreshItems();

	return TRUE;
}
Exemplo n.º 22
0
bool
CProject::Create(const char* games_directory, const char* project_name)
{
  // create the project
  if (SetCurrentDirectory(games_directory) == FALSE)
    return false;
  
  // if creating the directory failed, it may already exist
  CreateDirectory(project_name, NULL);
  // now create all of the subdirectories
  for (int i = 0; i < NUM_GROUP_TYPES; i++)
  {
    if (i == GT_TILESETS || i == GT_PLAYLISTS)
      continue;
    std::string directory = project_name;
    directory += "/";
    directory += GetGroupDirectory(i);
    CreateDirectory(directory.c_str(), NULL);
  }
  // create an 'other' subdirectory too
  std::string directory = project_name;
  directory += "/other";
  CreateDirectory(directory.c_str(), NULL);
  
  // wait to see if SetCurrentDirectory() fails
  if (SetCurrentDirectory(project_name) == FALSE)
    return false;
  // set the project directory
  char path[MAX_PATH];
  if (GetCurrentDirectory(MAX_PATH, path) == FALSE)
    return false;
  m_Directory = path;
    
  // set the project filename
  m_Filename = path;
  m_Filename += "\\game.sgm";
  // set default values in project
  m_GameTitle   = "Untitled";
  m_Author      = "Unknown";
  m_Description = "";
  m_GameScript = "";
  m_ScreenWidth = 320;
  m_ScreenHeight = 240;
  RefreshItems();
  return Save();
}
Exemplo n.º 23
0
// 设置Tab页签的宽度
void CDuiTabCtrl::SetItemWidth(int nTabItemMaxWidth, int nTabItemMinWidth, BOOL bRefresh)
{
	if(nTabItemMaxWidth != m_nTabItemMaxWidth)
	{
		m_nTabItemMaxWidth = nTabItemMaxWidth;
	}
	if(nTabItemMinWidth != m_nTabItemMinWidth)
	{
		m_nTabItemMinWidth = nTabItemMinWidth;
	}

	if(GetItemCount() == 0)
	{
		return;
	}

	int nTabItemWidth = m_nTabItemMaxWidth;
	if(m_nTabItemMinWidth > 0)
	{
		// 如果设置了页签的最小宽度,则计算页签实际宽度
		int nTabTotalWidth = m_rc.Width() - m_nTabLeftPading - m_nTabRightPading;
		int nTabItemCount = GetItemCount();
		int nTabItemAveWidth = nTabTotalWidth / nTabItemCount;
		if((nTabItemAveWidth < m_nTabItemMaxWidth) && (nTabItemAveWidth >= m_nTabItemMinWidth))
		{
			// 如果平均宽度介于最小宽度和最大宽度之间,则设置为平均宽度
			nTabItemWidth = nTabItemAveWidth;
		}else
		if(nTabItemAveWidth < m_nTabItemMinWidth)
		{
			// 如果平均宽度小于最小宽度,则设置为最小宽度
			nTabItemWidth = m_nTabItemMinWidth;
		}
	}

	// 如果计算出的宽度和之前的宽度不一致,则刷新tab页
	if(nTabItemWidth != m_nTabItemWidth)
	{
		m_nTabItemWidth = nTabItemWidth;
		if(bRefresh)	// 是否刷新tab页
		{
			RefreshItems();
		}
	}
}
void HOTKEY_LIST_CTRL::RestoreFrom( struct EDA_HOTKEY_CONFIG* aSection )
{
    int row = 0;

    EDA_HOTKEY** info_ptr;

    for( info_ptr = aSection->m_HK_InfoList; *info_ptr; info_ptr++ )
    {
        EDA_HOTKEY* info = *info_ptr;
        m_hotkeys[row++]->m_KeyCode = info->m_KeyCode;
    }

    // Remove selection
    DeselectRow( m_curEditingRow );
    m_curEditingRow = -1;

    RefreshItems( 0, m_hotkeys.size()-1 );
}
Exemplo n.º 25
0
bool CustomVirtListCtrl<T,L>::RemoveItem( const T& item )
{
	int index = GetIndexFromData( item );
	if ( (index >= 0) && (index<(long)m_data.size()) ) {
		SaveSelection();
		m_data.erase( m_data.begin() + index );
		SetItemCount( m_data.size() );
		if (index>(long)m_data.size()-1)
			index--;
		if (m_data.size() > 0) {
			RefreshItems( index, m_data.size() -1 );
			RestoreSelection();
		} else {
			Clear();
		}
		return true;
	}
	return false;
}
Exemplo n.º 26
0
void billsDepositsListCtrl::refreshVisualList(int selected_index)
{

    if (selected_index >= (long)m_bdp->bills_.size() || selected_index < 0)
        selected_index = - 1;
    if (!m_bdp->bills_.empty()) {
        RefreshItems(0, m_bdp->bills_.size() - 1);
    }
    else
        selected_index = -1;

    if (selected_index >= 0 && !m_bdp->bills_.empty())
    {
        SetItemState(selected_index, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        SetItemState(selected_index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
        EnsureVisible(selected_index);
    }
    m_selected_row = selected_index;
    m_bdp->updateBottomPanelData(selected_index);
}
Exemplo n.º 27
0
void EngagementTrigramsListCtrl::SortOnCount ()
{
  if (_lastsort == sortCount) return;
  _lastsort = sortCount;
  
  std::vector<int> newIndices;
 
  // initialise the set of new indices
  for (int i = 0; i < _sortedIndices.size (); ++i)
  {
    newIndices.push_back (_sortedIndices[i]);
  }
  
  std::sort (newIndices.begin(), newIndices.end(), 
      _ferretparent->GetDocumentList().GetEngagementCountComparer ());

  _sortedIndices = newIndices;
  RefreshItems (0, _sortedIndices.size()-1);
  _ferretparent->SetStatusText ("Rearranged table by engagement count", 0);
}
Exemplo n.º 28
0
// 删除指定tab页(按照名字)
void CDuiTabCtrl::DeleteItem(CString strTabName)
{
	vector<TabItemInfo>::iterator it;
	for(it=m_vecItemInfo.begin();it!=m_vecItemInfo.end();++it)
	{
		TabItemInfo &itemInfo = *it;
		if(itemInfo.strName == strTabName)
		{
			if(itemInfo.pControl != NULL)
			{
				RemoveControl(itemInfo.pControl);
			}
			m_vecItemInfo.erase(it);
			break;
		}
	}

	// 重新计算每个tab页的位置,并刷新界面
	RefreshItems();
}
Exemplo n.º 29
0
void DocumentListCtrl::SortOnResemblance (bool force_sort)
{
	if (_lastsort == sortResemblance && !force_sort) return;
	_lastsort = sortResemblance;
	// get current selected item
	long item_number = GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	int selected_item = (item_number == -1 ? -1 : _sortedIndices[(int)item_number]);

	std::vector<int> newIndices;

	// initialise the set of new indices
	for (int i=0; i < _sortedIndices.size(); ++i)
	{
		newIndices.push_back (_sortedIndices[i]);
	}
	
	std::sort (newIndices.begin(), newIndices.end(), 
			_ferretparent->GetDocumentList().GetSimilarityComparer (&_document1, &_document2, _remove_common_trigrams, _ignore_template_material));

	_sortedIndices = newIndices;
	RefreshItems (0, _sortedIndices.size()-1);
	// select original item
	if (selected_item != -1)
	{
		// find item in sorted indices, and select that position
		for (long i = 0, n = _sortedIndices.size(); i < n; ++i)
		{
			SetItemState (i, !wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
			if (_sortedIndices[i] == selected_item)
			{
				SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
				EnsureVisible (i);
			}
		}
	}

	Refresh ();
	_ferretparent->SetStatusText ("Rearranged table by similarity", 0);
}
Exemplo n.º 30
0
void StocksListCtrl::doRefreshItems(int trx_id)
{
    int selectedIndex = initVirtualListControl(trx_id, m_selected_col, m_asc);
    long cnt = static_cast<long>(m_stocks.size());

    if (selectedIndex >= cnt || selectedIndex < 0)
        selectedIndex = m_asc ? cnt - 1 : 0;

    if (cnt>0)
    {
        RefreshItems(0, cnt > 0 ? cnt - 1 : 0);
    }
    else
        selectedIndex = -1;

    if (selectedIndex >= 0 && cnt>0)
    {
        SetItemState(selectedIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        SetItemState(selectedIndex, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
        EnsureVisible(selectedIndex);
    }
}