SOL9 2.0 Class: ColorTable

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * ColorTable.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
#pragma once

#include <sol\HashTable.h>

#include <sol\ColorItem.h>

namespace SOL {

class ColorTable :public HashTable {

public:
    static const long Black        =RGB(   0,    0,    0);
    static const long Blue      =RGB(   0,    0, 0xff);
    static const long Brown        =RGB(0x80, 0x80,    0);
    static const long Cyan        =RGB(   0, 0xff, 0xff);
    static const long DarkBlue    =RGB(   0,    0, 0x80);
    static const long DarkCyan    =RGB(   0, 0x80, 0x80);
    static const long DarkGray    =RGB(0x80, 0x80, 0x80);
    static const long DarkGreen =RGB(   0, 0x80,    0);
    static const long DarkMagenta=RGB(0x80,    0, 0x80);
    static const long DarkRed   =RGB(0x80,    0,    0);
    static const long Gray        =RGB(0xc0, 0xc0, 0xc0);
    static const long Green        =RGB(   0, 0xff,    0);
    static const long LightBlue    =RGB(   0,    0, 0xff);
    static const long LightCyan    =RGB(   0, 0xff, 0xff);
    static const long LightGray    =RGB(0xc0, 0xc0, 0xc0);
    static const long LightGreen=RGB(   0, 0xff,    0);
    static const long LightMagenta=RGB(0xff,    0, 0xff);
    static const long LightRed    =RGB(0xff,    0,    0);
    static const long Magenta    =RGB(0xff,    0, 0xff);
    static const long Red        =RGB(0xff,    0,    0);
    static const long White        =RGB(0xff, 0xff, 0xff);
    static const long Yellow    =RGB(0xff, 0xff,    0);


public:
    ColorTable()
    :HashTable(113)
    {
        initialize();
    }

private:
    void initialize()
    {
    static ColorItem rgbTable[] = { 
        {_T("Black"),    Black},
        {_T("Blue"),    Blue},
        {_T("Brown"),    Brown},
        {_T("Cyan"),    Cyan},
        {_T("DarkBlue"),    DarkBlue},
        {_T("DarkCyan"),       DarkCyan},
        {_T("DarkGray"),      DarkGray},
        {_T("DarkGreen"),     DarkGreen},
        {_T("DarkMagenta"),    DarkMagenta},
        {_T("DarkRed"),    DarkRed},
        {_T("Gray"),    Gray},
        {_T("Green"),    Green},
        {_T("LightBlue"),    LightBlue},
        {_T("LightCyan"),    LightCyan},
        {_T("LightGray"),    LightGray},
        {_T("LightGreen"),    LightGreen},
        {_T("LightMagenta"), LightMagenta},
        {_T("LightRed"),    LightRed},
        {_T("Magenta"),    Magenta},
        {_T("Red"),        Red},
        {_T("White"),    White},
        {_T("Yellow"),    Yellow},
        };

        for(int i = 0; i<XtNumber(rgbTable); i++) {
            add(rgbTable[i].name, (Object*)&rgbTable[i]);
        }

    }

public:
    BOOL get(const TCHAR* colorName, long* value)
    {
        ColorItem* colorItem  = (ColorItem*) lookup(colorName);
        if(colorItem) {
            *value = colorItem->value;
            return TRUE;
        }
        else return FALSE;
    }


};

}



Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.