diff --git a/src/common/FBSurfaceGL.cxx b/src/common/FBSurfaceGL.cxx index ca902be03..8f96a0862 100644 --- a/src/common/FBSurfaceGL.cxx +++ b/src/common/FBSurfaceGL.cxx @@ -99,10 +99,10 @@ void FBSurfaceGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurfaceGL::drawChar(const GUI::Font* font, uInt8 chr, +void FBSurfaceGL::drawChar(const GUI::Font& font, uInt8 chr, uInt32 tx, uInt32 ty, uInt32 color) { - const FontDesc& desc = font->desc(); + const FontDesc& desc = font.desc(); // If this character is not included in the font, use the default char. if(chr < desc.firstchar || chr >= desc.firstchar + desc.size) diff --git a/src/common/FBSurfaceGL.hxx b/src/common/FBSurfaceGL.hxx index 3f1f23114..cba39f78a 100644 --- a/src/common/FBSurfaceGL.hxx +++ b/src/common/FBSurfaceGL.hxx @@ -44,7 +44,7 @@ class FBSurfaceGL : public FBSurface void hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color); void vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color); void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color); - void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, uInt32 color); + void drawChar(const GUI::Font& font, uInt8 c, uInt32 x, uInt32 y, uInt32 color); void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, uInt32 color, uInt32 h = 8); void drawPixels(uInt32* data, uInt32 x, uInt32 y, uInt32 numpixels); void drawSurface(const FBSurface* surface, uInt32 x, uInt32 y); diff --git a/src/common/FrameBufferSoft.cxx b/src/common/FrameBufferSoft.cxx index 51b811cea..84e1e8d41 100644 --- a/src/common/FrameBufferSoft.cxx +++ b/src/common/FrameBufferSoft.cxx @@ -587,10 +587,10 @@ void FBSurfaceSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 colo } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr, +void FBSurfaceSoft::drawChar(const GUI::Font& font, uInt8 chr, uInt32 tx, uInt32 ty, uInt32 color) { - const FontDesc& desc = font->desc(); + const FontDesc& desc = font.desc(); // If this character is not included in the font, use the default char. if(chr < desc.firstchar || chr >= desc.firstchar + desc.size) diff --git a/src/common/FrameBufferSoft.hxx b/src/common/FrameBufferSoft.hxx index e8800fe8f..8b6d72cb3 100644 --- a/src/common/FrameBufferSoft.hxx +++ b/src/common/FrameBufferSoft.hxx @@ -196,7 +196,7 @@ class FBSurfaceSoft : public FBSurface void hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color); void vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color); void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color); - void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, uInt32 color); + void drawChar(const GUI::Font& font, uInt8 c, uInt32 x, uInt32 y, uInt32 color); void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, uInt32 color, uInt32 h = 8); void drawPixels(uInt32* data, uInt32 x, uInt32 y, uInt32 numpixels); void drawSurface(const FBSurface* surface, uInt32 x, uInt32 y); diff --git a/src/debugger/gui/DataGridOpsWidget.cxx b/src/debugger/gui/DataGridOpsWidget.cxx index 66ee1957a..1980d0d7b 100644 --- a/src/debugger/gui/DataGridOpsWidget.cxx +++ b/src/debugger/gui/DataGridOpsWidget.cxx @@ -37,8 +37,8 @@ DataGridOpsWidget::DataGridOpsWidget(GuiObject* boss, const GUI::Font& font, { _type = kDataGridOpsWidget; - const int bwidth = _font->getMaxCharWidth() * 4, - bheight = _font->getFontHeight() + 3, + const int bwidth = _font.getMaxCharWidth() * 4, + bheight = _font.getFontHeight() + 3, space = 6; int xpos, ypos; diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index c23c78f8a..ddb90bcc1 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -104,7 +104,7 @@ void PromptWidget::drawWidget(bool hilite) } else { fgcolor = c >> 8; } - s.drawChar(&instance().consoleFont(), c & 0x7f, x, y, fgcolor); + s.drawChar(instance().consoleFont(), c & 0x7f, x, y, fgcolor); x += _kConsoleCharWidth; } y += _kConsoleLineHeight; @@ -833,7 +833,7 @@ void PromptWidget::drawCaret() char c = buffer(_currentPos); s.fillRect(x, y, _kConsoleCharWidth, _kConsoleLineHeight, kTextColor); - s.drawChar(&_boss->instance().consoleFont(), c, x, y + 2, kBGColor); + s.drawChar(_boss->instance().consoleFont(), c, x, y + 2, kBGColor); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 360731804..8964d3784 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -221,9 +221,9 @@ void FrameBuffer::update() myOSystem->console().tia().scanlines(), myOSystem->console().getFramerate(), info.DisplayFormat.c_str()); myStatsMsg.surface->fillRect(0, 0, myStatsMsg.w, myStatsMsg.h, kBGColor); - myStatsMsg.surface->drawString(&myOSystem->consoleFont(), + myStatsMsg.surface->drawString(myOSystem->consoleFont(), msg, 1, 1, myStatsMsg.w, myStatsMsg.color, kTextAlignLeft); - myStatsMsg.surface->drawString(&myOSystem->consoleFont(), + myStatsMsg.surface->drawString(myOSystem->consoleFont(), info.BankSwitch, 1, 15, myStatsMsg.w, myStatsMsg.color, kTextAlignLeft); myStatsMsg.surface->addDirtyRect(0, 0, 0, 0); // force a full draw myStatsMsg.surface->setPos(myImageRect.x() + 1, myImageRect.y() + 1); @@ -414,7 +414,7 @@ inline void FrameBuffer::drawMessage() myMsg.surface->setPos(myMsg.x + myImageRect.x(), myMsg.y + myImageRect.y()); myMsg.surface->fillRect(1, 1, myMsg.w-2, myMsg.h-2, kBtnColor); myMsg.surface->box(0, 0, myMsg.w, myMsg.h, kColor, kShadowColor); - myMsg.surface->drawString(&myOSystem->font(), myMsg.text, 4, 4, + myMsg.surface->drawString(myOSystem->font(), myMsg.text, 4, 4, myMsg.w, myMsg.color, kTextAlignLeft); myMsg.counter--; @@ -1275,14 +1275,14 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::drawString(const GUI::Font* font, const string& s, +void FBSurface::drawString(const GUI::Font& font, const string& s, int x, int y, int w, uInt32 color, TextAlignment align, int deltax, bool useEllipsis) { const int leftX = x, rightX = x + w; unsigned int i; - int width = font->getStringWidth(s); + int width = font.getStringWidth(s); string str; if(useEllipsis && width > w) @@ -1293,7 +1293,7 @@ void FBSurface::drawString(const GUI::Font* font, const string& s, // What is best really depends on the context; but unless we want to // make this configurable, replacing the middle probably is a good // compromise. - const int ellipsisWidth = font->getStringWidth("..."); + const int ellipsisWidth = font.getStringWidth("..."); // SLOW algorithm to remove enough of the middle. But it is good enough for now. const int halfWidth = (w - ellipsisWidth) / 2; @@ -1301,7 +1301,7 @@ void FBSurface::drawString(const GUI::Font* font, const string& s, for(i = 0; i < s.size(); ++i) { - int charWidth = font->getCharWidth(s[i]); + int charWidth = font.getCharWidth(s[i]); if(w2 + charWidth > halfWidth) break; @@ -1321,13 +1321,13 @@ void FBSurface::drawString(const GUI::Font* font, const string& s, // (width + ellipsisWidth - w) int skip = width + ellipsisWidth - w; for(; i < s.size() && skip > 0; ++i) - skip -= font->getCharWidth(s[i]); + skip -= font.getCharWidth(s[i]); // Append the remaining chars, if any for(; i < s.size(); ++i) str += s[i]; - width = font->getStringWidth(str); + width = font.getStringWidth(str); } else str = s; @@ -1340,7 +1340,7 @@ void FBSurface::drawString(const GUI::Font* font, const string& s, x += deltax; for(i = 0; i < str.size(); ++i) { - w = font->getCharWidth(str[i]); + w = font.getCharWidth(str[i]); if(x+w > rightX) break; if(x >= leftX) diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index ffa39cba5..c35c94bbc 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -684,7 +684,7 @@ class FBSurface @param y The y coordinate @param color The color of the character */ - virtual void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, + virtual void drawChar(const GUI::Font& font, uInt8 c, uInt32 x, uInt32 y, uInt32 color) { } /** @@ -825,7 +825,7 @@ class FBSurface @param useEllipsis Whether to use '...' when the string is too long */ virtual void drawString( - const GUI::Font* font, const string& str, int x, int y, int w, + const GUI::Font& font, const string& str, int x, int y, int w, uInt32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true); }; diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index e94ec3b21..f9c494b4f 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -41,7 +41,7 @@ ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font, _isScrolling(false), _scrollUpColor(kColor), _scrollDnColor(kColor), - _font(&font), + _font(font), _cmd(cmd), _xorig(0), _yorig(0) @@ -65,7 +65,7 @@ void ContextMenu::addItems(const StringMap& items) int maxwidth = 0; for(unsigned int i = 0; i < _entries.size(); ++i) { - int length = _font->getStringWidth(_entries[i].first); + int length = _font.getStringWidth(_entries[i].first); if(length > maxwidth) maxwidth = length; } diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 76536fd34..35d29f726 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -106,7 +106,7 @@ class ContextMenu : public Dialog, public CommandSender bool _isScrolling; uInt32 _scrollUpColor, _scrollDnColor; - const GUI::Font* _font; + const GUI::Font& _font; int _cmd; uInt32 _xorig, _yorig; diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index 1f5d88456..98ed3ea56 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -62,7 +62,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) for (i = 0; i < _editString.size(); ++i) { - width += _font->getCharWidth(_editString[i]); + width += _font.getCharWidth(_editString[i]); if (width >= x) break; } diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 21a1d8774..f43532408 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -58,7 +58,7 @@ void EditableWidget::setEditString(const string& str, bool) _editString = str; _caretPos = _editString.size(); - _editScrollOffset = (_font->getStringWidth(_editString) - (getEditRect().width())); + _editScrollOffset = (_font.getStringWidth(_editString) - (getEditRect().width())); if (_editScrollOffset < 0) _editScrollOffset = 0; @@ -177,7 +177,7 @@ int EditableWidget::getCaretOffset() const { int caretpos = 0; for (int i = 0; i < _caretPos; i++) - caretpos += _font->getCharWidth(_editString[i]); + caretpos += _font.getCharWidth(_editString[i]); caretpos -= _editScrollOffset; @@ -238,7 +238,7 @@ bool EditableWidget::adjustOffset() } else if (_editScrollOffset > 0) { - const int strWidth = _font->getStringWidth(_editString); + const int strWidth = _font.getStringWidth(_editString); if (strWidth - _editScrollOffset < editWidth) { // scroll right diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 2b4fa990d..522e0c140 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -59,12 +59,12 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, _textcolorhi = kTextColor; if(!_label.empty() && _labelWidth == 0) - _labelWidth = _font->getStringWidth(_label); + _labelWidth = _font.getStringWidth(_label); _w = w + _labelWidth + 15; // vertically center the arrows and text - myTextY = (_h - _font->getFontHeight()) / 2; + myTextY = (_h - _font.getFontHeight()) / 2; myArrowsY = (_h - 8) / 2; myMenu = new ContextMenu(this, font, list, cmd); @@ -147,7 +147,7 @@ void PopUpWidget::drawWidget(bool hilite) // Draw the selected entry, if any const string& name = myMenu->getSelectedName(); - TextAlignment align = (_font->getStringWidth(name) > w-6) ? + TextAlignment align = (_font.getStringWidth(name) > w-6) ? kTextAlignRight : kTextAlignLeft; s.drawString(_font, name, x+2, _y+myTextY, w-6, !isEnabled() ? kColor : kTextColor, align); diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index d645b7a85..715b8cae7 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -155,16 +155,16 @@ void RomInfoWidget::drawWidget(bool hilite) } else if(mySurfaceErrorMsg != "") { - const GUI::Font* font = &instance().font(); - uInt32 x = _x + ((_w - font->getStringWidth(mySurfaceErrorMsg)) >> 1); - uInt32 y = _y + ((yoff - font->getLineHeight()) >> 1); + const GUI::Font& font = instance().font(); + uInt32 x = _x + ((_w - font.getStringWidth(mySurfaceErrorMsg)) >> 1); + uInt32 y = _y + ((yoff - font.getLineHeight()) >> 1); s.drawString(font, mySurfaceErrorMsg, x, y, _w - 10, _textcolor); } int xpos = _x + 5, ypos = _y + yoff + 10; for(unsigned int i = 0; i < myRomInfo.size(); ++i) { s.drawString(_font, myRomInfo[i], xpos, ypos, _w - 10, _textcolor); - ypos += _font->getLineHeight(); + ypos += _font.getLineHeight(); } } diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 3b5b7b799..e14a5f953 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -121,7 +121,7 @@ GUI::Rect StringListWidget::getEditRect() const char temp[10]; // FIXME: Assumes that all digits have the same width. BSPF_snprintf(temp, 9, "%2d. ", (_list.size() - 1 + _numberingMode)); - r.left += _font->getStringWidth(temp); + r.left += _font.getStringWidth(temp); } return r; diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index 750f27cbc..64a265f5d 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -82,7 +82,7 @@ int TabWidget::addTab(const string& title) int numTabs = _tabs.size(); // Determine the new tab width - int newWidth = _font->getStringWidth(title) + 2 * kTabPadding; + int newWidth = _font.getStringWidth(title) + 2 * kTabPadding; if (_tabWidth < newWidth) _tabWidth = newWidth; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 2e25f2a5d..e428b9806 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -39,7 +39,7 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font, : GuiObject(boss->instance(), boss->parent(), boss->dialog(), x, y, w, h), _type(0), _boss(boss), - _font((GUI::Font*)&font), + _font(font), _id(-1), _flags(0), _hasFocus(false), @@ -52,8 +52,8 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font, _next = _boss->_firstWidget; _boss->_firstWidget = this; - _fontWidth = _font->getMaxCharWidth(); - _fontHeight = _font->getLineHeight(); + _fontWidth = _font.getMaxCharWidth(); + _fontHeight = _font.getLineHeight(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -182,37 +182,23 @@ Widget* Widget::findWidgetInChain(Widget *w, int x, int y) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Widget::isWidgetInChain(Widget* w, Widget* find) { - bool found = false; - while(w) { // Stop as soon as we find the widget - if(w == find) - { - found = true; - break; - } + if(w == find) return true; w = w->_next; } - - return found; + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Widget::isWidgetInChain(WidgetArray& list, Widget* find) { - bool found = false; - for(int i = 0; i < (int)list.size(); ++i) - { if(list[i] == find) - { - found = true; - break; - } - } + return true; - return found; + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -469,7 +455,7 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font, if(_h > 14) // center box _boxY = (_h - 14) / 2; else // center text - _textY = (14 - _font->getFontHeight()) / 2; + _textY = (14 - _font.getFontHeight()) / 2; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -546,7 +532,7 @@ SliderWidget::SliderWidget(GuiObject *boss, const GUI::Font& font, _bgcolorhi = kDlgColor; if(!_label.empty() && _labelWidth == 0) - _labelWidth = _font->getStringWidth(_label); + _labelWidth = _font.getStringWidth(_label); _w = w + _labelWidth; } diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index a2d593f4a..6d322d945 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -133,9 +133,9 @@ class Widget : public GuiObject bool wantsRaw() const { return _flags & WIDGET_WANTS_RAWDATA; } void setID(int id) { _id = id; } - int getID() { return _id; } + int getID() const { return _id; } - virtual const GUI::Font* font() { return _font; } + virtual const GUI::Font& font() const { return _font; } void setTextColor(uInt32 color) { _textcolor = color; } void setTextColorHi(uInt32 color) { _textcolorhi = color; } @@ -161,7 +161,7 @@ class Widget : public GuiObject protected: int _type; GuiObject* _boss; - GUI::Font* _font; + const GUI::Font& _font; Widget* _next; int _id; int _flags;