2008-10-01 08:28:35 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2000-2008, François Revol, <revol@free.fr>. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
2008-01-11 21:06:15 +03:00
|
|
|
#include "ViewItem.h"
|
|
|
|
#include <View.h>
|
|
|
|
#include <Font.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <Debug.h>
|
|
|
|
|
2008-10-01 07:37:33 +04:00
|
|
|
|
|
|
|
ViewItem::ViewItem(BRect bounds, const char *name,
|
|
|
|
uint32 resizeMask, uint32 flags, uint32 level, bool expanded)
|
2008-01-11 21:06:15 +03:00
|
|
|
: BView(bounds, name, resizeMask, flags), BListItem(level, expanded)
|
|
|
|
{
|
|
|
|
fOwner = NULL;
|
|
|
|
SetWidth(bounds.Width());
|
|
|
|
SetHeight(bounds.Height());
|
|
|
|
}
|
|
|
|
|
2008-10-01 07:37:33 +04:00
|
|
|
|
2008-01-11 21:06:15 +03:00
|
|
|
ViewItem::~ViewItem()
|
|
|
|
{
|
|
|
|
if (fOwner)
|
|
|
|
fOwner->RemoveChild(this);
|
|
|
|
}
|
|
|
|
|
2008-10-01 07:37:33 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
ViewItem::DrawItem(BView *ownerview, BRect frame, bool complete)
|
2008-01-11 21:06:15 +03:00
|
|
|
{
|
|
|
|
(void)frame; (void)complete;
|
|
|
|
if (!fOwner) {
|
|
|
|
fOwner = dynamic_cast<BListView *>(ownerview);
|
|
|
|
if (!ownerview)
|
|
|
|
return;
|
|
|
|
ownerview->AddChild(this);
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
const BListItem **list = fOwner->Items();
|
|
|
|
for (long i = 0; i < fOwner->CountItems(); i++) {
|
|
|
|
if (list[i] == this) {
|
|
|
|
BRect frame(fOwner->ItemFrame(i));
|
|
|
|
//ResizeTo(frame.Width(), frame.Height());
|
|
|
|
//MoveTo(frame.left, frame.top);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
//BListItem::DrawItem(ownerview, frame, complete);
|
|
|
|
}
|
|
|
|
|
2008-10-01 07:37:33 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
ViewItem::Update(BView *ownerview, const BFont *font)
|
2008-01-11 21:06:15 +03:00
|
|
|
{
|
|
|
|
PRINT(("ViewItem::Update()\n"));
|
|
|
|
(void)font;
|
|
|
|
if (!fOwner) {
|
|
|
|
fOwner = dynamic_cast<BListView *>(ownerview);
|
|
|
|
if (!ownerview)
|
|
|
|
return;
|
|
|
|
PRINT(("ViewItem::Update(), fOwner=%p\n", fOwner));
|
|
|
|
fOwner->AddChild(this);
|
|
|
|
}
|
|
|
|
//BListItem::Update(ownerview, font);
|
|
|
|
const BListItem **list = fOwner->Items();
|
|
|
|
for (long i = 0; i < fOwner->CountItems(); i++) {
|
|
|
|
if (list[i] == this) {
|
|
|
|
BRect frame(fOwner->ItemFrame(i));
|
|
|
|
ResizeTo(frame.Width(), Bounds().Height());
|
|
|
|
MoveTo(frame.left, frame.top);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetWidth(Bounds().Width());
|
|
|
|
SetHeight(Bounds().Height());
|
|
|
|
}
|
|
|
|
|