Fix language getting reset to system default on saving preferences
[amule.git] / src / BarShader.h
blob328364cb67184e576742738ac241ce18b97a9d50
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef BARSHADER_H
27 #define BARSHADER_H
29 #include "Types.h" // Needed for uint16 and uint32
30 #include "MuleColour.h"
32 class wxRect;
33 class wxDC;
35 /**
36 * The barshader class is responsible for drawing the chunk-based progress bars used in aMule.
38 * CBarShader represents the chunks of a file through the use of spans, which
39 * cover a range in the file with a certain color. New spans can be added on
40 * the fly and old spans are automatically removed, resized or merged when
41 * necessary.
43 * CBarShader will try to minimize the number of spans when possible.
45 class CBarShader
47 public:
48 /**
49 * Constructor.
51 * @param height The height of the area upon which the span is drawn.
52 * @param width The width of the area upon which the span is drawn.
54 CBarShader(unsigned height = 1, unsigned width = 1);
56 /**
57 * Destructor.
59 ~CBarShader();
61 /**
62 * Sets the width of the drawn bar.
64 * @param width The new width.
66 * Setting this sets the width the bar which is used when it
67 * is drawn and resets the pixel buffer to the fill color.
69 void SetWidth(int width);
71 /**
72 * Sets the height of the drawn bar.
74 * @param height The new height.
76 * Changes the height of the bar, used when it is drawn.
78 void SetHeight(unsigned height);
80 /**
81 * Sets the 3D-depth of the bar
83 * @param depth A value in the range from 1 to 5.
85 void Set3dDepth(unsigned depth);
87 /**
88 * Sets a new filesize.
90 * @param fileSize The new filesize.
92 * Calling this function sets a new filesize, which is the virtual
93 * length of the bar. This function must be called before any filling.
95 void SetFileSize(uint64 fileSize) { m_FileSize = fileSize; }
97 /**
98 * Fills in a range with a certain color.
100 * @param start The starting position of the new span.
101 * @param end The ending position of the new span. Must be larger than start.
102 * @param colour The colour of the new span.
104 * Calling this function fill the specified range with the specified color.
105 * Any spans completly or partially covered by the new span are either
106 * removed or resized. If the value of end is larger than the current
107 * filesize, the filesize is increased to the value of end.
109 void FillRange(uint64 start, uint64 end, const CMuleColour& colour);
112 * Fill the entire bar with a span of the specified color.
114 * @param colour The colour of the new span.
116 void Fill(const CMuleColour& colour)
118 m_Content.clear();
119 m_Content.resize(m_Width, colour);
123 * Draws the bar on the specifed wxDC.
125 * @param dc The wxDC upon which the bar should be drawn.
126 * @param iLeft The left position from where to start drawing.
127 * @param iTop The top position from where to start drawing.
128 * @param bFlat 3D effect is not applied if this is true.
130 * This functions draws the bar with the height and width specified
131 * through either the contructor or with SetWidth() and SetHeight().
133 void Draw( wxDC* dc, int iLeft, int iTop, bool bFlat );
135 private:
137 * Calculates the modifiers used to create 3d effect.
139 void BuildModifiers();
141 //! The width of the drawn bar
142 unsigned m_Width;
143 //! The height of the drawn bar
144 unsigned m_Height;
145 //! The virtual filesize assosiated with the bar
146 uint64 m_FileSize;
147 //! Pointer to array of modifers used to create 3D effect. Size is (m_Height+1)/2 when set.
148 double* m_Modifiers;
149 //! The current 3d level
150 uint16 m_used3dlevel;
152 // color for each pixel across the width is stored here
153 std::vector<CMuleColour> m_Content;
156 #endif
157 // File_checked_for_headers