ConfigView::ConfigView() : BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | B_FOLLOW_TOP,0) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // determine font height font_height fontHeight; GetFontHeight(&fontHeight); float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 6; BRect frame(5,2,250,itemHeight + 2); BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false); const char *notifyMethods[] = { MDR_DIALECT_CHOICE ("Beep","音"), MDR_DIALECT_CHOICE ("Alert","窓(メール毎)"), MDR_DIALECT_CHOICE ("Keyboard LEDs","キーボードLED"), MDR_DIALECT_CHOICE ("Central alert","窓(一括)"), "Central beep","Log window"}; for (int32 i = 0,j = 1;i < 6;i++,j *= 2) menu->AddItem(new BMenuItem(notifyMethods[i],new BMessage(kMsgNotifyMethod))); BMenuField *field = new BMenuField(frame,"notify", MDR_DIALECT_CHOICE ("Method:","方法:"),menu); field->ResizeToPreferred(); field->SetDivider(field->StringWidth( MDR_DIALECT_CHOICE ("Method:","方法:")) + 6); AddChild(field); ResizeToPreferred(); }
BodyDownloadConfig::BodyDownloadConfig() : BView(BRect(0,0,50,50), "body_config", B_FOLLOW_ALL_SIDES, 0) { const char *partial_text = B_TRANSLATE( "Partially download messages larger than"); BRect r(0, 0, 280, 15); fPartialBox = new BCheckBox(r, "size_if", partial_text, new BMessage('SIZF')); fPartialBox->ResizeToPreferred(); r = fPartialBox->Frame(); r.OffsetBy(17,r.Height() + 1); r.right = r.left + be_plain_font->StringWidth("0000") + 10; fSizeBox = new BTextControl(r, "size", "", "", NULL); r.OffsetBy(r.Width() + 5,0); fBytesLabel = new BStringView(r, "kb", B_TRANSLATE("KiB")); AddChild(fBytesLabel); fSizeBox->SetDivider(0); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(fPartialBox); AddChild(fSizeBox); ResizeToPreferred(); }
BFileControl::BFileControl(BRect rect, const char* name, const char* label, const char *pathOfFile,uint32 flavors) : BView(rect, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // determine font height font_height fontHeight; GetFontHeight(&fontHeight); float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13; BString selectString = B_TRANSLATE("Select" B_UTF8_ELLIPSIS); float labelWidth = StringWidth(selectString) + 20; rect = Bounds(); rect.right -= labelWidth; rect.top = 4; rect.bottom = itemHeight + 2; fText = new BTextControl(rect,"file_path", label, pathOfFile, NULL); if (label) fText->SetDivider(fText->StringWidth(label) + 6); AddChild(fText); fButton = new BButton(BRect(0, 0, 1, 1), "select_file", selectString, new BMessage(kMsgSelectButton)); fButton->ResizeToPreferred(); fButton->MoveBy(rect.right + 6, (rect.Height() - fButton->Frame().Height()) / 2); AddChild(fButton); fPanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, flavors, false); ResizeToPreferred(); }
void HMenuField::ResizeLocalized(const char* label, const char* itemLabel) { SetLabel(label); BMenuItem* item = MenuItem(); if (item && itemLabel) item->SetLabel(itemLabel); SetDivider(label == NULL ? 0 : StringWidth(label)+StringWidth("n")); ResizeToPreferred(); } /* HMenuField::ResizeLocalized */
ButtonElement::ButtonElement(UIBox frame, TNodePtr node, const char *name, const char *label, t_button_mode mode) : BButton(frame,name,label,NULL,B_FOLLOW_NONE,B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE) , UIElement(frame,node) { buttonMode = mode; float width, height; GetPreferredSize(&width,&height); frame.SetRightBottom(BPoint(frame.LeftTop().x + width, frame.LeftTop().y + height)); ResizeToPreferred(); }
SpinButton::SpinButton(BRect frame, const char *name, BMessage *message, int32 minValue, int32 maxValue, int32 defaultValue, int32 stepValue, uint32 resizingFlags, uint32 flags) : BControl(frame, name, B_EMPTY_STRING, message, resizingFlags, flags), fMinValue(minValue), fMaxValue(maxValue), fDefaultValue(defaultValue), fStepValue(stepValue), fButton(kSpinButtonNone), fPoint() { SetValue(fDefaultValue); ResizeToPreferred(); }
NotificationView::NotificationView(NotificationWindow* win, notification_type type, const char* app, const char* title, const char* text, BMessage* details) : BView(BRect(0, 0, win->ViewWidth(), 1), "NotificationView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS), fParent(win), fType(type), fRunner(NULL), fProgress(0.0f), fMessageID(""), fDetails(details), fBitmap(NULL), fIsFirst(false), fIsLast(false) { BMessage iconMsg; if (fDetails->FindMessage("icon", &iconMsg) == B_OK) fBitmap = new BBitmap(&iconMsg); if (!fBitmap) _LoadIcon(); const char* messageID = NULL; if (fDetails->FindString("messageID", &messageID) == B_OK) fMessageID = messageID; if (fDetails->FindFloat("progress", &fProgress) != B_OK) fProgress = 0.0f; // Progress is between 0 and 1 if (fProgress < 0.0f) fProgress = 0.0f; if (fProgress > 1.0f) fProgress = 1.0f; SetText(app, title, text); ResizeToPreferred(); switch (type) { case B_IMPORTANT_NOTIFICATION: SetViewColor(255, 255, 255); SetLowColor(255, 255, 255); break; case B_ERROR_NOTIFICATION: SetViewColor(ui_color(B_FAILURE_COLOR)); SetLowColor(ui_color(B_FAILURE_COLOR)); break; default: SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); break; } }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ void BmCheckControl::_InitSize() { ResizeToPreferred(); float width, height; GetPreferredSize(&width, &height); // if there's no label, just use the space required for the checkbox if (Label() == NULL) ct_mpm = minimax(17, int(height), 17, int(height)); else ct_mpm = minimax(int(width), int(height), 1E5, int(height)); }
// --------------------------------------------------------------- // Constructor // // Sets up the view settings // // Preconditions: // // Parameters: // // Postconditions: // // Returns: // --------------------------------------------------------------- SGIView::SGIView(const BRect &frame, const char *name, uint32 resize, uint32 flags, TranslatorSettings *settings) : BView(frame, name, resize, flags), fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); BPopUpMenu* menu = new BPopUpMenu("pick compression"); uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION); // create the menu items with the various compression methods add_menu_item(menu, SGI_COMP_NONE, "None", currentCompression); // menu->AddSeparatorItem(); add_menu_item(menu, SGI_COMP_RLE, "RLE", currentCompression); // DON'T turn this on, it's so slow that I didn't wait long enough // the one time I tested this. So I don't know if the code even works. // Supposedly, this would look for an already written scanline, and // modify the scanline tables so that the current row is not written // at all... // add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression); BRect menuFrame = Bounds(); menuFrame.bottom = menuFrame.top + menu->Bounds().Height(); fCompressionMF = new BMenuField(menuFrame, "compression", "Use compression:", menu, true/*, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP*/); if (fCompressionMF->MenuBar()) fCompressionMF->MenuBar()->ResizeToPreferred(); fCompressionMF->ResizeToPreferred(); // figure out where the text ends font_height fh; be_bold_font->GetHeight(&fh); float xbold, ybold; xbold = fh.descent + 1; ybold = fh.ascent + fh.descent * 2 + fh.leading; font_height plainh; be_plain_font->GetHeight(&plainh); float yplain; yplain = plainh.ascent + plainh.descent * 2 + plainh.leading; // position the menu field below all the text we draw in Draw() BPoint textOffset(0.0, yplain * 2 + ybold); fCompressionMF->MoveTo(textOffset); AddChild(fCompressionMF); ResizeToPreferred(); }
void TTimeView::AttachedToWindow() { fCurrentTime = time(NULL); SetFont(be_plain_font); if (Parent()) { fParent = Parent(); SetViewColor(Parent()->ViewColor()); } else SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); CalculateTextPlacement(); ResizeToPreferred(); }
void TTimeView::Update() { fLocale = *BLocale::Default(); GetCurrentTime(); GetCurrentDate(); SetToolTip(fCurrentDateStr); CalculateTextPlacement(); ResizeToPreferred(); if (fParent != NULL) fParent->Invalidate(); }
void StatusView::_SetupNewFreqString() { if (fCurrentFrequency) { fFreqString = ColorStepView::CreateFrequencyString( fCurrentFrequency->frequency); } else fFreqString = "? MHz"; ResizeToPreferred(); if (fDragger) { BRect bounds = Bounds(); fDragger->MoveTo(bounds.right - 7, bounds.bottom - 7); } }
void BSlider::SetLimitLabels(const char *minLabel, const char *maxLabel) { free(fMinLimitLabel); fMinLimitLabel = minLabel ? strdup(minLabel) : NULL; free(fMaxLimitLabel); fMaxLimitLabel = maxLabel ? strdup(maxLabel) : NULL; InvalidateLayout(); // TODO: This is for backwards compatibility and should // probably be removed when breaking binary compatiblity. // Applications like our own Mouse rely on this behavior. if ((Flags() & B_SUPPORTS_LAYOUT) == 0) ResizeToPreferred(); Invalidate(); }
void BSlider::AttachedToWindow() { ResizeToPreferred(); #if USE_OFF_SCREEN_VIEW BRect bounds(Bounds()); if (!fOffScreenView) { fOffScreenView = new BView(bounds, "", B_FOLLOW_ALL, B_WILL_DRAW); BFont font; GetFont(&font); fOffScreenView->SetFont(&font); } if (!fOffScreenBits) { fOffScreenBits = new BBitmap(bounds, B_RGBA32, true, false); if (fOffScreenBits && fOffScreenView) fOffScreenBits->AddChild(fOffScreenView); } else if (fOffScreenView) fOffScreenBits->AddChild(fOffScreenView); #endif // USE_OFF_SCREEN_VIEW BControl::AttachedToWindow(); BView* view = OffscreenView(); if (view && view->LockLooper()) { view->SetViewColor(B_TRANSPARENT_COLOR); view->SetLowColor(LowColor()); view->UnlockLooper(); } int32 value = Value(); SetValue(value); // makes sure the value is within valid bounds _SetLocationForValue(Value()); // makes sure the location is correct UpdateTextChanged(); }
status_t KeyRequestWindow::RequestKey(const BString& keyringName, BMessage& keyMessage) { fRequestView->SetUp(keyringName); ResizeToPreferred(); CenterOnScreen(); Show(); while (acquire_sem(fDoneSem) == B_INTERRUPTED) ; status_t result = fResult; if (result == B_OK) result = fRequestView->Complete(keyMessage); LockLooper(); Quit(); return result; }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ void BmTextControl::InitSize( const char* label, int32 fixedTextLen, int32 minTextLen, BmMenuControllerBase* popup) { ResizeToPreferred(); BRect b = Bounds(); float divPos = 0; if (label) divPos = StringWidth(label) + (mLabelIsMenu ? 27 : 3); inherited::SetDivider( divPos); BFont font; mTextView->GetFont( &font); if (fixedTextLen) { mTextView->SetMaxBytes( fixedTextLen); float width = divPos + font.StringWidth("W")*float(fixedTextLen); ct_mpm = minimax( int(width), int(b.Height()+4), int(width), int(b.Height()+4)); } else { if (minTextLen) ct_mpm = minimax( int(divPos + font.StringWidth("W")*float(minTextLen)), int(b.Height()+4), 100000, int(b.Height()+4)); else ct_mpm = minimax( int(divPos + font.StringWidth("W")*10), int(b.Height()+4), 100000, int(b.Height()+4)); } if (mLabelIsMenu) { float width, height; GetPreferredSize( &width, &height); // if (!popup) // popup = new BmMenuControllerBase( label, true, false); if (BeamOnDano) mMenuField = new BMenuField( BRect( 2,2,Divider(),height), NULL, label, popup, true, B_FOLLOW_NONE, B_WILL_DRAW); else mMenuField = new BMenuField( BRect( 2,0,Divider(),height), NULL, label, popup, true, B_FOLLOW_NONE, B_WILL_DRAW); mMenuField->SetDivider( 0); AddChild( mMenuField); } SetModificationMessage( new BMessage(BM_TEXTFIELD_MODIFIED)); }
XSAboutWindow::XSAboutWindow() : BAF::Window(BRect(), "About...", B_TITLED_WINDOW, BAF::WIN_AUTO_SIZE | BAF::WIN_ESCAPE_TO_CLOSE) { BAF::Button *button; BAF::Box *topview = new BAF::Box(NULL, B_PLAIN_BORDER, -1, new BAF::VGroup(B_ALIGN_CENTER, new BAF::StringView("Wild Flower Cross Stitch"), new BAF::StringView("Version 1.0"), new BAF::UrlView("http://uscoffings.net", "http://uscoffings.net"), button = new BAF::Button("OK", BAF_MSG_BUTTON_OKAY), 0 ) ); SetDefaultButton(button); AddChild(dynamic_cast<BView *>(topview)); ResizeToPreferred(); BAF::Layout::PosCenterOnScreen(this); Show(); }
PrintingProgressWindow::PrintingProgressWindow(const char *text, BRect aRect, int32 pages) : BWindow(aRect, B_TRANSLATE("BePDF printing"), B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_NOT_CLOSABLE|B_AUTO_UPDATE_SIZE_LIMITS) { mPages = pages; mPrintedPages = 0; mState = OK; BString s(B_TRANSLATE("BePDF printing document: ")); s << text; // center window BStringView *stringView = new BStringView("stringView", s.String()); mPageString = new BStringView("mPageString", B_TRANSLATE("Page:")); mProgress = new BStatusBar("mProgress"); mProgress->SetMaxValue(1); mStop = new BButton("mStop", B_TRANSLATE("Stop"), new BMessage('STOP')); mAbort = new BButton("mAbort", B_TRANSLATE("Abort"), new BMessage('ABRT')); BLayoutBuilder::Group<>(this, B_HORIZONTAL) .SetInsets(B_USE_WINDOW_INSETS) .AddGroup(B_VERTICAL) .Add(stringView) .Add(mPageString) .Add(mProgress) .End() .AddGroup(B_VERTICAL) .Add(mStop) .Add(mAbort) .End(); ResizeToPreferred(); CenterOnScreen(); SetDefaultButton(mStop); Show(); }
IMAPConfig::IMAPConfig(BMessage *archive) : BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER #ifdef USE_SSL | B_MAIL_PROTOCOL_HAS_FLAVORS #endif ) { #ifdef USE_SSL AddFlavor("No encryption"); AddFlavor("SSL"); #endif SetTo(archive); ((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON); ((BControl *)(FindView("leave_mail_remote")))->Hide(); BRect frame = FindView("delete_remote_when_local")->Frame(); ((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true); ((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25); frame.right -= 10;// FindView("pass")->Frame().right; /*frame.top += 10; frame.bottom += 10;*/ BTextControl *folder = new BTextControl(frame,"root","Top mailbox folder: ","",NULL); folder->SetDivider(be_plain_font->StringWidth("Top mailbox folder: ")); if (archive->HasString("root")) folder->SetText(archive->FindString("root")); AddChild(folder); ResizeToPreferred(); }
WonderBrushView::WonderBrushView(const BRect &frame, const char *name, uint32 resize, uint32 flags, TranslatorSettings *settings) : BView(frame, name, resize, flags), fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); // figure out where the text ends font_height fh; be_bold_font->GetHeight(&fh); float xbold, ybold; xbold = fh.descent + 1; ybold = fh.ascent + fh.descent * 2 + fh.leading; font_height plainh; be_plain_font->GetHeight(&plainh); float yplain; yplain = plainh.ascent + plainh.descent * 2 + plainh.leading; ResizeToPreferred(); }
void HTextControl::ResizeLocalized(const char* label) { SetLabel(label); SetDivider(label == NULL ? -2 : StringWidth(label)+StringWidth("n")); ResizeToPreferred(); } /* HTextControl::ResizeLocalized */
void AppWindow::InitWindow() { PRINT(("AppWindow::InitWindow()\n")); fOpenPanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_FILE_NODE, true, NULL, NULL, false, true); m_menu_bar = new BMenuBar("menuBar"); //create file menu m_file_menu = new BMenu(FILE_MENU); m_open_menu_item = new BMenuItem(OPEN_ITEM, new BMessage(MSG_FILE_OPEN), OPEN_SHORTCUT); m_about_menu_item = new BMenuItem(ABOUT_ITEM, new BMessage(B_ABOUT_REQUESTED)); m_quit_menu_item = new BMenuItem(QUIT_ITEM, new BMessage(B_QUIT_REQUESTED), QUIT_SHORTCUT); m_file_menu->AddItem(m_open_menu_item); m_file_menu->AddSeparatorItem(); m_file_menu->AddItem(m_about_menu_item); m_file_menu->AddSeparatorItem(); m_file_menu->AddItem(m_quit_menu_item); m_menu_bar->AddItem(m_file_menu); //create edit menu m_edit_menu = new BMenu(EDIT_MENU); m_cut_menu_item = new BMenuItem(CUT_ITEM, new BMessage(MSG_EDIT_CUT), CUT_ITEM_SHORTCUT); m_copy_menu_item = new BMenuItem(COPY_ITEM, new BMessage(MSG_EDIT_COPY), COPY_ITEM_SHORTCUT); m_paste_menu_item = new BMenuItem(PASTE_ITEM, new BMessage(MSG_EDIT_PASTE), PASTE_ITEM_SHORTCUT); m_select_all_menu_item = new BMenuItem(SELECT_ALL_ITEM, new BMessage(MSG_SELECT_ALL), SELECT_ALL_SHORTCUT); m_select_all_unsupported_menu_item = new BMenuItem(SELECT_ALL_UNSUPPORTED_ITEM, new BMessage(MSG_SELECT_ALL_UNSUPPORTED), SELECT_ALL_SHORTCUT, B_SHIFT_KEY); m_first_file_menu_item = new BMenuItem(FIRST_FILE_ITEM, new BMessage(MSG_FIRST_FILE), FIRST_FILE_SHORTCUT); m_last_file_menu_item = new BMenuItem(LAST_FILE_ITEM, new BMessage(MSG_LAST_FILE), LAST_FILE_SHORTCUT); m_previous_file_menu_item = new BMenuItem(PREVIOUS_FILE_ITEM, new BMessage(MSG_PREVIOUS_FILE), PREVIOUS_FILE_SHORTCUT); m_next_file_menu_item = new BMenuItem(NEXT_FILE_ITEM, new BMessage(MSG_NEXT_FILE), NEXT_FILE_SHORTCUT); m_reset_menu_item = new BMenuItem(RESET_ITEM, new BMessage(MSG_RESET), RESET_SHORTCUT); m_clear_list_menu_item = new BMenuItem(CLEAR_LIST_ITEM, new BMessage(MSG_CLEAR_LIST), CLEAR_LIST_SHORTCUT); m_edit_menu->AddItem(m_cut_menu_item); m_edit_menu->AddItem(m_copy_menu_item); m_edit_menu->AddItem(m_paste_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_select_all_menu_item); m_edit_menu->AddItem(m_select_all_unsupported_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_first_file_menu_item); m_edit_menu->AddItem(m_last_file_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_previous_file_menu_item); m_edit_menu->AddItem(m_next_file_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_reset_menu_item); m_edit_menu->AddItem(m_clear_list_menu_item); m_menu_bar->AddItem(m_edit_menu); //create mode menu m_mode_menu = new BMenu(MODE_MENU); m_mode_menu->AddItem(new BMenuItem(PREVIOUS_MODE_NAME, new BMessage(MSG_PREVIOUS_MODE), PREVIOUS_MODE_SHORTCUT)); m_mode_menu->AddItem(new BMenuItem(NEXT_MODE_NAME, new BMessage(MSG_NEXT_MODE), NEXT_MODE_SHORTCUT)); m_mode_menu->AddSeparatorItem(); m_mode_menu->AddItem(new BMenuItem(EDITOR_MODE_NAME, new BMessage(MSG_EDITOR_MODE), '1')); m_mode_menu->AddItem(new BMenuItem(TA_MODE_NAME, new BMessage(MSG_TA_MODE), '2')); m_mode_menu->AddItem(new BMenuItem(NA_MODE_NAME, new BMessage(MSG_NA_MODE), '3')); m_mode_menu->AddSeparatorItem(); m_mode_menu->AddItem(new BMenuItem(MPEG_MODE_NAME, new BMessage(MSG_MPEG_MODE), '4')); #ifdef _TTE_ m_mode_menu->AddSeparatorItem(); m_mode_menu->AddItem(new BMenuItem(TT_INFO_MODE_NAME, new BMessage(MSG_TT_INFO_MODE), '5')); #endif m_menu_bar->AddItem(m_mode_menu); m_help_menu = new BMenu(HELP_MENU); m_readme_item = new BMenuItem(README_ITEM, new BMessage(MSG_README)); m_changelog_item = new BMenuItem(CHANGELOG_ITEM, new BMessage(MSG_CHANGELOG)); m_help_menu->AddItem(m_readme_item); m_help_menu->AddItem(m_changelog_item); m_menu_bar->AddItem(m_help_menu); // create options menu /* m_options_menu = new BMenu(OPTIONS_MENU); m_beep_menu_item = new BMenuItem(BEEP_ON_UNSUPPORTED, new BMessage(MSG_BEEP_ON_UNSUPPORTED)); m_options_menu->AddItem(m_beep_menu_item); m_menu_bar->AddItem(m_options_menu); */ // add m_app_view below menu bar SetKeyMenuBar(m_menu_bar); m_app_view = new AppView(); BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(m_menu_bar) .Add(m_app_view); ResizeToPreferred(); }
/*! Tweaks the layout according to the configuration. */ void BAlert::_Prepare() { // Must have at least one button if (CountButtons() == 0) debugger("BAlerts must have at least one button."); float fontFactor = be_plain_font->Size() / 11.0f; if (fIconView->Bitmap() == NULL) fIconView->SetBitmap(_CreateTypeIcon()); if (fButtonWidth == B_WIDTH_AS_USUAL) { float usualWidth = kButtonUsualWidth * fontFactor; for (int32 index = 0; index < CountButtons(); index++) { BButton* button = ButtonAt(index); if (button->MinSize().width < usualWidth) button->SetExplicitSize(BSize(usualWidth, B_SIZE_UNSET)); } } else if (fButtonWidth == B_WIDTH_FROM_WIDEST) { // Get width of widest label float maxWidth = 0; for (int32 index = 0; index < CountButtons(); index++) { BButton* button = ButtonAt(index); float width; button->GetPreferredSize(&width, NULL); if (width > maxWidth) maxWidth = width; } for (int32 index = 0; index < CountButtons(); index++) { BButton* button = ButtonAt(index); button->SetExplicitSize(BSize(maxWidth, B_SIZE_UNSET)); } } if (fButtonSpacing == B_OFFSET_SPACING && CountButtons() > 1) { // Insert some strut fButtonLayout->AddItem(1, BSpaceLayoutItem::CreateHorizontalStrut( kButtonOffsetSpacing * fontFactor)); } // Position the alert so that it is centered vertically but offset a bit // horizontally in the parent window's frame or, if unavailable, the // screen frame. float minWindowWidth = (fButtonSpacing == B_OFFSET_SPACING ? kWindowOffsetMinWidth : kWindowMinWidth) * fontFactor; GetLayout()->SetExplicitMinSize(BSize(minWindowWidth, B_SIZE_UNSET)); ResizeToPreferred(); // Return early if we've already been moved... if (Frame().left != 0 && Frame().right != 0) return; // otherwise center ourselves on-top of parent window/screen BWindow* parent = dynamic_cast<BWindow*>(BLooper::LooperForThread( find_thread(NULL))); const BRect frame = parent != NULL ? parent->Frame() : BScreen(this).Frame(); MoveTo(static_cast<BWindow*>(this)->AlertPosition(frame)); // Hidden by BAlert::AlertPosition() }
void InfoWin::Update(uint32 which) { printf("InfoWin::Update(0x%08lx)\n", which); fLabelsView->SetText(""); fContentsView->SetText(""); fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue); fLabelsView->Insert(" "); fContentsView->SetFontAndColor(be_plain_font, B_FONT_ALL); // fContentsView->Insert(""); if (!fController->Lock()) return; fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kRed); status_t err; // video track format information if ((which & INFO_VIDEO) && fController->VideoTrackCount() > 0) { fLabelsView->Insert("Video\n\n\n"); BString s; media_format format; media_raw_video_format videoFormat; err = fController->GetEncodedVideoFormat(&format); if (err < B_OK) { s << "(" << strerror(err) << ")\n"; } else if (format.type == B_MEDIA_ENCODED_VIDEO) { videoFormat = format.u.encoded_video.output; media_codec_info mci; err = fController->GetVideoCodecInfo(&mci); if (err < B_OK) { s << "Haiku Media Kit: " << strerror(err); if (format.user_data_type == B_CODEC_TYPE_INFO) { s << (char *)format.user_data << " (not supported)"; } } else s << mci.pretty_name; //<< "(" << mci.short_name << ")"; } else if (format.type == B_MEDIA_RAW_VIDEO) { videoFormat = format.u.raw_video; s << "raw video"; } else s << "unknown format"; s << "\n"; s << format.Width() << " x " << format.Height(); // encoded has output as 1st field... s << ", " << videoFormat.field_rate << " fps"; s << "\n\n"; fContentsView->Insert(s.String()); } // audio track format information if ((which & INFO_AUDIO) && fController->AudioTrackCount() > 0) { fLabelsView->Insert("Audio\n\n\n"); BString s; media_format format; media_raw_audio_format audioFormat; err = fController->GetEncodedAudioFormat(&format); //string_for_format(format, buf, sizeof(buf)); //printf("%s\n", buf); if (err < 0) { s << "(" << strerror(err) << ")\n"; } else if (format.type == B_MEDIA_ENCODED_AUDIO) { audioFormat = format.u.encoded_audio.output; media_codec_info mci; err = fController->GetAudioCodecInfo(&mci); if (err < 0) { s << "Haiku Media Kit: " << strerror(err); if (format.user_data_type == B_CODEC_TYPE_INFO) { s << (char *)format.user_data << " (not supported)"; } } else s << mci.pretty_name; //<< "(" << mci.short_name << ")"; } else if (format.type == B_MEDIA_RAW_AUDIO) { audioFormat = format.u.raw_audio; s << "raw audio"; } else s << "unknown format"; s << "\n"; uint32 bitsPerSample = 8 * (audioFormat.format & media_raw_audio_format::B_AUDIO_SIZE_MASK); uint32 channelCount = audioFormat.channel_count; float sr = audioFormat.frame_rate; if (bitsPerSample > 0) s << bitsPerSample << " Bit "; if (channelCount == 1) s << "Mono"; else if (channelCount == 2) s << "Stereo"; else s << channelCount << " Channels"; s << ", "; if (sr > 0.0) s << sr / 1000; else s << "??"; s<< " kHz"; s << "\n\n"; fContentsView->Insert(s.String()); } // statistics if ((which & INFO_STATS) && fController->HasFile()) { fLabelsView->Insert("Duration\n"); BString s; bigtime_t d = fController->TimeDuration(); bigtime_t v; //s << d << "µs; "; d /= 1000; v = d / (3600 * 1000); d = d % (3600 * 1000); bool hours = v > 0; if (hours) s << v << ":"; v = d / (60 * 1000); d = d % (60 * 1000); s << v << ":"; v = d / 1000; s << v; if (hours) s << " h"; else s << " min"; s << "\n"; fContentsView->Insert(s.String()); // TODO: demux/video/audio/... perfs (Kb/s) fLabelsView->Insert("Display mode\n"); if (fController->IsOverlayActive()) fContentsView->Insert("Overlay\n"); else fContentsView->Insert("DrawBitmap\n"); fLabelsView->Insert("\n"); fContentsView->Insert("\n"); } if (which & INFO_TRANSPORT) { // Transport protocol info (file, http, rtsp, ...) } if (which & INFO_FILE) { bool iconSet = false; if (fController->HasFile()) { const PlaylistItem* item = fController->Item(); iconSet = fInfoView->SetIcon(item) == B_OK; media_file_format fileFormat; BString s; if (fController->GetFileFormatInfo(&fileFormat) == B_OK) { fLabelsView->Insert("Container\n"); s << fileFormat.pretty_name; s << "\n"; fContentsView->Insert(s.String()); if (!iconSet) iconSet = fInfoView->SetIcon(fileFormat.mime_type) == B_OK; } else fContentsView->Insert("\n"); fLabelsView->Insert("Location\n"); if (fController->GetLocation(&s) < B_OK) s = "<unknown>"; s << "\n"; fContentsView->Insert(s.String()); if (fController->GetName(&s) < B_OK) s = "<unnamed media>"; fFilenameView->SetText(s.String()); } else { fFilenameView->SetText("<no media>"); } if (!iconSet) fInfoView->SetGenericIcon(); } if ((which & INFO_COPYRIGHT) && fController->HasFile()) { BString s; if (fController->GetCopyright(&s) == B_OK && s.Length() > 0) { fLabelsView->Insert("Copyright\n\n"); s << "\n\n"; fContentsView->Insert(s.String()); } } fController->Unlock(); ResizeToPreferred(); }
void HStringView::ResizeLocalized(const char* label) { SetText(label); ResizeToPreferred(); } /* HStringView::ResizeLocalized */
void HButton::ResizeLocalized(const char* label) { SetLabel(label); ResizeToPreferred(); } /* HButton::ResizeLocalized */
void HCheckBox::ResizeLocalized(const char* label) { SetLabel(label); ResizeToPreferred(); } /* HCheckBox::ResizeLocalized */
void HTextView::ResizeLocalized() { ResizeToPreferred(); } /* HTextView::ResizeLocalized */