bitmapped button added

This commit is contained in:
thrust26 2017-12-15 15:25:08 +01:00
parent ba3cc0677d
commit d28fb580b8
4 changed files with 67 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -408,6 +408,35 @@ void DebuggerDialog::addStatusArea()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::addRomArea()
{
static uInt32 LEFT_ARROW[11] =
{
0b0000010,
0b0000110,
0b0001110,
0b0011110,
0b0111110,
0b1111110,
0b0111110,
0b0011110,
0b0001110,
0b0000110,
0b0000010
};
static uInt32 RIGHT_ARROW[11] =
{
0b0100000,
0b0110000,
0b0111000,
0b0111100,
0b0111110,
0b0111111,
0b0111110,
0b0111100,
0b0111000,
0b0110000,
0b0100000
};
const GUI::Rect& r = getRomBounds();
const int VBORDER = 4;
const string ELLIPSIS = "\x1d";
@ -430,20 +459,23 @@ void DebuggerDialog::addRomArea()
new ButtonWidget(this, *myLFont, buttonX, buttonY,
bwidth, bheight, "Exit", kDDExitCmd);
bwidth = myLFont->getStringWidth("< ") + 4;
bwidth = bheight; // 7 + 12;
bheight = bheight * 3 + 4 * 2;
buttonX -= (bwidth + 5);
buttonY = r.top + 5;
myRewindButton =
new ButtonWidget(this, *myLFont, buttonX, buttonY,
bwidth, bheight, "<", kDDRewindCmd);
bwidth, bheight, LEFT_ARROW, 7, 11, kDDRewindCmd);
myRewindButton->clearFlags(WIDGET_ENABLED);
buttonY += bheight + 4;
bheight = (myLFont->getLineHeight() + 2) * 2 + 4 * 1;
myUnwindButton =
new ButtonWidget(this, *myLFont, buttonX, buttonY,
bwidth, bheight, ">", kDDUnwindCmd);
bwidth, bheight, RIGHT_ARROW, 7, 11, kDDUnwindCmd);
myUnwindButton->clearFlags(WIDGET_ENABLED);
int xpos = buttonX - 8*myLFont->getMaxCharWidth() - 20, ypos = 30;

View File

@ -343,7 +343,8 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
const string& label, int cmd)
: StaticTextWidget(boss, font, x, y, w, h, label, TextAlign::Center),
CommandSender(boss),
_cmd(cmd)
_cmd(cmd),
_useBitmap(false)
{
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_bgcolor = kBtnColor;
@ -370,6 +371,19 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
uInt32* bitmap, int bmw, int bmh,
int cmd)
: ButtonWidget(boss, font, x, y, w, h, "", cmd)
{
_bitmap = bitmap;
_bmh = bmh;
_bmw = bmw;
_useBitmap = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseEntered(int button)
{
@ -415,9 +429,15 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount)
void ButtonWidget::drawWidget(bool hilite)
{
FBSurface& s = _boss->dialog().surface();
s.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w,
!isEnabled() ? hilite ? uInt32(kColor) : uInt32(kBGColorLo) :
hilite ? _textcolorhi : _textcolor, _align);
if (!_useBitmap)
s.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w,
!isEnabled() ? hilite ? uInt32(kColor) : uInt32(kBGColorLo) :
hilite ? _textcolorhi : _textcolor, _align);
else
s.drawBitmap(_bitmap, _x + (_w - _bmw) / 2, _y + (_h - _bmh) / 2,
!isEnabled() ? hilite ? uInt32(kColor) : uInt32(kBGColorLo) :
hilite ? _textcolorhi : _textcolor,
_bmw, _bmh);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -217,6 +217,10 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y,
const string& label, int cmd = 0);
ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int dw, int dh,
uInt32* bitmap, int bmw, int bmh,
int cmd = 0);
void setCmd(int cmd) { _cmd = cmd; }
int getCmd() const { return _cmd; }
@ -230,7 +234,10 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
void drawWidget(bool hilite) override;
protected:
int _cmd;
int _cmd;
bool _useBitmap;
uInt32* _bitmap;
int _bmw, _bmh;
private:
// Following constructors and assignment operators not supported