/src/VBox/Frontends/VirtualBox/src/widgets/VBoxSpecialControls.h

https://gitlab.com/ufo/virtualbox-ose-3-1-8 · C Header · 231 lines · 111 code · 51 blank · 69 comment · 0 complexity · 28968daa68dd7bbd99226ec78af257d2 MD5 · raw file

  1. /** @file
  2. *
  3. * VBox frontends: Qt GUI ("VirtualBox"):
  4. * VBoxSpecialButtons declarations
  5. */
  6. /*
  7. * Copyright (C) 2009 Sun Microsystems, Inc.
  8. *
  9. * This file is part of VirtualBox Open Source Edition (OSE), as
  10. * available from http://www.virtualbox.org. This file is free software;
  11. * you can redistribute it and/or modify it under the terms of the GNU
  12. * General Public License (GPL) as published by the Free Software
  13. * Foundation, in version 2 as it comes in the "COPYING" file of the
  14. * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  15. * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  16. *
  17. * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
  18. * Clara, CA 95054 USA or visit http://www.sun.com if you need
  19. * additional information or have any questions.
  20. */
  21. #ifndef ___VBoxSpecialControls_h__
  22. #define ___VBoxSpecialControls_h__
  23. /* VBox includes */
  24. #include "QIWithRetranslateUI.h"
  25. /* Qt includes */
  26. #include <QPushButton>
  27. #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
  28. /* VBox includes */
  29. #include "VBoxCocoaSpecialControls.h"
  30. /********************************************************************************
  31. *
  32. * A mini cancel button in the native Cocoa version.
  33. *
  34. ********************************************************************************/
  35. class VBoxMiniCancelButton: public QAbstractButton
  36. {
  37. Q_OBJECT;
  38. public:
  39. VBoxMiniCancelButton (QWidget *aParent = 0);
  40. void setText (const QString &aText) { mButton->setText (aText); }
  41. void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); }
  42. protected:
  43. void paintEvent (QPaintEvent * /* aEvent */) {}
  44. private:
  45. VBoxCocoaButton *mButton;
  46. };
  47. /********************************************************************************
  48. *
  49. * A help button in the native Cocoa version.
  50. *
  51. ********************************************************************************/
  52. class VBoxHelpButton: public QPushButton
  53. {
  54. Q_OBJECT;
  55. public:
  56. VBoxHelpButton (QWidget *aParent = 0);
  57. void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); }
  58. void initFrom (QPushButton * /* aOther */) {}
  59. protected:
  60. void paintEvent (QPaintEvent * /* aEvent */) {}
  61. private:
  62. VBoxCocoaButton *mButton;
  63. };
  64. /********************************************************************************
  65. *
  66. * A segmented button in the native Cocoa version.
  67. *
  68. ********************************************************************************/
  69. class VBoxSegmentedButton: public VBoxCocoaSegmentedButton
  70. {
  71. Q_OBJECT;
  72. public:
  73. VBoxSegmentedButton (int aCount, QWidget *aParent = 0);
  74. void setIcon (int /* aSegment */, const QIcon & /* aIcon */) {}
  75. };
  76. /********************************************************************************
  77. *
  78. * A search field in the native Cocoa version.
  79. *
  80. ********************************************************************************/
  81. class VBoxSearchField: public VBoxCocoaSearchField
  82. {
  83. Q_OBJECT;
  84. public:
  85. VBoxSearchField (QWidget *aParent = 0);
  86. };
  87. #else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
  88. /* VBox includes */
  89. #include "QIToolButton.h"
  90. /* Qt includes */
  91. #include <QLineEdit>
  92. /* Qt forward declarations */
  93. class QSignalMapper;
  94. /********************************************************************************
  95. *
  96. * A mini cancel button for the other OS's.
  97. *
  98. ********************************************************************************/
  99. class VBoxMiniCancelButton: public QIWithRetranslateUI<QIToolButton>
  100. {
  101. Q_OBJECT;
  102. public:
  103. VBoxMiniCancelButton (QWidget *aParent = 0);
  104. protected:
  105. void retranslateUi() {};
  106. };
  107. /********************************************************************************
  108. *
  109. * A help button for the other OS's.
  110. *
  111. ********************************************************************************/
  112. class VBoxHelpButton: public QIWithRetranslateUI<QPushButton>
  113. {
  114. Q_OBJECT;
  115. public:
  116. VBoxHelpButton (QWidget *aParent = 0);
  117. #ifdef Q_WS_MAC
  118. ~VBoxHelpButton();
  119. QSize sizeHint() const;
  120. #endif /* Q_WS_MAC */
  121. void initFrom (QPushButton *aOther);
  122. protected:
  123. void retranslateUi();
  124. #ifdef Q_WS_MAC
  125. void paintEvent (QPaintEvent *aEvent);
  126. bool hitButton (const QPoint &pos) const;
  127. void mousePressEvent (QMouseEvent *aEvent);
  128. void mouseReleaseEvent (QMouseEvent *aEvent);
  129. void leaveEvent (QEvent *aEvent);
  130. private:
  131. /* Private member vars */
  132. bool mButtonPressed;
  133. QSize mSize;
  134. QPixmap *mNormalPixmap;
  135. QPixmap *mPressedPixmap;
  136. QImage *mMask;
  137. QRect mBRect;
  138. #endif /* Q_WS_MAC */
  139. };
  140. /********************************************************************************
  141. *
  142. * A segmented button for the other OS's.
  143. *
  144. ********************************************************************************/
  145. class VBoxSegmentedButton: public QWidget
  146. {
  147. Q_OBJECT;
  148. public:
  149. VBoxSegmentedButton (int aCount, QWidget *aParent = 0);
  150. ~VBoxSegmentedButton();
  151. void setTitle (int aSegment, const QString &aTitle);
  152. void setToolTip (int aSegment, const QString &aTip);
  153. void setIcon (int aSegment, const QIcon &aIcon);
  154. void setEnabled (int aSegment, bool fEnabled);
  155. void animateClick (int aSegment);
  156. signals:
  157. void clicked (int aSegment);
  158. private:
  159. /* Private member vars */
  160. QList<QIToolButton*> mButtons;
  161. QSignalMapper *mSignalMapper;
  162. };
  163. /********************************************************************************
  164. *
  165. * A search field for the other OS's.
  166. *
  167. ********************************************************************************/
  168. class VBoxSearchField: public QLineEdit
  169. {
  170. Q_OBJECT;
  171. public:
  172. VBoxSearchField (QWidget *aParent = 0);
  173. void markError();
  174. void unmarkError();
  175. private:
  176. /* Private member vars */
  177. QBrush mBaseBrush;
  178. };
  179. #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
  180. #endif /* ___VBoxSpecialControls_h__ */