author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/ocolorbutton.cpp | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
-rw-r--r-- | libopie/ocolorbutton.cpp | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/libopie/ocolorbutton.cpp b/libopie/ocolorbutton.cpp deleted file mode 100644 index 298dba2..0000000 --- a/libopie/ocolorbutton.cpp +++ b/dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <opie/colorpopupmenu.h> | ||
30 | #include <opie/ocolorbutton.h> | ||
31 | |||
32 | #include <qpe/resource.h> | ||
33 | |||
34 | struct OColorButtonPrivate { | ||
35 | QPopupMenu *m_menu; | ||
36 | QColor m_color; | ||
37 | }; | ||
38 | |||
39 | |||
40 | /** | ||
41 | * This concstructs a Color Button with @param color as the start color | ||
42 | * It'll use a OColorPopupMenu internally | ||
43 | * | ||
44 | * @param parent The parent of the Color Button | ||
45 | * @param color The color from where to start on | ||
46 | * @param name @see QObject | ||
47 | */ | ||
48 | OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) | ||
49 | : QPushButton ( parent, name ) | ||
50 | { | ||
51 | d = new OColorButtonPrivate; | ||
52 | |||
53 | d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); | ||
54 | setPopup ( d-> m_menu ); | ||
55 | //setPopupDelay ( 0 ); | ||
56 | connect ( d-> m_menu, SIGNAL( colorSelected(const QColor&)), this, SLOT( updateColor(const QColor&))); | ||
57 | |||
58 | updateColor ( color ); | ||
59 | |||
60 | QSize s = sizeHint ( ) + QSize ( 12, 0 ); | ||
61 | setMinimumSize ( s ); | ||
62 | setMaximumSize ( s. width ( ) * 2, s. height ( )); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * This destructs the object | ||
67 | */ | ||
68 | OColorButton::~OColorButton ( ) | ||
69 | { | ||
70 | delete d; | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * @return Returns the current color of the button | ||
75 | */ | ||
76 | QColor OColorButton::color ( ) const | ||
77 | { | ||
78 | return d-> m_color; | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * This method sets the color of the button | ||
83 | * @param c The color to be set. | ||
84 | */ | ||
85 | void OColorButton::setColor ( const QColor &c ) | ||
86 | { | ||
87 | updateColor ( c ); | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * @internal | ||
92 | */ | ||
93 | void OColorButton::updateColor ( const QColor &c ) | ||
94 | { | ||
95 | d-> m_color = c; | ||
96 | |||
97 | QImage img ( 16, 16, 32 ); | ||
98 | img. fill ( 0 ); | ||
99 | |||
100 | int r, g, b; | ||
101 | c. rgb ( &r, &g, &b ); | ||
102 | |||
103 | int w = img. width ( ); | ||
104 | int h = img. height ( ); | ||
105 | |||
106 | int dx = w * 20 / 100; // 15% | ||
107 | int dy = h * 20 / 100; | ||
108 | |||
109 | for ( int y = 0; y < h; y++ ) { | ||
110 | for ( int x = 0; x < w; x++ ) { | ||
111 | double alpha = 1.0; | ||
112 | |||
113 | if ( x < dx ) | ||
114 | alpha *= ( double ( x + 1 ) / dx ); | ||
115 | else if ( x >= w - dx ) | ||
116 | alpha *= ( double ( w - x ) / dx ); | ||
117 | if ( y < dy ) | ||
118 | alpha *= ( double ( y + 1 ) / dy ); | ||
119 | else if ( y >= h - dy ) | ||
120 | alpha *= ( double ( h - y ) / dy ); | ||
121 | |||
122 | int a = int ( alpha * 255.0 ); | ||
123 | if ( a < 0 ) | ||
124 | a = 0; | ||
125 | if ( a > 255 ) | ||
126 | a = 255; | ||
127 | |||
128 | img. setPixel ( x, y, qRgba ( r, g, b, a )); | ||
129 | } | ||
130 | } | ||
131 | img. setAlphaBuffer ( true ); | ||
132 | |||
133 | QPixmap pix; | ||
134 | pix. convertFromImage ( img ); | ||
135 | setPixmap ( pix ); | ||
136 | |||
137 | emit colorSelected ( c ); | ||
138 | } | ||
139 | |||