Mercurial > octave-nkf
comparison libgui/graphics/QtHandlesUtils.cc @ 19655:af0399a5aae0 gui-release
untabify QtHandles source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 23 Jan 2015 16:24:46 -0500 |
parents | be7ac98fab43 |
children | 2f4406e9dad6 |
comparison
equal
deleted
inserted
replaced
19654:a1d172bfcb2f | 19655:af0399a5aae0 |
---|---|
106 | 106 |
107 return f; | 107 return f; |
108 } | 108 } |
109 | 109 |
110 template QFont computeFont<uicontrol> (const uicontrol::properties& props, | 110 template QFont computeFont<uicontrol> (const uicontrol::properties& props, |
111 int height); | 111 int height); |
112 template QFont computeFont<uipanel> (const uipanel::properties& props, | 112 template QFont computeFont<uipanel> (const uipanel::properties& props, |
113 int height); | 113 int height); |
114 | 114 |
115 QColor fromRgb (const Matrix& rgb) | 115 QColor fromRgb (const Matrix& rgb) |
116 { | 116 { |
117 QColor c; | 117 QColor c; |
118 | 118 |
140 { | 140 { |
141 Qt::MouseButtons buttons = event->buttons (); | 141 Qt::MouseButtons buttons = event->buttons (); |
142 Qt::KeyboardModifiers mods = event->modifiers (); | 142 Qt::KeyboardModifiers mods = event->modifiers (); |
143 | 143 |
144 if (mods == Qt::NoModifier) | 144 if (mods == Qt::NoModifier) |
145 { | 145 { |
146 if (buttons == Qt::LeftButton) | 146 if (buttons == Qt::LeftButton) |
147 return std::string ("normal"); | 147 return std::string ("normal"); |
148 else if (buttons == Qt::RightButton) | 148 else if (buttons == Qt::RightButton) |
149 return std::string ("alt"); | 149 return std::string ("alt"); |
150 #if defined (Q_WS_WIN) | 150 #if defined (Q_WS_WIN) |
151 else if (buttons == (Qt::LeftButton|Qt::RightButton)) | 151 else if (buttons == (Qt::LeftButton|Qt::RightButton)) |
152 return std::string ("extend"); | 152 return std::string ("extend"); |
153 #elif defined (Q_WS_X11) | 153 #elif defined (Q_WS_X11) |
154 else if (buttons == Qt::MidButton) | 154 else if (buttons == Qt::MidButton) |
155 return std::string ("extend"); | 155 return std::string ("extend"); |
156 #endif | 156 #endif |
157 } | 157 } |
158 else if (buttons == Qt::LeftButton) | 158 else if (buttons == Qt::LeftButton) |
159 { | 159 { |
160 if (mods == Qt::ShiftModifier) | 160 if (mods == Qt::ShiftModifier) |
161 return std::string ("extend"); | 161 return std::string ("extend"); |
162 else if (mods == Qt::ControlModifier) | 162 else if (mods == Qt::ControlModifier) |
163 return std::string ("alt"); | 163 return std::string ("alt"); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 return std::string ("normal"); | 167 return std::string ("normal"); |
168 } | 168 } |
169 | 169 |
174 if (tkFig) | 174 if (tkFig) |
175 { | 175 { |
176 Container* c = tkFig->innerContainer (); | 176 Container* c = tkFig->innerContainer (); |
177 | 177 |
178 if (c) | 178 if (c) |
179 { | 179 { |
180 QPoint qp = c->mapFromGlobal (event->globalPos ()); | 180 QPoint qp = c->mapFromGlobal (event->globalPos ()); |
181 | 181 |
182 return | 182 return |
183 tkFig->properties<figure> ().map_from_boundingbox (qp.x (), | 183 tkFig->properties<figure> ().map_from_boundingbox (qp.x (), |
184 qp.y ()); | 184 qp.y ()); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 return Matrix (1, 2, 0.0); | 188 return Matrix (1, 2, 0.0); |
189 } | 189 } |
190 | 190 |
191 Qt::Alignment fromHVAlign (const caseless_str& halign, | 191 Qt::Alignment fromHVAlign (const caseless_str& halign, |
192 const caseless_str& valign) | 192 const caseless_str& valign) |
193 { | 193 { |
194 Qt::Alignment flags; | 194 Qt::Alignment flags; |
195 | 195 |
196 if (halign.compare ("left")) | 196 if (halign.compare ("left")) |
197 flags |= Qt::AlignLeft; | 197 flags |= Qt::AlignLeft; |
228 | 228 |
229 QImage img (width, height, QImage::Format_ARGB32); | 229 QImage img (width, height, QImage::Format_ARGB32); |
230 img.fill (qRgba (0, 0, 0, 0)); | 230 img.fill (qRgba (0, 0, 0, 0)); |
231 | 231 |
232 if (v.is_uint8_type ()) | 232 if (v.is_uint8_type ()) |
233 { | 233 { |
234 uint8NDArray d = v.uint8_array_value (); | 234 uint8NDArray d = v.uint8_array_value (); |
235 | 235 |
236 for (int i = 0; i < w; i++) | 236 for (int i = 0; i < w; i++) |
237 for (int j = 0; j < h; j++) | 237 for (int j = 0; j < h; j++) |
238 { | 238 { |
239 int r = d(j, i, 0); | 239 int r = d(j, i, 0); |
240 int g = d(j, i, 1); | 240 int g = d(j, i, 1); |
241 int b = d(j, i, 2); | 241 int b = d(j, i, 2); |
242 int a = 255; | 242 int a = 255; |
243 | 243 |
244 img.setPixel (x_off + i, y_off + j, qRgba (r, g, b, a)); | 244 img.setPixel (x_off + i, y_off + j, qRgba (r, g, b, a)); |
245 } | 245 } |
246 } | 246 } |
247 else if (v.is_single_type ()) | 247 else if (v.is_single_type ()) |
248 { | 248 { |
249 FloatNDArray f = v.float_array_value (); | 249 FloatNDArray f = v.float_array_value (); |
250 | 250 |
251 for (int i = 0; i < w; i++) | 251 for (int i = 0; i < w; i++) |
252 for (int j = 0; j < h; j++) | 252 for (int j = 0; j < h; j++) |
253 { | 253 { |
254 float r = f(j, i, 0); | 254 float r = f(j, i, 0); |
255 float g = f(j, i, 1); | 255 float g = f(j, i, 1); |
256 float b = f(j, i, 2); | 256 float b = f(j, i, 2); |
257 int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255); | 257 int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255); |
258 | 258 |
259 img.setPixel (x_off + i, y_off + j, | 259 img.setPixel (x_off + i, y_off + j, |
260 qRgba (xround (r * 255), | 260 qRgba (xround (r * 255), |
261 xround (g * 255), | 261 xround (g * 255), |
262 xround (b * 255), | 262 xround (b * 255), |
263 a)); | 263 a)); |
264 } | 264 } |
265 } | 265 } |
266 else if (v.is_real_type ()) | 266 else if (v.is_real_type ()) |
267 { | 267 { |
268 NDArray d = v.array_value (); | 268 NDArray d = v.array_value (); |
269 | 269 |
270 for (int i = 0; i < w; i++) | 270 for (int i = 0; i < w; i++) |
271 for (int j = 0; j < h; j++) | 271 for (int j = 0; j < h; j++) |
272 { | 272 { |
273 double r = d(j, i, 0); | 273 double r = d(j, i, 0); |
274 double g = d(j, i, 1); | 274 double g = d(j, i, 1); |
275 double b = d(j, i, 2); | 275 double b = d(j, i, 2); |
276 int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255); | 276 int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255); |
277 | 277 |
278 img.setPixel (x_off + i, y_off + j, | 278 img.setPixel (x_off + i, y_off + j, |
279 qRgba (xround (r * 255), | 279 qRgba (xround (r * 255), |
280 xround (g * 255), | 280 xround (g * 255), |
281 xround (b * 255), | 281 xround (b * 255), |
282 a)); | 282 a)); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 return img; | 286 return img; |
287 } | 287 } |
288 | 288 |
289 return QImage (); | 289 return QImage (); |