xref: /haiku/src/preferences/appearance/Colors.cpp (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 /*
2  * Copyright 2001-2015, 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  *		Joseph Groover <looncraz@looncraz.net>
10  */
11 
12 
13 #include <stdio.h>
14 #include <Catalog.h>
15 #include <DefaultColors.h>
16 #include <Directory.h>
17 #include <Entry.h>
18 #include <File.h>
19 #include <InterfaceDefs.h>
20 #include <Locale.h>
21 #include <Message.h>
22 #include <ServerReadOnlyMemory.h>
23 #include <String.h>
24 #include "Colors.h"
25 
26 
27 #undef B_TRANSLATION_CONTEXT
28 #define B_TRANSLATION_CONTEXT "Colors tab"
29 
30 
31 static ColorDescription sColorDescriptionTable[] = {
32 	{ B_PANEL_BACKGROUND_COLOR, B_TRANSLATE_MARK("Panel background") },
33 	{ B_PANEL_TEXT_COLOR, B_TRANSLATE_MARK("Panel text") },
34 	{ B_DOCUMENT_BACKGROUND_COLOR, B_TRANSLATE_MARK("Document background") },
35 	{ B_DOCUMENT_TEXT_COLOR, B_TRANSLATE_MARK("Document text") },
36 	{ B_CONTROL_BACKGROUND_COLOR, B_TRANSLATE_MARK("Control background") },
37 	{ B_CONTROL_TEXT_COLOR, B_TRANSLATE_MARK("Control text") },
38 	{ B_CONTROL_BORDER_COLOR, B_TRANSLATE_MARK("Control border") },
39 	{ B_CONTROL_HIGHLIGHT_COLOR, B_TRANSLATE_MARK("Control highlight") },
40 	{ B_CONTROL_MARK_COLOR, B_TRANSLATE_MARK("Control mark") },
41 	{ B_NAVIGATION_BASE_COLOR, B_TRANSLATE_MARK("Navigation base") },
42 	{ B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") },
43 	{ B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") },
44 	{ B_SHADOW_COLOR, B_TRANSLATE_MARK("Shadow") },
45 	{ B_LINK_TEXT_COLOR, B_TRANSLATE_MARK("Link text") },
46 	{ B_LINK_HOVER_COLOR, B_TRANSLATE_MARK("Link hover") },
47 	{ B_LINK_VISITED_COLOR, B_TRANSLATE_MARK("Link visited") },
48 	{ B_LINK_ACTIVE_COLOR, B_TRANSLATE_MARK("Link active") },
49 	{ B_MENU_BACKGROUND_COLOR, B_TRANSLATE_MARK("Menu background") },
50 	{ B_MENU_SELECTED_BACKGROUND_COLOR,
51 		B_TRANSLATE_MARK("Selected menu item background") },
52 	{ B_MENU_ITEM_TEXT_COLOR, B_TRANSLATE_MARK("Menu item text") },
53 	{ B_MENU_SELECTED_ITEM_TEXT_COLOR,
54 		B_TRANSLATE_MARK("Selected menu item text") },
55 	{ B_MENU_SELECTED_BORDER_COLOR,
56 		B_TRANSLATE_MARK("Selected menu item border") },
57 	{ B_LIST_BACKGROUND_COLOR, B_TRANSLATE_MARK("List background") },
58 	{ B_LIST_SELECTED_BACKGROUND_COLOR,
59 		B_TRANSLATE_MARK("Selected list item background") },
60 	{ B_LIST_ITEM_TEXT_COLOR, B_TRANSLATE_MARK("List item text") },
61 	{ B_LIST_SELECTED_ITEM_TEXT_COLOR,
62 		B_TRANSLATE_MARK("Selected list item text") },
63 	{ B_SCROLL_BAR_THUMB_COLOR,
64 		B_TRANSLATE_MARK("Scroll bar thumb") },
65 	{ B_TOOL_TIP_BACKGROUND_COLOR, B_TRANSLATE_MARK("Tooltip background") },
66 	{ B_TOOL_TIP_TEXT_COLOR, B_TRANSLATE_MARK("Tooltip text") },
67 	{ B_STATUS_BAR_COLOR, B_TRANSLATE_MARK("Status bar") },
68 	{ B_SUCCESS_COLOR, B_TRANSLATE_MARK("Success") },
69 	{ B_FAILURE_COLOR, B_TRANSLATE_MARK("Failure") },
70 	{ B_WINDOW_TAB_COLOR, B_TRANSLATE_MARK("Window tab") },
71 	{ B_WINDOW_TEXT_COLOR, B_TRANSLATE_MARK("Window tab text") },
72 	{ B_WINDOW_INACTIVE_TAB_COLOR, B_TRANSLATE_MARK("Inactive window tab") },
73 	{ B_WINDOW_INACTIVE_TEXT_COLOR,
74 		B_TRANSLATE_MARK("Inactive window tab text") },
75 	{ B_WINDOW_BORDER_COLOR, B_TRANSLATE_MARK("Window border") },
76 	{ B_WINDOW_INACTIVE_BORDER_COLOR,
77 		B_TRANSLATE_MARK("Inactive window border") }
78 };
79 
80 const int32 sColorDescriptionCount = sizeof(sColorDescriptionTable)
81 	/ sizeof(ColorDescription);
82 
83 
84 const ColorDescription*
85 get_color_description(int32 index)
86 {
87 	if (index < 0 || index >= sColorDescriptionCount)
88 		return NULL;
89 	return &sColorDescriptionTable[index];
90 }
91 
92 
93 int32
94 color_description_count(void)
95 {
96 	return sColorDescriptionCount;
97 }
98 
99 
100 void
101 get_default_colors(BMessage* message)
102 {
103 	if (message == NULL)
104 		return;
105 
106 	for (int32 index = 0; index < kColorWhichCount; ++index) {
107 		color_which which = index_to_color_which(index);
108 		message->AddColor(ui_color_name(which),
109 			BPrivate::kDefaultColors[index]);
110 	}
111 }
112 
113 
114 void
115 get_current_colors(BMessage* message)
116 {
117 	if (message == NULL)
118 		return;
119 
120 	for (int32 index = 0; index < kColorWhichCount; ++index) {
121 		color_which which = index_to_color_which(index);
122 		message->AddColor(ui_color_name(which), ui_color(which));
123 	}
124 }
125 
126