InfoWin::InfoWin(BPoint leftTop, Controller* controller) : BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1, leftTop.y + 300), NAME, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE), fController(controller), fControllerObserver(new ControllerObserver(this, OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES)) { BRect rect = Bounds(); // accomodate for big fonts float div = max_c(2 * 32, be_plain_font->StringWidth("Display Mode") + 10); fInfoView = new InfoView(rect, "background", div); fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR)); AddChild(fInfoView); BFont bigFont(be_plain_font); bigFont.SetSize(bigFont.Size() + 6); font_height fh; bigFont.GetHeight(&fh); fFilenameView = new BStringView( BRect(div + 10, 20, rect.right - 10, 20 + fh.ascent + 5), "filename", ""); AddChild(fFilenameView); fFilenameView->SetFont(&bigFont); fFilenameView->SetViewColor(fInfoView->ViewColor()); fFilenameView->SetLowColor(fInfoView->ViewColor()); #ifdef B_BEOS_VERSION_DANO /* maybe we should support that as well ? */ fFilenameView->SetTruncation(B_TRUNCATE_END); #endif rect.top = BASE_HEIGHT; BRect lr(rect); BRect cr(rect); lr.right = div - 1; cr.left = div + 1; BRect tr; tr = lr.OffsetToCopy(0, 0).InsetByCopy(5, 1); fLabelsView = new BTextView(lr, "labels", tr, B_FOLLOW_BOTTOM); fLabelsView->SetViewColor(kGreen); fLabelsView->SetAlignment(B_ALIGN_RIGHT); fLabelsView->SetWordWrap(false); AddChild(fLabelsView); tr = cr.OffsetToCopy(0, 0).InsetByCopy(10, 1); fContentsView = new BTextView(cr, "contents", tr, B_FOLLOW_BOTTOM); fContentsView->SetWordWrap(false); AddChild(fContentsView); fLabelsView->MakeSelectable(); fContentsView->MakeSelectable(); fController->AddListener(fControllerObserver); Update(); Show(); }
InfoWin::InfoWin(BPoint leftTop, Controller* controller) : BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1, leftTop.y + 300), B_TRANSLATE("File info"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE), fController(controller), fControllerObserver(new ControllerObserver(this, OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES)) { fIconView = new IconView("background", B_LARGE_ICON); fFilenameView = _CreateInfo("filename"); BFont bigFont(be_plain_font); bigFont.SetSize(bigFont.Size() * 1.5f); fFilenameView->SetFont(&bigFont); // Create info views BStringView* containerLabel = _CreateLabel("containerLabel", B_TRANSLATE("Container")); fContainerInfo = _CreateInfo("container"); fVideoSeparator = _CreateSeparator(); fVideoLabel = _CreateLabel("videoLabel", B_TRANSLATE("Video")); fVideoFormatInfo = _CreateInfo("videoFormat"); fVideoConfigInfo = _CreateInfo("videoConfig"); fDisplayModeLabel = _CreateLabel("displayModeLabel", B_TRANSLATE("Display mode")); fDisplayModeInfo = _CreateInfo("displayMode"); fAudioSeparator = _CreateSeparator(); fAudioLabel = _CreateLabel("audioLabel", B_TRANSLATE("Audio")); fAudioFormatInfo = _CreateInfo("audioFormat"); fAudioConfigInfo = _CreateInfo("audioConfig"); BStringView* durationLabel = _CreateLabel("durationLabel", B_TRANSLATE("Duration")); fDurationInfo = _CreateInfo("duration"); BStringView* locationLabel = _CreateLabel("locationLabel", B_TRANSLATE("Location")); fLocationInfo = _CreateInfo("location"); fCopyrightSeparator = _CreateSeparator(); fCopyrightLabel = _CreateLabel("copyrightLabel", B_TRANSLATE("Copyright")); fCopyrightInfo = _CreateInfo("copyright"); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL) .Add(fIconView, 0) .Add(fFilenameView, 1) .End() .AddGrid(2, 13) .Add(containerLabel, 0, 0) .Add(fContainerInfo, 1, 0) .Add(fVideoSeparator, 0, 1) .Add(fVideoLabel, 0, 2) .Add(fVideoFormatInfo, 1, 2) .Add(fVideoConfigInfo, 1, 3) .Add(fDisplayModeLabel, 0, 4) .Add(fDisplayModeInfo, 1, 4) .Add(fAudioSeparator, 0, 5) .Add(fAudioLabel, 0, 6) .Add(fAudioFormatInfo, 1, 6) .Add(fAudioConfigInfo, 1, 7) .Add(_CreateSeparator(), 0, 8) .Add(durationLabel, 0, 9) .Add(fDurationInfo, 1, 9) .Add(_CreateSeparator(), 0, 10) .Add(locationLabel, 0, 11) .Add(fLocationInfo, 1, 11) .Add(fCopyrightSeparator, 0, 12) .Add(fCopyrightLabel, 0, 12) .Add(fCopyrightInfo, 1, 12) .SetColumnWeight(0, 0) .SetColumnWeight(1, 1) .SetSpacing(B_USE_DEFAULT_SPACING, 0) .SetExplicitMinSize(BSize(MIN_WIDTH, B_SIZE_UNSET)); fController->AddListener(fControllerObserver); Update(); UpdateSizeLimits(); // Move window on screen if needed BScreen screen(this); if (screen.Frame().bottom < Frame().bottom) MoveBy(0, screen.Frame().bottom - Frame().bottom); if (screen.Frame().right < Frame().right) MoveBy(0, screen.Frame().right - Frame().right); Show(); }