1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxSpecialButtons declarations
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef ___VBoxSpecialControls_h__
|
---|
24 | #define ___VBoxSpecialControls_h__
|
---|
25 |
|
---|
26 | /* VBox includes */
|
---|
27 | #include "QIWithRetranslateUI.h"
|
---|
28 |
|
---|
29 | /* Qt includes */
|
---|
30 | #include <QPushButton>
|
---|
31 |
|
---|
32 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
33 |
|
---|
34 | /* VBox includes */
|
---|
35 | #include "VBoxCocoaSpecialControls.h"
|
---|
36 |
|
---|
37 | /********************************************************************************
|
---|
38 | *
|
---|
39 | * A mini cancel button in the native Cocoa version.
|
---|
40 | *
|
---|
41 | ********************************************************************************/
|
---|
42 | class VBoxMiniCancelButton: public QAbstractButton
|
---|
43 | {
|
---|
44 | Q_OBJECT;
|
---|
45 |
|
---|
46 | public:
|
---|
47 | VBoxMiniCancelButton (QWidget *aParent = 0);
|
---|
48 |
|
---|
49 | void setText (const QString &aText) { mButton->setText (aText); }
|
---|
50 | void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); }
|
---|
51 |
|
---|
52 | protected:
|
---|
53 | void paintEvent (QPaintEvent * /* aEvent */) {}
|
---|
54 |
|
---|
55 | private:
|
---|
56 | VBoxCocoaButton *mButton;
|
---|
57 | };
|
---|
58 |
|
---|
59 | /********************************************************************************
|
---|
60 | *
|
---|
61 | * A help button in the native Cocoa version.
|
---|
62 | *
|
---|
63 | ********************************************************************************/
|
---|
64 | class VBoxHelpButton: public QPushButton
|
---|
65 | {
|
---|
66 | Q_OBJECT;
|
---|
67 |
|
---|
68 | public:
|
---|
69 | VBoxHelpButton (QWidget *aParent = 0);
|
---|
70 |
|
---|
71 | void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); }
|
---|
72 |
|
---|
73 | void initFrom (QPushButton * /* aOther */) {}
|
---|
74 |
|
---|
75 | protected:
|
---|
76 | void paintEvent (QPaintEvent * /* aEvent */) {}
|
---|
77 |
|
---|
78 | private:
|
---|
79 | VBoxCocoaButton *mButton;
|
---|
80 | };
|
---|
81 |
|
---|
82 | /********************************************************************************
|
---|
83 | *
|
---|
84 | * A segmented button in the native Cocoa version.
|
---|
85 | *
|
---|
86 | ********************************************************************************/
|
---|
87 | class VBoxSegmentedButton: public VBoxCocoaSegmentedButton
|
---|
88 | {
|
---|
89 | Q_OBJECT;
|
---|
90 |
|
---|
91 | public:
|
---|
92 | VBoxSegmentedButton (int aCount, QWidget *aParent = 0);
|
---|
93 |
|
---|
94 | void setIcon (int /* aSegment */, const QIcon & /* aIcon */) {}
|
---|
95 | };
|
---|
96 |
|
---|
97 | /********************************************************************************
|
---|
98 | *
|
---|
99 | * A search field in the native Cocoa version.
|
---|
100 | *
|
---|
101 | ********************************************************************************/
|
---|
102 | class VBoxSearchField: public VBoxCocoaSearchField
|
---|
103 | {
|
---|
104 | Q_OBJECT;
|
---|
105 |
|
---|
106 | public:
|
---|
107 | VBoxSearchField (QWidget *aParent = 0);
|
---|
108 | };
|
---|
109 |
|
---|
110 | #else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
111 |
|
---|
112 | /* VBox includes */
|
---|
113 | #include "QIToolButton.h"
|
---|
114 |
|
---|
115 | /* Qt includes */
|
---|
116 | #include <QLineEdit>
|
---|
117 |
|
---|
118 | /* Qt forward declarations */
|
---|
119 | class QSignalMapper;
|
---|
120 |
|
---|
121 | /********************************************************************************
|
---|
122 | *
|
---|
123 | * A mini cancel button for the other OS's.
|
---|
124 | *
|
---|
125 | ********************************************************************************/
|
---|
126 | class VBoxMiniCancelButton: public QIWithRetranslateUI<QIToolButton>
|
---|
127 | {
|
---|
128 | Q_OBJECT;
|
---|
129 |
|
---|
130 | public:
|
---|
131 | VBoxMiniCancelButton (QWidget *aParent = 0);
|
---|
132 |
|
---|
133 | protected:
|
---|
134 | void retranslateUi() {};
|
---|
135 | };
|
---|
136 |
|
---|
137 | /********************************************************************************
|
---|
138 | *
|
---|
139 | * A help button for the other OS's.
|
---|
140 | *
|
---|
141 | ********************************************************************************/
|
---|
142 | class VBoxHelpButton: public QIWithRetranslateUI<QPushButton>
|
---|
143 | {
|
---|
144 | Q_OBJECT;
|
---|
145 |
|
---|
146 | public:
|
---|
147 | VBoxHelpButton (QWidget *aParent = 0);
|
---|
148 | #ifdef Q_WS_MAC
|
---|
149 | ~VBoxHelpButton();
|
---|
150 | QSize sizeHint() const;
|
---|
151 | #endif /* Q_WS_MAC */
|
---|
152 |
|
---|
153 | void initFrom (QPushButton *aOther);
|
---|
154 |
|
---|
155 | protected:
|
---|
156 | void retranslateUi();
|
---|
157 |
|
---|
158 | #ifdef Q_WS_MAC
|
---|
159 | void paintEvent (QPaintEvent *aEvent);
|
---|
160 |
|
---|
161 | bool hitButton (const QPoint &pos) const;
|
---|
162 |
|
---|
163 | void mousePressEvent (QMouseEvent *aEvent);
|
---|
164 | void mouseReleaseEvent (QMouseEvent *aEvent);
|
---|
165 | void leaveEvent (QEvent *aEvent);
|
---|
166 |
|
---|
167 | private:
|
---|
168 | /* Private member vars */
|
---|
169 | bool mButtonPressed;
|
---|
170 |
|
---|
171 | QSize mSize;
|
---|
172 | QPixmap *mNormalPixmap;
|
---|
173 | QPixmap *mPressedPixmap;
|
---|
174 | QImage *mMask;
|
---|
175 | QRect mBRect;
|
---|
176 | #endif /* Q_WS_MAC */
|
---|
177 | };
|
---|
178 |
|
---|
179 | /********************************************************************************
|
---|
180 | *
|
---|
181 | * A segmented button for the other OS's.
|
---|
182 | *
|
---|
183 | ********************************************************************************/
|
---|
184 | class VBoxSegmentedButton: public QWidget
|
---|
185 | {
|
---|
186 | Q_OBJECT;
|
---|
187 |
|
---|
188 | public:
|
---|
189 | VBoxSegmentedButton (int aCount, QWidget *aParent = 0);
|
---|
190 | ~VBoxSegmentedButton();
|
---|
191 |
|
---|
192 | void setTitle (int aSegment, const QString &aTitle);
|
---|
193 | void setToolTip (int aSegment, const QString &aTip);
|
---|
194 | void setIcon (int aSegment, const QIcon &aIcon);
|
---|
195 | void setEnabled (int aSegment, bool fEnabled);
|
---|
196 |
|
---|
197 | void animateClick (int aSegment);
|
---|
198 |
|
---|
199 | signals:
|
---|
200 | void clicked (int aSegment);
|
---|
201 |
|
---|
202 | private:
|
---|
203 | /* Private member vars */
|
---|
204 | QList<QIToolButton*> mButtons;
|
---|
205 | QSignalMapper *mSignalMapper;
|
---|
206 | };
|
---|
207 |
|
---|
208 | /********************************************************************************
|
---|
209 | *
|
---|
210 | * A search field for the other OS's.
|
---|
211 | *
|
---|
212 | ********************************************************************************/
|
---|
213 | class VBoxSearchField: public QLineEdit
|
---|
214 | {
|
---|
215 | Q_OBJECT;
|
---|
216 |
|
---|
217 | public:
|
---|
218 | VBoxSearchField (QWidget *aParent = 0);
|
---|
219 |
|
---|
220 | void markError();
|
---|
221 | void unmarkError();
|
---|
222 |
|
---|
223 | private:
|
---|
224 | /* Private member vars */
|
---|
225 | QBrush mBaseBrush;
|
---|
226 | };
|
---|
227 |
|
---|
228 | #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
229 |
|
---|
230 | #endif /* ___VBoxSpecialControls_h__ */
|
---|
231 |
|
---|