1/* 2 * Copyright 2001-2009, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * DarkWyrm <bpmagic@columbus.rr.com> 7 * Stephan Aßmus <superstippi@gmx.de> 8 * Rene Gollent <rene@gollent.com> 9 */ 10 11#include <stdio.h> 12#include <Catalog.h> 13#include <DefaultColors.h> 14#include <Directory.h> 15#include <Entry.h> 16#include <File.h> 17#include <InterfaceDefs.h> 18#include <Locale.h> 19#include <Message.h> 20#include <ServerReadOnlyMemory.h> 21#include <String.h> 22#include "ColorSet.h" 23 24#undef B_TRANSLATION_CONTEXT 25#define B_TRANSLATION_CONTEXT "Colors tab" 26 27static ColorDescription sColorDescriptionTable[] = 28{ 29 { B_PANEL_BACKGROUND_COLOR, B_TRANSLATE_MARK("Panel background") }, 30 { B_PANEL_TEXT_COLOR, B_TRANSLATE_MARK("Panel text") }, 31 { B_DOCUMENT_BACKGROUND_COLOR, B_TRANSLATE_MARK("Document background") }, 32 { B_DOCUMENT_TEXT_COLOR, B_TRANSLATE_MARK("Document text") }, 33 { B_CONTROL_BACKGROUND_COLOR, B_TRANSLATE_MARK("Control background") }, 34 { B_CONTROL_TEXT_COLOR, B_TRANSLATE_MARK("Control text") }, 35 { B_CONTROL_BORDER_COLOR, B_TRANSLATE_MARK("Control border") }, 36 { B_CONTROL_HIGHLIGHT_COLOR, B_TRANSLATE_MARK("Control highlight") }, 37 { B_CONTROL_MARK_COLOR, B_TRANSLATE_MARK("Control mark") }, 38 { B_NAVIGATION_BASE_COLOR, B_TRANSLATE_MARK("Navigation base") }, 39 { B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") }, 40 { B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") }, 41 { B_SHADOW_COLOR, B_TRANSLATE_MARK("Shadow") }, 42 { B_MENU_BACKGROUND_COLOR, B_TRANSLATE_MARK("Menu background") }, 43 { B_MENU_SELECTED_BACKGROUND_COLOR, 44 B_TRANSLATE_MARK("Selected menu item background") }, 45 { B_MENU_ITEM_TEXT_COLOR, B_TRANSLATE_MARK("Menu item text") }, 46 { B_MENU_SELECTED_ITEM_TEXT_COLOR, 47 B_TRANSLATE_MARK("Selected menu item text") }, 48 { B_MENU_SELECTED_BORDER_COLOR, 49 B_TRANSLATE_MARK("Selected menu item border") }, 50 { B_LIST_BACKGROUND_COLOR, B_TRANSLATE_MARK("List background") }, 51 { B_LIST_SELECTED_BACKGROUND_COLOR, 52 B_TRANSLATE_MARK("Selected list item background") }, 53 { B_LIST_ITEM_TEXT_COLOR, B_TRANSLATE_MARK("List item text") }, 54 { B_LIST_SELECTED_ITEM_TEXT_COLOR, 55 B_TRANSLATE_MARK("Selected list item text") }, 56 { B_TOOL_TIP_BACKGROUND_COLOR, B_TRANSLATE_MARK("Tooltip background") }, 57 { B_TOOL_TIP_TEXT_COLOR, B_TRANSLATE_MARK("Tooltip text") }, 58 { B_SUCCESS_COLOR, B_TRANSLATE_MARK("Success") }, 59 { B_FAILURE_COLOR, B_TRANSLATE_MARK("Failure") }, 60 { B_WINDOW_TAB_COLOR, B_TRANSLATE_MARK("Window tab") }, 61 { B_WINDOW_TEXT_COLOR, B_TRANSLATE_MARK("Window tab text") }, 62 { B_WINDOW_INACTIVE_TAB_COLOR, B_TRANSLATE_MARK("Inactive window tab") }, 63 { B_WINDOW_INACTIVE_TEXT_COLOR, 64 B_TRANSLATE_MARK("Inactive window tab text") }, 65 { B_WINDOW_BORDER_COLOR, B_TRANSLATE_MARK("Window border") }, 66 { B_WINDOW_INACTIVE_BORDER_COLOR, 67 B_TRANSLATE_MARK("Inactive window border") } 68}; 69 70const int32 sColorDescriptionCount = sizeof(sColorDescriptionTable) 71 / sizeof(ColorDescription); 72 73const ColorDescription* 74get_color_description(int32 index) 75{ 76 if (index < 0 || index >= sColorDescriptionCount) 77 return NULL; 78 return &sColorDescriptionTable[index]; 79} 80 81int32 82color_description_count(void) 83{ 84 return sColorDescriptionCount; 85} 86 87// #pragma mark - 88 89 90ColorSet::ColorSet() 91{ 92} 93 94/*! 95 \brief Copy constructor which does a massive number of assignments 96 \param cs Color set to copy from 97*/ 98ColorSet::ColorSet(const ColorSet &cs) 99{ 100 *this = cs; 101} 102 103/*! 104 \brief Overloaded assignment operator which does a massive number of assignments 105 \param cs Color set to copy from 106 \return The new values assigned to the color set 107*/ 108ColorSet & 109ColorSet::operator=(const ColorSet &cs) 110{ 111 fColors = cs.fColors; 112 return *this; 113} 114 115 116/*! 117 \brief Assigns the default system colors to the passed ColorSet object 118 \param set The ColorSet object to set to defaults 119*/ 120ColorSet 121ColorSet::DefaultColorSet(void) 122{ 123 ColorSet set; 124 125 for (int i = 0; i < sColorDescriptionCount; i++) { 126 color_which which = get_color_description(i)->which; 127 set.fColors[which] = 128 BPrivate::kDefaultColors[color_which_to_index(which)]; 129 } 130 return set; 131} 132 133 134/*! 135 \brief Assigns a value to a named color member 136 \param string name of the color to receive the value 137 \param value An rgb_color which is the new value of the member 138*/ 139void 140ColorSet::SetColor(color_which which, rgb_color value) 141{ 142 fColors[which] = value; 143} 144 145 146rgb_color 147ColorSet::GetColor(int32 which) 148{ 149 return fColors[(color_which)which]; 150} 151 152 153