• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdefx
 

tdefx

  • tdefx
kpixmapsplitter.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kpixmapsplitter.h"
21
22KPixmapSplitter::KPixmapSplitter()
23 : m_itemSize( 4, 7 ),
24 m_vSpacing( 0 ),
25 m_hSpacing( 0 ),
26 m_numCols( 0 ),
27 m_numRows( 0 ),
28 m_dirty( false )
29{
30}
31
32KPixmapSplitter::~KPixmapSplitter()
33{
34}
35
36void KPixmapSplitter::setPixmap( const TQPixmap& pixmap )
37{
38 m_pixmap = pixmap;
39 m_dirty = true;
40}
41
42void KPixmapSplitter::setItemSize( const TQSize& size )
43{
44 if ( size != m_itemSize ) {
45 m_itemSize = size;
46 m_dirty = true;
47 }
48}
49
50void KPixmapSplitter::setVSpacing( int spacing )
51{
52 if ( spacing != m_vSpacing ) {
53 m_vSpacing = spacing;
54 m_dirty = true;
55 }
56}
57
58void KPixmapSplitter::setHSpacing( int spacing )
59{
60 if ( spacing != m_hSpacing ) {
61 m_hSpacing = spacing;
62 m_dirty = true;
63 }
64}
65
66
67TQRect KPixmapSplitter::coordinates( int pos )
68{
69 if ( pos < 0 || m_pixmap.isNull() )
70 return TQRect();
71
72 if ( m_dirty ) {
73 m_numCols = m_pixmap.width() / ( m_itemSize.width() + m_hSpacing );
74 m_numRows = m_pixmap.height() / ( m_itemSize.height() + m_vSpacing );
75 m_dirty = false;
76 // tqDebug("cols: %i, rows: %i (pixmap: %i, %i)", m_numCols, m_numRows, m_pixmap.width(), m_pixmap.height());
77 }
78
79 if ( m_numCols == 0 || m_numRows == 0 )
80 return TQRect();
81
82 int row = pos / m_numCols;
83 int col = pos - (row * m_numCols);
84
85 return TQRect( col * (m_itemSize.width() + m_hSpacing),
86 row * (m_itemSize.height() + m_vSpacing),
87 m_itemSize.width(),
88 m_itemSize.height() );
89}
90
91TQRect KPixmapSplitter::coordinates( const TQChar& ch )
92{
93 return coordinates( (unsigned char) ch.latin1() );
94}
95
KPixmapSplitter::pixmap
const TQPixmap & pixmap() const
Definition: kpixmapsplitter.h:70
KPixmapSplitter::setPixmap
void setPixmap(const TQPixmap &pixmap)
Sets the pixmap to be split.
Definition: kpixmapsplitter.cpp:36
KPixmapSplitter::coordinates
TQRect coordinates(int pos)
Definition: kpixmapsplitter.cpp:67
KPixmapSplitter::setVSpacing
void setVSpacing(int spacing)
If there is space between rows in the given pixmap, you have to specify how many pixels there are.
Definition: kpixmapsplitter.cpp:50
KPixmapSplitter::setItemSize
void setItemSize(const TQSize &size)
Sets the size of the items you want to get out of the given pixmap.
Definition: kpixmapsplitter.cpp:42
KPixmapSplitter::KPixmapSplitter
KPixmapSplitter()
Constructor, does nothing but initialize some default-values.
Definition: kpixmapsplitter.cpp:22
KPixmapSplitter::setHSpacing
void setHSpacing(int spacing)
If there is space between columns in the given pixmap, you have to specify how many pixels there are.
Definition: kpixmapsplitter.cpp:58

tdefx

Skip menu "tdefx"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdefx

Skip menu "tdefx"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdefx by doxygen 1.9.4
This website is maintained by Timothy Pearson.