Bibletime – a bible study tool
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.

cscrollerwidgetset.cpp 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*********
  2. *
  3. * This file is part of BibleTime's source code, http://www.bibletime.info/.
  4. *
  5. * Copyright 1999-2006 by the BibleTime developers.
  6. * The BibleTime source code is licensed under the GNU General Public License version 2.0.
  7. *
  8. **********/
  9. //BibleTime includes
  10. #include "cscrollbutton.h"
  11. #include "cscrollerwidgetset.h"
  12. //BibleTime frontend includes
  13. #include "frontend/cbtconfig.h"
  14. //TQt includes
  15. #include <tqlineedit.h>
  16. #include <tqstring.h>
  17. #include <tqstringlist.h>
  18. #include <tqlistbox.h>
  19. #include <tqtoolbutton.h>
  20. #include <tqevent.h>
  21. #include <tqlayout.h>
  22. #include <tqpainter.h>
  23. #include <tqstyle.h>
  24. #include <tqpixmap.h>
  25. #include <tqapplication.h>
  26. #include <tqtooltip.h>
  27. #include <tqrect.h>
  28. #include <tqlayout.h>
  29. const unsigned int WIDTH = 16;
  30. const unsigned int ARROW_HEIGHT = 12;
  31. const unsigned int MOVER_HEIGHT = 6;
  32. CScrollerWidgetSet::CScrollerWidgetSet(TQWidget *parent, const char *name) : TQWidget(parent,name) {
  33. m_layout = new TQVBoxLayout(this);
  34. m_layout->setAlignment(TQt::AlignHCenter | TQt::AlignCenter);
  35. //setAlignment(TQt::AlignHCenter | TQt::AlignCenter);
  36. btn_up = new TQToolButton( UpArrow, this, "btn_up" );
  37. btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
  38. btn_up->setFocusPolicy(TQ_NoFocus);
  39. btn_fx = new CScrollButton( this, "btn_fx" );
  40. btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
  41. btn_fx->setFocusPolicy(TQ_NoFocus);
  42. btn_down = new TQToolButton( DownArrow, this, "btn_down" );
  43. btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
  44. btn_down->setFocusPolicy(TQ_NoFocus);
  45. m_layout->addWidget( btn_up,0 );
  46. m_layout->addWidget( btn_fx,0 );
  47. m_layout->addWidget( btn_down,0 );
  48. setMinimumWidth(WIDTH+4); // Kludge to add some spacing but seems to work.
  49. connect(btn_fx, TQT_SIGNAL(lock()), TQT_SLOT(slotLock()));
  50. connect(btn_fx, TQT_SIGNAL(unlock()), TQT_SLOT(slotUnlock()));
  51. connect(btn_fx, TQT_SIGNAL(change_requested(int)), TQT_SLOT(slotScroller(int)));
  52. connect(btn_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotUpClick()));
  53. connect(btn_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotDownClick()));
  54. }
  55. /** Sets the tooltips for the given entries using the parameters as text. */
  56. void CScrollerWidgetSet::setToolTips( const TQString nextEntryTip, const TQString scrollButtonTip, const TQString previousEntryTip) {
  57. TQToolTip::add (btn_fx, scrollButtonTip);
  58. TQToolTip::add (btn_down, nextEntryTip);
  59. TQToolTip::add (btn_up, previousEntryTip);
  60. }
  61. void CScrollerWidgetSet::slotLock() { emit scroller_pressed(); }
  62. void CScrollerWidgetSet::slotUnlock() { emit scroller_released(); }
  63. void CScrollerWidgetSet::slotScroller(int n) { emit change(n); }
  64. void CScrollerWidgetSet::slotUpClick() { slotScroller(-1); }
  65. void CScrollerWidgetSet::slotDownClick() { slotScroller(1); }
  66. #include "cscrollerwidgetset.moc"