BRect BPose::CalcRect(BPoint loc, const BPoseView* poseView, bool minimalRect) const { ASSERT(poseView->ViewMode() == kListMode); BColumn* column = poseView->LastColumn(); BRect rect; rect.left = loc.x; rect.top = loc.y; rect.right = loc.x + column->Offset() + column->Width(); rect.bottom = rect.top + poseView->ListElemHeight(); if (minimalRect) { BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); if (widget != NULL) { rect.right = widget->CalcRect(loc, poseView->FirstColumn(), poseView).right; } } return rect; }
status_t SeqManageRosterWindow::GetConfiguration(BMessage* config) { ArpASSERT(config); config->what = ConfigWhat(); status_t err = GetDimensions(config, this); if (err != B_OK) return err; /* Add the columns */ BColumnListView* table = dynamic_cast<BColumnListView*>( FindView(TABLE_STR) ); if (table) { BColumn* col; for( int32 k = 0; (col = table->ColumnAt(k)); k++ ) { BMessage colMsg; BString colName; col->GetColumnName(&colName); if( colMsg.AddString("name", colName.String() ) == B_OK && colMsg.AddFloat("width", col->Width() ) == B_OK && colMsg.AddBool("visible", col->IsVisible() ) == B_OK ) { config->AddMessage("column", &colMsg); } } } return B_OK; }
void BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* drawView, bool fullDraw, BPoint offset, bool selected) { // If the background wasn't cleared and Draw() is not called after // having edited a name or similar (with fullDraw) if (!fBackgroundClean && !fullDraw) { fBackgroundClean = true; poseView->Invalidate(rect); return; } else fBackgroundClean = false; bool directDraw = (drawView == poseView); bool windowActive = poseView->Window()->IsActive(); bool showSelectionWhenInactive = poseView->fShowSelectionWhenInactive; bool isDrawingSelectionRect = poseView->fIsDrawingSelectionRect; ModelNodeLazyOpener modelOpener(fModel); if (poseView->ViewMode() == kListMode) { uint32 size = poseView->IconSizeInt(); BRect iconRect(rect); iconRect.left += kListOffset; iconRect.right = iconRect.left + size; iconRect.top = iconRect.bottom - size; if (updateRect.Intersects(iconRect)) { iconRect.OffsetBy(offset); DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(), directDraw, !windowActive && !showSelectionWhenInactive); } // draw text int32 columnsToDraw = 1; if (fullDraw) columnsToDraw = poseView->CountColumns(); for (int32 index = 0; index < columnsToDraw; index++) { BColumn* column = poseView->ColumnAt(index); if (column == NULL) break; // if widget doesn't exist, create it BTextWidget* widget = WidgetFor(column, poseView, modelOpener); if (widget && widget->IsVisible()) { BRect widgetRect(widget->ColumnRect(rect.LeftTop(), column, poseView)); if (updateRect.Intersects(widgetRect)) { BRect widgetTextRect(widget->CalcRect(rect.LeftTop(), column, poseView)); bool selectDuringDraw = directDraw && selected && windowActive; if (index == 0 && selectDuringDraw) { //draw with dark background to select text drawView->PushState(); drawView->SetLowColor(0, 0, 0); } if (index == 0) { widget->Draw(widgetRect, widgetTextRect, column->Width(), poseView, drawView, selected, fClipboardMode, offset, directDraw); } else { widget->Draw(widgetTextRect, widgetTextRect, column->Width(), poseView, drawView, false, fClipboardMode, offset, directDraw); } if (index == 0 && selectDuringDraw) drawView->PopState(); else if (index == 0 && selected) { if (windowActive || isDrawingSelectionRect) { widgetTextRect.OffsetBy(offset); drawView->InvertRect(widgetTextRect); } else if (!windowActive && showSelectionWhenInactive) { widgetTextRect.OffsetBy(offset); drawView->PushState(); drawView->SetDrawingMode(B_OP_BLEND); drawView->SetHighColor(128, 128, 128, 255); drawView->FillRect(widgetTextRect); drawView->PopState(); } } } } } } else { // draw in icon mode BPoint location(Location(poseView)); BPoint iconOrigin(location); iconOrigin += offset; DrawIcon(iconOrigin, drawView, poseView->IconSize(), directDraw, !windowActive && !showSelectionWhenInactive); BColumn* column = poseView->FirstColumn(); if (column == NULL) return; BTextWidget* widget = WidgetFor(column, poseView, modelOpener); if (widget == NULL || !widget->IsVisible()) return; rect = widget->CalcRect(location, 0, poseView); bool selectDuringDraw = directDraw && selected && (poseView->IsDesktopWindow() || windowActive); if (selectDuringDraw) { // draw with dark background to select text drawView->PushState(); drawView->SetLowColor(0, 0, 0); } widget->Draw(rect, rect, rect.Width(), poseView, drawView, selected, fClipboardMode, offset, directDraw); if (selectDuringDraw) drawView->PopState(); else if (selected && directDraw) { if (windowActive || isDrawingSelectionRect) { rect.OffsetBy(offset); drawView->InvertRect(rect); } else if (!windowActive && showSelectionWhenInactive) { drawView->PushState(); drawView->SetDrawingMode(B_OP_BLEND); drawView->SetHighColor(128, 128, 128, 255); drawView->FillRect(rect); drawView->PopState(); } } } }