summaryrefslogtreecommitdiffstats
path: root/knights/knightspixcache.h
blob: ef7cd78ed25d4d4bfafd2a3085f6f6db697cb91d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************
                          knightspixcache.h  -  description
                             -------------------
    begin                : Mon Aug 20 2001
    copyright            : (C) 2003 by Troy Corbin Jr.
    email                : tcorbin@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KNIGHTSPIXCACHE_H
#define KNIGHTSPIXCACHE_H

#include <tqvaluelist.h>
#include <tqpixmap.h>
#include <tqimage.h>

/**
  *@author Troy Corbin Jr.
  */

struct cacheItem
{
	TQString				label;
	TQPixmap				item;
	unsigned int	bytes;
	unsigned int	age;
};

typedef TQValueList<cacheItem> pixmapList;

class KnightsPixCache
{
		public:
		TQPixmap								SquareLight;
		TQPixmap								SquareDark;
		TQPixmap								HighlightSelect;
		TQPixmap								HighlightMove;
		TQPixmap								HighlightAttack;
		TQPixmap								BlackKing;
		TQPixmap								BlackQueen;
		TQPixmap								BlackBishop;
		TQPixmap								BlackKnight;
		TQPixmap								BlackRook;
		TQPixmap								BlackPawn;
		TQPixmap								WhiteKing;
		TQPixmap								WhiteQueen;
		TQPixmap								WhiteBishop;
		TQPixmap								WhiteKnight;
		TQPixmap								WhiteRook;
		TQPixmap								WhitePawn;
		TQPixmap								Border;
		TQPixmap								BorderLightOn;
		TQPixmap								BorderLightOff;

		TQImage								Orig_SquareLight;
		TQImage								Orig_SquareDark;
		TQImage								Orig_HighlightSelect;
		TQImage								Orig_HighlightMove;
		TQImage								Orig_HighlightAttack;
		TQImage								Orig_BlackKing;
		TQImage								Orig_BlackQueen;
		TQImage								Orig_BlackBishop;
		TQImage								Orig_BlackKnight;
		TQImage								Orig_BlackRook;
		TQImage								Orig_BlackPawn;
		TQImage								Orig_WhiteKing;
		TQImage								Orig_WhiteQueen;
		TQImage								Orig_WhiteBishop;
		TQImage								Orig_WhiteKnight;
		TQImage								Orig_WhiteRook;
		TQImage								Orig_WhitePawn;
		TQImage								Orig_Border;
		TQImage								Orig_BorderLightOn;
		TQImage								Orig_BorderLightOff;

													KnightsPixCache();
													~KnightsPixCache();
		void									clear( void );
		void									setCacheLimit( const unsigned int &limit );
		unsigned int					cacheLimit( void );
		void									add( const TQString &label, const TQPixmap &pixmap );
		bool									find( const TQString &label, TQPixmap &pixmap);
		void									resize( const int &size );
		
		private:
		
		pixmapList						list;
		pixmapList::Iterator	IT;
		
		unsigned int					bytesUsed;
		unsigned int					bytesTotal;
		
		void									cleanCache( const unsigned int &space );
};

#endif