void initial_log_id(int32_t prefix) { srand((unsigned)time(0)); int64_t log_id = prefix; log_id = (log_id * 10000000000) + rand(); atomic_set64(&g_log_id, log_id); }
void ActivityView::MessageReceived(BMessage* message) { // if a color is dropped, use it as background if (message->WasDropped()) { rgb_color* color; ssize_t size; if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, 0, (const void**)&color, &size) == B_OK && size == sizeof(rgb_color)) { BPoint dropPoint = message->DropPoint(); ConvertFromScreen(&dropPoint); if (_HistoryFrame().Contains(dropPoint)) { fHistoryBackgroundColor = *color; Invalidate(_HistoryFrame()); } else { // check each legend color box BAutolock _(fSourcesLock); BRect legendFrame = _LegendFrame(); for (int32 i = 0; i < fSources.CountItems(); i++) { BRect frame = _LegendColorFrameAt(legendFrame, i); if (frame.Contains(dropPoint)) { fSources.ItemAt(i)->SetColor(*color); Invalidate(_HistoryFrame()); Invalidate(frame); return; } } if (dynamic_cast<ActivityMonitor*>(be_app) == NULL) { // allow background color change in the replicant only fLegendBackgroundColor = *color; SetLowColor(fLegendBackgroundColor); Invalidate(legendFrame); } } return; } } switch (message->what) { case B_ABOUT_REQUESTED: { BAboutWindow* window = new BAboutWindow(kAppName, kSignature); const char* authors[] = { "Axel Dörfler", NULL }; window->AddCopyright(2008, "Haiku, Inc."); window->AddAuthors(authors); window->Show(); break; } case kMsgUpdateResolution: { int32 resolution; if (message->FindInt32("resolution", &resolution) != B_OK) break; _UpdateResolution(resolution, false); break; } case kMsgTimeIntervalUpdated: bigtime_t interval; if (message->FindInt64("interval", &interval) != B_OK) break; if (interval < 10000) interval = 10000; atomic_set64(&fRefreshInterval, interval); break; case kMsgToggleDataSource: { int32 index; if (message->FindInt32("index", &index) != B_OK) break; const DataSource* baseSource = DataSource::SourceAt(index); if (baseSource == NULL) break; DataSource* source = FindDataSource(baseSource); if (source == NULL) AddDataSource(baseSource); else RemoveDataSource(baseSource); Invalidate(); break; } case kMsgToggleLegend: fShowLegend = !fShowLegend; Invalidate(); break; case B_MOUSE_WHEEL_CHANGED: { float deltaY = 0.0f; if (message->FindFloat("be:wheel_delta_y", &deltaY) != B_OK || deltaY == 0.0f) break; int32 resolution = fDrawResolution; if (deltaY > 0) resolution *= 2; else resolution /= 2; _UpdateResolution(resolution); break; } default: BView::MessageReceived(message); break; } }