1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxSpecialButtons declarations
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009-2010 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef ___VBoxSpecialControls_h__
|
---|
20 | #define ___VBoxSpecialControls_h__
|
---|
21 |
|
---|
22 | /* VBox includes */
|
---|
23 | #include "QIWithRetranslateUI.h"
|
---|
24 |
|
---|
25 | /* Qt includes */
|
---|
26 | #include <QPushButton>
|
---|
27 |
|
---|
28 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
29 |
|
---|
30 | /* VBox includes */
|
---|
31 | #include "UICocoaSpecialControls.h"
|
---|
32 |
|
---|
33 | /********************************************************************************
|
---|
34 | *
|
---|
35 | * A mini cancel button in the native Cocoa version.
|
---|
36 | *
|
---|
37 | ********************************************************************************/
|
---|
38 | class UIMiniCancelButton: public QAbstractButton
|
---|
39 | {
|
---|
40 | Q_OBJECT;
|
---|
41 |
|
---|
42 | public:
|
---|
43 | UIMiniCancelButton(QWidget *pParent = 0);
|
---|
44 |
|
---|
45 | void setText(const QString &strText) { m_pButton->setText(strText); }
|
---|
46 | void setToolTip(const QString &strTip) { m_pButton->setToolTip(strTip); }
|
---|
47 | void removeBorder() {}
|
---|
48 |
|
---|
49 | protected:
|
---|
50 | void paintEvent(QPaintEvent * /* pEvent */) {}
|
---|
51 | void resizeEvent(QResizeEvent *pEvent);
|
---|
52 |
|
---|
53 | private:
|
---|
54 | UICocoaButton *m_pButton;
|
---|
55 | };
|
---|
56 |
|
---|
57 | /********************************************************************************
|
---|
58 | *
|
---|
59 | * A reset button in the native Cocoa version.
|
---|
60 | *
|
---|
61 | ********************************************************************************/
|
---|
62 | class UIResetButton: public QAbstractButton
|
---|
63 | {
|
---|
64 | Q_OBJECT;
|
---|
65 |
|
---|
66 | public:
|
---|
67 | UIResetButton(QWidget *pParent = 0);
|
---|
68 |
|
---|
69 | void setText(const QString &strText) { m_pButton->setText(strText); }
|
---|
70 | void setToolTip(const QString &strTip) { m_pButton->setToolTip(strTip); }
|
---|
71 | void removeBorder() {}
|
---|
72 |
|
---|
73 | protected:
|
---|
74 | void paintEvent(QPaintEvent * /* pEvent */) {}
|
---|
75 | void resizeEvent(QResizeEvent *pEvent);
|
---|
76 |
|
---|
77 | private:
|
---|
78 | UICocoaButton *m_pButton;
|
---|
79 | };
|
---|
80 |
|
---|
81 | /********************************************************************************
|
---|
82 | *
|
---|
83 | * A help button in the native Cocoa version.
|
---|
84 | *
|
---|
85 | ********************************************************************************/
|
---|
86 | class UIHelpButton: public QPushButton
|
---|
87 | {
|
---|
88 | Q_OBJECT;
|
---|
89 |
|
---|
90 | public:
|
---|
91 | UIHelpButton(QWidget *pParent = 0);
|
---|
92 |
|
---|
93 | void setToolTip(const QString &strTip) { m_pButton->setToolTip(strTip); }
|
---|
94 |
|
---|
95 | void initFrom(QPushButton * /* pOther */) {}
|
---|
96 |
|
---|
97 | protected:
|
---|
98 | void paintEvent(QPaintEvent * /* pEvent */) {}
|
---|
99 |
|
---|
100 | private:
|
---|
101 | UICocoaButton *m_pButton;
|
---|
102 | };
|
---|
103 |
|
---|
104 | /********************************************************************************
|
---|
105 | *
|
---|
106 | * A segmented button in the native Cocoa version.
|
---|
107 | *
|
---|
108 | ********************************************************************************/
|
---|
109 | class UIRoundRectSegmentedButton: public UICocoaSegmentedButton
|
---|
110 | {
|
---|
111 | Q_OBJECT;
|
---|
112 |
|
---|
113 | public:
|
---|
114 | UIRoundRectSegmentedButton(int cCount, QWidget *pParent = 0);
|
---|
115 | };
|
---|
116 |
|
---|
117 | class UITexturedSegmentedButton: public UICocoaSegmentedButton
|
---|
118 | {
|
---|
119 | Q_OBJECT;
|
---|
120 |
|
---|
121 | public:
|
---|
122 | UITexturedSegmentedButton(int cCount, QWidget *pParent = 0);
|
---|
123 | };
|
---|
124 |
|
---|
125 | /********************************************************************************
|
---|
126 | *
|
---|
127 | * A search field in the native Cocoa version.
|
---|
128 | *
|
---|
129 | ********************************************************************************/
|
---|
130 | class UISearchField: public UICocoaSearchField
|
---|
131 | {
|
---|
132 | Q_OBJECT;
|
---|
133 |
|
---|
134 | public:
|
---|
135 | UISearchField(QWidget *pParent = 0);
|
---|
136 | };
|
---|
137 |
|
---|
138 | #else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
139 |
|
---|
140 | /* VBox includes */
|
---|
141 | #include "QIToolButton.h"
|
---|
142 |
|
---|
143 | /* Qt includes */
|
---|
144 | #include <QLineEdit>
|
---|
145 |
|
---|
146 | /* Qt forward declarations */
|
---|
147 | class QSignalMapper;
|
---|
148 |
|
---|
149 | /********************************************************************************
|
---|
150 | *
|
---|
151 | * A mini cancel button for the other OS's.
|
---|
152 | *
|
---|
153 | ********************************************************************************/
|
---|
154 | class UIMiniCancelButton: public QIWithRetranslateUI<QIToolButton>
|
---|
155 | {
|
---|
156 | Q_OBJECT;
|
---|
157 |
|
---|
158 | public:
|
---|
159 | UIMiniCancelButton(QWidget *pParent = 0);
|
---|
160 | void removeBorder();
|
---|
161 |
|
---|
162 | protected:
|
---|
163 | void retranslateUi() {};
|
---|
164 | };
|
---|
165 |
|
---|
166 | /********************************************************************************
|
---|
167 | *
|
---|
168 | * A reset button for the other OS's (same as the cancel button for now)
|
---|
169 | *
|
---|
170 | ********************************************************************************/
|
---|
171 | class UIResetButton: public UIMiniCancelButton
|
---|
172 | {
|
---|
173 | Q_OBJECT;
|
---|
174 |
|
---|
175 | public:
|
---|
176 | UIResetButton(QWidget *pParent = 0)
|
---|
177 | : UIMiniCancelButton(pParent) {}
|
---|
178 | };
|
---|
179 |
|
---|
180 | /********************************************************************************
|
---|
181 | *
|
---|
182 | * A help button for the other OS's.
|
---|
183 | *
|
---|
184 | ********************************************************************************/
|
---|
185 | class UIHelpButton: public QIWithRetranslateUI<QPushButton>
|
---|
186 | {
|
---|
187 | Q_OBJECT;
|
---|
188 |
|
---|
189 | public:
|
---|
190 | UIHelpButton(QWidget *pParent = 0);
|
---|
191 | #ifdef Q_WS_MAC
|
---|
192 | ~UIHelpButton();
|
---|
193 | QSize sizeHint() const;
|
---|
194 | #endif /* Q_WS_MAC */
|
---|
195 |
|
---|
196 | void initFrom(QPushButton *pOther);
|
---|
197 |
|
---|
198 | protected:
|
---|
199 | void retranslateUi();
|
---|
200 |
|
---|
201 | #ifdef Q_WS_MAC
|
---|
202 | void paintEvent(QPaintEvent *pEvent);
|
---|
203 |
|
---|
204 | bool hitButton(const QPoint &pos) const;
|
---|
205 |
|
---|
206 | void mousePressEvent(QMouseEvent *pEvent);
|
---|
207 | void mouseReleaseEvent(QMouseEvent *pEvent);
|
---|
208 | void leaveEvent(QEvent *pEvent);
|
---|
209 |
|
---|
210 | private:
|
---|
211 | /* Private member vars */
|
---|
212 | bool m_pButtonPressed;
|
---|
213 |
|
---|
214 | QSize m_size;
|
---|
215 | QPixmap *m_pNormalPixmap;
|
---|
216 | QPixmap *m_pPressedPixmap;
|
---|
217 | QImage *m_pMask;
|
---|
218 | QRect m_BRect;
|
---|
219 | #endif /* Q_WS_MAC */
|
---|
220 | };
|
---|
221 |
|
---|
222 | /********************************************************************************
|
---|
223 | *
|
---|
224 | * A segmented button for the other OS's.
|
---|
225 | *
|
---|
226 | ********************************************************************************/
|
---|
227 | class UIRoundRectSegmentedButton: public QWidget
|
---|
228 | {
|
---|
229 | Q_OBJECT;
|
---|
230 |
|
---|
231 | public:
|
---|
232 | UIRoundRectSegmentedButton(int aCount, QWidget *pParent = 0);
|
---|
233 | ~UIRoundRectSegmentedButton();
|
---|
234 |
|
---|
235 | void setTitle(int iSegment, const QString &aTitle);
|
---|
236 | void setToolTip(int iSegment, const QString &strTip);
|
---|
237 | void setIcon(int iSegment, const QIcon &icon);
|
---|
238 | void setEnabled(int iSegment, bool fEnabled);
|
---|
239 |
|
---|
240 | void animateClick(int iSegment);
|
---|
241 |
|
---|
242 | signals:
|
---|
243 | void clicked(int iSegment);
|
---|
244 |
|
---|
245 | protected:
|
---|
246 | /* Protected member vars */
|
---|
247 | QList<QIToolButton*> m_pButtons;
|
---|
248 | QSignalMapper *m_pSignalMapper;
|
---|
249 | };
|
---|
250 |
|
---|
251 | class UITexturedSegmentedButton: public UIRoundRectSegmentedButton
|
---|
252 | {
|
---|
253 | Q_OBJECT;
|
---|
254 |
|
---|
255 | public:
|
---|
256 | UITexturedSegmentedButton(int cCount, QWidget *pParent = 0);
|
---|
257 | };
|
---|
258 |
|
---|
259 | /********************************************************************************
|
---|
260 | *
|
---|
261 | * A search field for the other OS's.
|
---|
262 | *
|
---|
263 | ********************************************************************************/
|
---|
264 | class UISearchField: public QLineEdit
|
---|
265 | {
|
---|
266 | Q_OBJECT;
|
---|
267 |
|
---|
268 | public:
|
---|
269 | UISearchField(QWidget *pParent = 0);
|
---|
270 |
|
---|
271 | void markError();
|
---|
272 | void unmarkError();
|
---|
273 |
|
---|
274 | private:
|
---|
275 | /* Private member vars */
|
---|
276 | QBrush m_baseBrush;
|
---|
277 | };
|
---|
278 |
|
---|
279 | #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
280 |
|
---|
281 | #endif /* ___VBoxSpecialControls_h__ */
|
---|
282 |
|
---|