ManaPlus
Public Member Functions | Private Types | Private Member Functions | Private Attributes
TabbedArea Class Reference

#include <tabbedarea.h>

Inheritance diagram for TabbedArea:
ActionListener BasicContainer KeyListener MouseListener WidgetListener Widget WidgetDeathListener Widget2

Public Member Functions

 TabbedArea (const Widget2 *const widget)
 
 ~TabbedArea ()
 
void postInit ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
int getNumberOfTabs () const
 
TabgetTab (const std::string &name) const
 
TabgetTabByIndex (const int index) const
 
WidgetgetWidgetByIndex (const int index) const
 
WidgetgetWidget (const std::string &name) const
 
WidgetgetCurrentWidget () const
 
void addTab (Tab *const tab, Widget *const widget)
 
void addTab (const std::string &caption, Widget *const widget)
 
void addTab (Image *const image, Widget *const widget)
 
bool isTabSelected (const size_t index) const
 
bool isTabSelected (const Tab *const tab) const
 
bool isTabPresent (const Tab *const tab) const
 
void removeTab (Tab *const tab)
 
void removeAll (const bool del)
 
void logic ()
 
int getContainerHeight () const
 
void setSelectedTab (Tab *const tab)
 
void setSelectedTabDefault ()
 
void setSelectedTabByIndex (const size_t index)
 
int getSelectedTabIndex () const
 
TabgetSelectedTab () const
 
void setOpaque (const Opaque opaque)
 
bool isOpaque () const
 
void adjustSize ()
 
void setSelectedTabByName (const std::string &name)
 
void widgetResized (const Event &event)
 
void adjustTabPositions ()
 
void action (const ActionEvent &actionEvent)
 
void mousePressed (MouseEvent &event)
 
void enableScrollButtons (const bool enable)
 
void setRightMargin (const int n)
 
int getRightMargin () const
 
void setFollowDownScroll (const bool n)
 
bool getFollowDownScroll () const
 
void keyPressed (KeyEvent &event)
 
void setBlockSwitching (const bool b)
 
void setWidth (int width)
 
void setHeight (int height)
 
void setSize (int width, int height)
 
void setDimension (const Rect &dimension)
 
void death (const Event &event)
 
void setResizeHeight (bool b)
 
void adjustWidget (Widget *const widget) const
 
void selectNextTab ()
 
void selectPrevTab ()
 
WidgetgetTabContainer () const
 
WidgetgetWidgetContainer () const
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- 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 setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
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 ()
 
- 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 KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mouseExited (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 widgetMoved (const Event &event)
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Private Types

typedef std::vector< std::pair< Tab *, Widget * > > TabContainer
 

Private Member Functions

void updateArrowEnableState ()
 
void updateTabsWidth ()
 
void updateVisibleTabsWidth ()
 

Private Attributes

ButtonmArrowButton [2]
 
TabmSelectedTab
 
BasicContainer2mTabContainer
 
BasicContainer2mWidgetContainer
 
std::vector< Tab * > mTabsToDelete
 
TabContainer mTabs
 
int mTabsWidth
 
int mVisibleTabsWidth
 
unsigned int mTabScrollIndex
 
int mRightMargin
 
Opaque mOpaque
 
bool mEnableScrollButtons
 
bool mFollowDownScroll
 
bool mBlockSwitching
 
bool mResizeHeight
 

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 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
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- 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 KeyListener
 KeyListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- 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
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A tabbed area, the same as the guichan tabbed area in 0.8, but extended

Definition at line 84 of file tabbedarea.h.

Member Typedef Documentation

◆ TabContainer

typedef std::vector<std::pair<Tab*, Widget*> > TabbedArea::TabContainer
private

Definition at line 247 of file tabbedarea.h.

Constructor & Destructor Documentation

◆ TabbedArea()

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

Constructor.

Definition at line 79 of file tabbedarea.cpp.

References Widget::addKeyListener(), Widget::addMouseListener(), and Widget::setFocusable().

79  :
81  BasicContainer(widget),
82  KeyListener(),
83  MouseListener(),
85  mArrowButton(),
86  mSelectedTab(nullptr),
87  mTabContainer(new BasicContainer2(widget)),
88  mWidgetContainer(new BasicContainer2(widget)),
89  mTabsToDelete(),
90  mTabs(),
91  mTabsWidth(0),
93  mTabScrollIndex(0),
94  mRightMargin(0),
96  mEnableScrollButtons(false),
97  mFollowDownScroll(false),
98  mBlockSwitching(true),
99  mResizeHeight(true)
100 {
101  setFocusable(true);
102  addKeyListener(this);
103  addMouseListener(this);
104 }
int mVisibleTabsWidth
Definition: tabbedarea.h:281
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
bool mBlockSwitching
Definition: tabbedarea.h:295
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
bool mResizeHeight
Definition: tabbedarea.h:296
Tab * mSelectedTab
Definition: tabbedarea.h:261
unsigned int mTabScrollIndex
Definition: tabbedarea.h:289
TabContainer mTabs
Definition: tabbedarea.h:265
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
const bool Opaque_false
Definition: opaque.h:29
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
Opaque mOpaque
Definition: tabbedarea.h:292
Button * mArrowButton[2]
Definition: tabbedarea.h:250
bool mFollowDownScroll
Definition: tabbedarea.h:294
void setFocusable(const bool focusable)
Definition: widget.cpp:191
int mRightMargin
Definition: tabbedarea.h:290
std::vector< Tab * > mTabsToDelete
Definition: tabbedarea.h:264
bool mEnableScrollButtons
Definition: tabbedarea.h:293
int mTabsWidth
Definition: tabbedarea.h:270
BasicContainer(const Widget2 *const widget)

◆ ~TabbedArea()

TabbedArea::~TabbedArea ( )

Definition at line 130 of file tabbedarea.cpp.

References delete2, gui, mArrowButton, mTabContainer, mTabsToDelete, mWidgetContainer, and Gui::removeDragged().

131 {
132  if (gui != nullptr)
133  gui->removeDragged(this);
134 
135  // +++ virtual method calls
136  remove(mTabContainer);
137  remove(mWidgetContainer);
138 
141 
142  for (size_t i = 0, sz = mTabsToDelete.size(); i < sz; i++)
144 
145  delete2(mArrowButton[0]);
146  delete2(mArrowButton[1]);
147 }
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
Gui * gui
Definition: gui.cpp:110
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
#define delete2(var)
Definition: delete2.h:24
Button * mArrowButton[2]
Definition: tabbedarea.h:250
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1160
std::vector< Tab * > mTabsToDelete
Definition: tabbedarea.h:264

Member Function Documentation

◆ action()

void TabbedArea::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 646 of file tabbedarea.cpp.

References adjustTabPositions(), CAST_SIZE, ActionEvent::getId(), Event::getSource(), mTabs, mTabScrollIndex, setSelectedTab(), and updateArrowEnableState().

Referenced by isOpaque().

647 {
648  Widget *const source = actionEvent.getSource();
649  Tab *const tab = dynamic_cast<Tab *>(source);
650 
651  if (tab != nullptr)
652  {
653  setSelectedTab(tab);
654  }
655  else
656  {
657  const std::string &eventId = actionEvent.getId();
658  if (eventId == "shift_left")
659  {
660  if (mTabScrollIndex != 0u)
661  --mTabScrollIndex;
662  }
663  else if (eventId == "shift_right")
664  {
665  if (CAST_SIZE(mTabScrollIndex) < mTabs.size() - 1)
666  ++mTabScrollIndex;
667  }
670  }
671 }
void adjustTabPositions()
Definition: tabbedarea.cpp:604
Definition: tab.h:84
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
void updateArrowEnableState()
Definition: tabbedarea.cpp:673
Widget * getSource() const
Definition: event.h:103
const std::string & getId() const
Definition: actionevent.h:121
unsigned int mTabScrollIndex
Definition: tabbedarea.h:289
TabContainer mTabs
Definition: tabbedarea.h:265
Definition: widget.h:97
#define CAST_SIZE
Definition: cast.h:33

◆ addTab() [1/3]

void TabbedArea::addTab ( Tab *const  tab,
Widget *const  widget 
)

Add a tab. Overridden since it needs to size the widget.

Parameters
tabThe tab widget for the tab.
widgetThe widget to view when the tab is selected.

Definition at line 237 of file tabbedarea.cpp.

References BasicContainer2::add(), Widget::addActionListener(), adjustSize(), adjustTabPositions(), Widget::getHeight(), Widget::getWidth(), Widget::mFrameSize, mSelectedTab, mTabContainer, mTabs, Widget::mVisible, setSelectedTab(), Widget::setSize(), Tab::setTabbedArea(), updateArrowEnableState(), updateTabsWidth(), Visible_true, and widgetResized().

Referenced by SkillDialog::addDefaultTab(), SocialWindow::addTab(), ShortcutWindow::addTab(), StatusWindow::addTab(), addTab(), ChatWindow::addTab(), StatusWindow::addTabBasic(), ClanWindow::ClanWindow(), DebugWindow::DebugWindow(), SetupWindow::externalUpdate(), SkillDialog::loadXmlFile(), EmoteWindow::postInit(), SetupWindow::postInit(), and SocialWindow::postInit().

239 {
240  if ((tab == nullptr) || (widget == nullptr))
241  return;
242 
243  tab->setTabbedArea(this);
244  tab->addActionListener(this);
245 
246  mTabContainer->add(tab);
247  mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
248 
249  if ((mSelectedTab == nullptr) && tab->mVisible == Visible_true)
250  setSelectedTab(tab);
251 
253  adjustSize();
254 
255  const int frameSize = 2 * mFrameSize;
256  widget->setSize(getWidth() - frameSize,
257  getHeight() - frameSize - mTabContainer->getHeight());
258 
259  widgetResized(Event(nullptr));
260  updateTabsWidth();
262 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustTabPositions()
Definition: tabbedarea.cpp:604
int getWidth() const
Definition: widget.h:220
const bool Visible_true
Definition: visible.h:29
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
Visible mVisible
Definition: widget.h:962
void updateArrowEnableState()
Definition: tabbedarea.cpp:673
Tab * mSelectedTab
Definition: tabbedarea.h:261
unsigned int mFrameSize
Definition: widget.h:1137
virtual void add(Widget *const widget)
void widgetResized(const Event &event)
Definition: tabbedarea.cpp:473
TabContainer mTabs
Definition: tabbedarea.h:265
void updateTabsWidth()
Definition: tabbedarea.cpp:544
void adjustSize()
Definition: tabbedarea.cpp:567
Definition: event.h:77
void setTabbedArea(TabbedArea *tabbedArea)
Definition: tab.cpp:447
int getHeight() const
Definition: widget.h:239

◆ addTab() [2/3]

void TabbedArea::addTab ( const std::string &  caption,
Widget *const  widget 
)

Definition at line 273 of file tabbedarea.cpp.

References addTab(), mTabsToDelete, and Tab::setCaption().

274 {
275  Tab *const tab = new Tab(this);
276  tab->setCaption(caption);
277  mTabsToDelete.push_back(tab);
278 
279  addTab(tab, widget);
280 }
void setCaption(const std::string &caption)
Definition: tab.cpp:457
Definition: tab.h:84
std::vector< Tab * > mTabsToDelete
Definition: tabbedarea.h:264
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:237

◆ addTab() [3/3]

void TabbedArea::addTab ( Image *const  image,
Widget *const  widget 
)

Definition at line 282 of file tabbedarea.cpp.

References addTab(), mTabsToDelete, and Tab::setImage().

283 {
284  Tab *const tab = new Tab(this);
285  tab->setImage(image);
286  mTabsToDelete.push_back(tab);
287 
288  addTab(tab, widget);
289 }
Definition: tab.h:84
void setImage(Image *const image)
Definition: tab.cpp:464
std::vector< Tab * > mTabsToDelete
Definition: tabbedarea.h:264
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:237

◆ adjustSize()

void TabbedArea::adjustSize ( )

Definition at line 567 of file tabbedarea.cpp.

References getCurrentWidget(), Widget::getFrameSize(), Widget::getHeight(), Widget::getWidth(), Rect::height, Widget::mDimension, mResizeHeight, mRightMargin, mTabContainer, mTabs, mWidgetContainer, Widget::setPosition(), Widget::setSize(), and Rect::width.

Referenced by addTab(), StatusWindow::addTabs(), ChatWindow::adjustTabSize(), isOpaque(), removeTab(), setDimension(), setHeight(), setSize(), setWidth(), SocialWindow::widgetResized(), SkillDialog::widgetResized(), and widgetResized().

568 {
569  int maxTabHeight = 0;
570 
571  const int width = mDimension.width;
572  const int height = mDimension.height;
573 
574  for (size_t i = 0, sz = mTabs.size(); i < sz; i++)
575  {
576  if (mTabs[i].first->getHeight() > maxTabHeight)
577  maxTabHeight = mTabs[i].first->getHeight();
578  }
579 
580  mTabContainer->setSize(width - mRightMargin, maxTabHeight);
581 
582  mWidgetContainer->setPosition(0, maxTabHeight);
583  mWidgetContainer->setSize(width, height - maxTabHeight);
584  Widget *const w = getCurrentWidget();
585  if (w != nullptr)
586  {
587  const int wFrameSize = w->getFrameSize();
588  const int frame2 = 2 * wFrameSize;
589 
590  w->setPosition(wFrameSize, wFrameSize);
591  if (mResizeHeight)
592  {
593  w->setSize(mWidgetContainer->getWidth() - frame2,
594  mWidgetContainer->getHeight() - frame2);
595  }
596  else
597  {
598  w->setSize(mWidgetContainer->getWidth() - frame2,
599  w->getHeight());
600  }
601  }
602 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int width
Definition: rect.h:218
int getWidth() const
Definition: widget.h:220
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
Widget * getCurrentWidget() const
Definition: tabbedarea.cpp:228
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
unsigned int getFrameSize() const
Definition: widget.h:183
bool mResizeHeight
Definition: tabbedarea.h:296
TabContainer mTabs
Definition: tabbedarea.h:265
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int height
Definition: rect.h:223
int mRightMargin
Definition: tabbedarea.h:290
Definition: widget.h:97
int getHeight() const
Definition: widget.h:239
Rect mDimension
Definition: widget.h:1100

◆ adjustTabPositions()

void TabbedArea::adjustTabPositions ( )

Definition at line 604 of file tabbedarea.cpp.

References Widget::getHeight(), Widget::getWidth(), mArrowButton, mEnableScrollButtons, mTabs, mTabScrollIndex, Widget::mVisible, Widget::setPosition(), Visible_false, Visible_true, and x.

Referenced by action(), SkillDialog::addDefaultTab(), SkillDialog::addSkill(), addTab(), Tab::adjustSize(), isOpaque(), SkillDialog::updateSkill(), and widgetResized().

605 {
606  int maxTabHeight = 0;
607  const size_t sz = mTabs.size();
608  for (size_t i = 0; i < sz; ++i)
609  {
610  const Tab *const tab = mTabs[i].first;
611  if ((tab != nullptr) &&
612  tab->mVisible == Visible_true &&
613  tab->getHeight() > maxTabHeight)
614  {
615  maxTabHeight = tab->getHeight();
616  }
617  }
618 
620  ? mArrowButton[0]->getWidth() : 0;
621  for (size_t i = mTabScrollIndex; i < sz; ++i)
622  {
623  Tab *const tab = mTabs[i].first;
624  if ((tab == nullptr) || tab->mVisible == Visible_false)
625  continue;
626  tab->setPosition(x, maxTabHeight - tab->getHeight());
627  x += tab->getWidth();
628  }
629 
630  // If the tabs are scrolled, we hide them away.
631  if (mTabScrollIndex > 0)
632  {
633  x = 0;
634  for (unsigned i = 0; i < mTabScrollIndex; ++i)
635  {
636  Tab *const tab = mTabs[i].first;
637  if ((tab != nullptr) && tab->mVisible == Visible_true)
638  {
639  x -= tab->getWidth();
640  tab->setPosition(x, maxTabHeight - tab->getHeight());
641  }
642  }
643  }
644 }
int getWidth() const
Definition: widget.h:220
const bool Visible_true
Definition: visible.h:29
Definition: tab.h:84
Visible mVisible
Definition: widget.h:962
const bool Visible_false
Definition: visible.h:29
unsigned int mTabScrollIndex
Definition: tabbedarea.h:289
TabContainer mTabs
Definition: tabbedarea.h:265
void setPosition(const int x, const int y)
Definition: widget.cpp:160
Button * mArrowButton[2]
Definition: tabbedarea.h:250
int getHeight() const
Definition: widget.h:239
bool mEnableScrollButtons
Definition: tabbedarea.h:293

◆ adjustWidget()

void TabbedArea::adjustWidget ( Widget *const  widget) const

Definition at line 264 of file tabbedarea.cpp.

References Widget::getHeight(), Widget::getWidth(), Widget::mFrameSize, mTabContainer, and Widget::setSize().

Referenced by setResizeHeight(), and EmoteWindow::widgetResized().

265 {
266  if (widget == nullptr)
267  return;
268  const int frameSize = 2 * mFrameSize;
269  widget->setSize(getWidth() - frameSize,
270  getHeight() - frameSize - mTabContainer->getHeight());
271 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
int getWidth() const
Definition: widget.h:220
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
unsigned int mFrameSize
Definition: widget.h:1137
int getHeight() const
Definition: widget.h:239

◆ death()

void TabbedArea::death ( const Event event)
virtual

Called when a widget dies. It is used to be able to recieve a notification when a death of a widget occurs.

Parameters
eventThe event of the death.

Reimplemented from BasicContainer.

Definition at line 806 of file tabbedarea.cpp.

References BasicContainer::death(), and removeTab().

Referenced by setBlockSwitching().

807 {
808  Tab *const tab = dynamic_cast<Tab*>(event.getSource());
809 
810  if (tab != nullptr)
811  removeTab(tab);
812  else
813  BasicContainer::death(event);
814 }
Definition: tab.h:84
void removeTab(Tab *const tab)
Definition: tabbedarea.cpp:322
void death(const Event &event)

◆ draw()

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

Draw the tabbed area.

Implements Widget.

Definition at line 187 of file tabbedarea.cpp.

References BLOCK_END, BLOCK_START, BasicContainer::drawChildren(), and mTabs.

188 {
189  BLOCK_START("TabbedArea::draw")
190  if (mTabs.empty())
191  {
192  BLOCK_END("TabbedArea::draw")
193  return;
194  }
195 
196  drawChildren(graphics);
198 }
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
void draw(Graphics *const graphics)
Definition: tabbedarea.cpp:187
TabContainer mTabs
Definition: tabbedarea.h:265
std::string empty
Definition: podict.cpp:25
virtual void drawChildren(Graphics *const graphics)

◆ enableScrollButtons()

void TabbedArea::enableScrollButtons ( const bool  enable)

Definition at line 149 of file tabbedarea.cpp.

References BasicContainer::add(), mArrowButton, and mEnableScrollButtons.

Referenced by ChatWindow::ChatWindow(), isOpaque(), and SetupWindow::postInit().

150 {
151  if (mEnableScrollButtons && !enable)
152  {
153  if (mArrowButton[0] != nullptr)
154  remove(mArrowButton[0]);
155  if (mArrowButton[1] != nullptr)
156  remove(mArrowButton[1]);
157  }
158  else if (!mEnableScrollButtons && enable)
159  {
160  if (mArrowButton[0] != nullptr)
161  add(mArrowButton[0]);
162  if (mArrowButton[1] != nullptr)
163  add(mArrowButton[1]);
164  }
165  mEnableScrollButtons = enable;
166 }
void add(Widget *const widget)
Button * mArrowButton[2]
Definition: tabbedarea.h:250
bool mEnableScrollButtons
Definition: tabbedarea.h:293

◆ getContainerHeight()

int TabbedArea::getContainerHeight ( ) const
inline

◆ getCurrentWidget()

Widget * TabbedArea::getCurrentWidget ( ) const

Returns the widget for the current tab

Definition at line 228 of file tabbedarea.cpp.

References Tab::getCaption(), getSelectedTab(), and getWidget().

Referenced by adjustSize(), ShortcutWindow::widgetHidden(), and widgetResized().

229 {
230  const Tab *const tab = getSelectedTab();
231 
232  if (tab != nullptr)
233  return getWidget(tab->getCaption());
234  return nullptr;
235 }
Widget * getWidget(const std::string &name) const
Definition: tabbedarea.cpp:213
Definition: tab.h:84
Tab * getSelectedTab() const
Definition: tabbedarea.h:174
const std::string & getCaption() const
Definition: tab.cpp:472

◆ getFollowDownScroll()

bool TabbedArea::getFollowDownScroll ( ) const
inline

Definition at line 213 of file tabbedarea.h.

References keyPressed(), and mFollowDownScroll.

214  { return mFollowDownScroll; }
bool mFollowDownScroll
Definition: tabbedarea.h:294

◆ getNumberOfTabs()

int TabbedArea::getNumberOfTabs ( ) const

Return how many tabs have been created.

Definition at line 168 of file tabbedarea.cpp.

References CAST_S32, and mTabs.

Referenced by ChatWindow::nextTab(), ChatWindow::prevTab(), removeAll(), and ChatWindow::selectTabByType().

169 {
170  return CAST_S32(mTabs.size());
171 }
#define CAST_S32
Definition: cast.h:29
TabContainer mTabs
Definition: tabbedarea.h:265

◆ getRightMargin()

int TabbedArea::getRightMargin ( ) const
inline

Definition at line 207 of file tabbedarea.h.

References mRightMargin.

208  { return mRightMargin; }
int mRightMargin
Definition: tabbedarea.h:290

◆ getSelectedTab()

Tab* TabbedArea::getSelectedTab ( ) const
inline

◆ getSelectedTabIndex()

int TabbedArea::getSelectedTabIndex ( ) const

Definition at line 448 of file tabbedarea.cpp.

References CAST_U32, mSelectedTab, and mTabs.

Referenced by ChatWindow::closeTab(), getContainerHeight(), ShortcutWindow::getTabIndex(), keyPressed(), ChatWindow::nextTab(), ChatWindow::prevTab(), removeAll(), removeTab(), selectNextTab(), selectPrevTab(), ClanWindow::slowLogic(), and DebugWindow::slowLogic().

449 {
450  for (unsigned int i = 0, fsz = CAST_U32(mTabs.size());
451  i < fsz;
452  i++)
453  {
454  if (mTabs[i].first == mSelectedTab)
455  return i;
456  }
457 
458  return -1;
459 }
#define CAST_U32
Definition: cast.h:30
Tab * mSelectedTab
Definition: tabbedarea.h:261
TabContainer mTabs
Definition: tabbedarea.h:265

◆ getTab()

Tab * TabbedArea::getTab ( const std::string &  name) const

Return tab with specified name as caption.

Definition at line 173 of file tabbedarea.cpp.

References mTabs.

Referenced by SetupWindow::unloadTab().

174 {
175  TabContainer::const_iterator itr = mTabs.begin();
176  const TabContainer::const_iterator itr_end = mTabs.end();
177  while (itr != itr_end)
178  {
179  if ((*itr).first->getCaption() == name)
180  return static_cast<Tab*>((*itr).first);
181 
182  ++itr;
183  }
184  return nullptr;
185 }
TabContainer mTabs
Definition: tabbedarea.h:265

◆ getTabByIndex()

Tab * TabbedArea::getTabByIndex ( const int  index) const

Definition at line 713 of file tabbedarea.cpp.

References CAST_S32, and mTabs.

Referenced by ChatWindow::closeTab(), ChatWindow::joinRoom(), ChatWindow::selectTabByType(), and EmoteWindow::~EmoteWindow().

714 {
715  if (index < 0 || index >= CAST_S32(mTabs.size()))
716  return nullptr;
717  return static_cast<Tab*>(mTabs[index].first);
718 }
Definition: tab.h:84
#define CAST_S32
Definition: cast.h:29
TabContainer mTabs
Definition: tabbedarea.h:265

◆ getTabContainer()

Widget* TabbedArea::getTabContainer ( ) const
inline

◆ getWidget()

Widget * TabbedArea::getWidget ( const std::string &  name) const

Returns the widget with the tab that has specified caption

Definition at line 213 of file tabbedarea.cpp.

References mTabs.

Referenced by getCurrentWidget().

214 {
215  TabContainer::const_iterator itr = mTabs.begin();
216  const TabContainer::const_iterator itr_end = mTabs.end();
217  while (itr != itr_end)
218  {
219  if ((*itr).first->getCaption() == name)
220  return (*itr).second;
221 
222  ++itr;
223  }
224 
225  return nullptr;
226 }
TabContainer mTabs
Definition: tabbedarea.h:265

◆ getWidgetByIndex()

Widget * TabbedArea::getWidgetByIndex ( const int  index) const

Definition at line 720 of file tabbedarea.cpp.

References CAST_S32, and mTabs.

721 {
722  if (index < 0 || index >= CAST_S32(mTabs.size()))
723  return nullptr;
724  return mTabs[index].second;
725 }
#define CAST_S32
Definition: cast.h:29
TabContainer mTabs
Definition: tabbedarea.h:265

◆ getWidgetContainer()

Widget* TabbedArea::getWidgetContainer ( ) const
inline

◆ isOpaque()

bool TabbedArea::isOpaque ( ) const
inline

Definition at line 180 of file tabbedarea.h.

References action(), adjustSize(), adjustTabPositions(), enableScrollButtons(), mOpaque, mousePressed(), Opaque_true, setSelectedTabByName(), and widgetResized().

181  { return mOpaque == Opaque_true; }
Opaque mOpaque
Definition: tabbedarea.h:292
const bool Opaque_true
Definition: opaque.h:29

◆ isTabPresent()

bool TabbedArea::isTabPresent ( const Tab *const  tab) const

Definition at line 299 of file tabbedarea.cpp.

References FOR_EACH, and mTabs.

Referenced by ChatWindow::isTabPresent().

300 {
301  FOR_EACH (TabContainer::const_iterator, it, mTabs)
302  {
303  if ((*it).first == tab || (*it).second == tab)
304  return true;
305  }
306  return false;
307 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
TabContainer mTabs
Definition: tabbedarea.h:265

◆ isTabSelected() [1/2]

bool TabbedArea::isTabSelected ( const size_t  index) const

Definition at line 291 of file tabbedarea.cpp.

References mSelectedTab, and mTabs.

Referenced by Tab::draw(), and Tab::safeDraw().

292 {
293  if (index >= mTabs.size())
294  return false;
295 
296  return mSelectedTab == mTabs[index].first;
297 }
Tab * mSelectedTab
Definition: tabbedarea.h:261
TabContainer mTabs
Definition: tabbedarea.h:265

◆ isTabSelected() [2/2]

bool TabbedArea::isTabSelected ( const Tab *const  tab) const

Definition at line 309 of file tabbedarea.cpp.

References mSelectedTab.

310 {
311  return mSelectedTab == tab;
312 }
Tab * mSelectedTab
Definition: tabbedarea.h:261

◆ keyPressed()

void TabbedArea::keyPressed ( KeyEvent event)
virtual

Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.

Parameters
eventDiscribes the event.

Reimplemented from KeyListener.

Definition at line 775 of file tabbedarea.cpp.

References CAST_S32, getSelectedTabIndex(), InputAction::GUI_LEFT, InputAction::GUI_RIGHT, InputGuiEvent::isConsumed(), Widget::isFocused(), mBlockSwitching, mTabs, and setSelectedTab().

Referenced by getFollowDownScroll().

776 {
777  if (mBlockSwitching || event.isConsumed() || !isFocused())
778  return;
779 
780  const InputActionT actionId = event.getActionId();
781 
782  if (actionId == InputAction::GUI_LEFT)
783  {
784  int index = getSelectedTabIndex();
785  index--;
786 
787  if (index < 0)
788  return;
789 
790  setSelectedTab(mTabs[index].first);
791  event.consume();
792  }
793  else if (actionId == InputAction::GUI_RIGHT)
794  {
795  int index = getSelectedTabIndex();
796  index++;
797 
798  if (index >= CAST_S32(mTabs.size()))
799  return;
800 
801  setSelectedTab(mTabs[index].first);
802  event.consume();
803  }
804 }
bool mBlockSwitching
Definition: tabbedarea.h:295
virtual bool isFocused() const
Definition: widget.cpp:183
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
#define CAST_S32
Definition: cast.h:29
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:448
InputAction ::T InputActionT
Definition: inputaction.h:715
TabContainer mTabs
Definition: tabbedarea.h:265
bool isConsumed() const

◆ logic()

void TabbedArea::logic ( )
virtual

Overload the logic function since it's broken in guichan 0.8.

Reimplemented from BasicContainer.

Definition at line 379 of file tabbedarea.cpp.

References BLOCK_END, BLOCK_START, and BasicContainer::logicChildren().

380 {
381  BLOCK_START("TabbedArea::logic")
382  logicChildren();
384 }
void logic()
Definition: tabbedarea.cpp:379
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
virtual void logicChildren()

◆ mousePressed()

void TabbedArea::mousePressed ( MouseEvent event)
virtual

Called when a mouse button has been pressed on the widget area.

NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 386 of file tabbedarea.cpp.

References MouseEvent::getButton(), BasicContainer::getWidgetAt(), MouseEvent::getX(), InputGuiEvent::isConsumed(), MouseButton::LEFT, mTabContainer, Widget::requestFocus(), and setSelectedTab().

Referenced by isOpaque().

387 {
388  if (event.isConsumed())
389  return;
390 
391  if (event.getButton() == MouseButton::LEFT)
392  {
393  Widget *const widget = mTabContainer->getWidgetAt(
394  event.getX(), event.getY());
395  Tab *const tab = dynamic_cast<Tab *>(widget);
396 
397  if (tab != nullptr)
398  {
399  event.consume();
400  setSelectedTab(tab);
401  requestFocus();
402  }
403  }
404 }
Definition: tab.h:84
MouseButtonT getButton() const
Definition: mouseevent.h:115
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
Widget * getWidgetAt(int x, int y)
virtual void requestFocus()
Definition: widget.cpp:203
bool isConsumed() const
Definition: widget.h:97
int getX() const
Definition: mouseevent.h:126

◆ postInit()

void TabbedArea::postInit ( )
virtual

Reimplemented from Widget.

Definition at line 106 of file tabbedarea.cpp.

References BasicContainer::add(), Widget::addWidgetListener(), BUTTON_SKIN, mArrowButton, mTabContainer, mWidgetContainer, Opaque_false, BasicContainer2::setOpaque(), and widgetResized().

107 {
109 
112 
114  addWidgetListener(this);
115 
116  mArrowButton[0] = new Button(this,
117  "<",
118  "shift_left",
119  BUTTON_SKIN,
120  this);
121  mArrowButton[1] = new Button(this,
122  ">",
123  "shift_right",
124  BUTTON_SKIN,
125  this);
126 
127  widgetResized(Event(nullptr));
128 }
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
Definition: button.h:96
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
const std::string BUTTON_SKIN
Definition: button.h:88
void add(Widget *const widget)
void widgetResized(const Event &event)
Definition: tabbedarea.cpp:473
const bool Opaque_false
Definition: opaque.h:29
Button * mArrowButton[2]
Definition: tabbedarea.h:250
void setOpaque(Opaque opaque)
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
Definition: event.h:77

◆ removeAll()

void TabbedArea::removeAll ( const bool  del)

Definition at line 727 of file tabbedarea.cpp.

References CAST_U32, getNumberOfTabs(), getSelectedTabIndex(), mTabs, removeTab(), and setSelectedTabByIndex().

Referenced by SkillDialog::clearSkills(), EmoteWindow::~EmoteWindow(), and ShortcutWindow::~ShortcutWindow().

728 {
729  if (getSelectedTabIndex() != -1)
730  {
732  }
733  while (getNumberOfTabs() > 0)
734  {
735  const int idx = getNumberOfTabs() - 1;
736  Tab *tab = mTabs[idx].first;
737  Widget *widget = mTabs[idx].second;
738  removeTab(tab);
739  if (del)
740  {
741  delete tab;
742  delete widget;
743  }
744  }
745 }
#define CAST_U32
Definition: cast.h:30
Definition: tab.h:84
void removeTab(Tab *const tab)
Definition: tabbedarea.cpp:322
int getNumberOfTabs() const
Definition: tabbedarea.cpp:168
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:448
TabContainer mTabs
Definition: tabbedarea.h:265
void setSelectedTabByIndex(const size_t index)
Definition: tabbedarea.cpp:314
Definition: widget.h:97

◆ removeTab()

void TabbedArea::removeTab ( Tab *const  tab)

Overload the remove tab function as it's broken in guichan 0.8.

Definition at line 322 of file tabbedarea.cpp.

References adjustSize(), CAST_S32, BasicContainer::clear(), getSelectedTabIndex(), mSelectedTab, mTabContainer, mTabs, mTabsToDelete, mWidgetContainer, BasicContainer::remove(), setSelectedTabByIndex(), updateTabsWidth(), and widgetResized().

Referenced by death(), removeAll(), SocialWindow::removeTab(), ChatWindow::removeTab(), SetupWindow::unloadTab(), and EmoteWindow::~EmoteWindow().

323 {
324  int tabIndexToBeSelected = -1;
325 
326  if (tab == mSelectedTab)
327  {
328  const int index = getSelectedTabIndex();
329  const size_t sz = mTabs.size();
330  if (index == CAST_S32(sz) - 1 && sz == 1)
331  tabIndexToBeSelected = -1;
332  else
333  tabIndexToBeSelected = index - 1;
334  }
335 
336  for (TabContainer::iterator iter = mTabs.begin();
337  iter != mTabs.end(); ++iter)
338  {
339  if (iter->first == tab)
340  {
341  mTabContainer->remove(tab);
342  mTabs.erase(iter);
343  break;
344  }
345  }
346 
347  for (STD_VECTOR<Tab*>::iterator iter2 = mTabsToDelete.begin();
348  iter2 != mTabsToDelete.end(); ++iter2)
349  {
350  if (*iter2 == tab)
351  {
352  mTabsToDelete.erase(iter2);
353  delete tab;
354  break;
355  }
356  }
357 
358  const int tabsSize = CAST_S32(mTabs.size());
359  if (tabIndexToBeSelected >= tabsSize)
360  tabIndexToBeSelected = tabsSize - 1;
361  if (tabIndexToBeSelected < -1)
362  tabIndexToBeSelected = -1;
363 
364  if (tabIndexToBeSelected == -1)
365  {
366  mSelectedTab = nullptr;
368  }
369  else
370  {
371  setSelectedTabByIndex(tabIndexToBeSelected);
372  }
373 
374  adjustSize();
375  updateTabsWidth();
376  widgetResized(Event(nullptr));
377 }
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
virtual void clear()
#define CAST_S32
Definition: cast.h:29
Tab * mSelectedTab
Definition: tabbedarea.h:261
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:448
virtual void remove(Widget *const widget)
void widgetResized(const Event &event)
Definition: tabbedarea.cpp:473
TabContainer mTabs
Definition: tabbedarea.h:265
void updateTabsWidth()
Definition: tabbedarea.cpp:544
void setSelectedTabByIndex(const size_t index)
Definition: tabbedarea.cpp:314
void adjustSize()
Definition: tabbedarea.cpp:567
Definition: event.h:77
std::vector< Tab * > mTabsToDelete
Definition: tabbedarea.h:264

◆ safeDraw()

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

Implements Widget.

Definition at line 200 of file tabbedarea.cpp.

References BLOCK_END, BLOCK_START, mTabs, and BasicContainer::safeDrawChildren().

201 {
202  BLOCK_START("TabbedArea::draw")
203  if (mTabs.empty())
204  {
205  BLOCK_END("TabbedArea::draw")
206  return;
207  }
208 
209  safeDrawChildren(graphics);
211 }
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
void draw(Graphics *const graphics)
Definition: tabbedarea.cpp:187
TabContainer mTabs
Definition: tabbedarea.h:265
std::string empty
Definition: podict.cpp:25
virtual void safeDrawChildren(Graphics *const graphics)

◆ selectNextTab()

void TabbedArea::selectNextTab ( )

Definition at line 816 of file tabbedarea.cpp.

References CAST_S32, getSelectedTabIndex(), mTabs, and setSelectedTab().

Referenced by ShortcutWindow::nextTab(), SocialWindow::nextTab(), and setResizeHeight().

817 {
818  int tab = getSelectedTabIndex();
819  tab++;
820  if (tab == CAST_S32(mTabs.size()))
821  tab = 0;
822  setSelectedTab(mTabs[tab].first);
823 }
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
#define CAST_S32
Definition: cast.h:29
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:448
TabContainer mTabs
Definition: tabbedarea.h:265

◆ selectPrevTab()

void TabbedArea::selectPrevTab ( )

Definition at line 825 of file tabbedarea.cpp.

References CAST_S32, getSelectedTabIndex(), mTabs, and setSelectedTab().

Referenced by ShortcutWindow::prevTab(), SocialWindow::prevTab(), and setResizeHeight().

826 {
827  int tab = getSelectedTabIndex();
828 
829  if (tab == 0)
830  tab = CAST_S32(mTabs.size());
831  if (tab < 0)
832  return;
833  tab--;
834  setSelectedTab(mTabs[tab].first);
835 }
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
#define CAST_S32
Definition: cast.h:29
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:448
TabContainer mTabs
Definition: tabbedarea.h:265

◆ setBlockSwitching()

void TabbedArea::setBlockSwitching ( const bool  b)
inline

Definition at line 218 of file tabbedarea.h.

References death(), mBlockSwitching, setDimension(), setHeight(), setSize(), and setWidth().

219  { mBlockSwitching = b; }
bool mBlockSwitching
Definition: tabbedarea.h:295

◆ setDimension()

void TabbedArea::setDimension ( const Rect dimension)

Definition at line 768 of file tabbedarea.cpp.

References adjustSize(), and Widget::setDimension().

Referenced by ClanWindow::ClanWindow(), DebugWindow::DebugWindow(), SetupWindow::postInit(), setBlockSwitching(), ClanWindow::widgetResized(), DebugWindow::widgetResized(), and SetupWindow::widgetResized().

769 {
770  // +++ need use virtual
771  Widget::setDimension(dimension);
772  adjustSize();
773 }
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
void adjustSize()
Definition: tabbedarea.cpp:567

◆ setFollowDownScroll()

void TabbedArea::setFollowDownScroll ( const bool  n)
inline

Definition at line 210 of file tabbedarea.h.

References mFollowDownScroll.

Referenced by ChatWindow::ChatWindow().

211  { mFollowDownScroll = n; }
bool mFollowDownScroll
Definition: tabbedarea.h:294

◆ setHeight()

void TabbedArea::setHeight ( int  height)

Definition at line 754 of file tabbedarea.cpp.

References adjustSize(), and Widget::setHeight().

Referenced by ChatWindow::adjustTabSize(), EmoteWindow::postInit(), and setBlockSwitching().

755 {
756  // +++ need use virtual
757  Widget::setHeight(height);
758  adjustSize();
759 }
void setHeight(const int height)
Definition: widget.cpp:139
void adjustSize()
Definition: tabbedarea.cpp:567

◆ setOpaque()

void TabbedArea::setOpaque ( const Opaque  opaque)
inline

Definition at line 177 of file tabbedarea.h.

References mOpaque.

178  { mOpaque = opaque; }
Opaque mOpaque
Definition: tabbedarea.h:292

◆ setResizeHeight()

void TabbedArea::setResizeHeight ( bool  b)
inline

Definition at line 231 of file tabbedarea.h.

References adjustWidget(), mResizeHeight, selectNextTab(), and selectPrevTab().

Referenced by ChatWindow::ChatWindow().

232  { mResizeHeight = b; }
bool mResizeHeight
Definition: tabbedarea.h:296

◆ setRightMargin()

void TabbedArea::setRightMargin ( const int  n)
inline

Definition at line 204 of file tabbedarea.h.

References mRightMargin.

Referenced by ChatWindow::updateTabsMargin().

205  { mRightMargin = n; }
int mRightMargin
Definition: tabbedarea.h:290

◆ setSelectedTab()

void TabbedArea::setSelectedTab ( Tab *const  tab)

Definition at line 406 of file tabbedarea.cpp.

References BasicContainer2::add(), mSelectedTab, mTabs, mWidgetContainer, BasicContainer::remove(), Tab::setCurrent(), and widgetResized().

Referenced by action(), ChatWindow::addChannelTab(), ChatWindow::addSpecialChannelTab(), addTab(), ChatWindow::addWhisperTab(), getContainerHeight(), keyPressed(), mousePressed(), selectNextTab(), selectPrevTab(), ChatWindow::selectTabByType(), setSelectedTabByIndex(), setSelectedTabByName(), and setSelectedTabDefault().

407 {
408  for (size_t i = 0; i < mTabs.size(); i++)
409  {
410  if (mTabs[i].first == mSelectedTab)
411  mWidgetContainer->remove(mTabs[i].second);
412  }
413 
414  for (size_t i = 0; i < mTabs.size(); i++)
415  {
416  if (mTabs[i].first == tab)
417  {
418  mSelectedTab = tab;
419  mWidgetContainer->add(mTabs[i].second);
420  }
421  }
422 
423  Tab *const newTab = tab;
424 
425  if (newTab != nullptr)
426  newTab->setCurrent();
427 
428  widgetResized(Event(nullptr));
429 }
virtual void setCurrent()
Definition: tab.h:210
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
Definition: tab.h:84
Tab * mSelectedTab
Definition: tabbedarea.h:261
virtual void add(Widget *const widget)
virtual void remove(Widget *const widget)
void widgetResized(const Event &event)
Definition: tabbedarea.cpp:473
TabContainer mTabs
Definition: tabbedarea.h:265
Definition: event.h:77

◆ setSelectedTabByIndex()

void TabbedArea::setSelectedTabByIndex ( const size_t  index)

Definition at line 314 of file tabbedarea.cpp.

References mTabs, and setSelectedTab().

Referenced by ChatWindow::defaultTab(), getContainerHeight(), ChatWindow::nextTab(), ChatWindow::prevTab(), removeAll(), and removeTab().

315 {
316  if (index >= mTabs.size())
317  return;
318 
319  setSelectedTab(mTabs[index].first);
320 }
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
TabContainer mTabs
Definition: tabbedarea.h:265

◆ setSelectedTabByName()

void TabbedArea::setSelectedTabByName ( const std::string &  name)

Definition at line 461 of file tabbedarea.cpp.

References FOR_EACH, mTabs, and setSelectedTab().

Referenced by SetupWindow::activateTab(), and isOpaque().

462 {
463  FOR_EACH (TabContainer::const_iterator, itr, mTabs)
464  {
465  if (((*itr).first != nullptr) && (*itr).first->getCaption() == name)
466  {
467  setSelectedTab((*itr).first);
468  return;
469  }
470  }
471 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
TabContainer mTabs
Definition: tabbedarea.h:265

◆ setSelectedTabDefault()

void TabbedArea::setSelectedTabDefault ( )

Definition at line 431 of file tabbedarea.cpp.

References mSelectedTab, mTabs, Widget::mVisible, setSelectedTab(), Visible_false, and Visible_true.

Referenced by SkillDialog::addDefaultTab(), SkillDialog::addSkill(), getContainerHeight(), and SkillDialog::updateSkill().

432 {
433  if (mSelectedTab == nullptr ||
435  {
436  for (size_t i = 0; i < mTabs.size(); i++)
437  {
438  Tab *const tab = mTabs[i].first;
439  if ((tab != nullptr) && tab->mVisible == Visible_true)
440  {
441  setSelectedTab(tab);
442  return;
443  }
444  }
445  }
446 }
const bool Visible_true
Definition: visible.h:29
Definition: tab.h:84
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:406
Visible mVisible
Definition: widget.h:962
Tab * mSelectedTab
Definition: tabbedarea.h:261
const bool Visible_false
Definition: visible.h:29
TabContainer mTabs
Definition: tabbedarea.h:265

◆ setSize()

void TabbedArea::setSize ( int  width,
int  height 
)

Definition at line 761 of file tabbedarea.cpp.

References adjustSize(), and Widget::setSize().

Referenced by setBlockSwitching(), and EmoteWindow::widgetResized().

762 {
763  // +++ need use virtual
764  Widget::setSize(width, height);
765  adjustSize();
766 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustSize()
Definition: tabbedarea.cpp:567

◆ setWidth()

void TabbedArea::setWidth ( int  width)

Definition at line 747 of file tabbedarea.cpp.

References adjustSize(), and Widget::setWidth().

Referenced by ChatWindow::adjustTabSize(), EmoteWindow::postInit(), and setBlockSwitching().

748 {
749  // +++ need use virtual
750  Widget::setWidth(width);
751  adjustSize();
752 }
void setWidth(const int width)
Definition: widget.cpp:132
void adjustSize()
Definition: tabbedarea.cpp:567

◆ updateArrowEnableState()

void TabbedArea::updateArrowEnableState ( )
private

Check whether the arrow should be clickable

Definition at line 673 of file tabbedarea.cpp.

References Widget::getWidth(), mArrowButton, Widget::mDimension, mRightMargin, mTabScrollIndex, mTabsWidth, mVisibleTabsWidth, Widget::setEnabled(), Widget::setVisible(), updateTabsWidth(), Visible_false, Visible_true, and Rect::width.

Referenced by action(), addTab(), and widgetResized().

674 {
675  updateTabsWidth();
676  if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
677  return;
678 
679  const int width = mDimension.width;
680  if (mTabsWidth > width - 4
681  - mArrowButton[0]->getWidth()
683  {
686  }
687  else
688  {
691  mTabScrollIndex = 0;
692  }
693 
694  // Left arrow consistency check
695  if (mTabScrollIndex == 0u)
696  mArrowButton[0]->setEnabled(false);
697  else
698  mArrowButton[0]->setEnabled(true);
699 
700  // Right arrow consistency check
701  if (mVisibleTabsWidth < width - 4
702  - mArrowButton[0]->getWidth()
704  {
705  mArrowButton[1]->setEnabled(false);
706  }
707  else
708  {
709  mArrowButton[1]->setEnabled(true);
710  }
711 }
int width
Definition: rect.h:218
int mVisibleTabsWidth
Definition: tabbedarea.h:281
int getWidth() const
Definition: widget.h:220
const bool Visible_true
Definition: visible.h:29
void setVisible(Visible visible)
Definition: widget.cpp:224
const bool Visible_false
Definition: visible.h:29
unsigned int mTabScrollIndex
Definition: tabbedarea.h:289
void updateTabsWidth()
Definition: tabbedarea.cpp:544
Button * mArrowButton[2]
Definition: tabbedarea.h:250
void setEnabled(const bool enabled)
Definition: widget.h:351
int mRightMargin
Definition: tabbedarea.h:290
int mTabsWidth
Definition: tabbedarea.h:270
Rect mDimension
Definition: widget.h:1100

◆ updateTabsWidth()

void TabbedArea::updateTabsWidth ( )
private

Update the overall width of all tab. Used to know whether the arrows have to be drawn or not.

Definition at line 544 of file tabbedarea.cpp.

References FOR_EACH, Widget::getWidth(), mTabs, mTabsWidth, Widget::mVisible, updateVisibleTabsWidth(), and Visible_true.

Referenced by addTab(), removeTab(), and updateArrowEnableState().

545 {
546  mTabsWidth = 0;
547  FOR_EACH (TabContainer::const_iterator, itr, mTabs)
548  {
549  Tab *const tab = (*itr).first;
550  if ((tab != nullptr) && tab->mVisible == Visible_true)
551  mTabsWidth += tab->getWidth();
552  }
554 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int getWidth() const
Definition: widget.h:220
const bool Visible_true
Definition: visible.h:29
Definition: tab.h:84
Visible mVisible
Definition: widget.h:962
TabContainer mTabs
Definition: tabbedarea.h:265
int mTabsWidth
Definition: tabbedarea.h:270
void updateVisibleTabsWidth()
Definition: tabbedarea.cpp:556

◆ updateVisibleTabsWidth()

void TabbedArea::updateVisibleTabsWidth ( )
private

Update the overall width of visible tab. Used to know whether the arrows have to be enable or not.

Definition at line 556 of file tabbedarea.cpp.

References CAST_S32, Widget::getWidth(), mTabs, mTabScrollIndex, Widget::mVisible, mVisibleTabsWidth, and Visible_true.

Referenced by updateTabsWidth().

557 {
558  mVisibleTabsWidth = 0;
559  for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
560  {
561  Tab *const tab = mTabs[i].first;
562  if ((tab != nullptr) && tab->mVisible == Visible_true)
564  }
565 }
int mVisibleTabsWidth
Definition: tabbedarea.h:281
int getWidth() const
Definition: widget.h:220
const bool Visible_true
Definition: visible.h:29
Definition: tab.h:84
Visible mVisible
Definition: widget.h:962
#define CAST_S32
Definition: cast.h:29
unsigned int mTabScrollIndex
Definition: tabbedarea.h:289
TabContainer mTabs
Definition: tabbedarea.h:265

◆ widgetResized()

void TabbedArea::widgetResized ( const Event event)
virtual

Invoked when a widget changes its size.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 473 of file tabbedarea.cpp.

References adjustSize(), adjustTabPositions(), getCurrentWidget(), Widget::getDimension(), Widget::getFrameSize(), Widget::getHeight(), ScrollArea::getVerticalMaxScroll(), ScrollArea::getVerticalScrollAmount(), Widget::getWidth(), Widget::getY(), Rect::height, mArrowButton, Widget::mDimension, mFollowDownScroll, Widget::mFrameSize, mRightMargin, mTabs, mTabScrollIndex, Widget::mVisible, mVisibleTabsWidth, mWidgetContainer, Widget::setPosition(), Widget::setSize(), ScrollArea::setVerticalScrollAmount(), updateArrowEnableState(), Visible_true, and Rect::width.

Referenced by addTab(), isOpaque(), postInit(), removeTab(), and setSelectedTab().

474 {
475  adjustSize();
476 
477  const int frameSize = 2 * mFrameSize;
478  const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize();
479  const int w1 = mDimension.width;
480  const int h1 = mDimension.height;
481  const int width = w1 - frameSize - widgetFrameSize;
482  const int height = h1 - frameSize
483  - mWidgetContainer->getY() - widgetFrameSize;
484 
485  Widget *const w = getCurrentWidget();
486  ScrollArea *const scr = dynamic_cast<ScrollArea *>(w);
487  if (scr != nullptr)
488  {
489  if (mFollowDownScroll && height != 0)
490  {
491  const Rect &rect = w->getDimension();
492  if (rect.height != 0 && rect.height > height + 2)
493  {
494  if (scr->getVerticalScrollAmount()
495  >= scr->getVerticalMaxScroll() - 2
496  && scr->getVerticalScrollAmount()
497  <= scr->getVerticalMaxScroll() + 2)
498  {
499  const int newScroll = scr->getVerticalScrollAmount()
500  + rect.height - height;
501  w->setSize(mWidgetContainer->getWidth() - frameSize,
502  mWidgetContainer->getHeight() - frameSize);
503  if (newScroll != 0)
504  scr->setVerticalScrollAmount(newScroll);
505  }
506  }
507  }
508  }
509 
510  if (mArrowButton[1] != nullptr)
511  {
512  // Check whether there is room to show more tabs now.
513  int innerWidth = w1 - 4 - mArrowButton[0]->getWidth()
515  if (innerWidth < 0)
516  innerWidth = 0;
517 
518  int newWidth = mVisibleTabsWidth;
519  while ((mTabScrollIndex != 0u) && newWidth < innerWidth)
520  {
521  Tab *const tab = mTabs[mTabScrollIndex - 1].first;
522  if ((tab != nullptr) && tab->mVisible == Visible_true)
523  {
524  newWidth += tab->getWidth();
525  if (newWidth < innerWidth)
526  --mTabScrollIndex;
527  }
528  }
529 
530  if (mArrowButton[1] != nullptr)
531  {
532  // Move the right arrow to fit the windows content.
533  newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
534  if (newWidth < 0)
535  newWidth = 0;
536  mArrowButton[1]->setPosition(newWidth, 0);
537  }
538  }
539 
542 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustTabPositions()
Definition: tabbedarea.cpp:604
int width
Definition: rect.h:218
int mVisibleTabsWidth
Definition: tabbedarea.h:281
int getWidth() const
Definition: widget.h:220
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
const bool Visible_true
Definition: visible.h:29
Definition: tab.h:84
int getY() const
Definition: widget.h:287
Definition: rect.h:72
Widget * getCurrentWidget() const
Definition: tabbedarea.cpp:228
void setVerticalScrollAmount(const int vScroll)
unsigned int getFrameSize() const
Definition: widget.h:183
int getVerticalMaxScroll()
Visible mVisible
Definition: widget.h:962
void updateArrowEnableState()
Definition: tabbedarea.cpp:673
int getVerticalScrollAmount() const
Definition: scrollarea.h:273
unsigned int mFrameSize
Definition: widget.h:1137
unsigned int mTabScrollIndex
Definition: tabbedarea.h:289
TabContainer mTabs
Definition: tabbedarea.h:265
void setPosition(const int x, const int y)
Definition: widget.cpp:160
int height
Definition: rect.h:223
Button * mArrowButton[2]
Definition: tabbedarea.h:250
const Rect & getDimension() const
Definition: widget.h:316
bool mFollowDownScroll
Definition: tabbedarea.h:294
void adjustSize()
Definition: tabbedarea.cpp:567
int mRightMargin
Definition: tabbedarea.h:290
Definition: widget.h:97
int getHeight() const
Definition: widget.h:239
Rect mDimension
Definition: widget.h:1100

Field Documentation

◆ mArrowButton

Button* TabbedArea::mArrowButton[2]
private

◆ mBlockSwitching

bool TabbedArea::mBlockSwitching
private

Definition at line 295 of file tabbedarea.h.

Referenced by keyPressed(), and setBlockSwitching().

◆ mEnableScrollButtons

bool TabbedArea::mEnableScrollButtons
private

Definition at line 293 of file tabbedarea.h.

Referenced by adjustTabPositions(), and enableScrollButtons().

◆ mFollowDownScroll

bool TabbedArea::mFollowDownScroll
private

Definition at line 294 of file tabbedarea.h.

Referenced by getFollowDownScroll(), setFollowDownScroll(), and widgetResized().

◆ mOpaque

Opaque TabbedArea::mOpaque
private

Definition at line 292 of file tabbedarea.h.

Referenced by isOpaque(), and setOpaque().

◆ mResizeHeight

bool TabbedArea::mResizeHeight
private

Definition at line 296 of file tabbedarea.h.

Referenced by adjustSize(), and setResizeHeight().

◆ mRightMargin

int TabbedArea::mRightMargin
private

◆ mSelectedTab

Tab* TabbedArea::mSelectedTab
private

◆ mTabContainer

BasicContainer2* TabbedArea::mTabContainer
private

◆ mTabs

TabContainer TabbedArea::mTabs
private

◆ mTabScrollIndex

unsigned int TabbedArea::mTabScrollIndex
private

The tab scroll index. When scrolling with the arrows, the tabs must be displayed according to the current index. So the first tab displayed may not be the first in the list.

Note
the index must start at 0.

Definition at line 289 of file tabbedarea.h.

Referenced by action(), adjustTabPositions(), updateArrowEnableState(), updateVisibleTabsWidth(), and widgetResized().

◆ mTabsToDelete

std::vector<Tab*> TabbedArea::mTabsToDelete
private

Definition at line 264 of file tabbedarea.h.

Referenced by addTab(), removeTab(), and ~TabbedArea().

◆ mTabsWidth

int TabbedArea::mTabsWidth
private

The overall width of all tab.

Definition at line 270 of file tabbedarea.h.

Referenced by updateArrowEnableState(), and updateTabsWidth().

◆ mVisibleTabsWidth

int TabbedArea::mVisibleTabsWidth
private

The overall width of visible tab.

Definition at line 281 of file tabbedarea.h.

Referenced by updateArrowEnableState(), updateVisibleTabsWidth(), and widgetResized().

◆ mWidgetContainer

BasicContainer2* TabbedArea::mWidgetContainer
private

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