StatsTab.cpp 4.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
// StatsTab.cpp : implementation file
//

#include "stdafx.h"
#include "Icecast2win.h"
#include "StatsTab.h"

#include "Icecast2winDlg.h"

extern CIcecast2winDlg	*g_mainDialog;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern void AddToAdditionalGlobalStats(CString source, CString name);

/////////////////////////////////////////////////////////////////////////////
// CStatsTab dialog


CStatsTab::CStatsTab(CWnd* pParent /*=NULL*/)
	: CTabPageSSL(CStatsTab::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStatsTab)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CStatsTab::DoDataExchange(CDataExchange* pDX)
{
	CTabPageSSL::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStatsTab)
	DDX_Control(pDX, IDC_STATIC_SLS, m_SLS);
	DDX_Control(pDX, IDC_STATSLIST, m_StatsListCtrl);
	DDX_Control(pDX, IDC_SOURCELIST, m_SourceListCtrl);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStatsTab, CTabPageSSL)
	//{{AFX_MSG_MAP(CStatsTab)
	ON_NOTIFY(NM_DBLCLK, IDC_SOURCELIST, OnDblclkSourcelist)
	ON_NOTIFY(NM_RCLICK, IDC_STATSLIST, OnRclickStatslist)
	ON_NOTIFY(NM_CLICK, IDC_SOURCELIST, OnClickSourcelist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStatsTab message handlers

BOOL CStatsTab::OnInitDialog() 
{
	CTabPageSSL::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_SourceListCtrl.InsertColumn(0, _T("Source"), LVCFMT_LEFT, m_colSource0Width);
	m_StatsListCtrl.InsertColumn(0, _T("Statistic"), LVCFMT_LEFT, m_colStats0Width);
	m_StatsListCtrl.InsertColumn(1, _T("Value"), LVCFMT_LEFT, m_colStats1Width);

64 65 66
//	AddAnchor(IDC_STATSLIST, TOP_LEFT, BOTTOM_RIGHT);
//	AddAnchor(IDC_SOURCELIST, TOP_LEFT, BOTTOM_LEFT);
//	AddAnchor(IDC_FILLER1, BOTTOM_LEFT, BOTTOM_RIGHT);
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
	
	m_SourceListCtrl.SetSelectionMark(0);
	m_SLS.SetFont(&(g_mainDialog->labelFont), TRUE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CStatsTab::OnDblclkSourcelist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	g_mainDialog->statsTab.m_StatsListCtrl.DeleteAllItems();
	g_mainDialog->UpdateStatsLists();
	*pResult = 0;
}

void CStatsTab::OnRclickStatslist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	CMenu	menu;

	
    CPoint point;                                            
    ::GetCursorPos(&point); //where is the mouse?

    DWORD dwSelectionMade;                                       
    menu.LoadMenu(IDR_MENU2);  
    CMenu *pmenuPopup = menu.GetSubMenu(0);
    dwSelectionMade = pmenuPopup->TrackPopupMenu( (TPM_LEFTALIGN|TPM_LEFTBUTTON|
                                                       TPM_NONOTIFY|TPM_RETURNCMD),
                                                       point.x, point.y, this);                                
  
    pmenuPopup->DestroyMenu();
	char	msg[255] ="";
	char	buffer[1024] = "";
	char	buffer2[1024] = "";

	CString name;
	CString source;
	POSITION pos;
	switch (dwSelectionMade) {
	case ID_POPUP_ADDTOGLOBALSTATLIST :
		pos = m_StatsListCtrl.GetFirstSelectedItemPosition();
		if (pos != NULL) {
			int nItem = m_StatsListCtrl.GetNextSelectedItem(pos);
			LVITEM	lvi;

			lvi.mask =  LVIF_TEXT;
			lvi.iItem = nItem;
			lvi.iSubItem = 0;
			lvi.pszText = buffer;
			lvi.cchTextMax = sizeof(buffer);
			m_StatsListCtrl.GetItem(&lvi);
			name = buffer;
	   }
		pos = m_SourceListCtrl.GetFirstSelectedItemPosition();
		if (pos != NULL) {
			int nItem = m_SourceListCtrl.GetNextSelectedItem(pos);
			LVITEM	lvi;

			lvi.mask =  LVIF_TEXT;
			lvi.iItem = nItem;
			lvi.iSubItem = 0;
			lvi.pszText = buffer2;
			lvi.cchTextMax = sizeof(buffer2);
			m_SourceListCtrl.GetItem(&lvi);
			source = buffer2;
	   }
		AddToAdditionalGlobalStats(source, name);
		break;
	default :
		break;
	}

	*pResult = 0;
}

void CStatsTab::OnClickSourcelist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	OnDblclkSourcelist(pNMHDR, pResult);
	*pResult = 0;
}