1 | /* $Id: UISpecialControls.h 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISpecialControls declarations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2019 Oracle Corporation
|
---|
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 |
|
---|
18 | #ifndef ___VBoxSpecialControls_h__
|
---|
19 | #define ___VBoxSpecialControls_h__
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QPushButton>
|
---|
26 | #ifndef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
27 | # include <QLineEdit>
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | /* GUI includes: */
|
---|
31 | #include "QIWithRetranslateUI.h"
|
---|
32 | #include "UILibraryDefs.h"
|
---|
33 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
34 | # include "UICocoaSpecialControls.h"
|
---|
35 | #else
|
---|
36 | # include "QIToolButton.h"
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | /* Forward declarations: */
|
---|
40 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
41 | class UICocoaButton;
|
---|
42 | #endif
|
---|
43 |
|
---|
44 |
|
---|
45 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
46 |
|
---|
47 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
48 | class SHARED_LIBRARY_STUFF UIMiniCancelButton : public QAbstractButton
|
---|
49 | {
|
---|
50 | Q_OBJECT;
|
---|
51 |
|
---|
52 | public:
|
---|
53 |
|
---|
54 | /** Constructs mini cancel-button passing @a pParent to the base-class. */
|
---|
55 | UIMiniCancelButton(QWidget *pParent = 0);
|
---|
56 |
|
---|
57 | /** Defines button @a strText. */
|
---|
58 | void setText(const QString &strText) { m_pButton->setText(strText); }
|
---|
59 | /** Defines button @a strToolTip. */
|
---|
60 | void setToolTip(const QString &strToolTip) { m_pButton->setToolTip(strToolTip); }
|
---|
61 | /** Removes button border. */
|
---|
62 | void removeBorder() {}
|
---|
63 |
|
---|
64 | protected:
|
---|
65 |
|
---|
66 | /** Handles paint @a pEvent. */
|
---|
67 | virtual void paintEvent(QPaintEvent *pEvent) /* override */ { Q_UNUSED(pEvent); }
|
---|
68 | /** Handles resize @a pEvent. */
|
---|
69 | virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
|
---|
70 |
|
---|
71 | private:
|
---|
72 |
|
---|
73 | /** Holds the wrapped cocoa button instance. */
|
---|
74 | UICocoaButton *m_pButton;
|
---|
75 | };
|
---|
76 |
|
---|
77 |
|
---|
78 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
79 | class SHARED_LIBRARY_STUFF UIHelpButton : public QPushButton
|
---|
80 | {
|
---|
81 | Q_OBJECT;
|
---|
82 |
|
---|
83 | public:
|
---|
84 |
|
---|
85 | /** Constructs help-button passing @a pParent to the base-class. */
|
---|
86 | UIHelpButton(QWidget *pParent = 0);
|
---|
87 |
|
---|
88 | /** Defines button @a strToolTip. */
|
---|
89 | void setToolTip(const QString &strToolTip) { m_pButton->setToolTip(strToolTip); }
|
---|
90 |
|
---|
91 | /** Inits this button from pOther. */
|
---|
92 | void initFrom(QPushButton *pOther) { Q_UNUSED(pOther); }
|
---|
93 |
|
---|
94 | protected:
|
---|
95 |
|
---|
96 | /** Handles paint @a pEvent. */
|
---|
97 | virtual void paintEvent(QPaintEvent *pEvent) /* override */ { Q_UNUSED(pEvent); }
|
---|
98 |
|
---|
99 | private:
|
---|
100 |
|
---|
101 | /** Holds the wrapped cocoa button instance. */
|
---|
102 | UICocoaButton *m_pButton;
|
---|
103 | };
|
---|
104 |
|
---|
105 | #else /* !VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
106 |
|
---|
107 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
108 | class SHARED_LIBRARY_STUFF UIMiniCancelButton : public QIWithRetranslateUI<QIToolButton>
|
---|
109 | {
|
---|
110 | Q_OBJECT;
|
---|
111 |
|
---|
112 | public:
|
---|
113 |
|
---|
114 | /** Constructs mini cancel-button passing @a pParent to the base-class. */
|
---|
115 | UIMiniCancelButton(QWidget *pParent = 0);
|
---|
116 |
|
---|
117 | protected:
|
---|
118 |
|
---|
119 | /** Handles translation event. */
|
---|
120 | virtual void retranslateUi() /* override */ {};
|
---|
121 | };
|
---|
122 |
|
---|
123 |
|
---|
124 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
125 | class SHARED_LIBRARY_STUFF UIHelpButton : public QIWithRetranslateUI<QPushButton>
|
---|
126 | {
|
---|
127 | Q_OBJECT;
|
---|
128 |
|
---|
129 | public:
|
---|
130 |
|
---|
131 | /** Constructs help-button passing @a pParent to the base-class. */
|
---|
132 | UIHelpButton(QWidget *pParent = 0);
|
---|
133 |
|
---|
134 | # ifdef VBOX_WS_MAC
|
---|
135 | /** Destructs help-button. */
|
---|
136 | ~UIHelpButton();
|
---|
137 |
|
---|
138 | /** Returns size-hint. */
|
---|
139 | QSize sizeHint() const;
|
---|
140 | # endif /* VBOX_WS_MAC */
|
---|
141 |
|
---|
142 | /** Inits this button from pOther. */
|
---|
143 | void initFrom(QPushButton *pOther);
|
---|
144 |
|
---|
145 | protected:
|
---|
146 |
|
---|
147 | /** Handles translation event. */
|
---|
148 | void retranslateUi();
|
---|
149 |
|
---|
150 | # ifdef VBOX_WS_MAC
|
---|
151 | /** Handles button hit as certain @a position. */
|
---|
152 | bool hitButton(const QPoint &position) const;
|
---|
153 |
|
---|
154 | /** Handles paint @a pEvent. */
|
---|
155 | virtual void paintEvent(QPaintEvent *pEvent) /* override */;
|
---|
156 |
|
---|
157 | /** Handles mouse-press @a pEvent. */
|
---|
158 | virtual void mousePressEvent(QMouseEvent *pEvent) /* override */;
|
---|
159 | /** Handles mouse-release @a pEvent. */
|
---|
160 | virtual void mouseReleaseEvent(QMouseEvent *pEvent) /* override */;
|
---|
161 | /** Handles mouse-leave @a pEvent. */
|
---|
162 | virtual void leaveEvent(QEvent *pEvent) /* override */;
|
---|
163 |
|
---|
164 | private:
|
---|
165 |
|
---|
166 | /** Holds the pressed button instance. */
|
---|
167 | bool m_pButtonPressed;
|
---|
168 |
|
---|
169 | /** Holds the button size. */
|
---|
170 | QSize m_size;
|
---|
171 |
|
---|
172 | /** Holds the normal pixmap instance. */
|
---|
173 | QPixmap *m_pNormalPixmap;
|
---|
174 | /** Holds the pressed pixmap instance. */
|
---|
175 | QPixmap *m_pPressedPixmap;
|
---|
176 |
|
---|
177 | /** Holds the button mask instance. */
|
---|
178 | QImage *m_pMask;
|
---|
179 |
|
---|
180 | /** Holds the button rect. */
|
---|
181 | QRect m_BRect;
|
---|
182 | # endif /* VBOX_WS_MAC */
|
---|
183 | };
|
---|
184 |
|
---|
185 | #endif /* !VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
186 |
|
---|
187 |
|
---|
188 | #endif /* !___UISpecialControls_h___ */
|
---|
189 |
|
---|