ctkCheckBoxPixmaps.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. /*=========================================================================
  11. Program: ParaView
  12. Module: $RCSfile: pqCheckBoxPixMaps.h,v $
  13. Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
  14. All rights reserved.
  15. ParaView is a free software; you can redistribute it and/or modify it
  16. under the terms of the ParaView license version 1.2.
  17. See License_v1.2.txt for the full ParaView license.
  18. A copy of this license can be obtained by contacting
  19. Kitware Inc.
  20. 28 Corporate Drive
  21. Clifton Park, NY 12065
  22. USA
  23. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
  27. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  28. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  31. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. ========================================================================*/
  35. #ifndef __ctkCheckBoxPixmaps_h
  36. #define __ctkCheckBoxPixmaps_h
  37. /// Qt includes
  38. #include <QObject>
  39. #include <QPixmap>
  40. /// CTK includes
  41. #include "CTKWidgetsExport.h"
  42. class QWidget;
  43. /// ctkCheckBoxPixmaps is a helper class that can used to create pixmaps for
  44. /// checkboxs in various states. This is useful for showing checkboxes in qt-views.
  45. class CTK_WIDGETS_EXPORT ctkCheckBoxPixmaps : public QObject
  46. {
  47. Q_OBJECT
  48. typedef QObject Superclass;
  49. public:
  50. /// parent cannot be NULL.
  51. ctkCheckBoxPixmaps(QWidget* parent);
  52. /// Returns a pixmap for the given state .
  53. QPixmap getPixmap(Qt::CheckState state, bool active) const;
  54. QPixmap getPixmap(int state, bool active) const
  55. {
  56. return this->getPixmap(static_cast<Qt::CheckState>(state), active);
  57. }
  58. private:
  59. Q_DISABLE_COPY(ctkCheckBoxPixmaps)
  60. enum PixmapStateIndex
  61. {
  62. Checked = 0,
  63. PartiallyChecked = 1,
  64. UnChecked = 2,
  65. // All active states in lower half
  66. Checked_Active = 3,
  67. PartiallyChecked_Active = 4,
  68. UnChecked_Active = 5,
  69. PixmapCount = 6
  70. };
  71. QPixmap Pixmaps[6];
  72. };
  73. #endif