Style.hpp

A CSS class for tracking font style, etc.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2015-2018 Michigan State University MIT Software license; see doc/LICENSE.md

Defines

INCLUDE_EMP_WEB_STYLE_HPP_GUARD
class Style
#include <Style.hpp>

Class to maintain a map of setting names to values that can be easily ported over to JavaScript. A companion class, Attributes, also exists.

Public Functions

Style() = default
Style(const Style&) = default
Style(Style&&) = default
template<typename ...Ts>
inline Style(Ts&&... args)
Style &operator=(const Style&) = default
Style &operator=(Style&&) = default
inline size_t GetSize() const

Return a count of the number of settings that have been set.

inline size_t GetNClasses() const

Return a count of the number of classes that have been added.

inline Style &AddClass(const std::string &in_class)
template<typename SET_TYPE, typename ...EXTRA_Ts>
inline Style &Set(const std::string &s, SET_TYPE v, EXTRA_Ts&&... extras)

Record that setting “s” is set to value “v” (converted to string) and return this object.

inline Style &Set()

Null condition; Set may have no arguments.

inline Style &Insert(const Style &in_css)

Set all values from in_css here as well. Return this object.

inline bool Has(const std::string &setting) const

Return true/false based on whether “setting” has been given a value in this Style.

inline const std::string &Get(const std::string &setting) const

Return the (string) value of “setting” that has been recorded in this Style.

inline const std::map<std::string, std::string> &GetMap() const
inline const std::set<std::string> &GetClasses() const
inline void Clear()

Remove all setting values and all classes.

inline void Remove(const std::string &setting)

Remove a specific setting value.

inline void RemoveClass(const std::string &css_class)

Remove a specific class.

inline void Apply(const std::string &widget_id)

Apply ALL of the style settings to a specified widget.

inline void Apply(const std::string &widget_id, const std::string &setting)

Apply only a SPECIFIC style setting from the setting library.

inline operator bool() const

Have any settings be set?

Public Static Functions

static inline void Apply(const std::string &widget_id, const std::string &setting, const std::string &value)

Apply only a SPECIFIC style setting with a specified value!

static inline void ApplyClass(const std::string &widget_id, const std::string &css_class)
static inline void ApplyRemoveClass(const std::string &widget_id, const std::string &css_class)

Private Members

std::map<std::string, std::string> settings

CSS Setting values being tracked.

std::set<std::string> classes

CSS classes.