1 // Author: Michael Wilber
2 // Copyright (C) Haiku, uses the MIT license
19 IconView::IconView(icon_size iconSize
)
21 BView("IconView", B_WILL_DRAW
),
23 fIconBitmap(new BBitmap(BRect(iconSize
), B_RGBA32
)),
26 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
38 IconView::SetIcon(const BPath
& path
, icon_size iconSize
)
42 if (iconSize
!= fIconSize
) {
43 BBitmap
* bitmap
= new BBitmap(BRect(iconSize
), B_RGBA32
);
52 status_t status
= fIconBitmap
->InitCheck();
56 BEntry
entry(path
.Path());
58 BNodeInfo
info(&node
);
60 status
= info
.GetTrackerIcon(fIconBitmap
, fIconSize
);
64 if (!fIconBitmap
->IsValid())
65 return fIconBitmap
->InitCheck();
76 IconView::DrawIcon(bool draw
)
78 if (draw
== fDrawIcon
)
87 IconView::Draw(BRect area
)
89 if (fDrawIcon
&& fIconBitmap
!= NULL
) {
90 SetDrawingMode(B_OP_ALPHA
);
91 SetBlendingMode(B_PIXEL_ALPHA
, B_ALPHA_OVERLAY
);
92 DrawBitmap(fIconBitmap
);
93 SetDrawingMode(B_OP_COPY
);
100 IconView::InitCheck() const
102 if (fIconBitmap
== NULL
)
105 return fIconBitmap
->InitCheck();
112 SetExplicitMinSize(BSize(fIconSize
, fIconSize
));
113 SetExplicitMaxSize(BSize(fIconSize
, fIconSize
));
114 SetExplicitPreferredSize(BSize(fIconSize
, fIconSize
));