KiCad PCB EDA Suite
Loading...
Searching...
No Matches
color4d_variant.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
23 wxVariantData()
24{}
25
26
27COLOR4D_VARIANT_DATA::COLOR4D_VARIANT_DATA( const wxString& aColorStr ) :
28 wxVariantData(),
29 m_color( aColorStr )
30{}
31
32
34 wxVariantData(),
35 m_color( aColor )
36{}
37
38
39bool COLOR4D_VARIANT_DATA::Eq( wxVariantData& aOther ) const
40{
41 try
42 {
43 COLOR4D_VARIANT_DATA& evd = dynamic_cast<COLOR4D_VARIANT_DATA&>( aOther );
44
45 return evd.m_color == m_color;
46 }
47 catch( std::bad_cast& )
48 {
49 return false;
50 }
51}
52
53
54bool COLOR4D_VARIANT_DATA::Read( wxString& aString )
55{
56 m_color = KIGFX::COLOR4D( aString );
57 return true;
58}
59
60
61bool COLOR4D_VARIANT_DATA::Write( wxString& aString ) const
62{
63 aString = m_color.ToCSSString();
64 return true;
65}
66
67
68bool COLOR4D_VARIANT_DATA::GetAsAny( wxAny* aAny ) const
69{
70 *aAny = m_color;
71 return true;
72}
73
74
75wxVariantData* COLOR4D_VARIANT_DATA::VariantDataFactory( const wxAny& aAny )
76{
77 return new COLOR4D_VARIANT_DATA( aAny.As<KIGFX::COLOR4D>() );
78}
bool Write(wxString &aString) const override
bool GetAsAny(wxAny *aAny) const override
KIGFX::COLOR4D m_color
static wxVariantData * VariantDataFactory(const wxAny &aAny)
bool Read(wxString &aString) override
bool Eq(wxVariantData &aOther) const override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
wxString ToCSSString() const
Definition: color4d.cpp:147