colors.h 2.47 KB
Newer Older
1 2 3
/************/
/* colors.h */
/************/
plyatov's avatar
plyatov committed
4 5 6 7

#ifndef _COLORS_H
#define _COLORS_H

8 9
#include <wx/wx.h>

10
/* Number of colors ( 32 bit palette. ) */
charras's avatar
charras committed
11
#define NBCOLOR             24
dickelbeck's avatar
dickelbeck committed
12

13
#define MASKCOLOR           31       ///< mask for color index into ColorRefs[]
dickelbeck's avatar
dickelbeck committed
14

15 16
/// Flag bit display (seen / not seen) items: (defined in the color values
//IMB: Not used anymore   #define ITEM_NOT_SHOW       (1<<18)      // 0x40000
dickelbeck's avatar
dickelbeck committed
17

18
#define HIGHLIGHT_FLAG      ( 1<<19 )         // 0x80000
dickelbeck's avatar
dickelbeck committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41


/**
 * Function SetAlpha
 * ORs in the alpha blend parameter in to a color index.
 */
static inline void SetAlpha( int* aColor, int aBlend )
{
    const int MASKALPHA = 0xFF;

    *aColor = (*aColor & ~(MASKALPHA << 24)) | ((aBlend & MASKALPHA) << 24);
}


/**
 * Function GetAlpha
 * returns the alpha blend parameter from a color index.
 */
static inline int GetAlpha( int aColor )
{
    const int MASKALPHA = 0xFF;
    return (aColor >> 24) & MASKALPHA;
}
42

plyatov's avatar
plyatov committed
43

44
enum EDA_COLOR_T
plyatov's avatar
plyatov committed
45
{
46
    UNSPECIFIED = -1,
dickelbeck's avatar
dickelbeck committed
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
    BLACK = 0,
    BLUE,
    GREEN,
    CYAN,
    RED,
    MAGENTA,
    BROWN,
    LIGHTGRAY,
    DARKGRAY,
    LIGHTBLUE,
    LIGHTGREEN,
    LIGHTCYAN,
    LIGHTRED,
    LIGHTMAGENTA,
    YELLOW,
    WHITE,
    DARKDARKGRAY,
    DARKBLUE,
    DARKGREEN,
    DARKCYAN,
    DARKRED,
    DARKMAGENTA,
    DARKBROWN,
    LIGHTYELLOW,
    LASTCOLOR
plyatov's avatar
plyatov committed
72 73
};

dickelbeck's avatar
dickelbeck committed
74 75

struct StructColors
plyatov's avatar
plyatov committed
76
{
dickelbeck's avatar
dickelbeck committed
77 78 79 80 81 82 83
    unsigned char   m_Blue;
    unsigned char   m_Green;
    unsigned char   m_Red;
    unsigned char   m_Numcolor;

    const wxChar*   m_Name;
    int             m_LightColor;
plyatov's avatar
plyatov committed
84 85
};

86
// list of existing Colors:
plyatov's avatar
plyatov committed
87 88
extern StructColors ColorRefs[NBCOLOR];

dickelbeck's avatar
dickelbeck committed
89 90
/**
 * Function MakeColour
91
 * returns a wxWidgets wxColor from a KiCad color index with alpha value.
dickelbeck's avatar
dickelbeck committed
92 93 94 95
 * Note that alpha support is not available on every wxWidgets platform.  On
 * such platform the behavior is the same as for wxALPHA_OPAQUE and that
 * means the alpha value has no effect and will be ignored.  wxGtk 2.8.4 is
 * not supporting alpha.
96
 * @return wxColour - given a KiCad color index with alpha value
dickelbeck's avatar
dickelbeck committed
97 98 99
 */
static inline wxColour MakeColour( int aColor )
{
100
#if wxCHECK_VERSION(2,8,5)
dickelbeck's avatar
dickelbeck committed
101 102
    int alpha = GetAlpha( aColor );
    alpha = alpha ? alpha : wxALPHA_OPAQUE;
103
#endif
dickelbeck's avatar
dickelbeck committed
104 105
    int ndx = aColor & MASKCOLOR;

106 107 108
    return wxColour( ColorRefs[ndx].m_Red,
                     ColorRefs[ndx].m_Green,
                     ColorRefs[ndx].m_Blue
109
#if wxCHECK_VERSION(2,8,5)
110
                     ,(unsigned char) alpha
111
#endif
112
        );
dickelbeck's avatar
dickelbeck committed
113 114
}

dickelbeck's avatar
dickelbeck committed
115 116 117
int DisplayColorFrame( wxWindow* parent, int OldColor );


plyatov's avatar
plyatov committed
118
#endif /* ifndef _COLORS_H */