2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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.
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
29 #include "Types.h" // Needed for uint16 and uint32
37 * The barshader class is responsible for drawing the chunk-based progress bars used in aMule.
39 * CBarShader represents the chunks of a file through the use of spans, which
40 * cover a range in the file with a certain color. New spans can be added on
41 * the fly and old spans are automatically removed, resized or merged when
44 * CBarShader will try to minimize the number of spans when possible.
52 * @param height The height of the area upon which the span is drawn.
53 * @param width The width of the area upon which the span is drawn.
55 CBarShader(uint32 height
= 1, uint32 width
= 1);
63 * Sets the width of the drawn bar.
65 * @param width The new width.
67 * Setting this sets the width the bar which is used when it
68 * is drawn and resets the pixel buffer to the fill color.
70 void SetWidth(int width
);
73 * Sets the height of the drawn bar.
75 * @param height The new height.
77 * Changes the height of the bar, used when it is drawn.
79 void SetHeight( int height
);
83 * Sets the 3D-depth of the bar
85 * @param depth A value in the range from 1 to 5.
87 void Set3dDepth( int depth
);
90 * Sets a new filesize.
92 * @param fileSize The new filesize.
94 * Calling this function sets a new filesize, which is the virtual
95 * length of the bar. This function must be called before any filling.
97 void SetFileSize(uint64 fileSize
);
100 * Fills in a range with a certain color.
102 * @param start The starting position of the new span.
103 * @param end The ending position of the new span. Must be larger than start.
104 * @param color The color of the new span.
106 * Calling this function fill the specified range with the specified color.
107 * Any spans completly or partially covered by the new span are either
108 * removed or resized. If the value of end is larger than the current
109 * filesize, the filesize is increased to the value of end.
111 void FillRange(uint64 start
, uint64 end
, uint32 color
);
114 * Fill the entire bar with a span of the specified color.
116 * @param color The color of the new span.
118 void Fill(uint32 color
);
121 * Draws the bar on the specifed wxDC.
123 * @param dc The wxDC upon which the bar should be drawn.
124 * @param iLeft The left position from where to start drawing.
125 * @param iTop The top position from where to start drawing.
126 * @param bFlat 3D effect is not applied if this is true.
128 * This functions draws the bar with the height and width specified
129 * through either the contructor or with SetWidth() and SetHeight().
131 void Draw( wxDC
* dc
, int iLeft
, int iTop
, bool bFlat
);
135 * Calculates the modifiers used to create 3d effect.
137 void BuildModifiers();
140 * Fills a rectangle with a given color.
142 * @param dc The DC upon which to draw the bar.
143 * @param rectSpan The area within the specifed DC upon which to draw.
144 * @param color The color of the rectangle.
145 * @param bFlat If this is true, a simple rectangle will be drawn, otherwise the modifers will be applyed to achive a 3D effect.
147 void FillRect(wxDC
* dc
, const wxRect
& rectSpan
, uint32 color
, bool bFlat
);
150 * Blend in a single pixel
152 void BlendPixel(uint32 index
, uint32 color
, double covered
);
154 //! The width of the drawn bar
156 //! The height of the drawn bar
158 //! The virtual filesize assosiated with the bar
160 //! Pointer to array of modifers used to create 3D effect. Size is (m_Height+1)/2 when set.
162 //! The current 3d level
163 uint16 m_used3dlevel
;
165 // color for each pixel across the width is stored here
166 std::vector
<uint32
> m_Content
;
170 // File_checked_for_headers