/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "Be.h"


// ui_color
_IMPEXP_BE rgb_color ui_color (color_which which)
{
	rgb_color color;

	color.red = 0;
	color.green = 0;
	color.blue = 0;
	color.alpha = 255;

	switch (which) {

		case B_PANEL_BACKGROUND_COLOR:
			color.red = 216;
			color.green = 216;
			color.blue = 216;
			break;

		case B_MENU_BACKGROUND_COLOR:
			color.red = 216;
			color.green = 216;
			color.blue = 216;
			break;

		case B_MENU_SELECTION_BACKGROUND_COLOR:
			color.red = 0;
			color.green = 0;
			color.blue = 0;
			break;

		case B_MENU_ITEM_TEXT_COLOR:
			color.red = 0;
			color.green = 0;
			color.blue = 0;
			break;

		case B_MENU_SELECTED_ITEM_TEXT_COLOR:
			color.red = 0;
			color.green = 0;
			color.blue = 0;
			break;

		case B_WINDOW_TAB_COLOR:
			color.red = 0;
			color.green = 0;
			color.blue = 0;
			break;

		case B_KEYBOARD_NAVIGATION_COLOR:
			color.red = 0;
			color.green = 0;
			color.blue = 0;
			break;

		case B_DESKTOP_COLOR:
			color.red = 0;
			color.green = 0;
			color.blue = 0;
			break;

	}

	return color;
}


// tint_color
_IMPEXP_BE rgb_color tint_color (rgb_color color, float tint)
{
	rgb_color newColor;
	newColor.alpha = color.alpha;

	if (tint == B_LIGHTEN_MAX_TINT) {
		newColor.red = 255;
		newColor.green = 255;
		newColor.blue = 255;
	} else if (tint == B_LIGHTEN_2_TINT) {
		newColor.red = std::min (static_cast<uint8>(255), static_cast<uint8>(156 + color.red * tint));
		newColor.green = std::min (static_cast<uint8>(255), static_cast<uint8>(156 + color.green * tint));
		newColor.blue = std::min (static_cast<uint8>(255), static_cast<uint8>(156 + color.blue * tint));
	} else if (tint == B_LIGHTEN_1_TINT) {
		newColor.red = std::min (static_cast<uint8>(255), static_cast<uint8>(104 + color.red * tint));
		newColor.green = std::min (static_cast<uint8>(255), static_cast<uint8>(104 + color.green * tint));
		newColor.blue = std::min (static_cast<uint8>(255), static_cast<uint8>(104 + color.blue * tint));
	} else if (tint == B_DARKEN_1_TINT) {
		newColor.red = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.red) / 1.1726)));
		newColor.green = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.green) / 1.1726)));
		newColor.blue = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.blue) / 1.1726)));
	} else if (tint == B_DARKEN_2_TINT) {
		newColor.red = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.red) / 1.4183)));
		newColor.green = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.green) / 1.4183)));
		newColor.blue = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.blue) / 1.4183)));
	} else if (tint == B_DARKEN_3_TINT) {
		newColor.red = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.red) / 1.6862)));
		newColor.green = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.green) / 1.6862)));
		newColor.blue = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.blue) / 1.6862)));
	} else if (tint == B_DARKEN_4_TINT) {
		newColor.red = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.red) / 2.2476)));
		newColor.green = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.green) / 2.2476)));
		newColor.blue = std::min (static_cast<uint8>(255), static_cast<uint8>((static_cast<float>(color.blue) / 2.2476)));
	} else if (tint == B_DARKEN_MAX_TINT) {
		newColor.red = 0;
		newColor.green = 0;
		newColor.blue = 0;
	} else {
		newColor.red = color.red;
		newColor.blue = color.blue;
		newColor.green = color.green;
	}

	return newColor;
}
