# class KThemeCache | A very simple pixmap cache for theme plugins. More...
Definition | `#include <kthemebase.h>`
Inherits | QObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum ScaleHint {FullScale, HorizontalScale, VerticalScale}

#### Public Methods

- KThemeCache (int maxSize, QObject *parent=0, const char *name=0)
- bool insert (KThemePixmap *pixmap, ScaleHint scale, int widgetID, bool border=false, bool mask=false)
- KThemePixmap* pixmap (int w, int h, int widgetID, bool border=false, bool mask=false)
- KThemePixmap* horizontalPixmap (int w, int widgetID)
- KThemePixmap* verticalPixmap (int h, int widgetID)

#### Protected Slots

- void flushTimeout ()

#### Protected Members

- QIntCache<KThemePixmap> cache
- QTimer flushTimer

## 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.

enum ScaleHint {FullScale, HorizontalScale, VerticalScale} | ### ScaleHint

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

KThemeCache (int maxSize, QObject *parent=0, const char *name=0) | ### KThemeCache

The constructor.

Parameters:

maxSize | The maximum size of the cache in kilobytes.

bool insert (KThemePixmap *pixmap, ScaleHint scale, int widgetID, bool border=false, bool mask=false) | ### insert

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 KThemeBase's WidgetType enum.

Returns: True if the insert was successful, false otherwise.

KThemePixmap* pixmap (int w, int h, int widgetID, bool border=false, bool mask=false) | ### pixmap

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.

KThemePixmap* horizontalPixmap (int w, int widgetID) | ### horizontalPixmap

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.

KThemePixmap* verticalPixmap (int h, int widgetID) | ### verticalPixmap

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.

void flushTimeout () | ### flushTimeout

[protected slots slot]

QIntCache<KThemePixmap> cache | ### cache

[protected]

QTimer flushTimer | ### flushTimer

[protected]

- Author: Daniel M. Duley <mosfet@kde.org>
- Generated: root@i386.ports.openbsd.org on Wed Apr 25 13:58:24 2001, using kdoc 2.0a53.