From 04da1e1d456322d07e941ca19d35e9dc1020faf1 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 18 Jan 2008 10:36:55 +0000 Subject: (svn r11915) -Codechange: Add a function to draw a sort button's up/down arrow. Arrows are now drawn in a consistent position based on the widget, instead of randomly positioned by pixel. --- src/widget.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/widget.cpp') diff --git a/src/widget.cpp b/src/widget.cpp index 9cb767149..d13352f77 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -14,6 +14,9 @@ #include "table/sprites.h" #include "table/strings.h" +static const char *UPARROW = "\xEE\x8A\x80"; +static const char *DOWNARROW = "\xEE\x8A\xAA"; + static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom) { Point pt; @@ -579,3 +582,16 @@ void ResizeButtons(Window *w, byte left, byte right) } } } + +/** Draw a sort button's up or down arrow symbol. + * @param w Window of widget + * @param widget Sort button widget + * @param state State of sort button + */ +void DrawSortButtonState(const Window *w, int widget, SortButtonState state) +{ + if (state == SBS_OFF) return; + + int offset = w->IsWidgetLowered(widget) ? 1 : 0; + DoDrawString(state == SBS_DOWN ? DOWNARROW : UPARROW, w->widget[widget].right - 11 + offset, w->widget[widget].top + 1 + offset, TC_BLACK); +} -- cgit v1.2.3-54-g00ecf