VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISpecialControls.h@ 35740

Last change on this file since 35740 was 30694, checked in by vboxsync, 14 years ago

FE/Qt4: UITexturedSegmentedButton for non OSX

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
Line 
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 ********************************************************************************/
38class UIMiniCancelButton: public QAbstractButton
39{
40 Q_OBJECT;
41
42public:
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
49protected:
50 void paintEvent(QPaintEvent * /* pEvent */) {}
51 void resizeEvent(QResizeEvent *pEvent);
52
53private:
54 UICocoaButton *m_pButton;
55};
56
57/********************************************************************************
58 *
59 * A reset button in the native Cocoa version.
60 *
61 ********************************************************************************/
62class UIResetButton: public QAbstractButton
63{
64 Q_OBJECT;
65
66public:
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
73protected:
74 void paintEvent(QPaintEvent * /* pEvent */) {}
75 void resizeEvent(QResizeEvent *pEvent);
76
77private:
78 UICocoaButton *m_pButton;
79};
80
81/********************************************************************************
82 *
83 * A help button in the native Cocoa version.
84 *
85 ********************************************************************************/
86class UIHelpButton: public QPushButton
87{
88 Q_OBJECT;
89
90public:
91 UIHelpButton(QWidget *pParent = 0);
92
93 void setToolTip(const QString &strTip) { m_pButton->setToolTip(strTip); }
94
95 void initFrom(QPushButton * /* pOther */) {}
96
97protected:
98 void paintEvent(QPaintEvent * /* pEvent */) {}
99
100private:
101 UICocoaButton *m_pButton;
102};
103
104/********************************************************************************
105 *
106 * A segmented button in the native Cocoa version.
107 *
108 ********************************************************************************/
109class UIRoundRectSegmentedButton: public UICocoaSegmentedButton
110{
111 Q_OBJECT;
112
113public:
114 UIRoundRectSegmentedButton(int cCount, QWidget *pParent = 0);
115};
116
117class UITexturedSegmentedButton: public UICocoaSegmentedButton
118{
119 Q_OBJECT;
120
121public:
122 UITexturedSegmentedButton(int cCount, QWidget *pParent = 0);
123};
124
125/********************************************************************************
126 *
127 * A search field in the native Cocoa version.
128 *
129 ********************************************************************************/
130class UISearchField: public UICocoaSearchField
131{
132 Q_OBJECT;
133
134public:
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 */
147class QSignalMapper;
148
149/********************************************************************************
150 *
151 * A mini cancel button for the other OS's.
152 *
153 ********************************************************************************/
154class UIMiniCancelButton: public QIWithRetranslateUI<QIToolButton>
155{
156 Q_OBJECT;
157
158public:
159 UIMiniCancelButton(QWidget *pParent = 0);
160 void removeBorder();
161
162protected:
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 ********************************************************************************/
171class UIResetButton: public UIMiniCancelButton
172{
173 Q_OBJECT;
174
175public:
176 UIResetButton(QWidget *pParent = 0)
177 : UIMiniCancelButton(pParent) {}
178};
179
180/********************************************************************************
181 *
182 * A help button for the other OS's.
183 *
184 ********************************************************************************/
185class UIHelpButton: public QIWithRetranslateUI<QPushButton>
186{
187 Q_OBJECT;
188
189public:
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
198protected:
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
210private:
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 ********************************************************************************/
227class UIRoundRectSegmentedButton: public QWidget
228{
229 Q_OBJECT;
230
231public:
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
242signals:
243 void clicked(int iSegment);
244
245protected:
246 /* Protected member vars */
247 QList<QIToolButton*> m_pButtons;
248 QSignalMapper *m_pSignalMapper;
249};
250
251class UITexturedSegmentedButton: public UIRoundRectSegmentedButton
252{
253 Q_OBJECT;
254
255public:
256 UITexturedSegmentedButton(int cCount, QWidget *pParent = 0);
257};
258
259/********************************************************************************
260 *
261 * A search field for the other OS's.
262 *
263 ********************************************************************************/
264class UISearchField: public QLineEdit
265{
266 Q_OBJECT;
267
268public:
269 UISearchField(QWidget *pParent = 0);
270
271 void markError();
272 void unmarkError();
273
274private:
275 /* Private member vars */
276 QBrush m_baseBrush;
277};
278
279#endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
280
281#endif /* ___VBoxSpecialControls_h__ */
282
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use