本文整理汇总了C++中DataSource::SetColor方法的典型用法代码示例。如果您正苦于以下问题:C++ DataSource::SetColor方法的具体用法?C++ DataSource::SetColor怎么用?C++ DataSource::SetColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::SetColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _
status_t
ActivityView::AddDataSource(const DataSource* source, const BMessage* state)
{
if (source == NULL)
return B_BAD_VALUE;
BAutolock _(fSourcesLock);
// Search for the correct insert spot to maintain the order of the sources
int32 insert = DataSource::IndexOf(source);
for (int32 i = 0; i < fSources.CountItems() && i < insert; i++) {
DataSource* before = fSources.ItemAt(i);
if (DataSource::IndexOf(before) > insert) {
insert = i;
break;
}
}
if (insert > fSources.CountItems())
insert = fSources.CountItems();
// Generate DataHistory and ViewHistory objects for the source
// (one might need one history per CPU)
uint32 count = 1;
if (source->PerCPU()) {
SystemInfo info;
count = info.CPUCount();
}
for (uint32 i = 0; i < count; i++) {
DataHistory* values = new(std::nothrow) DataHistory(10 * 60000000LL,
RefreshInterval());
ListAddDeleter<DataHistory> valuesDeleter(fValues, values, insert);
ViewHistory* viewValues = new(std::nothrow) ViewHistory;
ListAddDeleter<ViewHistory> viewValuesDeleter(fViewValues, viewValues,
insert);
if (valuesDeleter.Failed() || viewValuesDeleter.Failed())
return B_NO_MEMORY;
values->SetScale(_ScaleFor(source->ScaleType()));
DataSource* copy;
if (source->PerCPU())
copy = source->CopyForCPU(i);
else
copy = source->Copy();
ListAddDeleter<DataSource> sourceDeleter(fSources, copy, insert);
if (sourceDeleter.Failed())
return B_NO_MEMORY;
BString colorName = source->Name();
colorName << " color";
if (state != NULL) {
const rgb_color* color = NULL;
ssize_t colorLength;
if (state->FindData(colorName.String(), B_RGB_COLOR_TYPE, i,
(const void**)&color, &colorLength) == B_OK
&& colorLength == sizeof(rgb_color))
copy->SetColor(*color);
}
valuesDeleter.Detach();
viewValuesDeleter.Detach();
sourceDeleter.Detach();
insert++;
}
#ifdef __HAIKU__
InvalidateLayout();
#endif
return B_OK;
}