ManaPlus
|
#include <progressbar.h>
Public Member Functions | |
ProgressBar (const Widget2 *const widget, float progress, const int width, const int height, const ProgressColorIdT backColor, const std::string &skin, const std::string &skinFill) | |
~ProgressBar () | |
void | logic () |
void | updateAlpha () |
void | draw (Graphics *const graphics) |
void | safeDraw (Graphics *const graphics) |
void | setProgress (const float progress) |
float | getProgress () const |
void | setProgressPalette (const ProgressColorIdT progressPalette) |
void | setBackgroundColor (const Color &color) |
void | setColor (const Color &color1, const Color &color2) |
const Color & | getBackgroundColor () const |
void | setText (const std::string &str) |
const std::string & | text () const |
void | setSmoothProgress (bool smoothProgress) |
void | setSmoothColorChange (bool smoothColorChange) |
void | widgetResized (const Event &event) |
void | widgetMoved (const Event &event) |
void | widgetHidden (const Event &event) |
void | setPadding (unsigned int padding) |
Public Member Functions inherited from Widget | |
Widget (const Widget2 *const widget) | |
~Widget () | |
virtual void | drawFrame (Graphics *graphics) |
virtual void | safeDrawFrame (Graphics *graphics) |
void | setFrameSize (const unsigned int frameSize) |
unsigned int | getFrameSize () const |
Widget * | getParent () const |
void | setWidth (const int width) |
int | getWidth () const |
void | setHeight (const int height) |
int | getHeight () const |
void | setSize (const int width, const int height) |
void | setX (const int x) |
int | getX () const |
void | setY (const int y) |
int | getY () const |
void | setPosition (const int x, const int y) |
void | setDimension (const Rect &dimension) |
const Rect & | getDimension () const |
void | setFocusable (const bool focusable) |
bool | isFocusable () const |
virtual bool | isFocused () const |
void | setEnabled (const bool enabled) |
bool | isEnabled () const |
void | setVisible (Visible visible) |
bool | isVisible () const |
void | setBaseColor (const Color &color) |
const Color & | getBaseColor () const |
void | setForegroundColor (const Color &color) |
const Color & | getForegroundColor () const |
void | setBackgroundColor (const Color &color) |
const Color & | getBackgroundColor () const |
virtual void | requestFocus () |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
virtual void | setFocusHandler (FocusHandler *const focusHandler) |
FocusHandler * | getFocusHandler () |
void | addActionListener (ActionListener *const actionListener) |
void | removeActionListener (ActionListener *const actionListener) |
void | addDeathListener (WidgetDeathListener *const deathListener) |
void | removeDeathListener (WidgetDeathListener *const deathListener) |
void | addMouseListener (MouseListener *const mouseListener) |
void | removeMouseListener (MouseListener *const mouseListener) |
void | addKeyListener (KeyListener *const keyListener) |
void | removeKeyListener (KeyListener *const keyListener) |
void | addFocusListener (FocusListener *const focusListener) |
void | removeFocusListener (FocusListener *const focusListener) |
void | addWidgetListener (WidgetListener *const widgetListener) |
void | removeWidgetListener (WidgetListener *const widgetListener) |
void | setActionEventId (const std::string &actionEventId) |
const std::string & | getActionEventId () const |
virtual void | getAbsolutePosition (int &x, int &y) const |
virtual void | setParent (Widget *parent) |
Font * | getFont () const |
void | setFont (Font *const font) |
virtual void | fontChanged () |
bool | isTabInEnabled () const |
void | setTabInEnabled (const bool enabled) |
bool | isTabOutEnabled () const |
void | setTabOutEnabled (const bool enabled) |
void | requestModalFocus () |
virtual void | requestModalMouseInputFocus () |
virtual void | releaseModalFocus () |
virtual void | releaseModalMouseInputFocus () |
virtual bool | isModalFocused () const |
virtual bool | isModalMouseInputFocused () const |
virtual Widget * | getWidgetAt (int x, int y) |
const std::list< MouseListener * > & | getMouseListeners () const A_CONST |
const std::list< KeyListener * > & | getKeyListeners () const A_CONST |
const std::list< FocusListener * > & | getFocusListeners () const A_CONST |
virtual Rect | getChildrenArea () |
virtual FocusHandler * | getInternalFocusHandler () |
void | setInternalFocusHandler (FocusHandler *const internalFocusHandler) |
virtual void | moveToTop (Widget *widget) |
virtual void | moveToBottom (Widget *widget) |
virtual void | focusNext () |
virtual void | focusPrevious () |
virtual void | showWidgetPart (Widget *const widget, const Rect &area) |
void | setId (const std::string &id) |
const std::string & | getId () const |
virtual void | showPart (const Rect &rectangle) |
bool | isAllowLogic () const |
void | setMouseConsume (const bool b) |
bool | isMouseConsume () const |
void | setRedraw (const bool b) |
virtual bool | isSelectable () const |
void | setSelectable (const bool selectable) |
void | windowResized () |
virtual void | postInit () |
Public Member Functions inherited from Widget2 | |
virtual | ~Widget2 () |
const Color & | getThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE |
const Color & | getThemeCharColor (const signed char c, bool &valid) const A_INLINE |
virtual void | setWidget2 (const Widget2 *const widget) |
void | setPalette (int palette) |
void | checkPalette () |
void | setForegroundColor2 (const Color &color) |
Widget * | getWindow () const |
virtual void | setWindow (Widget *const window) |
Public Member Functions inherited from WidgetListener | |
virtual | ~WidgetListener () |
virtual void | widgetShown (const Event &event) |
Private Attributes | |
ImageRect | mFillRect |
TextChunk | mTextChunk |
Skin * | mSkin |
float | mProgress |
float | mProgressToGo |
Color | mBackgroundColorToGo |
std::string | mText |
ImageCollection * | mVertexes |
ProgressColorIdT | mProgressPalette |
unsigned int | mPadding |
unsigned int | mFillPadding |
bool | mFillImage |
bool | mSmoothProgress |
bool | mSmoothColorChange |
bool | mTextChanged |
Static Private Attributes | |
static int | mInstances = 0 |
static float | mAlpha = 1.0 |
A progress bar.
Definition at line 45 of file progressbar.h.
ProgressBar::ProgressBar | ( | const Widget2 *const | widget, |
float | progress, | ||
const int | width, | ||
const int | height, | ||
const ProgressColorIdT | backColor, | ||
const std::string & | skin, | ||
const std::string & | skinFill | ||
) |
Constructor, initializes the progress with the given value.
Definition at line 44 of file progressbar.cpp.
References Widget::addWidgetListener(), Widget::getFont(), Widget::getHeight(), Skin::getOption(), Skin::getPadding(), Theme::getProgressColor(), Widget2::getThemeColor(), Theme::getThemePath(), Theme::load(), Theme::loadRect(), Widget::mBackgroundColor, mBackgroundColorToGo, mFillImage, mFillPadding, mFillRect, Widget::mForegroundColor, Widget2::mForegroundColor2, mInstances, mPadding, mProgress, mSkin, ProgressColorId::PROG_HP, Widget::setHeight(), setPadding(), Widget::setSize(), and theme.
ProgressBar::~ProgressBar | ( | ) |
Definition at line 111 of file progressbar.cpp.
References delete2, TextChunk::deleteImage(), gui, mFillRect, mInstances, mSkin, mTextChunk, mVertexes, Gui::removeDragged(), theme, Theme::unload(), and Theme::unloadRect().
|
virtual |
Draws the progress bar.
Implements Widget.
Definition at line 168 of file progressbar.cpp.
References Color::a, BLOCK_END, BLOCK_START, Graphics::calcWindow(), CAST_S32, CAST_U32, ImageCollection::clear(), TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), Graphics::drawImage(), Graphics::drawTileCollection(), Graphics::fillRectangle(), Graphics::finalize(), Font::generate(), Skin::getBorder(), Gui::getFont(), Font::getHeight(), Graphics::getRedraw(), Font::getWidth(), gui, Rect::height, TextChunk::img, mAlpha, Widget::mBackgroundColor, Widget::mDimension, mFillImage, mFillPadding, mFillRect, Widget::mForegroundColor, Widget2::mForegroundColor2, mProgress, Widget::mRedraw, mSkin, mText, mTextChanged, mTextChunk, mVertexes, Graphics::setColor(), TextChunk::text, TextChunk::textFont, updateAlpha(), and Rect::width.
|
inline |
Returns the color of the progress bar.
Definition at line 108 of file progressbar.h.
References Widget::mBackgroundColor.
|
inline |
|
virtual |
Performs progress bar logic (fading colors)
Reimplemented from Widget.
Definition at line 128 of file progressbar.cpp.
References Color::b, BLOCK_END, BLOCK_START, Color::g, Widget::mBackgroundColor, mBackgroundColorToGo, mProgress, mProgressToGo, Widget::mRedraw, mSmoothColorChange, mSmoothProgress, and Color::r.
|
virtual |
Implements Widget.
Definition at line 247 of file progressbar.cpp.
References Color::a, BLOCK_END, BLOCK_START, CAST_S32, CAST_U32, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), Graphics::drawImage(), Graphics::drawImageRect(), Graphics::fillRectangle(), Font::generate(), Skin::getBorder(), Gui::getFont(), Font::getHeight(), Font::getWidth(), gui, Rect::height, TextChunk::img, mAlpha, Widget::mBackgroundColor, Widget::mDimension, mFillImage, mFillPadding, mFillRect, Widget::mForegroundColor, Widget2::mForegroundColor2, mProgress, mSkin, mText, mTextChanged, mTextChunk, Graphics::setColor(), TextChunk::text, TextChunk::textFont, updateAlpha(), and Rect::width.
void ProgressBar::setBackgroundColor | ( | const Color & | color | ) |
Change the color of the progress bar.
Definition at line 348 of file progressbar.cpp.
References Widget::mBackgroundColor, mBackgroundColorToGo, Widget::mRedraw, and mSmoothColorChange.
Referenced by StatusWindow::updateStatusBar().
Definition at line 357 of file progressbar.cpp.
References Widget::mForegroundColor, Widget2::mForegroundColor2, and mTextChanged.
Referenced by MiniStatusWindow::createBar(), InventoryWindow::InventoryWindow(), StatusWindow::StatusWindow(), and StatusWindow::updateMPBar().
|
inline |
void ProgressBar::setProgress | ( | const float | progress | ) |
Sets the current progress.
Definition at line 318 of file progressbar.cpp.
References Theme::getProgressColor(), mBackgroundColorToGo, mProgress, mProgressPalette, mProgressToGo, Widget::mRedraw, mSmoothProgress, and ProgressColorId::PROG_HP.
Referenced by UpdaterWindow::logic(), InventoryWindow::slotsChanged(), StatusWindow::updateHPBar(), StatusWindow::updateInvSlotsBar(), StatusWindow::updateMoneyBar(), StatusWindow::updateMPBar(), StatusWindow::updateProgressBar(), StatusWindow::updateStatusBar(), InventoryWindow::updateWeight(), and StatusWindow::updateWeightBar().
void ProgressBar::setProgressPalette | ( | const ProgressColorIdT | progressPalette | ) |
Change the ProgressPalette for this ProgressBar to follow or -1 to disable this and manage color manually.
Definition at line 334 of file progressbar.cpp.
References Theme::getProgressColor(), mBackgroundColorToGo, mProgressPalette, mProgressToGo, Widget::mRedraw, and ProgressColorId::PROG_HP.
Referenced by StatusWindow::updateMPBar().
|
inline |
Set whether the color changing is made smoothly.
Definition at line 131 of file progressbar.h.
References mSmoothColorChange.
|
inline |
Set whether the progress is moved smoothly.
Definition at line 125 of file progressbar.h.
References mSmoothProgress.
Referenced by UpdaterWindow::UpdaterWindow().
void ProgressBar::setText | ( | const std::string & | str | ) |
Sets the text shown on the progress bar.
Definition at line 374 of file progressbar.cpp.
References mText, and mTextChanged.
Referenced by UpdaterWindow::logic(), InventoryWindow::slotsChanged(), StatusWindow::updateArrowsBar(), StatusWindow::updateHPBar(), StatusWindow::updateInvSlotsBar(), StatusWindow::updateMoneyBar(), StatusWindow::updateMPBar(), StatusWindow::updateProgressBar(), StatusWindow::updateStatusBar(), InventoryWindow::updateWeight(), and StatusWindow::updateWeightBar().
|
inline |
Returns the text shown on the progress bar.
Definition at line 119 of file progressbar.h.
References mText.
Referenced by PopupMenu::showPopup().
void ProgressBar::updateAlpha | ( | ) |
Update the alpha value to the graphic components.
Definition at line 161 of file progressbar.cpp.
References Theme::getMinimumOpacity(), Settings::guiAlpha, mAlpha, settings, and theme.
Referenced by draw(), and safeDraw().
|
virtual |
Invoked when a widget is hidden, i.e it's set to be not visible.
event | Describes the event. |
Reimplemented from WidgetListener.
Definition at line 383 of file progressbar.cpp.
References TextChunk::deleteImage(), mTextChanged, and mTextChunk.
|
virtual |
Invoked when a widget is moved.
event | Describes the event. |
Reimplemented from WidgetListener.
Definition at line 369 of file progressbar.cpp.
References Widget::mRedraw.
|
virtual |
Invoked when a widget changes its size.
event | Describes the event. |
Reimplemented from WidgetListener.
Definition at line 364 of file progressbar.cpp.
References Widget::mRedraw.
|
staticprivate |
Definition at line 159 of file progressbar.h.
Referenced by draw(), safeDraw(), and updateAlpha().
|
private |
Definition at line 150 of file progressbar.h.
Referenced by logic(), ProgressBar(), setBackgroundColor(), setProgress(), and setProgressPalette().
|
private |
Definition at line 161 of file progressbar.h.
Referenced by draw(), ProgressBar(), and safeDraw().
|
private |
Definition at line 156 of file progressbar.h.
Referenced by draw(), ProgressBar(), and safeDraw().
|
private |
Definition at line 144 of file progressbar.h.
Referenced by draw(), ProgressBar(), safeDraw(), and ~ProgressBar().
|
staticprivate |
Definition at line 158 of file progressbar.h.
Referenced by ProgressBar(), and ~ProgressBar().
|
private |
Definition at line 155 of file progressbar.h.
Referenced by ProgressBar(), and setPadding().
|
private |
Definition at line 147 of file progressbar.h.
Referenced by draw(), getProgress(), logic(), ProgressBar(), safeDraw(), and setProgress().
|
private |
Definition at line 154 of file progressbar.h.
Referenced by setProgress(), and setProgressPalette().
|
private |
Definition at line 148 of file progressbar.h.
Referenced by logic(), setProgress(), and setProgressPalette().
|
private |
Definition at line 146 of file progressbar.h.
Referenced by draw(), ProgressBar(), safeDraw(), and ~ProgressBar().
|
private |
Definition at line 163 of file progressbar.h.
Referenced by logic(), setBackgroundColor(), and setSmoothColorChange().
|
private |
Definition at line 162 of file progressbar.h.
Referenced by logic(), setProgress(), and setSmoothProgress().
|
private |
Definition at line 152 of file progressbar.h.
Referenced by draw(), safeDraw(), setText(), and text().
|
private |
Definition at line 164 of file progressbar.h.
Referenced by draw(), safeDraw(), setColor(), setText(), and widgetHidden().
|
private |
Definition at line 145 of file progressbar.h.
Referenced by draw(), safeDraw(), widgetHidden(), and ~ProgressBar().
|
private |
Definition at line 153 of file progressbar.h.
Referenced by draw(), and ~ProgressBar().