Beispiel #1
0
string COperMysql::GetItemValue(DWORD row,WORD index)
{
	if(index >= m_Fieldtype.size())
	{
		ZeroMemory(m_szErr, sizeof(m_szErr));
		strcpy(m_szErr, "列索引已经到达上限");
		//m_Err = "列索引已经到达上限";
		
		m_State = false;//得到当前执行状态
		return "";
	}	

	row_t * rowvalue = FindRow(row);
	
	if(rowvalue ==  NULL)
	{
		ZeroMemory(m_szErr, sizeof(m_szErr));
		strcpy(m_szErr, "行索引已经到达上限");
		//m_Err = "行索引已经到达上限";
		m_State = false;
		return "";
	}
	
	return (*rowvalue)[index];

}
Beispiel #2
0
int wxbConfigPanel::GetRowSelection(const wxChar* title) {
   int i;
   if ((i = FindRow(title)) > -1) {
      return (*config)[i].GetIndex();
   }
   return -1;
}
Beispiel #3
0
wxString wxbConfigPanel::GetRowString(const wxChar* title) {
   int i;
   if ((i = FindRow(title)) > -1) {
      return (*config)[i].GetValue();
   }
   return wxT("");
}
Beispiel #4
0
//---------------------------------------------------------------------------
// 函数:	GetFloat
// 功能:	取得某行某列字符串的值
// 参数:	szRow			行
//			szColomn		列
//			nDefault		缺省值
//			pnValue			返回值
// 返回:	1:成功	0:表格不对	-1:未填,使用默认值
//---------------------------------------------------------------------------
int	KTabFile::GetFloat(const char* szRow, const char* szColumn,
						float fDefault, float *pfValue)
{
	int		nRow, nColumn;
	char	Buffer[32];
	int		nRet = 0;

	nRow = FindRow(szRow);
	nColumn = FindColumn(szColumn);
	nRet = GetValue(nRow - 1, nColumn - 1, Buffer, sizeof(Buffer));
	if (1 == nRet)
	{
		*pfValue = (float)atof(Buffer);
	}
	else
	{
		*pfValue = fDefault;
	}

    if (nRet == 0 && m_bErrorLogEnable)
    {
        KGLogPrintf(KGLOG_DEBUG, "GetFloat(%s, %s) failed !\n", szRow, szColumn);
    }

	return nRet;
}
bool	CReportCtrl::RedrawRow(int SortKey)
{
	int	row = FindRow(SortKey);
	if (row < 0)
		return(FALSE);
	RedrawItems(row, row);
	return(TRUE);
}
	bool searchMatrix(vector<vector<int> > &matrix, int target) {
		bool found = false;
		int row = 0;
		if (FindRow(matrix, target, row))
			return true;
		found = FindCol(matrix, target, row);
		return found;
	}
Beispiel #7
0
int wxbConfigPanel::GetRowCount(const wxChar* title)
{
   int i;
   if ((i = FindRow(title)) > -1) {
      return (*config)[i].GetCount();
   }  

   return -1;
}
Beispiel #8
0
//---------------------------------------------------------------------------
// 函数:	GetString
// 功能:	取得某行某列字符串的值
// 参数:	szRow			行	(关键字)
//			szColomn		列	(关键字)
//			lpDefault		缺省值
//			lpRString		返回值
//			dwSize			返回字符串的最大长度
// 返回:	是否成功
//---------------------------------------------------------------------------
BOOL KTabFile::GetString(LPSTR szRow, LPSTR szColumn, LPSTR lpDefault, LPSTR lpRString, DWORD dwSize)
{
	int nRow, nColumn;

	nRow = FindRow(szRow);
	nColumn = FindColumn(szColumn);
	if (GetValue(nRow - 1, nColumn - 1, lpRString, dwSize))
		return TRUE;
	g_StrCpyLen(lpRString, lpDefault, dwSize);
	return FALSE;
}
Beispiel #9
0
void MainWindow::OpenNote(const QString& title)
{
	int index = fNotes.FindIndex(title);
	if (index == -1) return;

	int row = FindRow(index);

	if (row == -1) {
		ui->fTagsComboBox->setCurrentIndex(0);
		row = FindRow(index);
	}
	if (row == -1) {
		ui->fSearchEdit->clear();
		row = FindRow(index);
	}
	if (row == -1) return;


	QModelIndex current = ui->fNoteList->model()->index(row, 0);
	OnSelection(current);
	ui->fNoteList->setCurrentIndex(current);

}
PartitionListRow*
PartitionListView::AddPartition(BPartition* partition)
{
	PartitionListRow* partitionrow = FindRow(partition->ID());

	// forget about it if this partition is already in the listview
	if (partitionrow != NULL)
		return partitionrow;

	// create the row for this partition
	partitionrow = new PartitionListRow(partition);

	// see if this partition has a parent, or should have
	// a parent (add it in this case)
	PartitionListRow* parent = NULL;
	if (partition->Parent() != NULL) {
		// check if it is in the listview
		parent = FindRow(partition->Parent()->ID());
		// If parent of this partition is not yet in the list
		if (parent == NULL) {
			// add it
			parent = AddPartition(partition->Parent());
		}
	}

	// find a proper insertion index based on the on-disk offset
	int32 index = _InsertIndexForOffset(parent, partition->Offset());

	// add the row, parent may be NULL (add at top level)
	AddRow(partitionrow, index, parent);

	// make sure the row is initially expanded
	ExpandOrCollapse(partitionrow, true);

	return partitionrow;
}
Beispiel #11
0
bool	CReportCtrl::RemoveRow(int SortKey)
{
	int	row = FindRow(SortKey);
	if (row < 0)
		return(FALSE);
	DeleteItem(row);
	int	items = GetItemCount();
	// items with sort keys >= the deleted item's need updating
	for (int i = 0; i < items; i++) { // for each item
		int	sk = INT64TO32(GetItemData(i));	// get item's sort key
		if (sk >= SortKey)	// if sort key is invalid
			SetItemData(i, sk - 1);	// update it
	}
	return(TRUE);
}
bool CRowAtlasAlloc::Allocate()
{
	bool success = true;

	if (npot) {
		// revert the used height clamping at the bottom of this function
		// else for the case when Allocate() is called multiple times, the width would grew faster than height
		// also AddRow() only works with PowerOfTwo values.
		atlasSize.y = next_power_of_2(atlasSize.y);
	}

	// it gives much better results when we resize the available space before starting allocation
	// esp. allocation is more horizontal and so we can clip more free space at bottom
	EstimateNeededSize();

	// sort new entries by height from large to small
	std::vector<SAtlasEntry*> memtextures;
	for (auto it = entries.begin(); it != entries.end(); ++it) {
		memtextures.push_back(&it->second);
	}
	sort(memtextures.begin(), memtextures.end(), CRowAtlasAlloc::CompareTex);

	// find space for them
	for (auto& curtex: memtextures) {
		Row* row = FindRow(curtex->size.x + ATLAS_PADDING, curtex->size.y + ATLAS_PADDING);
		if (!row) {
			success = false;
			continue;
		}

		curtex->texCoords.x1 = row->width;
		curtex->texCoords.y1 = row->position;
		curtex->texCoords.x2 = row->width + curtex->size.x;
		curtex->texCoords.y2 = row->position + curtex->size.y;
		row->width += curtex->size.x + ATLAS_PADDING;
	}

	if (npot) {
		atlasSize.y = nextRowPos;
	} else {
		atlasSize.y = next_power_of_2(nextRowPos);
	}

	return success;
}
PartitionListRow*
PartitionListView::FindRow(partition_id id, PartitionListRow* parent)
{
	for (int32 i = 0; i < CountRows(parent); i++) {
		PartitionListRow* item
			= dynamic_cast<PartitionListRow*>(RowAt(i, parent));
		if (item != NULL && item->ID() == id)
			return item;
		if (CountRows(item) > 0) {
			// recurse into child rows
			item = FindRow(id, item);
			if (item)
				return item;
		}
	}

	return NULL;
}
Beispiel #14
0
//---------------------------------------------------------------------------
// 函数:	GetInteger
// 功能:	取得某行某列字符串的值
// 参数:	szRow			行
//			szColomn		列
//			nDefault		缺省值
//			pnValue			返回值
// 返回:	是否成功
//---------------------------------------------------------------------------
BOOL KTabFile::GetInteger(LPSTR szRow, LPSTR szColumn, int nDefault, int *pnValue)
{
	int		nRow, nColumn;
	char	Buffer[32];

	nRow = FindRow(szRow);
	nColumn = FindColumn(szColumn);
	if (GetValue(nRow - 1, nColumn - 1, Buffer, sizeof(Buffer)))
	{
		*pnValue = atoi(Buffer);
		return TRUE;
	}
	else
	{
		*pnValue = nDefault;
		return FALSE;
	}
}
Beispiel #15
0
//---------------------------------------------------------------------------
// 函数:	GetFloat
// 功能:	取得某行某列字符串的值
// 参数:	szRow			行
//			szColomn		列
//			nDefault		缺省值
//			pnValue			返回值
// 返回:	是否成功
//---------------------------------------------------------------------------
BOOL KTabFile::GetFloat(LPSTR szRow, LPSTR szColumn, float fDefault, float *pfValue)
{
	int		nRow, nColumn;
	char	Buffer[32];

	nRow = FindRow(szRow);
	nColumn = FindColumn(szColumn);
	if (GetValue(nRow - 1, nColumn - 1, Buffer, sizeof(Buffer)))
	{
		*pfValue = (float)atof(Buffer);
		return TRUE;
	}
	else
	{
		*pfValue = fDefault;
		return FALSE;
	}
}
Beispiel #16
0
//---------------------------------------------------------------------------
// 函数:	GetString
// 功能:	取得某行某列字符串的值
// 参数:	szRow			行	(关键字)
//			szColomn		列	(关键字)
//			lpDefault		缺省值
//			lpRString		返回值
//			dwSize			返回字符串的最大长度
// 返回:	1:成功	0:表格不对	-1:未填,使用默认值
//---------------------------------------------------------------------------
int	KTabFile::GetString(const char* szRow, const char* szColumn,
					const char* lpDefault, char* lpRString, unsigned int dwSize)
{
	int nRow, nColumn;
	int nRet = 0;

	nRow = FindRow(szRow);
	nColumn = FindColumn(szColumn);
	nRet = GetValue(nRow - 1, nColumn - 1, lpRString, dwSize);
	if (1 != nRet)
		g_StrCpyLen(lpRString, lpDefault, dwSize);

    if (nRet == 0 && m_bErrorLogEnable)
    {
        KGLogPrintf(KGLOG_DEBUG, "GetString(%s, %s) failed !\n", szRow, szColumn);
    }

	return nRet;
}
const std::string CMysqlStore::GetItemValue(unsigned long row,
											const std::string &fieldname)
{
	int index = 10000;
	if((index = GetFieldIndex(fieldname)) >= 10000)
	{
		m_err = "column index upper bound";
		return "";
	}

	row_t * rowvalue = FindRow(row);
	if(rowvalue ==  NULL)
	{
		m_err = "row index upper bound";
		m_getstatus = false;
		return "";
	}

	return (*rowvalue)[index];
}
Beispiel #18
0
bool CGItemListArea::LButtonDown (int x, int y)

//	LButtonDown
//
//	Handle button down

	{
	if (m_iOldCursor != -1 && m_pListData->GetCount())
		{
		//	Figure out the cursor position that the user clicked on

		int iPos = FindRow((y - GetRect().top) - m_yFirst);
		if (iPos >= 0 && iPos < m_pListData->GetCount())
			SignalAction(iPos);

		return true;
		}

	return false;
	}
const std::string CMysqlStore::GetItemValue(unsigned long row,
											unsigned int index)
{
	if(index >= m_fieldtype.size())
	{
		m_err = "column index upper bound";
		//得到当前执行状态
		m_getstatus = false;
		return "";
	}

	row_t * rowvalue = FindRow(row);
	if(rowvalue ==  NULL)
	{
		m_err = "row index upper bound";
		m_getstatus = false;
		return "";
	}

	return (*rowvalue)[index];
}
void Browse_Organization::UpdateFunc()
{
    QSqlQuery Query(Global.DataBase);
    QString SearchString = QuoteString(FilterBy->text().trimmed());
    QString Where = "";
    QString QueryString;
    QStringList SearchList;

    Where = SearchPrepare(
                "  POSITION (LOWER(?) IN LOWER(o.\"Name\")) > 0 OR "
                "  POSITION (LOWER(?) IN LOWER(o.\"Phone\")) > 0 OR "
                "  POSITION (LOWER(?) IN LOWER(o.\"Contact\")) > 0 ",
                &SearchList, SearchString);

    QueryString =
                "SELECT * "
                "FROM public.\"Organization\" AS o " +
                Where+
                OrderBy;
    Query.prepare(QueryString);
    SearchBind(SearchList,&Query,3);
    if (!Query.exec()) { GuiSqlError("Ошибка при работе с БД!"); return; }
    Model->setQuery(Query);
    Model->setHeaderData(1,Qt::Horizontal,tr("Наименование"));
    Model->setHeaderData(2,Qt::Horizontal,tr("Телефон"));
    Model->setHeaderData(4,Qt::Horizontal,tr("Контактное лицо"));
    Table->setModel(Model);
    Table->setColumnHidden(0,true);
    Table->setColumnHidden(3,true);
    Table->setColumnHidden(5,true);
    TuneTable(Table);
    Table->resizeColumnsToContents();
    Table->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    Table->setSortingEnabled(true);
    Table->horizontalHeader()->setSortIndicator(SortColumn, SortOrder);
    connect(Table->selectionModel(),SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),this,SLOT(SlotCurChanged(QModelIndex,QModelIndex)));
    int SelRow = FindRow((QSqlQueryModel*)(Table->model()),Cur);
    Table->selectRow(SelRow);
}
Beispiel #21
0
string COperMysql::GetItemValue(DWORD row,string &fieldname)
{
	DWORD index = 0;
	if((index = GetFieldIndex(fieldname)) >= 10000)
	{
		//m_Err = "列索引已经到达上限";
		ZeroMemory(m_szErr, sizeof(m_szErr));
		strcpy(m_szErr, "列索引已经到达上限");
		m_State = false;
		return "";
	}
	
	row_t * rowvalue = FindRow(row);
	if(rowvalue ==  NULL)
	{
		//m_Err = "行索引已经到达上限";
		ZeroMemory(m_szErr, sizeof(m_szErr));
		strcpy(m_szErr, "行索引已经到达上限");
		m_State = false;
		return "";
	}
	
	return (*rowvalue)[index];
}
PartitionListRow*
PartitionListView::AddSpace(partition_id parentID, partition_id id,
	off_t offset, off_t size)
{
	// the parent should already be in the listview
	PartitionListRow* parent = FindRow(parentID);
	if (!parent)
		return NULL;

	// create the row for this partition
	PartitionListRow* partitionrow = new PartitionListRow(parentID,
		id, offset, size);

	// find a proper insertion index based on the on-disk offset
	int32 index = _InsertIndexForOffset(parent, offset);

	// add the row, parent may be NULL (add at top level)
	AddRow(partitionrow, index, parent);

	// make sure the row is initially expanded
	ExpandOrCollapse(partitionrow, true);

	return partitionrow;
}
Beispiel #23
0
void wxbConfigPanel::SetRowString(const wxChar* title, wxString value) {
   int i;
   if ((i = FindRow(title)) > -1) {
      (*config)[i].SetValue(value);
   }
}
Beispiel #24
0
void wxbConfigPanel::SetRowSelection(const wxChar* title, int ind) {
   int i;
   if ((i = FindRow(title)) > -1) {
      (*config)[i].SetIndex(ind);
   }
}
Beispiel #25
0
void Browse_User::UpdateFunc()
{
    QSqlQuery Query(Global.DataBase);
    QString SearchString = QuoteString(FilterBy->text().trimmed());
    QString Where = "";
    QString QueryString;
    QStringList SearchList;

    if (Mode == buWidget) {
        Where = SearchPrepare(
                    "  POSITION (LOWER(?) IN LOWER(f.\"Name\")) > 0 OR "
                    "  POSITION (LOWER(?) IN LOWER(f.\"Role\")) > 0 OR  "
                    "  POSITION (LOWER(?) IN LOWER(to_char(f.\"StartDate\"::date ,'DD.MM.YYYY' ))) > 0 OR  "
                    "  POSITION (LOWER(?) IN LOWER(f.\"StopDate\")) > 0 OR  "
                    "  POSITION (LOWER(?) IN LOWER(f.\"Position\")) > 0 ",
                &SearchList, SearchString);

        QString QueryString =
                "SELECT * FROM ("
                " SELECT "
                "  u.\"Id\" AS \"Id\", "
                "  u.\"Name\" AS \"Name\", "
                "  COALESCE(r.\"Name\",'-') AS \"Role\", "
                "  u.\"StartDate\" AS \"StartDate\", "
                "  CASE WHEN (u.\"StopDate\" = to_date('1980-01-01', 'YYYY-MM-DD')) THEN 'в штате' ELSE to_char(u.\"StopDate\",'DD-MM-YYYY') END AS \"StopDate\", "
                "  COALESCE(d.\"Name\",'-') AS \"Position\", "
                "  u.\"LongName\" AS \"LongName\" "
                " FROM public.\"Users\" as u "
                " LEFT OUTER JOIN public.\"Rubricator\" AS r ON (r.\"GroupId\" = 1 AND r.\"Id\" = u.\"Role\") "
                " LEFT OUTER JOIN public.\"Rubricator\" AS d ON (d.\"GroupId\" = 2 AND d.\"Id\" = u.\"Position\") "
                " GROUP BY u.\"Id\", r.\"Name\", d.\"Name\" "
                ") AS f "
                +Where
                +OrderBy;
        Query.prepare(QueryString);
        SearchBind(SearchList,&Query,5);
        if (!Query.exec()) { GuiSqlError("Ошибка при работе с БД!"); return; }
        Model->setQuery(Query);
        Model->setHeaderData(0,Qt::Horizontal,tr("Ид"));
        Model->setHeaderData(1,Qt::Horizontal,tr("ФИО"));
        Model->setHeaderData(2,Qt::Horizontal,tr("Права"));
        Model->setHeaderData(3,Qt::Horizontal,tr("Прием"));
        Model->setHeaderData(4,Qt::Horizontal,tr("Увольнение"));
        Model->setHeaderData(5,Qt::Horizontal,tr("Подразделение"));
        Model->setHeaderData(6,Qt::Horizontal,tr("ФИО(полностью)"));

        Table->setModel(Model);
        Table->setItemDelegate(new NotEditableDelegate());
        Table->setColumnHidden(0,true);
        Table->setColumnHidden(6,true);
        TuneTable(Table);
        Table->setSortingEnabled(true);
        Table->horizontalHeader()->setSortIndicator(SortColumn, SortOrder);
        Table->resizeColumnsToContents();
        Table->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    }
    if (Mode == buService) {
        Where = SearchPrepare(
                    " POSITION (LOWER(?) IN LOWER(f.\"Name\")) > 0",
                &SearchList, SearchString);

        QueryString =
                "SELECT * FROM ( "
                "  SELECT u.\"Id\" AS \"Id\", "
                "  u.\"Name\" AS \"Name\" "
                "  FROM public.\"Users\" AS u, public.\"Service2Users\" AS s "
                "  WHERE u.\"Id\" = s.\"User\" AND s.\"Service\" ="+(*Ref)["Id"].toString()+" "
                ") AS f "
                +Where
                +OrderBy;
        Query.prepare(QueryString);
        SearchBind(SearchList,&Query,1);
        if (!Query.exec()) { GuiSqlError("Ошибка при работе с БД!"); return; }
        Model->setQuery(Query);
        Model->setHeaderData(0,Qt::Horizontal,tr("Ид"));
        Model->setHeaderData(1,Qt::Horizontal,tr("ФИО"));
        Table->setModel(Model);
        Table->setColumnHidden(0,true);
        TuneTable(Table);
        Table->setSortingEnabled(true);
        Table->horizontalHeader()->setSortIndicator(SortColumn, SortOrder);
        Table->resizeColumnsToContents();
        Table->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    }
    if (Mode == buSelect) {
        Where = SearchPrepare(
                    " POSITION (LOWER(?) IN LOWER(f.\"Name\")) > 0",
                &SearchList, SearchString);


        QueryString =
                " SELECT * FROM ( "
                " SELECT u.\"Id\", u.\"Name\" FROM public.\"Users\" AS u "
                " WHERE u.\"Id\" NOT IN ( "
                "   SELECT u1.\"Id\" FROM public.\"Users\" AS u1, public.\"Service2Users\" AS s "
                "   WHERE s.\"Service\" = 1 AND s.\"User\" = u1.\"Id\" "
                " )) AS f "
                +Where
                +OrderBy;
        Query.prepare(QueryString);
        SearchBind(SearchList,&Query,1);
        if (!Query.exec()) { GuiSqlError("Ошибка при работе с БД!"); return; }
        Model->setQuery(Query);
        Model->setHeaderData(0,Qt::Horizontal,tr("Ид"));
        Model->setHeaderData(1,Qt::Horizontal,tr("ФИО"));
        Table->setModel(Model);
        Table->setColumnHidden(0,true);
        TuneTable(Table);
        Table->setSortingEnabled(true);
        Table->horizontalHeader()->setSortIndicator(SortColumn, SortOrder);
        Table->resizeColumnsToContents();
        Table->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    }

    connect(Table->selectionModel(),SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),this,SLOT(SlotCurChanged(QModelIndex,QModelIndex)));
    int SelRow = FindRow((QSqlQueryModel*)(Table->model()),Cur);
    Table->selectRow(SelRow);
}
Beispiel #26
0
void wxbConfigPanel::ClearRowChoices(const wxChar* title) {
   int i;
   if ((i = FindRow(title)) > -1) {
      (*config)[i].Clear();
   }  
}
Beispiel #27
0
void wxbConfigPanel::AddRowChoice(const wxChar* title, wxString value) {
   int i;
   if ((i = FindRow(title)) > -1) {
      (*config)[i].Add(value);
   }  
}
Beispiel #28
0
void CGItemListArea::Paint (CG16bitImage &Dest, const RECT &rcRect)

//	Paint
//
//	Paint the area

	{
	//	Can't paint if we are not properly initialized

	if (m_pFonts == NULL)
		return;

	//	If there are no items here, then say so

	if (m_pListData == NULL || !m_pListData->IsCursorValid())
		{
		int x = rcRect.left + (RectWidth(rcRect) - m_pFonts->LargeBold.MeasureText(STR_NO_ITEMS)) / 2;
		int y = rcRect.top + (RectHeight(rcRect) - m_pFonts->LargeBold.GetHeight()) / 2;

		Dest.DrawText(x, y,
				m_pFonts->LargeBold,
				RGB_DISABLED_TEXT,
				STR_NO_ITEMS);

		m_iOldCursor = -1;
		}

	//	Otherwise, paint the list of items

	else
		{
		int iCursor = m_pListData->GetCursor();
		int iCount = m_pListData->GetCount();

		ASSERT(iCursor >= 0 && iCursor < m_Rows.GetCount());
		ASSERT(iCount == m_Rows.GetCount());

		//	If the cursor has changed, update the offset so that we
		//	have a smooth scroll.

		if (m_iOldCursor != -1 && m_iOldCursor != iCursor)
			{
			int cyDiff = (m_Rows[iCursor].cyHeight - m_Rows[m_iOldCursor].cyHeight) / 2;

			if (m_iOldCursor < iCursor)
				m_yOffset = m_Rows[m_iOldCursor].cyHeight + cyDiff;
			else
				m_yOffset = -(m_Rows[iCursor].cyHeight - cyDiff);
			}

		m_iOldCursor = iCursor;

		//	Figure out the ideal position of the cursor (relative to the
		//	rect).

		int yIdeal = m_yOffset + ((RectHeight(rcRect) - m_Rows[iCursor].cyHeight) / 2);

		//	Figure out the actual position of the cursor row (relative to the
		//	rect).

		int yCursor;

		//	If the cursor is in the top part of the list
		if (m_Rows[iCursor].yPos < yIdeal)
			yCursor = m_Rows[iCursor].yPos;

		//	If the total number of lines is less than the whole rect
		else if (m_cyTotalHeight < RectHeight(rcRect))
			yCursor = m_Rows[iCursor].yPos;

		//	If the cursor is in the bottom part of the list
		else if ((m_cyTotalHeight - m_Rows[iCursor].yPos) < (RectHeight(rcRect) - yIdeal))
			yCursor = (RectHeight(rcRect) - (m_cyTotalHeight - m_Rows[iCursor].yPos));

		//	The cursor is in the middle of the list
		else
			yCursor = yIdeal;

		//	Figure out the item position at which we start painting

		int iStart = FindRow(m_Rows[iCursor].yPos - yCursor);
		ASSERT(iStart != -1);
		if (iStart == -1)
			iStart = 0;

		int yStart = yCursor - (m_Rows[iCursor].yPos - m_Rows[iStart].yPos);

		//	Compute y offset of first row (so that we can handle clicks later)

		m_yFirst = yStart - m_Rows[iStart].yPos;

		//	Paint

		int y = rcRect.top + yStart;
		int iPos = iStart;
		bool bPaintSeparator = false;
		RECT rcItem;

		while (y < rcRect.bottom && iPos < m_Rows.GetCount())
			{
			//	Paint previous separator

			if (bPaintSeparator)
				{
				Dest.Fill(rcItem.left,
						rcItem.bottom - 1,
						RectWidth(rcItem),
						1,
						CG16bitImage::RGBValue(80,80,80));
				}
			else
				bPaintSeparator = true;

			//	Paint only if we have a valid entry. Sometimes we can
			//	start at an invalid entry because we're scrolling.

			if (iPos >= 0)
				{
				m_pListData->SetCursor(iPos);

				rcItem.top = y;
				rcItem.left = rcRect.left;
				rcItem.bottom = y + m_Rows[iPos].cyHeight;
				rcItem.right = rcRect.right;

				//	See if we need to paint the cursor

				bool bPaintCursor = (iPos == iCursor);

				//	Paint selection background (if selected)

				if (bPaintCursor)
					{
					Dest.FillTrans(rcItem.left,
							rcItem.top,
							RectWidth(rcItem),
							RectHeight(rcItem),
							m_pFonts->wSelectBackground,
							128);

					bPaintSeparator = false;
					}

				//	Paint item

				switch (m_iType)
					{
					case listCustom:
						PaintCustom(Dest, rcItem, bPaintCursor);
						break;

					case listItem:
						PaintItem(Dest, m_pListData->GetItemAtCursor(), rcItem, bPaintCursor);
						break;
					}
				}

			//	Next

			y += m_Rows[iPos].cyHeight;
			iPos++;
			}

		//	Done

		m_pListData->SetCursor(iCursor);
		}
	}
Beispiel #29
0
void CMembersView::RefreshRows(const CMembers::RowList& aoRows)
{
	// For all data rows, update grid row.
	for (size_t i = 0; i != aoRows.size(); i++)
		UpdateRow(FindRow(*aoRows[i]), false);
}