Public Member Functions
ColorPage Class Reference

#include <colorpage.h>

Inheritance diagram for ColorPage:
ListBox Widget MouseListener KeyListener Widget2

Public Member Functions

 ColorPage (const Widget2 *const widget, ListModel *const listModel, const std::string &skin)
 ~ColorPage ()
void draw (Graphics *const graphics)
void safeDraw (Graphics *const graphics)
void resetAction ()
void adjustSize ()
- Public Member Functions inherited from ListBox
 ListBox (const Widget2 *const widget, ListModel *const listModel, const std::string &skin)
 ~ListBox ()
void postInit ()
void draw (Graphics *const graphics)
void safeDraw (Graphics *const graphics)
void updateAlpha ()
void keyPressed (KeyEvent &event)
void mouseWheelMovedUp (MouseEvent &event)
void mouseWheelMovedDown (MouseEvent &event)
void mousePressed (MouseEvent &event)
void mouseReleased (MouseEvent &event)
void mouseReleased1 (const MouseEvent &event)
void mouseDragged (MouseEvent &event)
void refocus ()
void setDistributeMousePressed (const bool b)
void logic ()
virtual int getSelectionByMouse (const int y) const
void setCenter (const bool b)
int getPressedIndex () const
virtual unsigned int getRowHeight () const
void setRowHeight (unsigned int n)
int getSelected () const
void setSelected (const int selected)
void setListModel (ListModel *listModel)
ListModelgetListModel () const
bool isWrappingEnabled () const
void setWrappingEnabled (const bool wrappingEnabled)
void addSelectionListener (SelectionListener *const selectionListener)
void removeSelectionListener (SelectionListener *const selectionListener)
void distributeValueChangedEvent ()
- 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
WidgetgetParent () 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 RectgetDimension () 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 ColorgetBaseColor () const
void setForegroundColor (const Color &color)
const ColorgetForegroundColor () const
void setBackgroundColor (const Color &color)
const ColorgetBackgroundColor () const
virtual void requestFocus ()
virtual void requestMoveToTop ()
virtual void requestMoveToBottom ()
virtual void setFocusHandler (FocusHandler *const focusHandler)
FocusHandlergetFocusHandler ()
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)
FontgetFont () 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 WidgetgetWidgetAt (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 FocusHandlergetInternalFocusHandler ()
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 ()
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
const ColorgetThemeCharColor (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)
WidgetgetWindow () const
virtual void setWindow (Widget *const window)
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
virtual void mouseEntered (MouseEvent &event)
virtual void mouseExited (MouseEvent &event)
virtual void mouseClicked (MouseEvent &event)
virtual void mouseMoved (MouseEvent &event)
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
virtual void keyReleased (KeyEvent &event)

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
static FontgetGloablFont ()
static void cleanGlobalFont ()
static bool widgetExists (const Widget *const widget)
static void distributeWindowResizeEvent ()
static WidgetcallPostInit (Widget *const widget)
- Data Fields inherited from Widget
Visible mVisible
- Protected Types inherited from ListBox
typedef std::list< SelectionListener * > SelectionListenerList
typedef SelectionListenerList::iterator SelectionListenerIterator
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
typedef MouseListenerList::iterator MouseListenerIterator
typedef std::list< KeyListener * > KeyListenerList
typedef KeyListenerList::iterator KeyListenerIterator
typedef std::list< ActionListener * > ActionListenerList
typedef ActionListenerList::iterator ActionListenerIterator
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
typedef std::list< FocusListener * > FocusListenerList
typedef FocusListenerList::iterator FocusListenerIterator
typedef std::list< WidgetListener * > WidgetListenerList
typedef WidgetListenerList::iterator WidgetListenerIterator
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
void distributeResizedEvent ()
void distributeMovedEvent ()
void distributeHiddenEvent ()
void distributeShownEvent ()
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
- Protected Member Functions inherited from MouseListener
 MouseListener ()
- Protected Member Functions inherited from KeyListener
 KeyListener ()
- Protected Attributes inherited from ListBox
int mSelected
bool mWrappingEnabled
SelectionListenerList mSelectionListeners
Color mHighlightColor
Color mForegroundSelectedColor
Color mForegroundSelectedColor2
int mOldSelected
int mPadding
int mPressedIndex
unsigned int mRowHeight
int mItemPadding
bool mDistributeMousePressed
bool mCenterText
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
KeyListenerList mKeyListeners
ActionListenerList mActionListeners
WidgetDeathListenerList mDeathListeners
FocusListenerList mFocusListeners
WidgetListenerList mWidgetListeners
Color mForegroundColor
Color mBackgroundColor
Color mBaseColor
Rect mDimension
std::string mActionEventId
std::string mId
unsigned int mFrameSize
bool mFocusable
bool mTabIn
bool mTabOut
bool mEnabled
bool mAllowLogic
bool mMouseConsume
bool mRedraw
bool mSelectable
- Protected Attributes inherited from Widget2
int mPaletteOffset
Color mForegroundColor2
- Static Protected Attributes inherited from ListBox
static float mAlpha = 1.0
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0

Detailed Description

Definition at line 29 of file colorpage.h.

Constructor & Destructor Documentation

◆ ColorPage()

ColorPage::ColorPage ( const Widget2 *const  widget,
ListModel *const  listModel,
const std::string &  skin 

Definition at line 34 of file colorpage.cpp.

36  :
37  ListBox(widget, listModel, skin)
38 {
39  mItemPadding = mSkin != nullptr ? mSkin->getOption("itemPadding") : 1;
40  const Font *const font = getFont();
41  mRowHeight = CAST_U32(font->getHeight() +
42  2 * mItemPadding);
43  if (mListModel != nullptr)
44  {
47  + 2 * mPadding + 20);
48  }
49 }
#define CAST_S32
Definition: cast.h:30
#define CAST_U32
Definition: cast.h:31
Definition: font.h:90
int getHeight() const
Definition: font.cpp:362
ListBox(const Widget2 *const widget, ListModel *const listModel, const std::string &skin)
Definition: listbox.cpp:89
unsigned int mRowHeight
Definition: listbox.h:289
virtual unsigned int getRowHeight() const
Definition: listbox.h:156
ListModel * mListModel
Definition: listbox.h:261
int mItemPadding
Definition: listbox.h:290
int mPadding
Definition: listbox.h:287
Skin * mSkin
Definition: listbox.h:291
virtual int getNumberOfElements()=0
int getOption(const std::string &name) const
Definition: skin.h:106
void setHeight(const int height)
Definition: widget.cpp:140
Font * getFont() const
Definition: widget.cpp:331

References CAST_S32, CAST_U32, Widget::getFont(), Font::getHeight(), ListModel::getNumberOfElements(), Skin::getOption(), ListBox::getRowHeight(), ListBox::mItemPadding, ListBox::mListModel, ListBox::mPadding, ListBox::mRowHeight, ListBox::mSkin, and Widget::setHeight().

◆ ~ColorPage()

ColorPage::~ColorPage ( )

Definition at line 51 of file colorpage.cpp.

52 {
53 }

Member Function Documentation

◆ adjustSize()

void ColorPage::adjustSize ( )

Reimplemented from ListBox.

Definition at line 115 of file colorpage.cpp.

116 {
117  BLOCK_START("ColorPage::adjustSize")
118  if (mListModel != nullptr)
119  {
122  2 * mPadding + 20);
123  }
124  BLOCK_END("ColorPage::adjustSize")
125 }
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, CAST_S32, ListModel::getNumberOfElements(), ListBox::getRowHeight(), ListBox::mListModel, ListBox::mPadding, and Widget::setHeight().

◆ draw()

void ColorPage::draw ( Graphics *const  graphics)

Draws the widget. It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.

graphicsaA graphics object to draw with.

Implements Widget.

Definition at line 55 of file colorpage.cpp.

56 {
57  BLOCK_START("ColorPage::draw")
59  const ColorModel *const model = static_cast<const ColorModel*>(
60  mListModel);
62  mHighlightColor.a = CAST_U32(mAlpha * 255.0F);
63  updateAlpha();
64  Font *const font = getFont();
66  const int rowHeight = CAST_S32(getRowHeight());
67  const int width = mDimension.width;
69  if (mSelected >= 0)
70  {
71  graphics->setColor(mHighlightColor);
72  graphics->fillRectangle(Rect(mPadding,
73  rowHeight * mSelected + mPadding,
74  mDimension.width - 2 * mPadding, rowHeight));
76  const ColorPair *const colors = model->getColorAt(mSelected);
77  const std::string str = mListModel->getElementAt(mSelected);
78  font->drawString(graphics,
79  *colors->color1,
80  *colors->color2,
81  str,
82  (width - font->getWidth(str)) / 2,
83  mSelected * rowHeight + mPadding);
84  }
86  const int sz = mListModel->getNumberOfElements();
87  for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight)
88  {
89  if (i != mSelected)
90  {
91  const ColorPair *const colors = model->getColorAt(i);
92  const std::string str = mListModel->getElementAt(i);
93  font->drawString(graphics,
94  *colors->color1,
95  *colors->color2,
96  str,
97  (width - font->getWidth(str)) / 2,
98  y);
99  }
100  }
102  BLOCK_END("ColorPage::draw")
103 }
virtual void fillRectangle(const Rect &rectangle)=0
virtual void setColor(const Color &color)
Definition: graphics.h:320
int mSelected
Definition: listbox.h:256
Color mHighlightColor
Definition: listbox.h:283
void updateAlpha()
Definition: listbox.cpp:154
static float mAlpha
Definition: listbox.h:292
virtual std::string getElementAt(int i)=0
Definition: rect.h:74
int width
Definition: rect.h:219
Rect mDimension
Definition: widget.h:1101
const Color * color2
Definition: colorpair.h:41
const Color * color1
Definition: colorpair.h:40

References Color::a, BLOCK_END, BLOCK_START, CAST_S32, CAST_U32, ColorPair::color1, ColorPair::color2, Font::drawString(), Graphics::fillRectangle(), ColorModel::getColorAt(), ListModel::getElementAt(), Widget::getFont(), ListModel::getNumberOfElements(), ListBox::getRowHeight(), Font::getWidth(), ListBox::mAlpha, Widget::mDimension, ListBox::mHighlightColor, ListBox::mListModel, ListBox::mPadding, ListBox::mSelected, Graphics::setColor(), ListBox::updateAlpha(), Rect::width, and y.

Referenced by safeDraw().

◆ resetAction()

void ColorPage::resetAction ( )

Definition at line 110 of file colorpage.cpp.

111 {
112  setSelected(-1);
113 }
void setSelected(const int selected)
Definition: listbox.cpp:399

References ListBox::setSelected().

Referenced by EmoteWindow::clearColor().

◆ safeDraw()

void ColorPage::safeDraw ( Graphics *const  graphics)

Implements Widget.

Definition at line 105 of file colorpage.cpp.

106 {
107  ColorPage::draw(graphics);
108 }
void draw(Graphics *const graphics)
Definition: colorpage.cpp:55

References draw().

The documentation for this class was generated from the following files: