summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-04-12 22:12:27 +0000
committerpeter1138 <peter1138@openttd.org>2008-04-12 22:12:27 +0000
commit66783add65831ff12c1fe54ef33f1a842f27d4e3 (patch)
tree0109cdbf06c952b8c6219fa3e180b65741dc1a8e /src
parent5d755429b49ada9dc50069504d44025fabff5b4c (diff)
downloadopenttd-66783add65831ff12c1fe54ef33f1a842f27d4e3.tar.xz
(svn r12675) -Codechange: Add support for custom drawing of drop down list items.
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dropdown.cpp7
-rw-r--r--src/widgets/dropdown_type.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 90b57730f..251c01ca0 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -36,6 +36,11 @@ StringID DropDownListParamStringItem::String() const
return this->string;
}
+void DropDownListItem::Draw(int x, int y, uint width, uint height, bool sel) const
+{
+ DrawStringTruncated(x + 2, y, this->String(), sel ? TC_WHITE : TC_BLACK, x + width);
+}
+
/**
* Delete all items of a drop down list and the list itself
* @param list List to delete.
@@ -122,7 +127,7 @@ static void DropDownMenuWndProc(Window *w, WindowEvent *e)
if (item->String() != STR_NULL) {
if (sel == item->result) GfxFillRect(x + 1, y, x + width, y + item_height - 1, 0);
- DrawStringTruncated(x + 2, y, item->String(), sel == item->result ? TC_WHITE : TC_BLACK, x + width);
+ item->Draw(x, y, width, 10, sel == item->result);
if (item->masked) {
GfxFillRect(x, y, x + width, y + item_height - 1,
diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h
index 859b331d2..a93cbb360 100644
--- a/src/widgets/dropdown_type.h
+++ b/src/widgets/dropdown_type.h
@@ -19,6 +19,7 @@ public:
virtual ~DropDownListItem() {}
virtual StringID String() const;
virtual uint Height(uint width) const;
+ virtual void Draw(int x, int y, uint width, uint height, bool sel) const;
};
/**