ManaPlus
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends
Tab Class Reference

#include <tab.h>

Inheritance diagram for Tab:
BasicContainer MouseListener WidgetListener Widget WidgetDeathListener Widget2 ChatTab ShortcutTab SkillTab SocialTab BattleTab ChannelTab ClanTab EmulateGuildTab GmTab GuildTab LangTab PartyTab TradeTab WhisperTab SocialAttackTab SocialFriendsTab SocialGuildTab SocialGuildTab2 SocialNavigationTab SocialPartyTab SocialPickupTab SocialPlayersTab

Public Types

enum  {
  TAB_STANDARD = 0 , TAB_HIGHLIGHTED = 1 , TAB_SELECTED = 2 , TAB_UNUSED = 3 ,
  TAB_COUNT = 4
}
 

Public Member Functions

 Tab (const Widget2 *const widget)
 
 ~Tab ()
 
void updateAlpha ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setTabColor (const Color *const color1, const Color *const color2)
 
void setHighlightedTabColor (const Color *const color1, const Color *const color2)
 
void setSelectedTabColor (const Color *const color1, const Color *const color2)
 
void setFlashTabColor (const Color *const color1, const Color *const color2)
 
void setPlayerFlashTabColor (const Color *const color1, const Color *const color2)
 
void setFlash (const int flash)
 
int getFlash () const
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void setLabelFont (Font *const font)
 
LabelgetLabel () const
 
void adjustSize ()
 
void setTabbedArea (TabbedArea *tabbedArea)
 
TabbedAreagetTabbedArea () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void mouseEntered (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void setImage (Image *const image)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- 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 ()
 
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
 
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 FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
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 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 WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mousePressed (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseMoved (MouseEvent &event)
 
virtual void mouseDragged (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Static Public Member Functions

static void finalCleanup ()
 
- 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)
 

Protected Member Functions

virtual void setCurrent ()
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- 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 WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 

Protected Attributes

LabelmLabel
 
TabbedAreamTabbedArea
 
bool mHasMouse
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- 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
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
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
 
WidgetmWindow
 
Color mForegroundColor2
 

Private Member Functions

void init ()
 

Private Attributes

const ColormTabColor
 
const ColormTabOutlineColor
 
const ColormTabHighlightedColor
 
const ColormTabHighlightedOutlineColor
 
const ColormTabSelectedColor
 
const ColormTabSelectedOutlineColor
 
const ColormFlashColor
 
const ColormFlashOutlineColor
 
const ColormPlayerFlashColor
 
const ColormPlayerFlashOutlineColor
 
int mFlash
 
ImageCollectionmVertexes
 
ImagemImage
 
int mMode
 
int mLabelMode
 

Static Private Attributes

static SkintabImg [TAB_COUNT]
 
static int mInstances = 0
 
static float mAlpha = 1.0
 

Friends

class TabbedArea
 

Additional Inherited Members

- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- 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
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A tab, the same as the Guichan tab in 0.8, but extended

Definition at line 85 of file tab.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TAB_STANDARD 
TAB_HIGHLIGHTED 
TAB_SELECTED 
TAB_UNUSED 
TAB_COUNT 

Definition at line 96 of file tab.h.

97  {
98  TAB_STANDARD = 0,
99  TAB_HIGHLIGHTED = 1,
100  TAB_SELECTED = 2,
101  TAB_UNUSED = 3,
102  TAB_COUNT = 4 // Must be last
103  };
@ TAB_COUNT
Definition: tab.h:102
@ TAB_HIGHLIGHTED
Definition: tab.h:99
@ TAB_SELECTED
Definition: tab.h:100
@ TAB_STANDARD
Definition: tab.h:98
@ TAB_UNUSED
Definition: tab.h:101

Constructor & Destructor Documentation

◆ Tab()

Tab::Tab ( const Widget2 *const  widget)
explicit

Definition at line 103 of file tab.cpp.

103  :
104  BasicContainer(widget),
105  MouseListener(),
106  WidgetListener(),
107  mLabel(new Label(this)),
108  mTabbedArea(nullptr),
110  mTabOutlineColor(&getThemeColor(ThemeColorId::TAB_OUTLINE, 255U)),
111  mTabHighlightedColor(&getThemeColor(ThemeColorId::TAB_HIGHLIGHTED, 255U)),
113  ThemeColorId::TAB_HIGHLIGHTED_OUTLINE, 255U)),
114  mTabSelectedColor(&getThemeColor(ThemeColorId::TAB_SELECTED, 255U)),
116  ThemeColorId::TAB_SELECTED_OUTLINE, 255U)),
117  mFlashColor(&getThemeColor(ThemeColorId::TAB_FLASH, 255U)),
118  mFlashOutlineColor(&getThemeColor(ThemeColorId::TAB_FLASH_OUTLINE, 255U)),
119  mPlayerFlashColor(&getThemeColor(ThemeColorId::TAB_PLAYER_FLASH, 255U)),
121  ThemeColorId::TAB_PLAYER_FLASH_OUTLINE, 255U)),
122  mFlash(0),
124  mImage(nullptr),
125  mMode(0),
126  mLabelMode(-1),
127  mHasMouse(false)
128 {
129  init();
130 }
Definition: label.h:91
int mMode
Definition: tab.h:239
const Color * mFlashColor
Definition: tab.h:232
const Color * mTabSelectedColor
Definition: tab.h:230
const Color * mTabColor
Definition: tab.h:226
const Color * mTabSelectedOutlineColor
Definition: tab.h:231
int mFlash
Definition: tab.h:236
void init()
Definition: tab.cpp:154
const Color * mTabHighlightedColor
Definition: tab.h:228
const Color * mTabOutlineColor
Definition: tab.h:227
const Color * mPlayerFlashColor
Definition: tab.h:234
bool mHasMouse
Definition: tab.h:243
TabbedArea * mTabbedArea
Definition: tab.h:216
const Color * mTabHighlightedOutlineColor
Definition: tab.h:229
Image * mImage
Definition: tab.h:238
Label * mLabel
Definition: tab.h:214
const Color * mFlashOutlineColor
Definition: tab.h:233
int mLabelMode
Definition: tab.h:240
ImageCollection * mVertexes
Definition: tab.h:237
const Color * mPlayerFlashOutlineColor
Definition: tab.h:235
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
friend class BasicContainer
Definition: widget.h:101

References init().

◆ ~Tab()

Tab::~Tab ( )

Definition at line 132 of file tab.cpp.

133 {
134  if (gui != nullptr)
135  gui->removeDragged(this);
136 
137  mInstances--;
138  if (mInstances == 0 && (theme != nullptr))
139  {
140  for (int mode = 0; mode < TAB_COUNT; mode ++)
141  theme->unload(tabImg[mode]);
142  }
143 
144  delete2(mLabel)
145 
146  if (mImage != nullptr)
147  {
148  mImage->decRef();
149  mImage = nullptr;
150  }
152 }
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
static int mInstances
Definition: tab.h:223
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:222
void unload(Skin *const skin)
Definition: theme.cpp:250
#define delete2(var)
Definition: delete2.h:25
Gui * gui
Definition: gui.cpp:111
Theme * theme
Definition: theme.cpp:62

References delete2, gui, mImage, mInstances, mLabel, mVertexes, Gui::removeDragged(), TAB_COUNT, tabImg, theme, and Theme::unload().

Member Function Documentation

◆ adjustSize()

void Tab::adjustSize ( )

Definition at line 426 of file tab.cpp.

427 {
428  const Skin *const skin = tabImg[TAB_STANDARD];
429  if (skin == nullptr)
430  return;
431  const int pad2 = skin->getPadding() * 2;
432 
433  if (mImage != nullptr)
434  {
435  const SDL_Rect &rect = mImage->mBounds;
436  setSize(rect.w + pad2, rect.h + pad2);
437  }
438  else
439  {
440  setSize(mLabel->getWidth() + pad2,
441  mLabel->getHeight() + pad2);
442  }
443 
444  if (mTabbedArea != nullptr)
446 }
Definition: skin.h:37
int getPadding() const
Definition: skin.h:100
void adjustTabPositions()
Definition: tabbedarea.cpp:606
void setSize(const int width, const int height)
Definition: widget.cpp:367
int getHeight() const
Definition: widget.h:240
int getWidth() const
Definition: widget.h:221

References TabbedArea::adjustTabPositions(), Widget::getHeight(), Skin::getPadding(), Widget::getWidth(), mImage, mLabel, mTabbedArea, Widget::setSize(), TAB_STANDARD, and tabImg.

Referenced by setCaption(), setImage(), and setLabelFont().

◆ draw()

void Tab::draw ( Graphics *const  graphics)
virtual

Draw the tabbed area.

Implements Widget.

Definition at line 215 of file tab.cpp.

216 {
217  BLOCK_START("Tab::draw")
218  int mode = TAB_STANDARD;
219 
220  // check which type of tab to draw
221  if (mTabbedArea != nullptr)
222  {
223  int labelMode = mFlash;
224 
225  if (mTabbedArea->isTabSelected(this))
226  {
227  labelMode = 3;
228  mode = TAB_SELECTED;
229  // if tab is selected, it doesnt need to highlight activity
230  mFlash = 0;
231  }
232  else if (labelMode == 0)
233  {
234  if (mHasMouse)
235  {
236  labelMode = 4;
237  mode = TAB_HIGHLIGHTED;
238  }
239  }
240  else if (mHasMouse)
241  {
242  mode = TAB_HIGHLIGHTED;
243  }
244 
245  // mRedraw need here because no other way to say label to change color
246  // +++ text from label must be moved to tab itself
247  if (labelMode != mLabelMode || mRedraw)
248  {
249  mLabelMode = labelMode;
250  switch (labelMode)
251  {
252  case 0: // default state
253  default:
256  break;
257  case 1: // mFlash == 1
260  break;
261  case 2: // mFlash == 2
264  break;
265  case 3: // mTabbedArea->isTabSelected(this)
268  break;
269  case 4: // mHasMouse
272  break;
273  }
274  }
275  }
276 
277  const Skin *const skin = tabImg[mode];
278  if (skin == nullptr)
279  {
280  BLOCK_END("Tab::draw")
281  return;
282  }
283 
284  updateAlpha();
285 
286  const ImageRect &rect = skin->getBorder();
287  if (mRedraw || mode != mMode || graphics->getRedraw())
288  {
289  mMode = mode;
290  mRedraw = false;
291  mVertexes->clear();
292  graphics->calcWindow(mVertexes,
293  0, 0,
295  rect);
296 
297  if (mImage != nullptr)
298  {
299  const Skin *const skin1 = tabImg[TAB_STANDARD];
300  if (skin1 != nullptr)
301  {
302  const int padding = skin1->getPadding();
303  graphics->calcTileCollection(mVertexes,
304  mImage,
305  padding,
306  padding);
307  }
308  }
309  graphics->finalize(mVertexes);
310  }
311 
312  graphics->drawTileCollection(mVertexes);
313 
314  drawChildren(graphics);
315  BLOCK_END("Tab::draw")
316 }
virtual void drawChildren(Graphics *const graphics)
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:465
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
void setForegroundColorAll(const Color &color1, const Color &color2)
Definition: label.cpp:217
int width
Definition: rect.h:219
int height
Definition: rect.h:224
void updateAlpha()
Definition: tab.cpp:190
bool isTabSelected(const size_t index) const
Definition: tabbedarea.cpp:292
Rect mDimension
Definition: widget.h:1101
bool mRedraw
Definition: widget.h:1164
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, Graphics::calcTileCollection(), Graphics::calcWindow(), ImageCollection::clear(), BasicContainer::drawChildren(), Graphics::drawTileCollection(), Graphics::finalize(), Skin::getBorder(), Skin::getPadding(), Graphics::getRedraw(), Rect::height, TabbedArea::isTabSelected(), Widget::mDimension, mFlash, mFlashColor, mFlashOutlineColor, mHasMouse, mImage, mLabel, mLabelMode, mMode, mPlayerFlashColor, mPlayerFlashOutlineColor, Widget::mRedraw, mTabbedArea, mTabColor, mTabHighlightedColor, mTabHighlightedOutlineColor, mTabOutlineColor, mTabSelectedColor, mTabSelectedOutlineColor, mVertexes, Label::setForegroundColorAll(), TAB_HIGHLIGHTED, TAB_SELECTED, TAB_STANDARD, tabImg, updateAlpha(), and Rect::width.

◆ finalCleanup()

void Tab::finalCleanup ( )
static

Definition at line 488 of file tab.cpp.

489 {
490  for (int f = 0; f < TAB_COUNT; f ++)
491  {
492  tabImg[f] = nullptr;
493  }
494 }

References TAB_COUNT, and tabImg.

Referenced by Gui::~Gui().

◆ getCaption()

const std::string & Tab::getCaption ( ) const

Definition at line 473 of file tab.cpp.

474 {
475  return mLabel->getCaption();
476 }
const std::string & getCaption() const
Definition: label.h:133

References Label::getCaption(), and mLabel.

Referenced by TabbedArea::getCurrentWidget().

◆ getFlash()

int Tab::getFlash ( ) const
inline

Definition at line 178 of file tab.h.

179  { return mFlash; }

References mFlash.

Referenced by ChatTab::chatLog().

◆ getLabel()

Label* Tab::getLabel ( ) const
inline

Definition at line 187 of file tab.h.

188  { return mLabel; }

References mLabel.

◆ getTabbedArea()

TabbedArea * Tab::getTabbedArea ( ) const

Definition at line 453 of file tab.cpp.

454 {
455  return mTabbedArea;
456 }

References mTabbedArea.

Referenced by ChatTab::chatLog().

◆ init()

void Tab::init ( )
private

Load images if no other instances exist yet

Definition at line 154 of file tab.cpp.

155 {
156  addMouseListener(this);
157  setFocusable(false);
158  setFrameSize(0);
159  mFlash = 0;
160 
161  addWidgetListener(this);
162 
163  if (mInstances == 0)
164  {
165  // Load the skin
166  if (theme != nullptr)
167  {
168  for (int mode = 0; mode < TAB_COUNT; mode ++)
169  {
170  tabImg[mode] = theme->load(data[mode],
171  "tab.xml",
172  true,
174  }
175  }
176  updateAlpha();
177  }
178  mInstances++;
179 
180  add(mLabel);
181 
182  const Skin *const skin = tabImg[TAB_STANDARD];
183  if (skin == nullptr)
184  return;
185  const int padding = skin->getPadding();
186 
187  mLabel->setPosition(padding, padding);
188 }
void add(Widget *const widget)
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:168
void setFocusable(const bool focusable)
Definition: widget.cpp:192
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
void setPosition(const int x, const int y)
Definition: widget.cpp:161
uint32_t data

References BasicContainer::add(), Widget::addMouseListener(), Widget::addWidgetListener(), data, Skin::getPadding(), Theme::getThemePath(), Theme::load(), mFlash, mInstances, mLabel, Widget::setFocusable(), Widget::setFrameSize(), Widget::setPosition(), TAB_COUNT, TAB_STANDARD, tabImg, theme, and updateAlpha().

Referenced by Tab().

◆ mouseEntered()

void Tab::mouseEntered ( MouseEvent event)
virtual

Called when the mouse has entered into the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 478 of file tab.cpp.

479 {
480  mHasMouse = true;
481 }

References mHasMouse.

◆ mouseExited()

void Tab::mouseExited ( MouseEvent event)
virtual

Called when the mouse has exited the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 483 of file tab.cpp.

484 {
485  mHasMouse = false;
486 }

References mHasMouse.

◆ safeDraw()

void Tab::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 318 of file tab.cpp.

319 {
320  BLOCK_START("Tab::draw")
321  int mode = TAB_STANDARD;
322 
323  // check which type of tab to draw
324  if (mTabbedArea != nullptr)
325  {
326  int labelMode = mFlash;
327 
328  if (mTabbedArea->isTabSelected(this))
329  {
330  labelMode = 3;
331  mode = TAB_SELECTED;
332  // if tab is selected, it doesnt need to highlight activity
333  mFlash = 0;
334  }
335  else if (labelMode == 0)
336  {
337  if (mHasMouse)
338  {
339  labelMode = 4;
340  mode = TAB_HIGHLIGHTED;
341  }
342  }
343  else if (mHasMouse)
344  {
345  mode = TAB_HIGHLIGHTED;
346  }
347 
348  if (labelMode != mLabelMode)
349  {
350  mLabelMode = labelMode;
351  switch (labelMode)
352  {
353  case 0: // default state
354  default:
357  break;
358  case 1: // mFlash == 1
361  break;
362  case 2: // mFlash == 2
365  break;
366  case 3: // mTabbedArea->isTabSelected(this)
369  break;
370  case 4: // mHasMouse
373  break;
374  }
375  }
376  }
377 
378  const Skin *const skin = tabImg[mode];
379  if (skin == nullptr)
380  {
381  BLOCK_END("Tab::draw")
382  return;
383  }
384 
385  updateAlpha();
386 
387  graphics->drawImageRect(0, 0,
388  mDimension.width, mDimension.height,
389  skin->getBorder());
390  if (mImage != nullptr)
391  {
392  const Skin *const skin1 = tabImg[TAB_STANDARD];
393  if (skin1 != nullptr)
394  {
395  const int padding = skin1->getPadding();
396  graphics->drawImage(mImage, padding, padding);
397  }
398  }
399 
400  safeDrawChildren(graphics);
401  BLOCK_END("Tab::draw")
402 }
virtual void safeDrawChildren(Graphics *const graphics)
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final

References BLOCK_END, BLOCK_START, Graphics::drawImage(), Graphics::drawImageRect(), Skin::getBorder(), Skin::getPadding(), Rect::height, TabbedArea::isTabSelected(), Widget::mDimension, mFlash, mFlashColor, mFlashOutlineColor, mHasMouse, mImage, mLabel, mLabelMode, mPlayerFlashColor, mPlayerFlashOutlineColor, mTabbedArea, mTabColor, mTabHighlightedColor, mTabHighlightedOutlineColor, mTabOutlineColor, mTabSelectedColor, mTabSelectedOutlineColor, BasicContainer::safeDrawChildren(), Label::setForegroundColorAll(), TAB_HIGHLIGHTED, TAB_SELECTED, TAB_STANDARD, tabImg, updateAlpha(), and Rect::width.

◆ setCaption()

void Tab::setCaption ( const std::string &  caption)

◆ setCurrent()

virtual void Tab::setCurrent ( )
inlineprotectedvirtual

Reimplemented in SocialTab, SkillTab, and ChatTab.

Definition at line 211 of file tab.h.

212  { }

Referenced by TabbedArea::setSelectedTab().

◆ setFlash()

void Tab::setFlash ( const int  flash)
inline

Set tab flashing state

Definition at line 175 of file tab.h.

176  { mFlash = flash; mRedraw = true; }

References mFlash, and Widget::mRedraw.

Referenced by ChatTab::chatLog(), and ChatTab::setCurrent().

◆ setFlashTabColor()

void Tab::setFlashTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the flash color for the tab's text.

Definition at line 153 of file tab.h.

155  {
156  mFlashColor = color1;
157  mFlashOutlineColor = color2;
158  mRedraw = true;
159  }

References mFlashColor, mFlashOutlineColor, and Widget::mRedraw.

◆ setHighlightedTabColor()

void Tab::setHighlightedTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the highlighted color for the tab's text.

Definition at line 131 of file tab.h.

133  {
134  mTabHighlightedColor = color1;
136  mRedraw = true;
137  }

References Widget::mRedraw, mTabHighlightedColor, and mTabHighlightedOutlineColor.

Referenced by SocialGuildTab::SocialGuildTab(), SocialGuildTab2::SocialGuildTab2(), and SocialPartyTab::SocialPartyTab().

◆ setImage()

void Tab::setImage ( Image *const  image)

Definition at line 465 of file tab.cpp.

466 {
467  if (mImage != nullptr)
468  mImage->decRef();
469  mImage = image;
470  adjustSize();
471 }

References adjustSize(), and mImage.

Referenced by TabbedArea::addTab().

◆ setLabelFont()

void Tab::setLabelFont ( Font *const  font)

Definition at line 414 of file tab.cpp.

415 {
416  if (mLabel == nullptr)
417  return;
418 
419  mLabel->setFont(font);
420  mLabel->adjustSize();
421  adjustSize();
422  mRedraw = true;
423 }
void setFont(Font *const font)
Definition: widget.cpp:349

References Label::adjustSize(), adjustSize(), mLabel, Widget::mRedraw, and Widget::setFont().

Referenced by ChatWindow::addWhisperTab().

◆ setPlayerFlashTabColor()

void Tab::setPlayerFlashTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the player flash color for the tab's text.

Definition at line 164 of file tab.h.

166  {
167  mPlayerFlashColor = color1;
168  mPlayerFlashOutlineColor = color2;
169  mRedraw = true;
170  }

References mPlayerFlashColor, mPlayerFlashOutlineColor, and Widget::mRedraw.

◆ setSelectedTabColor()

void Tab::setSelectedTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the selected color for the tab's text.

Definition at line 142 of file tab.h.

144  {
145  mTabSelectedColor = color1;
146  mTabSelectedOutlineColor = color2;
147  mRedraw = true;
148  }

References Widget::mRedraw, mTabSelectedColor, and mTabSelectedOutlineColor.

Referenced by SocialGuildTab::SocialGuildTab(), SocialGuildTab2::SocialGuildTab2(), and SocialPartyTab::SocialPartyTab().

◆ setTabbedArea()

void Tab::setTabbedArea ( TabbedArea tabbedArea)

Definition at line 448 of file tab.cpp.

449 {
450  mTabbedArea = tabbedArea;
451 }

References mTabbedArea.

Referenced by TabbedArea::addTab().

◆ setTabColor()

void Tab::setTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the normal color for the tab's text.

Definition at line 120 of file tab.h.

122  {
123  mTabColor = color1;
124  mTabOutlineColor = color2;
125  mRedraw = true;
126  }

References Widget::mRedraw, mTabColor, and mTabOutlineColor.

Referenced by SocialGuildTab::SocialGuildTab(), SocialGuildTab2::SocialGuildTab2(), and SocialPartyTab::SocialPartyTab().

◆ updateAlpha()

void Tab::updateAlpha ( )

Update the alpha value to the graphic components.

Definition at line 190 of file tab.cpp.

191 {
192  const float alpha = std::max(settings.guiAlpha,
194 
195  if (alpha != mAlpha)
196  {
197  mAlpha = alpha;
198  for (int a = 0; a < 9; a++)
199  {
200  for (int t = 0; t < TAB_COUNT; t++)
201  {
202  Skin *const skin = tabImg[t];
203  if (skin != nullptr)
204  {
205  const ImageRect &rect = skin->getBorder();
206  Image *const image = rect.grid[a];
207  if (image != nullptr)
208  image->setAlpha(mAlpha);
209  }
210  }
211  }
212  }
213 }
Image * grid[9]
Definition: imagerect.h:42
float guiAlpha
Definition: settings.h:131
const ImageRect & getBorder() const
Definition: skin.h:68
static float mAlpha
Definition: tab.h:224
float getMinimumOpacity() const
Definition: theme.h:124
Settings settings
Definition: settings.cpp:32

References Skin::getBorder(), Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, settings, TAB_COUNT, tabImg, and theme.

Referenced by draw(), init(), and safeDraw().

◆ widgetMoved()

void Tab::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 409 of file tab.cpp.

410 {
411  mRedraw = true;
412 }

References Widget::mRedraw.

◆ widgetResized()

void Tab::widgetResized ( const Event event)
virtual

Invoked when a widget changes its size.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 404 of file tab.cpp.

405 {
406  mRedraw = true;
407 }

References Widget::mRedraw.

Friends And Related Function Documentation

◆ TabbedArea

friend class TabbedArea
friend

Definition at line 209 of file tab.h.

Field Documentation

◆ mAlpha

float Tab::mAlpha = 1.0
staticprivate

Definition at line 224 of file tab.h.

Referenced by updateAlpha().

◆ mFlash

int Tab::mFlash
private

Definition at line 236 of file tab.h.

Referenced by draw(), getFlash(), init(), safeDraw(), and setFlash().

◆ mFlashColor

const Color* Tab::mFlashColor
private

Definition at line 232 of file tab.h.

Referenced by draw(), safeDraw(), and setFlashTabColor().

◆ mFlashOutlineColor

const Color* Tab::mFlashOutlineColor
private

Definition at line 233 of file tab.h.

Referenced by draw(), safeDraw(), and setFlashTabColor().

◆ mHasMouse

bool Tab::mHasMouse
protected

Definition at line 243 of file tab.h.

Referenced by draw(), mouseEntered(), mouseExited(), and safeDraw().

◆ mImage

Image* Tab::mImage
private

Definition at line 238 of file tab.h.

Referenced by adjustSize(), draw(), safeDraw(), setImage(), and ~Tab().

◆ mInstances

int Tab::mInstances = 0
staticprivate

Number of tab instances

Definition at line 223 of file tab.h.

Referenced by init(), and ~Tab().

◆ mLabel

Label* Tab::mLabel
protected

Definition at line 214 of file tab.h.

Referenced by adjustSize(), draw(), getCaption(), getLabel(), init(), safeDraw(), setCaption(), setLabelFont(), and ~Tab().

◆ mLabelMode

int Tab::mLabelMode
private

Definition at line 240 of file tab.h.

Referenced by draw(), and safeDraw().

◆ mMode

int Tab::mMode
private

Definition at line 239 of file tab.h.

Referenced by draw().

◆ mPlayerFlashColor

const Color* Tab::mPlayerFlashColor
private

Definition at line 234 of file tab.h.

Referenced by draw(), safeDraw(), and setPlayerFlashTabColor().

◆ mPlayerFlashOutlineColor

const Color* Tab::mPlayerFlashOutlineColor
private

Definition at line 235 of file tab.h.

Referenced by draw(), safeDraw(), and setPlayerFlashTabColor().

◆ mTabbedArea

TabbedArea* Tab::mTabbedArea
protected

Definition at line 216 of file tab.h.

Referenced by adjustSize(), draw(), getTabbedArea(), safeDraw(), and setTabbedArea().

◆ mTabColor

const Color* Tab::mTabColor
private

Definition at line 226 of file tab.h.

Referenced by draw(), safeDraw(), and setTabColor().

◆ mTabHighlightedColor

const Color* Tab::mTabHighlightedColor
private

Definition at line 228 of file tab.h.

Referenced by draw(), safeDraw(), and setHighlightedTabColor().

◆ mTabHighlightedOutlineColor

const Color* Tab::mTabHighlightedOutlineColor
private

Definition at line 229 of file tab.h.

Referenced by draw(), safeDraw(), and setHighlightedTabColor().

◆ mTabOutlineColor

const Color* Tab::mTabOutlineColor
private

Definition at line 227 of file tab.h.

Referenced by draw(), safeDraw(), and setTabColor().

◆ mTabSelectedColor

const Color* Tab::mTabSelectedColor
private

Definition at line 230 of file tab.h.

Referenced by draw(), safeDraw(), and setSelectedTabColor().

◆ mTabSelectedOutlineColor

const Color* Tab::mTabSelectedOutlineColor
private

Definition at line 231 of file tab.h.

Referenced by draw(), safeDraw(), and setSelectedTabColor().

◆ mVertexes

ImageCollection* Tab::mVertexes
private

Definition at line 237 of file tab.h.

Referenced by draw(), and ~Tab().

◆ tabImg

Skin * Tab::tabImg
staticprivate

Tab state graphics

Definition at line 222 of file tab.h.

Referenced by adjustSize(), draw(), finalCleanup(), init(), safeDraw(), updateAlpha(), and ~Tab().


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