Rubberband.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Rubberband.h - rubberband - either own implementation for Qt3 or wrapper for
  3. * Qt4
  4. *
  5. * Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef RUBBERBAND_H
  26. #define RUBBERBAND_H
  27. #include <QRubberBand>
  28. #include <QtCore/QVector>
  29. class selectableObject : public QWidget
  30. {
  31. Q_OBJECT
  32. public:
  33. selectableObject( QWidget * _parent ) :
  34. QWidget( _parent ),
  35. m_selected( false )
  36. {
  37. }
  38. virtual ~selectableObject()
  39. {
  40. }
  41. inline void setSelected( bool _selected )
  42. {
  43. m_selected = _selected;
  44. update();
  45. }
  46. inline bool isSelected() const
  47. {
  48. return( m_selected );
  49. }
  50. public slots:
  51. virtual void update()
  52. {
  53. QWidget::update();
  54. }
  55. private:
  56. bool m_selected;
  57. } ;
  58. class RubberBand : public QRubberBand
  59. {
  60. public:
  61. RubberBand( QWidget * _parent );
  62. virtual ~RubberBand();
  63. QVector<selectableObject *> selectedObjects() const;
  64. QVector<selectableObject *> selectableObjects() const;
  65. protected:
  66. void resizeEvent( QResizeEvent * _re ) override;
  67. private:
  68. };
  69. #endif