X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fslideswitch.cpp;fp=src%2Fgui%2Fslideswitch.cpp;h=fcf05201ef67c25574a3d5a6436986922bdedba8;hb=f9098d0570ae6462781e8189518085cb1c8c00ef;hp=0000000000000000000000000000000000000000;hpb=836c7fa1f3e2dc3ec9849cac2584d4544bf2fba4;p=virtualjaguar diff --git a/src/gui/slideswitch.cpp b/src/gui/slideswitch.cpp new file mode 100644 index 0000000..fcf0520 --- /dev/null +++ b/src/gui/slideswitch.cpp @@ -0,0 +1,38 @@ +// +// SlideSwitch class +// +// by James L. Hammons +// + +#include "slideswitch.h" + +#include "guimisc.h" + +SlideSwitch::SlideSwitch(uint32 x, uint32 y, bool * st, std::string s1, std::string s2): + Element(x, y, 16, 32), state(st), inside(false), text1(s1), text2(s2) +{ +} + +void SlideSwitch::HandleMouseMove(uint32 x, uint32 y) +{ + inside = Inside(x, y); +} + +void SlideSwitch::HandleMouseButton(uint32 x, uint32 y, bool mouseDown) +{ + if (inside && mouseDown) + { + *state = !(*state); + } +} + +void SlideSwitch::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/) +{ + DrawTransparentBitmapDeprecated(screenBuffer, extents.x + offsetX, extents.y + offsetY, (*state ? slideSwitchDown : slideSwitchUp)); + + if (text1.length() > 0) + DrawString(screenBuffer, extents.x + offsetX + 24, extents.y + offsetY, false, "%s", text1.c_str()); + + if (text2.length() > 0) + DrawString(screenBuffer, extents.x + offsetX + 24, extents.y + offsetY + 16, false, "%s", text2.c_str()); +}