ThemeManager Class Reference

The graphics theme manager. More...

#include <thememanager.h>

List of all members.

Public Member Functions

 ThemeManager (QString cards, QString deck, QString themefile, QObject *parent, int initialSize=1)
 Constructor for the theme manager.
const QPixmap getCard (int suite, int cardtype, double width)
 Get the pixmap for a card.
const QPixmap getCardback (double width)
 Get a backside of the card.
const QPixmap getPixmap (QString svgid, QSize size)
 Load a pixmap from the SVG theme file.
const QPixmap getPixmap (QString svgid, double width)
 Load a pixmap from the SVG theme file.
const QPixmap getPixmap (QString svgid, QString svgref, double refwidth)
 Load a pixmap from the SVG theme file.
double getScale ()
 Retreive the current scale of the theme.
KConfigGroup config (QString id)
 Retrieve the current theme configuration object.
void registerTheme (Themable *ob)
 Register an object with the theme manager.
void unregisterTheme (Themable *ob)
 Unregister an object with the theme manager.
void updateTheme (Themable *ob)
 Forces an update to a theme objects.
void updateCardTheme (QString cards, QString deck)
 Forces an update to the card theme objects.
void updateTheme (QString themefile)
 Forces an update to all theme objects.
void rescale (int scale)
 Change the scale of the theme and update all registered theme objects.
double aspectRatio ()
 Retrieve the theme's apsect ratio.

Protected Member Functions

const QPixmap getPixmap (KSvgRenderer *renderer, QString svgid, QSize size)
 Load a pixmap from the SVG theme file.
void updateCardTheme (QString themefile, QString cards, QString deck)
 Forces an update to the card theme objects.
QString calcCardSVGId (int no)
 Retrive the SVGid for a card number.


Detailed Description

The graphics theme manager.

The theme manager holds a list of all Themable objects and notifies them in the event of a theme change so that the objects can then redraw. It also allows access to the theme configuration file and reads pixmaps from an SVG file given a certain size or scale. The pixmaps are cached so that the same pixmap is retrieved from the cache on not rendered again.

Definition at line 105 of file thememanager.h.


Constructor & Destructor Documentation

ThemeManager::ThemeManager QString  cards,
QString  deck,
QString  themefile,
QObject *  parent,
int  initialSize = 1
 

Constructor for the theme manager.

Parameters:
cards Directory of the cards
deck Filename of the deck PNG file
themefile The theme configuration file
parent The parent object
initialSize Initial theme size, can be arbitrary.

Definition at line 46 of file thememanager.cpp.

References updateCardTheme().

Here is the call graph for this function:


Member Function Documentation

double ThemeManager::aspectRatio  )  [inline]
 

Retrieve the theme's apsect ratio.

This is stored as 'aspect-ratio' key in the 'general' group of the theme.

Returns:
The aspect ratio (x/y).

Definition at line 213 of file thememanager.h.

Referenced by DisplayIntro::loop(), and GameView::resizeEvent().

QString ThemeManager::calcCardSVGId int  no  )  [protected]
 

Retrive the SVGid for a card number.

This effectively maps the 'old' PNG cards to the new SVG card ids. For example Ace of clubs is PNG card '1' or SVG id'1_club'

Parameters:
no The card number [1-52]

Definition at line 236 of file thememanager.cpp.

Referenced by getCard().

KConfigGroup ThemeManager::config QString  id  ) 
 

Retrieve the current theme configuration object.

Returns:
The configuration object.

Definition at line 228 of file thememanager.cpp.

Referenced by TextSprite::changeTheme(), ScoreSprite::changeTheme(), PixmapSprite::changeTheme(), DisplayTwo::changeTheme(), DisplayIntro::changeTheme(), CardSprite::changeTheme(), DisplayTwo::convertMousePress(), DisplayTwo::deal(), PixmapSprite::getDoubleValue(), DisplayIntro::loop(), DisplayTwo::play(), DisplayTwo::remove(), and updateTheme().

const QPixmap ThemeManager::getCard int  suite,
int  cardtype,
double  width
 

Get the pixmap for a card.

Parameters:
suite The suite of the card [Club, ...]
cardtype The type of the card [Ace, ...]
width The width of the card [pixels]
Returns:
The new pixmap.

Definition at line 258 of file thememanager.cpp.

References calcCardSVGId(), and getPixmap().

Referenced by CardSprite::calcFrame().

Here is the call graph for this function:

const QPixmap ThemeManager::getCardback double  width  ) 
 

Get a backside of the card.

Parameters:
width The width of the card back [pixels]
Returns:
The new pixmap.

Definition at line 308 of file thememanager.cpp.

References CARDBACK_SVGID, and getPixmap().

Referenced by CardSprite::calcFrame().

Here is the call graph for this function:

const QPixmap ThemeManager::getPixmap KSvgRenderer *  renderer,
QString  svgid,
QSize  size
[protected]
 

Load a pixmap from the SVG theme file.

Its filename is given in the "general" section of the theme file as "svgfile". The pixmap is scaled to the given size.

Parameters:
renderer The SVG renderer to use
svgid The ID of the SVG item to be rendered as pixmap
size The size of the resulting pixmap
Returns:
The new pixmap.

Definition at line 353 of file thememanager.cpp.

const QPixmap ThemeManager::getPixmap QString  svgid,
QString  svgref,
double  refwidth
 

Load a pixmap from the SVG theme file.

Its filename is given in the "general" section of the theme file as "svgfile". The pixmap is scaled with reference to another SVG item. This allows to generate a set of pixmaps with related sizes.

Parameters:
svgid The ID of the SVG item to be rendered as pixmap
svgref The ID of the SVG item used as width reference
refwidth The width of the resulting pixmap in relation to the reference item
Returns:
The new pixmap.

Definition at line 405 of file thememanager.cpp.

References getPixmap().

Here is the call graph for this function:

const QPixmap ThemeManager::getPixmap QString  svgid,
double  width
 

Load a pixmap from the SVG theme file.

Its filename is given in the "general" section of the theme file as "svgfile". The pixmap is scaled to the given width. The height is relative to the width as given in the SVG file.

Parameters:
svgid The ID of the SVG item to be rendered as pixmap
width The width of the resulting pixmap
Returns:
The new pixmap.

Definition at line 394 of file thememanager.cpp.

References getPixmap().

Here is the call graph for this function:

const QPixmap ThemeManager::getPixmap QString  svgid,
QSize  size
 

Load a pixmap from the SVG theme file.

Its filename is given in the "general" section of the theme file as "svgfile". The pixmap is scaled to the given size.

Parameters:
svgid The ID of the SVG item to be rendered as pixmap
size The size of the resulting pixmap
Returns:
The new pixmap.

Definition at line 387 of file thememanager.cpp.

Referenced by DisplayTwo::changeTheme(), DisplayIntro::changeTheme(), getCard(), getCardback(), and getPixmap().

double ThemeManager::getScale  ) 
 

Retreive the current scale of the theme.

Returns:
The scale.

Definition at line 221 of file thememanager.cpp.

Referenced by TextSprite::changeTheme(), PixmapSprite::changeTheme(), CardSprite::changeTheme(), and DisplayTwo::convertMousePress().

void ThemeManager::registerTheme Themable ob  ) 
 

Register an object with the theme manager.

Parameters:
ob The object to be registered.

Definition at line 64 of file thememanager.cpp.

Referenced by Themable::Themable().

void ThemeManager::rescale int  scale  ) 
 

Change the scale of the theme and update all registered theme objects.

If the scale did not change no action is performed!

Parameters:
scale The new scale (maximum extension)

Definition at line 199 of file thememanager.cpp.

References Themable::changeTheme(), and global_debug.

Referenced by GameView::GameView(), and GameView::resizeEvent().

Here is the call graph for this function:

void ThemeManager::unregisterTheme Themable ob  ) 
 

Unregister an object with the theme manager.

Parameters:
ob The object to be unregistered.

Definition at line 71 of file thememanager.cpp.

Referenced by Themable::~Themable().

void ThemeManager::updateCardTheme QString  themefile,
QString  cards,
QString  deck
[protected]
 

Forces an update to the card theme objects.

Parameters:
themefile The theme rc file
cards The card dir
deck The deck file

Definition at line 89 of file thememanager.cpp.

void ThemeManager::updateCardTheme QString  cards,
QString  deck
 

Forces an update to the card theme objects.

Parameters:
cards The card dir
deck The deck file

Definition at line 85 of file thememanager.cpp.

Referenced by ThemeManager().

void ThemeManager::updateTheme QString  themefile  ) 
 

Forces an update to all theme objects.

That is their changeTheme() method is called. Before this a (new) theme file is loaded and all cached pixmaps deleted. This is used to really change one theme over to another one.

Parameters:
themefile The theme file to load

Definition at line 158 of file thememanager.cpp.

References Themable::changeTheme(), and config().

Here is the call graph for this function:

void ThemeManager::updateTheme Themable ob  ) 
 

Forces an update to a theme objects.

That is its changeTheme() method is called.

Parameters:
ob The object to be updated.

Definition at line 78 of file thememanager.cpp.

References Themable::changeTheme().

Referenced by DisplayIntro::DisplayIntro(), DisplayTwo::DisplayTwo(), PixmapSprite::PixmapSprite(), ScoreSprite::ScoreSprite(), TextSprite::setText(), and TextSprite::TextSprite().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Tue May 1 09:34:40 2007 for LSkat by  doxygen 1.4.6