ManaPlus
tabbedarea.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 /* _______ __ __ __ ______ __ __ _______ __ __
24  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
25  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
26  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
27  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
28  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
29  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
30  *
31  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
32  *
33  *
34  * Per Larsson a.k.a finalman
35  * Olof Naessén a.k.a jansem/yakslem
36  *
37  * Visit: http://guichan.sourceforge.net
38  *
39  * License: (BSD)
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  * 1. Redistributions of source code must retain the above copyright
44  * notice, this list of conditions and the following disclaimer.
45  * 2. Redistributions in binary form must reproduce the above copyright
46  * notice, this list of conditions and the following disclaimer in
47  * the documentation and/or other materials provided with the
48  * distribution.
49  * 3. Neither the name of Guichan nor the names of its contributors may
50  * be used to endorse or promote products derived from this software
51  * without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
59  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
60  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
61  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
62  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
63  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  */
65 
66 #include "gui/widgets/tabbedarea.h"
67 
68 #include "gui/gui.h"
69 
70 #include "gui/widgets/button.h"
71 #include "gui/widgets/scrollarea.h"
72 #include "gui/widgets/tabs/tab.h"
73 
74 #include "utils/delete2.h"
75 #include "utils/foreach.h"
76 
77 #include "debug.h"
78 
79 TabbedArea::TabbedArea(const Widget2 *const widget) :
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),
92  mVisibleTabsWidth(0),
93  mTabScrollIndex(0),
94  mRightMargin(0),
95  mOpaque(Opaque_false),
96  mEnableScrollButtons(false),
97  mFollowDownScroll(false),
98  mBlockSwitching(true),
99  mResizeHeight(true)
100 {
101  setFocusable(true);
102  addKeyListener(this);
103  addMouseListener(this);
104 }
105 
107 {
109 
112 
114  addWidgetListener(this);
115 
116  mArrowButton[0] = new Button(this, "<", "shift_left", this);
117  mArrowButton[1] = new Button(this, ">", "shift_right", this);
118 
119  widgetResized(Event(nullptr));
120 }
121 
123 {
124  if (gui != nullptr)
125  gui->removeDragged(this);
126 
127  // +++ virtual method calls
128  remove(mTabContainer);
129  remove(mWidgetContainer);
130 
133 
134  for (size_t i = 0, sz = mTabsToDelete.size(); i < sz; i++)
136 
137  delete2(mArrowButton[0]);
138  delete2(mArrowButton[1]);
139 }
140 
141 void TabbedArea::enableScrollButtons(const bool enable)
142 {
143  if (mEnableScrollButtons && !enable)
144  {
145  if (mArrowButton[0] != nullptr)
146  remove(mArrowButton[0]);
147  if (mArrowButton[1] != nullptr)
148  remove(mArrowButton[1]);
149  }
150  else if (!mEnableScrollButtons && enable)
151  {
152  if (mArrowButton[0] != nullptr)
153  add(mArrowButton[0]);
154  if (mArrowButton[1] != nullptr)
155  add(mArrowButton[1]);
156  }
157  mEnableScrollButtons = enable;
158 }
159 
161 {
162  return CAST_S32(mTabs.size());
163 }
164 
165 Tab *TabbedArea::getTab(const std::string &name) const
166 {
167  TabContainer::const_iterator itr = mTabs.begin();
168  const TabContainer::const_iterator itr_end = mTabs.end();
169  while (itr != itr_end)
170  {
171  if ((*itr).first->getCaption() == name)
172  return static_cast<Tab*>((*itr).first);
173 
174  ++itr;
175  }
176  return nullptr;
177 }
178 
179 void TabbedArea::draw(Graphics *const graphics)
180 {
181  BLOCK_START("TabbedArea::draw")
182  if (mTabs.empty())
183  {
184  BLOCK_END("TabbedArea::draw")
185  return;
186  }
187 
188  drawChildren(graphics);
189  BLOCK_END("TabbedArea::draw")
190 }
191 
192 void TabbedArea::safeDraw(Graphics *const graphics)
193 {
194  BLOCK_START("TabbedArea::draw")
195  if (mTabs.empty())
196  {
197  BLOCK_END("TabbedArea::draw")
198  return;
199  }
200 
201  safeDrawChildren(graphics);
202  BLOCK_END("TabbedArea::draw")
203 }
204 
205 Widget *TabbedArea::getWidget(const std::string &name) const
206 {
207  TabContainer::const_iterator itr = mTabs.begin();
208  const TabContainer::const_iterator itr_end = mTabs.end();
209  while (itr != itr_end)
210  {
211  if ((*itr).first->getCaption() == name)
212  return (*itr).second;
213 
214  ++itr;
215  }
216 
217  return nullptr;
218 }
219 
221 {
222  const Tab *const tab = getSelectedTab();
223 
224  if (tab != nullptr)
225  return getWidget(tab->getCaption());
226  return nullptr;
227 }
228 
229 void TabbedArea::addTab(Tab *const tab,
230  Widget *const widget)
231 {
232  if ((tab == nullptr) || (widget == nullptr))
233  return;
234 
235  tab->setTabbedArea(this);
236  tab->addActionListener(this);
237 
238  mTabContainer->add(tab);
239  mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
240 
241  if ((mSelectedTab == nullptr) && tab->mVisible == Visible_true)
242  setSelectedTab(tab);
243 
245  adjustSize();
246 
247  const int frameSize = 2 * mFrameSize;
248  widget->setSize(getWidth() - frameSize,
249  getHeight() - frameSize - mTabContainer->getHeight());
250 
251  widgetResized(Event(nullptr));
252  updateTabsWidth();
254 }
255 
256 void TabbedArea::adjustWidget(Widget *const widget) const
257 {
258  if (widget == nullptr)
259  return;
260  const int frameSize = 2 * mFrameSize;
261  widget->setSize(getWidth() - frameSize,
262  getHeight() - frameSize - mTabContainer->getHeight());
263 }
264 
265 void TabbedArea::addTab(const std::string &caption, Widget *const widget)
266 {
267  Tab *const tab = new Tab(this);
268  tab->setCaption(caption);
269  mTabsToDelete.push_back(tab);
270 
271  addTab(tab, widget);
272 }
273 
274 void TabbedArea::addTab(Image *const image, Widget *const widget)
275 {
276  Tab *const tab = new Tab(this);
277  tab->setImage(image);
278  mTabsToDelete.push_back(tab);
279 
280  addTab(tab, widget);
281 }
282 
283 bool TabbedArea::isTabSelected(const size_t index) const
284 {
285  if (index >= mTabs.size())
286  return false;
287 
288  return mSelectedTab == mTabs[index].first;
289 }
290 
291 bool TabbedArea::isTabPresent(const Tab *const tab) const
292 {
293  FOR_EACH (TabContainer::const_iterator, it, mTabs)
294  {
295  if ((*it).first == tab || (*it).second == tab)
296  return true;
297  }
298  return false;
299 }
300 
301 bool TabbedArea::isTabSelected(const Tab *const tab) const
302 {
303  return mSelectedTab == tab;
304 }
305 
306 void TabbedArea::setSelectedTabByIndex(const size_t index)
307 {
308  if (index >= mTabs.size())
309  return;
310 
311  setSelectedTab(mTabs[index].first);
312 }
313 
314 void TabbedArea::removeTab(Tab *const tab)
315 {
316  int tabIndexToBeSelected = -1;
317 
318  if (tab == mSelectedTab)
319  {
320  const int index = getSelectedTabIndex();
321  const size_t sz = mTabs.size();
322  if (index == CAST_S32(sz) - 1 && sz == 1)
323  tabIndexToBeSelected = -1;
324  else
325  tabIndexToBeSelected = index - 1;
326  }
327 
328  for (TabContainer::iterator iter = mTabs.begin();
329  iter != mTabs.end(); ++iter)
330  {
331  if (iter->first == tab)
332  {
333  mTabContainer->remove(tab);
334  mTabs.erase(iter);
335  break;
336  }
337  }
338 
339  for (STD_VECTOR<Tab*>::iterator iter2 = mTabsToDelete.begin();
340  iter2 != mTabsToDelete.end(); ++iter2)
341  {
342  if (*iter2 == tab)
343  {
344  mTabsToDelete.erase(iter2);
345  delete tab;
346  break;
347  }
348  }
349 
350  const int tabsSize = CAST_S32(mTabs.size());
351  if (tabIndexToBeSelected >= tabsSize)
352  tabIndexToBeSelected = tabsSize - 1;
353  if (tabIndexToBeSelected < -1)
354  tabIndexToBeSelected = -1;
355 
356  if (tabIndexToBeSelected == -1)
357  {
358  mSelectedTab = nullptr;
360  }
361  else
362  {
363  setSelectedTabByIndex(tabIndexToBeSelected);
364  }
365 
366  adjustSize();
367  updateTabsWidth();
368  widgetResized(Event(nullptr));
369 }
370 
372 {
373  BLOCK_START("TabbedArea::logic")
374  logicChildren();
375  BLOCK_END("TabbedArea::logic")
376 }
377 
379 {
380  if (event.isConsumed())
381  return;
382 
383  if (event.getButton() == MouseButton::LEFT)
384  {
385  Widget *const widget = mTabContainer->getWidgetAt(
386  event.getX(), event.getY());
387  Tab *const tab = dynamic_cast<Tab *>(widget);
388 
389  if (tab != nullptr)
390  {
391  event.consume();
392  setSelectedTab(tab);
393  requestFocus();
394  }
395  }
396 }
397 
399 {
400  for (size_t i = 0; i < mTabs.size(); i++)
401  {
402  if (mTabs[i].first == mSelectedTab)
403  mWidgetContainer->remove(mTabs[i].second);
404  }
405 
406  for (size_t i = 0; i < mTabs.size(); i++)
407  {
408  if (mTabs[i].first == tab)
409  {
410  mSelectedTab = tab;
411  mWidgetContainer->add(mTabs[i].second);
412  }
413  }
414 
415  Tab *const newTab = tab;
416 
417  if (newTab != nullptr)
418  newTab->setCurrent();
419 
420  widgetResized(Event(nullptr));
421 }
422 
424 {
425  if (mSelectedTab == nullptr ||
427  {
428  for (size_t i = 0; i < mTabs.size(); i++)
429  {
430  Tab *const tab = mTabs[i].first;
431  if ((tab != nullptr) && tab->mVisible == Visible_true)
432  {
433  setSelectedTab(tab);
434  return;
435  }
436  }
437  }
438 }
439 
441 {
442  for (unsigned int i = 0, fsz = CAST_U32(mTabs.size());
443  i < fsz;
444  i++)
445  {
446  if (mTabs[i].first == mSelectedTab)
447  return i;
448  }
449 
450  return -1;
451 }
452 
453 void TabbedArea::setSelectedTabByName(const std::string &name)
454 {
455  FOR_EACH (TabContainer::const_iterator, itr, mTabs)
456  {
457  if (((*itr).first != nullptr) && (*itr).first->getCaption() == name)
458  {
459  setSelectedTab((*itr).first);
460  return;
461  }
462  }
463 }
464 
466 {
467  adjustSize();
468 
469  const int frameSize = 2 * mFrameSize;
470  const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize();
471  const int w1 = mDimension.width;
472  const int h1 = mDimension.height;
473  const int width = w1 - frameSize - widgetFrameSize;
474  const int height = h1 - frameSize
475  - mWidgetContainer->getY() - widgetFrameSize;
476 
477  Widget *const w = getCurrentWidget();
478  ScrollArea *const scr = dynamic_cast<ScrollArea *>(w);
479  if (scr != nullptr)
480  {
481  if (mFollowDownScroll && height != 0)
482  {
483  const Rect &rect = w->getDimension();
484  if (rect.height != 0 && rect.height > height + 2)
485  {
486  if (scr->getVerticalScrollAmount()
487  >= scr->getVerticalMaxScroll() - 2
488  && scr->getVerticalScrollAmount()
489  <= scr->getVerticalMaxScroll() + 2)
490  {
491  const int newScroll = scr->getVerticalScrollAmount()
492  + rect.height - height;
493  w->setSize(mWidgetContainer->getWidth() - frameSize,
494  mWidgetContainer->getHeight() - frameSize);
495  if (newScroll != 0)
496  scr->setVerticalScrollAmount(newScroll);
497  }
498  }
499  }
500  }
501 
502  if (mArrowButton[1] != nullptr)
503  {
504  // Check whether there is room to show more tabs now.
505  int innerWidth = w1 - 4 - mArrowButton[0]->getWidth()
507  if (innerWidth < 0)
508  innerWidth = 0;
509 
510  int newWidth = mVisibleTabsWidth;
511  while ((mTabScrollIndex != 0u) && newWidth < innerWidth)
512  {
513  Tab *const tab = mTabs[mTabScrollIndex - 1].first;
514  if ((tab != nullptr) && tab->mVisible == Visible_true)
515  {
516  newWidth += tab->getWidth();
517  if (newWidth < innerWidth)
518  --mTabScrollIndex;
519  }
520  }
521 
522  if (mArrowButton[1] != nullptr)
523  {
524  // Move the right arrow to fit the windows content.
525  newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
526  if (newWidth < 0)
527  newWidth = 0;
528  mArrowButton[1]->setPosition(newWidth, 0);
529  }
530  }
531 
534 }
535 
537 {
538  mTabsWidth = 0;
539  FOR_EACH (TabContainer::const_iterator, itr, mTabs)
540  {
541  Tab *const tab = (*itr).first;
542  if ((tab != nullptr) && tab->mVisible == Visible_true)
543  mTabsWidth += tab->getWidth();
544  }
546 }
547 
549 {
550  mVisibleTabsWidth = 0;
551  for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
552  {
553  Tab *const tab = mTabs[i].first;
554  if ((tab != nullptr) && tab->mVisible == Visible_true)
556  }
557 }
558 
560 {
561  int maxTabHeight = 0;
562 
563  const int width = mDimension.width;
564  const int height = mDimension.height;
565 
566  for (size_t i = 0, sz = mTabs.size(); i < sz; i++)
567  {
568  if (mTabs[i].first->getHeight() > maxTabHeight)
569  maxTabHeight = mTabs[i].first->getHeight();
570  }
571 
572  mTabContainer->setSize(width - mRightMargin, maxTabHeight);
573 
574  mWidgetContainer->setPosition(0, maxTabHeight);
575  mWidgetContainer->setSize(width, height - maxTabHeight);
576  Widget *const w = getCurrentWidget();
577  if (w != nullptr)
578  {
579  const int wFrameSize = w->getFrameSize();
580  const int frame2 = 2 * wFrameSize;
581 
582  w->setPosition(wFrameSize, wFrameSize);
583  if (mResizeHeight)
584  {
585  w->setSize(mWidgetContainer->getWidth() - frame2,
586  mWidgetContainer->getHeight() - frame2);
587  }
588  else
589  {
590  w->setSize(mWidgetContainer->getWidth() - frame2,
591  w->getHeight());
592  }
593  }
594 }
595 
597 {
598  int maxTabHeight = 0;
599  const size_t sz = mTabs.size();
600  for (size_t i = 0; i < sz; ++i)
601  {
602  const Tab *const tab = mTabs[i].first;
603  if ((tab != nullptr) &&
604  tab->mVisible == Visible_true &&
605  tab->getHeight() > maxTabHeight)
606  {
607  maxTabHeight = tab->getHeight();
608  }
609  }
610 
612  ? mArrowButton[0]->getWidth() : 0;
613  for (size_t i = mTabScrollIndex; i < sz; ++i)
614  {
615  Tab *const tab = mTabs[i].first;
616  if ((tab == nullptr) || tab->mVisible == Visible_false)
617  continue;
618  tab->setPosition(x, maxTabHeight - tab->getHeight());
619  x += tab->getWidth();
620  }
621 
622  // If the tabs are scrolled, we hide them away.
623  if (mTabScrollIndex > 0)
624  {
625  x = 0;
626  for (unsigned i = 0; i < mTabScrollIndex; ++i)
627  {
628  Tab *const tab = mTabs[i].first;
629  if ((tab != nullptr) && tab->mVisible == Visible_true)
630  {
631  x -= tab->getWidth();
632  tab->setPosition(x, maxTabHeight - tab->getHeight());
633  }
634  }
635  }
636 }
637 
638 void TabbedArea::action(const ActionEvent& actionEvent)
639 {
640  Widget *const source = actionEvent.getSource();
641  Tab *const tab = dynamic_cast<Tab *>(source);
642 
643  if (tab != nullptr)
644  {
645  setSelectedTab(tab);
646  }
647  else
648  {
649  const std::string &eventId = actionEvent.getId();
650  if (eventId == "shift_left")
651  {
652  if (mTabScrollIndex != 0u)
653  --mTabScrollIndex;
654  }
655  else if (eventId == "shift_right")
656  {
657  if (CAST_SIZE(mTabScrollIndex) < mTabs.size() - 1)
658  ++mTabScrollIndex;
659  }
662  }
663 }
664 
666 {
667  updateTabsWidth();
668  if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
669  return;
670 
671  const int width = mDimension.width;
672  if (mTabsWidth > width - 4
673  - mArrowButton[0]->getWidth()
675  {
678  }
679  else
680  {
683  mTabScrollIndex = 0;
684  }
685 
686  // Left arrow consistency check
687  if (mTabScrollIndex == 0u)
688  mArrowButton[0]->setEnabled(false);
689  else
690  mArrowButton[0]->setEnabled(true);
691 
692  // Right arrow consistency check
693  if (mVisibleTabsWidth < width - 4
694  - mArrowButton[0]->getWidth()
696  {
697  mArrowButton[1]->setEnabled(false);
698  }
699  else
700  {
701  mArrowButton[1]->setEnabled(true);
702  }
703 }
704 
705 Tab *TabbedArea::getTabByIndex(const int index) const
706 {
707  if (index < 0 || index >= CAST_S32(mTabs.size()))
708  return nullptr;
709  return static_cast<Tab*>(mTabs[index].first);
710 }
711 
712 Widget *TabbedArea::getWidgetByIndex(const int index) const
713 {
714  if (index < 0 || index >= CAST_S32(mTabs.size()))
715  return nullptr;
716  return mTabs[index].second;
717 }
718 
719 void TabbedArea::removeAll(const bool del)
720 {
721  if (getSelectedTabIndex() != -1)
722  {
724  }
725  while (getNumberOfTabs() > 0)
726  {
727  const int idx = getNumberOfTabs() - 1;
728  Tab *tab = mTabs[idx].first;
729  Widget *widget = mTabs[idx].second;
730  removeTab(tab);
731  if (del)
732  {
733  delete tab;
734  delete widget;
735  }
736  }
737 }
738 
739 void TabbedArea::setWidth(int width)
740 {
741  // +++ need use virtual
742  Widget::setWidth(width);
743  adjustSize();
744 }
745 
746 void TabbedArea::setHeight(int height)
747 {
748  // +++ need use virtual
749  Widget::setHeight(height);
750  adjustSize();
751 }
752 
753 void TabbedArea::setSize(int width, int height)
754 {
755  // +++ need use virtual
756  Widget::setSize(width, height);
757  adjustSize();
758 }
759 
760 void TabbedArea::setDimension(const Rect &dimension)
761 {
762  // +++ need use virtual
763  Widget::setDimension(dimension);
764  adjustSize();
765 }
766 
768 {
769  if (mBlockSwitching || event.isConsumed() || !isFocused())
770  return;
771 
772  const InputActionT actionId = event.getActionId();
773 
774  if (actionId == InputAction::GUI_LEFT)
775  {
776  int index = getSelectedTabIndex();
777  index--;
778 
779  if (index < 0)
780  return;
781 
782  setSelectedTab(mTabs[index].first);
783  event.consume();
784  }
785  else if (actionId == InputAction::GUI_RIGHT)
786  {
787  int index = getSelectedTabIndex();
788  index++;
789 
790  if (index >= CAST_S32(mTabs.size()))
791  return;
792 
793  setSelectedTab(mTabs[index].first);
794  event.consume();
795  }
796 }
797 
798 void TabbedArea::death(const Event &event)
799 {
800  Tab *const tab = dynamic_cast<Tab*>(event.getSource());
801 
802  if (tab != nullptr)
803  removeTab(tab);
804  else
805  BasicContainer::death(event);
806 }
807 
809 {
810  int tab = getSelectedTabIndex();
811  tab++;
812  if (tab == CAST_S32(mTabs.size()))
813  tab = 0;
814  setSelectedTab(mTabs[tab].first);
815 }
816 
818 {
819  int tab = getSelectedTabIndex();
820 
821  if (tab == 0)
822  tab = CAST_S32(mTabs.size());
823  if (tab < 0)
824  return;
825  tab--;
826  setSelectedTab(mTabs[tab].first);
827 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustTabPositions()
Definition: tabbedarea.cpp:596
#define CAST_U32
Definition: cast.h:30
void setHeight(int height)
Definition: tabbedarea.cpp:746
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
Widget * getWidget(const std::string &name) const
Definition: tabbedarea.cpp:205
int width
Definition: rect.h:218
virtual void setCurrent()
Definition: tab.h:210
int mVisibleTabsWidth
Definition: tabbedarea.h:281
void removeAll(const bool del)
Definition: tabbedarea.cpp:719
void adjustWidget(Widget *const widget) const
Definition: tabbedarea.cpp:256
int getWidth() const
Definition: widget.h:220
void logic()
Definition: tabbedarea.cpp:371
BasicContainer2 * mWidgetContainer
Definition: tabbedarea.h:263
void setWidth(const int width)
Definition: widget.cpp:132
Gui * gui
Definition: gui.cpp:110
void setCaption(const std::string &caption)
Definition: tab.cpp:457
void mousePressed(MouseEvent &event)
Definition: tabbedarea.cpp:378
const bool Visible_true
Definition: visible.h:29
Definition: tab.h:84
int getY() const
Definition: widget.h:287
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setVisible(Visible visible)
Definition: widget.cpp:224
void removeTab(Tab *const tab)
Definition: tabbedarea.cpp:314
MouseButtonT getButton() const
Definition: mouseevent.h:115
Definition: rect.h:72
bool mBlockSwitching
Definition: tabbedarea.h:295
Widget * getCurrentWidget() const
Definition: tabbedarea.cpp:220
#define BLOCK_START(name)
Definition: perfomance.h:78
Definition: button.h:94
BasicContainer2 * mTabContainer
Definition: tabbedarea.h:262
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
#define BLOCK_END(name)
Definition: perfomance.h:79
void setVerticalScrollAmount(const int vScroll)
#define delete2(var)
Definition: delete2.h:24
int getNumberOfTabs() const
Definition: tabbedarea.cpp:160
void enableScrollButtons(const bool enable)
Definition: tabbedarea.cpp:141
virtual bool isFocused() const
Definition: widget.cpp:183
virtual void clear()
unsigned int getFrameSize() const
Definition: widget.h:183
int getVerticalMaxScroll()
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:398
Visible mVisible
Definition: widget.h:962
#define new
Definition: debug_new.h:147
Tab * getTabByIndex(const int index) const
Definition: tabbedarea.cpp:705
void updateArrowEnableState()
Definition: tabbedarea.cpp:665
Widget * getWidgetAt(int x, int y)
bool mResizeHeight
Definition: tabbedarea.h:296
#define CAST_S32
Definition: cast.h:29
virtual void requestFocus()
Definition: widget.cpp:203
void keyPressed(KeyEvent &event)
Definition: tabbedarea.cpp:767
Tab * mSelectedTab
Definition: tabbedarea.h:261
void safeDraw(Graphics *const graphics)
Definition: tabbedarea.cpp:192
const bool Visible_false
Definition: visible.h:29
void setDimension(const Rect &dimension)
Definition: tabbedarea.cpp:760
TabbedArea(const Widget2 *const widget)
Definition: tabbedarea.cpp:79
void draw(Graphics *const graphics)
Definition: tabbedarea.cpp:179
Tab * getTab(const std::string &name) const
Definition: tabbedarea.cpp:165
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:440
Widget * getSource() const
Definition: event.h:103
int getVerticalScrollAmount() const
Definition: scrollarea.h:273
void setWidth(int width)
Definition: tabbedarea.cpp:739
unsigned int mFrameSize
Definition: widget.h:1137
void setSelectedTabDefault()
Definition: tabbedarea.cpp:423
virtual void logicChildren()
virtual void add(Widget *const widget)
const std::string & getId() const
Definition: actionevent.h:121
void add(Widget *const widget)
void action(const ActionEvent &actionEvent)
Definition: tabbedarea.cpp:638
virtual void remove(Widget *const widget)
void widgetResized(const Event &event)
Definition: tabbedarea.cpp:465
InputAction ::T InputActionT
Definition: inputaction.h:714
#define nullptr
Definition: localconsts.h:44
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 setPosition(const int x, const int y)
Definition: widget.cpp:160
void setSize(int width, int height)
Definition: tabbedarea.cpp:753
int height
Definition: rect.h:223
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
void updateTabsWidth()
Definition: tabbedarea.cpp:536
Button * mArrowButton[2]
Definition: tabbedarea.h:250
bool isConsumed() const
const Rect & getDimension() const
Definition: widget.h:316
void setOpaque(Opaque opaque)
void setEnabled(const bool enabled)
Definition: widget.h:351
bool mFollowDownScroll
Definition: tabbedarea.h:294
Widget * getWidgetByIndex(const int index) const
Definition: tabbedarea.cpp:712
void death(const Event &event)
Definition: tabbedarea.cpp:798
void selectPrevTab()
Definition: tabbedarea.cpp:817
void setHeight(const int height)
Definition: widget.cpp:139
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
void setSelectedTabByIndex(const size_t index)
Definition: tabbedarea.cpp:306
#define A_UNUSED
Definition: localconsts.h:171
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void adjustSize()
Definition: tabbedarea.cpp:559
int mRightMargin
Definition: tabbedarea.h:290
void postInit()
Definition: tabbedarea.cpp:106
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1160
Definition: widget.h:97
void setSelectedTabByName(const std::string &name)
Definition: tabbedarea.cpp:453
void setImage(Image *const image)
Definition: tab.cpp:464
bool isTabSelected(const size_t index) const
Definition: tabbedarea.cpp:283
virtual void drawChildren(Graphics *const graphics)
Definition: event.h:77
Tab * getSelectedTab() const
Definition: tabbedarea.h:174
const std::string & getCaption() const
Definition: tab.cpp:472
Definition: image.h:61
void setTabbedArea(TabbedArea *tabbedArea)
Definition: tab.cpp:447
int getHeight() const
Definition: widget.h:239
void death(const Event &event)
std::vector< Tab * > mTabsToDelete
Definition: tabbedarea.h:264
bool mEnableScrollButtons
Definition: tabbedarea.h:293
#define CAST_SIZE
Definition: cast.h:33
int getX() const
Definition: mouseevent.h:126
int mTabsWidth
Definition: tabbedarea.h:270
bool isTabPresent(const Tab *const tab) const
Definition: tabbedarea.cpp:291
Rect mDimension
Definition: widget.h:1100
virtual void safeDrawChildren(Graphics *const graphics)
void updateVisibleTabsWidth()
Definition: tabbedarea.cpp:548
void selectNextTab()
Definition: tabbedarea.cpp:808
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:229