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 = 34; 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_LIST_SELECTED_ITEM_TEXT_COLOR) 30 return which - 1; 31 if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) 32 return which - B_SUCCESS_COLOR + B_LIST_SELECTED_ITEM_TEXT_COLOR; 33 34 return -1; 35 } 36 37 38 static inline color_which 39 index_to_color_which(int32 index) 40 { 41 if (index >= 0 && index < kNumColors) { 42 if ((color_which)index < B_LIST_SELECTED_ITEM_TEXT_COLOR) 43 return (color_which)(index + 1); 44 else { 45 return (color_which)(index + B_SUCCESS_COLOR 46 - B_LIST_SELECTED_ITEM_TEXT_COLOR); 47 } 48 } 49 50 return (color_which)-1; 51 } 52 53 #endif /* SERVER_READ_ONLY_MEMORY_H */ 54