xref: /haiku/headers/private/app/ServerReadOnlyMemory.h (revision 586734d609d50f647376541dc5de052110c01bd6)
1 /*
2  * Copyright 2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Axel Dörfler, axeld@pinc-software.de
7  */
8 #ifndef SERVER_READ_ONLY_MEMORY_H
9 #define SERVER_READ_ONLY_MEMORY_H
10 
11 
12 #include <GraphicsDefs.h>
13 #include <InterfaceDefs.h>
14 
15 
16 // Update kColorWhichLastContinuous with the largest color constant which
17 // leaves no gaps in the color_which integer values.
18 static const int32 kColorWhichLastContinuous = B_STATUS_BAR_COLOR;
19 static const int32 kColorWhichCount = kColorWhichLastContinuous + 3;
20 	// + 1 for index-offset, + 2 for B_SUCCESS_COLOR, B_FAILURE_COLOR
21 
22 
23 struct server_read_only_memory {
24 	rgb_color	colors[kColorWhichCount];
25 };
26 
27 
28 static inline int32
color_which_to_index(color_which which)29 color_which_to_index(color_which which)
30 {
31 	if (which <= kColorWhichCount - 3)
32 		return which - 1;
33 	if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR)
34 		return which - B_SUCCESS_COLOR + kColorWhichCount - 3;
35 
36 	return -1;
37 }
38 
39 
40 static inline color_which
index_to_color_which(int32 index)41 index_to_color_which(int32 index)
42 {
43 	if (index >= 0 && index < kColorWhichCount) {
44 		if ((color_which)index < kColorWhichCount - 3)
45 			return (color_which)(index + 1);
46 		else {
47 			return (color_which)(index + B_SUCCESS_COLOR
48 				- kColorWhichCount + 3);
49 		}
50 	}
51 
52 	return (color_which)-1;
53 }
54 
55 #endif	/* SERVER_READ_ONLY_MEMORY_H */
56