X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fbutton.cpp;fp=src%2Fgui%2Fbutton.cpp;h=0000000000000000000000000000000000000000;hb=94e1e961b57f253b760298ab0bae96a7de6d20fa;hp=052d19c2c3aac94621ba45107ac849c3942b017d;hpb=f95620384355f3db89f779e1e7be59260ecfc6ff;p=virtualjaguar diff --git a/src/gui/button.cpp b/src/gui/button.cpp deleted file mode 100644 index 052d19c..0000000 --- a/src/gui/button.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// -// Button class -// -// by James L. Hammons -// - -#include "button.h" - -//#include "font14pt.h" -#include "guimisc.h" - -// Various constructors - -Button::Button(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/): - Element(x, y, w, h), activated(false), clicked(false), inside(false), - fgColor(0xFFFFFFFF), bgColor(0xFF00FF00), pic(NULL), elementToTell(NULL) -{ -} - -Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, uint32 * p): - Element(x, y, w, h), activated(false), clicked(false), inside(false), - fgColor(0xFFFFFFFF), bgColor(0xFF00FF00), pic(p), elementToTell(NULL) -{ -} - -// Button::Button(uint32 x, uint32 y, uint32 * p): Element(x, y, 0, 0), - -Button::Button(uint32 x, uint32 y, uint32 * p, uint32 * pH/*= NULL*/, uint32 * pD/*= NULL*/): - Element(x, y, 0, 0), activated(false), clicked(false), inside(false), - fgColor(0xFFFFFFFF), bgColor(0xFF00FF00), pic(p), picHover(pH), picDown(pD), - elementToTell(NULL) -{ - if (pic) - extents.w = pic[0], extents.h = pic[1]; -} - -Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, std::string s): - Element(x, y, w, h), activated(false), clicked(false), inside(false), - fgColor(0xFFFFFFFF), bgColor(0xFF00FF00), pic(NULL), text(s), elementToTell(NULL) -{ -} - -Button::Button(uint32 x, uint32 y, std::string s): - Element(x, y, 0, FONT_HEIGHT), activated(false), clicked(false), inside(false), - fgColor(0xFFFFFFFF), bgColor(0xFF00FF00), pic(NULL), text(s), elementToTell(NULL) -{ - extents.w = s.length() * FONT_WIDTH; -} - -// Implementation - -void Button::HandleMouseMove(uint32 x, uint32 y) -{ - inside = Inside(x, y); -} - -void Button::HandleMouseButton(uint32 x, uint32 y, bool mouseDown) -{ - if (inside) - { - if (mouseDown) - clicked = true; - - if (clicked && !mouseDown) - { - clicked = false, activated = true; - - // Send a message that we're activated (if there's someone to tell, that is) - if (elementToTell) - elementToTell->Notify(this); - } - } - else - clicked = activated = false; -} - -void Button::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/) -{ - uint32 addr = (extents.x + offsetX) + ((extents.y + offsetY) * pitch); - - if (text.length() > 0) // Simple text button -// if (pic == NULL) - { - for(uint32 y=0; y 010000 11111 10000 -> 0100 0001 1111 1111 1000 0100 -> 41 FF 84 - = (clicked && inside ? fgColor : (inside ? 0xFF84FF41 : bgColor)); - } - } - - DrawString(screenBuffer, extents.x + offsetX, extents.y + offsetY, false, "%s", text.c_str()); - } - else // Graphical button - { - uint32 * picToShow = pic; - - if (picHover != NULL && inside && !clicked) - picToShow = picHover; - - if (picDown != NULL && inside && clicked) - picToShow = picDown; - - DrawTransparentBitmapDeprecated(screenBuffer, extents.x + offsetX, extents.y + offsetY, picToShow); - } -} - -bool Button::ButtonClicked(void) -{ - return activated; -} - -void Button::SetNotificationElement(Element * e) -{ - elementToTell = e; -}