TorK – anonymity manager for TDE
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.

127 lines
3.9KB

  1. /***************************************************************************
  2. * Copyright (C) 2004 by David Sansome *
  3. * me@davidsansome.com *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
  19. ***************************************************************************/
  20. #include "headerlistitem.h"
  21. #include <ntqfontmetrics.h>
  22. #include <ntqpainter.h>
  23. #include <ntqapplication.h>
  24. #include "uninstallwizard.h"
  25. #include "wizard.h"
  26. HeaderListItem::HeaderListItem(TQListView* parent)
  27. : TQListViewItem(parent)
  28. {
  29. }
  30. int HeaderListItem::compare(TQListViewItem* i, int , bool ) const
  31. {
  32. switch (i->rtti())
  33. {
  34. case 1001: // Component
  35. {
  36. ComponentListItem* item = (ComponentListItem*) i;
  37. if (section > item->section)
  38. return 1;
  39. return -1;
  40. }
  41. case 1003: // App
  42. {
  43. AppListItem* item = (AppListItem*) i;
  44. if (section > item->section)
  45. return 1;
  46. return -1;
  47. }
  48. case 1002: // Header
  49. {
  50. HeaderListItem* item = (HeaderListItem*) i;
  51. if (section > item->section)
  52. return 1;
  53. if (section < item->section)
  54. return -1;
  55. return 0;
  56. }
  57. }
  58. return 0;
  59. }
  60. void HeaderListItem::paintCell(TQPainter* p, const TQColorGroup& cg, int , int width, int )
  61. {
  62. p->fillRect(0, 0, width, height(), cg.base());
  63. TQFont boldFont = p->font();
  64. boldFont.setBold(true);
  65. p->setFont(boldFont);
  66. p->drawText(listView()->itemMargin(), listView()->itemMargin(), width, TQFontMetrics(boldFont).height(), TQt::AlignLeft, text(0));
  67. int textWidth = TQFontMetrics(boldFont).width(text(0));
  68. p->fillRect(0, height() - 4 - listView()->itemMargin(), textWidth-10, 4, cg.highlight());
  69. TQColor ca = cg.highlight();
  70. TQColor cb = cg.base();
  71. // Taken from KPixmapEffect::gradient
  72. int rDiff, gDiff, bDiff;
  73. int rca, gca, bca /*, rcb, gcb, bcb*/;
  74. // int x, y;
  75. rDiff = (/*rcb = */ cb.red()) - (rca = ca.red());
  76. gDiff = (/*gcb = */ cb.green()) - (gca = ca.green());
  77. bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue());
  78. int rl = rca << 16;
  79. int gl = gca << 16;
  80. int bl = bca << 16;
  81. int rcdelta = ((1<<16) / 20) * rDiff;
  82. int gcdelta = ((1<<16) / 20) * gDiff;
  83. int bcdelta = ((1<<16) / 20) * bDiff;
  84. for( int x = textWidth-10; x < textWidth+10; x++)
  85. {
  86. rl += rcdelta;
  87. gl += gcdelta;
  88. bl += bcdelta;
  89. p->setPen(TQColor(rl>>16, gl>>16, bl>>16));
  90. p->drawLine(x, height() - 4 - listView()->itemMargin(), x, height() - listView()->itemMargin() - 1);
  91. }
  92. }
  93. void HeaderListItem::paintFocus(TQPainter* , const TQColorGroup& , const TQRect& )
  94. {
  95. }
  96. int HeaderListItem::width(const TQFontMetrics& , const TQListView* lv, int ) const
  97. {
  98. TQFont boldFont = tqApp->font();
  99. boldFont.setBold(true);
  100. TQFontMetrics metrics(boldFont);
  101. return metrics.width(text(0)) + lv->itemMargin() + 10;
  102. }
  103. void HeaderListItem::setup()
  104. {
  105. setHeight(tqApp->fontMetrics().height() + listView()->itemMargin()*3 + 4);
  106. }