// This method clears the list and adds contacts again, according to the current filter settings.
	void RebuildList()
	{
		LPSTR pszProto;
		MTime mtNow;
		MAnnivDate ad;
		int i = 0;
		DWORD age = 0;
		WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
		WORD numMale = 0;
		WORD numFemale = 0;
		WORD numContacts = 0;
		WORD numBirthContacts = 0;

		ShowWindow(_hList, SW_HIDE);
		DeleteAllItems();
		mtNow.GetLocalTime();

		// insert the items into the list
		for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
			// ignore meta subcontacts here, as they are not interesting.
			if (!db_mc_isSub(hContact)) {
				// filter protocol
				pszProto = Proto_GetBaseAccountName(hContact);
				if (pszProto) {
					numContacts++;
					switch (GenderOf(hContact, pszProto)) {
					case 'M':
						numMale++;
						break;
					case 'F':
						numFemale++;
					}

					if (!ad.DBGetBirthDate(hContact, pszProto)) {
						age += ad.Age(&mtNow);
						numBirthContacts++;

						// add birthday
						if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto)))
							AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
					}

					// add anniversaries
					if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) 
						for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++)
							if (!_filter.pszAnniv || !mir_tstrcmpi(_filter.pszAnniv, ad.Description()))
								AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
				}
			}
		}
		ListView_SortItemsEx(_hList, (CMPPROC)cmpProc, this);
		ShowWindow(_hList, SW_SHOW);

		// display statistics
		SetDlgItemInt(_hDlg, TXT_NUMBIRTH, numBirthContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_NUMCONTACT, numContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_FEMALE, numFemale, FALSE);
		SetDlgItemInt(_hDlg, TXT_MALE, numMale, FALSE);
		SetDlgItemInt(_hDlg, TXT_AGE, numBirthContacts > 0 ? (age - (age % numBirthContacts)) / numBirthContacts : 0, FALSE);
	}
Exemple #2
0
void _EndpointList::AddEndpoint(BMidiEndpoint* endpoint)
{
	ArpASSERT(endpoint);
	BRow*			row = new _EndpointRow(endpoint, -1, this);
	if (row) {
		AddRow(row);
		for (int32 k = 0; k < 16; k++) {
			BRow*	crow = new _EndpointRow(endpoint, k, this);
			if (crow) AddRow(crow, row);
		}
	}
}
Exemple #3
0
void ActorEditorListCtrl::DoImport(AtObj& in)
{
	DeleteData();

	for (AtIter group = in["group"]; group.defined(); ++group)
	{
		for (AtIter variant = group["variant"]; variant.defined(); ++variant)
			AddRow(variant);

		AtObj blank;
		AddRow(blank);
	}

	UpdateDisplay();
}
void
TeamsListView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_TEAM_ADDED:
		{
			TeamInfo* info;
			team_id team;
			if (message->FindInt32("team", &team) != B_OK)
				break;

			TargetHost* host = fInterface->GetTargetHost();
			AutoLocker<TargetHost> hostLocker(host);
			info = host->TeamInfoByID(team);
			if (info == NULL)
				break;

			TeamRow* row = new TeamRow(info);
			AddRow(row);
			break;
		}

		case MSG_TEAM_REMOVED:
		{
			team_id team;
			if (message->FindInt32("team", &team) != B_OK)
				break;

			TeamRow* row = FindTeamRow(team);
			if (row != NULL) {
				RemoveRow(row);
				delete row;
			}
			break;
		}

		case MSG_TEAM_RENAMED:
		{
			TeamInfo* info;
			team_id team;
			if (message->FindInt32("team", &team) != B_OK)
				break;

			TargetHost* host = fInterface->GetTargetHost();
			AutoLocker<TargetHost> hostLocker(host);
			info = host->TeamInfoByID(team);
			if (info == NULL)
				break;

			TeamRow* row = FindTeamRow(info->TeamID());
			if (row != NULL && row->NeedsUpdate(info))
				UpdateRow(row);

			break;
		}

		default:
			Inherited::MessageReceived(message);
	}
}
void MultiViewerMain::OnPopupClick(wxCommandEvent &evt)
{
	switch(evt.GetId()) {
	case eSelectAllOnPage:
		m_pTableDBDataGrid->SelectAll();
		break;
	case eDeleteAll:
		m_pTableDBDataGrid->SelectAll();
		break;
	case eAddRow:
		AddRow();
		break;
	case eDeleteCurrentRow:
		DeleteRow();
		break;
	case eModifyCurrentCol:
		ModifyCol();
		break;
	case eDeleteCurrentCol:
		DeleteCol();
		break;
	case eAddCol:
		AddCol();
		break;
	default:
		break;
	}

}
void CComputerGrid::UpdateComputerInfoToRow(DWORD_PTR dwData, CComputerInfo& computer)
{	
	computer.SetUpdateState(CComputerInfo::EUS_NORMAL);

	CBCGPGridRow* pRow = FindRowByData(dwData);

	if (pRow != NULL) //已经存在的行
	{
		if (CheckShowCondition(computer))
		{
			UpdateRowData(pRow, computer);
		}
		else
		{
			RemoveRow(pRow->GetRowId()); //移除该行
		}		
	}
	else //添加新行
	{
		if (CheckShowCondition(computer))
		{
			pRow = CreateRow(GetColumnCount());
			pRow->SetData(dwData);
			UpdateRowData(pRow, computer);
			AddRow(pRow, FALSE);
		}
	}
}
Exemple #7
0
bool
TreeTable::_AddChildRows(TreeTableNode* parentNode, int32 childIndex,
	int32 count, int32 columnCount)
{
	int32 childEndIndex = childIndex + count;
	for (int32 i = childIndex; i < childEndIndex; i++) {
		void* child = fModel->ChildAt(parentNode->ModelObject(), i);

		// create node
		TreeTableNode* node = new(std::nothrow) TreeTableNode(parentNode);
		if (node == NULL || node->Init(child, columnCount) != B_OK
			|| !parentNode->AddChild(node, i)) {
			delete node;
			return false;
		}

		// add row
		AddRow(node->Row(), i,
			parentNode != fRootNode ? parentNode->Row() : NULL);

		// recursively create children
		if (!_AddChildRows(node, 0, fModel->CountChildren(child), columnCount))
			return false;
	}

	return true;
}
CRowAtlasAlloc::Row* CRowAtlasAlloc::FindRow(int glyphWidth, int glyphHeight)
{
	int   best_width = atlasSize.x;
	float best_ratio = 10000.0f;
	Row*  best_row   = nullptr;

	// first try to find a row with similar height
	for(auto& row: imageRows) {
		// Check if there is enough space in this row
		if (glyphWidth > (atlasSize.x - row.width))
			continue;
		if (glyphHeight > row.height)
			continue;

		const float ratio = float(row.height) / glyphHeight;
		if ((ratio < best_ratio) || ((ratio == best_ratio) && (row.width < best_width))) {
			best_width = row.width;
			best_ratio = ratio;
			best_row   = &row;
		}
	}

	if (best_row != nullptr)
		return best_row;

	// no row found create a new one
	return AddRow(glyphWidth, glyphHeight);
}
// 重新加载现场测道数据
void CSensorListCtrl::OnReloadSiteDataCMD()
{
    // 现场数据对象初始化
    OnSiteDataInit();

    matrix_data::data_base_helper::device_info_map& map = data_base_helper_->get_devices_info();
    matrix_data::data_base_helper::device_info_map::const_iterator itr;
    matrix_data::data_base_helper::device_info di;
    CBCGPGridRow* pRow = NULL;

    data_base_helper_->devices_info_lock();
    for(itr = map.begin(); itr != map.end(); ++itr) {

        pRow = FindRowByData(itr->second.ip_, FALSE);
        // 填充本次数据
        if(pRow != NULL) {
            SetRowData(pRow, itr->second);	// 设置一行的数据
        }
        else {
            pRow = CreateRow(GetColumnCount());
            SetRowData(pRow, itr->second);
            AddRow(pRow, FALSE);
        }
    }
    // 删除没有用到的行
    for(int i = (GetRowCount() - 1); i >= 0; i--) {
        pRow = GetRow(i);
        if(pRow != NULL) {	// 找到行
            di.ip_ = pRow->GetData();
            if(data_base_helper_->find_device(di.ip_, di))	RemoveRow(i, FALSE);
        }
    }
    data_base_helper_->devices_info_unlock();
    AdjustLayout ();
}
void EGridCtrl::OnAddGridRow( WPARAM wp , LPARAM lp )
{
	IGridRow* pGridRow = (IGridRow*)wp;

	AddRow(pGridRow);

}
Exemple #11
0
// { ----- begin row set methods -----
NS_IMETHODIMP
morkTable::NewRow( // create a new row instance in table
  nsIMdbEnv* mev, // context
  mdbOid* ioOid, // please use zero (unbound) rowId for db-assigned IDs
  nsIMdbRow** acqRow) // create new row
{
  mdb_err outErr = NS_OK;
  nsIMdbRow* outRow = 0;
  morkEnv* ev = morkEnv::FromMdbEnv(mev);
  if ( ev )
  {
    if ( ioOid && mTable_Store )
    {
      morkRow* row = 0;
      if ( ioOid->mOid_Id == morkRow_kMinusOneRid )
        row = mTable_Store->NewRow(ev, ioOid->mOid_Scope);
      else
        row = mTable_Store->NewRowWithOid(ev, ioOid);
        
      if ( row && AddRow(ev, row) )
        outRow = row->AcquireRowHandle(ev, mTable_Store);
    }
    else
      ev->NilPointerError();
      
    outErr = ev->AsErr();
  }
  if ( acqRow )
    *acqRow = outRow;
  return outErr;
}
void
CBMacroSetTable::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == itsAddRowButton && message.Is(JXButton::kPushed))
		{
		AddRow();
		}
	else if (sender == itsRemoveRowButton && message.Is(JXButton::kPushed))
		{
		RemoveRow();
		}

	else
		{
		if (sender == &(GetTableSelection()))
			{
			SwitchDisplay();
			}

		JXStringTable::Receive(sender, message);
		}
}
Exemple #13
0
        //Add delta to local buffer and send it to the parameter sever
        void Trainer::AddDeltaParameter(std::vector<int>& input_nodes,
            std::vector<int>& output_nodes)
        {
            std::vector<real*> blocks;
            for (int i = 0; i < input_nodes.size(); ++i)
            {
                real* ptr = WordEmbedding_->GetWeightIE(input_nodes[i]);
                assert(ptr != nullptr);
                AddRow(ptr, kInputEmbeddingTableId, input_nodes[i],
                    option_->embeding_size);

                blocks.push_back(ptr);
            }

            for (int i = 0; i < output_nodes.size(); ++i)
            {
                real* ptr = WordEmbedding_->GetWeightEO(output_nodes[i]);
                assert(ptr != nullptr);
                AddRow(ptr, kEmbeddingOutputTableId, output_nodes[i],
                    option_->embeding_size);
                blocks.push_back(ptr);
            }

            if (option_->use_adagrad)
            {
                for (int i = 0; i < input_nodes.size(); ++i)
                {
                    real* ptr = WordEmbedding_->GetSumGradient2IE(input_nodes[i]);
                    assert(ptr != nullptr);
                    AddRow(ptr, kSumGradient2IETableId, input_nodes[i],
                        option_->embeding_size);
                    blocks.push_back(ptr);
                }

                for (int i = 0; i < output_nodes.size(); ++i)
                {
                    real* ptr = WordEmbedding_->GetSumGradient2EO(output_nodes[i]);
                    assert(ptr != nullptr);
                    AddRow(ptr, kSumGradient2EOTableId, output_nodes[i],
                        option_->embeding_size);
                    blocks.push_back(ptr);
                }
            }

            //Return all the memory blocks
            memory_mamanger_->ReturnBlocks(blocks);
        }
Exemple #14
0
void
PropertyList::AddAttributes(const Attributes& attributes)
{
	RemoveAll();
	for (unsigned int i = 0; i < attributes.size(); i++) {
		AddRow(new PropertyRow(attributes[i].fName, attributes[i].fValue));
	}
}
CHighScoresTable::CHighScoresTable()
{
	m_nMaxScores=100;
	for(int x=0;x<20;x++)
	{
		SHighScoreRow sRow(".............",eGameDifficulty_Easy,(x+1)*5000);
		AddRow(sRow);
	}	
}
Exemple #16
0
void *AddThread( int i ) {

	//INIT = NUMROWS / THREADS * i
	//MAX = NUMROWS / THREADS * ( i + 1 ) 
	int n;
	for (n = NUMROWS / numcores * i; n < NUMROWS / numcores * (i + 1); n++) {
		AddRow( & matrix[n] );
	}
}
Exemple #17
0
/**
 * @brief Called when Add-button is clicked.
 */
void LineFiltersDlg::OnBnClickedLfilterAddBtn()
{
	int ind = AddRow(_T(""));
	if (ind >= -1)
	{
		m_filtersList.SetItemState(ind, LVIS_SELECTED, LVIS_SELECTED);
		m_filtersList.EnsureVisible(ind, FALSE);
		EditSelectedFilter();
	}
}
Exemple #18
0
void C4Scoreboard::SetCell(int32_t iColKey, int32_t iRowKey, const char *szValue, int32_t iValue)
{
	// ensure primary row/col exists
	if (!iCols || !iRows)
	{
		if (!iCols) AddCol(0);
		if (!iRows) AddRow(0);
		GetCell(0, 0)->iVal = TitleKey;
	}
	// get row/col; create new if not yet existing
	int32_t iCol = GetColByKey(iColKey);
	if (iCol<0) { AddCol(iCol=iCols); GetCell(iCol, 0)->iVal = iColKey; }
	int32_t iRow = GetRowByKey(iRowKey);
	if (iRow<0) { AddRow(iRow=iRows); GetCell(0, iRow)->iVal = iRowKey; }
	// now set values
	Entry *pCell = GetCell(iCol, iRow);
	pCell->Text.Copy(szValue);
	if (iCol && iRow) pCell->iVal = iValue; // do NOT overwrite index keys!
	// if an empty value was set, prune empty
	if (!szValue || !*szValue)
	{
		// prune empty row (not label row)
		int32_t i;
		if (iRow)
		{
			for (i=1; i<iCols; ++i) if (GetCell(i, iRow)->Text) break;
			if (i == iCols) DelRow(iRow);
		}
		// prune empty col (not label col)
		if (iCol)
		{
			for (i=1; i<iRows; ++i) if (GetCell(iCol, i)->Text) break;
			if (i == iRows) DelCol(iCol);
		}
	}
	/*  // prune empty board? but this would prevent boards that just sort
	  if (iRows == 1 && iCols == 1)
	    Clear(); // must not do this, because it will del pDlg
	  else*/
	// recalc row widths in display (else done by clear)
	InvalidateRows();
}
void
HEventList::SetType(const char* type)
{
	RemoveAll();
	BMediaFiles mfiles;
	mfiles.RewindRefs(type);
	delete fType;
	fType = strdup(type);

	BString name;
	entry_ref ref;
	while (mfiles.GetNextRef(&name,&ref) == B_OK) {
		BPath path(&ref);
		if (path.InitCheck() != B_OK || ref.name == NULL
			|| strcmp(ref.name, "") == 0)
			AddRow(new HEventRow(name.String(), NULL));
		else
			AddRow(new HEventRow(name.String(), path.Path()));
	}
}
Exemple #20
0
/********************************************************
 * _OWQ-LIST
 ********************************************************/
_OwqList::_OwqList(BRect frame, const BMessage& prefs)
		: inherited( frame, "owq_table", B_FOLLOW_ALL, B_WILL_DRAW, B_NO_BORDER ),
		mAdd(0), mChange(0), mRemove(0)
{
	BMessage	msg;
	float		fh = view_font_height(this);
	for( int32 k = 0; prefs.FindMessage(OPEN_FROM_QUERY_PREF, k, &msg) == B_OK; k++ ) {
		_OwqRow*	row = new _OwqRow( &msg, fh );
		if( row )  AddRow( row );
	}
}
void
TeamsListView::_InitList()
{
	TargetHost* host = fInterface->GetTargetHost();
	AutoLocker<TargetHost> hostLocker(host);
	for (int32 i = 0; i < host->CountTeams(); i++) {
		TeamInfo* info = host->TeamInfoAt(i);
		BRow* row = new TeamRow(info);
		AddRow(row);
	}
}
void MainWindow::EvolutionaryLoop()
{
    m_GenerationNumber++;

    for(int i = 0; i < ui->sbChildren->value(); i++)
    {
        float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);

        //80 percent of the time we do a crossover.
        if (r < 0.8)
        {
            int father_index = rand() % population.size();
            int mother_index = rand() % population.size();
            CrossOver(population.at(father_index), population.at(mother_index));
            ComputeFitness(population.back());
        }
        // we clone the rest of the time (10%)
        else
        {
            int clone_index = rand() % population.size();
            population.push_back(population.at(clone_index));
        }

        Mutation(population.at(i));
    }

    MakeFights();

    fs = GetPhenotypeStatsInAGeneration();
    int best_index = fs.bestFitnessIndex;

    if (population.at(best_index)->GetFitness() <= ui->dsbFitnessThreshold->value()
            && population.at(best_index)->IsValid() == true)
    {
        timer->stop();
        statusLabel->setText(QString("Found best phenotype (number %2) at generation %0 with a fitness of %1")
                             .arg(fs.noOfGeneration)
                             .arg(population.at(best_index)->GetFitness())
                             .arg(best_index));
        //statusProgressBar->setValue(statusProgressBar->maximum());
    }

    //population.at(best_index)->Mutate();
    ComputeFitness(population.at(best_index));
    int row = AddRow(population.at(best_index));
    bool green = population.at(best_index)->IsValid();
    SetRowColor(row, green);
    PopulatePlot(ui->tableWidget, fs);
    ShowPhenotype(population.at(best_index));

    ui->lGeneration->setText(QString("Generation %0").arg(m_GenerationNumber));
}
// This creates a new row as a copy of an existing row. Returns the index of the new row.
// NOTE: the user data will be initialized to NULL for the new row!
int CValueTable::CopyRow(int FromRowIdx)
{
	n_assert(FromRowIdx < NumRows);
	int ToRowIdx = AddRow();
	CData Value; //???or inside the loop?
	for (int ColIdx = 0; ColIdx < Columns.Size(); ColIdx++)
	{
		GetValue(ColIdx, FromRowIdx, Value);
		SetValue(ColIdx, ToRowIdx, Value);
		//!!!or switch-case GetColumnValueType(ColIdx) == bool: Set<bool>(Get<bool>()) etc
	}
	return ToRowIdx;
}
void PreferencesDialog::PopulateShortcuts()
{
    sortLock->lock();
    numberOfShortcuts = 0;
    for(auto iter = baka->input.begin(); iter != baka->input.end(); ++iter)
    {
        QPair<QString, QString> p = iter.value();
        if(p.first == QString() || p.second == QString())
            continue;
        AddRow(iter.key(), p.first, p.second);
    }
    sortLock->unlock();
}
void PreferencesDialog::SelectKey(bool add, QPair<QString, QPair<QString, QString>> init)
{
    sortLock->lock();
    KeyDialog dialog(this);
    int status = 0;
    while(status != 2)
    {
        QPair<QString, QPair<QString, QString>> result = dialog.SelectKey(add, init);
        if(result == QPair<QString, QPair<QString, QString>>()) // cancel
            break;
        for(int i = 0; i < numberOfShortcuts; ++i)
        {
            if(!add && i == ui->infoWidget->currentRow()) // don't compare selected row if we're changing
                continue;
            if(ui->infoWidget->item(i, 0)->text() == result.first)
            {
                if(QMessageBox::question(this,
                       tr("Existing keybinding"),
                       tr("%0 is already being used. Would you like to change its function?").arg(
                           result.first)) == QMessageBox::Yes)
                {
                    baka->input[ui->infoWidget->item(i, 0)->text()] = {QString(), QString()};
                    RemoveRow(i);
                    status = 0;
                }
                else
                {
                    init = result;
                    status = 1;
                }
                break;
            }
        }
        if(status == 0)
        {
            if(add) // add
                AddRow(result.first, result.second.first, result.second.second);
            else // change
            {
                if(result.first != init.first)
                    baka->input[init.first] = {QString(), QString()};
                ModifyRow(ui->infoWidget->currentRow(), result.first, result.second.first, result.second.second);
            }
            baka->input[result.first] = result.second;
            status = 2;
        }
        else
            status = 0;
    }
    sortLock->unlock();
}
Exemple #26
0
void	ListView1::MessageDropped(BMessage *msg, BPoint point) {
printf("MessageDropped():");
	switch(msg->what) {
		case B_MOUSE_DOWN: printf("B_MOUSE_DOWN\n");break;
		case B_SIMPLE_DATA: be_app->PostMessage(msg); break;
		case B_MOUSE_MOVED: printf("B_MOUSE_MOVED\n");break;
		case LISTITEM_DROPPED: 	printf("LISTITEM_DROPPED\n");
				if ((CDMode!=AUDIOCD_INDEX) && (CDMode!=CDEXTRA_INDEX)) break;
				if (msg->WasDropped()) {
					BPoint where=msg->DropPoint();
					ConvertFromScreen(&where);
					where.PrintToStream();
					BRow *draggedRow=NULL;
					if ((CDMode==DATACD_INDEX) || (CDMode==BOOTABLECD_INDEX) || (CDMode==DVDVIDEO_INDEX)) {	// yes? then we are not in audio mode
						draggedRow=folderRow;
					} else
					if ((CDMode==AUDIOCD_INDEX) || (CDMode==CDEXTRA_INDEX)) {
						draggedRow=audioRow;
					}
					void	*row;
					msg->FindPointer("from", &row);
					if (RowAt(where)) {
						int32 index=IndexOf(RowAt(where));
						if (index>0) index--;
						AddRow(draggedRow, index);
					} else
						AddRow(draggedRow);
					RemoveRow(IndexOf((BRow *)row));
					Invalidate();
					ResetTrackNumbers();
					//Refresh();
					
					project_has_changed=true;
				}
				break;
		default:  BColumnListView::MessageDropped(msg, point);
	}
}
Exemple #27
0
int AsciiTableCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	ProcessFlags( cmd );
	IOManager io( cmd );
	CSVRow row;
	while( io.ReadCSV( row ) ) {
		if ( ! Skip( row ) ) {
			AddRow( row );
		}
	}
	OutputTable( io.Out() );
	return 0;
}
Exemple #28
0
void AsciiTableCommand :: ProcessFlags( ALib::CommandLine & cmd ) {
	mUseLineSep = cmd.HasFlag( FLAG_SEP );
	mHeadings = ALib::CommaList( cmd.GetValue( FLAG_HEADER, "" ) );
	ALib::CommaList ra = ALib::CommaList( cmd.GetValue( FLAG_RALIGN, "" ) );
	CommaListToIndex( ra, mRightAlign );

	if ( mHeadings.Size() && mHeadings.At(0) != FILE_HEADER) {
		CSVRow r;
		for ( unsigned int i = 0; i < mHeadings.Size() ; i++ ) {
			r.push_back( mHeadings.At( i ) );
		}
		AddRow( r );
	}
}
RedChar RedBufferInput::GetNextChar(void)
{
    // get the character
    RedChar cCharObj( cStrBuffer.CharAtIndex(iCharPos) );

    // increment to the next read position. The string class deals with any 
    // boundary checks.
    iCharPos++;
    iCol++;
    
    if (cCharObj.IsNewline()) AddRow();

    return cCharObj;
}
//----------------------------------------------------------------------------------//
void CBCGPAutoHideDockBar::DockControlBar (CBCGPControlBar* pControlBar, BCGP_DOCK_METHOD /*dockMethod*/, 
								    LPCRECT lpRect)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pControlBar);

	BOOL bVertDock = !IsHorizontal ();
	CSize szBarSize = pControlBar->CalcFixedLayout (FALSE, !bVertDock);

	// the control bar doesn't take up all space of the row
	int nRowHeight = bVertDock ? szBarSize.cx + m_nExtraSpace 
							   : szBarSize.cy + m_nExtraSpace;

	if (!m_lstControlBars.Find (pControlBar))
	{
		CBCGPDockBarRow* pRowToDock = NULL;

		if (m_lstDockBarRows.IsEmpty ())
		{
			pRowToDock = AddRow (NULL, nRowHeight);
			if (GetCurrentAlignment () & CBRS_ALIGN_LEFT || 
				GetCurrentAlignment () & CBRS_ALIGN_TOP)
			{
				pRowToDock->SetExtra (m_nExtraSpace, BCGP_ROW_ALIGN_TOP);
			}
			else
			{
				pRowToDock->SetExtra (m_nExtraSpace, BCGP_ROW_ALIGN_BOTTOM);
			}
		}
		else
		{
			pRowToDock = (CBCGPDockBarRow*) m_lstDockBarRows.GetHead ();
		}
		
		ASSERT_VALID (pRowToDock);
		// the bar should be placed on the existing row or new row
		pRowToDock->AddControlBar (pControlBar, BCGP_DM_RECT, lpRect, TRUE);

		ShowWindow (SW_SHOW);

		m_lstControlBars.AddTail (pControlBar);
		AdjustDockingLayout ();
		CRect rectClient;
		GetClientRect (rectClient);
		RepositionBars (rectClient);
		
	}
}