Loading [MathJax]/extensions/tex2jax.js
Antares Simulator
Power System Simulator
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages Concepts
iitem.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator 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** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_UI_COMMON_COMPONENT_SPOTLIGHT_SPOTLIGHT_IITEM_H__
22#define __ANTARES_UI_COMMON_COMPONENT_SPOTLIGHT_SPOTLIGHT_IITEM_H__
23
24#include <memory>
25
26class IItem
27{
28public:
30 using Ptr = std::shared_ptr<IItem>;
32 using Vector = std::vector<Ptr>;
34 using VectorPtr = std::shared_ptr<Vector>;
36 using GroupType = Yuni::CString<64, false>;
37
38 class IPart
39 {
40 public:
41 IPart()
42 {
43 }
44 virtual ~IPart()
45 {
46 }
47
49 virtual uint width() const;
51 virtual uint height() const;
52
53 }; // background color
54
55 class Tag
56 {
57 public:
59 using Ptr = std::shared_ptr<Tag>;
61 using Vector = std::vector<Ptr>;
62
63 public:
64 template<class StringT>
65 Tag(const StringT& t) : text(wxStringFromUTF8(t))
66 {
67 }
68 Tag(const wxChar* t) : text(t)
69 {
70 }
71 Tag(const wxString& t) : text(t)
72 {
73 }
74 template<class StringT>
75 Tag(const StringT& t, uint8_t r, uint8_t g, uint8_t b) :
76 text(wxStringFromUTF8(t)), color(r, g, b)
77 {
78 }
79 Tag(const wxChar* t, uint8_t r, uint8_t g, uint8_t b) : text(t), color(r, g, b)
80 {
81 }
82 Tag(const wxString& t, uint8_t r, uint8_t g, uint8_t b) :
83 text(t), color(r, g, b)
84 {
85 }
86
87 public:
89 wxString text;
91 Yuni::Color::RGB<> color;
92 };
93
94public:
96
97
102 virtual ~IItem();
104
106
107
108 const Yuni::String& caption() const;
110 template<class StringT>
111 void caption(const StringT& caption);
113 void caption(const wxString& caption);
114
116 const Yuni::String& subcaption() const;
118 template<class StringT>
119 void subcaption(const StringT& caption);
120
122
124
125
126 const GroupType& group() const;
128 template<class StringT>
129 void group(const StringT& g);
131 template<class StringT>
132 bool isSameGroup(const StringT& group) const;
134
136
137
138 virtual bool canBeSelected() const;
140
142
143
144 void image(const wxBitmap& bmp);
146 void image(const wxBitmap* bmp);
148 const wxBitmap& image() const;
150
152
153
154 bool selected() const;
156 void select();
158 void unselect();
160
162
163
164 template<class StringT>
165 void addTag(const StringT& text);
167 template<class StringT>
168 void addTag(const StringT& text, uint8_t r, uint8_t g, uint8_t b);
170 template<class StringT>
171 void addRightTag(const StringT& text);
173 template<class StringT>
174 void addRightTag(const StringT& text, uint8_t r, uint8_t g, uint8_t b);
176 void clearTags();
178
180
181
182 bool countedAsResult() const;
184 void countedAsResult(bool v);
186
188
189
196 virtual void draw(wxDC& dc,
197 uint itemHeight,
198 wxRect& bounds,
199 bool selected,
200 const SearchToken::VectorPtr& tokens) const;
202
203public:
205 int tag;
206
207protected:
211 Yuni::String pCaption;
213 Yuni::String pSubCaption;
215 wxBitmap pBitmap;
226
227}; // class IITem
228
229#endif // __ANTARES_UI_COMMON_COMPONENT_SPOTLIGHT_SPOTLIGHT_IITEM_H__
Definition iitem.h:39
virtual uint width() const
Width of the cell.
virtual uint height() const
Height of the cell.
Definition iitem.h:56
std::vector< Ptr > Vector
Vector.
Definition iitem.h:61
std::shared_ptr< Tag > Ptr
The most suitable smart pointer.
Definition iitem.h:59
wxString text
Text.
Definition iitem.h:89
Yuni::Color::RGB color
Tag color.
Definition iitem.h:91
Definition iitem.h:27
bool pSelected
Selected.
Definition iitem.h:217
IItem()
Default constructor.
std::vector< Ptr > Vector
Vector of items.
Definition iitem.h:32
void image(const wxBitmap *bmp)
Set the item's image (pointer, can be null)
void unselect()
Mark the item as not selected.
void caption(const wxString &caption)
Set the caption.
void image(const wxBitmap &bmp)
Set the item's image (reference)
void caption(const StringT &caption)
Set the caption.
void addRightTag(const StringT &text)
Add a new tag on the right.
virtual void draw(wxDC &dc, uint itemHeight, wxRect &bounds, bool selected, const SearchToken::VectorPtr &tokens) const
Draw the item.
const Yuni::String & caption() const
Get the caption.
Tag::Vector pLeftTags
Tags on the left.
Definition iitem.h:221
void clearTags()
Clear all tags.
Tag::Vector pRightTags
Tags on the right.
Definition iitem.h:223
void addRightTag(const StringT &text, uint8_t r, uint8_t g, uint8_t b)
Add a new tag on the right.
Yuni::CString< 64, false > GroupType
Group.
Definition iitem.h:36
void countedAsResult(bool v)
Set if this item should be counted as a result.
const wxBitmap & image() const
Get the item& image.
void select()
Mark the item as selected.
int tag
User-custom tag.
Definition iitem.h:205
void addTag(const StringT &text, uint8_t r, uint8_t g, uint8_t b)
Add a new tag.
std::shared_ptr< IItem > Ptr
Ptr.
Definition iitem.h:30
const GroupType & group() const
Get the group of the item.
wxString pCacheCaption
Cache wxString.
Definition iitem.h:225
bool isSameGroup(const StringT &group) const
Compare with another group.
std::shared_ptr< Vector > VectorPtr
Vector Ptr.
Definition iitem.h:34
bool countedAsResult() const
Get if this item should be counted as a result.
void subcaption(const StringT &caption)
Set the caption.
virtual ~IItem()
Destructor.
wxBitmap pBitmap
Image.
Definition iitem.h:215
void addTag(const StringT &text)
Add a new tag.
bool pCountedAsResult
Flag to determine if this items should be counted as a result.
Definition iitem.h:219
virtual bool canBeSelected() const
Get if the item can be selected.
void group(const StringT &g)
Set the group.
bool selected() const
Get if the item is selected.
Yuni::String pCaption
Caption.
Definition iitem.h:211
const Yuni::String & subcaption() const
Get the sub-caption.
GroupType pGroup
The group.
Definition iitem.h:209
std::shared_ptr< Vector > VectorPtr
Vector ptr.
Definition searchtoken.h:35