Wt
4.11.0
|
Theme based on the Bootstrap 5 CSS framework. More...
#include <Wt/WBootstrap5Theme.h>
Public Member Functions | |
WBootstrap5Theme () | |
Constructor. | |
void | init (WApplication *app) const override |
Called when the theme is assigned to a WApplication. | |
std::string | name () const override |
Returns a theme name. | |
std::string | resourcesUrl () const override |
Returns the URL where theme-related resources are stored. | |
std::vector< WLinkedCssStyleSheet > | styleSheets () const override |
Returns a vector with stylesheets for the theme. | |
void | apply (WWidget *widget, WWidget *child, int widgetRole) const override |
Applies the theme to a child of a composite widget. | |
void | apply (WWidget *widget, DomElement &element, int elementRole) const override |
Applies the theme to a DOM element that renders a widget. | |
std::string | disabledClass () const override |
Returns a generic CSS class name for a disabled element. | |
std::string | activeClass () const override |
Returns a generic CSS class name for an active element. | |
std::string | utilityCssClass (int utilityCssClassRole) const override |
Returns a generic CSS class name for the chosen role. | |
bool | canStyleAnchorAsButton () const override |
Returns whether the theme allows for an anchor to be styled as a button. | |
void | applyValidationStyle (WWidget *widget, const Wt::WValidator::Result &validation, WFlags< ValidationStyleFlag > flags) const override |
Applies a style that indicates the result of validation. | |
Side | panelCollapseIconSide () const override |
Returns which side the WPanel collapse icon should be added on. | |
Public Member Functions inherited from Wt::WTheme | |
WTheme () | |
Constructor. | |
virtual | ~WTheme () |
Destructor. | |
virtual void | serveCss (WStringStream &out) const |
Serves the CSS for the theme. | |
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 | |
Public Types inherited from Wt::WObject | |
typedef void(WObject::* | Method) () |
Typedef for a WObject method without arguments. | |
Protected Member Functions inherited from Wt::WObject | |
virtual WStatelessSlot * | getStateless (Method method) |
On-demand stateless slot implementation. | |
Theme based on the Bootstrap 5 CSS framework.
This theme implements support for building a Wt web application that uses Bootstrap 5 as a theme for its (layout and) styling.
Using this theme, various widgets provided by the library are rendered using markup that is compatible with Bootstrap 5. 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 and JavaScript resources that are shipped together with the Wt distribution, but you can replace the CSS with custom-built CSS by reimplementing styleSheets().
Although this theme styles individual widgets correctly, for your web application's layout you are recommended to use WTemplate in conjunction with Bootstrap's CSS classes. For this we refer to Bootstrap's documentation at https://getbootstrap.com.
Custom Sass files can be used to make your own derived theme.
If Wt is installed into PREFIX
(and the CMake option INSTALL_THEMES
is set to ON
), then you can find the source files in PREFIX/share/Wt/themes/bootstrap/5
.
Apart from the variables that Bootstrap defines, Wt also provides variables, defined in wt/_variables.scss
. All of Wt's variables start with a wt-
prefix.
Refer to the example in examples/custom-bs-theme
for more information.
|
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.
|
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.
|
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.
|
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.
|
overridevirtual |
Returns which side the WPanel collapse icon should be added on.
Side is assumed to be Side::Left or Side::Right, other sides are not supported.
Reimplemented from Wt::WTheme.
|
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.
|
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.
|
overridevirtual |
Returns a generic CSS class name for the chosen role.
Implements Wt::WTheme.