// --------------------------------------------------------------- // Draw // // Draws information about the SlideShowConfigTranslator to this view. // // Preconditions: // // Parameters: area, not used // // Postconditions: // // Returns: // --------------------------------------------------------------- void SlideShowConfigView::Draw(BRect area) { SetFont(be_bold_font); font_height fh; GetFontHeight(&fh); float xbold, ybold; xbold = fh.descent + 1; ybold = fh.ascent + fh.descent * 2 + fh.leading; char title[] = "SlideShow Screen Saver"; DrawString(title, BPoint(xbold, ybold)); SetFont(be_plain_font); font_height plainh; GetFontHeight(&plainh); float yplain; yplain = plainh.ascent + plainh.descent * 2 + plainh.leading; char writtenby[] = "Written by Michael Wilber"; DrawString(writtenby, BPoint(xbold, yplain * 1 + ybold)); // Draw current folder BString strFolder; fSettings->GetString(SAVER_SETTING_DIRECTORY, strFolder); strFolder.Prepend("Image folder: "); DrawString(strFolder.String(), BPoint(10, yplain * 9 + ybold)); }
// Draw void ListLabelView::Draw(BRect updateRect) { rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lightenMax = tint_color(base, B_LIGHTEN_MAX_TINT); rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT); BRect r(Bounds()); BeginLineArray(3); AddLine(BPoint(r.left, r.bottom - 1), BPoint(r.left, r.top), lightenMax); AddLine(BPoint(r.right, r.top), BPoint(r.right, r.bottom), darken2); AddLine(BPoint(r.right - 1, r.bottom), BPoint(r.left, r.bottom), darken2); EndLineArray(); r.left += 1; r.right -= 1; r.bottom -= 1; SetLowColor(base); FillRect(r & updateRect, B_SOLID_LOW); font_height fh; GetFontHeight(&fh); SetHighColor(0, 0, 0, 255); BPoint labelPos; labelPos.x = 5; labelPos.y = r.top + floorf((r.Height() + fh.ascent) / 2.0); DrawString(fLabel.String(), labelPos); }
void MonitorView::Draw(BRect updateRect) { rgb_color darkColor = {160, 160, 160, 255}; rgb_color blackColor = {0, 0, 0, 255}; rgb_color redColor = {228, 0, 0, 255}; rgb_color whiteColor = {255, 255, 255, 255}; BRect outerRect = _MonitorBounds(); SetHighColor(fBackgroundColor); FillRect(updateRect); SetDrawingMode(B_OP_OVER); // frame & background SetHighColor(darkColor); FillRoundRect(outerRect, 3.0, 3.0); SetHighColor(blackColor); StrokeRoundRect(outerRect, 3.0, 3.0); SetHighColor(fDesktopColor); BRect innerRect(outerRect.InsetByCopy(4, 4)); FillRoundRect(innerRect, 2.0, 2.0); SetHighColor(blackColor); StrokeRoundRect(innerRect, 2.0, 2.0); SetDrawingMode(B_OP_COPY); // power light SetHighColor(redColor); BPoint powerPos(outerRect.left + 5, outerRect.bottom - 2); StrokeLine(powerPos, BPoint(powerPos.x + 2, powerPos.y)); // DPI if (fDPI == 0) return; font_height fontHeight; GetFontHeight(&fontHeight); float height = ceilf(fontHeight.ascent + fontHeight.descent); char text[64]; snprintf(text, sizeof(text), B_TRANSLATE("%ld dpi"), fDPI); float width = StringWidth(text); if (width > innerRect.Width() || height > innerRect.Height()) return; SetLowColor(fDesktopColor); SetHighColor(whiteColor); DrawString(text, BPoint(innerRect.left + (innerRect.Width() - width) / 2, innerRect.top + fontHeight.ascent + (innerRect.Height() - height) / 2)); }
BSize BButton::_ValidatePreferredSize() { if (fPreferredSize.width < 0) { // width float width = 20.0f + (float)ceil(StringWidth(Label())); if (width < 75.0f) width = 75.0f; if (fDrawAsDefault) width += 6.0f; fPreferredSize.width = width; // height font_height fontHeight; GetFontHeight(&fontHeight); fPreferredSize.height = ceilf((fontHeight.ascent + fontHeight.descent) * 1.8) + (fDrawAsDefault ? 6.0f : 0); ResetLayoutInvalidation(); } return fPreferredSize; }
//Kris: //This is a new function which duplicates the older "yellow info boxes" that //are common throughout the editor. This draws the yellow box with the indentation //look. void DrawEditorInfoBox( UINT16 *str, UINT32 uiFont, UINT16 x, UINT16 y, UINT16 w, UINT16 h ) { UINT16 usFillColorDark, usFillColorLight, usFillColorBack; UINT16 x2, y2; UINT16 usStrWidth; x2 = x + w; y2 = y + h; usFillColorDark = Get16BPPColor(FROMRGB(24, 61, 81)); usFillColorLight = Get16BPPColor(FROMRGB(136, 138, 135)); usFillColorBack = Get16BPPColor(FROMRGB(250, 240, 188)); ColorFillVideoSurfaceArea(ButtonDestBuffer, x, y, x2, y2, usFillColorDark); ColorFillVideoSurfaceArea(ButtonDestBuffer, x + 1, y + 1, x2, y2, usFillColorLight); ColorFillVideoSurfaceArea(ButtonDestBuffer, x + 1, y + 1, x2 - 1, y2 - 1, usFillColorBack); usStrWidth = StringPixLength( str, uiFont ); if( usStrWidth > w ) { //the string is too long, so use the wrapped method y += 1; DisplayWrappedString( x, y, w, 2, uiFont, FONT_BLACK, str, FONT_BLACK, TRUE, CENTER_JUSTIFIED ); return; } //center the string vertically and horizontally. SetFont( uiFont ); SetFontForeground( FONT_BLACK ); SetFontShadow( FONT_BLACK ); x += (w - (UINT16)StringPixLength( str, uiFont )) / 2; y += (h - (UINT16)GetFontHeight( uiFont)) / 2; mprintf( x, y, L"%s", str ); InvalidateRegion( x, y, x2, y2 ); }
void BRadioButton::Draw(BRect updateRect) { // its size depends on the text height font_height fontHeight; GetFontHeight(&fontHeight); rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); uint32 flags = be_control_look->Flags(this); if (fOutlined) flags |= BControlLook::B_CLICKED; BRect knobRect(_KnobFrame(fontHeight)); BRect rect(knobRect); be_control_look->DrawRadioButton(this, rect, updateRect, base, flags); BRect labelRect(Bounds()); labelRect.left = knobRect.right + 1 + be_control_look->DefaultLabelSpacing(); const BBitmap* icon = IconBitmap( B_INACTIVE_ICON_BITMAP | (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP)); be_control_look->DrawLabel(this, Label(), icon, labelRect, updateRect, base, flags); }
void BRadioButton::GetPreferredSize(float* _width, float* _height) { font_height fontHeight; GetFontHeight(&fontHeight); BRect rect(_KnobFrame(fontHeight)); float width = rect.right + rect.left; float height = rect.bottom + rect.top; const BBitmap* icon = IconBitmap(B_INACTIVE_ICON_BITMAP); if (icon != NULL) { width += be_control_look->DefaultLabelSpacing() + icon->Bounds().Width() + 1; height = std::max(height, icon->Bounds().Height()); } if (const char* label = Label()) { width += be_control_look->DefaultLabelSpacing() + ceilf(StringWidth(label)); height = std::max(height, ceilf(6.0f + fontHeight.ascent + fontHeight.descent)); } if (_width != NULL) *_width = width; if (_height != NULL) *_height = height; }
void BIconButton::GetPreferredSize(float* width, float* height) { float minWidth = 0.0f; float minHeight = 0.0f; if (IsValid()) { minWidth += fNormalBitmap->Bounds().IntegerWidth() + 1.0f; minHeight += fNormalBitmap->Bounds().IntegerHeight() + 1.0f; } const float kMinSpace = 15.0f; if (minWidth < kMinSpace) minWidth = kMinSpace; if (minHeight < kMinSpace) minHeight = kMinSpace; float hPadding = max_c(6.0f, ceilf(minHeight / 4.0f)); float vPadding = max_c(6.0f, ceilf(minWidth / 4.0f)); if (Label() != NULL && Label()[0] != '\0') { font_height fh; GetFontHeight(&fh); minHeight += ceilf(fh.ascent + fh.descent) + vPadding; minWidth += StringWidth(Label()) + vPadding; } if (width) *width = minWidth + hPadding; if (height) *height = minHeight + vPadding; }
void BStatusBar::_SetTextData(BString& text, const char* source, const BString& combineWith, bool rightAligned) { if (source == NULL) source = ""; // If there were no changes, we don't have to do anything if (text == source) return; bool oldHasText = _HasText(); text = source; BString newString; if (rightAligned) newString << text << combineWith; else newString << combineWith << text; if (oldHasText != _HasText()) InvalidateLayout(); font_height fontHeight; GetFontHeight(&fontHeight); // Invalidate(BRect(position, 0, position + invalidateWidth, // ceilf(fontHeight.ascent) + ceilf(fontHeight.descent))); // TODO: redrawing the entire area takes care of the edge case // where the left side string changes because of truncation and // part of it needs to be redrawn as well. Invalidate(BRect(0, 0, Bounds().right, ceilf(fontHeight.ascent) + ceilf(fontHeight.descent))); }
void StaticString :: GetPreferredSize( float * w , float * h ) { font_height fh ; GetFontHeight( &fh ) ; *h = fh.ascent + fh.descent + fh.leading ; *w = StringWidth( Text() ) * 1.1 ; }
//......................................................... BOOL Cls_OnAdvInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) //WM_INITDIALOG handler { TCHAR fontName[80], charSet[64]; LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam; LoadString(hInstance, IDS_TAB_FONT, fontName, SIZEOF_IN_CHAR(fontName)); LoadString(hInstance, IDS_CHAR_SET, charSet, SIZEOF_IN_CHAR(charSet)); hFont = CreateFont(GetFontHeight(hInstance, hwnd, IDS_FONT_HEIGHT), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, CharSetFromString((LPTSTR)(const TCHAR *)charSet), OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, TMPF_TRUETYPE | FF_DONTCARE, (const TCHAR *)fontName); hPeripheral = (HPERIPHERAL)psp->lParam; hAdvanced = hwnd; OnInitAdvancedDialog(); return TRUE; }
/////////////////////////////////////////////////////////////////////////////// // SetFont void CXColorStatic::SetFont(LPCTSTR lpszFaceName, int nPointSize, BOOL bRedraw /*= TRUE*/) { // null face name is ok - we will use current font LOGFONT lf; memset(&lf, 0, sizeof(lf)); if (lpszFaceName == NULL) { CFont *pFont = GetFont(); ASSERT(pFont); pFont->GetLogFont(&lf); } else { _tcsncpy(lf.lfFaceName, lpszFaceName, sizeof(lf.lfFaceName)/sizeof(TCHAR)-1); } m_nHeight = GetFontHeight(nPointSize); lf.lfHeight = m_nHeight; SetFont(&lf, bRedraw); }
void ListedTextItems::Repaint( const WidgetPainter &painter ) { int entry_h = GetEntryHeight(); int font_h = GetFontHeight(); int shy = ( entry_h - font_h +1)/2; if (!_items.Empty()) { int shsel = (_shift<0)? (-_shift) : 0; int shtxt = (_shift<0)? 0: _shift; int i,n,y; bool be_always_dirty = false; for( i=0, n=_items.Size(), y=0; i<n; ++i ) { __Item k = _items[i]; _skins.Select(k._state); _skins.Paint( painter, Pos( shsel,y ), Rect(0,0,GetWidth(),entry_h)+Pos( shsel,y ) ); _fonts.Select(k._state); _fonts.Paint( painter, k._caption, Pos(shtxt, y+shy) ); be_always_dirty |= IsAlwaysDirty(); y += entry_h; } BeAlwaysDirty( be_always_dirty); } }
void BRadioButton::MouseDown(BPoint where) { if (!IsEnabled() || !QueryCurrentMouse(true, B_PRIMARY_MOUSE_BUTTON)) return; #if 0 font_height fontHeight; GetFontHeight(&fontHeight); float sHeight = fontHeight.ascent + fontHeight.descent; BRect rect = Frame().OffsetToSelf(B_ORIGIN); rect.InsetBy(5, (rect.Height() - sHeight) / 2); if (rect.IsValid() == false) return; rect.right = rect.left + rect.Height(); if (rect.Contains(where) == false) return; #endif if ((Flags() &B_NAVIGABLE) && !IsFocus()) MakeFocus(); // SetValue((Value() == B_CONTROL_ON) ?B_CONTROL_OFF :B_CONTROL_ON); if (Value() == B_CONTROL_ON) return; SetValue(B_CONTROL_ON); Invoke(); }
void SButton::GetContentPreferredSize(float *width, float *height) { if(!width && !height) return; float string_width = 0, string_height = 0; if(label) { string_width = StringWidth(label); font_height fheight; GetFontHeight(&fheight); string_height = fheight.ascent + fheight.descent + fheight.leading; } if(!bitmap) { if(width) *width = string_width; if(height) *height = string_height; } else { if(label) string_width += 3; if(width) *width = string_width + bitmap->Bounds().Width(); if(height) *height = MAX(string_height, bitmap->Bounds().Height()); } }
void DropDownBase::Init(UINT16 sX, UINT16 sY) { mfMouseRegionsCreated = FALSE; musStartX = sX; musStartY = sY; mSelectedEntry = min(mSelectedEntry, mEntryVector.size() - 1); mNumDisplayedEntries = min(DROPDOWN_REGIONS, mEntryVector.size() ); mFirstShownEntry = max(0, min(mFirstShownEntry, mEntryVector.size() - 1 - mNumDisplayedEntries)); musWidth = 0; UINT8 size = mEntryVector.size(); for( UINT8 i = 0; i < size; ++i) { musWidth = max(musWidth, StringPixLength ( mEntryVector[i].second, DEF_DROPDOWN_FONT )); } // account for a bit of space let and right musWidth += 2 * CITY_NAME_OFFSET; musUpArrowX = musStartX + musWidth; musUpArrowY = musStartY + 2; musFontHeight = GetFontHeight( DEF_DROPDOWN_FONT ); // does not work on init of static objects, as the fonts do not yet exist! }
MsgView::MsgView(const string& text, va_list list) : os::View(os::Rect(0,0,1,1), "MsgView", os::CF_FOLLOW_ALL) { const char* butName; uint i=0; while((butName = va_arg(list, const char*)) != NULL) { os::Button* button = new os::Button(os::Rect(0,0,1,1), butName, butName, new os::Message(i++)); buttons.push_back(button); AddChild(button); os::Point size = button->GetPreferredSize(false); if(size.x > buttonSize.x) { buttonSize.x = size.x; } if(size.y > buttonSize.y) { buttonSize.y = size.y; } } float width = (buttonSize.x + 5) * buttons.size(); int start = 0; for(i=0;i<=text.size();++i) { if(i==text.size() || text[i]=='\n') { std::string line(text, start, i-start); lines.push_back(line); float strLen = GetStringWidth(line.c_str())+20; if(strLen>width) { width=strLen; } start = i + 1; } } os::font_height fontHeight; GetFontHeight(&fontHeight); lineHeight = fontHeight.ascender + fontHeight.descender + fontHeight.line_gap; float height=lines.size()*lineHeight; height+=buttonSize.y + 30; float y=height - buttonSize.y - 5; float x=width - buttons.size() * (buttonSize.x + 5) - 5; for(i=0;i<buttons.size();++i) { buttons[i]->SetFrame(os::Rect(x, y, x+buttonSize.x-1, y+buttonSize.y-1)); x+=buttonSize.x+5; } minSize.x=width; minSize.y=height; }
void FolderPanel :: AttachedToWindow( void ) { BRect r ; if( Parent() ) r = Parent()->Frame() ; else r = Window()->Frame() ; font_height fh ; GetFontHeight( &fh ) ; r.top = 0 ; r.right = r.Width() ; r.left = 0 ; r.bottom = 3 * (fh.ascent + fh.descent + fh.leading ) ; MoveTo( 0,0 ) ; ResizeTo( r.right, r.bottom ) ; r.left = 25 ; r.right = r.right - r.left ; r.top = r.Height()/5 ; r.bottom = r.bottom - r.top ; fpFolderPU->MoveTo( r.left , r.top ) ; fpFolderPU->ResizeTo( r.Width() , r.Height() ) ; fpFolderPU->SetViewColor( ViewColor() ) ; fpFolderPU->SetLowColor( ViewColor() ) ; AddChild( fpFolderPU ) ; }
BTitleView::BTitleView(BPoseView* view) : BView("BTitleView", B_WILL_DRAW), fPoseView(view), fTitleList(10, true), fHorizontalResizeCursor(B_CURSOR_ID_RESIZE_EAST_WEST), fPreviouslyClickedColumnTitle(0), fPreviousLeftClickTime(0), fTrackingState(NULL) { SetHighUIColor(B_PANEL_BACKGROUND_COLOR); SetLowUIColor(B_PANEL_BACKGROUND_COLOR); #if APP_SERVER_CLEARS_BACKGROUND SetViewUIColor(B_PANEL_BACKGROUND_COLOR); #else SetViewColor(B_TRANSPARENT_COLOR); #endif BFont font(be_plain_font); font.SetSize(floorf(be_plain_font->Size() * 0.75f)); SetFont(&font); font_height height; GetFontHeight(&height); fPreferredHeight = ceilf(height.ascent + height.descent) + 2; Reset(); }
// -------------------------------------------------------------- CollapsableBox::CollapsableBox ( BRect frame, const char *name, const char *label, BMessage *msg, uint32 resize_mask, uint32 flags ) : BControl(frame, name, label, msg, resize_mask, flags | B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE | B_NAVIGABLE_JUMP) { m_pressing = false; font_height fh; GetFontHeight(&fh); float min_height = (float) ceil(6.0f + fh.ascent + fh.descent) + 2.0f; if (Bounds().Height() < min_height) ResizeTo(Bounds().Width(), min_height); m_collapsed_rect = BRect(0, 0, Bounds().Width(), min_height); m_expanded_rect = Bounds(); SetValue(B_CONTROL_ON); }
BRect BRadioButton::_KnobFrame() const { font_height fontHeight; GetFontHeight(&fontHeight); return _KnobFrame(fontHeight); }
void BStringView::Draw(BRect updateRect) { if (!fText) return; SetLowColor(ViewColor()); font_height fontHeight; GetFontHeight(&fontHeight); BRect bounds = Bounds(); float y = (bounds.top + bounds.bottom - ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2.0 + ceilf(fontHeight.ascent); float x; switch (fAlign) { case B_ALIGN_RIGHT: x = bounds.Width() - fStringWidth; break; case B_ALIGN_CENTER: x = (bounds.Width() - fStringWidth) / 2.0; break; default: x = 0.0; break; } DrawString(fText, BPoint(x, y)); }
//------------------------------------------------------------------------------ void BMenuField::DrawLabel(BRect bounds, BRect update) { font_height fh; GetFontHeight(&fh); if (Label()) { SetLowColor(ViewColor()); float y = (float)ceil(fh.ascent + fh.descent + fh.leading) + 2.0f; float x; switch (fAlign) { case B_ALIGN_RIGHT: x = fDivider - StringWidth(Label()) - 3.0f; break; case B_ALIGN_CENTER: x = fDivider - StringWidth(Label()) / 2.0f; break; default: x = 3.0f; break; } SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT)); DrawString(Label(), BPoint(x, y)); } }
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(); }
void TermView::_Init() { SetFont(be_fixed_font); font_height height; GetFontHeight(&height); fFontHeight = (int)(ceilf(height.ascent) + ceilf(height.descent) + ceilf(height.leading)); fFontWidth = (int)be_fixed_font->StringWidth("X"); fTerm = vterm_new(kDefaultHeight, kDefaultWidth); fTermScreen = vterm_obtain_screen(fTerm); vterm_screen_set_callbacks(fTermScreen, &sScreenCallbacks, this); vterm_screen_reset(fTermScreen, 1); vterm_parser_set_utf8(fTerm, 1); VTermScreenCell cell; VTermPos firstPos; firstPos.row = 0; firstPos.col = 0; _GetCell(firstPos, cell); rgb_color background; background.red = cell.bg.red; background.green = cell.bg.green; background.blue = cell.bg.blue; background.alpha = 255; SetViewColor(background); SetLineTerminator("\n"); }
void LiveTextControl::Draw(BRect updateRect) { SetHighColor( 0, 0, 0 ); font_height hoehe; GetFontHeight(&hoehe); DrawString(Label(), BPoint( 3.0, hoehe.ascent + 3.0 ) ); }
void CWndCommand::OnDraw( C2DRender* p2DRender ) { CWndListBox::OnDraw( p2DRender ); if( ::GetLanguage() == LANG_KOR ) { CPoint pt(3,3); int nFontHeight = GetFontHeight() + 3; pt.y -= ( nFontHeight ) * m_wndScrollBar.GetScrollPos(); LPLISTITEM pListItem; CRect rectHittest; CPoint point; CRect rect = GetWindowRect(); CString string; for(int i = 0; i < m_listItemArray.GetSize(); i++) { pListItem = (LPLISTITEM)m_listItemArray.GetAt(i); point = GetMousePoint(); rectHittest.SetRect( 0, pt.y - 3 , 0 + rect.Width(), pt.y + nFontHeight - 3 ); if( rectHittest.PtInRect( point ) ) { TextCmdFunc* pTextCmdFunc = (TextCmdFunc*)pListItem->m_dwData; CPoint point2 = point; ClientToScreen( &point2 ); ClientToScreen( &rectHittest ); string += pTextCmdFunc->m_pszDesc; g_toolTip.PutToolTip( i + 1000, string, rectHittest, point2, 3 ); break; } pt.y += nFontHeight; } } }
void _BMCMenuBar_::_Init() { SetFlags(Flags() | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE); SetBorder(B_BORDER_CONTENTS); float left, top, right, bottom; GetItemMargins(&left, &top, &right, &bottom); #if 0 // TODO: Better fix would be to make BMenuItem draw text properly // centered font_height fontHeight; GetFontHeight(&fontHeight); top = ceilf((Bounds().Height() - ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2) + 1; bottom = top - 1; #else // TODO: Fix content location properly. This is just a quick fix to // make the BMenuField label and the super-item of the BMenuBar // align vertically. top++; bottom--; #endif if (be_control_look != NULL) left = right = be_control_look->DefaultLabelSpacing(); SetItemMargins(left, top, right + fShowPopUpMarker ? kPopUpIndicatorWidth : 0, bottom); }
virtual void GetPreferredSize(float* width, float* height) { font_height fh; GetFontHeight(&fh); *height = fh.ascent+fh.descent + 2; *width = StringWidth(fTip.String()) + 2; }
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(); }