1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: MenuPalettes.h 3 // Purpose: The class to create and store menu palettes 4 // Author: Alex Thuering 5 // Created: 04.11.2006 6 // RCS-ID: $Id: MenuPalettes.h,v 1.5 2014/02/25 11:08:27 ntalex Exp $ 7 // Copyright: (c) Alex Thuering 8 // Licence: GPL 9 ///////////////////////////////////////////////////////////////////////////// 10 11 #ifndef MENU_PALETTES_H 12 #define MENU_PALETTES_H 13 14 #include "Menu.h" 15 #include <wx/palette.h> 16 #include <wx/hashmap.h> 17 #include <wx/hashset.h> 18 19 WX_DECLARE_HASH_SET(int, wxIntegerHash, wxIntegerEqual, IntHashSet); 20 21 class Palette: public wxPalette { 22 private: 23 int coloursCount; 24 bool m_hasTranspColour; 25 26 public: Palette()27 Palette() { coloursCount = 0; m_hasTranspColour = false; } ~Palette()28 virtual ~Palette() {} 29 bool Create(IntHashSet& colours); 30 bool Apply(const unsigned char* pixel, unsigned char *dest, unsigned char *destAlpha) const; 31 }; 32 33 WX_DECLARE_HASH_MAP(int, Palette, wxIntegerHash, wxIntegerEqual, PaletteMap); 34 WX_DECLARE_HASH_MAP(int, PaletteMap, wxIntegerHash, wxIntegerEqual, Palette2DMap); 35 36 class MenuPalettes { 37 private: 38 Palette m_palette1; 39 PaletteMap m_palette2; 40 Palette2DMap m_palette3; 41 bool m_drawButtonsOnBackground; 42 int GetKey(const unsigned char* pixel, unsigned char alpha); 43 44 public: 45 /** Constructor. Creates palettes */ 46 MenuPalettes(MenuObject& obj, bool drawButtonsOnBackground); 47 48 /** Returns rgb value for first image (buttons normal) */ 49 bool Apply(const unsigned char* pixel1, unsigned char *dest, unsigned char *destAlpha); 50 /** Returns rgb value for second image (buttons highlighted) */ 51 bool Apply(const unsigned char* pixel1, unsigned char pixel1Alpha, const unsigned char* pixel2, 52 unsigned char *dest, unsigned char *destAlpha); 53 /** Returns rgb value for third image (buttons selected) */ 54 bool Apply(const unsigned char* pixel1, unsigned char pixel1Alpha, const unsigned char* pixel2, 55 unsigned char pixel2Alpha, const unsigned char* pixel3, unsigned char *dest, unsigned char *destAlpha); 56 }; 57 58 #endif // MENU_PALETTES_H 59