本文整理汇总了C++中BRect::Height方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::Height方法的具体用法?C++ BRect::Height怎么用?C++ BRect::Height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::Height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Menu
void
BSeparatorItem::Draw()
{
BMenu *menu = Menu();
if (menu == NULL)
return;
BRect bounds = Frame();
rgb_color oldColor = menu->HighColor();
rgb_color lowColor = menu->LowColor();
const float startTop = bounds.top + (floor(bounds.Height())) / 2;
menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop),
BPoint(bounds.right - 1.0f, startTop));
menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
BPoint(bounds.right - 1.0f, startTop + 1.0f));
menu->SetHighColor(oldColor);
}
示例2: truncatedString
// SimpleItem::DrawItem
void
SimpleItem::Draw(BView *owner, BRect frame, uint32 flags)
{
DrawBackground(owner, frame, flags);
// label
owner->SetHighColor( 0, 0, 0, 255 );
font_height fh;
owner->GetFontHeight( &fh );
const char* text = Text();
BString truncatedString( text );
owner->TruncateString( &truncatedString, B_TRUNCATE_MIDDLE,
frame.Width() - TEXT_OFFSET - 4.0 );
float height = frame.Height();
float textHeight = fh.ascent + fh.descent;
BPoint textPoint;
textPoint.x = frame.left + TEXT_OFFSET;
textPoint.y = frame.top
+ ceilf(height / 2.0 - textHeight / 2.0
+ fh.ascent);
owner->DrawString(truncatedString.String(), textPoint);
}
示例3: point
void
TDateEdit::DrawSection(uint32 index, BRect bounds, bool hasFocus)
{
if (fFieldPositions == NULL || index * 2 + 1 >= (uint32)fFieldPosCount)
return;
SetLowColor(ViewColor());
if (hasFocus)
SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
BString field;
fText.CopyCharsInto(field, fFieldPositions[index * 2],
fFieldPositions[index * 2 + 1] - fFieldPositions[index * 2]);
BPoint point(bounds.LeftBottom());
point.y -= bounds.Height() / 2.0 - 6.0;
point.x += (bounds.Width() - StringWidth(field)) / 2;
SetHighColor(0, 0, 0, 255);
FillRect(bounds, B_SOLID_LOW);
DrawString(field, point);
}
示例4: HandleSorterResize
void TElementsSorter::HandleSorterResize(BMessage* theMessage)
{
// Extract sorter ID from message
int16 theID;
if (theMessage->FindInt16("ID", &theID) == B_OK) {
// Get sorter from list
TSorterContainer* theSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt(theID) );
if (theSorter) {
// Get drag point
BPoint dragPt;
if (theMessage->FindPoint("ResizePoint", &dragPt) == B_OK) {
// Get current size
BRect sizeRect = theSorter->Bounds();
// Resize
sizeRect.right = dragPt.x;
// Check for width violation
if (sizeRect.Width() > kMinSorterWidth) {
// Resize the sorter based on drag
theSorter->ResizeTo(sizeRect.Width(), sizeRect.Height());
// Now scoot the other views over
for (int32 index = theID+1; index < fSorterList->CountItems(); index++ ) {
TSorterContainer* moveSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt(index) );
if (moveSorter) {
// Get previous item in list for MoveTo coordinates
TSorterContainer* prevSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt(index-1) );
if (prevSorter) {
moveSorter->MoveTo( prevSorter->Frame().right+1, moveSorter->Frame().top);
}
}
}
}
}
}
}
}
示例5: Bounds
/**
* @brief コンテナのスクロールバーを調整します。
*/
void TextDiffView::DiffPaneView::adjustScrollBar()
{
if (NULL == scroller)
{
return;
}
BRect bounds = Bounds();
// 縦スクロールバーについての調整
BScrollBar* verticalBar = scroller->ScrollBar(B_VERTICAL);
if (NULL != verticalBar)
{
float boundsHeight = bounds.Height() + 1;
float height = getDataHeight();
if (height < boundsHeight)
{
height = boundsHeight;
}
verticalBar->SetRange(0, height - boundsHeight);
verticalBar->SetProportion(boundsHeight / height);
BFont font;
GetFont(&font);
font_height fh;
font.GetHeight(&fh);
float lineHeight = static_cast<float>(ceil(fh.ascent + fh.descent + fh.leading));
verticalBar->SetSteps(lineHeight, boundsHeight);
}
// 横スクロールバーについての調整
BScrollBar* horizontalBar = scroller->ScrollBar(B_HORIZONTAL);
if (NULL != horizontalBar)
{
float boundsWidth = bounds.Width() + 1;
horizontalBar->SetRange(0, HORIZONTAL_SCROLL_MAX);
horizontalBar->SetProportion(boundsWidth / (HORIZONTAL_SCROLL_MAX + boundsWidth));
horizontalBar->SetSteps(HORIZONTAL_SCROLL_MINSTEPS, boundsWidth);
}
}
示例6: CopyBitmap
void ClientView::CopyBitmap(BBitmap *bmp1, BRect frame, const BBitmap *bmp2)
{
char *bits1=(char *)bmp1->Bits();
const char *bits2=(char *)bmp2->Bits();
int32 bpr1=bmp1->BytesPerRow();
int32 bpr2=bmp2->BytesPerRow();
int32 height=int32(frame.Height()+1);
int32 offset=int32(frame.left)*4+int32(frame.top)*bpr1;
for(int32 i=0; i<height; i++)
memcpy(&(bits1[offset+i*bpr1]), &(bits2[i*bpr2]), bpr2);
// for(int32 i=0; i<height; i++)
// {
// bits1[offset+i*bpr1+2]=255;
// bits1[offset+i*bpr1+bpr2-2]=255;
// }
// for(int32 j=2; j<bpr2-2; j+=4)
// {
// bits1[offset+j]=255;
// bits1[offset+(height-1)*bpr1+j]=255;
// }
}
示例7:
StatusView::StatusView(
BRect frame,
RouteAppNodeManager *manager,
BScrollBar *scrollBar)
: BStringView(frame, "StatusView", "", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
B_FRAME_EVENTS | B_WILL_DRAW),
m_scrollBar(scrollBar),
m_icon(0),
m_opacity(1.0),
m_clock(0),
m_dragging(false),
m_backBitmap(0),
m_backView(0),
m_dirty(true),
m_manager(manager) {
D_ALLOC(("StatusView::StatusView()\n"));
SetViewColor(B_TRANSPARENT_COLOR);
SetFont(be_plain_font);
allocBackBitmap(frame.Width(), frame.Height());
}
示例8: screen
void
RouteWindow::_constrainToScreen()
{
D_INTERNAL(("RouteWindow::_constrainToScreen()\n"));
BScreen screen(this);
BRect screenRect = screen.Frame();
BRect windowRect = Frame();
// if the window is outside the screen rect
// move it to the default position
if (!screenRect.Intersects(windowRect)) {
windowRect.OffsetTo(screenRect.LeftTop());
MoveTo(windowRect.LeftTop());
windowRect = Frame();
}
// if the window is larger than the screen rect
// resize it to fit at each side
if (!screenRect.Contains(windowRect)) {
if (windowRect.left < screenRect.left) {
windowRect.left = screenRect.left + 5.0;
MoveTo(windowRect.LeftTop());
windowRect = Frame();
}
if (windowRect.top < screenRect.top) {
windowRect.top = screenRect.top + 5.0;
MoveTo(windowRect.LeftTop());
windowRect = Frame();
}
if (windowRect.right > screenRect.right) {
windowRect.right = screenRect.right - 5.0;
}
if (windowRect.bottom > screenRect.bottom) {
windowRect.bottom = screenRect.bottom - 5.0;
}
ResizeTo(windowRect.Width(), windowRect.Height());
}
}
示例9: viewRect
void
PeakView::_DrawBitmap()
{
SetHighColor(0, 0, 0);
BRect bitmapFrame = _BackBitmapFrame();
BRect bitmapRect = fBackBitmap->Bounds();
bitmapRect.bottom = bitmapRect.top;
float channelHeight = (bitmapFrame.Height() + 1) / fChannelCount;
for (uint32 i = 0; i < fChannelCount; i++) {
BRect viewRect(bitmapFrame);
viewRect.bottom = viewRect.top;
viewRect.top += floorf(i * channelHeight + 0.5);
if (i < fChannelCount - 1) {
viewRect.bottom += floorf((i + 1) * channelHeight + 0.5) - 2;
StrokeLine(BPoint(viewRect.left, viewRect.bottom + 1),
BPoint(viewRect.right, viewRect.bottom + 1));
} else
viewRect.bottom += floorf((i + 1) * channelHeight + 0.5) - 1;
DrawBitmapAsync(fBackBitmap, bitmapRect, viewRect);
bitmapRect.OffsetBy(0, 1);
}
}
示例10: if
void
DataView::MakeVisible(int32 position)
{
if (position < 0 || position > int32(fDataSize) - 1)
return;
BRect frame = SelectionFrame(fFocus, position, position);
BRect bounds = Bounds();
if (bounds.Contains(frame))
return;
// special case the first and the last line and column, so that
// we can take kHorizontalSpace & kVerticalSpace into account
if ((position % kBlockSize) == 0)
frame.left -= kHorizontalSpace;
else if ((position % kBlockSize) == kBlockSize - 1)
frame.right += kHorizontalSpace;
if (position < int32(kBlockSize))
frame.top -= kVerticalSpace;
else if (position > int32(fDataSize - kBlockSize))
frame.bottom += kVerticalSpace;
// compute the scroll point
BPoint point = bounds.LeftTop();
if (bounds.left > frame.left)
point.x = frame.left;
else if (bounds.right < frame.right)
point.x = frame.right - bounds.Width();
if (bounds.top > frame.top)
point.y = frame.top;
else if (bounds.bottom < frame.bottom)
point.y = frame.bottom - bounds.Height();
ScrollTo(point);
}
示例11: Bounds
void
BBox::_DrawPlain(BRect labelBox)
{
BRect rect = Bounds();
rect.top += TopBorderOffset();
float lightTint;
float shadowTint;
if (be_control_look != NULL) {
lightTint = B_LIGHTEN_1_TINT;
shadowTint = B_DARKEN_1_TINT;
} else {
lightTint = B_LIGHTEN_MAX_TINT;
shadowTint = B_DARKEN_3_TINT;
}
if (rect.Height() == 0.0 || rect.Width() == 0.0) {
// used as separator
rgb_color shadow = tint_color(ViewColor(), B_DARKEN_2_TINT);
SetHighColor(shadow);
StrokeLine(rect.LeftTop(),rect.RightBottom());
} else {
// used as box
rgb_color light = tint_color(ViewColor(), lightTint);
rgb_color shadow = tint_color(ViewColor(), shadowTint);
BeginLineArray(4);
AddLine(BPoint(rect.left, rect.bottom),
BPoint(rect.left, rect.top), light);
AddLine(BPoint(rect.left + 1.0f, rect.top),
BPoint(rect.right, rect.top), light);
AddLine(BPoint(rect.left + 1.0f, rect.bottom),
BPoint(rect.right, rect.bottom), shadow);
AddLine(BPoint(rect.right, rect.bottom - 1.0f),
BPoint(rect.right, rect.top + 1.0f), shadow);
EndLineArray();
}
}
示例12: r
void
ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
{
BScreen screen;
if (!screen.IsValid())
return;
BRect r(pbitmap->Bounds());
float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
B_H_SCROLL_BAR_HEIGHT;
BRect frame = screen.Frame();
const float windowBorder = 5;
// dimensions so that window does not reach outside of screen
float maxWidth = frame.Width() + 1 - windowBorder - Frame().left;
float maxHeight = frame.Height() + 1 - windowBorder - Frame().top;
// We have to check size limits manually, otherwise
// menu bar will be too short for small images.
float minW, maxW, minH, maxH;
GetSizeLimits(&minW, &maxW, &minH, &maxH);
if (maxWidth > maxW)
maxWidth = maxW;
if (maxHeight > maxH)
maxHeight = maxH;
if (width < minW)
width = minW;
if (height < minH)
height = minH;
if (width > maxWidth)
width = maxWidth;
if (height > maxHeight)
height = maxHeight;
ResizeTo(width, height);
}
示例13: iconBounds
void
WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
bool isFirst, bool isLast, bool isFront)
{
if (fController->CloseButtonsAvailable())
_DrawCloseButton(owner, frame, updateRect, isFirst, isLast, isFront);
if (fIcon) {
BRect iconBounds(0, 0, kIconSize - 1, kIconSize - 1);
// clip to icon bounds, if they are smaller
if (iconBounds.Contains(fIcon->Bounds()))
iconBounds = fIcon->Bounds();
else {
// Try to scale down the icon by an even factor so the
// final size is between 14 and 18 pixel size. If this fails,
// the icon will simply be displayed at 18x18.
float scale = 2;
while ((fIcon->Bounds().Width() + 1) / scale > kIconSize)
scale *= 2;
if ((fIcon->Bounds().Width() + 1) / scale >= kIconSize - 4
&& (fIcon->Bounds().Height() + 1) / scale >= kIconSize - 4
&& (fIcon->Bounds().Height() + 1) / scale <= kIconSize) {
iconBounds.right = (fIcon->Bounds().Width() + 1) / scale - 1;
iconBounds.bottom = (fIcon->Bounds().Height() + 1) / scale - 1;
}
}
BPoint iconPos(frame.left + kIconInset - 1,
frame.top + floorf((frame.Height() - iconBounds.Height()) / 2));
iconBounds.OffsetTo(iconPos);
owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
owner->DrawBitmap(fIcon, fIcon->Bounds(), iconBounds,
B_FILTER_BITMAP_BILINEAR);
owner->SetDrawingMode(B_OP_COPY);
frame.left = frame.left + kIconSize + kIconInset * 2;
}
TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, isFront);
}
示例14: SetPreviewBitmap
void ThresholdManipulator::SetPreviewBitmap(BBitmap *bm)
{
if (preview_bitmap != bm) {
delete copy_of_the_preview_bitmap;
if (bm != NULL) {
preview_bitmap = bm;
copy_of_the_preview_bitmap = DuplicateBitmap(bm,0);
}
else {
preview_bitmap = NULL;
copy_of_the_preview_bitmap = NULL;
}
}
if (preview_bitmap != NULL) {
system_info info;
get_system_info(&info);
double speed = info.cpu_count * info.cpu_clock_speed;
// Let's select a resolution that can handle all the pixels at least
// 10 times in a second while assuming that one pixel calculation takes
// about 50 CPU cycles.
speed = speed / (10*50);
BRect bounds = preview_bitmap->Bounds();
float num_pixels = (bounds.Width()+1) * (bounds.Height() + 1);
lowest_available_quality = 1;
while ((num_pixels/lowest_available_quality/lowest_available_quality) > speed)
lowest_available_quality *= 2;
lowest_available_quality = min_c(lowest_available_quality,16);
highest_available_quality = max_c(lowest_available_quality/2,1);
}
else {
lowest_available_quality = 1;
highest_available_quality = 1;
}
last_calculated_resolution = lowest_available_quality;
}
示例15: MessageReceived
void GPView::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case bmsgBitmapDirty:
{
// m_bitmap->Lock();
// m_bitmap->display();
// m_bitmap->Unlock();
// printf("view (dirty) displaying %d commands\n",m_bitmap->ncommands);
Draw(Bounds());
break;
};
case bmsgBitmapResize:
{
BRect r;
msg->FindRect("rect",&r);
m_bitmap->ResizeTo(r.Width(),r.Height(),0);
break;
};
case bmsgNewCmd:
{
char *cmd = NULL;
int32 i, num;
num = msg->FindInt32("numcmds");
m_bitmap->addCommands(msg,num);
// printf("view (new cmds) displaying %d commands\n",m_bitmap->ncommands);
Draw(Bounds());
break;
}
case bmsgClrCmd:
{
m_bitmap->clearCommands();
break;
}
default:
BView::MessageReceived(msg);
};
};