/usr/include/Wt/WTabWidget is in libwt-dev 3.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WTABWIDGET_H_
#define WTABWIDGET_H_
#include <Wt/WCompositeWidget>
namespace Wt {
class WMenu;
class WMenuItem;
class WStackedWidget;
/*! \class WTabWidget Wt/WTabWidget Wt/WTabWidget
* \brief A widget that organizes contents in tab panes.
*
* This widget combines a horizontal WMenu with a WStackedWidget, and a
* tab-like look.
*
* A tab widget will place the tab bar on top of the contents, and fit the
* contents below it.
*
* Usage example:
* \if cpp
* \code
* Wt::WTabWidget *examples = new Wt::WTabWidget(this);
*
* examples->addTab(helloWorldExample(), "Hello World");
* examples->addTab(chartExample(), "Charts");
* examples->addTab(new Wt::WText("A WText"), "WText");
*
* examples->currentChanged().connect(this, &MyClass::logInternalPath);
* examples->setInternalPathEnabled();
* examples->setInternalBasePath("/examples");
* \endcode
* \elseif java
* \code
* WTabWidget examples = new WTabWidget(this);
*
* examples.addTab(helloWorldExample(), "Hello World");
* examples.addTab(chartExample(), "Charts");
* examples.addTab(new WText("A WText"), "WText");
*
* examples.currentChanged().addListener(this, new Signal.Listener(){
* public void trigger() {
* //custom code
* }
* });
* examples.setInternalPathEnabled();
* examples.setInternalBasePath("/examples");
* \endcode
* \endif
*
* <h3>CSS</h3>
*
* The tab widget is styled by the current CSS theme.
*
* <TABLE border="0" align="center"> <TR> <TD>
* \image html WTabWidget-default-1.png "An example WTabWidget (default)"
* </TD> <TD>
* \image html WTabWidget-polished-1.png "An example WTabWidget (polished)"
* </TD> </TR> </TABLE>
*/
class WT_API WTabWidget : public WCompositeWidget
{
public:
/*! \brief Enumeration to indicate when the contents should be loaded
*/
enum LoadPolicy { LazyLoading, //!< Lazy loading: on first use
PreLoading //!< Pre-loading: before first use
};
/*! \brief Creates a new tab widget
*/
WTabWidget(WContainerWidget *parent = 0);
/*! \brief Adds a new tab, with <i>child</i> as content, and the given label.
*
* Returns the menu item that implements the tab item.
*/
WMenuItem *addTab(WWidget *child, const WString& label,
LoadPolicy = LazyLoading);
/*! \brief Removes a tab item.
*
* The widget itself is not deleted.
*
* \sa WMenu::removeItem()
*/
void removeTab(WWidget *widget);
/*! \brief Returns the number of tabs.
*/
int count() const;
/*! \brief Returns the content widget at the given tab <i>index</i>.
*/
WWidget *widget(int index) const;
/*! \brief Returns the index of the tab of the given content widget.
*
* If the widget is not in this tab widget, then -1 is returned.
*/
int indexOf(WWidget *widget) const;
/*! \brief Activates the tab at <i>index</i>.
*/
void setCurrentIndex(int index);
/*! \brief Returns the index of the activated tab.
*/
int currentIndex() const;
/*! \brief Activates the tab showing the given <i>widget</i>
*/
void setCurrentWidget(WWidget *widget);
/*! \brief Returns the widget of the activated tab.
*/
WWidget *currentWidget() const;
/*! \brief Enables or disables a tab.
*
* Enables or disables the tab at \p index. A disabled tab cannot be
* activated.
*/
void setTabEnabled(int index, bool enable);
/*! \brief Returns whether a tab is enabled.
*
* \sa WMenu::enableItem(), WMenu::disableItem()
*/
bool isTabEnabled(int index) const;
/*! \brief Hides or shows a tab.
*
* Hides or shows the tab at \p index.
*/
void setTabHidden(int index, bool hidden);
/*! \brief Returns whether a tab is hidden.
*/
bool isTabHidden(int index) const;
/*! \brief Make it possible to close a tab interactively or by
* \link WTabWidget::closeTab() closeTab\endlink.
*
* A tab that has been closed is marked as hidden, but not removed
* from the menu.
*
* \sa removeTab()
*/
void setTabCloseable(int index, bool closeable);
/*! \brief Returns whether a tab is closeable.
*
* \sa setTabCloseable()
*/
bool isTabCloseable(int index);
/*! \brief Changes the label for a tab.
*/
void setTabText(int index, const WString& label);
/*! \brief Returns the label for a tab.
*
* \sa setTabText()
*/
const WString& tabText(int index) const;
/*! \brief Sets the tooltip for a tab.
*
* The tooltip is shown when the user hovers over the label.
*/
void setTabToolTip(int index, const WString& tip);
/*! \brief Returns the tooltip for a tab.
*
* \sa setTabToolTip()
*/
const WString& tabToolTip(int index) const;
/*! \brief Enables internal paths for items.
*
* \copydetails WMenu::setInternalPathEnabled
*/
void setInternalPathEnabled(const std::string& basePath = "");
/*! \brief Returns whether internal paths are enabled.
*
* \copydetails WMenu::internalPathEnabled
*/
bool internalPathEnabled() const;
/*! \brief Sets the internal base path.
*
* \copydetails WMenu::setInternalBasePath
*/
void setInternalBasePath(const std::string& path);
/*! \brief Returns the internal base path.
*
* \copydetails WMenu::internalBasePath
*/
const std::string& internalBasePath() const;
/*! \brief %Signal emitted when the user activates a tab.
*
* The index of the newly activated tab is passed as an argument.
*/
Signal<int>& currentChanged() { return currentChanged_; }
/*! \brief Closes a tab at \p index.
*
* A tab that has been closed is marked as hidden, but not removed
* from the menu.
*
* \sa removeTab(), setTabHidden()
*/
void closeTab(int index);
/*! \brief %Signal emitted when the user closes a tab.
*
* The index of the closed tab is passed as an argument.
*
* \sa closeTab(), setTabCloseable()
*/
Signal<int>& tabClosed() { return tabClosed_; }
/*! \brief Returns the contents stack.
*
* The tab widget is implemented as a WMenu + WStackedWidget which
* displays the contents. This method returns a reference to this
* contents stack.
*/
WStackedWidget *contentsStack() const;
private:
Signal<int> currentChanged_;
Signal<int> tabClosed_;
WContainerWidget *layout_;
WMenu *menu_;
std::vector<WWidget *> contentsWidgets_;
void create();
void onItemSelected(WMenuItem *item);
void onItemClosed(WMenuItem *item);
void setJsSize();
};
}
#endif // WTABWIDGET_H_
|