Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/fmt/xpm/Color.h

raw
1 /*
2 * Copyright (C) 2026 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2026 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 18 янв. 2026 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_FMT_XPM_COLOR_H_
23 #define LSP_PLUG_IN_FMT_XPM_COLOR_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26
27 #include <lsp-plug.in/fmt/xpm/ColorItem.h>
28
29 namespace lsp
30 {
31 namespace xpm
32 {
33 /**
34 * XPM2/XPM3 color
35 */
36 class LSP_RUNTIME_LIB_PUBLIC Color
37 {
38 private:
39 char *sCode;
40 ColorItem sMono; // XPM: mono visual ('m')
41 ColorItem sSymbolic; // XPM: symbolic name ('s')
42 ColorItem sGray4; // XPM: 4-level grayscale ('g4')
43 ColorItem sGray; // XPM: grayscale with more than 4 levels ('g')
44 ColorItem sColor; // XPM: color visual
45
46 public:
47 Color() noexcept;
48 explicit Color(const char * code);
49 Color(const char * code, size_t len);
50 Color(const Color & src);
51 Color(Color && src) noexcept;
52 ~Color();
53
54 Color & operator = (const Color & src);
55 Color & operator = (Color && src) noexcept;
56
57 public:
58 inline const char *code() const noexcept { return sCode; }
59 bool set_code(const char *code);
60 bool set_code(const char *code, size_t len);
61 inline bool has_code() const noexcept { return sCode != NULL; }
62 bool has_code(const char *code) const noexcept;
63 void clear_code();
64
65 bool set(const Color & src);
66
67 inline ColorItem & mono_visual() noexcept { return sMono; }
68 inline const ColorItem & mono_visual() const noexcept { return sMono; }
69
70 inline ColorItem & symbolic_visual()noexcept { return sSymbolic; }
71 inline const ColorItem & symbolic_visual() const noexcept { return sSymbolic; }
72
73 inline ColorItem & gray4_visual() noexcept { return sGray4; }
74 inline const ColorItem & gray4_visual() const noexcept { return sGray4; }
75
76 inline ColorItem & gray_visual() noexcept { return sGray; }
77 inline const ColorItem & gray_visual() const noexcept { return sGray; }
78
79 inline ColorItem & color_visual() noexcept { return sColor; }
80 inline const ColorItem & color_visual() const noexcept { return sColor; }
81
82 public:
83 void swap(Color & src) noexcept;
84 void swap(Color * src) noexcept;
85 };
86
87 } /* namespace xpm */
88 } /* namespace lsp */
89
90
91 #endif /* LSP_PLUG_IN_FMT_XPM_COLOR_H_ */