X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fpushbutton.cpp;fp=src%2Fgui%2Fpushbutton.cpp;h=738b3ac997ac90e97e6da7f6c6062946b4fcd25f;hb=f9098d0570ae6462781e8189518085cb1c8c00ef;hp=0000000000000000000000000000000000000000;hpb=836c7fa1f3e2dc3ec9849cac2584d4544bf2fba4;p=virtualjaguar diff --git a/src/gui/pushbutton.cpp b/src/gui/pushbutton.cpp new file mode 100644 index 0000000..738b3ac --- /dev/null +++ b/src/gui/pushbutton.cpp @@ -0,0 +1,38 @@ +// +// PushButton class +// +// by James L. Hammons +// + +#include "pushbutton.h" + +#include "guimisc.h" + +PushButton::PushButton(uint32 x, uint32 y, bool * st, std::string s): + Element(x, y, 16, 16), state(st), inside(false), text(s) +{ + if (st == NULL) + state = &internalState; +} + +void PushButton::HandleMouseMove(uint32 x, uint32 y) +{ + inside = Inside(x, y); +} + +void PushButton::HandleMouseButton(uint32 x, uint32 y, bool mouseDown) +{ + if (inside && mouseDown) + *state = !(*state); +} + +void PushButton::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/) +{ + if (*state) + DrawTransparentBitmap(screenBuffer, extents.x + offsetX, extents.y + offsetY, &pbDown); + else + DrawTransparentBitmap(screenBuffer, extents.x + offsetX, extents.y + offsetY, &pbUp); + + if (text.length() > 0) + DrawString(screenBuffer, extents.x + offsetX + 24, extents.y + offsetY, false, "%s", text.c_str()); +}