| 1 | /*************************************************************************** |
| 2 | guibar.h - description |
| 3 | ------------------- |
| 4 | begin : december, 14th 2006 |
| 5 | copyright : (C) 2006 by Duong Khang NGUYEN |
| 6 | email : neoneurone @ gmail com |
| 7 | |
| 8 | $Id: guibar.h 375 2008-10-28 14:47:15Z neoneurone $ |
| 9 | ***************************************************************************/ |
| 10 | |
| 11 | /*************************************************************************** |
| 12 | * * |
| 13 | * This program is free software; you can redistribute it and/or modify * |
| 14 | * it under the terms of the GNU General Public License as published by * |
| 15 | * the Free Software Foundation; either version 2 of the License, or * |
| 16 | * any later version. * |
| 17 | * * |
| 18 | ***************************************************************************/ |
| 19 | |
| 20 | #ifndef _OPENCITY_GUIBAR_H_ |
| 21 | #define _OPENCITY_GUIBAR_H_ 1 |
| 22 | |
| 23 | #include "guimain.h" |
| 24 | |
| 25 | |
| 26 | //======================================================================== |
| 27 | /** A bar GUI control is used to display a color bar in 2D |
| 28 | */ |
| 29 | class GUIBar : public GUIMain { |
| 30 | public: |
| 31 | enum OPENCITY_VARIATION { |
| 32 | OC_HORIZONTAL, // Default value |
| 33 | OC_VERTICAL, |
| 34 | OC_BOTH |
| 35 | }; |
| 36 | |
| 37 | GUIBar(); |
| 38 | GUIBar( |
| 39 | const int ciX, |
| 40 | const int ciY, |
| 41 | const uint cuiW, |
| 42 | const uint cuiH ); |
| 43 | ~GUIBar(); |
| 44 | |
| 45 | |
| 46 | //======================================================================== |
| 47 | void |
| 48 | SetInitialValue( const float fValue ); |
| 49 | |
| 50 | void |
| 51 | SetValue( const float fValue ); |
| 52 | |
| 53 | void |
| 54 | SetVariation( const OPENCITY_VARIATION eV ); |
| 55 | |
| 56 | |
| 57 | //======================================================================== |
| 58 | /** Set the foreground color of the bar. |
| 59 | */ |
| 60 | void |
| 61 | SetForeground( const Color& color ); |
| 62 | |
| 63 | |
| 64 | //======================================================================== |
| 65 | // Inherited methods from GUIMain |
| 66 | //======================================================================== |
| 67 | void |
| 68 | Display() const; |
| 69 | |
| 70 | |
| 71 | //======================================================================== |
| 72 | // Inherited methods from UI |
| 73 | //======================================================================== |
| 74 | void Keyboard( const SDL_KeyboardEvent& rcEvent ); |
| 75 | void MouseMotion( const SDL_MouseMotionEvent& rcEvent ); |
| 76 | void MouseButton( const SDL_MouseButtonEvent& rcEvent ); |
| 77 | void Expose( const SDL_ExposeEvent& rcEvent ); |
| 78 | void Resize( const SDL_ResizeEvent& rcEvent ); |
| 79 | |
| 80 | |
| 81 | private: |
| 82 | OPENCITY_VARIATION _eVariation; |
| 83 | |
| 84 | /** The quantity that the full bar surface represents. |
| 85 | Must be diffrent than 0 |
| 86 | */ |
| 87 | float _fInitialValue; |
| 88 | float _fValue; ///< The current quantity of the bar |
| 89 | float _fWidthRatio; ///< The ratio of W to display |
| 90 | float _fHeightRatio; ///< The ratio of H to display |
| 91 | Color _cForeground; ///< The color of the bar |
| 92 | }; |
| 93 | |
| 94 | #endif |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 |