File: itemattr.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (79 lines) | stat: -rw-r--r-- 2,624 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/itemattr.h
// Purpose:     wxItemAttr class declaration
// Author:      Vadim Zeitlin
// Created:     2016-04-16 (extracted from wx/listctrl.h)
// Copyright:   (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_ITEMATTR_H_
#define _WX_ITEMATTR_H_

// ----------------------------------------------------------------------------
// wxItemAttr: a structure containing the visual attributes of an item
// ----------------------------------------------------------------------------

class wxItemAttr
{
public:
    // ctors
    wxItemAttr() { }
    wxItemAttr(const wxColour& colText,
               const wxColour& colBack,
               const wxFont& font)
        : m_colText(colText), m_colBack(colBack), m_font(font)
    {
    }

    // default copy ctor, assignment operator and dtor are ok

    bool operator==(const wxItemAttr& other) const
    {
        return m_colText == other.m_colText &&
               m_colBack == other.m_colBack &&
               m_font == other.m_font;
    }

    bool operator!=(const wxItemAttr& other) const
    {
        return !(*this == other);
    }

    // setters
    void SetTextColour(const wxColour& colText) { m_colText = colText; }
    void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
    void SetFont(const wxFont& font) { m_font = font; }

    // accessors
    bool HasTextColour() const { return m_colText.IsOk(); }
    bool HasBackgroundColour() const { return m_colBack.IsOk(); }
    bool HasFont() const { return m_font.IsOk(); }

    bool HasColours() const { return HasTextColour() || HasBackgroundColour(); }
    bool IsDefault() const { return !HasColours() && !HasFont(); }

    const wxColour& GetTextColour() const { return m_colText; }
    const wxColour& GetBackgroundColour() const { return m_colBack; }
    const wxFont& GetFont() const { return m_font; }


    // this is almost like assignment operator except it doesn't overwrite the
    // fields unset in the source attribute
    void AssignFrom(const wxItemAttr& source)
    {
        if ( source.HasTextColour() )
            SetTextColour(source.GetTextColour());
        if ( source.HasBackgroundColour() )
            SetBackgroundColour(source.GetBackgroundColour());
        if ( source.HasFont() )
            SetFont(source.GetFont());
    }

private:
    wxColour m_colText,
             m_colBack;
    wxFont   m_font;
};

#endif // _WX_ITEMATTR_H_