#include "ChartView.h"
#include "ChartWindow.h"
ChartView::ChartView(BRect rect)
:
BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
{
}
void
ChartView::Draw(BRect rect)
{
ChartWindow *window = dynamic_cast<ChartWindow *>(Window());
if (window == NULL)
return;
if ((window->fOffscreen != 0) && (window->fCurrentSettings.display == DISPLAY_BITMAP))
DrawBitmap(window->fOffscreen, rect, rect);
}
void
ChartView::MouseDown(BPoint where)
{
Window()->PostMessage(BACK_DEMO_MSG);
}
InstantView::InstantView(BRect rect)
:
BView(rect, "", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
{
step = 5;
}
void
InstantView::Draw(BRect rect)
{
ChartWindow *window = dynamic_cast<ChartWindow *>(Window());
if (window == NULL)
return;
for (int32 i = 0; i < window->fInstantLoadLevel; i++) {
if (i < step)
SetHighColor(255, 90, 90);
else if ((i / step) & 1)
SetHighColor(90, 255, 90);
else
SetHighColor(40, 200, 40);
FillRect(BRect(3 + i * 4, 2, 5 + i * 4, 19));
}
Flush();
}
ChartColorControl::ChartColorControl(BPoint start, BMessage *message)
:
BColorControl(start, B_CELLS_32x8, 8.0, "", message)
{
}
void
ChartColorControl::SetValue(int32 colorValue)
{
BLooper *looper;
BColorControl::SetValue(colorValue);
Target(&looper);
if (looper) {
BMessage msg(*Message());
msg.AddInt32("be:value", colorValue);
looper->PostMessage(&msg);
}
}