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 this constant with the largest color constant excluding 17 // B_SUCCESS_COLOR and B_FAILURE_COLOR. 18 // If you add a constant with index greater than 100 you'll have to add 19 // to the second operand. 20 static const int32 kColorWhichCount = B_SCROLL_BAR_THUMB_COLOR + 3; 21 22 23 struct server_read_only_memory { 24 rgb_color colors[kColorWhichCount]; 25 }; 26 27 28 static inline int32 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 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