当前位置: 首页>>代码示例>>C++>>正文


C++ BStringField::String方法代码示例

本文整理汇总了C++中BStringField::String方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringField::String方法的具体用法?C++ BStringField::String怎么用?C++ BStringField::String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BStringField的用法示例。


在下文中一共展示了BStringField::String方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

void
NetPrefsServerView::RemoveServer ()
{
  BAutolock lock (Looper ());

  if (!lock.IsLocked ())
    return;

  BRow *row (fServerList->CurrentSelection ());
  if (row)
  {
    BStringField *field ((BStringField *) row->GetField (1));

    int32 count;
    ssize_t size;
    type_code type;
    fActiveNetwork->GetInfo ("server", &type, &count);

    const ServerData *data;
    for (int32 i = 0; i < count; i++)
    {
      fActiveNetwork->FindData ("server", B_ANY_TYPE, i, reinterpret_cast < const void **>(&data),
        &size);

      if (!strcmp (data->serverName, field->String ()))
      {
        fActiveNetwork->RemoveData ("server", i);
        break;
      }
	}
    fServerList->RemoveRow (row);
    delete row;
  }
}
开发者ID:xray7224,项目名称:Vision,代码行数:34,代码来源:NetPrefsServerView.cpp

示例2: max_c

float
TeamsColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
	BBitmapStringField* bitmapField
		= dynamic_cast<BBitmapStringField*>(_field);
	BStringField* stringField = dynamic_cast<BStringField*>(_field);

	float parentWidth = Inherited::GetPreferredWidth(_field, parent);
	float width = 0.0;

	if (bitmapField) {
		const BBitmap* bitmap = bitmapField->Bitmap();
		BFont font;
		parent->GetFont(&font);
		width = font.StringWidth(bitmapField->String()) + 3 * sTextMargin;
		if (bitmap)
			width += bitmap->Bounds().Width();
		else
			width += 16;
	} else if (stringField) {
		BFont font;
		parent->GetFont(&font);
		width = font.StringWidth(stringField->String()) + 2 * sTextMargin;
	}
	return max_c(width, parentWidth);
}
开发者ID:jessicah,项目名称:haiku-private,代码行数:26,代码来源:TeamsListView.cpp

示例3:

void
NotificationsView::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case kApplicationSelected:
		{
			BRow* row = fApplications->CurrentSelection();
			if (row == NULL)
				return;
			BStringField* appName
				= dynamic_cast<BStringField*>(row->GetField(kAppIndex));
			if (appName == NULL)
				break;

			appusage_t::iterator it = fAppFilters.find(appName->String());
			if (it != fAppFilters.end())
				_Populate(it->second);

			break;
		}
		case kNotificationSelected:
			break;
		default:
			BView::MessageReceived(msg);
			break;
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:27,代码来源:NotificationsView.cpp

示例4: out_string

void
BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
    float width = rect.Width() - (2 * kTEXT_MARGIN);
    BStringField* field = static_cast<BStringField*>(_field);
    bool clipNeeded = width < field->Width();

    if (clipNeeded) {
        BString out_string(field->String());

        parent->TruncateString(&out_string, fTruncate, width + 2);
        field->SetClippedString(out_string.String());
        field->SetWidth(width);
    }

    DrawString(clipNeeded ? field->ClippedString() : field->String(), parent, rect);
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:17,代码来源:ColumnTypes.cpp

示例5: max_c

float
BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
	BStringField* field = static_cast<BStringField*>(_field);
	BFont font;
	parent->GetFont(&font);
	float width = font.StringWidth(field->String()) + 2 * kTEXT_MARGIN;
	float parentWidth = BTitledColumn::GetPreferredWidth(_field, parent);
	return max_c(width, parentWidth);
}
开发者ID:HaikuArchives,项目名称:IMKit,代码行数:10,代码来源:ColumnTypes.cpp

示例6: GetItemText

/**
 *	@brief	Gets a string at specified index from the control.
 *	@param[in]	rowIndex		row index
 *	@param[in]	columnIndex		column index
 *	@param[out]	text	a string value is returned.
 */
void BeColumnListViewAdapter::GetItemText(SInt32 rowIndex, SInt32 columnIndex, MBCString& text)
{
	BColumnListView* listView = getColumnListView();
	BRow* row = listView->RowAt(rowIndex);
	BStringField* field = dynamic_cast<BStringField*>(row->GetField(columnIndex));
	if (NULL != field)
	{
		text = field->String();
	}
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:16,代码来源:BeColumnListViewAdapter.cpp

示例7: out_string

void
BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
	float width = rect.Width() - (2 * kTEXT_MARGIN);
	BStringField* field = static_cast<BStringField*>(_field);
	float fieldWidth = field->Width();
	bool updateNeeded = width != fieldWidth;

	if (updateNeeded) {
		BString out_string(field->String());
		float preferredWidth = parent->StringWidth(out_string.String());
		if (width < preferredWidth) {
			parent->TruncateString(&out_string, fTruncate, width + 2);
			field->SetClippedString(out_string.String());
		} else
			field->SetClippedString("");
		field->SetWidth(width);
	}

	DrawString(field->HasClippedString() ? field->ClippedString()
			: field->String(), parent, rect);
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:22,代码来源:ColumnTypes.cpp

示例8:

void
ResView::UpdateRow(BRow *row)
{
	TypeCodeField *typeField = (TypeCodeField*) row->GetField(1);
	ResourceData *resData = typeField->GetResourceData();
	BStringField *strField = (BStringField *)row->GetField(0);
	
	if (strcmp("(attr)", strField->String()) != 0)
		strField->SetString(resData->GetIDString());
	
	strField = (BStringField *)row->GetField(2);
	if (strField)
		strField->SetString(resData->GetName());
	
	PreviewField *preField = (PreviewField*)row->GetField(3);
	if (preField)
		preField->SetData(resData->GetData(), resData->GetLength());
	
	BSizeField *sizeField = (BSizeField*)row->GetField(4);
	if (sizeField)
		sizeField->SetSize(resData->GetLength());
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:22,代码来源:ResView.cpp

示例9: truncatedString

void
TeamsColumn::DrawField(BField* field, BRect rect, BView* parent)
{
	BBitmapStringField* bitmapField
		= dynamic_cast<BBitmapStringField*>(field);
	BStringField* stringField = dynamic_cast<BStringField*>(field);

	if (bitmapField) {
		const BBitmap* bitmap = bitmapField->Bitmap();

		// figure out the placement
		float x = 0.0;
		BRect r = bitmap ? bitmap->Bounds() : BRect(0, 0, 15, 15);
		float y = rect.top + ((rect.Height() - r.Height()) / 2);
		float width = 0.0;

		switch (Alignment()) {
			default:
			case B_ALIGN_LEFT:
			case B_ALIGN_CENTER:
				x = rect.left + sTextMargin;
				width = rect.right - (x + r.Width()) - (2 * sTextMargin);
				r.Set(x + r.Width(), rect.top, rect.right - width, rect.bottom);
				break;

			case B_ALIGN_RIGHT:
				x = rect.right - sTextMargin - r.Width();
				width = (x - rect.left - (2 * sTextMargin));
				r.Set(rect.left, rect.top, rect.left + width, rect.bottom);
				break;
		}

		if (width != bitmapField->Width()) {
			BString truncatedString(bitmapField->String());
			parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
			bitmapField->SetClippedString(truncatedString.String());
			bitmapField->SetWidth(width);
		}

		// draw the bitmap
		if (bitmap) {
			parent->SetDrawingMode(B_OP_ALPHA);
			parent->DrawBitmap(bitmap, BPoint(x, y));
			parent->SetDrawingMode(B_OP_OVER);
		}

		// draw the string
		DrawString(bitmapField->ClippedString(), parent, r);

	} else if (stringField) {

		float width = rect.Width() - (2 * sTextMargin);

		if (width != stringField->Width()) {
			BString truncatedString(stringField->String());

			parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
			stringField->SetClippedString(truncatedString.String());
			stringField->SetWidth(width);
		}

		DrawString(stringField->ClippedString(), parent, rect);
	}
}
开发者ID:jessicah,项目名称:haiku-private,代码行数:64,代码来源:TeamsListView.cpp

示例10:

float
BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
	BStringField* field = static_cast<BStringField*>(_field);
	return parent->StringWidth(field->String()) + 2 * kTEXT_MARGIN;
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:6,代码来源:ColumnTypes.cpp

示例11: SetPeriod

void BudgetWindow::SetPeriod(const BudgetPeriod &period)
{
	BRow *row = fCategoryList->CurrentSelection();
	if(!row)
		return;

	BudgetEntry entry;
	BStringField *strfield = (BStringField*)row->GetField(0);
	if(!gDatabase.GetBudgetEntry(strfield->String(),entry))
		return;

	// Convert the amount to reflect the change in period
	switch(entry.period)
	{
		case BUDGET_WEEKLY:
		{
			entry.amount *= 52;
			break;
		}
		case BUDGET_QUARTERLY:
		{
			entry.amount *= 4;
			break;
		}
		case BUDGET_ANNUALLY:
		{
			break;
		}
		default:
		{
			entry.amount *= 12;
			break;
		}
	}
	entry.period = period;

	switch(entry.period)
	{
		case BUDGET_WEEKLY:
		{
			entry.amount /= 52;
			break;
		}
		case BUDGET_QUARTERLY:
		{
			entry.amount /= 4;
			break;
		}
		case BUDGET_ANNUALLY:
		{
			break;
		}
		default:
		{
			entry.amount /= 12;
			break;
		}
	}
	// yeah, yeah, I know about rounding errors. It's not that big of a deal,
	// so deal with it. *famous last words*
	entry.amount.Round();

	gDatabase.AddBudgetEntry(entry);
	RefreshBudgetGrid();
	RefreshBudgetSummary();

	BString str;
	gDefaultLocale.CurrencyToString(entry.amount,str);
	str.Truncate(str.FindFirst(gDefaultLocale.CurrencyDecimal()));
	str.RemoveFirst(gDefaultLocale.CurrencySymbol());

	row->SetField(new BStringField(str.String()),1);
	fAmountBox->SetText(str.String());

	row->SetField(new BStringField(BudgetPeriodToString(entry.period).String()),2);
	fCategoryList->UpdateRow(row);
}
开发者ID:HaikuArchives,项目名称:CapitalBe,代码行数:77,代码来源:BudgetWindow.cpp

示例12: HandleCategorySelection

void BudgetWindow::HandleCategorySelection(void)
{
	BRow *row = fCategoryList->CurrentSelection();
	if(!row)
	{
		fAmountBox->SetText("");
		fMonthly->SetValue(B_CONTROL_ON);
		fStatAverageRow->SetField(new BStringField(""),1);
		fStatHighestRow->SetField(new BStringField(""),1);
		fStatLowestRow->SetField(new BStringField(""),1);
	}

	BudgetEntry entry;
	BStringField *strfield = (BStringField*)row->GetField(0);
	if(!gDatabase.GetBudgetEntry(strfield->String(),entry))
		return;

	switch(entry.period)
	{
		case BUDGET_WEEKLY:
		{
			fWeekly->SetValue(B_CONTROL_ON);
			break;
		}
		case BUDGET_QUARTERLY:
		{
			fQuarterly->SetValue(B_CONTROL_ON);
			break;
		}
		case BUDGET_ANNUALLY:
		{
			fAnnually->SetValue(B_CONTROL_ON);
			break;
		}
		default:
		{
			fMonthly->SetValue(B_CONTROL_ON);
			break;
		}
	}

	BString str;
	gDefaultLocale.CurrencyToString(entry.amount.AbsoluteValue(),str);
	str.Truncate(str.FindFirst(gDefaultLocale.CurrencyDecimal()));
	str.RemoveFirst(gDefaultLocale.CurrencySymbol());
	fAmountBox->SetText(str.String());

	Fixed high,low,avg;
	CalcStats(entry.name.String(),high,low,avg);

	gDefaultLocale.CurrencyToString(high.AbsoluteValue(),str);
	str.RemoveFirst(gDefaultLocale.CurrencySymbol());
	fStatHighestRow->SetField(new BStringField(str.String()),1);

	gDefaultLocale.CurrencyToString(low.AbsoluteValue(),str);
	str.RemoveFirst(gDefaultLocale.CurrencySymbol());
	fStatLowestRow->SetField(new BStringField(str.String()),1);

	gDefaultLocale.CurrencyToString(avg.AbsoluteValue(),str);
	str.RemoveFirst(gDefaultLocale.CurrencySymbol());
	fStatAverageRow->SetField(new BStringField(str.String()),1);

	fCatStat->Invalidate();
}
开发者ID:HaikuArchives,项目名称:CapitalBe,代码行数:64,代码来源:BudgetWindow.cpp

示例13: which

void
ListAgent::MessageReceived (BMessage *msg)
{
  switch (msg->what)
  {
    case M_THEME_FONT_CHANGE:
      {
        int32 which (msg->FindInt16 ("which"));
        if (which == F_LISTAGENT)
        {
          activeTheme->ReadLock();
          listView->SetFont (B_FONT_ROW, &activeTheme->FontAt (F_LISTAGENT));
          activeTheme->ReadUnlock();
          listView->Invalidate();
        }
      }
      break;
      
    case M_THEME_FOREGROUND_CHANGE:
      {
        int32 which (msg->FindInt16 ("which"));
        bool refresh (false);
        switch (which)
        {
          case C_BACKGROUND:
            activeTheme->ReadLock();
            listView->SetColor (B_COLOR_BACKGROUND, activeTheme->ForegroundAt (C_BACKGROUND));
            activeTheme->ReadUnlock();
            refresh = true;
            break;
            
          case C_TEXT:
            activeTheme->ReadLock();
            listView->SetColor (B_COLOR_TEXT, activeTheme->ForegroundAt (C_TEXT));
            activeTheme->ReadUnlock();
            refresh = true;
            break;

          case C_SELECTION:             
            activeTheme->ReadLock();
            listView->SetColor (B_COLOR_SELECTION, activeTheme->ForegroundAt (C_SELECTION));
            activeTheme->ReadUnlock();
            refresh = true;
            break;
            
          default:
            break;
        }
        if (refresh)
          Invalidate();
      }
      break;
      
    case M_STATUS_ADDITEMS:
      {
        vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem (S_STATUS_LISTCOUNT, ""), true);
        vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem (S_STATUS_LISTSTAT, ""), true);
        vision_app->pClientWin()->pStatusView()->AddItem (new StatusItem (S_STATUS_LISTFILTER, "", STATUS_ALIGN_LEFT), true);
 
        BString cString;
        cString << listView->CountRows();
        vision_app->pClientWin()->pStatusView()->SetItemValue (0, cString.String(), false);
        vision_app->pClientWin()->pStatusView()->SetItemValue (1, statusStr.String(), false);
        vision_app->pClientWin()->pStatusView()->SetItemValue (2, filter.String(), true);
      }
      break;

    case M_LIST_COMMAND:
      {
        if (!processing)
        {
          BMessage sMsg (M_SERVER_SEND);
          
          BString command ("LIST");
          
          BString params (msg->FindString ("cmd"));
          if (params != "-9z99")
          {
            command.Append (" ");
            command.Append (params);
          }

          sMsg.AddString ("data", command.String());

          fSMsgr->SendMessage (&sMsg);
          processing = true;

          if (!IsHidden())
            vision_app->pClientWin()->pStatusView()->SetItemValue (0, "0", true);
        }
      }
      break;

    case M_LIST_BEGIN:
      {
        BMessage msg (M_LIST_UPDATE);
        listUpdateTrigger = new BMessageRunner (BMessenger(this), &msg, 3000000); 
        statusStr = S_LIST_STATUS_LOADING;
        if (!IsHidden())
          vision_app->pClientWin()->pStatusView()->SetItemValue (1, statusStr.String(), true);
//.........这里部分代码省略.........
开发者ID:xray7224,项目名称:Vision,代码行数:101,代码来源:ListAgent.cpp


注:本文中的BStringField::String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。