コード例 #1
0
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;
  }
}
コード例 #2
0
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);
}
コード例 #3
0
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;
	}
}
コード例 #4
0
ファイル: ColumnTypes.cpp プロジェクト: HaikuArchives/IMKit
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);
}
コード例 #5
0
/**
 *	@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();
	}
}
コード例 #6
0
ファイル: ResView.cpp プロジェクト: AmirAbrams/haiku
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());
}
コード例 #7
0
ファイル: ColumnTypes.cpp プロジェクト: dtbinh/Sequitur
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);
}
コード例 #8
0
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);
}
コード例 #9
0
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);
	}
}
コード例 #10
0
ファイル: ColumnTypes.cpp プロジェクト: dtbinh/Sequitur
float
BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
	BStringField* field = static_cast<BStringField*>(_field);
	return parent->StringWidth(field->String()) + 2 * kTEXT_MARGIN;
}
コード例 #11
0
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);
}
コード例 #12
0
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();
}
コード例 #13
0
ファイル: ListAgent.cpp プロジェクト: xray7224/Vision
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);
      }
      break;
      
    case M_LIST_DONE:
      {
        if (listUpdateTrigger)
        {
          delete listUpdateTrigger;
          listUpdateTrigger = 0;
        }
        statusStr = S_LIST_STATUS_DONE;

        listView->SetSortingEnabled (true);
        listView->SetSortColumn (channelColumn, true, true);
        
        if (!IsHidden())
          vision_app->pClientWin()->pStatusView()->SetItemValue (1, statusStr.String(), true);

        mFind->SetEnabled (true);
        mFindAgain->SetEnabled (true);
        mFilter->SetEnabled (true);

        processing = false;
        
        // empty out any remaining channels that fell below the batch cut off
        AddBatch();

        BString cString;
        cString << listView->CountRows();
        if (!IsHidden())
          vision_app->pClientWin()->pStatusView()->SetItemValue (0, cString.String(), true);
      }
      break;

    case M_LIST_EVENT:
      {
        const char *channel, *users, *topic;

        msg->FindString ("channel", &channel);
        msg->FindString ("users", &users);
        msg->FindString ("topic", &topic);
        
        BRow *row (new BRow ());
        
        
        BStringField *channelField (new BStringField (channel));
        BIntegerField *userField (new BIntegerField (atoi(users)));
        BStringField *topicField (new BStringField (topic));
        
        row->SetField (channelField, channelColumn->LogicalFieldNum());
        row->SetField (userField, usersColumn->LogicalFieldNum());
        row->SetField (topicField, topicColumn->LogicalFieldNum());

        fBuildList.AddItem (row);
        
        if (fBuildList.CountItems() == LIST_BATCH_SIZE)
          AddBatch();
      }
      break;

#ifdef __INTEL__

		case M_LIST_FILTER:
			if (msg->HasString ("text"))
			{
				const char *buffer;

				msg->FindString ("text", &buffer);
				if (filter != buffer)
				{
					filter = buffer;

					if (!IsHidden())
					  vision_app->pClientWin()->pStatusView()->SetItemValue (2, filter.String(), true);

					regfree (&re);
					memset (&re, 0, sizeof (re));
					regcomp (
						&re,
						filter.String(),
						REG_EXTENDED | REG_ICASE | REG_NOSUB);
					
					BRow *currentRow;	
					BStringField *channel,
					             *topic;

					while (hiddenItems.CountItems() != 0)
					{
					  currentRow = hiddenItems.RemoveItemAt (0L);
					  listView->AddRow (currentRow);
					}

					if (filter != NULL)
					{
  					  int32 k (0);
  					    					  					
					  while (k < listView->CountRows())
					  {
					     currentRow = listView->RowAt (k);
					     channel = (BStringField *)currentRow->GetField (0);
					     topic = (BStringField *)currentRow->GetField (2);
       				  	 if ((regexec (&re, channel->String(), 0, 0, 0) != REG_NOMATCH)
       				  	    || (regexec (&re, topic->String(), 0, 0, 0) != REG_NOMATCH))
       				  	  {
       				  	    k++;
       					    continue;
       					  }
       					 else
       					 {
       					   listView->RemoveRow (currentRow);
       					   hiddenItems.AddItem (currentRow);
       					 }
					  }
					}
					fMsgr.SendMessage (M_LIST_DONE);
					processing = true;
				}
			}
			else
			{
				PromptWindow *prompt (new PromptWindow (
					BPoint ((Window()->Frame().right/2) - 100, (Window()->Frame().bottom/2) - 50),
					"  Filter:",
					"List Filter",
					filter.String(),
					this,
					new BMessage (M_LIST_FILTER),
					new RegExValidate ("Filter"),
					true));
				prompt->Show();
			}

			break;

		case M_LIST_FIND:
			if (msg->HasString ("text"))
			{
				int32 selection (listView->IndexOf(listView->CurrentSelection()));
				const char *buffer;

				msg->FindString ("text", &buffer);

				if (strlen (buffer) == 0)
				{
					find = buffer;
					break;
				}

				if (selection < 0)
				{
					selection = 0;
				}
				else
				{
					++selection;
				}

				if (find != buffer)
				{
					regfree (&fre);
					memset (&fre, 0, sizeof (fre));
					regcomp (
						&fre,
						buffer,
						REG_EXTENDED | REG_ICASE | REG_NOSUB);
					find = buffer;
				}

				BStringField *field;
				int32 i;
				for (i = selection; i < listView->CountRows(); ++i)
				{
					field = (BStringField *)listView->RowAt (i)->GetField (0);

					if (regexec (&fre, field->String(), 0, 0, 0) != REG_NOMATCH)
						break;
				}

				if (i < listView->CountRows())
				{
					BRow* row = listView->RowAt (i);
					listView->DeselectAll();
					listView->AddToSelection (row);
					listView->ScrollTo(row);
					listView->Refresh();
				}
				else
				{
					listView->DeselectAll();
				}
			}
			else
			{
				PromptWindow *prompt (new PromptWindow (
					BPoint ((Window()->Frame().right / 2) - 100, (Window()->Frame().bottom/2) - 50),
					S_LIST_PROMPT_LABEL,
					S_LIST_PROMPT_TITLE,
					find.String(),
					this,
					new BMessage (M_LIST_FIND),
					new RegExValidate ("Find:"),
					true));
				prompt->Show();
			} 
			break;

		case M_LIST_FAGAIN:
			if (find.Length())
			{
				msg->AddString ("text", find.String());
				msg->what = M_LIST_FIND;
				fMsgr.SendMessage (msg);
			}
			break;
#endif

		case M_LIST_INVOKE:
		{
			BMessage msg (M_SUBMIT);
			BString buffer;
				
			BRow *row (listView->CurrentSelection());
				
			if (row)
			{
                 buffer = "/JOIN ";
                 buffer += ((BStringField *)row->GetField(0))->String();
                 msg.AddBool ("history", false);
                 msg.AddBool ("clear", false);
                 msg.AddString ("input", buffer.String());
                 fSMsgr->SendMessage (&msg);
            }
		}
		break;
		
		case M_CLIENT_QUIT:
		{
		  fSMsgr->SendMessage(M_LIST_SHUTDOWN);
		  BMessage deathchant (M_OBITUARY);
          deathchant.AddPointer ("agent", this);
          deathchant.AddPointer ("item", fAgentWinItem);
          vision_app->pClientWin()->PostMessage (&deathchant);
		}
		break;
		
		default:
			BView::MessageReceived (msg);
	}
}
コード例 #14
0
void
PackageColumn::DrawField(BField* field, BRect rect, BView* parent)
{
    BBitmapStringField* bitmapField
        = dynamic_cast<BBitmapStringField*>(field);
    BStringField* stringField = dynamic_cast<BStringField*>(field);
    RatingField* ratingField = dynamic_cast<RatingField*>(field);

    if (bitmapField != NULL) {
        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 != NULL) {
            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 != NULL) {

        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);

    } else if (ratingField != NULL) {

        const float kDefaultTextMargin = 8;

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

        BString string = "★★★★★";
        float stringWidth = parent->StringWidth(string);
        bool drawOverlay = true;

        if (width < stringWidth) {
            string.SetToFormat("%.1f", ratingField->Rating());
            drawOverlay = false;
            stringWidth = parent->StringWidth(string);
        }

        switch (Alignment()) {
        default:
        case B_ALIGN_LEFT:
            rect.left += kDefaultTextMargin;
            break;
        case B_ALIGN_CENTER:
            rect.left = rect.left + (width - stringWidth) / 2.0f;
            break;

        case B_ALIGN_RIGHT:
            rect.left = rect.right - (stringWidth + kDefaultTextMargin);
            break;
        }

        rect.left = floorf(rect.left);
        rect.right = rect.left + stringWidth;

        if (drawOverlay)
            parent->SetHighColor(0, 170, 255);

        font_height	fontHeight;
        parent->GetFontHeight(&fontHeight);
        float y = rect.top + (rect.Height()
                              - (fontHeight.ascent + fontHeight.descent)) / 2
                  + fontHeight.ascent;

        parent->DrawString(string, BPoint(rect.left, y));

        if (drawOverlay) {
            rect.left = ceilf(rect.left
                              + (ratingField->Rating() / 5.0f) * rect.Width());

            rgb_color color = parent->LowColor();
            color.alpha = 190;
            parent->SetHighColor(color);

            parent->SetDrawingMode(B_OP_ALPHA);
            parent->FillRect(rect, B_SOLID_HIGH);

        }
    }
}