示例#1
0
wxString CQueueViewBase::OnGetItemText(long item, long column) const
{
	if (column < 0 || static_cast<size_t>(column) >= m_columns.size())
		return wxString();

	CQueueViewBase* pThis = const_cast<CQueueViewBase*>(this);

	CQueueItem* pItem = pThis->GetQueueItem(item);
	if (!pItem)
		return wxString();

	return OnGetItemText(pItem, m_columns[column]);
}
示例#2
0
void CSourcesListBox::EndEditLabel( wxListEvent& event )
{
#if wxVERSION_NUMBER >= 2500
	if(event.IsEditCancelled())
		return;
#endif
    wxString sCheck = event.GetText();
	sCheck.Replace( wxT( " " ), wxT( "" ), TRUE );
	if ( sCheck.IsEmpty() )
		return; // do not want to rename to an empty string ( or one that only consists of spaces

	EMUSIK_SOURCES_TYPE nType = GetType( event.GetIndex() );

	wxString sType;
	if(!GetTypeAsString(nType,sType))
	{
		wxASSERT(FALSE);
		return;
	}
	//--- Musik Library entry edited ---//
	if ( nType == MUSIK_SOURCES_LIBRARY )
	{
 		
	}
	//--- Now Playing entry edited ---//
	else if ( nType == MUSIK_SOURCES_NOW_PLAYING )
	{
        
	}
	//--- "playlist with data in a file" renamed ---//
	else
	{
		//--- rename file ---//
		wxString sOldFile = OnGetItemText(event.GetIndex(),0);
		wxString sNewFile = event.GetText();
		
		SourcesToFilename( &sOldFile, nType );
		SourcesToFilename( &sNewFile, nType );

		wxRenameFile( sOldFile, sNewFile );
	}
	//--- rename in musiksources.dat ---//
	m_SourcesList.Item( event.GetIndex() ) = sType + event.GetText();
}
示例#3
0
wxString StocksListCtrl::getStockInfo(int selectedIndex) const
{
    int purchasedTime = 0;
    double stocktotalnumShares = 0;
    double stockavgPurchasePrice = 0;
    for (const auto& s: Model_Stock::instance().find(Model_Stock::SYMBOL(m_stocks[selectedIndex].SYMBOL)))
    {
        purchasedTime++;
        stocktotalnumShares += s.NUMSHARES;
        stockavgPurchasePrice += s.PURCHASEPRICE * s.NUMSHARES;
    }
    stockavgPurchasePrice /= stocktotalnumShares;

    double sNumShares = m_stocks[selectedIndex].NUMSHARES;
    wxString sTotalNumShares;
    if ((stocktotalnumShares - static_cast<long>(stocktotalnumShares)) != 0.0)
        sTotalNumShares = wxString::Format("%.4f", stocktotalnumShares);
    else
        sTotalNumShares <<  static_cast<long>(stocktotalnumShares);
    wxString sGainLoss = Model_Currency::toCurrency(getGainLoss(selectedIndex));

    double stockPurchasePrice = m_stocks[selectedIndex].PURCHASEPRICE;
    double stockCurrentPrice = m_stocks[selectedIndex].CURRENTPRICE;
    double stockDifference = stockCurrentPrice - stockPurchasePrice;

    double stocktotalDifference = stockCurrentPrice - stockavgPurchasePrice;
    //Commision don't calculates here
    double stockPercentage = (stockCurrentPrice / stockPurchasePrice - 1.0)*100.0;
    double stocktotalPercentage = (stockCurrentPrice / stockavgPurchasePrice - 1.0)*100.0;
    double stocktotalgainloss = stocktotalDifference * stocktotalnumShares;

    wxString sPurchasePrice = Model_Currency::toCurrency(stockPurchasePrice);
    wxString sAvgPurchasePrice = Model_Currency::toCurrency(stockavgPurchasePrice);
    wxString sCurrentPrice = Model_Currency::toCurrency(stockCurrentPrice);
    wxString sDifference = Model_Currency::toCurrency(stockDifference);
    wxString sTotalDifference = Model_Currency::toCurrency(stocktotalDifference);
    wxString sPercentage = wxNumberFormatter::ToString(stockPercentage, 2);
    wxString sTotalPercentage = wxNumberFormatter::ToString(stocktotalPercentage, 2);
    wxString sTotalGainLoss = Model_Currency::toCurrency(stocktotalgainloss);

    wxString miniInfo = "";
    if (m_stocks[selectedIndex].SYMBOL != "")
        miniInfo << "\t" << _("Symbol: ") << m_stocks[selectedIndex].SYMBOL << "\t\t";
    miniInfo << _ ("Total:") << " (" << stocktotalnumShares << ") ";
    stock_panel_->stock_details_short_->SetLabelText(miniInfo);

    wxString additionInfo = "";
    //Selected share info
    additionInfo
    << "|" << sCurrentPrice << " - " << sPurchasePrice << "|" << " = " << sDifference
    << " * " << sNumShares << " = " << sGainLoss << " ( " << sPercentage << "%"
    << " )" << "\n";
    //Summary for account for selected symbol
    if (purchasedTime > 1)
    {
        additionInfo << "|" << sCurrentPrice << " - " << sAvgPurchasePrice << "|" << " = " << sTotalDifference
        << " * " << sTotalNumShares << " = " << sTotalGainLoss << " ( " << sTotalPercentage << "%"
        << " )"
        << "\n" << OnGetItemText(selectedIndex, (long)COL_NOTES);
    }
    return additionInfo;
}
示例#4
0
wxString StocksListCtrl::getStockInfo(int selectedIndex) const
{
    int purchasedTime = 0;
    double stocktotalnumShares = 0;
    double stockavgPurchasePrice = 0;
    for (const auto& s: Model_Stock::instance().find(Model_Stock::SYMBOL(m_stocks[selectedIndex].SYMBOL)))
    {
        purchasedTime++;
        stocktotalnumShares += s.NUMSHARES;
        stockavgPurchasePrice += s.PURCHASEPRICE * s.NUMSHARES;
    }
    stockavgPurchasePrice /= stocktotalnumShares;

    double numShares = m_stocks[selectedIndex].NUMSHARES;
    wxString sNumShares = wxString::Format("%i", (int)numShares);
    if (numShares - static_cast<long>(numShares) != 0.0)
        sNumShares = wxString::Format("%.4f", numShares);

    wxString sTotalNumShares = wxString::Format("%i", (int)stocktotalnumShares);
    if ((stocktotalnumShares - static_cast<long>(stocktotalnumShares)) != 0.0)
        sTotalNumShares = wxString::Format("%.4f", stocktotalnumShares);

    double stockPurchasePrice = m_stocks[selectedIndex].PURCHASEPRICE;
    double stockCurrentPrice = m_stocks[selectedIndex].CURRENTPRICE;
    double stockDifference = stockCurrentPrice - stockPurchasePrice;

    double stocktotalDifference = stockCurrentPrice - stockavgPurchasePrice;
    //Commision don't calculates here
    double stockPercentage = (stockCurrentPrice / stockPurchasePrice - 1.0)*100.0;
    double stocktotalPercentage = (stockCurrentPrice / stockavgPurchasePrice - 1.0)*100.0;
    double stocktotalgainloss = stocktotalDifference * stocktotalnumShares;

    const wxString& sPurchasePrice = Model_Currency::toCurrency(stockPurchasePrice, stock_panel_->m_currency, 4);
    const wxString& sAvgPurchasePrice = Model_Currency::toCurrency(stockavgPurchasePrice, stock_panel_->m_currency, 4);
    const wxString& sCurrentPrice = Model_Currency::toCurrency(stockCurrentPrice, stock_panel_->m_currency, 4);
    const wxString& sDifference = Model_Currency::toCurrency(stockDifference, stock_panel_->m_currency, 4);
    const wxString& sTotalDifference = Model_Currency::toCurrency(stocktotalDifference);

    wxString miniInfo = "";
    if (m_stocks[selectedIndex].SYMBOL != "")
        miniInfo << "\t" << wxString::Format(_("Symbol: %s"), m_stocks[selectedIndex].SYMBOL) << "\t\t";
    miniInfo << wxString::Format(_("Total: %s"), " (" + sTotalNumShares + ") ");
    stock_panel_->stock_details_short_->SetLabelText(miniInfo);

    //Selected share info
    wxString additionInfo = wxString::Format("|%s - %s| = %s, %s * %s = %s ( %s %% )\n"
        , sCurrentPrice, sPurchasePrice, sDifference
        , sDifference, sNumShares
        , Model_Currency::toCurrency(getGainLoss(selectedIndex))
        , wxNumberFormatter::ToString(stockPercentage, 2));

    //Summary for account for selected symbol
    if (purchasedTime > 1)
    {
        additionInfo += wxString::Format( "|%s - %s| = %s, %s * %s = %s ( %s %% )\n%s"
            ,  sCurrentPrice, sAvgPurchasePrice, sTotalDifference
            , sTotalDifference, sTotalNumShares
            , Model_Currency::toCurrency(stocktotalgainloss)
            , wxNumberFormatter::ToString(stocktotalPercentage, 2)
            , OnGetItemText(selectedIndex, (long)COL_NOTES));
    }
    return additionInfo;
}
示例#5
0
//***************************************************************************************
HRESULT CBCGPShellList::EnumObjects (LPSHELLFOLDER pParentFolder,
									LPITEMIDLIST pidlParent)
{
	ASSERT_VALID (this);
	ASSERT_VALID (g_pShellManager);

	LPENUMIDLIST pEnum;
	HRESULT hRes = pParentFolder->EnumObjects (NULL, m_nTypes, &pEnum);

	if (SUCCEEDED (hRes))
	{
		LPITEMIDLIST	pidlTemp;
		DWORD			dwFetched = 1;
		LPBCGCBITEMINFO pItem;
		
		//enumerate the item's PIDLs
		while (pEnum->Next(1, &pidlTemp, &dwFetched) == S_OK && dwFetched)
		{
			LVITEM lvItem;
			ZeroMemory(&lvItem, sizeof(lvItem));
			
			//fill in the TV_ITEM structure for this item
			lvItem.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
			
			//AddRef the parent folder so it's pointer stays valid
			pParentFolder->AddRef();
			
			//put the private information in the lParam
			pItem = (LPBCGCBITEMINFO)GlobalAlloc(GPTR, sizeof(BCGCBITEMINFO));
			
			pItem->pidlRel = pidlTemp;
			pItem->pidlFQ = g_pShellManager->ConcatenateItem (pidlParent, pidlTemp);
			
			pItem->pParentFolder = pParentFolder;

			if (!IsItemMatchedToFilter(pItem))
			{
				ReleaseItem(pItem);
				dwFetched = 0;
				continue;
			}

			lvItem.lParam = (LPARAM)pItem;
			
			lvItem.pszText = _T("");
			lvItem.iImage = OnGetItemIcon (GetItemCount (), pItem);
			
			//determine if the item is shared
			DWORD dwAttr = SFGAO_DISPLAYATTRMASK;
			pParentFolder->GetAttributesOf (1, (LPCITEMIDLIST*)&pidlTemp, &dwAttr);
			
			if (dwAttr & SFGAO_SHARE)
			{
				lvItem.mask |= LVIF_STATE;
				lvItem.stateMask |= LVIS_OVERLAYMASK;
				lvItem.state |= INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
			}
			
			if (dwAttr & SFGAO_GHOSTED)
			{
				lvItem.mask |= LVIF_STATE;
				lvItem.stateMask |= LVIS_CUT;
				lvItem.state |= LVIS_CUT;
			}
			
			int iItem = InsertItem (&lvItem);
			if (iItem >= 0)
			{
				//-------------
				// Set columns:
				//-------------
				const int nColumns = (GetStyle () & LVS_TYPEMASK) == LVS_REPORT ?
					m_wndHeader.GetItemCount () : 1;

				for (int iColumn = 0; iColumn < nColumns; iColumn++)
				{
					SetItemText (iItem, iColumn, 
								OnGetItemText (iItem, iColumn, pItem));
				}
			}

			dwFetched = 0;
		}
		
		pEnum->Release ();
	}

	return hRes;
}