Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OThemeCache Class Reference

#include </home/clem/local/src/opie/noncore/styles/theme/othemebase.h>

List of all members.

Public Types

enum  ScaleHint { FullScale, HorizontalScale, VerticalScale }

Public Member Functions

 OThemeCache (int maxSize, QObject *parent=0, const char *name=0)
bool insert (OThemePixmap *pixmap, ScaleHint scale, int widgetID, bool border=false, bool mask=false)
OThemePixmappixmap (int w, int h, int widgetID, bool border=false, bool mask=false)
OThemePixmaphorizontalPixmap (int w, int widgetID)
OThemePixmapverticalPixmap (int h, int widgetID)

Protected Slots

void flushTimeout ()

Protected Attributes

QIntCache< OThemePixmapcache
QTimer flushTimer

Private Attributes

OThemeCachePrivate * d


Detailed Description

A very simple pixmap cache for theme plugins. QPixmapCache is not used since it uses QString keys which are not needed. All the information we need can be encoded in a numeric key. Using QIntCache instead allows us to skip the string operations.

This class is mostly just inline methods that do bit operations on a key composed of the widget ID, width and/or height, and then calls QIntCache::find().

One other thing to note is that full, horizontal, and vertically scaled pixmaps are not used interchangeably. For example, if you insert a fully scaled pixmap that is 32x32 then request a horizontally scaled pixmap with a width of 32, they will not match. This is because a pixmap that has been inserted into the cache has already been scaled at some point and it is very likely the vertical height was not originally 32. Thus the pixmap will be wrong when drawn, even though the horizontal width matches.

Author:
Daniel M. Duley <mosfet@kde.org>

Definition at line 112 of file othemebase.h.


Member Enumeration Documentation

enum OThemeCache::ScaleHint
 

The scale hints supported by the cache. Note that Tiled is not here since tiled pixmaps are kept only once in OThemeBase.

Enumeration values:
FullScale 
HorizontalScale 
VerticalScale 

Definition at line 120 of file othemebase.h.


Constructor & Destructor Documentation

OThemeCache::OThemeCache int  maxSize,
QObject *  parent = 0,
const char *  name = 0
 

The constructor.

Parameters:
maxSize The maximum size of the cache in kilobytes.

Definition at line 1117 of file othemebase.cpp.

References cache, flushTimeout(), and flushTimer.


Member Function Documentation

void OThemeCache::flushTimeout  )  [protected, slot]
 

Definition at line 1126 of file othemebase.cpp.

References cache.

Referenced by OThemeCache().

OThemePixmap * OThemeCache::horizontalPixmap int  w,
int  widgetID
 

Returns a horizontally scaled pixmap.

Parameters:
w The pixmap width to search for.
widgetID The widget ID to search for.
Returns:
True if a pixmap matching the width and widget ID of the pixmap exists, NULL otherwise.

Definition at line 1155 of file othemebase.cpp.

References kthemeKeyData::border, cache, kthemeKey::cacheKey, kthemeKey::data, kthemeKeyData::height, kthemeKeyData::id, kthemeKeyData::mask, pix, and kthemeKeyData::width.

Referenced by OThemeBase::gradient(), and OThemeBase::scale().

bool OThemeCache::insert OThemePixmap pixmap,
ScaleHint  scale,
int  widgetID,
bool  border = false,
bool  mask = false
 

Inserts a new pixmap into the cache.

Parameters:
pixmap The pixmap to insert.
scale The scaling type of the pixmap.
widgetID The widget ID of the pixmap, usually from OThemeBase's WidgetType enum.
Returns:
True if the insert was successful, false otherwise.

Definition at line 1185 of file othemebase.cpp.

References kthemeKeyData::border, cache, kthemeKey::cacheKey, kthemeKey::data, FullScale, kthemeKeyData::height, HorizontalScale, kthemeKeyData::id, kthemeKeyData::mask, NULL, VerticalScale, and kthemeKeyData::width.

Referenced by OThemeBase::gradient(), OThemeBase::scale(), and OThemeBase::scaleBorder().

OThemePixmap * OThemeCache::pixmap int  w,
int  h,
int  widgetID,
bool  border = false,
bool  mask = false
 

Returns a fully scaled pixmap.

Parameters:
w The pixmap width to search for.
h The pixmap height to search for.
widgetID The widget ID to search for.
Returns:
True if a pixmap matching the width, height, and widget ID of the pixmap exists, NULL otherwise.

Definition at line 1137 of file othemebase.cpp.

References kthemeKeyData::border, cache, kthemeKey::cacheKey, kthemeKey::data, kthemeKeyData::height, kthemeKeyData::id, kthemeKeyData::mask, pix, and kthemeKeyData::width.

Referenced by OThemeBase::gradient(), OThemeBase::scale(), and OThemeBase::scaleBorder().

OThemePixmap * OThemeCache::verticalPixmap int  h,
int  widgetID
 

Returns a vertically scaled pixmap.

Parameters:
h The pixmap height to search for.
widgetID The widget ID to search for.
Returns:
True if a pixmap matching the height and widget ID of the pixmap exists, NULL otherwise.

Definition at line 1170 of file othemebase.cpp.

References kthemeKeyData::border, cache, kthemeKey::cacheKey, kthemeKey::data, kthemeKeyData::height, kthemeKeyData::id, kthemeKeyData::mask, pix, and kthemeKeyData::width.

Referenced by OThemeBase::gradient(), and OThemeBase::scale().


Member Data Documentation

QIntCache<OThemePixmap> OThemeCache::cache [protected]
 

Definition at line 174 of file othemebase.h.

Referenced by flushTimeout(), horizontalPixmap(), insert(), OThemeCache(), pixmap(), and verticalPixmap().

OThemeCachePrivate* OThemeCache::d [private]
 

Definition at line 178 of file othemebase.h.

QTimer OThemeCache::flushTimer [protected]
 

Definition at line 175 of file othemebase.h.

Referenced by OThemeCache().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:43:39 2005 for OPIE by  doxygen 1.4.2