summaryrefslogtreecommitdiffstats
path: root/kkbswitch/boldmenuitem.cpp
blob: e98d3bba5374a3d0e64bd14da8fdcf1396d75779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/***************************************************************************
                          boldmenuitem.cpp  -  description
                             -------------------
    begin                : Sat Sep 1 2001
    copyright            : (C) 2001 by Leonid Zeitlin
    email                : lz@europe.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "boldmenuitem.h"
#include <ntqfont.h>
#include <ntqpainter.h>
#include <ntqpalette.h>
#include <ntqstyle.h>
#include <kdebug.h>
#include <tdeglobalsettings.h>
#include <tdeversion.h>
#if TDE_VERSION_MAJOR >= 3
  #include <tdeapplication.h>
#else
  #include <kapp.h>
#endif


BoldMenuItem::BoldMenuItem(const TQString &text, const TQColor &active_text_color,
  bool bold)
  : m_text(text), m_active_text_color(active_text_color), m_bold(bold)
{
}

BoldMenuItem::~BoldMenuItem(){
}

void BoldMenuItem::paint(TQPainter* painter, const TQColorGroup& /*cg*/,
	  bool act, bool /*enabled*/, int x, int y, int w, int h)
{
  TQFont font = painter->font();
  if (font.bold() != m_bold) {
    font.setBold(m_bold);
    painter->setFont(font);
  }
  //if (act) painter->setPen(TDEGlobalSettings::highlightedTextColor());
  //if (act) painter->setPen(cg.highlightedText());
  if (act) painter->setPen(m_active_text_color);
  kdDebug() << "bg color = " << painter->brush().color().rgb() << endl;

  painter->drawText(x, y, w, h, AlignLeft | AlignVCenter | ShowPrefix | DontClip,
    m_text);
  //TDEApplication::style().drawItem(painter, TQRect(x, y, w, h), AlignLeft | AlignVCenter | ShowPrefix | DontClip,
  //  cg, enabled, 0, m_text);
}	


void BoldMenuItem::setFont(const TQFont& font)
{
  m_size = TQFontMetrics(font).size(AlignLeft | AlignVCenter | ShowPrefix | DontClip,
    m_text);
  TQCustomMenuItem::setFont(font);
}