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,
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 }
129 
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 }
148 
149 void TabbedArea::enableScrollButtons(const bool enable)
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 }
167 
169 {
170  return CAST_S32(mTabs.size());
171 }
172 
173 Tab *TabbedArea::getTab(const std::string &name) const
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 }
186 
187 void TabbedArea::draw(Graphics *const graphics)
188 {
189  BLOCK_START("TabbedArea::draw")
190  if (mTabs.empty())
191  {
192  BLOCK_END("TabbedArea::draw")
193  return;
194  }
195 
196  drawChildren(graphics);
197  BLOCK_END("TabbedArea::draw")
198 }
199 
200 void TabbedArea::safeDraw(Graphics *const graphics)
201 {
202  BLOCK_START("TabbedArea::draw")
203  if (mTabs.empty())
204  {
205  BLOCK_END("TabbedArea::draw")
206  return;
207  }
208 
209  safeDrawChildren(graphics);
210  BLOCK_END("TabbedArea::draw")
211 }
212 
213 Widget *TabbedArea::getWidget(const std::string &name) const
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 }
227 
229 {
230  const Tab *const tab = getSelectedTab();
231 
232  if (tab != nullptr)
233  return getWidget(tab->getCaption());
234  return nullptr;
235 }
236 
237 void TabbedArea::addTab(Tab *const tab,
238  Widget *const widget)
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 }
263 
264 void TabbedArea::adjustWidget(Widget *const widget) const
265 {
266  if (widget == nullptr)
267  return;
268  const int frameSize = 2 * mFrameSize;
269  widget->setSize(getWidth() - frameSize,
270  getHeight() - frameSize - mTabContainer->getHeight());
271 }
272 
273 void TabbedArea::addTab(const std::string &caption, Widget *const widget)
274 {
275  Tab *const tab = new Tab(this);
276  tab->setCaption(caption);
277  mTabsToDelete.push_back(tab);
278 
279  addTab(tab, widget);
280 }
281 
282 void TabbedArea::addTab(Image *const image, Widget *const widget)
283 {
284  Tab *const tab = new Tab(this);
285  tab->setImage(image);
286  mTabsToDelete.push_back(tab);
287 
288  addTab(tab, widget);
289 }
290 
291 bool TabbedArea::isTabSelected(const size_t index) const
292 {
293  if (index >= mTabs.size())
294  return false;
295 
296  return mSelectedTab == mTabs[index].first;
297 }
298 
299 bool TabbedArea::isTabPresent(const Tab *const tab) const
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 }
308 
309 bool TabbedArea::isTabSelected(const Tab *const tab) const
310 {
311  return mSelectedTab == tab;
312 }
313 
314 void TabbedArea::setSelectedTabByIndex(const size_t index)
315 {
316  if (index >= mTabs.size())
317  return;
318 
319  setSelectedTab(mTabs[index].first);
320 }
321 
322 void TabbedArea::removeTab(Tab *const tab)
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 }
378 
380 {
381  BLOCK_START("TabbedArea::logic")
382  logicChildren();
383  BLOCK_END("TabbedArea::logic")
384 }
385 
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 }
405 
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 }
430 
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 }
447 
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 }
460 
461 void TabbedArea::setSelectedTabByName(const std::string &name)
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 }
472 
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 }
543 
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 }
555 
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 }
566 
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 }
603 
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 }
645 
646 void TabbedArea::action(const ActionEvent& actionEvent)
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 }
672 
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 }
712 
713 Tab *TabbedArea::getTabByIndex(const int index) const
714 {
715  if (index < 0 || index >= CAST_S32(mTabs.size()))
716  return nullptr;
717  return static_cast<Tab*>(mTabs[index].first);
718 }
719 
720 Widget *TabbedArea::getWidgetByIndex(const int index) const
721 {
722  if (index < 0 || index >= CAST_S32(mTabs.size()))
723  return nullptr;
724  return mTabs[index].second;
725 }
726 
727 void TabbedArea::removeAll(const bool del)
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 }
746 
747 void TabbedArea::setWidth(int width)
748 {
749  // +++ need use virtual
750  Widget::setWidth(width);
751  adjustSize();
752 }
753 
754 void TabbedArea::setHeight(int height)
755 {
756  // +++ need use virtual
757  Widget::setHeight(height);
758  adjustSize();
759 }
760 
761 void TabbedArea::setSize(int width, int height)
762 {
763  // +++ need use virtual
764  Widget::setSize(width, height);
765  adjustSize();
766 }
767 
768 void TabbedArea::setDimension(const Rect &dimension)
769 {
770  // +++ need use virtual
771  Widget::setDimension(dimension);
772  adjustSize();
773 }
774 
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 }
805 
806 void TabbedArea::death(const Event &event)
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 }
815 
817 {
818  int tab = getSelectedTabIndex();
819  tab++;
820  if (tab == CAST_S32(mTabs.size()))
821  tab = 0;
822  setSelectedTab(mTabs[tab].first);
823 }
824 
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 setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustTabPositions()
Definition: tabbedarea.cpp:604
#define CAST_U32
Definition: cast.h:30
void setHeight(int height)
Definition: tabbedarea.cpp:754
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
Widget * getWidget(const std::string &name) const
Definition: tabbedarea.cpp:213
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:727
void adjustWidget(Widget *const widget) const
Definition: tabbedarea.cpp:264
int getWidth() const
Definition: widget.h:220
void logic()
Definition: tabbedarea.cpp:379
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:386
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:322
MouseButtonT getButton() const
Definition: mouseevent.h:115
Definition: rect.h:72
bool mBlockSwitching
Definition: tabbedarea.h:295
Widget * getCurrentWidget() const
Definition: tabbedarea.cpp:228
#define BLOCK_START(name)
Definition: perfomance.h:78
Definition: button.h:96
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:168
void enableScrollButtons(const bool enable)
Definition: tabbedarea.cpp:149
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:406
Visible mVisible
Definition: widget.h:962
#define new
Definition: debug_new.h:147
Tab * getTabByIndex(const int index) const
Definition: tabbedarea.cpp:713
void updateArrowEnableState()
Definition: tabbedarea.cpp:673
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
const std::string BUTTON_SKIN
Definition: button.h:88
void keyPressed(KeyEvent &event)
Definition: tabbedarea.cpp:775
Tab * mSelectedTab
Definition: tabbedarea.h:261
void safeDraw(Graphics *const graphics)
Definition: tabbedarea.cpp:200
const bool Visible_false
Definition: visible.h:29
void setDimension(const Rect &dimension)
Definition: tabbedarea.cpp:768
TabbedArea(const Widget2 *const widget)
Definition: tabbedarea.cpp:79
void draw(Graphics *const graphics)
Definition: tabbedarea.cpp:187
Tab * getTab(const std::string &name) const
Definition: tabbedarea.cpp:173
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:448
Widget * getSource() const
Definition: event.h:103
int getVerticalScrollAmount() const
Definition: scrollarea.h:273
void setWidth(int width)
Definition: tabbedarea.cpp:747
unsigned int mFrameSize
Definition: widget.h:1137
void setSelectedTabDefault()
Definition: tabbedarea.cpp:431
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:646
virtual void remove(Widget *const widget)
void widgetResized(const Event &event)
Definition: tabbedarea.cpp:473
InputAction ::T InputActionT
Definition: inputaction.h:715
#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:761
int height
Definition: rect.h:223
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
void updateTabsWidth()
Definition: tabbedarea.cpp:544
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:720
void death(const Event &event)
Definition: tabbedarea.cpp:806
void selectPrevTab()
Definition: tabbedarea.cpp:825
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:314
#define A_UNUSED
Definition: localconsts.h:151
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void adjustSize()
Definition: tabbedarea.cpp:567
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:461
void setImage(Image *const image)
Definition: tab.cpp:464
bool isTabSelected(const size_t index) const
Definition: tabbedarea.cpp:291
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:299
Rect mDimension
Definition: widget.h:1100
virtual void safeDrawChildren(Graphics *const graphics)
void updateVisibleTabsWidth()
Definition: tabbedarea.cpp:556
void selectNextTab()
Definition: tabbedarea.cpp:816
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:237