[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.h,1.31,1.32 editable.cpp,1.2,1.3 editable.h,1.2,1.3
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Mon May 16 17:39:57 CEST 2005
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23538
Modified Files:
ListWidget.h editable.cpp editable.h
Log Message:
Fixed drawing of the caret. (It was drawn using the GUI font, rather than
the widget's font.)
Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- ListWidget.h 15 May 2005 18:22:44 -0000 1.31
+++ ListWidget.h 16 May 2005 13:43:30 -0000 1.32
@@ -57,7 +57,6 @@
ScrollBarWidget *_scrollBar;
int _currentKeyDown;
int _lineHeight;
- const Graphics::Font *_font;
String _quickSelectStr;
uint32 _quickSelectTime;
Index: editable.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/editable.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- editable.cpp 29 Jan 2005 18:04:34 -0000 1.2
+++ editable.cpp 16 May 2005 13:43:31 -0000 1.3
@@ -34,6 +34,8 @@
_caretInverse = false;
_editScrollOffset = 0;
+
+ _font = &(g_gui.getFont()); // Most widgets will probably set this to something else.
}
EditableWidget::~EditableWidget() {
@@ -45,7 +47,7 @@
_editString = str;
_caretPos = _editString.size();
- _editScrollOffset = (g_gui.getStringWidth(_editString) - (getEditRect().width()));
+ _editScrollOffset = (_font->getStringWidth(_editString) - (getEditRect().width()));
if (_editScrollOffset < 0)
_editScrollOffset = 0;
}
@@ -130,7 +132,7 @@
int EditableWidget::getCaretOffset() const {
int caretpos = 0;
for (int i = 0; i < _caretPos; i++)
- caretpos += g_gui.getCharWidth(_editString[i]);
+ caretpos += _font->getCharWidth(_editString[i]);
caretpos -= _editScrollOffset;
@@ -142,20 +144,22 @@
if (!isVisible() || !_boss->isVisible())
return;
+ Common::Rect editRect = getEditRect();
+
int16 color = (erase ^ _caretInverse) ? g_gui._bgcolor : g_gui._textcolorhi;
- int x = getEditRect().left;
- int y = getEditRect().top;
+ int x = editRect.left;
+ int y = editRect.top;
x += getCaretOffset();
- if (y < 0 || y + kLineHeight >= _h)
+ if (y < 0 || y + editRect.height() >= _h)
return;
x += getAbsX();
y += getAbsY();
- g_gui.vLine(x, y, y + kLineHeight, color);
- g_gui.addDirtyRect(x, y, 2, kLineHeight);
+ g_gui.vLine(x, y, y + editRect.height(), color);
+ g_gui.addDirtyRect(x, y, 2, editRect.height());
_caretVisible = !erase;
}
@@ -182,7 +186,7 @@
_editScrollOffset -= (editWidth - caretpos);
return true;
} else if (_editScrollOffset > 0) {
- const int strWidth = g_gui.getStringWidth(_editString);
+ const int strWidth = _font->getStringWidth(_editString);
if (strWidth - _editScrollOffset < editWidth) {
// scroll right
_editScrollOffset = (strWidth - editWidth);
Index: editable.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/editable.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- editable.h 29 Jan 2005 18:04:34 -0000 1.2
+++ editable.h 16 May 2005 13:43:31 -0000 1.3
@@ -35,6 +35,7 @@
public:
typedef Common::String String;
protected:
+ const Graphics::Font *_font;
String _editString;
bool _caretVisible;
More information about the Scummvm-git-logs
mailing list