Webdar 1.0.0
Web user interface to libdar
webdar_css_style.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef WEBDAR_CSS_STYLE_HPP
25#define WEBDAR_CSS_STYLE_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35
36
37 // webdar headers
38#include "css_library.hpp"
39
41
42namespace webdar_css_style
43{
45 extern void update_library(css_library & ref);
46
47 constexpr const char* text_grey = "wcs_tg";
48 constexpr const char* text_bold = "wcs_tb";
49 constexpr const char* text_shadow_dark = "wcs_tsd";
50 constexpr const char* text_shadow_bright = "wcs_tsb";
51 constexpr const char* text_color_normal = "wcs_cn";
52 constexpr const char* text_color_red = "wcs_cr";
53 constexpr const char* text_color_green = "wcs_cg";
54 constexpr const char* text_top_right = "wcs_ttr";
55 constexpr const char* text_top_center = "wcs_tc";
56 constexpr const char* text_right = "wcs_tr";
57 constexpr const char* float_left = "wcs_fll";
58 constexpr const char* float_right = "wcs_flr";
59 constexpr const char* float_flush = "wcs_flf";
60 constexpr const char* spacing_vertical = "wcs_spcv";
61 constexpr const char* spacing_horizontal = "wcs_spch";
62 constexpr const char* width_100vw = "wcs_w100";
63 constexpr const char* width_100vw_3em = "wcs_w100_3em"; // 100% - 3em / to align html_form_input with html_form_input_file
64 constexpr const char* width_100vw_8em = "wcs_w100_8em"; // 100% - 3em / to align html_form_input with html_form_input_unit
65 constexpr const char* width_100vw_5em = "wcs_w100_5em"; // 100% - 3em / to align html_form_input_file with html_form_input_unit
66 constexpr const char* width_80vw = "wcs_w80";
67 constexpr const char* width_60vw = "wcs_w60";
68 constexpr const char* red_border = "wcs_red_border";
69 constexpr const char* indent = "wcs_indent";
70
71
73
76 const css_class & get_css_class(const std::string & name);
77
78 // class used by the *_button templates below (should not be used directly, it is publicly
79 // available because template body need to be stored in header file")
80 constexpr const char* width_8em = "wcs_w8em";
81 constexpr const char* width_full = "fullwidth";
82 constexpr const char* btn_off = "wcs_btn_off";
83 constexpr const char* btn_small = "wcs_btn_small";
84 constexpr const char* btn_on = "wcs_btn_on";
85 constexpr const char* btn_void = "wcs_btn_void";
86 constexpr const char* btn_grey = "wcs_btn_grey";
87 constexpr const char* url_selected = "wcs_url_selected";
88 constexpr const char* url_normal = "wcs_url_normal";
89 constexpr const char* url_void = "wcs_url_void";
90 constexpr const char* url_grey = "wcs_url_grey";
91
92
94 template <class T> void normal_button(T & obj, bool fullwidth = false)
95 {
96 obj.clear_css_classes();
97 obj.add_css_class(btn_off);
98 obj.url_clear_css_classes();
99 obj.url_add_css_class(url_normal);
100 if(!fullwidth)
101 obj.add_css_class(width_8em);
102 }
103
104 template <class T> void small_button(T & obj)
105 {
106 obj.clear_css_classes();
107 obj.add_css_class(btn_small);
108 obj.url_clear_css_classes();
109 obj.url_add_css_class(url_normal);
110 }
111
112
114 template <class T> void active_button(T & obj, bool fullwidth = false)
115 {
116 obj.clear_css_classes();
117 obj.add_css_class(btn_on);
118 obj.url_clear_css_classes();
119 obj.url_add_css_class(url_selected);
120 if(!fullwidth)
121 obj.add_css_class(width_8em);
122 }
123
125 template <class T> void void_button(T & obj, bool fullwidth = false)
126 {
127 obj.clear_css_classes();
128 obj.add_css_class(btn_void);
129 obj.url_clear_css_classes();
130 obj.url_add_css_class(url_void);
131 if(!fullwidth)
132 obj.add_css_class(width_8em);
133 }
134
135 template <class T> void grey_button(T & obj, bool fullwidth = false)
136 {
137 obj.clear_css_classes();
138 obj.add_css_class(btn_grey);
139 obj.url_clear_css_classes();
140 obj.url_add_css_class(url_grey);
141 if(!fullwidth)
142 obj.add_css_class(width_8em);
143 }
144
145
146} // namespace end
147
148#endif
class css_class gather css attributed under a given label
Definition: css_class.hpp:51
class css_library
Definition: css_library.hpp:46
the webdar_css_style namespace defines a set of global css objets and some routines to use them
Definition: webdar_css_style.cpp:45
void normal_button(T &obj, bool fullwidth=false)
apply to the given button the css_classe names defined by update_library to get a normal button style
Definition: webdar_css_style.hpp:94
void update_library(css_library &csslib)
update a css_library with all css definitions of this webdar_css_style module
Definition: webdar_css_style.cpp:452
void void_button(T &obj, bool fullwidth=false)
apply to the given button the css_classe names defined by update_library to get an void/invisible but...
Definition: webdar_css_style.hpp:125
const css_class & get_css_class(const string &name)
obtain the css_class object corresponding to the given name
Definition: webdar_css_style.cpp:465
void active_button(T &obj, bool fullwidth=false)
apply to the given button the css_classe names defined by update_library to get an active button styl...
Definition: webdar_css_style.hpp:114