31 #include "util/log/logger.h"
33 #include "twobutton.h"
38 TwoButton::TwoButton(Image *up_file , Image *down_file, Image *hover_file,
const std::string& caption):
41 m_downImage(down_file),
42 m_hoverImage(hover_file),
45 m_hoverImage = hover_file;
51 TwoButton::~TwoButton() {
54 void TwoButton::setDownOffset(int32_t x, int32_t y) {
59 void TwoButton::draw(Graphics *graphics) {
60 Image* img = m_upImage;
67 xoffset = x_downoffset;
68 yoffset = y_downoffset;
70 }
else if(mHasMouse) {
77 graphics->drawImage(img, xoffset, yoffset);
80 graphics->setColor(getForegroundColor());
82 int32_t textY = getHeight() / 2 - getFont()->getHeight() / 2;
83 switch (getAlignment())
88 case Graphics::CENTER:
89 textX = getWidth() / 2;
92 textX = getWidth() - 4;
96 FL_WARN(_log,
FIFE::LMsg(
"TwoButton::draw() - ") <<
"Unknown alignment: "
97 << getAlignment() <<
". Using the default of Graphics::LEFT");
100 graphics->setFont(getFont());
101 if (mCaption.size() > 0) {
103 graphics->drawText(getCaption(), textX + 1,
104 textY + 1, getAlignment());
106 graphics->drawText(getCaption(), textX, textY, getAlignment());
109 void TwoButton::adjustSize() {
113 w = m_upImage->getWidth();
114 h = m_upImage->getHeight();
117 w = std::max(m_downImage->getWidth(), w);
118 h = std::max(m_downImage->getHeight(), h);
121 w = std::max(m_hoverImage->getWidth(), w);
122 h = std::max(m_hoverImage->getHeight(), h);
127 void TwoButton::setUpImage(Image* image) {
131 void TwoButton::setDownImage(Image* image) {
135 void TwoButton::setHoverImage(Image* image) {
136 m_hoverImage = image;