xref: /haiku/headers/private/app/ServerReadOnlyMemory.h (revision 4466b89c65970de4c7236ac87faa2bee4589f413)
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 static const int32 kNumColors = 32;
17 
18 struct server_read_only_memory {
19 	rgb_color	colors[kNumColors];
20 };
21 
22 
23 // NOTE: these functions must be kept in sync with InterfaceDefs.h color_which!
24 
25 static inline int32
26 color_which_to_index(color_which which)
27 {
28 	// NOTE: this must be kept in sync with InterfaceDefs.h color_which!
29 	if (which <= B_WINDOW_INACTIVE_TEXT_COLOR)
30 		return which - 1;
31 	if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR)
32 		return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_TEXT_COLOR;
33 
34 	return -1;
35 }
36 
37 static inline color_which
38 index_to_color_which(int32 index)
39 {
40 	if (index >= 0 && index < kNumColors) {
41 		if ((color_which)index < B_WINDOW_INACTIVE_TEXT_COLOR)
42 			return (color_which)(index + 1);
43 		else
44 			return (color_which)(index + B_SUCCESS_COLOR - B_WINDOW_INACTIVE_TEXT_COLOR);
45 	}
46 
47 	return (color_which)-1;
48 }
49 
50 #endif	/* SERVER_READ_ONLY_MEMORY_H */
51