|
//------------------------------------------------------------------------------
// $Workfile: ListController.cpp $
// $Header: $
//
// Copyright � 2008 SbjCat
// All rights reserved.
//
//
// *** Authors ***
// Steve Johnson
//
// $Revision: $
//
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "ListController.h"
#include "Column.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
namespace SbjCore
{
namespace Mvc
{
struct ListControllerImpl
{
std::vector<Column> theColumns;
ListControllerImpl()
{
}
~ListControllerImpl()
{
}
};
// ListController ////////////////////////
ListController::ListController() :
m_pImpl(new ListControllerImpl)
{
}
ListController::~ListController()
{
try
{
delete m_pImpl;
}
catch (...)
{
TRACE(_T("Unhandled Exception in ~ListController()"));
}
}
CListCtrl* ListController::GetListCtrl()
{
CListCtrl* pList = dynamic_cast<CListCtrl*>(GetCmdTarget());
if (NULL == pList) // assume CListView
{
CListView* pView = dynamic_cast<CListView*>(GetCmdTarget());
if (pView != NULL)
{
pList = &pView->GetListCtrl();
}
}
return pList;
}
void ListController::SelectItem(int nItem)
{
CListCtrl* pList = GetListCtrl();
pList->SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
}
int ListController::GetCurItem()
{
CListCtrl* pList = GetListCtrl();
int nCurItem = -1;
POSITION pos = pList->GetFirstSelectedItemPosition();
while (pos != NULL)
{
int nItem = pList->GetNextSelectedItem(pos);
UINT nState = pList->GetItemState(nItem, LVIS_FOCUSED);
if (LVIS_FOCUSED == (nState & LVIS_FOCUSED))
{
nCurItem = nItem;
break;
}
}
return nCurItem;
}
int ListController::AddColumn(Column* pCol)
{
int nCol = 0; //m_pImpl->theColumns.size();
CListCtrl* pList = GetListCtrl();
pList->InsertColumn(nCol, (LVCOLUMN*)pCol);
// if (pCol->
return nCol;
}
}
}
//*** Modification History ***
// $Log: $
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Real name is Steve Johnson. Programming since 1979. Started on a Heathkit Micro with a DEC LSI-11 and UCSD Pascal. Moved to PCs & DOS as soon as Turbo Pascal became available. Did some Assembly, ISR, TSR etc. All this while working for a Manufacturing Co. for 8 years. Had my own solo Co. doing barcode labeling software for 4 years (terrible business man, all I wanted to do was code). Since then working for various software companies. Moved to Windows around the time of 3.1 with Borland C then C++. Then on to VC++ and MFC, and just about anything I could get my hands on or had to learn for my job, and been at it ever since. Of course recently I've been playing with .NET, ASP, C#, WPF etc.