void Window::MessageReceived(BMessage* message) { switch (message->what) { case kMsgUpdate: { char buffer[100]; snprintf(buffer, sizeof(buffer), "%ld ", (int32)fStatusBar->CurrentValue()); fStatusBar->Update(1, fStatusBar->CurrentValue() > 25 ? " updated!" : NULL, buffer); if (fStatusBar->CurrentValue() >= fStatusBar->MaxValue()) { #if 1 fStatusBar->Reset("-", "????"); #else fStatusBar->Reset(); fStatusBar->SetText("-"); fStatusBar->SetTrailingText("????"); #endif fStatusBar->SetMaxValue(50.0); } } default: BWindow::MessageReceived(message); } }
status_t PProgressBar::GetProperty(const char *name, PValue *value, const int32 &index) const { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; BStatusBar *backend = (BStatusBar*)fView; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("BarColor") == 0) ((ColorProperty*)prop)->SetValue(backend->BarColor()); else if (str.ICompare("BarHeight") == 0) ((FloatProperty*)prop)->SetValue(backend->BarHeight()); else if (str.ICompare("Label") == 0) ((StringProperty*)prop)->SetValue(backend->Label()); else if (str.ICompare("CurrentValue") == 0) { ((FloatProperty*)prop)->SetValue(backend->CurrentValue()); } else if (str.ICompare("MaxValue") == 0) ((FloatProperty*)prop)->SetValue(backend->MaxValue()); else if (str.ICompare("Text") == 0) ((StringProperty*)prop)->SetValue(backend->Text()); else if (str.ICompare("TrailingLabel") == 0) ((StringProperty*)prop)->SetValue(backend->TrailingLabel()); else if (str.ICompare("TrailingText") == 0) ((StringProperty*)prop)->SetValue(backend->TrailingText()); else { if (backend->Window()) backend->Window()->Unlock(); return PView::GetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }