Wt: Wt::WBootstrapTheme Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Wt::WBootstrapTheme Class Reference

Theme based on the Twitter Bootstrap CSS framework. More...

`#include <Wt/WBootstrapTheme.h>`

Inheritance diagram for Wt::WBootstrapTheme:
[legend]

## Public Types
typedef BootstrapVersion | Version
| Typedef for enum Wt::BootstrapVersion.
Public Types inherited from Wt::WObject
typedef void(WObject::*) | Method()
| Typedef for a WObject method without arguments.

## Public Member Functions
| WBootstrapTheme ()
| Constructor.
void | setResponsive (bool responsive)
bool | responsive () const
| Returns whether responsive features are enabled.
void | setVersion (BootstrapVersion version)
| Sets the bootstrap version.
BootstrapVersion | version () const
| Returns the bootstrap version.
void | setFormControlStyleEnabled (bool enabled)
| Enables form-control on all applicable form widgets.
virtual std::string | name () const override
| Returns a theme name.
virtual std::string | resourcesUrl () const override
| Returns the URL where theme-related resources are stored.
virtual std::vector< WLinkedCssStyleSheet > | styleSheets () const override
| Returns a vector with stylesheets for the theme.
virtual void | init (WApplication *app) const override
| Called when the theme is assigned to a WApplication.
virtual void | apply (WWidget *widget, WWidget *child, int widgetRole) const override
| Applies the theme to a child of a composite widget.
virtual void | apply (WWidget *widget, DomElement &element, int elementRole) const override
| Applies the theme to a DOM element that renders a widget.
virtual std::string | disabledClass () const override
| Returns a generic CSS class name for a disabled element.
virtual std::string | activeClass () const override
| Returns a generic CSS class name for an active element.
virtual std::string | utilityCssClass (int utilityCssClassRole) const override
| Returns a generic CSS class name for the chosen role.
virtual bool | canStyleAnchorAsButton () const override
| Returns whether the theme allows for an anchor to be styled as a button.
virtual void | applyValidationStyle (WWidget *widget, const Wt::WValidator::Result &validation, WFlags< ValidationStyleFlag > styles) const override
| Applies a style that indicates the result of validation.
Public Member Functions inherited from Wt::WTheme
| WTheme ()
| Constructor.
virtual | ~WTheme ()
| Destructor.
virtual void | serveCss (WStringStream &out) const
| Serves the CSS for the theme.
virtual Side | panelCollapseIconSide () const
| Returns which side the WPanel collapse icon should be added on.
Public Member Functions inherited from Wt::WObject
void | addChild (std::unique_ptr< WObject > child)
| Add a child WObject whose lifetime is determined by this WObject.
template<typename Child >
Child * | addChild (std::unique_ptr< Child > child)
| Add a child WObject, returning a raw pointer.
std::unique_ptr< WObject > | removeChild (WObject *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
template<typename Child >
std::unique_ptr< Child > | removeChild (Child *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
virtual const std::string | id () const
| Returns the (unique) identifier for this object.
virtual void | setObjectName (const std::string &name)
| Sets an object name.
virtual std::string | objectName () const
| Returns the object name.
void | resetLearnedSlots ()
| Resets learned stateless slot implementations.
template<class T >
void | resetLearnedSlot (void(T::*method)())
| Resets a learned stateless slot implementation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)())
| Declares a slot to be stateless and learn client-side behaviour on first invocation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)())
| Declares a slot to be stateless and learn client-side behaviour in advance.
void | isNotStateless ()
| Marks the current function as not stateless.
template<class T >
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode)
| Provides a JavaScript implementation for a method.
Public Member Functions inherited from Wt::Core::observable
| observable () noexcept
| Default constructor.
virtual | ~observable ()
| Destructor.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...)) noexcept
| Protects a method call against object destruction.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...) const) const noexcept
| Protects a const method call against object destruction.
template<typename Function >
auto | bindSafe (const Function &function) noexcept
| Protects a function against object destruction.

## Additional Inherited Members
Static Public Member Functions inherited from Wt::WObject
Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * | getStateless (Method method)
| On-demand stateless slot implementation.

## Detailed Description

Theme based on the Twitter Bootstrap CSS framework.

Deprecated
  WBootstrapTheme is deprecated. Use one of the concrete versioned Bootstrap theme classes instead, like WBootstrap2Theme and WBootstrap3Theme.

This theme implements support for building a Wt web application that uses Twitter Bootstrap as a theme for its (layout and) styling. The theme comes with CSS from Bootstrap version 2.2.2 or version 3.1. Only the CSS components of twitter bootstrap are used, but not the JavaScript (i.e. the functional parts), since the functionality is already built-in to the widgets from the library.

Using this theme, various widgets provided by the library are rendered using markup that is compatible with Twitter Bootstrap. The bootstrap theme is also extended with a proper (compatible) styling of widgets for which bootstrap does not provide styling (table views, tree views, sliders, etc...).

By default, the theme will use CSS resources that are shipped together with the Wt distribution, but since the Twitter Bootstrap CSS API is a popular API for custom themes, you can easily replace the CSS with custom-built CSS (by reimplementing styleSheets()).

Although this theme facilitates the use of Twitter Bootstrap with Wt, it is still important to understand how Bootstrap expects markup to be, especially related to layout using its grid system, for which we refer to the official bootstrap documentation, see http://getbootstrap.com

See also
  WApplication::setTheme()

## Member Function Documentation

## ◆ apply() [1/2]

virtual void Wt::WBootstrapTheme::apply | ( | WWidget * | widget,
|  | DomElement & | element,
|  | int | elementRole ) const
| overridevirtual

Applies the theme to a DOM element that renders a widget.

The `element` is a rendered representation of the `widget`, and may be further customized to reflect the theme.

Implements Wt::WTheme.

## ◆ apply() [2/2]

virtual void Wt::WBootstrapTheme::apply | ( | WWidget * | widget,
|  | WWidget * | child,
|  | int | widgetRole ) const
| overridevirtual

Applies the theme to a child of a composite widget.

The `widgetRole` indicates the role that `child` has within the implementation of the `widget`.

Implements Wt::WTheme.

## ◆ init()

virtual void Wt::WBootstrapTheme::init | ( | WApplication * | app | ) | const
| overridevirtual

Called when the theme is assigned to a WApplication.

This allows the theme to do things like load resource bundles when it is added to an application using WApplication::setTheme().

The default implementation does nothing.

Reimplemented from Wt::WTheme.

## ◆ name()

virtual std::string Wt::WBootstrapTheme::name | ( |  | ) | const
| overridevirtual

Returns a theme name.

Returns a unique name for the theme. This name is used by the default implementation of resourcesUrl() to compute a location for the theme's resources.

Implements Wt::WTheme.

## ◆ resourcesUrl()

virtual std::string Wt::WBootstrapTheme::resourcesUrl | ( |  | ) | const
| overridevirtual

Returns the URL where theme-related resources are stored.

The default implementation considers a folder within Wt's resource directory, based on the theme name().

Reimplemented from Wt::WTheme.

## ◆ responsive()

bool Wt::WBootstrapTheme::responsive | ( |  | ) | const

Returns whether responsive features are enabled.

See also
  setResponsive()

## ◆ setFormControlStyleEnabled()

void Wt::WBootstrapTheme::setFormControlStyleEnabled | ( | bool | enabled | ) |

Enables form-control on all applicable form widgets.

This is relevant only for bootstrap 3.

By applying "form-control" on form widgets, they will become block level elements that take the size of the parent (which is in bootstrap's philosphy a grid layout).

The default value is `true`.

## ◆ setResponsive()

void Wt::WBootstrapTheme::setResponsive | ( | bool | responsive | ) |

Enables responsive features.

Responsive features can be enabled only at application startup. For bootstrap 3, you need to use the progressive bootstrap feature of Wt (see 10.2 General application settings (wt_config.xml)) as it requires setting HTML meta flags.

Responsive features are disabled by default.

## ◆ setVersion()

void Wt::WBootstrapTheme::setVersion | ( | BootstrapVersion | version | ) |

Sets the bootstrap version.

The default bootstrap version is 2 (but this may change in the future and thus we recommend setting the version).

Since Twitter Bootstrap breaks its API with a major version change, the version has a big impact on how how the markup is done for various widgets.

Note that the two Bootstrap versions have a different license: Apache 2.0 for Bootstrap version 2.2.2, and MIT for version 3.1. See these licenses for details.

## ◆ styleSheets()

virtual std::vector< WLinkedCssStyleSheet > Wt::WBootstrapTheme::styleSheets | ( |  | ) | const
| overridevirtual

Returns a vector with stylesheets for the theme.

This should return a vector with stylesheets that implement the theme. This list may be tailored to the current user agent, which is read from the application environment.

Implements Wt::WTheme.

## ◆ utilityCssClass()

virtual std::string Wt::WBootstrapTheme::utilityCssClass | ( | int | utilityCssClassRole | ) | const
| overridevirtual

Returns a generic CSS class name for the chosen role.

See also
  WTheme::utilityCssClassRole

Implements Wt::WTheme.

## ◆ version()

BootstrapVersion Wt::WBootstrapTheme::version | ( |  | ) | const

Returns the bootstrap version.

See also
  setVersion()