| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "WiBox.h" |
| 10 |
|
| 11 |
//----------------------------------------------------------------- |
| 12 |
/** |
| 13 |
* Release all subwidgets. |
| 14 |
*/ |
| 15 |
WiBox::~WiBox() |
| 16 |
{ |
| 17 |
t_widgets::iterator end = m_widgets.end(); |
| 18 |
for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) { |
| 19 |
delete *i; |
| 20 |
} |
| 21 |
} |
| 22 |
//----------------------------------------------------------------- |
| 23 |
/** |
| 24 |
* Draw all subwidgets. |
| 25 |
*/ |
| 26 |
void |
| 27 |
WiBox::drawOn(SDL_Surface *screen) |
| 28 |
{ |
| 29 |
t_widgets::iterator end = m_widgets.end(); |
| 30 |
for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) { |
| 31 |
(*i)->drawOn(screen); |
| 32 |
} |
| 33 |
} |
| 34 |
//----------------------------------------------------------------- |
| 35 |
/** |
| 36 |
* Returns tooltip for active subwidget. |
| 37 |
*/ |
| 38 |
std::string |
| 39 |
WiBox::own_getTip(const V2 &loc) |
| 40 |
{ |
| 41 |
std::string result = m_tip; |
| 42 |
t_widgets::iterator end = m_widgets.end(); |
| 43 |
for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) { |
| 44 |
std::string subtip = (*i)->getTip(loc); |
| 45 |
if (!subtip.empty()) { |
| 46 |
if (result.empty()) { |
| 47 |
return subtip; |
| 48 |
} |
| 49 |
else { |
| 50 |
return result + " - " + subtip; |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
return result; |
| 55 |
} |
| 56 |
//----------------------------------------------------------------- |
| 57 |
/** |
| 58 |
* Let all subwidgets to react on button press. |
| 59 |
*/ |
| 60 |
void |
| 61 |
WiBox::own_mouseButton(const MouseStroke &stroke) |
| 62 |
{ |
| 63 |
t_widgets::iterator end = m_widgets.end(); |
| 64 |
for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) { |
| 65 |
(*i)->mouseButton(stroke); |
| 66 |
} |
| 67 |
} |
| 68 |
|