* added missing destructor
* delete app icon on pref close * use HVIF icon in case of Haiku git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25302 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9ec99c6e2f
commit
88be2c9f5d
@ -51,6 +51,13 @@ JobListView::JobListView(BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JobListView::~JobListView()
|
||||||
|
{
|
||||||
|
while (!IsEmpty())
|
||||||
|
delete RemoveItem(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JobListView::AttachedToWindow()
|
JobListView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@ -64,31 +71,24 @@ JobListView::AttachedToWindow()
|
|||||||
void
|
void
|
||||||
JobListView::SetSpoolFolder(SpoolFolder* folder)
|
JobListView::SetSpoolFolder(SpoolFolder* folder)
|
||||||
{
|
{
|
||||||
BPath path;
|
|
||||||
|
|
||||||
// clear list
|
// clear list
|
||||||
const BListItem** items = Items();
|
while (!IsEmpty())
|
||||||
for (int i = CountItems() - 1; i >= 0; i --) {
|
delete RemoveItem(0L);
|
||||||
delete items[i];
|
|
||||||
}
|
|
||||||
MakeEmpty();
|
|
||||||
|
|
||||||
if (folder == NULL)
|
if (folder == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find directory containing printer definition nodes
|
// Find directory containing printer definition nodes
|
||||||
for (int32 i = 0; i < folder->CountJobs(); i ++) {
|
for (int32 i = 0; i < folder->CountJobs(); i++)
|
||||||
Job* job = folder->JobAt(i);
|
AddJob(folder->JobAt(i));
|
||||||
AddJob(job);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JobItem*
|
JobItem*
|
||||||
JobListView::Find(Job* job)
|
JobListView::FindJob(Job* job) const
|
||||||
{
|
{
|
||||||
const int32 n = CountItems();
|
const int32 n = CountItems();
|
||||||
for (int32 i = 0; i < n; i ++) {
|
for (int32 i = 0; i < n; i++) {
|
||||||
JobItem* item = dynamic_cast<JobItem*>(ItemAt(i));
|
JobItem* item = dynamic_cast<JobItem*>(ItemAt(i));
|
||||||
if (item && item->GetJob() == job)
|
if (item && item->GetJob() == job)
|
||||||
return item;
|
return item;
|
||||||
@ -98,18 +98,16 @@ JobListView::Find(Job* job)
|
|||||||
|
|
||||||
|
|
||||||
JobItem*
|
JobItem*
|
||||||
JobListView::SelectedItem()
|
JobListView::SelectedItem() const
|
||||||
{
|
{
|
||||||
BListItem* item = ItemAt(CurrentSelection());
|
return dynamic_cast<JobItem*>(ItemAt(CurrentSelection()));
|
||||||
return dynamic_cast<JobItem*>(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JobListView::AddJob(Job* job)
|
JobListView::AddJob(Job* job)
|
||||||
{
|
{
|
||||||
JobItem* item = new JobItem(job);
|
AddItem(new JobItem(job));
|
||||||
AddItem(item);
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ JobListView::AddJob(Job* job)
|
|||||||
void
|
void
|
||||||
JobListView::RemoveJob(Job* job)
|
JobListView::RemoveJob(Job* job)
|
||||||
{
|
{
|
||||||
JobItem* item = Find(job);
|
JobItem* item = FindJob(job);
|
||||||
if (item) {
|
if (item) {
|
||||||
RemoveItem(item);
|
RemoveItem(item);
|
||||||
delete item;
|
delete item;
|
||||||
@ -129,7 +127,7 @@ JobListView::RemoveJob(Job* job)
|
|||||||
void
|
void
|
||||||
JobListView::UpdateJob(Job* job)
|
JobListView::UpdateJob(Job* job)
|
||||||
{
|
{
|
||||||
JobItem* item = Find(job);
|
JobItem* item = FindJob(job);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->Update();
|
item->Update();
|
||||||
InvalidateItem(IndexOf(item));
|
InvalidateItem(IndexOf(item));
|
||||||
@ -176,6 +174,7 @@ JobItem::JobItem(Job* job)
|
|||||||
JobItem::~JobItem()
|
JobItem::~JobItem()
|
||||||
{
|
{
|
||||||
fJob->Release();
|
fJob->Release();
|
||||||
|
delete fIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -193,7 +192,17 @@ JobItem::Update()
|
|||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (fIcon == NULL && be_roster->FindApp(mimeType.String(), &ref) == B_OK) {
|
if (fIcon == NULL && be_roster->FindApp(mimeType.String(), &ref) == B_OK) {
|
||||||
fIcon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_CMAP8);
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
|
font_height fontHeight;
|
||||||
|
be_plain_font->GetHeight(&fontHeight);
|
||||||
|
float height = (fontHeight.ascent + fontHeight.descent
|
||||||
|
+ fontHeight.leading) * 2.0;
|
||||||
|
BRect rect(0.0, 0.0, height, height);
|
||||||
|
fIcon = new BBitmap(rect, B_RGBA32);
|
||||||
|
#else
|
||||||
|
BRect rect(0.0, 0.0, B_MINI_ICON - 1, B_MINI_ICON - 1);
|
||||||
|
fIcon = new BBitmap(rect, B_CMAP8);
|
||||||
|
#endif
|
||||||
BMimeType type(mimeType.String());
|
BMimeType type(mimeType.String());
|
||||||
if (type.GetIcon(fIcon, B_MINI_ICON) != B_OK) {
|
if (type.GetIcon(fIcon, B_MINI_ICON) != B_OK) {
|
||||||
delete fIcon;
|
delete fIcon;
|
||||||
@ -254,7 +263,7 @@ JobItem::Update(BView *owner, const BFont *font)
|
|||||||
font_height height;
|
font_height height;
|
||||||
font->GetHeight(&height);
|
font->GetHeight(&height);
|
||||||
|
|
||||||
SetHeight((height.ascent + height.descent + height.leading) * 2.0 + 4.0);
|
SetHeight((height.ascent + height.descent + height.leading) * 2.0 + 8.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -263,40 +272,52 @@ JobItem::DrawItem(BView *owner, BRect, bool complete)
|
|||||||
{
|
{
|
||||||
BListView* list = dynamic_cast<BListView*>(owner);
|
BListView* list = dynamic_cast<BListView*>(owner);
|
||||||
if (list) {
|
if (list) {
|
||||||
font_height height;
|
|
||||||
BFont font;
|
BFont font;
|
||||||
owner->GetFont(&font);
|
owner->GetFont(&font);
|
||||||
|
|
||||||
|
font_height height;
|
||||||
font.GetHeight(&height);
|
font.GetHeight(&height);
|
||||||
float fntheight = height.ascent+height.descent+height.leading;
|
float fntheight = height.ascent + height.descent + height.leading;
|
||||||
|
|
||||||
BRect bounds = list->ItemFrame(list->IndexOf(this));
|
BRect bounds = list->ItemFrame(list->IndexOf(this));
|
||||||
|
|
||||||
rgb_color color = owner->ViewColor();
|
rgb_color color = owner->ViewColor();
|
||||||
|
rgb_color oldViewColor = color;
|
||||||
|
rgb_color oldLowColor = owner->LowColor();
|
||||||
|
rgb_color oldHighColor = owner->HighColor();
|
||||||
|
|
||||||
if (IsSelected())
|
if (IsSelected())
|
||||||
color = tint_color(color, B_HIGHLIGHT_BACKGROUND_TINT);
|
color = tint_color(color, B_HIGHLIGHT_BACKGROUND_TINT);
|
||||||
|
|
||||||
rgb_color oldviewcolor = owner->ViewColor();
|
|
||||||
rgb_color oldlowcolor = owner->LowColor();
|
|
||||||
rgb_color oldcolor = owner->HighColor();
|
|
||||||
owner->SetViewColor(color);
|
owner->SetViewColor(color);
|
||||||
owner->SetHighColor(color);
|
owner->SetHighColor(color);
|
||||||
owner->SetLowColor(color);
|
owner->SetLowColor(color);
|
||||||
|
|
||||||
owner->FillRect(bounds);
|
owner->FillRect(bounds);
|
||||||
owner->SetLowColor(oldlowcolor);
|
|
||||||
owner->SetHighColor(oldcolor);
|
|
||||||
|
|
||||||
BPoint iconPt(bounds.LeftTop() + BPoint(2, 2));
|
owner->SetLowColor(oldLowColor);
|
||||||
BPoint leftTop(bounds.LeftTop() + BPoint(12 + B_MINI_ICON, 2));
|
owner->SetHighColor(oldHighColor);
|
||||||
BPoint namePt(leftTop + BPoint(0, fntheight));
|
|
||||||
BPoint statusPt(leftTop + BPoint(0, fntheight*2));
|
|
||||||
|
|
||||||
float width = owner->StringWidth(fPages.String());
|
BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0));
|
||||||
BPoint pagePt(bounds.RightTop() + BPoint(-width - 32, fntheight));
|
float iconHeight = B_MINI_ICON;
|
||||||
width = owner->StringWidth(fSize.String());
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
BPoint sizePt(bounds.RightTop() + BPoint(-width - 32, fntheight * 2));
|
if (fIcon)
|
||||||
|
iconHeight = fIcon->Bounds().Height();
|
||||||
|
#endif
|
||||||
|
BPoint leftTop(bounds.LeftTop() + BPoint(12.0 + iconHeight, 2.0));
|
||||||
|
BPoint namePt(leftTop + BPoint(0.0, fntheight));
|
||||||
|
BPoint statusPt(leftTop + BPoint(0.0, fntheight * 2.0));
|
||||||
|
|
||||||
|
float x = owner->StringWidth(fPages.String()) + 32.0;
|
||||||
|
BPoint pagePt(bounds.RightTop() + BPoint(-x, fntheight));
|
||||||
|
BPoint sizePt(bounds.RightTop() + BPoint(-x, fntheight * 2.0));
|
||||||
|
|
||||||
drawing_mode mode = owner->DrawingMode();
|
drawing_mode mode = owner->DrawingMode();
|
||||||
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
|
owner->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
#else
|
||||||
owner->SetDrawingMode(B_OP_OVER);
|
owner->SetDrawingMode(B_OP_OVER);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fIcon)
|
if (fIcon)
|
||||||
owner->DrawBitmap(fIcon, iconPt);
|
owner->DrawBitmap(fIcon, iconPt);
|
||||||
@ -310,6 +331,6 @@ JobItem::DrawItem(BView *owner, BRect, bool complete)
|
|||||||
owner->DrawString(fSize.String(), fSize.Length(), sizePt);
|
owner->DrawString(fSize.String(), fSize.Length(), sizePt);
|
||||||
|
|
||||||
owner->SetDrawingMode(mode);
|
owner->SetDrawingMode(mode);
|
||||||
owner->SetViewColor(oldviewcolor);
|
owner->SetViewColor(oldViewColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ class JobListView : public BListView
|
|||||||
typedef BListView Inherited;
|
typedef BListView Inherited;
|
||||||
public:
|
public:
|
||||||
JobListView(BRect frame);
|
JobListView(BRect frame);
|
||||||
|
~JobListView();
|
||||||
|
|
||||||
void AttachedToWindow();
|
void AttachedToWindow();
|
||||||
void SetSpoolFolder(SpoolFolder* folder);
|
void SetSpoolFolder(SpoolFolder* folder);
|
||||||
|
|
||||||
@ -53,13 +55,13 @@ public:
|
|||||||
void RemoveJob(Job* job);
|
void RemoveJob(Job* job);
|
||||||
void UpdateJob(Job* job);
|
void UpdateJob(Job* job);
|
||||||
|
|
||||||
JobItem* SelectedItem();
|
JobItem* SelectedItem() const;
|
||||||
|
|
||||||
void RestartJob();
|
void RestartJob();
|
||||||
void CancelJob();
|
void CancelJob();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JobItem* Find(Job* job);
|
JobItem* FindJob(Job* job) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ public:
|
|||||||
void Update(BView *owner, const BFont *font);
|
void Update(BView *owner, const BFont *font);
|
||||||
void DrawItem(BView *owner, BRect bounds, bool complete);
|
void DrawItem(BView *owner, BRect bounds, bool complete);
|
||||||
|
|
||||||
Job* GetJob() { return fJob; }
|
Job* GetJob() const { return fJob; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Job* fJob;
|
Job* fJob;
|
||||||
|
Loading…
Reference in New Issue
Block a user