/* * Implementation of paintbutton.h. */ #include "map.h" #include #include #include PaintedPushButton::PaintedPushButton(Bitmap* bm, ButtonState* bs, int value) : PushButton("x", bs, value) { this->bm = bm; Init(); } PaintedPushButton::PaintedPushButton( const char* filename, ButtonState* bs, int value) : PushButton("", bs, value) { bm = new Bitmap(filename); Init(); } void PaintedPushButton::Init() { } /* * Manually reconfig shape to the size of the contained bitmap. NOTE WELL: We * die a very unhappy death if we don't call PushButton::Reconfig (q.v), since * it does the output stuff. */ void PaintedPushButton::Reconfig() { Interactor::Reconfig(); if (output != highlight && output != normal) { highlight = new Painter(output); highlight->Reference(); highlight->SetColors(output->GetBgColor(), output->GetFgColor()); } normal = output; shape->Rect(bm->Width(), bm->Height()); shape->Rigid(); } /* * Stencil in the bitmap for the widget panel item. */ void PaintedPushButton::Redraw(Coord l, Coord b, Coord r, Coord t) { output->ClearRect(canvas, l, b, r, t); PaintedPushButton::Refresh(); } void PaintedPushButton::Refresh() { output = (chosen || hit) ? highlight : normal; output->Stencil(canvas, 0, 0, bm, nil); }