sptk2 logo
SPTK Home Page
CColumn.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/Strings.h>
30#include <sptk5/Variant.h>
31#include <sptk5/xdoc/Node.h>
32#include <string>
33
34namespace sptk {
35
44class SP_EXPORT CColumn
45{
49 String m_name;
50
54 uint32_t m_width;
55
59 VariantDataType m_type;
60
64 bool m_visible;
65
69 bool m_autoWidth;
70
71public:
79 CColumn(const std::string& cname = "", VariantDataType type = VariantDataType::VAR_STRING, int32_t cwidth = 100,
80 bool cvisible = true);
81
86 CColumn(const CColumn& col) = default;
87
91 String name() const
92 {
93 return m_name;
94 }
95
99 int16_t width() const
100 {
101 return (int16_t) m_width;
102 }
103
108 void width(int16_t w)
109 {
110 m_width = (uint32_t) w;
111 }
112
116 bool visible() const
117 {
118 return m_visible;
119 }
120
125 void visible(bool v)
126 {
127 m_visible = v;
128 }
129
133 bool autoWidth() const
134 {
135 return m_autoWidth;
136 }
137
142 void autoWidth(bool v)
143 {
144 m_autoWidth = v;
145 }
146
151 {
152 return m_type;
153 }
154
161 void load(const xdoc::SNode& node);
162
170 void save(const xdoc::SNode& node) const;
171};
172
176class SP_EXPORT CColumnList
177 : public std::vector<CColumn>
178{
179public:
183 CColumnList() = default;
184
189 int indexOf(const char* columnName) const;
190
197 void load(const xdoc::SNode& node);
198
205 void save(const xdoc::SNode& node) const;
206};
210}
Definition: CColumn.h:178
void save(const xdoc::SNode &node) const
Saves columns information.
CColumnList()=default
Default constructor.
int indexOf(const char *columnName) const
Finds the column index by column name.
void load(const xdoc::SNode &node)
Loads columns information.
Class CColumn represents a column descriptor for CListView.
Definition: CColumn.h:45
void width(int16_t w)
Sets column width in pixels.
Definition: CColumn.h:108
String name() const
Returns column name.
Definition: CColumn.h:91
bool autoWidth() const
Returns Column auto width flag.
Definition: CColumn.h:133
void save(const xdoc::SNode &node) const
Saves column information.
void visible(bool v)
Sets column visibility.
Definition: CColumn.h:125
CColumn(const CColumn &col)=default
Copy constructor.
CColumn(const std::string &cname="", VariantDataType type=VariantDataType::VAR_STRING, int32_t cwidth=100, bool cvisible=true)
Constructor.
void autoWidth(bool v)
Sets column auto width flag.
Definition: CColumn.h:142
void load(const xdoc::SNode &node)
Loads column information.
VariantDataType type() const
Returns column data type.
Definition: CColumn.h:150
bool visible() const
Returns column visibility.
Definition: CColumn.h:116
int16_t width() const
Returns column width in pixels.
Definition: CColumn.h:99
Definition: String.h:49
VariantDataType
Definition: VariantData.h:44
@ VAR_STRING
String pointer.

Fri Oct 14 2022 09:58:31: SPTK 5.4.1