Diffstat (limited to 'noncore/graphics/opie-eye/gui/imagescrollview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 586 |
1 files changed, 0 insertions, 586 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp deleted file mode 100644 index 3bb07a7..0000000 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/dev/null | |||
@@ -1,586 +0,0 @@ | |||
1 | #include "imagescrollview.h" | ||
2 | |||
3 | #include "lib/oimagezoomer.h" | ||
4 | |||
5 | #include <opie2/odebug.h> | ||
6 | #include <opie2/oapplication.h> | ||
7 | #include <opie2/owait.h> | ||
8 | |||
9 | #include <qimage.h> | ||
10 | #include <qlayout.h> | ||
11 | #include <qpe/qcopenvelope_qws.h> | ||
12 | |||
13 | /* for usage with the bitset */ | ||
14 | #define AUTO_SCALE 0 | ||
15 | #define AUTO_ROTATE 1 | ||
16 | #define SHOW_ZOOMER 2 | ||
17 | #define FIRST_RESIZE_DONE 3 | ||
18 | #define IMAGE_IS_JPEG 4 | ||
19 | #define IMAGE_SCALED_LOADED 5 | ||
20 | |||
21 | #define SCROLLVIEW_BITSET_SIZE 6 | ||
22 | |||
23 | namespace Opie { | ||
24 | namespace MM { | ||
25 | OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f ) | ||
26 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(), | ||
27 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | ||
28 | { | ||
29 | _zoomer = 0; | ||
30 | m_states[AUTO_SCALE]=true; | ||
31 | m_states[AUTO_ROTATE]=true; | ||
32 | m_states[FIRST_RESIZE_DONE]=false; | ||
33 | m_states[IMAGE_IS_JPEG]=false; | ||
34 | m_states[IMAGE_SCALED_LOADED]=false; | ||
35 | m_states[SHOW_ZOOMER]=true; | ||
36 | init(); | ||
37 | } | ||
38 | |||
39 | OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | ||
40 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img), | ||
41 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | ||
42 | { | ||
43 | _zoomer = 0; | ||
44 | m_states[AUTO_SCALE]=always_scale; | ||
45 | m_states[AUTO_ROTATE]=rfit; | ||
46 | m_states[FIRST_RESIZE_DONE]=false; | ||
47 | m_states[IMAGE_IS_JPEG]=false; | ||
48 | m_states[IMAGE_SCALED_LOADED]=false; | ||
49 | m_states[SHOW_ZOOMER]=true; | ||
50 | _original_data.convertDepth(QPixmap::defaultDepth()); | ||
51 | _original_data.setAlphaBuffer(false); | ||
52 | init(); | ||
53 | } | ||
54 | |||
55 | OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | ||
56 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | ||
57 | { | ||
58 | _zoomer = 0; | ||
59 | m_states.resize(SCROLLVIEW_BITSET_SIZE); | ||
60 | m_states[AUTO_SCALE]=always_scale; | ||
61 | m_states[AUTO_ROTATE]=rfit; | ||
62 | m_states[FIRST_RESIZE_DONE]=false; | ||
63 | m_states[IMAGE_IS_JPEG]=false; | ||
64 | m_states[IMAGE_SCALED_LOADED]=false; | ||
65 | m_states[SHOW_ZOOMER]=true; | ||
66 | init(); | ||
67 | setImage(img); | ||
68 | } | ||
69 | |||
70 | void OImageScrollView::setImage(const QImage&img) | ||
71 | { | ||
72 | _image_data = QImage(); | ||
73 | _original_data=img; | ||
74 | _original_data.convertDepth(QPixmap::defaultDepth()); | ||
75 | _original_data.setAlphaBuffer(false); | ||
76 | m_lastName = ""; | ||
77 | setImageIsJpeg(false); | ||
78 | setImageScaledLoaded(false); | ||
79 | if (FirstResizeDone()) { | ||
80 | generateImage(); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | void OImageScrollView::loadJpeg(bool interncall) | ||
85 | { | ||
86 | if (m_lastName.isEmpty()) return; | ||
87 | QImageIO iio( m_lastName, 0l ); | ||
88 | QString param; | ||
89 | bool real_load = false; | ||
90 | if (AutoScale()) { | ||
91 | if (!interncall) { | ||
92 | int wid, hei; | ||
93 | wid = QApplication::desktop()->width(); | ||
94 | hei = QApplication::desktop()->height(); | ||
95 | if (hei>wid) { | ||
96 | wid = hei; | ||
97 | } else { | ||
98 | hei = wid; | ||
99 | } | ||
100 | param = QString( "Fast Shrink( 7 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); | ||
101 | odebug << "Load jpeg scaled \"" << param << "\"" << oendl; | ||
102 | iio.setParameters(param.latin1()); | ||
103 | setImageScaledLoaded(true); | ||
104 | real_load = true; | ||
105 | } | ||
106 | } else { | ||
107 | if (ImageScaledLoaded()||!interncall) { | ||
108 | odebug << "Load jpeg unscaled" << oendl; | ||
109 | real_load = true; | ||
110 | } | ||
111 | setImageScaledLoaded(false); | ||
112 | } | ||
113 | if (real_load) { | ||
114 | { | ||
115 | QCopEnvelope( "QPE/System", "busy()" ); | ||
116 | } | ||
117 | _original_data = iio.read() ? iio.image() : QImage(); | ||
118 | { | ||
119 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); | ||
120 | env << "Image loaded"; | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | void OImageScrollView::setImage( const QString& path ) { | ||
126 | odebug << "load new image " << oendl; | ||
127 | if (m_lastName == path) return; | ||
128 | m_lastName = path; | ||
129 | QString itype = QImage::imageFormat(m_lastName); | ||
130 | odebug << "Image type = " << itype << oendl; | ||
131 | if (itype == "JPEG") { | ||
132 | setImageIsJpeg(true); | ||
133 | loadJpeg(); | ||
134 | } else { | ||
135 | { | ||
136 | QCopEnvelope( "QPE/System", "busy()" ); | ||
137 | } | ||
138 | setImageIsJpeg(false); | ||
139 | _original_data.load(path); | ||
140 | _original_data.convertDepth(QPixmap::defaultDepth()); | ||
141 | _original_data.setAlphaBuffer(false); | ||
142 | { | ||
143 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); | ||
144 | env << "Image loaded"; | ||
145 | } | ||
146 | } | ||
147 | _image_data = QImage(); | ||
148 | if (FirstResizeDone()) { | ||
149 | generateImage(); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /* should be called every time the QImage changed it content */ | ||
154 | void OImageScrollView::init() | ||
155 | { | ||
156 | odebug << "init " << oendl; | ||
157 | |||
158 | /* | ||
159 | * create the zoomer | ||
160 | * and connect ther various signals | ||
161 | */ | ||
162 | _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); | ||
163 | connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), | ||
164 | this, SLOT(scrollBy(int,int)) ); | ||
165 | connect(_zoomer, SIGNAL( zoomArea(int,int)), | ||
166 | this, SLOT(center(int,int)) ); | ||
167 | connect(this,SIGNAL(contentsMoving(int,int)), | ||
168 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); | ||
169 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), | ||
170 | _zoomer, SLOT(setImageSize(const QSize&)) ); | ||
171 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), | ||
172 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); | ||
173 | |||
174 | viewport()->setBackgroundColor(white); | ||
175 | setFocusPolicy(QWidget::StrongFocus); | ||
176 | setImageScaledLoaded(false); | ||
177 | setImageIsJpeg(false); | ||
178 | if (FirstResizeDone()) { | ||
179 | m_last_rot = Rotate0; | ||
180 | generateImage(); | ||
181 | } else if (_original_data.size().isValid()) { | ||
182 | if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); | ||
183 | resizeContents(_original_data.width(),_original_data.height()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | void OImageScrollView::setAutoRotate(bool how) | ||
188 | { | ||
189 | /* to avoid double repaints */ | ||
190 | if (AutoRotate() != how) { | ||
191 | m_states.setBit(AUTO_ROTATE,how); | ||
192 | _image_data = QImage(); | ||
193 | generateImage(); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | bool OImageScrollView::AutoRotate()const | ||
198 | { | ||
199 | return m_states.testBit(AUTO_ROTATE); | ||
200 | } | ||
201 | |||
202 | void OImageScrollView::setAutoScale(bool how) | ||
203 | { | ||
204 | m_states.setBit(AUTO_SCALE,how); | ||
205 | if (!how) { | ||
206 | setAutoRotate(false); | ||
207 | } | ||
208 | _image_data = QImage(); | ||
209 | if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { | ||
210 | loadJpeg(true); | ||
211 | } | ||
212 | generateImage(); | ||
213 | } | ||
214 | |||
215 | bool OImageScrollView::AutoScale()const | ||
216 | { | ||
217 | return m_states.testBit(AUTO_SCALE); | ||
218 | } | ||
219 | |||
220 | OImageScrollView::~OImageScrollView() | ||
221 | { | ||
222 | } | ||
223 | |||
224 | void OImageScrollView::rescaleImage(int w, int h) | ||
225 | { | ||
226 | if (_image_data.width()==w && _image_data.height()==h) { | ||
227 | return; | ||
228 | } | ||
229 | double hs = (double)h / (double)_image_data.height() ; | ||
230 | double ws = (double)w / (double)_image_data.width() ; | ||
231 | double scaleFactor = (hs > ws) ? ws : hs; | ||
232 | int smoothW = (int)(scaleFactor * _image_data.width()); | ||
233 | int smoothH = (int)(scaleFactor * _image_data.height()); | ||
234 | _image_data = _image_data.smoothScale(smoothW,smoothH); | ||
235 | } | ||
236 | |||
237 | void OImageScrollView::rotate_into_data(Rotation r) | ||
238 | { | ||
239 | /* realy - we must do this that way, 'cause when acting direct on _image_data the app will | ||
240 | segfault :( */ | ||
241 | QImage dest; | ||
242 | int x, y; | ||
243 | if ( _original_data.depth() > 8 ) | ||
244 | { | ||
245 | unsigned int *srcData, *destData; | ||
246 | switch ( r ) | ||
247 | { | ||
248 | case Rotate90: | ||
249 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | ||
250 | for ( y=0; y < _original_data.height(); ++y ) | ||
251 | { | ||
252 | srcData = (unsigned int *)_original_data.scanLine(y); | ||
253 | for ( x=0; x < _original_data.width(); ++x ) | ||
254 | { | ||
255 | destData = (unsigned int *)dest.scanLine(x); | ||
256 | destData[_original_data.height()-y-1] = srcData[x]; | ||
257 | } | ||
258 | } | ||
259 | break; | ||
260 | case Rotate180: | ||
261 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); | ||
262 | for ( y=0; y < _original_data.height(); ++y ) | ||
263 | { | ||
264 | srcData = (unsigned int *)_original_data.scanLine(y); | ||
265 | destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); | ||
266 | for ( x=0; x < _original_data.width(); ++x ) | ||
267 | destData[_original_data.width()-x-1] = srcData[x]; | ||
268 | } | ||
269 | break; | ||
270 | case Rotate270: | ||
271 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | ||
272 | for ( y=0; y < _original_data.height(); ++y ) | ||
273 | { | ||
274 | srcData = (unsigned int *)_original_data.scanLine(y); | ||
275 | for ( x=0; x < _original_data.width(); ++x ) | ||
276 | { | ||
277 | destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); | ||
278 | destData[y] = srcData[x]; | ||
279 | } | ||
280 | } | ||
281 | break; | ||
282 | default: | ||
283 | dest = _original_data; | ||
284 | break; | ||
285 | } | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | unsigned char *srcData, *destData; | ||
290 | unsigned int *srcTable, *destTable; | ||
291 | switch ( r ) | ||
292 | { | ||
293 | case Rotate90: | ||
294 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | ||
295 | dest.setNumColors(_original_data.numColors()); | ||
296 | srcTable = (unsigned int *)_original_data.colorTable(); | ||
297 | destTable = (unsigned int *)dest.colorTable(); | ||
298 | for ( x=0; x < _original_data.numColors(); ++x ) | ||
299 | destTable[x] = srcTable[x]; | ||
300 | for ( y=0; y < _original_data.height(); ++y ) | ||
301 | { | ||
302 | srcData = (unsigned char *)_original_data.scanLine(y); | ||
303 | for ( x=0; x < _original_data.width(); ++x ) | ||
304 | { | ||
305 | destData = (unsigned char *)dest.scanLine(x); | ||
306 | destData[_original_data.height()-y-1] = srcData[x]; | ||
307 | } | ||
308 | } | ||
309 | break; | ||
310 | case Rotate180: | ||
311 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); | ||
312 | dest.setNumColors(_original_data.numColors()); | ||
313 | srcTable = (unsigned int *)_original_data.colorTable(); | ||
314 | destTable = (unsigned int *)dest.colorTable(); | ||
315 | for ( x=0; x < _original_data.numColors(); ++x ) | ||
316 | destTable[x] = srcTable[x]; | ||
317 | for ( y=0; y < _original_data.height(); ++y ) | ||
318 | { | ||
319 | srcData = (unsigned char *)_original_data.scanLine(y); | ||
320 | destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); | ||
321 | for ( x=0; x < _original_data.width(); ++x ) | ||
322 | destData[_original_data.width()-x-1] = srcData[x]; | ||
323 | } | ||
324 | break; | ||
325 | case Rotate270: | ||
326 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | ||
327 | dest.setNumColors(_original_data.numColors()); | ||
328 | srcTable = (unsigned int *)_original_data.colorTable(); | ||
329 | destTable = (unsigned int *)dest.colorTable(); | ||
330 | for ( x=0; x < _original_data.numColors(); ++x ) | ||
331 | destTable[x] = srcTable[x]; | ||
332 | for ( y=0; y < _original_data.height(); ++y ) | ||
333 | { | ||
334 | srcData = (unsigned char *)_original_data.scanLine(y); | ||
335 | for ( x=0; x < _original_data.width(); ++x ) | ||
336 | { | ||
337 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); | ||
338 | destData[y] = srcData[x]; | ||
339 | } | ||
340 | } | ||
341 | break; | ||
342 | default: | ||
343 | dest = _original_data; | ||
344 | break; | ||
345 | } | ||
346 | |||
347 | } | ||
348 | _image_data = dest; | ||
349 | } | ||
350 | |||
351 | void OImageScrollView::generateImage() | ||
352 | { | ||
353 | Rotation r = Rotate0; | ||
354 | if (_original_data.isNull()) return; | ||
355 | { | ||
356 | QCopEnvelope( "QPE/System", "busy()" ); | ||
357 | } | ||
358 | if (width()>height()&&_original_data.width()<_original_data.height() || | ||
359 | width()<height()&&_original_data.width()>_original_data.height()) { | ||
360 | if (AutoRotate()) r = Rotate90; | ||
361 | } | ||
362 | |||
363 | odebug << " r = " << r << oendl; | ||
364 | if (AutoScale()) { | ||
365 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { | ||
366 | odebug << "Rescaling data" << oendl; | ||
367 | if (r==Rotate0) { | ||
368 | _image_data = _original_data; | ||
369 | } else { | ||
370 | rotate_into_data(r); | ||
371 | } | ||
372 | } | ||
373 | rescaleImage(width(),height()); | ||
374 | resizeContents(_image_data.width(),_image_data.height()); | ||
375 | } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { | ||
376 | if (r==Rotate0) { | ||
377 | _image_data = _original_data; | ||
378 | } else { | ||
379 | rotate_into_data(r); | ||
380 | } | ||
381 | m_last_rot = r; | ||
382 | resizeContents(_image_data.width(),_image_data.height()); | ||
383 | } | ||
384 | _pdata.convertFromImage(_image_data); | ||
385 | |||
386 | |||
387 | /* | ||
388 | * update the zoomer | ||
389 | */ | ||
390 | check_zoomer(); | ||
391 | emit imageSizeChanged( _image_data.size() ); | ||
392 | rescaleImage( 128, 128 ); | ||
393 | /* | ||
394 | * move scrollbar | ||
395 | */ | ||
396 | if (_zoomer) { | ||
397 | _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, | ||
398 | _image_data.width()/2, _image_data.height()/2 ); | ||
399 | _zoomer->setImage( _image_data ); | ||
400 | } | ||
401 | /* | ||
402 | * invalidate | ||
403 | */ | ||
404 | _image_data=QImage(); | ||
405 | { | ||
406 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); | ||
407 | env << "Image generated"; | ||
408 | } | ||
409 | } | ||
410 | |||
411 | void OImageScrollView::resizeEvent(QResizeEvent * e) | ||
412 | { | ||
413 | odebug << "OImageScrollView resizeEvent" << oendl; | ||
414 | QScrollView::resizeEvent(e); | ||
415 | generateImage(); | ||
416 | setFirstResizeDone(true); | ||
417 | emit viewportSizeChanged( viewport()->size() ); | ||
418 | |||
419 | } | ||
420 | |||
421 | void OImageScrollView::keyPressEvent(QKeyEvent * e) | ||
422 | { | ||
423 | if (!e) return; | ||
424 | int dx = horizontalScrollBar()->lineStep(); | ||
425 | int dy = verticalScrollBar()->lineStep(); | ||
426 | if (e->key()==Qt::Key_Right) { | ||
427 | scrollBy(dx,0); | ||
428 | e->accept(); | ||
429 | } else if (e->key()==Qt::Key_Left) { | ||
430 | scrollBy(0-dx,0); | ||
431 | e->accept(); | ||
432 | } else if (e->key()==Qt::Key_Up) { | ||
433 | scrollBy(0,0-dy); | ||
434 | e->accept(); | ||
435 | } else if (e->key()==Qt::Key_Down) { | ||
436 | scrollBy(0,dy); | ||
437 | e->accept(); | ||
438 | } else { | ||
439 | e->ignore(); | ||
440 | } | ||
441 | QScrollView::keyPressEvent(e); | ||
442 | } | ||
443 | |||
444 | void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) | ||
445 | { | ||
446 | int w = clipw; | ||
447 | int h = cliph; | ||
448 | int x = clipx; | ||
449 | int y = clipy; | ||
450 | bool erase = false; | ||
451 | |||
452 | if (!_pdata.size().isValid()) { | ||
453 | p->fillRect(clipx,clipy,clipw,cliph,white); | ||
454 | return; | ||
455 | } | ||
456 | if (w>_pdata.width()) { | ||
457 | w=_pdata.width(); | ||
458 | x = 0; | ||
459 | erase = true; | ||
460 | } else if (x+w>_pdata.width()){ | ||
461 | x = _pdata.width()-w; | ||
462 | } | ||
463 | if (h>_pdata.height()) { | ||
464 | h=_pdata.height(); | ||
465 | y = 0; | ||
466 | erase = true; | ||
467 | } else if (y+h>_pdata.height()){ | ||
468 | y = _pdata.height()-h; | ||
469 | } | ||
470 | if (erase||_original_data.hasAlphaBuffer()) { | ||
471 | p->fillRect(clipx,clipy,clipw,cliph,white); | ||
472 | } | ||
473 | p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); | ||
474 | } | ||
475 | |||
476 | /* using the real geometry points and not the translated points is wanted! */ | ||
477 | void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | ||
478 | { | ||
479 | odebug << "Move X and Y " << e->x() << " " << e->y() << oendl; | ||
480 | int mx, my; | ||
481 | mx = e->x(); | ||
482 | my = e->y(); | ||
483 | if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) { | ||
484 | int diffx = _mouseStartPosX-mx; | ||
485 | int diffy = _mouseStartPosY-my; | ||
486 | #if 0 | ||
487 | QScrollBar*xbar = horizontalScrollBar(); | ||
488 | QScrollBar*ybar = verticalScrollBar(); | ||
489 | if (xbar->value()+diffx>xbar->maxValue()) { | ||
490 | diffx = xbar->maxValue()-xbar->value(); | ||
491 | } else if (xbar->value()+diffx<0) { | ||
492 | diffx=0-xbar->value(); | ||
493 | } | ||
494 | if (ybar->value()+diffy>ybar->maxValue()) { | ||
495 | diffy = ybar->maxValue()-ybar->value(); | ||
496 | } else if (ybar->value()+diffy<0) { | ||
497 | diffy=0-ybar->value(); | ||
498 | } | ||
499 | #endif | ||
500 | scrollBy(diffx,diffy); | ||
501 | } | ||
502 | _mouseStartPosX=mx; | ||
503 | _mouseStartPosY=my; | ||
504 | } | ||
505 | |||
506 | void OImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | ||
507 | { | ||
508 | odebug << " X and Y " << e->x() << " " << e->y() << oendl; | ||
509 | /* this marks the beginning of a possible mouse move. Due internal reasons of QT | ||
510 | the geometry values here may real differ from that set in MoveEvent (I don't know | ||
511 | why). For getting them in real context, we use the first move-event to set the start | ||
512 | position ;) | ||
513 | */ | ||
514 | _mouseStartPosX = -1; | ||
515 | _mouseStartPosY = -1; | ||
516 | } | ||
517 | |||
518 | void OImageScrollView::setDestructiveClose() { | ||
519 | WFlags fl = getWFlags(); | ||
520 | /* clear it just in case */ | ||
521 | fl &= ~WDestructiveClose; | ||
522 | fl |= WDestructiveClose; | ||
523 | setWFlags( fl ); | ||
524 | } | ||
525 | |||
526 | bool OImageScrollView::image_fit_into(const QSize&s ) | ||
527 | { | ||
528 | if (s.width()>width()||s.height()>height()) { | ||
529 | return false; | ||
530 | } | ||
531 | return true; | ||
532 | } | ||
533 | |||
534 | void OImageScrollView::setShowZoomer(bool how) | ||
535 | { | ||
536 | m_states.setBit(SHOW_ZOOMER,how); | ||
537 | check_zoomer(); | ||
538 | } | ||
539 | |||
540 | bool OImageScrollView::ShowZoomer()const | ||
541 | { | ||
542 | return m_states.testBit(SHOW_ZOOMER); | ||
543 | } | ||
544 | |||
545 | void OImageScrollView::check_zoomer() | ||
546 | { | ||
547 | if (!_zoomer) return; | ||
548 | if ( (!ShowZoomer()||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { | ||
549 | _zoomer->hide(); | ||
550 | } else if ( ShowZoomer() && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ | ||
551 | _zoomer->show(); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | bool OImageScrollView::FirstResizeDone()const | ||
556 | { | ||
557 | return m_states.testBit(FIRST_RESIZE_DONE); | ||
558 | } | ||
559 | |||
560 | void OImageScrollView::setFirstResizeDone(bool how) | ||
561 | { | ||
562 | m_states.setBit(FIRST_RESIZE_DONE,how); | ||
563 | } | ||
564 | |||
565 | bool OImageScrollView::ImageIsJpeg()const | ||
566 | { | ||
567 | return m_states.testBit(IMAGE_IS_JPEG); | ||
568 | } | ||
569 | |||
570 | void OImageScrollView::setImageIsJpeg(bool how) | ||
571 | { | ||
572 | m_states.setBit(IMAGE_IS_JPEG,how); | ||
573 | } | ||
574 | |||
575 | bool OImageScrollView::ImageScaledLoaded()const | ||
576 | { | ||
577 | return m_states.testBit(IMAGE_SCALED_LOADED); | ||
578 | } | ||
579 | |||
580 | void OImageScrollView::setImageScaledLoaded(bool how) | ||
581 | { | ||
582 | m_states.setBit(IMAGE_SCALED_LOADED,how); | ||
583 | } | ||
584 | |||
585 | } // namespace MM | ||
586 | } // namespace Opie | ||