KBFX – an alternative to T-Menu
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.

126 lines
4.1KB

  1. /*
  2. * Copyright (C) 2006
  3. * Siraj Razick <siraj@kdemail.net>
  4. * PhobosK <phobosk@mail.kbfx.net>
  5. * see Also AUTHORS
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Library General Public License version 2 as
  9. * published by the Free Software Foundation
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this program; if not, write to the
  18. * Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. #include "kbfxplasmacanvasitemwrapper.h"
  22. #include <tqptrlist.h>
  23. #include <kbfxplasmapixmapprovider.h>
  24. KbfxPlasmaCanvasItemWrapper::KbfxPlasmaCanvasItemWrapper ( TQCanvas * canvas )
  25. {
  26. m_canvas = canvas;
  27. }
  28. KbfxPlasmaCanvasItemWrapper::~KbfxPlasmaCanvasItemWrapper ()
  29. {}
  30. TQCanvasItem *
  31. KbfxPlasmaCanvasItemWrapper::item ( KbfxPlasmaCanvasItem::Type __type )
  32. {
  33. TQPixmap _img_sep = ( *KbfxPlasmaPixmapProvider::pixmap ( "separator" ) );
  34. TQImage _tmp_img = _img_sep.convertToImage();
  35. _tmp_img = _tmp_img.smoothScale ( ConfigInit().m_itemView_w, _img_sep.height (),TQ_ScaleFree );
  36. _img_sep = TQPixmap ( _tmp_img );
  37. TQPixmap _img_tnorm = ( *KbfxPlasmaPixmapProvider::pixmap ( "tilenormal" ) );
  38. _tmp_img = _img_tnorm.convertToImage();
  39. _tmp_img = _tmp_img.smoothScale ( ConfigInit().m_itemView_w, _img_tnorm.height (),TQ_ScaleFree );
  40. _img_tnorm = TQPixmap ( _tmp_img );
  41. TQPixmap _img_thov = ( *KbfxPlasmaPixmapProvider::pixmap ( "tilehover" ) );
  42. _tmp_img = _img_thov.convertToImage();
  43. _tmp_img = _tmp_img.smoothScale ( ConfigInit().m_itemView_w, _img_thov.height (),TQ_ScaleFree );
  44. _img_thov = TQPixmap ( _tmp_img );
  45. if ( __type == KbfxPlasmaCanvasItem::SEPARATOR )
  46. {
  47. TQValueList<TQPixmap> list;
  48. list.append ( _img_sep );
  49. KbfxPlasmaCanvasItem *_ret =
  50. new KbfxPlasmaCanvasItem ( new TQCanvasPixmapArray ( list ),m_canvas );
  51. _ret->setType ( __type );
  52. return ( TQCanvasItem * ) _ret;
  53. }
  54. if ( __type == KbfxPlasmaCanvasItem::EXECUTABLE )
  55. {
  56. TQValueList<TQPixmap> list;
  57. list.append ( _img_tnorm );
  58. list.append ( _img_thov );
  59. TQCanvasPixmapArray * _pArray = new TQCanvasPixmapArray ( list );
  60. KbfxPlasmaCanvasItem *_ret = new KbfxPlasmaCanvasItem ( _pArray,
  61. m_canvas );
  62. _ret->setType ( __type );
  63. return ( TQCanvasItem * ) _ret;
  64. }
  65. return 0;
  66. }
  67. TQCanvasItem *
  68. KbfxPlasmaCanvasItemWrapper::itemIndex ( KbfxPlasmaCanvasItem::Type __type )
  69. {
  70. TQPixmap _img_isep = ( *KbfxPlasmaPixmapProvider::pixmap ( "indexseparator" ) );
  71. TQImage _tmp_img = _img_isep.convertToImage();
  72. _tmp_img = _tmp_img.smoothScale ( ConfigInit().m_listBox_w, _img_isep.height (),TQ_ScaleFree );
  73. _img_isep = TQPixmap ( _tmp_img );
  74. TQPixmap _img_r = ( *KbfxPlasmaPixmapProvider::pixmap ( "rhstile" ) );
  75. _tmp_img = _img_r.convertToImage();
  76. _tmp_img = _tmp_img.smoothScale ( ConfigInit().m_listBox_w, _img_r.height (),TQ_ScaleFree );
  77. _img_r = TQPixmap ( _tmp_img );
  78. TQPixmap _img_rhov = ( *KbfxPlasmaPixmapProvider::pixmap ( "rhshovertile" ) );
  79. _tmp_img = _img_rhov.convertToImage();
  80. _tmp_img = _tmp_img.smoothScale ( ConfigInit().m_listBox_w, _img_rhov.height (),TQ_ScaleFree );
  81. _img_rhov = TQPixmap ( _tmp_img );
  82. if ( __type == KbfxPlasmaCanvasItem::SEPARATOR )
  83. {
  84. TQValueList<TQPixmap> list;
  85. list.append ( _img_isep );
  86. KbfxPlasmaIndexItem *_ret =
  87. new KbfxPlasmaIndexItem ( new TQCanvasPixmapArray ( list ),m_canvas );
  88. _ret->setType ( __type );
  89. return ( TQCanvasItem * ) _ret;
  90. }
  91. if ( __type == KbfxPlasmaCanvasItem::INDEX )
  92. {
  93. TQValueList<TQPixmap> list2;
  94. list2.append ( _img_r );
  95. list2.append ( _img_rhov );
  96. KbfxPlasmaIndexItem *_ret = new KbfxPlasmaIndexItem ( new TQCanvasPixmapArray ( list2 ),
  97. m_canvas );
  98. _ret->setType ( __type );
  99. return ( TQCanvasItem * ) _ret;
  100. }
  101. return 0;
  102. }
  103. #include "kbfxplasmacanvasitemwrapper.moc"