KKBSwitch – keyboard layout indicator
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.

boldmenuitem.cpp 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #include "boldmenuitem.h"
  17. #include <ntqfont.h>
  18. #include <ntqpainter.h>
  19. #include <ntqpalette.h>
  20. #include <ntqstyle.h>
  21. #include <kdebug.h>
  22. #include <tdeglobalsettings.h>
  23. #include <tdeversion.h>
  24. #if TDE_VERSION_MAJOR >= 3
  25. #include <tdeapplication.h>
  26. #else
  27. #include <kapp.h>
  28. #endif
  29. BoldMenuItem::BoldMenuItem(const TQString &text, const TQColor &active_text_color,
  30. bool bold)
  31. : m_text(text), m_active_text_color(active_text_color), m_bold(bold)
  32. {
  33. }
  34. BoldMenuItem::~BoldMenuItem(){
  35. }
  36. void BoldMenuItem::paint(TQPainter* painter, const TQColorGroup& /*cg*/,
  37. bool act, bool /*enabled*/, int x, int y, int w, int h)
  38. {
  39. TQFont font = painter->font();
  40. if (font.bold() != m_bold) {
  41. font.setBold(m_bold);
  42. painter->setFont(font);
  43. }
  44. //if (act) painter->setPen(TDEGlobalSettings::highlightedTextColor());
  45. //if (act) painter->setPen(cg.highlightedText());
  46. if (act) painter->setPen(m_active_text_color);
  47. kdDebug() << "bg color = " << painter->brush().color().rgb() << endl;
  48. painter->drawText(x, y, w, h, AlignLeft | AlignVCenter | ShowPrefix | DontClip,
  49. m_text);
  50. //TDEApplication::style().drawItem(painter, TQRect(x, y, w, h), AlignLeft | AlignVCenter | ShowPrefix | DontClip,
  51. // cg, enabled, 0, m_text);
  52. }
  53. void BoldMenuItem::setFont(const TQFont& font)
  54. {
  55. m_size = TQFontMetrics(font).size(AlignLeft | AlignVCenter | ShowPrefix | DontClip,
  56. m_text);
  57. TQCustomMenuItem::setFont(font);
  58. }