1 /* 2 This file is part of Warzone 2100. 3 Copyright (C) 1999-2004 Eidos Interactive 4 Copyright (C) 2005-2020 Warzone 2100 Project 5 6 Warzone 2100 is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 Warzone 2100 is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Warzone 2100; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 /** @file 21 * Definitions for Bar Graph functions. 22 */ 23 24 #ifndef __INCLUDED_LIB_WIDGET_BAR_H__ 25 #define __INCLUDED_LIB_WIDGET_BAR_H__ 26 27 #include "widget.h" 28 #include <string> 29 30 31 class W_BARGRAPH : public WIDGET 32 { 33 34 public: 35 W_BARGRAPH(W_BARINIT const *init); 36 37 void highlight(W_CONTEXT *psContext) override; 38 void highlightLost() override; 39 void display(int xOffset, int yOffset) override; 40 41 void setTip(std::string string) override; 42 setBackgroundColour(PIELIGHT colour)43 void setBackgroundColour(PIELIGHT colour) 44 { 45 backgroundColour = colour; 46 } 47 48 WBAR_ORIENTATION barPos; // Orientation of the bar on the widget 49 UWORD majorSize; // Percentage of the main bar that is filled 50 UWORD minorSize; // Percentage of the minor bar if there is one 51 UWORD iRange; // Maximum range 52 UWORD iValue; // Current value 53 UWORD iOriginal; // hack to keep uncapped value around 54 int denominator; // Denominator, 1 by default. 55 int precision; // Number of places after the decimal point to display, 0 by default. 56 PIELIGHT majorCol; // Colour for the major bar 57 PIELIGHT minorCol; // Colour for the minor bar 58 PIELIGHT textCol; // Colour for the text on the bar. 59 std::string pTip; // The tool tip for the graph 60 std::string text; // Text on the bar. 61 62 //private: 63 PIELIGHT backgroundColour; 64 WzText wzCachedText; 65 }; 66 67 /* The trough bar graph display function */ 68 void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset); 69 70 #endif // __INCLUDED_LIB_WIDGET_BAR_H__ 71