~ubuntu-branches/ubuntu/lucid/kkbswitch/lucid

« back to all changes in this revision

Viewing changes to kkbswitch/boldmenuitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Lior Kaplan
  • Date: 2005-09-07 02:01:14 UTC
  • Revision ID: james.westby@ubuntu.com-20050907020114-2wyo9eu21uihq86n
Tags: upstream-1.4.3
ImportĀ upstreamĀ versionĀ 1.4.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          boldmenuitem.cpp  -  description
 
3
                             -------------------
 
4
    begin                : Sat Sep 1 2001
 
5
    copyright            : (C) 2001 by Leonid Zeitlin
 
6
    email                : lz@europe.com
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#include "boldmenuitem.h"
 
19
#include <qfont.h>
 
20
#include <qpainter.h>
 
21
#include <qpalette.h>
 
22
#include <qstyle.h>
 
23
#include <kdebug.h>
 
24
#include <kglobalsettings.h>
 
25
#include <kdeversion.h>
 
26
#if KDE_VERSION_MAJOR >= 3
 
27
  #include <kapplication.h>
 
28
#else
 
29
  #include <kapp.h>
 
30
#endif
 
31
 
 
32
 
 
33
BoldMenuItem::BoldMenuItem(const QString &text, const QColor &active_text_color,
 
34
  bool bold)
 
35
  : m_text(text), m_active_text_color(active_text_color), m_bold(bold)
 
36
{
 
37
}
 
38
 
 
39
BoldMenuItem::~BoldMenuItem(){
 
40
}
 
41
 
 
42
void BoldMenuItem::paint(QPainter* painter, const QColorGroup& /*cg*/,
 
43
          bool act, bool /*enabled*/, int x, int y, int w, int h)
 
44
{
 
45
  QFont font = painter->font();
 
46
  if (font.bold() != m_bold) {
 
47
    font.setBold(m_bold);
 
48
    painter->setFont(font);
 
49
  }
 
50
  //if (act) painter->setPen(KGlobalSettings::highlightedTextColor());
 
51
  //if (act) painter->setPen(cg.highlightedText());
 
52
  if (act) painter->setPen(m_active_text_color);
 
53
  kdDebug() << "bg color = " << painter->brush().color().rgb() << endl;
 
54
 
 
55
  painter->drawText(x, y, w, h, AlignLeft | AlignVCenter | ShowPrefix | DontClip,
 
56
    m_text);
 
57
  //KApplication::style().drawItem(painter, QRect(x, y, w, h), AlignLeft | AlignVCenter | ShowPrefix | DontClip,
 
58
  //  cg, enabled, 0, m_text);
 
59
}       
 
60
 
 
61
 
 
62
void BoldMenuItem::setFont(const QFont& font)
 
63
{
 
64
  m_size = QFontMetrics(font).size(AlignLeft | AlignVCenter | ShowPrefix | DontClip,
 
65
    m_text);
 
66
  QCustomMenuItem::setFont(font);
 
67
}
 
68