43
ctrlProgress::ctrlProgress(Window *parent,
44
const unsigned int id,
45
const unsigned short x,
46
const unsigned short y,
47
const unsigned short width,
48
const unsigned short height,
49
const TextureColor tc,
50
unsigned short button_minus,
51
unsigned short button_plus,
52
const unsigned short maximum,
53
const unsigned short x_padding,
54
const unsigned short y_padding,
55
const unsigned int force_color,
56
const std::string& tooltip,
57
const std::string& button_minus_tooltip,
58
const std::string& button_plus_tooltip,
59
unsigned short * const write_val)
60
: Window(x, y, id, parent, width, height, tooltip),
61
tc(tc), position(0), maximum(maximum), x_padding(x_padding), y_padding(y_padding), force_color(force_color)
43
ctrlProgress::ctrlProgress(Window* parent,
44
const unsigned int id,
45
const unsigned short x,
46
const unsigned short y,
47
const unsigned short width,
48
const unsigned short height,
49
const TextureColor tc,
50
unsigned short button_minus,
51
unsigned short button_plus,
52
const unsigned short maximum,
53
const unsigned short x_padding,
54
const unsigned short y_padding,
55
const unsigned int force_color,
56
const std::string& tooltip,
57
const std::string& button_minus_tooltip,
58
const std::string& button_plus_tooltip,
59
unsigned short* const write_val)
60
: Window(x, y, id, parent, width, height, tooltip),
61
tc(tc), position(0), maximum(maximum), x_padding(x_padding), y_padding(y_padding), force_color(force_color)
63
const char * str1 = "io", * str2 = "io";
64
if(button_minus >= 1000)
69
if(button_plus >= 1000)
75
AddImageButton(0, 0, 0, height, height, tc, LOADER.GetImageN(str1, button_minus), (button_minus_tooltip.length() ? button_minus_tooltip : _("Less")) );
76
AddImageButton(1, width - height, 0, height, height, tc, LOADER.GetImageN(str2, button_plus), (button_plus_tooltip.length( ) ? button_plus_tooltip : _("More")) );
63
const char* str1 = "io", * str2 = "io";
64
if(button_minus >= 1000)
69
if(button_plus >= 1000)
75
AddImageButton(0, 0, 0, height, height, tc, LOADER.GetImageN(str1, button_minus), (button_minus_tooltip.length() ? button_minus_tooltip : _("Less")) );
76
AddImageButton(1, width - height, 0, height, height, tc, LOADER.GetImageN(str2, button_plus), (button_plus_tooltip.length( ) ? button_plus_tooltip : _("More")) );
79
79
///////////////////////////////////////////////////////////////////////////////
99
99
bool ctrlProgress::Draw_(void)
101
Draw3D(GetX() + height - 2 + x_padding, GetY() + y_padding, width - (height*2) + 4 - 2*x_padding, height - 2*y_padding, tc, 2);
106
unsigned int percentage = position * 100 / maximum;
107
unsigned int progress = (width - height*2 - 4 - 2*x_padding) * position / maximum;
109
// Farbe herausfinden
110
unsigned int color = 0xFFFF0000;
117
// Farbe w�hlen je nachdem wie viel Prozent
120
else if(percentage >= 30)
122
else if(percentage >= 20)
127
DrawRectangle(GetX() + height + 2 + x_padding, GetY() + 4 + y_padding, progress, height -8 - 2*y_padding, color);
129
// Prozentzahlen zeichnen
130
std::stringstream percent;
131
percent << percentage << "%";
132
SmallFont->Draw(GetX() + (width / 2), GetY() + height / 2, percent.str(), glArchivItem_Font::DF_VCENTER|glArchivItem_Font::DF_CENTER, COLOR_YELLOW);
101
Draw3D(GetX() + height - 2 + x_padding, GetY() + y_padding, width - (height * 2) + 4 - 2 * x_padding, height - 2 * y_padding, tc, 2);
106
unsigned int percentage = position * 100 / maximum;
107
unsigned int progress = (width - height * 2 - 4 - 2 * x_padding) * position / maximum;
109
// Farbe herausfinden
110
unsigned int color = 0xFFFF0000;
117
// Farbe w�hlen je nachdem wie viel Prozent
120
else if(percentage >= 30)
122
else if(percentage >= 20)
127
DrawRectangle(GetX() + height + 2 + x_padding, GetY() + 4 + y_padding, progress, height - 8 - 2 * y_padding, color);
129
// Prozentzahlen zeichnen
130
std::stringstream percent;
131
percent << percentage << "%";
132
SmallFont->Draw(GetX() + (width / 2), GetY() + height / 2, percent.str(), glArchivItem_Font::DF_VCENTER | glArchivItem_Font::DF_CENTER, COLOR_YELLOW);
137
137
///////////////////////////////////////////////////////////////////////////////
143
143
void ctrlProgress::Msg_ButtonClick(const unsigned int ctrl_id)
152
parent->Msg_ProgressChange(GetID(), position);
156
if(position < maximum)
159
parent->Msg_ProgressChange(GetID(), position);
152
parent->Msg_ProgressChange(GetID(), position);
156
if(position < maximum)
159
parent->Msg_ProgressChange(GetID(), position);
164
164
///////////////////////////////////////////////////////////////////////////////
170
170
bool ctrlProgress::Msg_LeftDown(const MouseCoords& mc)
172
// Test if clicked on progress bar
174
GetX() + height + 2 + x_padding, GetY() + 4 + y_padding,
175
width - height*2 - 4 - 2*x_padding, height - 8 - 2*y_padding))
177
// The additional check for (position > maximum) is
178
// mathematically redundant here; if there was more code than
179
// it in SetPosition() we had to call it here instead of simply:
180
position = ( mc.x - (GetX() + height + 2 + x_padding)
181
+ /*rounding:*/ (width - height*2 - 4 - 2*x_padding) / maximum / 2)
182
* maximum / (width - height*2 - 4 - 2*x_padding);
172
// Test if clicked on progress bar
174
GetX() + height + 2 + x_padding, GetY() + 4 + y_padding,
175
width - height * 2 - 4 - 2 * x_padding, height - 8 - 2 * y_padding))
177
// The additional check for (position > maximum) is
178
// mathematically redundant here; if there was more code than
179
// it in SetPosition() we had to call it here instead of simply:
180
position = ( mc.x - (GetX() + height + 2 + x_padding)
181
+ /*rounding:*/ (width - height * 2 - 4 - 2 * x_padding) / maximum / 2)
182
* maximum / (width - height * 2 - 4 - 2 * x_padding);
184
if(parent) parent->Msg_ProgressChange(GetID(), position);
188
return RelayMouseMessage(&Window::Msg_LeftDown, mc);
184
if(parent) parent->Msg_ProgressChange(GetID(), position);
188
return RelayMouseMessage(&Window::Msg_LeftDown, mc);
191
191
///////////////////////////////////////////////////////////////////////////////
197
197
bool ctrlProgress::Msg_LeftUp(const MouseCoords& mc)
199
return RelayMouseMessage(&Window::Msg_LeftUp, mc);
199
return RelayMouseMessage(&Window::Msg_LeftUp, mc);
202
202
///////////////////////////////////////////////////////////////////////////////
208
208
bool ctrlProgress::Msg_WheelUp(const MouseCoords& mc)
210
// If mouse is over the controls, simulate button click
211
if(Coll(mc.x,mc.y,GetX(),GetY(), width, height))
210
// If mouse is over the controls, simulate button click
211
if(Coll(mc.x, mc.y, GetX(), GetY(), width, height))
219
219
///////////////////////////////////////////////////////////////////////////////
225
225
bool ctrlProgress::Msg_WheelDown(const MouseCoords& mc)
227
// If mouse is over the controls, simulate button click
228
if(Coll(mc.x,mc.y,GetX(),GetY(), width, height))
227
// If mouse is over the controls, simulate button click
228
if(Coll(mc.x, mc.y, GetX(), GetY(), width, height))
236
236
///////////////////////////////////////////////////////////////////////////////
242
242
bool ctrlProgress::Msg_MouseMove(const MouseCoords& mc)
244
// an Buttons weiterleiten
245
RelayMouseMessage(&Window::Msg_MouseMove, mc);
244
// an Buttons weiterleiten
245
RelayMouseMessage(&Window::Msg_MouseMove, mc);
247
if(Coll(mc.x, mc.y, GetX() + height + x_padding, GetY(), width - height*2 - x_padding*2, height))
249
WindowManager::inst().SetToolTip(this, tooltip);
254
WindowManager::inst().SetToolTip(this, "");
247
if(Coll(mc.x, mc.y, GetX() + height + x_padding, GetY(), width - height * 2 - x_padding * 2, height))
249
WindowManager::inst().SetToolTip(this, tooltip);
254
WindowManager::inst().SetToolTip(this, "");