void GradientsView::DrawRadialFocus(BRect update) { BGradientRadialFocus gradient; rgb_color c; c.red = 255; c.green = 0; c.blue = 0; gradient.AddColor(c, 0); c.red = 0; c.green = 255; c.blue = 0; gradient.AddColor(c, 127); c.red = 0; c.green = 0; c.blue = 255; gradient.AddColor(c, 255); // RoundRect SetHighColor(0, 0, 0); FillRoundRect(BRect(10, 10, 110, 110), 5, 5); gradient.SetCenter(BPoint(170, 60)); FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient); // Rect SetHighColor(0, 0, 0); FillRect(BRect(10, 120, 110, 220)); gradient.SetCenter(BPoint(170, 170)); FillRect(BRect(120, 120, 220, 220), gradient); // Triangle SetHighColor(0, 0, 0); FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330)); gradient.SetCenter(BPoint(170, 280)); FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient); // Ellipse SetHighColor(0, 0, 0); FillEllipse(BPoint(60, 390), 50, 50); gradient.SetCenter(BPoint(170, 390)); FillEllipse(BPoint(170, 390), 50, 50, gradient); }
void GradientsView::DrawLinear(BRect update) { BGradientLinear gradient; rgb_color c; c.red = 255; c.green = 0; c.blue = 0; gradient.AddColor(c, 0); c.red = 0; c.green = 255; c.blue = 0; gradient.AddColor(c, 127); c.red = 0; c.green = 0; c.blue = 255; gradient.AddColor(c, 255); // RoundRect SetHighColor(0, 0, 0); FillRoundRect(BRect(10, 10, 110, 110), 5, 5); gradient.SetStart(BPoint(120, 10)); gradient.SetEnd(BPoint(220, 110)); FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient); // Rect SetHighColor(0, 0, 0); FillRect(BRect(10, 120, 110, 220)); gradient.SetStart(BPoint(120, 120)); gradient.SetEnd(BPoint(220, 220)); FillRect(BRect(120, 120, 220, 220), gradient); // Triangle SetHighColor(0, 0, 0); FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330)); gradient.SetStart(BPoint(60, 230)); gradient.SetEnd(BPoint(60, 330)); FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient); // Ellipse SetHighColor(0, 0, 0); FillEllipse(BPoint(60, 390), 50, 50); gradient.SetStart(BPoint(60, 340)); gradient.SetEnd(BPoint(60, 440)); FillEllipse(BPoint(170, 390), 50, 50, gradient); }
void Mover::Draw(BRect rect) { /* BRect r = Bounds(); r.top+=1; r.left+=1; r.right-=1; r.bottom-=1; SetHighColor(192,192,192); FillRect(r); r=Bounds(); SetHighColor(255,255,255); StrokeLine(r.LeftBottom(),r.LeftTop()); StrokeLine(r.LeftTop(),r.RightTop()); SetHighColor(168,168,168); StrokeLine(r.RightTop(),r.RightBottom()); StrokeLine(r.RightBottom(),r.LeftBottom()); SetHighColor(208,208,208); StrokeLine(r.LeftBottom(),r.LeftBottom()); StrokeLine(r.RightTop(),r.RightTop()); */ BRect r = Bounds(); SetHighColor(152,152,152); if (vertical) { StrokeLine(r.LeftTop(),r.LeftBottom()); StrokeLine(r.RightTop()+BPoint(-1,0),r.RightBottom()+BPoint(-1,0)); StrokeLine(r.RightTop(),r.RightBottom()); } else { StrokeLine(r.LeftTop(),r.RightTop()); StrokeLine(r.LeftBottom()+BPoint(0,-1),r.RightBottom()+BPoint(0,-1)); StrokeLine(r.LeftBottom(),r.RightBottom()); } SetHighColor(255,255,255); if (vertical) StrokeLine(r.LeftTop()+BPoint(1,0),r.LeftBottom()+BPoint(1,0)); else StrokeLine(r.LeftTop()+BPoint(0,1),r.RightTop()+BPoint(0,1)); SetHighColor(232,232,232); if (vertical) StrokeLine(r.RightTop()+BPoint(-2,0),r.RightBottom()+BPoint(-2,0)); else StrokeLine(r.LeftBottom()+BPoint(0,-2),r.RightBottom()+BPoint(0,-2)); }
void ArpDocumentButton::Draw(BRect) { enum { ShineColor = 0, MedShineColor = 1, ShadowColor = 2, MedShadowColor = 3, NumColors = 4 }; static float ColorTints[NumColors] = { .2, B_DARKEN_2_TINT, B_DARKEN_4_TINT, B_DARKEN_1_TINT }; static int32 StandardMap[NumColors] = { ShineColor, MedShineColor, ShadowColor, MedShadowColor }; static int32 PressedMap[NumColors] = { ShadowColor, MedShadowColor, ShineColor, MedShineColor }; rgb_color bgcolor = LowColor(); if( mDropped ) bgcolor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); BRect bounds(Bounds()); ArpD(cdb << ADH << "Drawing ArpDocument Button..." << endl); ArpD(cdb << ADH << "Initial view bounds=" << bounds << endl); int32* cmap = mPressed ? PressedMap : StandardMap; BeginLineArray(8); rgb_color curcol; if( bounds.IsValid() ) { ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds << endl); curcol = tint_color(bgcolor, ColorTints[cmap[MedShineColor]]); AddLine( BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), curcol ); AddLine( BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), curcol ); curcol = tint_color(bgcolor, ColorTints[cmap[ShadowColor]]); AddLine( BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), curcol ); AddLine( BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), curcol ); bounds.InsetBy(1, 1); } if( bounds.IsValid() ) { ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds << endl); curcol = tint_color(bgcolor, ColorTints[cmap[ShineColor]]); if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR); AddLine( BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), curcol ); AddLine( BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), curcol ); curcol = tint_color(bgcolor, ColorTints[cmap[MedShadowColor]]); if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR); AddLine( BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), curcol ); AddLine( BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), curcol ); bounds.InsetBy(1, 1); } EndLineArray(); BRect ibounds; BBitmap* shownBitmap = 0; if( mPressed ) bgcolor = tint_color(LowColor(), B_DARKEN_MAX_TINT); else if( mMenued ) bgcolor = tint_color(LowColor(), B_DARKEN_2_TINT); if( bounds.IsValid() ) { shownBitmap = mDocIcon; if( shownBitmap ) ibounds = shownBitmap->Bounds(); if( mSmallIcon && ( !ibounds.IsValid() || ibounds.Width() > bounds.Width() || ibounds.Height() > bounds.Height() ) ) { shownBitmap = mSmallIcon; ibounds = shownBitmap->Bounds(); } ArpD(cdb << ADH << "Current view bounds=" << bounds << ", icon bounds=" << ibounds << endl); SetHighColor(bgcolor); const float xdiff = bounds.Width() - ibounds.Width(); const float xoff = floor(xdiff/2); if( xdiff > 0 ) { // Fill in background to left and right of bitmap. if( xoff > 0 ) { FillRect(BRect(bounds.left, bounds.top, bounds.left+xoff-1, bounds.bottom)); } FillRect(BRect(bounds.right-(xdiff-xoff)+1, bounds.top, bounds.right, bounds.bottom)); bounds.left += xoff; bounds.right -= (xdiff-xoff); ArpD(cdb << ADH << "Fill view X to bounds=" << bounds << endl); } else { #if 1 ibounds.left -= xoff; ibounds.right += (xdiff-xoff); #endif ArpD(cdb << ADH << "Indent icon X to bounds=" << ibounds << endl); } const float ydiff = bounds.Height() - ibounds.Height(); const float yoff = floor(ydiff/2); if( ydiff > 0 ) { // Fill in background to left and right of bitmap. if( yoff > 0 ) { FillRect(BRect(bounds.left, bounds.top, bounds.right, bounds.top+yoff-1)); } FillRect(BRect(bounds.left, bounds.bottom-(ydiff-yoff)+1, bounds.right, bounds.bottom)); bounds.top += yoff; bounds.bottom -= (ydiff-yoff); ArpD(cdb << ADH << "Fill view Y to bounds=" << bounds << endl); } else { #if 1 ibounds.top -= yoff; ibounds.bottom += (ydiff-yoff); #endif ArpD(cdb << ADH << "Indent icon Y to bounds=" << ibounds << endl); } } if( bounds.IsValid() && ibounds.IsValid() && shownBitmap ) { ArpD(cdb << ADH << "Drawing icon at bounds=" << bounds << ", icon bounds=" << ibounds << endl); SetHighColor(bgcolor); SetLowColor(bgcolor); FillRect(bounds); SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); DrawBitmapAsync(shownBitmap, ibounds, bounds); SetDrawingMode(B_OP_COPY); } }
status_t MediaRoutingView::importStateFor( const NodeSetIOContext* context, const BMessage* archive) { status_t err; for(int32 archiveIndex = 0;; ++archiveIndex) { // fetch archived key & panel data const char* key; err = archive->FindString("nodeKey", archiveIndex, &key); if(err < B_OK) break; BMessage m; err = archive->FindMessage("panel", archiveIndex, &m); if(err < B_OK) { PRINT(( "!!! MediaRoutingView::importStateFor(): missing panel %ld\n", archiveIndex)); continue; } // find corresponding node media_node_id id; err = context->getNodeFor(key, &id); if(err < B_OK) { PRINT(( "!!! MediaRoutingView::importStateFor(): missing node '%s'\n", key)); continue; } // look for panel, create it if necessary MediaNodePanel* panel; err = _findPanelFor(id, &panel); if(err < B_OK) { // create it err = _addPanelFor( id, BPoint(5.0, 5.0)); if(err < B_OK) { PRINT(( "!!! MediaRoutingView::importStateFor(): _addPanelFor():\n" " %s\n", strerror(err))); continue; } err = _findPanelFor(id, &panel); if(err < B_OK) { PRINT(( "!!! MediaRoutingView::importStateFor(): _findPanelFor():\n" " %s\n", strerror(err))); continue; } } // pass state data along panel->importState(&m); // select the panel SelectItem(panel, false); } return B_OK; }
void MediaRoutingView::MessageReceived( BMessage* message) { D_METHOD(("MediaRoutingView::MessageReceived()\n")); switch (message->what) { case B_MEDIA_NODE_CREATED: { D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_CREATED)\n")); type_code type; int32 count; if (message->GetInfo("media_node_id", &type, &count) == B_OK) { for(int32 n = 0; n < count; n++) { int32 id; if (message->FindInt32("media_node_id", n, &id) == B_OK) { // [e.moon 8dec99] allow for existing panel MediaNodePanel* panel; if(_findPanelFor(id, &panel) < B_OK) _addPanelFor(id, BPoint(5.0, 5.0)); } } } break; } case B_MEDIA_NODE_DELETED: { D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_DELETED)\n")); type_code type; int32 count; if (message->GetInfo("media_node_id", &type, &count) == B_OK) { for (int32 n = 0; n < count; n++) { int32 id; if (message->FindInt32("media_node_id", n, &id) == B_OK) { _removePanelFor(id); } } } break; } case B_MEDIA_CONNECTION_MADE: { D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_MADE)\n")); type_code type; int32 count; if (message->GetInfo("output", &type, &count) == B_OK) { for (int32 n = 0; n < count; n++) { media_output output; const void *data; ssize_t dataSize; if (message->FindData("output", B_RAW_TYPE, n, &data, &dataSize) == B_OK) { output = *reinterpret_cast<const media_output *>(data); Connection connection; if (manager->findConnection(output.node.node, output.source, &connection) == B_OK) { _addWireFor(connection); } } } } break; } case B_MEDIA_CONNECTION_BROKEN: { D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_BROKEN)\n")); type_code type; int32 count; if (message->GetInfo("__connection_id", &type, &count) == B_OK) { for (int32 n = 0; n < count; n++) { int32 id; if (message->FindInt32("__connection_id", n, &id) == B_OK) { _removeWireFor(id); } } } break; } case B_MEDIA_FORMAT_CHANGED: { D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_FORMAT_CHANGED)\n")); media_node_id nodeID; if(message->FindInt32("__source_node_id", &nodeID) < B_OK) break; uint32 connectionID; if(message->FindInt32("__connection_id", (int32*)&connectionID) < B_OK) break; media_source* source; ssize_t dataSize; if(message->FindData("be:source", B_RAW_TYPE, (const void**)&source, &dataSize) < B_OK) break; MediaWire* wire; if(_findWireFor(connectionID, &wire) == B_OK) { // copy new connection data manager->findConnection(nodeID, *source, &wire->connection); } break; } case M_CLEANUP_REQUESTED: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_M_CLEANUP_REQUESTED)\n")); cleanUp(); break; } case M_SELECT_ALL: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_SELECT_ALL)\n")); SelectAll(DiagramItem::M_BOX); break; } case M_DELETE_SELECTION: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_DELETE_SELECTION)\n")); _deleteSelection(); break; } case M_NODE_CHANGE_CYCLING: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_CYCLING_CHANGED)\n")); bool cycle; if (message->FindBool("cycle", &cycle) == B_OK) { _changeCyclingForSelection(cycle); } break; } case M_NODE_CHANGE_RUN_MODE: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_RUNMODE_CHANGED)\n")); int32 mode; if (message->FindInt32("run_mode", &mode) == B_OK) { _changeRunModeForSelection(static_cast<uint32>(mode)); } break; } case M_LAYOUT_CHANGED: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_LAYOUT_CHANGED)\n")); layout_t layout; if (message->FindInt32("layout", (int32*)&layout) == B_OK) { if (layout != m_layout) { layoutChanged(layout); updateDataRect(); Invalidate(); } } break; } case M_NODE_START_TIME_SOURCE: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_START_TIME_SOURCE)\n")); int32 id; if(message->FindInt32("nodeID", &id) < B_OK) break; NodeRef* ref; if(manager->getNodeRef(id, &ref) < B_OK) break; bigtime_t when = system_time(); status_t err = manager->roster->StartTimeSource(ref->node(), when); if(err < B_OK) { PRINT(( "! StartTimeSource(%ld): '%s'\n", ref->id(), strerror(err))); } break; } case M_NODE_STOP_TIME_SOURCE: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_STOP_TIME_SOURCE)\n")); int32 id; if(message->FindInt32("nodeID", &id) < B_OK) break; NodeRef* ref; if(manager->getNodeRef(id, &ref) < B_OK) break; bigtime_t when = system_time(); status_t err = manager->roster->StopTimeSource(ref->node(), when); if(err < B_OK) { PRINT(( "! StopTimeSource(%ld): '%s'\n", ref->id(), strerror(err))); } break; } case M_NODE_TWEAK_PARAMETERS: { D_MESSAGE((" -> M_NODE_TWEAK_PARAMETERS\n")); _openParameterWindowsForSelection(); break; } case M_NODE_START_CONTROL_PANEL: { D_MESSAGE((" -> M_NODE_START_CONTROL_PANEL\n")); _startControlPanelsForSelection(); break; } case M_GROUP_SET_LOCKED: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_GROUP_SET_LOCKED)\n")); int32 groupID; if(message->FindInt32("groupID", &groupID) < B_OK) break; bool locked; if(message->FindBool("locked", &locked) < B_OK) break; NodeGroup* group; if(manager->findGroup(groupID, &group) < B_OK) break; uint32 f = locked ? group->groupFlags() | NodeGroup::GROUP_LOCKED : group->groupFlags() & ~NodeGroup::GROUP_LOCKED; group->setGroupFlags(f); break; } case M_BROADCAST_SELECTION: { D_MESSAGE((" -> M_BROADCAST_SELECTION\n")); _broadcastSelection(); break; } case InfoWindowManager::M_INFO_WINDOW_REQUESTED: { D_MESSAGE(("MediaRoutingView::MessageReceived(InfoView::M_INFO_WINDOW_REQUESTED)\n")); type_code type; int32 count; if (message->GetInfo("input", &type, &count) == B_OK) { for (int32 i = 0; i < count; i++) { media_input input; const void *data; ssize_t dataSize; if (message->FindData("input", B_RAW_TYPE, i, &data, &dataSize) == B_OK) { input = *reinterpret_cast<const media_input *>(data); InfoWindowManager *manager = InfoWindowManager::Instance(); if (manager && manager->Lock()) { manager->openWindowFor(input); manager->Unlock(); } } } } else if (message->GetInfo("output", &type, &count) == B_OK) { for (int32 i = 0; i < count; i++) { media_output output; const void *data; ssize_t dataSize; if (message->FindData("output", B_RAW_TYPE, i, &data, &dataSize) == B_OK) { output = *reinterpret_cast<const media_output *>(data); InfoWindowManager *manager = InfoWindowManager::Instance(); if (manager && manager->Lock()) { manager->openWindowFor(output); manager->Unlock(); } } } } else { _openInfoWindowsForSelection(); } break; } case NodeManager::M_RELEASED: { D_MESSAGE(("MediaRoutingView::MessageReceived(NodeManager::M_RELEASED)\n")); remove_observer(this, manager); const_cast<RouteAppNodeManager*&>(manager) = 0; // +++++ disable view! break; } case NodeRef::M_RELEASED: { D_MESSAGE(("MediaRoutingView::MessageReceived(NodeRef::M_RELEASED)\n")); // only relevant on shutdown; do nothing break; } default: { DiagramView::MessageReceived(message); } } }
int32 MouseWatcher(void* data) { BMessenger *TheMessenger = (BMessenger*)data; BPoint PreviousPos; uint32 PreviousButtons = 0; bool FirstCheck = true; BMessage MessageToSend; MessageToSend.AddPoint("where",BPoint(0,0)); MessageToSend.AddInt32("buttons",0); while(true) { if (!TheMessenger->LockTarget()) { delete TheMessenger; return 0; // window is dead so exit } BLooper *TheLooper; BView *TheView = (BView*)TheMessenger->Target(&TheLooper); BPoint Where; uint32 Buttons; TheView->GetMouse(&Where,&Buttons,false); if(FirstCheck) { PreviousPos = Where; PreviousButtons = Buttons; FirstCheck = false; } bool Send = false; if(Buttons != PreviousButtons || Buttons == 0 || Where != PreviousPos) { if(Buttons == 0) MessageToSend.what = MW_MOUSE_UP; else if(Buttons != PreviousButtons) MessageToSend.what = MW_MOUSE_DOWN; else MessageToSend.what = MW_MOUSE_MOVED; MessageToSend.ReplacePoint("where",Where); MessageToSend.ReplaceInt32("buttons",Buttons); Send = true; } TheLooper->Unlock(); if(Send) TheMessenger->SendMessage(&MessageToSend); if(Buttons == 0) { //Button was released delete TheMessenger; return 0; } snooze(50 * 1000); } }
FloatRect::operator BRect() const { return BRect(BPoint(x(), y()), BSize(width() - 1, height() - 1)); }
Layer::Layer(BRect frame, int32 id, ImageView* imageView, layer_type type, BBitmap* bitmap) : fLayerData(NULL) , fLayerPreview(NULL) , fLayerId(id) , fLayerPreviewSem(-1) , fLayerPreviewThreads(0) , fLayerVisible(true) , fLayerActive(false) , fLayerType(type) , fImage(NULL) , fImageView(imageView) , fLayerView(NULL) { frame.OffsetTo(B_ORIGIN); fLayerName << "Layer " << fLayerId; if (fLayerType == HS_NORMAL_LAYER) { BRect sourceRect; if (bitmap && bitmap->IsValid()) sourceRect = bitmap->Bounds(); fLayerData = new BBitmap(BRect(frame.LeftTop(), BPoint(max_c(frame.right, sourceRect.right), max_c(frame.bottom, sourceRect.bottom))), B_RGB_32_BIT); if (!fLayerData->IsValid()) throw std::bad_alloc(); union { char bytes[4]; uint32 word; } color; color.bytes[0] = 0xFF; color.bytes[1] = 0xFF; color.bytes[2] = 0xFF; color.bytes[3] = 0x00; int32 bits_length = fLayerData->BitsLength() / 4; uint32* target_bits = (uint32*)fLayerData->Bits(); // Fill the layer data with initial color. for (int32 i = 0; i < bits_length; ++i) *target_bits++ = color.word; if (bitmap && bitmap->IsValid()) { fLayerData->ImportBits(bitmap, BPoint(B_ORIGIN), BPoint(B_ORIGIN), int32(min_c(frame.Width(), sourceRect.Width())), int32(min_c(frame.Height(), sourceRect.Height()))); } // create the miniature image for this layer and a semaphore for it fLayerPreview = new BBitmap(BRect(0, 0, HS_MINIATURE_IMAGE_WIDTH - 1, HS_MINIATURE_IMAGE_HEIGHT - 1), B_RGB_32_BIT); fLayerPreviewSem = create_sem(1, "mini image semaphore"); } fLayerView = new LayerView(fLayerPreview, this); SetTransparency(1.0); }
void StatusView::drawInto(BView *v, BRect updateRect) { BRect r(Bounds()); D_OPERATION(("StatusView::drawInto(%.1f, %.1f)\n", r.Width(), r.Height())); // draw border (minus right edge, which the scrollbar draws) v->SetDrawingMode(B_OP_COPY); v->BeginLineArray(8); v->AddLine(r.LeftTop(), r.RightTop(), M_MED_GRAY_COLOR); BPoint rtop = r.RightTop(); rtop.y++; v->AddLine(rtop, r.RightBottom(), tint_color(M_MED_GRAY_COLOR, B_LIGHTEN_1_TINT)); v->AddLine(r.RightBottom(), r.LeftBottom(), M_MED_GRAY_COLOR); v->AddLine(r.LeftBottom(), r.LeftTop(), M_MED_GRAY_COLOR); r.InsetBy(1.0, 1.0); v->AddLine(r.LeftTop(), r.RightTop(), M_LIGHT_GRAY_COLOR); rtop.y++; rtop.x--; v->AddLine(rtop, r.RightBottom(), M_GRAY_COLOR); v->AddLine(r.RightBottom(), r.LeftBottom(), tint_color(M_MED_GRAY_COLOR, B_LIGHTEN_1_TINT)); v->AddLine(r.LeftBottom(), r.LeftTop(), M_LIGHT_GRAY_COLOR); v->EndLineArray(); r.InsetBy(1.0, 1.0); v->SetLowColor(M_GRAY_COLOR); v->FillRect(r, B_SOLID_LOW); r.InsetBy(2.0, 0.0); v->SetDrawingMode(B_OP_ALPHA); v->SetHighColor(0, 0, 0, uchar(255 * m_opacity)); // draw icon if (m_icon) { v->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); BPoint p = r.LeftTop(); p.y--; v->DrawBitmap(m_icon, p); } // draw text r.left += 10.0; font_height fh; be_plain_font->GetHeight(&fh); r.bottom = Bounds().bottom - fh.descent - (Bounds().Height() - fh.ascent - fh.descent) / 2; v->MovePenTo(r.LeftBottom()); v->DrawString(Text()); // draw resize dragger v->SetDrawingMode(B_OP_OVER); r = Bounds(); r.right -= 2.0; r.left = r.right - 2.0; r.InsetBy(0.0, 3.0); r.top += 1.0; for (int32 i = 0; i < r.IntegerHeight(); i += 3) { BPoint p = r.LeftTop() + BPoint(0.0, i); v->SetHighColor(M_MED_GRAY_COLOR); v->StrokeLine(p, p, B_SOLID_HIGH); p += BPoint(1.0, 1.0); v->SetHighColor(M_WHITE_COLOR); v->StrokeLine(p, p, B_SOLID_HIGH); } }
void DataView::DrawSelectionFrame(view_focus which) { if (fFileSize == 0) return; bool drawBlock = false; bool drawLastLine = false; BRect block, lastLine; int32 spacing = 0; if (which == kAsciiFocus) spacing++; // draw first line int32 start = fStart % kBlockSize; int32 first = (fStart / kBlockSize) * kBlockSize; int32 end = fEnd; if (end > first + (int32)kBlockSize - 1) end = first + kBlockSize - 1; BRect firstLine = SelectionFrame(which, first + start, end); firstLine.right += spacing; first += kBlockSize; // draw block (and last line) if necessary end = fEnd % kBlockSize; int32 last = (fEnd / kBlockSize) * kBlockSize; if (last >= first) { if (end == kBlockSize - 1) last += kBlockSize; if (last > first) { block = SelectionFrame(which, first, last - 1); block.right += spacing; drawBlock = true; } if (end != kBlockSize - 1) { lastLine = SelectionFrame(which, last, last + end); lastLine.right += spacing; drawLastLine = true; } } SetDrawingMode(B_OP_INVERT); BeginLineArray(8); // +******* // | * // +------+ const rgb_color color = {0, 0, 0}; float bottom; if (drawBlock) bottom = block.bottom; else bottom = firstLine.bottom; AddLine(BPoint(firstLine.left + 1, firstLine.top), firstLine.RightTop(), color); AddLine(BPoint(firstLine.right, firstLine.top + 1), BPoint(firstLine.right, bottom), color); // *-------+ // * | // ********* BRect rect; if (start == 0 || (!drawBlock && !drawLastLine)) rect = firstLine; else if (drawBlock) rect = block; else rect = lastLine; if (drawBlock) rect.bottom = block.bottom; if (drawLastLine) { rect.bottom = lastLine.bottom; rect.right = lastLine.right; } rect.bottom++; AddLine(rect.LeftTop(), rect.LeftBottom(), color); AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(), color); // *--------+ // * | // +**** | // | | if (start && (drawLastLine || drawBlock)) { AddLine(firstLine.LeftTop(), firstLine.LeftBottom(), color); float right = firstLine.left; if (!drawBlock && right > lastLine.right) right = lastLine.right; AddLine(BPoint(rect.left + 1, rect.top), BPoint(right, rect.top), color); } // | | // | ***** // | * // +--------+ if (drawLastLine) { AddLine(lastLine.RightBottom(), BPoint(lastLine.right, lastLine.top + 1), color); if (!drawBlock && lastLine.right <= firstLine.left) lastLine.right = firstLine.left + (lastLine.right < firstLine.left ? 0 : 1); AddLine(BPoint(lastLine.right, lastLine.top), BPoint(firstLine.right, lastLine.top), color); } EndLineArray(); SetDrawingMode(B_OP_COPY); }