Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb_tab_container.h
1 // ================================================================================
2 // == This file is a part of Turbo Badger. (C) 2011-2014, Emil SegerÃ¥s ==
3 // == See tb_core.h for more information. ==
4 // ================================================================================
5 
6 #ifndef TB_TAB_CONTAINER_H
7 #define TB_TAB_CONTAINER_H
8 
9 #include "tb_widgets_common.h"
10 
11 namespace tb {
12 
16 class TBTabLayout : public TBLayout
17 {
18 public:
19  // For safe typecasting
20  TBOBJECT_SUBCLASS(TBTabLayout, TBLayout);
21 
22  virtual void OnChildAdded(TBWidget *child);
24 };
25 
28 class TBTabContainer : public TBWidget
29 {
30 public:
31  // For safe typecasting
32  TBOBJECT_SUBCLASS(TBTabContainer, TBWidget);
33 
35  ~TBTabContainer();
36 
40  virtual void SetAxis(AXIS axis);
41  virtual AXIS GetAxis() const { return m_root_layout.GetAxis(); }
42 
44  void SetAlignment(TB_ALIGN align);
45  TB_ALIGN GetAlignment() const { return m_align; }
46 
48  virtual void SetValue(long value);
49  virtual long GetValue() const { return m_current_page; }
50 
52  void SetCurrentPage(int index) { SetValue(index); }
53  int GetCurrentPage() { return GetValue(); }
54  int GetNumPages();
55 
57  TBWidget *GetCurrentPageWidget() const;
58 
59  virtual void OnInflate(const INFLATE_INFO &info);
60  virtual bool OnEvent(const TBWidgetEvent &ev);
61  virtual void OnProcess();
62 
63  virtual TBWidget *GetContentRoot() { return &m_content_root; }
64  TBLayout *GetTabLayout() { return &m_tab_layout; }
65 protected:
66  TBLayout m_root_layout;
67  TBTabLayout m_tab_layout;
68  TBWidget m_content_root;
69  bool m_need_page_update;
70  int m_current_page;
71  TB_ALIGN m_align;
72 };
73 
74 };
75 
76 #endif // TB_TAB_CONTAINER_H
AXIS
Definition: tb_widgets.h:251
virtual void SetValue(long value)
Set which page should be selected and visible.
Definition: tb_tab_container.cpp:76
virtual void SetAxis(AXIS axis)
Set along which axis the content should layouted.
Definition: tb_tab_container.cpp:68
The base TBWidget class.
Definition: tb_widgets.h:418
TBTabLayout is a TBLayout used in TBTabContainer to apply some default properties on any TBButton add...
Definition: tb_tab_container.h:16
TBWidget * GetCurrentPageWidget() const
Return the widget that is the current page, or nullptr if none is active.
Definition: tb_tab_container.cpp:102
virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints)
Calculate the preferred content size for this widget.
Definition: tb_tab_container.cpp:23
Specifies size constraints used during size calculations.
Definition: tb_widgets.h:321
void SetCurrentPage(int index)
Set which page should be selected and visible.
Definition: tb_tab_container.h:52
TBTabContainer - A container with tabs for multiple pages.
Definition: tb_tab_container.h:28
virtual void OnInflate(const INFLATE_INFO &info)
Called when this widget is inflated from resources, before any children have been inflated...
Definition: tb_widgets_reader.cpp:585
virtual TBWidget * GetContentRoot()
Get this widget or a child widget that should be root for other children.
Definition: tb_tab_container.h:63
void SetAlignment(TB_ALIGN align)
Set alignment of the tabs.
Definition: tb_tab_container.cpp:107
virtual void OnProcess()
Callback for doing anything that might be needed before paint.
Definition: tb_tab_container.cpp:130
TB_ALIGN
Definition: tb_widgets.h:29
virtual AXIS GetAxis() const
See TBWidget::SetAxis.
Definition: tb_layout.h:106
virtual bool OnEvent(const TBWidgetEvent &ev)
Callback for handling events.
Definition: tb_tab_container.cpp:117
virtual AXIS GetAxis() const
See TBWidget::SetAxis.
Definition: tb_tab_container.h:41
virtual void OnChildAdded(TBWidget *child)
Called when a child widget has been added to this widget (before calling OnAdded on child)...
Definition: tb_tab_container.cpp:13
PreferredSize contains size preferences for a TBWidget.
Definition: tb_widgets.h:277
TBLayout layouts its children along the given axis.
Definition: tb_layout.h:96
virtual long GetValue() const
See TBWidget::SetValue.
Definition: tb_tab_container.h:49