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  unsigned int visibleTabsWidth = 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)
563  visibleTabsWidth += CAST_S32(tab->getWidth());
564  }
565  mVisibleTabsWidth = visibleTabsWidth;
566 }
567 
569 {
570  int maxTabHeight = 0;
571 
572  const int width = mDimension.width;
573  const int height = mDimension.height;
574 
575  for (size_t i = 0, sz = mTabs.size(); i < sz; i++)
576  {
577  if (mTabs[i].first->getHeight() > maxTabHeight)
578  maxTabHeight = mTabs[i].first->getHeight();
579  }
580 
581  mTabContainer->setSize(width - mRightMargin, maxTabHeight);
582 
583  mWidgetContainer->setPosition(0, maxTabHeight);
584  mWidgetContainer->setSize(width, height - maxTabHeight);
585  Widget *const w = getCurrentWidget();
586  if (w != nullptr)
587  {
588  const int wFrameSize = w->getFrameSize();
589  const int frame2 = 2 * wFrameSize;
590 
591  w->setPosition(wFrameSize, wFrameSize);
592  if (mResizeHeight)
593  {
594  w->setSize(mWidgetContainer->getWidth() - frame2,
595  mWidgetContainer->getHeight() - frame2);
596  }
597  else
598  {
599  w->setSize(mWidgetContainer->getWidth() - frame2,
600  w->getHeight());
601  }
602  }
603 }
604 
606 {
607  int maxTabHeight = 0;
608  const size_t sz = mTabs.size();
609  for (size_t i = 0; i < sz; ++i)
610  {
611  const Tab *const tab = mTabs[i].first;
612  if ((tab != nullptr) &&
613  tab->mVisible == Visible_true &&
614  tab->getHeight() > maxTabHeight)
615  {
616  maxTabHeight = tab->getHeight();
617  }
618  }
619 
620  unsigned int x = (mEnableScrollButtons &&
622  mArrowButton[0]->getWidth() : 0U;
623  for (size_t i = mTabScrollIndex; i < sz; ++i)
624  {
625  Tab *const tab = mTabs[i].first;
626  if ((tab == nullptr) || tab->mVisible == Visible_false)
627  continue;
628  tab->setPosition(x, maxTabHeight - tab->getHeight());
629  x += tab->getWidth();
630  }
631 
632  // If the tabs are scrolled, we hide them away.
633  if (mTabScrollIndex > 0)
634  {
635  x = 0;
636  for (unsigned i = 0; i < mTabScrollIndex; ++i)
637  {
638  Tab *const tab = mTabs[i].first;
639  if ((tab != nullptr) && tab->mVisible == Visible_true)
640  {
641  x -= tab->getWidth();
642  tab->setPosition(x, maxTabHeight - tab->getHeight());
643  }
644  }
645  }
646 }
647 
648 void TabbedArea::action(const ActionEvent& actionEvent)
649 {
650  Widget *const source = actionEvent.getSource();
651  Tab *const tab = dynamic_cast<Tab *>(source);
652 
653  if (tab != nullptr)
654  {
655  setSelectedTab(tab);
656  }
657  else
658  {
659  const std::string &eventId = actionEvent.getId();
660  if (eventId == "shift_left")
661  {
662  if (mTabScrollIndex != 0U)
663  --mTabScrollIndex;
664  }
665  else if (eventId == "shift_right")
666  {
667  if (CAST_SIZE(mTabScrollIndex) < mTabs.size() - 1)
668  ++mTabScrollIndex;
669  }
672  }
673 }
674 
676 {
677  updateTabsWidth();
678  if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
679  return;
680 
681  const int width = mDimension.width;
682  if (mTabsWidth > width - 4
683  - mArrowButton[0]->getWidth()
685  {
688  }
689  else
690  {
693  mTabScrollIndex = 0;
694  }
695 
696  // Left arrow consistency check
697  if (mTabScrollIndex == 0U)
698  mArrowButton[0]->setEnabled(false);
699  else
700  mArrowButton[0]->setEnabled(true);
701 
702  // Right arrow consistency check
703  if (mVisibleTabsWidth < width - 4
704  - mArrowButton[0]->getWidth()
706  {
707  mArrowButton[1]->setEnabled(false);
708  }
709  else
710  {
711  mArrowButton[1]->setEnabled(true);
712  }
713 }
714 
715 Tab *TabbedArea::getTabByIndex(const int index) const
716 {
717  if (index < 0 || index >= CAST_S32(mTabs.size()))
718  return nullptr;
719  return static_cast<Tab*>(mTabs[index].first);
720 }
721 
722 Widget *TabbedArea::getWidgetByIndex(const int index) const
723 {
724  if (index < 0 || index >= CAST_S32(mTabs.size()))
725  return nullptr;
726  return mTabs[index].second;
727 }
728 
729 void TabbedArea::removeAll(const bool del)
730 {
731  if (getSelectedTabIndex() != -1)
732  {
734  }
735  while (getNumberOfTabs() > 0)
736  {
737  const int idx = getNumberOfTabs() - 1;
738  Tab *tab = mTabs[idx].first;
739  Widget *widget = mTabs[idx].second;
740  removeTab(tab);
741  if (del)
742  {
743  delete tab;
744  delete widget;
745  }
746  }
747 }
748 
749 void TabbedArea::setWidth(int width)
750 {
751  // +++ need use virtual
752  Widget::setWidth(width);
753  adjustSize();
754 }
755 
756 void TabbedArea::setHeight(int height)
757 {
758  // +++ need use virtual
759  Widget::setHeight(height);
760  adjustSize();
761 }
762 
763 void TabbedArea::setSize(int width, int height)
764 {
765  // +++ need use virtual
766  Widget::setSize(width, height);
767  adjustSize();
768 }
769 
770 void TabbedArea::setDimension(const Rect &dimension)
771 {
772  // +++ need use virtual
773  Widget::setDimension(dimension);
774  adjustSize();
775 }
776 
778 {
779  if (mBlockSwitching || event.isConsumed() || !isFocused())
780  return;
781 
782  const InputActionT actionId = event.getActionId();
783 
784  if (actionId == InputAction::GUI_LEFT)
785  {
786  int index = getSelectedTabIndex();
787  index--;
788 
789  if (index < 0)
790  return;
791 
792  setSelectedTab(mTabs[index].first);
793  event.consume();
794  }
795  else if (actionId == InputAction::GUI_RIGHT)
796  {
797  int index = getSelectedTabIndex();
798  index++;
799 
800  if (index >= CAST_S32(mTabs.size()))
801  return;
802 
803  setSelectedTab(mTabs[index].first);
804  event.consume();
805  }
806 }
807 
808 void TabbedArea::death(const Event &event)
809 {
810  Tab *const tab = dynamic_cast<Tab*>(event.getSource());
811 
812  if (tab != nullptr)
813  removeTab(tab);
814  else
815  BasicContainer::death(event);
816 }
817 
819 {
820  int tab = getSelectedTabIndex();
821  tab++;
822  if (tab == CAST_S32(mTabs.size()))
823  tab = 0;
824  setSelectedTab(mTabs[tab].first);
825 }
826 
828 {
829  int tab = getSelectedTabIndex();
830 
831  if (tab == 0)
832  tab = CAST_S32(mTabs.size());
833  if (tab < 0)
834  return;
835  tab--;
836  setSelectedTab(mTabs[tab].first);
837 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustTabPositions()
Definition: tabbedarea.cpp:605
#define CAST_U32
Definition: cast.h:30
void setHeight(int height)
Definition: tabbedarea.cpp:756
#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:729
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:715
void updateArrowEnableState()
Definition: tabbedarea.cpp:675
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:777
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:770
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:749
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:648
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:763
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:722
void death(const Event &event)
Definition: tabbedarea.cpp:808
void selectPrevTab()
Definition: tabbedarea.cpp:827
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:159
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void adjustSize()
Definition: tabbedarea.cpp:568
int mRightMargin
Definition: tabbedarea.h:290
void postInit()
Definition: tabbedarea.cpp:106
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1161
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:818
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:237