AlbumShaper 1.0a3
groupIcon.cpp
Go to the documentation of this file.
1//==============================================
2// copyright : (C) 2003-2005 by Will Stokes
3//==============================================
4// This program is free software; you can redistribute it
5// and/or modify it under the terms of the GNU General
6// Public License as published by the Free Software
7// Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//==============================================
10
11//Systemwide includes
12#include <qpixmap.h>
13#include <qstring.h>
14#include <qpainter.h>
15#include <q3iconview.h>
16
17//Projectwide includes
18#include "groupIcon.h"
19#include "groupsWidget.h"
20
21//==============================================
22GroupIcon::GroupIcon( Q3IconView* parent, QPixmap icon,
23 QString text, QWidget* settingsWidget) :
24 Q3IconViewItem(parent, text, icon)
25{
26 this->parent = parent;
27 this->settingsWidget = settingsWidget;
28 mousedOver = false;
29
30 //initialize item rectangle
32}
33//==============================================
34void GroupIcon::paintItem( QPainter* p, const QColorGroup&)
35{
36 p->save();
37 QRect r = rect();
38
39 //if selected paint dark blue background and outline
40 if(isSelected())
41 {
42 //Draw Selected Color (dark blue)
43 p->fillRect( r, QColor(193, 210, 238) );
44
45 //draw selection rectangle (darker blue)
46 p->setPen( QColor(49, 106, 197) );
47 p->drawRect(r);
48 }
49 //else if pseudo selected paint ligher blue background with outline
50 else if(mousedOver)
51 {
52 //Draw Pseudo Selected Color (light blue)
53 p->fillRect( r, QColor(224, 232, 246) );
54
55 //draw selection rectangle (darker blue)
56 p->setPen( QColor(152, 180, 226) );
57 p->drawRect(r);
58 }
59
60 p->restore();
61
62 p->drawPixmap( x()+3 , y() + ( height() - pixmap()->height() ) / 2, *pixmap());
63
64 int align = Qt::AlignLeft | Qt::TextWordWrap | Qt::TextWrapAnywhere;
65 p->drawText( textRect( FALSE ), align, text());
66}
67//==============================================
68void GroupIcon::paintFocus( QPainter*, const QColorGroup&) { }
69//==============================================
71//==============================================
72void GroupIcon::setMousedOver(bool val) { mousedOver = val; }
73//==============================================
75{
76 //reset pixmap rect
77 QRect pr = pixmapRect();
78 int prWidth = pr.width();
79 int prHeight = pr.height();
80 pr.setTopLeft( QPoint(3,3) );
81 pr.setBottomRight( QPoint(pr.left()+prWidth, pr.top()+prHeight) );
82 setPixmapRect( pr );
83
84 //reset text rect
85 int textWidth = ((GroupsWidget*)parent)->getTextWidth();
86 QRect tr = textRect();
87 tr.setTop( pixmapRect().top() );
88 tr.setBottom( pixmapRect().bottom() );
89 tr.setLeft( pixmapRect().right() + 2 );
90 tr.setRight( tr.left() + textWidth );
91 setTextRect( tr );
92
93 //reset item rect using pixmap and text rect dimensions
94 int itemW = 3 + pixmapRect().width() + (tr.left() - pr.right()) + textRect().width() + 3;
95 int itemH = 3 + pixmapRect().height() + 3;
96 setItemRect( QRect( pixmapRect().left() - 3, pixmapRect().top() - 3, itemW, itemH ) );
97}
98//==============================================
int height
Definition blur.cpp:79
QWidget * getSettingsWidget()
Definition groupIcon.cpp:70
void setMousedOver(bool val)
Definition groupIcon.cpp:72
void initializeItemRect()
Definition groupIcon.cpp:74
Q3IconView * parent
Definition groupIcon.h:53
void paintFocus(QPainter *p, const QColorGroup &cg)
Definition groupIcon.cpp:68
bool mousedOver
Definition groupIcon.h:55
GroupIcon(Q3IconView *parent, QPixmap icon, QString text, QWidget *settingsWidget)
Definition groupIcon.cpp:22
void paintItem(QPainter *p, const QColorGroup &cg)
Definition groupIcon.cpp:34
QWidget * settingsWidget
Definition groupIcon.h:54
Displays group icon and text, also contains pointer to widget for setting group settings.