You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
9.8 KiB
192 lines
9.8 KiB
13 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qpixmapcache.cpp:45 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>TQPixmapCache Class</title>
|
||
|
<style type="text/css"><!--
|
||
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
||
|
a:link { color: #004faf; text-decoration: none }
|
||
|
a:visited { color: #672967; text-decoration: none }
|
||
|
body { background: #ffffff; color: black; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||
|
<tr bgcolor="#E5E5E5">
|
||
|
<td valign=center>
|
||
|
<a href="index.html">
|
||
|
<font color="#004faf">Home</font></a>
|
||
|
| <a href="classes.html">
|
||
|
<font color="#004faf">All Classes</font></a>
|
||
|
| <a href="mainclasses.html">
|
||
|
<font color="#004faf">Main Classes</font></a>
|
||
|
| <a href="annotated.html">
|
||
|
<font color="#004faf">Annotated</font></a>
|
||
|
| <a href="groups.html">
|
||
|
<font color="#004faf">Grouped Classes</font></a>
|
||
|
| <a href="functions.html">
|
||
|
<font color="#004faf">Functions</font></a>
|
||
|
</td>
|
||
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQPixmapCache Class Reference</h1>
|
||
|
|
||
|
<p>The TQPixmapCache class provides an application-global cache for
|
||
|
pixmaps.
|
||
|
<a href="#details">More...</a>
|
||
13 years ago
|
<p><tt>#include <<a href="qpixmapcache-h.html">ntqpixmapcache.h</a>></tt>
|
||
13 years ago
|
<p><a href="qpixmapcache-members.html">List of all member functions.</a>
|
||
|
<h2>Static Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>int <a href="#cacheLimit"><b>cacheLimit</b></a> ()</li>
|
||
|
<li class=fn>void <a href="#setCacheLimit"><b>setCacheLimit</b></a> ( int n )</li>
|
||
|
<li class=fn>TQPixmap * <a href="#find"><b>find</b></a> ( const TQString & key )</li>
|
||
|
<li class=fn>bool <a href="#find-2"><b>find</b></a> ( const TQString & key, TQPixmap & pm )</li>
|
||
|
<li class=fn>bool insert ( const TQString & key, TQPixmap * pm ) <em>(obsolete)</em></li>
|
||
|
<li class=fn>bool <a href="#insert"><b>insert</b></a> ( const TQString & key, const TQPixmap & pm )</li>
|
||
|
<li class=fn>void <a href="#remove"><b>remove</b></a> ( const TQString & key )</li>
|
||
|
<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
<p> The TQPixmapCache class provides an application-global cache for
|
||
|
pixmaps.
|
||
|
<p>
|
||
|
|
||
|
|
||
13 years ago
|
<p> This class is a tool for optimized drawing with <a href="ntqpixmap.html">TQPixmap</a>. You can
|
||
13 years ago
|
use it to store temporary pixmaps that are expensive to generate
|
||
|
without using more storage space than <a href="#cacheLimit">cacheLimit</a>(). Use <a href="#insert">insert</a>()
|
||
|
to insert pixmaps, <a href="#find">find</a>() to find them and <a href="#clear">clear</a>() to empty the
|
||
|
cache.
|
||
13 years ago
|
<p> For example, <a href="ntqradiobutton.html">TQRadioButton</a> has a non-trivial visual representation
|
||
13 years ago
|
so we don't want to regenerate a pixmap whenever a radio button is
|
||
|
displayed or changes state. In the function
|
||
13 years ago
|
<a href="ntqbutton.html#drawButton">TQRadioButton::drawButton</a>(), we do not draw the radio button
|
||
13 years ago
|
directly. Instead, we first check the global pixmap cache for a
|
||
|
pixmap with the key "$qt_radio_nnn_", where <tt>nnn</tt> is a numerical
|
||
|
value that specifies the the radio button state. If a pixmap is
|
||
13 years ago
|
found, we <a href="ntqimage.html#bitBlt">bitBlt</a>() it onto the widget and return. Otherwise, we
|
||
13 years ago
|
create a new pixmap, draw the radio button in the pixmap, and
|
||
|
finally insert the pixmap in the global pixmap cache, using the
|
||
|
key above. The bitBlt() is ten times faster than drawing the
|
||
|
radio button. All radio buttons in the program share the cached
|
||
|
pixmap since TQPixmapCache is application-global.
|
||
|
<p> TQPixmapCache contains no member data, only static functions to
|
||
13 years ago
|
access the global pixmap cache. It creates an internal <a href="ntqcache.html">TQCache</a> for
|
||
13 years ago
|
caching the pixmaps.
|
||
|
<p> The cache associates a pixmap with a string (key). If two pixmaps
|
||
|
are inserted into the cache using equal keys, then the last pixmap
|
||
13 years ago
|
will hide the first pixmap. The <a href="ntqdict.html">TQDict</a> and TQCache classes do
|
||
13 years ago
|
exactly the same.
|
||
|
<p> The cache becomes full when the total size of all pixmaps in the
|
||
|
cache exceeds <a href="#cacheLimit">cacheLimit</a>(). The initial cache limit is 1024 KByte
|
||
|
(1 MByte); it is changed with <a href="#setCacheLimit">setCacheLimit</a>(). A pixmap takes
|
||
|
roughly width*height*depth/8 bytes of memory.
|
||
13 years ago
|
<p> See the <a href="ntqcache.html">TQCache</a> documentation for more details about the cache
|
||
13 years ago
|
mechanism.
|
||
|
<p>See also <a href="environment.html">Environment Classes</a>, <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>.
|
||
|
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn>int <a name="cacheLimit"></a>TQPixmapCache::cacheLimit ()<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Returns the cache limit (in kilobytes).
|
||
|
<p> The default setting is 1024 kilobytes.
|
||
|
<p> <p>See also <a href="#setCacheLimit">setCacheLimit</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="clear"></a>TQPixmapCache::clear ()<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Removes all pixmaps from the cache.
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqpixmap.html">TQPixmap</a> * <a name="find"></a>TQPixmapCache::find ( const <a href="ntqstring.html">TQString</a> & key )<tt> [static]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Returns the pixmap associated with the <em>key</em> in the cache, or
|
||
|
null if there is no such pixmap.
|
||
|
<p> <b>Warning:</b> If valid, you should copy the pixmap immediately (this is
|
||
|
fast). Subsequent insertions into the cache could cause the
|
||
|
pointer to become invalid. For this reason, we recommend you use
|
||
13 years ago
|
<a href="#find">find</a>(const <a href="ntqstring.html">TQString</a>&, <a href="ntqpixmap.html">TQPixmap</a>&) instead.
|
||
13 years ago
|
<p> Example:
|
||
|
<pre>
|
||
13 years ago
|
<a href="ntqpixmap.html">TQPixmap</a>* pp;
|
||
|
<a href="ntqpixmap.html">TQPixmap</a> p;
|
||
13 years ago
|
if ( (pp=TQPixmapCache::<a href="#find">find</a>("my_big_image", pm)) ) {
|
||
|
p = *pp;
|
||
|
} else {
|
||
13 years ago
|
p.<a href="ntqpixmap.html#load">load</a>("bigimage.png");
|
||
|
TQPixmapCache::<a href="#insert">insert</a>("my_big_image", new <a href="ntqpixmap.html">TQPixmap</a>(p));
|
||
13 years ago
|
}
|
||
|
painter->drawPixmap(0, 0, p);
|
||
|
</pre>
|
||
|
|
||
|
|
||
13 years ago
|
<h3 class=fn>bool <a name="find-2"></a>TQPixmapCache::find ( const <a href="ntqstring.html">TQString</a> & key, <a href="ntqpixmap.html">TQPixmap</a> & pm )<tt> [static]</tt>
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Looks for a cached pixmap associated with the <em>key</em> in the cache.
|
||
|
If a pixmap is found, the function sets <em>pm</em> to that pixmap and
|
||
|
returns TRUE; otherwise leaves <em>pm</em> alone and returns FALSE.
|
||
|
<p> Example:
|
||
|
<pre>
|
||
13 years ago
|
<a href="ntqpixmap.html">TQPixmap</a> p;
|
||
13 years ago
|
if ( !TQPixmapCache::find("my_big_image", pm) ) {
|
||
|
pm.load("bigimage.png");
|
||
|
TQPixmapCache::<a href="#insert">insert</a>("my_big_image", pm);
|
||
|
}
|
||
|
painter->drawPixmap(0, 0, p);
|
||
|
</pre>
|
||
|
|
||
|
|
||
13 years ago
|
<h3 class=fn>bool <a name="insert"></a>TQPixmapCache::insert ( const <a href="ntqstring.html">TQString</a> & key, const <a href="ntqpixmap.html">TQPixmap</a> & pm )<tt> [static]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Inserts a copy of the pixmap <em>pm</em> associated with the <em>key</em> into
|
||
|
the cache.
|
||
|
<p> All pixmaps inserted by the TQt library have a key starting with
|
||
|
"$qt", so your own pixmap keys should never begin "$qt".
|
||
|
<p> When a pixmap is inserted and the cache is about to exceed its
|
||
|
limit, it removes pixmaps until there is enough room for the
|
||
|
pixmap to be inserted.
|
||
|
<p> The oldest pixmaps (least recently accessed in the cache) are
|
||
|
deleted when more space is needed.
|
||
|
<p> <p>See also <a href="#setCacheLimit">setCacheLimit</a>().
|
||
|
|
||
13 years ago
|
<h3 class=fn>bool <a name="insert-2"></a>TQPixmapCache::insert ( const <a href="ntqstring.html">TQString</a> & key, <a href="ntqpixmap.html">TQPixmap</a> * pm )<tt> [static]</tt>
|
||
13 years ago
|
</h3>
|
||
|
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
||
|
<p> Inserts the pixmap <em>pm</em> associated with <em>key</em> into the cache.
|
||
|
Returns TRUE if successful, or FALSE if the pixmap is too big for the cache.
|
||
|
<p> <strong>
|
||
|
Note: <em>pm</em> must be allocated on the heap (using <tt>new</tt>).
|
||
|
<p> If this function returns FALSE, you must delete <em>pm</em> yourself.
|
||
|
<p> If this function returns TRUE, do not use <em>pm</em> afterwards or
|
||
|
keep references to it because any other insertions into the cache,
|
||
|
whether from anywhere in the application or within TQt itself, could cause
|
||
|
the pixmap to be discarded from the cache and the pointer to
|
||
|
become invalid.
|
||
|
<p> Due to these dangers, we strongly recommend that you use
|
||
13 years ago
|
<a href="#insert">insert</a>(const <a href="ntqstring.html">TQString</a>&, const <a href="ntqpixmap.html">TQPixmap</a>&) instead.
|
||
13 years ago
|
</strong>
|
||
|
|
||
13 years ago
|
<h3 class=fn>void <a name="remove"></a>TQPixmapCache::remove ( const <a href="ntqstring.html">TQString</a> & key )<tt> [static]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Removes the pixmap associated with <em>key</em> from the cache.
|
||
|
|
||
|
<h3 class=fn>void <a name="setCacheLimit"></a>TQPixmapCache::setCacheLimit ( int n )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Sets the cache limit to <em>n</em> kilobytes.
|
||
|
<p> The default setting is 1024 kilobytes.
|
||
|
<p> <p>See also <a href="#cacheLimit">cacheLimit</a>().
|
||
|
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">TQt toolkit</a>.
|
||
|
Copyright © 1995-2007
|
||
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
||
|
<table width=100% cellspacing=0 border=0><tr>
|
||
|
<td>Copyright © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>TQt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|