libkdegames
KCardCache Class Reference
#include <KCardCache>
Detailed Description
This class implements a kdegames wide cache for cards.Card games such as lskat or kpat should use this cache to load the various decks into QPixmaps instead of inventing their own. It uses KPixmapCache behind the scenes, set up to use disk and memory caching. Thus a SVG card deck that was loaded by kpat for the size 100x200 doesn't need re-rendering when requested from lskat.
Usage is quite simple. During initialization of the game the cache object should be created and it should be told to load the currently selected theme. myCache = new KCardCache(); myCache->loadTheme( myTheme );
Later when actually drawing the cards the getter methods can be used to get the pixmap of a specific card at a specific size from a given theme. myCache->getCard( myTheme, KCardCache::Club, KCardCache::Ace, calculatedSize );
Definition at line 83 of file cardcache.h.
Public Types | |
| enum | LoadInfo { LoadFrontSide = 1 << 0, LoadBackSide = 1 << 2, Load52Cards = 1 << 3, Load32Cards = 1 << 4, Load53Cards = 1 << 5 } |
Public Member Functions | |
| QPixmap | backside (int variant=-1) const |
| QString | backTheme () const |
| QSizeF | defaultBackSize (int variant=-1) const |
| QSizeF | defaultFrontSize (const KCardInfo &info) const |
| QPixmap | frontside (const KCardInfo &info) const |
| QString | frontTheme () const |
| void | invalidateBackside () |
| void | invalidateFrontside () |
| KCardCache () | |
| void | loadTheme (LoadInfos infos=LoadInfos(LoadFrontSide|LoadBackSide|Load53Cards)) |
| void | setBackTheme (const QString &theme) |
| void | setFrontTheme (const QString &theme) |
| void | setSize (const QSize &size) |
| QSize | size () const |
| ~KCardCache () | |
Member Enumeration Documentation
| enum KCardCache::LoadInfo |
Can be used to load only parts of a theme, in case the user chose to have front and backside from different themes.
Definition at line 92 of file cardcache.h.
Constructor & Destructor Documentation
| KCardCache::KCardCache | ( | ) |
Constructor creates and initializes a KPixmapCache for all KDE Games card games.
Definition at line 379 of file cardcache.cpp.
| KCardCache::~KCardCache | ( | ) |
Member Function Documentation
| QPixmap KCardCache::backside | ( | int | variant = -1 |
) | const |
Retrieve the backside of the given theme theme at the specified size size.
Make sure to set a reasonable size and theme, before calling this function.
- Parameters:
-
variant which variant, like a back with another color, to use for rendering. Defaults to -1 which means no variant.
- Returns:
- a QPixmap with the card backside rendered
- See also:
- setBackTheme
Definition at line 413 of file cardcache.cpp.
| QString KCardCache::backTheme | ( | ) | const |
Return the currently used backside theme.
- Returns:
- the name of the backside theme
Definition at line 574 of file cardcache.cpp.
| QSizeF KCardCache::defaultBackSize | ( | int | variant = -1 |
) | const |
Retrieve the default size for the backside card.
Make sure to set a reasonable theme, before calling this function.
- Parameters:
-
variant which variant, like a back with another color, to use. Defaults to -1 which means no variant.
- Returns:
- the default size of the selected background variant
Definition at line 613 of file cardcache.cpp.
Retrieve the default size for the frontside card.
Make sure to set a reasonable theme, before calling this function.
- Parameters:
-
infos A combination of CardInfo flags to identify what type of card to load. There are of course only certain combinations that make sense, like King | Heart, some flags are used standalone, like Joker.
- Returns:
- the default size of the selected frontside card
Definition at line 594 of file cardcache.cpp.
Retrieve the frontside pixmap.
The infos paramter is used to determine which frontside to load. Make sure to set a reasonable size and theme, before calling this function.
- Parameters:
-
infos A combination of CardInfo flags to identify what type of card to load. There are of course only certain combinations that make sense, like King | Heart, some flags are used standalone, like Joker.
- Returns:
- a QPixmap with the card frontside rendered
- See also:
- setBackTheme
CardInfo
Definition at line 453 of file cardcache.cpp.
| QString KCardCache::frontTheme | ( | ) | const |
Return the currently used frontside theme.
- Returns:
- the name of the frontside theme
Definition at line 539 of file cardcache.cpp.
| void KCardCache::invalidateBackside | ( | ) |
Invalidates all cached images in the current size for the current backside theme.
Definition at line 646 of file cardcache.cpp.
| void KCardCache::invalidateFrontside | ( | ) |
Invalidates all cached images in the current size for the current frontside theme.
Definition at line 639 of file cardcache.cpp.
| void KCardCache::loadTheme | ( | LoadInfos | infos = LoadInfos( LoadFrontSide | LoadBackSide | Load53Cards ) |
) |
Loads a whole theme in the background.
Depending on the value of type only parts may be rendered.
- Parameters:
-
infos wether to load all entries in the theme or just the front or back sides. Also its possible to specify a different deck, like a 32 card deck.
Definition at line 579 of file cardcache.cpp.
| void KCardCache::setBackTheme | ( | const QString & | theme | ) |
Set the theme to be used to render the backside of cards.
Make sure to set a proper theme before fetching frontside pixmaps from the cache.
- Parameters:
-
theme the name of the theme to be use for rendering backsides
Definition at line 544 of file cardcache.cpp.
| void KCardCache::setFrontTheme | ( | const QString & | theme | ) |
Set the theme to be used to render the frontside of cards.
Make sure to set a proper theme before fetching frontside pixmaps from the cache.
- Parameters:
-
theme the name of the theme to be use for rendering frontsides
Definition at line 502 of file cardcache.cpp.
| void KCardCache::setSize | ( | const QSize & | size | ) |
Set the size of rendered pixmaps.
Make sure to set a reasonable size, before fetching pixmaps from the cache.
- Parameters:
-
size the new size for rendering cards and backsides
Definition at line 491 of file cardcache.cpp.
| QSize KCardCache::size | ( | ) | const |
Returns the currently used size to render cards and backsides.
- Returns:
- the size of pixmaps for rendering.
Definition at line 497 of file cardcache.cpp.
The documentation for this class was generated from the following files:
KDE 4.1 API Reference