void AntialiasingSettingsView::MessageReceived(BMessage *msg) { switch (msg->what) { case kMsgSetAntialiasing: { bool subpixelAntialiasing; if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK || subpixelAntialiasing == fCurrentSubpixelAntialiasing) break; fCurrentSubpixelAntialiasing = subpixelAntialiasing; fAverageWeightControl->SetEnabled(fCurrentSubpixelAntialiasing); set_subpixel_antialiasing(fCurrentSubpixelAntialiasing); Window()->PostMessage(kMsgUpdate); break; } case kMsgSetHinting: { int8 hinting; if (msg->FindInt8("hinting", &hinting) != B_OK || hinting == fCurrentHinting) break; fCurrentHinting = hinting; set_hinting_mode(fCurrentHinting); Window()->PostMessage(kMsgUpdate); break; } case kMsgSetAverageWeight: { int32 averageWeight = fAverageWeightControl->Value(); if (averageWeight == fCurrentAverageWeight) break; fCurrentAverageWeight = averageWeight; set_average_weight(fCurrentAverageWeight); Window()->PostMessage(kMsgUpdate); break; } case B_COLORS_UPDATED: { if (msg->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR)) || msg->HasColor(ui_color_name(B_PANEL_TEXT_COLOR))) { _UpdateColors(); } break; } default: BView::MessageReceived(msg); } }
void APRView::Revert() { _SetUIColors(fPrevColors); _UpdatePreviews(fPrevColors); rgb_color color = fPrevColors.GetColor(ui_color_name(fWhich), make_color(255, 0, 255)); fPicker->SetValue(color); fColorPreview->SetColor(color); fColorPreview->Invalidate(); Window()->PostMessage(kMsgUpdate); }
void OverlayView::MessageReceived(BMessage *msg) { switch (msg->what) { case B_SIMPLE_DATA: { if (fReplicated) break; entry_ref ref; msg->FindRef("refs", &ref); BEntry entry(&ref); BPath path(&entry); delete fBitmap; fBitmap = BTranslationUtils::GetBitmap(path.Path()); if (fBitmap != NULL) { if (fText != NULL) { RemoveChild(fText); fText = NULL; } BRect rect = fBitmap->Bounds(); if (!fReplicated) { Window()->ResizeTo(rect.right, rect.bottom); Window()->Activate(true); } ResizeTo(rect.right, rect.bottom); Invalidate(); } break; } case B_ABOUT_REQUESTED: OverlayAboutRequested(); break; case B_COLORS_UPDATED: { rgb_color color; if (msg->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &color) == B_OK) fText->SetFontAndColor(be_plain_font, B_FONT_ALL, &color); break; } default: BView::MessageReceived(msg); break; } }
void APRView::_UpdatePreviews(const BMessage& colors) { rgb_color color; for (int32 i = color_description_count() - 1; i >= 0; i--) { ColorWhichItem* item = static_cast<ColorWhichItem*>(fAttrList->ItemAt(i)); if (item == NULL) continue; color = colors.GetColor(ui_color_name(get_color_description(i)->which), make_color(255, 0, 255)); item->SetColor(color); fAttrList->InvalidateItem(i); } }
void APRView::SetDefaults() { _SetUIColors(fDefaultColors); _UpdatePreviews(fDefaultColors); // Use a default color that stands out to show errors clearly rgb_color color = fDefaultColors.GetColor(ui_color_name(fWhich), make_color(255, 0, 255)); fPicker->SetValue(color); fColorPreview->SetColor(color); fColorPreview->Invalidate(); Window()->PostMessage(kMsgUpdate); }
void APRView::_SetCurrentColor(rgb_color color) { set_ui_color(fWhich, color); fCurrentColors.SetColor(ui_color_name(fWhich), color); int32 currentIndex = fAttrList->CurrentSelection(); ColorWhichItem* item = (ColorWhichItem*)fAttrList->ItemAt(currentIndex); if (item != NULL) { item->SetColor(color); fAttrList->InvalidateItem(currentIndex); } fPicker->SetValue(color); fColorPreview->SetColor(color); fColorPreview->Invalidate(); }
void BStatusBar::MessageReceived(BMessage *message) { switch(message->what) { case B_UPDATE_STATUS_BAR: { float delta; const char *text = NULL, *trailing_text = NULL; message->FindFloat("delta", &delta); message->FindString("text", &text); message->FindString("trailing_text", &trailing_text); Update(delta, text, trailing_text); break; } case B_RESET_STATUS_BAR: { const char *label = NULL, *trailing_label = NULL; message->FindString("label", &label); message->FindString("trailing_label", &trailing_label); Reset(label, trailing_label); break; } case B_COLORS_UPDATED: { // Change the bar color IF we don't have an application-set color. if ((fInternalFlags & kCustomBarColor) == 0) { message->FindColor(ui_color_name(B_STATUS_BAR_COLOR), &fBarColor); } break; } default: BView::MessageReceived(message); break; } }
void CalcView::MessageReceived(BMessage* message) { if (message->what == B_COLORS_UPDATED && !fHasCustomBaseColor) { const char* panelBgColorName = ui_color_name(B_PANEL_BACKGROUND_COLOR); if (message->HasColor(panelBgColorName)) { fBaseColor = message->GetColor(panelBgColorName, fBaseColor); _Colorize(); } return; } if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) { // if we are embedded in desktop we need to receive these // message here since we don't have a parent BWindow switch (message->what) { case MSG_OPTIONS_AUTO_NUM_LOCK: ToggleAutoNumlock(); return; case MSG_OPTIONS_AUDIO_FEEDBACK: ToggleAudioFeedback(); return; case MSG_OPTIONS_ANGLE_MODE_RADIAN: SetDegreeMode(false); return; case MSG_OPTIONS_ANGLE_MODE_DEGREE: SetDegreeMode(true); return; } } // check if message was dropped if (message->WasDropped()) { // pass message on to paste if (message->IsSourceRemote()) Paste(message); } else { // act on posted message type switch (message->what) { // handle "cut" case B_CUT: Cut(); break; // handle copy case B_COPY: Copy(); break; // handle paste case B_PASTE: // access system clipboard if (be_clipboard->Lock()) { BMessage* clipper = be_clipboard->Data(); //clipper->PrintToStream(); Paste(clipper); be_clipboard->Unlock(); } break; // (replicant) about box requested case B_ABOUT_REQUESTED: { BAboutWindow* window = new BAboutWindow(kAppName, kSignature); // create the about window const char* extraCopyrights[] = { "1997, 1998 R3 Software Ltd.", NULL }; const char* authors[] = { "Stephan Aßmus", "John Scipione", "Timothy Wayper", "Ingo Weinhold", NULL }; window->AddCopyright(2006, "Haiku, Inc.", extraCopyrights); window->AddAuthors(authors); window->Show(); break; } case MSG_UNFLASH_KEY: { int32 key; if (message->FindInt32("key", &key) == B_OK) _FlashKey(key, 0); break; } case kMsgAnimateDots: { int32 end = fExpressionTextView->TextLength(); int32 start = end - 3; if (fEnabled || strcmp(fExpressionTextView->Text() + start, "...") != 0) { // stop the message runner delete fEvaluateMessageRunner; fEvaluateMessageRunner = NULL; break; } uint8 dot = 0; if (message->FindUInt8("dot", &dot) == B_OK) { rgb_color fontColor = fExpressionTextView->HighColor(); rgb_color backColor = fExpressionTextView->LowColor(); fExpressionTextView->SetStylable(true); fExpressionTextView->SetFontAndColor(start, end, NULL, 0, &backColor); fExpressionTextView->SetFontAndColor(start + dot - 1, start + dot, NULL, 0, &fontColor); fExpressionTextView->SetStylable(false); } dot++; if (dot == 4) dot = 1; delete fEvaluateMessageRunner; BMessage animate(kMsgAnimateDots); animate.AddUInt8("dot", dot); fEvaluateMessageRunner = new (std::nothrow) BMessageRunner( BMessenger(this), &animate, kAnimationInterval, 1); break; } case kMsgCalculating: { // calculation has taken more than 3 seconds if (fEnabled) { // stop the message runner delete fEvaluateMessageRunner; fEvaluateMessageRunner = NULL; break; } BString calculating; calculating << B_TRANSLATE("Calculating") << "..."; fExpressionTextView->SetText(calculating.String()); delete fEvaluateMessageRunner; BMessage animate(kMsgAnimateDots); animate.AddUInt8("dot", 1U); fEvaluateMessageRunner = new (std::nothrow) BMessageRunner( BMessenger(this), &animate, kAnimationInterval, 1); break; } case kMsgDoneEvaluating: { _SetEnabled(true); rgb_color fontColor = fExpressionTextView->HighColor(); fExpressionTextView->SetFontAndColor(NULL, 0, &fontColor); const char* result; if (message->FindString("error", &result) == B_OK) fExpressionTextView->SetText(result); else if (message->FindString("value", &result) == B_OK) fExpressionTextView->SetValue(result); // stop the message runner delete fEvaluateMessageRunner; fEvaluateMessageRunner = NULL; break; } default: BView::MessageReceived(message); break; } } }
void DataTranslationsWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgTranslatorInfo: { int32 selected = fTranslatorListView->CurrentSelection(0); if (selected < 0) break; TranslatorItem* item = fTranslatorListView->TranslatorAt(selected); if (item != NULL) _ShowInfoAlert(item->ID()); break; } case kMsgSelectedTranslator: { // Update the icon and translator info panel // to match the new selection int32 selected = fTranslatorListView->CurrentSelection(0); if (selected < 0) { // If none selected, clear the old one fIconView->DrawIcon(false); fButton->SetEnabled(false); fRightBox->RemoveChild(fConfigView); _ShowInfoView(); break; } TranslatorItem* item = fTranslatorListView->TranslatorAt(selected); if (item == NULL) break; _ShowConfigView(item->ID()); const char* name = NULL; const char* info = NULL; int32 version = 0; BPath path; _GetTranslatorInfo(item->ID(), name, info, version, path); fIconView->SetIcon(path); fButton->SetEnabled(true); break; } case B_COLORS_UPDATED: { if (fInfoText == NULL || fInfoText->Parent() == NULL) break; rgb_color color; if (message->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &color) == B_OK) { fInfoText->SetFontAndColor(be_plain_font, B_FONT_ALL, &color); } break; } case B_TRANSLATOR_ADDED: { int32 index = 0; int32 id; while (message->FindInt32("translator_id", index++, &id) == B_OK) { const char* name; const char* info; int32 version; BPath path; if (_GetTranslatorInfo(id, name, info, version, path) == B_OK) fTranslatorListView->AddItem(new TranslatorItem(id, name)); } fTranslatorListView->SortItems(); break; } case B_TRANSLATOR_REMOVED: { int32 index = 0; int32 id; while (message->FindInt32("translator_id", index++, &id) == B_OK) { for (int32 i = 0; i < fTranslatorListView->CountItems(); i++) { TranslatorItem* item = fTranslatorListView->TranslatorAt(i); if (item == NULL) continue; if (item->ID() == (translator_id)id) { fTranslatorListView->RemoveItem(i); delete item; break; } } } break; } default: BWindow::MessageReceived(message); break; } }