virtual void Draw(BRect updateRect) { BRegion region; region.Include(BRect(20, 20, 40, 40)); region.Include(BRect(30, 30, 80, 80)); ConstrainClippingRegion(®ion); SetHighColor(55, 255, 128, 255); FillRect(BRect(0, 0, 100, 100)); PushState(); SetOrigin(15, 15); ConstrainClippingRegion(®ion); SetHighColor(155, 255, 128, 255); FillRect(BRect(0, 0, 100, 100)); // ConstrainClippingRegion(NULL); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(80, 80)); SetHighColor(255, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(4, 2)); PopState(); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(4, 2), BPoint(82, 80)); }
// Draw void IconValueView::Draw(BRect updateRect) { BRect r; BRegion originalClippingRegion; GetClippingRegion(&originalClippingRegion); if (fIcon) { BRect b(Bounds()); // layout icon in the center r = fIcon->Bounds(); r.OffsetTo(floorf(b.left + b.Width() / 2.0 - r.Width() / 2.0), floorf(b.top + b.Height() / 2.0 - r.Height() / 2.0)); if (fIcon->ColorSpace() == B_RGBA32 || fIcon->ColorSpace() == B_RGBA32_BIG) { // set up transparent drawing and let // the base class draw the entire background SetHighColor(255, 255, 255, 255); SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); } else { // constrain clipping region to exclude bitmap BRegion region = originalClippingRegion; region.Exclude(r); ConstrainClippingRegion(®ion); } } // draw surrouing area (and possibly background for bitmap) PropertyEditorView::Draw(updateRect); ConstrainClippingRegion(&originalClippingRegion); if (fIcon) { DrawBitmap(fIcon, r.LeftTop()); } }
void LanguageListView::Draw(BRect updateRect) { BOutlineListView::Draw(updateRect); if (fDropIndex >= 0 && fDropTargetHighlightFrame.IsValid()) { // TODO: decide if drawing of a drop target indicator should be moved // into ControlLook BGradientLinear gradient; int step = fGlobalDropTargetIndicator ? 64 : 128; for (int i = 0; i < 256; i += step) gradient.AddColor(i % (step * 2) == 0 ? ViewColor() : ui_color(B_CONTROL_HIGHLIGHT_COLOR), i); gradient.AddColor(ViewColor(), 255); gradient.SetStart(fDropTargetHighlightFrame.LeftTop()); gradient.SetEnd(fDropTargetHighlightFrame.RightBottom()); if (fGlobalDropTargetIndicator) { BRegion region(fDropTargetHighlightFrame); region.Exclude(fDropTargetHighlightFrame.InsetByCopy(2.0, 2.0)); ConstrainClippingRegion(®ion); FillRect(fDropTargetHighlightFrame, gradient); ConstrainClippingRegion(NULL); } else FillRect(fDropTargetHighlightFrame, gradient); } }
void TPanelWindowView::Draw( BRect updateRect ) { BRegion Region; Region.Include(updateRect); ConstrainClippingRegion(&Region); float w, h; w = Bounds().Width(); h = Bounds().Height(); SetHighColor( fColor2 ); FillRect( BRect( 0, 0, h, h ) ); FillRect( BRect( w-h, 0, w, h ) ); FillRect( BRect( h/2, 0, w-(h/2), h/2) ); FillRect( BRect( 0, h/2, w, h ) ); SetHighColor( 196, 196, 176 ); FillRect( BRect( 0, h - 2, w, h ) ); fPanels.Lock(); for ( int i=0; i<fPanels.CountItems(); i++ ) { TInnerPanel *panel = fPanels.ItemAt(i); if ( panel->Frame().Intersects( updateRect ) ) { BRect rect( panel->Frame() ); if ( rect.left < updateRect.left ) rect.left = updateRect.left; if ( rect.right > updateRect.right ) rect.right = updateRect.right; if ( rect.top < updateRect.top ) rect.top = updateRect.top; if ( rect.bottom > updateRect.bottom ) rect.bottom = updateRect.bottom; panel->Draw(rect); } } fPanels.Unlock(); if ( fDrawOuterFrame ) { SetDrawingMode( B_OP_COPY ); SetHighColor( fOuterFrameColor ); BRect bounds = Bounds(); StrokeLine( bounds.LeftTop(), bounds.RightTop() ); StrokeLine( bounds.LeftTop(), bounds.LeftBottom() ); StrokeLine( bounds.RightTop(), bounds.RightBottom() ); } ConstrainClippingRegion(NULL); }
void MyView::RequestRedraw() { wind->Lock(); ConstrainClippingRegion(&fRedrawReg); PushState(); DrawSubTree(topLayer); PopState(); ConstrainClippingRegion(NULL); fRedrawReg.MakeEmpty(); wind->Unlock(); }
virtual void Draw(BRect updateRect) { BRegion region; region.Include(BRect(20, 20, 40, 40)); region.Include(BRect(30, 30, 80, 80)); ConstrainClippingRegion(®ion); SetHighColor(255, 0, 0, 255); FillRect(BRect(0, 0, 100, 100)); ConstrainClippingRegion(NULL); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(80, 80)); }
void MyView::DrawSubTree(Layer* lay) { //printf("======== %s =======\n", lay->Name()); // lay->Visible()->PrintToStream(); // lay->FullVisible()->PrintToStream(); for (Layer *child = lay->BottomChild(); child; child = lay->UpperSibling()) DrawSubTree(child); ConstrainClippingRegion(lay->Visible()); SetHighColor(lay->HighColor()); BRegion reg; lay->GetWantedRegion(reg); FillRect(reg.Frame()); Flush(); ConstrainClippingRegion(NULL); }
void ObjectView::Draw(BRect region) { BRect bnd = Bounds(); BRegion regi; regi.Include(region); ConstrainClippingRegion(®i); if (isSelected) { SetDrawingMode(B_OP_OVER); SetHighColor(black); FillRect(bnd, B_SOLID_HIGH); SetViewColor(black); SetHighColor(color); } else { SetDrawingMode(B_OP_OVER); SetHighColor(color); FillRect(bnd, B_SOLID_HIGH); SetViewColor(color); SetHighColor(black); } StrokeRect(bnd, B_SOLID_HIGH); if (label) { DrawString(label, labelPoint); if (container) { BRect cb = container->Bounds(); int d = (cb.right-cb.left-30); int llbl; for ( llbl = labelPoint.x + (1+(((int32)region.left) / d)) * d; llbl < region.right; llbl += d) { DrawString(label, BPoint(llbl,labelPoint.y)); } } } }
// Draw void ColorField::Draw(BRect updateRect) { if (fBitmapDirty && fBitmap != NULL) { _FillBitmap(fBitmap, fMode, fFixedValue, fOrientation); fBitmapDirty = false; } BRect bounds = Bounds(); // Frame if (fBorderStyle == B_FANCY_BORDER) { rgb_color color = LowColor(); be_control_look->DrawTextControlBorder(this, bounds, updateRect, color); BRegion region(bounds); ConstrainClippingRegion(®ion); } // Color field fill if (fBitmap != NULL) DrawBitmap(fBitmap, bounds.LeftTop()); else { SetHighColor(255, 0, 0); FillRect(bounds); } // Marker SetHighColor(0, 0, 0); StrokeEllipse(fMarkerPosition + bounds.LeftTop(), 5.0, 5.0); SetHighColor(255.0, 255.0, 255.0); StrokeEllipse(fMarkerPosition + bounds.LeftTop(), 4.0, 4.0); }
void NetListView::FrameResized(float width, float height) { BListView::FrameResized(width, height); //Ensure the bevel on the right is drawn properly if(width < oldWidth) oldWidth = width; PushState(); BRect invalRect(oldWidth, 0, oldWidth, height); ConvertFromParent(&invalRect); BRegion lineRegion(invalRect); ConstrainClippingRegion(&lineRegion); Draw(invalRect); oldWidth = width; PopState(); //Do word wrapping BFont curFont; GetFont(&curFont); float itemWidth = Bounds().Width(); float wrapWidth = (itemWidth - 6)/curFont.Size(); for(int itemNum = 0; itemNum < CountItems(); itemNum++) { NetListItem* item = (NetListItem*)(Items()[itemNum]); item->SetWidth(itemWidth); item->CalcWordWrap(wrapWidth); } //DoForEach(UpdateItem, (void*)this); Invalidate(); BListView::FrameResized(width, height); }
void BBox::Draw(BRect updateRect) { if (!IsVisible() || fBorder == B_NO_BORDER) return; e_theme_engine *theme = get_current_theme_engine(); if (theme == NULL || theme->get_border_margins == NULL || theme->draw_border == NULL) return; float l = 0, t = 0, r = 0, b = 0; theme->get_border_margins(theme, this, &l, &t, &r, &b, fBorder, PenSize()); BRect rect = Frame().OffsetToSelf(B_ORIGIN); if (!(fLabelView == NULL || fLabelView->Frame().Width() <= 0 || fLabelView->Frame().Height() < t)) rect.top += (fLabelView->Frame().Height() - t) / 2.f; PushState(); BRegion clipping(updateRect); if (!(fLabelView == NULL || fLabelView->Frame().IsValid() == false)) clipping.Exclude(fLabelView->Frame()); ConstrainClippingRegion(&clipping); if (clipping.CountRects() > 0) theme->draw_border(theme, this, rect, fBorder, PenSize()); PopState(); }
void AsyncRedraw(BRegion& region) { if (!LockLooper()) return; #if 0 ConstrainClippingRegion(®ion); FillRect(Bounds()); ConstrainClippingRegion(NULL); #else PushState(); ConstrainClippingRegion(®ion); FillRect(Bounds()); PopState(); #endif UnlockLooper(); }
void BBox::Draw(BRect updateRect) { _ValidateLayoutData(); PushState(); BRect labelBox = BRect(0, 0, 0, 0); if (fLabel != NULL) { labelBox = fLayoutData->label_box; BRegion update(updateRect); update.Exclude(labelBox); ConstrainClippingRegion(&update); } else if (fLabelView != NULL) labelBox = fLabelView->Bounds(); switch (fStyle) { case B_FANCY_BORDER: _DrawFancy(labelBox); break; case B_PLAIN_BORDER: _DrawPlain(labelBox); break; default: break; } if (fLabel) { ConstrainClippingRegion(NULL); font_height fontHeight; GetFontHeight(&fontHeight); SetHighColor(0, 0, 0); DrawString(fLabel, BPoint(10.0f, ceilf(fontHeight.ascent))); } PopState(); }
virtual void Draw(BRect updateRect) { BRegion region; region.Include(BRect(0, 0, 40, 40)); region.Include(BRect(30, 30, 140, 140)); ConstrainClippingRegion(®ion); SetHighColor(55, 255, 128, 255); FillRect(BRect(0, 0, 200, 200)); PushState(); SetOrigin(50, 10); ConstrainClippingRegion(®ion); SetHighColor(155, 55, 128, 255); FillRect(BRect(0, 0, 200, 200)); PopState(); SetHighColor(255, 0, 0); StrokeLine(Bounds().LeftTop(), Bounds().RightBottom()); }
void ClippingView::KeyDown(const char *bytes, int32 numBytes) { SetHighColor(0, 0, 255); FillRect(Bounds(), B_SOLID_HIGH); BRegion region(BRect(200, 100, 250, 150)); ConstrainClippingRegion(®ion); SetHighColor(255, 0, 0); FillRect(Bounds(), B_SOLID_HIGH); }
virtual void Draw(BRect updateRect) { BRegion region; region.Include(BRect(20, 20, 40, 40)); region.Include(BRect(30, 30, 140, 140)); ConstrainClippingRegion(®ion); SetHighColor(55, 255, 128, 255); FillRect(BRect(0, 0, 200, 200)); // NOTE: This exposes broken behavior of the ZETA // (probably R5 too) app_server. The new origin // is not taken into account PushState(); ConstrainClippingRegion(®ion); SetOrigin(15, 15); SetScale(1.5); SetHighColor(155, 255, 128, 255); FillRect(BRect(0, 0, 200, 200)); ConstrainClippingRegion(NULL); SetHighColor(0, 0, 0, 255); SetDrawingMode(B_OP_OVER); DrawString("Text is scaled.", BPoint(20, 30)); SetScale(1.2); DrawString("Text is scaled.", BPoint(20, 30)); StrokeLine(BPoint(2, 2), BPoint(80, 80)); PopState(); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(4, 2), BPoint(82, 80)); }
// Draw void FontValueView::Draw(BRect updateRect) { BRect b(Bounds()); // focus indication if (IsFocus()) { SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); StrokeRect(b); b.InsetBy(1.0, 1.0); BRegion clipping; clipping.Include(b); ConstrainClippingRegion(&clipping); b.left --; } // background FillRect(b, B_SOLID_LOW); rgb_color labelColor = LowColor(); if (fEnabled) labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT); else labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT); SetHighColor(labelColor); b.InsetBy(2.0, 1.0); float center = floorf(b.top + b.Height() / 2.0); BPoint arrow[3]; arrow[0] = BPoint(b.left, center - 3.0); arrow[1] = BPoint(b.left, center + 3.0); arrow[2] = BPoint(b.left + 3.0, center); FillPolygon(arrow, 3); b.left += 6.0; BFont font; GetFont(&font); font_height fh; font.GetHeight(&fh); BString truncated(fCurrentFont); font.TruncateString(&truncated, B_TRUNCATE_END, b.Width()); DrawString(truncated.String(), BPoint(b.left, floorf(center + fh.ascent / 2.0))); }
void BScrollBar::Draw(BRect updateRect) { if (!IsVisible()) return; e_theme_engine *theme = get_current_theme_engine(); if (theme == NULL || theme->draw_scrollbar == NULL) return; PushState(); ConstrainClippingRegion(updateRect); theme->draw_scrollbar(theme, this, Frame().OffsetToSelf(B_ORIGIN), fOrientation, fRangeMin, fRangeMax, fValue, (fTracking && fTrackingState > 0) ? fTrackingRegion.Contains(fMousePosition) : false, fMousePosition); PopState(); }
status_t BitmapDrawingEngine::SetSize(int32 newWidth, int32 newHeight) { if (fBitmap != NULL && newWidth > 0 && newHeight > 0 && fBitmap->Bounds().IntegerWidth() >= newWidth && fBitmap->Bounds().IntegerHeight() >= newHeight) { return B_OK; } SetHWInterface(NULL); if (fHWInterface) { fHWInterface->LockExclusiveAccess(); fHWInterface->Shutdown(); fHWInterface->UnlockExclusiveAccess(); delete fHWInterface; fHWInterface = NULL; } delete fBitmap; fBitmap = NULL; if (newWidth <= 0 || newHeight <= 0) return B_OK; fBitmap = new(std::nothrow) UtilityBitmap(BRect(0, 0, newWidth - 1, newHeight - 1), B_RGB32, 0); if (fBitmap == NULL) return B_NO_MEMORY; fHWInterface = new(std::nothrow) BitmapHWInterface(fBitmap); if (fHWInterface == NULL) return B_NO_MEMORY; status_t result = fHWInterface->Initialize(); if (result != B_OK) return result; // we have to set a valid clipping first fClipping.Set(fBitmap->Bounds()); ConstrainClippingRegion(&fClipping); SetHWInterface(fHWInterface); return B_OK; }
void BarberPole::Draw(BRect r) { if (fStyle == BARBERPOLE_FANCY) { BRect b(Bounds()); BRect b1; for (int i = 0; i < 4; i ++) { BRegion r(b); if (i != (4-1)) { b1 = b.InsetByCopy(1, 1); r.Exclude(b1); } ConstrainClippingRegion(&r); BView::SetHighColor(fHighColors[i]); BView::SetLowColor(fLowColors[i]); FillRect(b, fStripes); b.InsetBy(1, 1); } } else { BView::SetHighColor(fHighColors[4 - 1]); BView::SetLowColor(fLowColors[4 - 1]); FillRect(r, fStripes); } }
void TrackMenu::Draw(BRect update) { rgb_color dark = {20, 20, 20, 255}; rgb_color light = {200, 200, 200, 255}; BPoint pt1, pt2; // Draw the frame SetHighColor(dark); pt1.Set(0, 0); pt2 = Bounds().RightTop(); StrokeLine(pt1, pt2); pt2.Set(0, Bounds().bottom); StrokeLine(pt1, pt2); SetHighColor(255,255,255); pt1 = Bounds().RightBottom(); pt2.Set(Bounds().right, 1); StrokeLine(pt1, pt2); pt2.Set(1,Bounds().bottom); StrokeLine(pt1, pt2); // Draw the items BRect r(fItemRect); for (int32 i = 0; i < fCount; i++) { // Draw the item's frame if (i == fCurrentItem) SetHighColor(dark); else SetHighColor(light); pt1.Set(r.left, r.top); pt2.Set(r.right, r.top); StrokeLine(pt1, pt2); pt2.Set(r.left, r.bottom); StrokeLine(pt1, pt2); if (i == fCurrentItem) { SetHighColor(light); pt1.Set(r.right, r.bottom); pt2.Set(r.right, r.top + 1); StrokeLine(pt1, pt2); pt2.Set(r.left + 1, r.bottom); StrokeLine(pt1, pt2); SetHighColor(light); FillRect(r.InsetByCopy(1, 1)); SetHighColor(dark); } else if (i == fCount - 1) { SetHighColor(light); pt1.Set(r.right, r.bottom); pt2.Set(r.right, r.top + 1); StrokeLine(pt1, pt2); } // Draw the label, center justified BString label; label << (i + 1); BPoint labelpt; labelpt.x = r.left + (r.Width() - StringWidth(label.String())) / 2 + 2; labelpt.y = r.bottom - (r.Height() - fFontHeight + 4) / 2; if (i == fCurrentItem) { SetHighColor(dark); SetLowColor(light); } else { SetHighColor(light); SetLowColor(dark); } DrawString(label.String(), labelpt); // Setup for next iteration r.OffsetBy(r.Width() + 1, 0); if (r.left > Bounds().right - 2) { ConstrainClippingRegion(NULL); break; } if (r.right > Bounds().right - 2) { r.right = Bounds().right - 2; BRegion reg(r); ConstrainClippingRegion(®); } } }
void ETextEditable::Draw(ERect updateRect) { if(!IsVisible()) return; ERect rect = Frame().OffsetToSelf(E_ORIGIN); rect.left += fMargins.left; rect.top += fMargins.top; rect.right -= fMargins.right; rect.bottom -= fMargins.bottom; if(!rect.IsValid()) return; ERegion clipping; GetClippingRegion(&clipping); if(clipping.CountRects() > 0) clipping &= (rect & updateRect); else clipping = (rect & updateRect); if(clipping.CountRects() <= 0) return; e_rgb_color bkColor = e_ui_color(E_DOCUMENT_BACKGROUND_COLOR); e_rgb_color fgColor = e_ui_color(E_DOCUMENT_TEXT_COLOR); if(!IsEnabled()) { bkColor.disable(ViewColor()); fgColor.disable(ViewColor()); } if(!IsFocusChanging()) { PushState(); ConstrainClippingRegion(&clipping); SetDrawingMode(E_OP_COPY); SetPenSize(0); SetHighColor(bkColor); FillRect(rect & updateRect, E_SOLID_HIGH); PopState(); } EFont font; e_font_height fontHeight; GetFont(&font); font.GetHeight(&fontHeight); if(fCount > 0 && !IsFocusChanging()) { PushState(); ConstrainClippingRegion(&clipping); float x = 0, y = 0; if(GetCharLocation(0, &x, &y, &font)) { SetDrawingMode(E_OP_COPY); SetPenSize(0); SetHighColor(fgColor); SetLowColor(bkColor); _DrawString(fText, EPoint(x, y)); if(IsEnabled() && IsSelected()) { char *selectedText = DuplicateText(fSelectStart, fSelectEnd); if(selectedText != NULL) { x = 0; y = 0; if(GetCharLocation(fSelectStart, &x, &y, &font)) { DrawSelectedBackground(updateRect); SetLowColor(e_ui_color(E_DOCUMENT_HIGHLIGHT_COLOR)); _DrawString(selectedText, EPoint(x, y)); } free(selectedText); } } } PopState(); } if(IsEnabled() && IsEditable() && (IsFocus() || IsFocusChanging())) { PushState(); ConstrainClippingRegion(&clipping); DrawCursor(); PopState(); } if((IsFocus() || IsFocusChanging()) && Window()->IsActivate() && IsEnabled() && (Flags() & E_NAVIGABLE)) { e_rgb_color color = e_ui_color(E_NAVIGATION_BASE_COLOR); if(IsFocusChanging() && !IsFocus()) color = e_ui_color(E_DOCUMENT_BACKGROUND_COLOR); PushState(); ConstrainClippingRegion(&clipping); SetDrawingMode(E_OP_COPY); SetPenSize(0); SetHighColor(color); StrokeRect(rect, E_SOLID_HIGH); PopState(); } }
void CLVColumnLabelView::Draw(BRect update_rect) { BRect ViewBounds = Bounds(); //Draw each column label in turn float ColumnBegin = 0.0; float ColumnEnd = -1.0; bool MergeWithLeft = false; int32 NumberOfColumns = fDisplayList->CountItems(); BPoint Start,Stop; for(int32 ColumnDraw = 0; ColumnDraw < NumberOfColumns; ColumnDraw++) { CLVColumn* ThisColumn = (CLVColumn*)fDisplayList->ItemAt(ColumnDraw); if(ThisColumn->IsShown()) { //Figure out where this column is ColumnBegin = ThisColumn->fColumnBegin; ColumnEnd = ThisColumn->fColumnEnd; //Start by figuring out if this column will merge with a shown column to the right bool MergeWithRight = false; if(ThisColumn->fFlags & CLV_MERGE_WITH_RIGHT) { for(int32 ColumnCounter = ColumnDraw+1; ColumnCounter < NumberOfColumns; ColumnCounter++) { CLVColumn* NextColumn = (CLVColumn*)fDisplayList->ItemAt(ColumnCounter); if(NextColumn->IsShown()) { //The next column is shown MergeWithRight = true; break; } else if(!(NextColumn->fFlags & CLV_MERGE_WITH_RIGHT)) //The next column is not shown and doesn't pass on the merge break; } } if(update_rect.Intersects(BRect(ColumnBegin,ViewBounds.top,ColumnEnd, ViewBounds.bottom))) { //Need to draw this column BeginLineArray(4); //Top line Start.Set(ColumnBegin,ViewBounds.top); Stop.Set(ColumnEnd-1.0,ViewBounds.top); if(MergeWithRight && !(ThisColumn == fColumnClicked && fColumnResizing)) Stop.x = ColumnEnd; AddLine(Start,Stop,BeHighlight); //Left line if(!MergeWithLeft) AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0), BPoint(ColumnBegin,ViewBounds.bottom),BeHighlight); //Bottom line Start.Set(ColumnBegin+1.0,ViewBounds.bottom); if(MergeWithLeft) Start.x = ColumnBegin; Stop.Set(ColumnEnd-1.0,ViewBounds.bottom); if(MergeWithRight && !(ThisColumn == fColumnClicked && fColumnResizing)) Stop.x = ColumnEnd; AddLine(Start,Stop,BeShadow); //Right line if(ThisColumn == fColumnClicked && fColumnResizing) AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom), BeFocusBlue); else if(!MergeWithRight) AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom), BeShadow); EndLineArray(); //Add the label //Limit the clipping region to the interior of the box BRect TextRect(ColumnBegin+1.0,ViewBounds.top+1.0,ColumnEnd-1.0, ViewBounds.bottom-1.0); BRegion TextRegion; TextRegion.Include(TextRect); ConstrainClippingRegion(&TextRegion); bool focus; bool sort_key; if(ThisColumn == fColumnClicked && !fColumnResizing) focus = true; else focus = false; if(fParent->fSortKeyList.HasItem(ThisColumn) && ThisColumn->fSortMode != NoSort) sort_key = true; else sort_key = false; ThisColumn->DrawColumnHeader(this,TextRect,sort_key,focus,fFontAscent); //Restore the clipping region ConstrainClippingRegion(NULL); } //Set MergeWithLeft flag for the next column to the appropriate state MergeWithLeft = MergeWithRight; } } //Add highlight and shadow to the region after the columns if necessary if(ColumnEnd < ViewBounds.right) { ColumnBegin = ColumnEnd+1.0; if(update_rect.Intersects(BRect(ColumnEnd+1.0,ViewBounds.top,ViewBounds.right, ViewBounds.bottom))) { BeginLineArray(3); //Top line AddLine(BPoint(ColumnBegin,ViewBounds.top),BPoint(ViewBounds.right,ViewBounds.top), BeHighlight); //Left line AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0),BPoint(ColumnBegin,ViewBounds.bottom), BeHighlight); //Bottom line Start.Set(ColumnBegin+1.0,ViewBounds.bottom); if(MergeWithLeft) Start.x = ColumnBegin; Stop.Set(ViewBounds.right,ViewBounds.bottom); AddLine(Start,Stop,BeShadow); EndLineArray(); } } //Draw the dragging box if necessary if(fColumnClicked && fColumnDragging) { float DragOutlineLeft = fPreviousMousePos.x-fDragBoxMouseHoldOffset; float GroupBegin = ((CLVDragGroup*)fDragGroups.ItemAt(fDragGroup))->GroupBegin; if(DragOutlineLeft < GroupBegin && fSnapGroupBefore == -1) DragOutlineLeft = GroupBegin; if(DragOutlineLeft > GroupBegin && fSnapGroupAfter == -1) DragOutlineLeft = GroupBegin; float DragOutlineRight = DragOutlineLeft + fDragBoxWidth; BeginLineArray(4); AddLine(BPoint(DragOutlineLeft,ViewBounds.top),BPoint(DragOutlineRight, ViewBounds.top),BeFocusBlue); AddLine(BPoint(DragOutlineLeft,ViewBounds.bottom),BPoint(DragOutlineRight, ViewBounds.bottom),BeFocusBlue); AddLine(BPoint(DragOutlineLeft,ViewBounds.top+1.0),BPoint(DragOutlineLeft, ViewBounds.bottom-1.0),BeFocusBlue); AddLine(BPoint(DragOutlineRight,ViewBounds.top+1.0),BPoint(DragOutlineRight, ViewBounds.bottom-1.0),BeFocusBlue); EndLineArray(); fPrevDragOutlineLeft = DragOutlineLeft; fPrevDragOutlineRight = DragOutlineRight; } }
void TLevelsSlider::Draw(BRect updateRect) { PushState(); // Set up clipping BRegion clipRegion, saveRegion; GetClippingRegion(&saveRegion); clipRegion.Set(updateRect); ConstrainClippingRegion( &clipRegion ); BPoint startPt, endPt; const BRect bounds = Bounds(); // Fill with background SetHighColor(kPaleGrey); FillRect(updateRect); // Create left frame SetHighColor(kDarkGrey); startPt.Set(bounds.left, bounds.bottom); endPt.Set(bounds.left, bounds.top); StrokeLine(startPt, endPt); endPt.Set(bounds.right-2, bounds.top); StrokeLine(endPt); // Create left shadow SetHighColor(kBeShadow); BRect shadowOutline = bounds; shadowOutline.InsetBy(1,1); StrokeRect(shadowOutline); startPt.Set(shadowOutline.left+1, shadowOutline.bottom); endPt.Set(shadowOutline.left+1, shadowOutline.top+1); StrokeLine(startPt, endPt); endPt.Set(shadowOutline.right, shadowOutline.top+1); StrokeLine(endPt); startPt.Set(shadowOutline.right-1, shadowOutline.top+1); endPt.Set(shadowOutline.right-1, shadowOutline.bottom-1); StrokeLine(startPt, endPt); endPt.Set(shadowOutline.left-2, shadowOutline.bottom-1); StrokeLine(endPt); // Create right hilite SetHighColor(kPaleGrey); startPt.Set(bounds.right, bounds.top); endPt.Set(bounds.right, bounds.bottom); StrokeLine(startPt, endPt); endPt.Set(bounds.left, bounds.bottom); StrokeLine(endPt); startPt.Set(bounds.right-1, bounds.top+1); endPt.Set(bounds.right-1, bounds.bottom-1); StrokeLine(startPt, endPt); endPt.Set(bounds.left, bounds.bottom-1); StrokeLine(endPt); // Create channel slot BRect slot = bounds; slot.left = (bounds.Width()/2) - 3; slot.right = (bounds.Width()/2) + 2; slot.top += 1; slot.bottom -= 3; SetHighColor(kBlack); FillRect(slot); // Draw slot hilites startPt.Set(slot.left, slot.top); endPt.Set(slot.left, slot.bottom); SetHighColor(kDarkGrey); StrokeLine(startPt, endPt); slot.top +=1; slot.left = slot.right-2; rgb_color dkGrey = {35,35,35,255}; SetHighColor(dkGrey); FillRect(slot); // Draw ticks DrawSliderTicks(); // Draw Sliders DrawSliders(); ConstrainClippingRegion( &saveRegion ); PopState(); }
void BTextControl::Draw(BRect updateRect) { bool enabled = IsEnabled(); bool active = fText->IsFocus() && Window()->IsActive(); BRect rect = fText->Frame(); rect.InsetBy(-2, -2); if (be_control_look != NULL) { rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); uint32 flags = 0; if (!enabled) flags |= BControlLook::B_DISABLED; if (active) flags |= BControlLook::B_FOCUSED; be_control_look->DrawTextControlBorder(this, rect, updateRect, base, flags); rect = Bounds(); rect.right = fDivider - kLabelInputSpacing; // rect.right = fText->Frame().left - 2; // rect.right -= 3;//be_control_look->DefaultLabelSpacing(); be_control_look->DrawLabel(this, Label(), rect, updateRect, base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); return; } // outer bevel rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT); rgb_color lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT); rgb_color lightenMax = tint_color(noTint, B_LIGHTEN_MAX_TINT); rgb_color darken1 = tint_color(noTint, B_DARKEN_1_TINT); rgb_color darken2 = tint_color(noTint, B_DARKEN_2_TINT); rgb_color darken4 = tint_color(noTint, B_DARKEN_4_TINT); rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); if (enabled) SetHighColor(darken1); else SetHighColor(noTint); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); if (enabled) SetHighColor(lighten2); else SetHighColor(lighten1); StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom()); // inner bevel rect.InsetBy(1.0f, 1.0f); if (active) { SetHighColor(navigationColor); StrokeRect(rect); } else { if (enabled) SetHighColor(darken4); else SetHighColor(darken2); StrokeLine(rect.LeftTop(), rect.LeftBottom()); StrokeLine(rect.LeftTop(), rect.RightTop()); SetHighColor(noTint); StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1.0f)); } // label if (Label()) { _ValidateLayoutData(); font_height& fontHeight = fLayoutData->font_info; float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent - fontHeight.descent) / 2 + fontHeight.ascent; float x; float labelWidth = StringWidth(Label()); switch (fLabelAlign) { case B_ALIGN_RIGHT: x = fDivider - labelWidth - kLabelInputSpacing; break; case B_ALIGN_CENTER: x = fDivider - labelWidth / 2.0; break; default: x = 0.0; break; } BRect labelArea(x, Bounds().top, x + labelWidth, Bounds().bottom); if (x < fDivider && updateRect.Intersects(labelArea)) { labelArea.right = fText->Frame().left - kLabelInputSpacing; BRegion clipRegion(labelArea); ConstrainClippingRegion(&clipRegion); SetHighColor(IsEnabled() ? ui_color(B_CONTROL_TEXT_COLOR) : tint_color(noTint, B_DISABLED_LABEL_TINT)); DrawString(Label(), BPoint(x, y)); } } }
void BSlider::DrawBar() { BRect frame = BarFrame(); BView *view = OffscreenView(); if (be_control_look != NULL) { uint32 flags = be_control_look->Flags(this); rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color rightFillColor = fBarColor; rgb_color leftFillColor = fUseFillColor ? fFillColor : fBarColor; be_control_look->DrawSliderBar(view, frame, frame, base, leftFillColor, rightFillColor, Position(), flags, fOrientation); return; } rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lightenmax; rgb_color darken1; rgb_color darken2; rgb_color darkenmax; rgb_color barColor; rgb_color fillColor; if (IsEnabled()) { lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT); darken1 = tint_color(no_tint, B_DARKEN_1_TINT); darken2 = tint_color(no_tint, B_DARKEN_2_TINT); darkenmax = tint_color(no_tint, B_DARKEN_MAX_TINT); barColor = fBarColor; fillColor = fFillColor; } else { lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT); darken1 = no_tint; darken2 = tint_color(no_tint, B_DARKEN_1_TINT); darkenmax = tint_color(no_tint, B_DARKEN_3_TINT); barColor.red = (fBarColor.red + no_tint.red) / 2; barColor.green = (fBarColor.green + no_tint.green) / 2; barColor.blue = (fBarColor.blue + no_tint.blue) / 2; barColor.alpha = 255; fillColor.red = (fFillColor.red + no_tint.red) / 2; fillColor.green = (fFillColor.green + no_tint.green) / 2; fillColor.blue = (fFillColor.blue + no_tint.blue) / 2; fillColor.alpha = 255; } // exclude the block thumb from the bar filling BRect lowerFrame = frame.InsetByCopy(1, 1); lowerFrame.top++; lowerFrame.left++; BRect upperFrame = lowerFrame; BRect thumbFrame; if (Style() == B_BLOCK_THUMB) { thumbFrame = ThumbFrame(); if (fOrientation == B_HORIZONTAL) { lowerFrame.right = thumbFrame.left; upperFrame.left = thumbFrame.right; } else { lowerFrame.top = thumbFrame.bottom; upperFrame.bottom = thumbFrame.top; } } else if (fUseFillColor) { if (fOrientation == B_HORIZONTAL) { lowerFrame.right = floor(lowerFrame.left - 1 + Position() * (lowerFrame.Width() + 1)); upperFrame.left = lowerFrame.right; } else { lowerFrame.top = floor(lowerFrame.bottom + 1 - Position() * (lowerFrame.Height() + 1)); upperFrame.bottom = lowerFrame.top; } } view->SetHighColor(barColor); view->FillRect(upperFrame); if (Style() == B_BLOCK_THUMB || fUseFillColor) { if (fUseFillColor) view->SetHighColor(fillColor); view->FillRect(lowerFrame); } if (Style() == B_BLOCK_THUMB) { // We don't want to stroke the lines over the thumb PushState(); BRegion region; GetClippingRegion(®ion); region.Exclude(thumbFrame); ConstrainClippingRegion(®ion); } view->SetHighColor(darken1); view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.left + 1.0f, frame.top)); view->StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.left + 1.0f, frame.bottom)); view->StrokeLine(BPoint(frame.right - 1.0f, frame.top), BPoint(frame.right, frame.top)); view->SetHighColor(darken2); view->StrokeLine(BPoint(frame.left + 1.0f, frame.top), BPoint(frame.right - 1.0f, frame.top)); view->StrokeLine(BPoint(frame.left, frame.bottom - 1.0f), BPoint(frame.left, frame.top + 1.0f)); view->SetHighColor(lightenmax); view->StrokeLine(BPoint(frame.left + 1.0f, frame.bottom), BPoint(frame.right, frame.bottom)); view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f), BPoint(frame.right, frame.top + 1.0f)); frame.InsetBy(1.0f, 1.0f); view->SetHighColor(darkenmax); view->StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.left, frame.top)); view->StrokeLine(BPoint(frame.left + 1.0f, frame.top), BPoint(frame.right, frame.top)); if (Style() == B_BLOCK_THUMB) PopState(); }