1 /***************************************************************************
2 * Copyright (C) 2005 by David Saxton *
3 * david@bluehaze.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
10
11 #include "itemdocument.h"
12 #include "mechanicsitem.h"
13 #include "resizeoverlay.h"
14
15 #include <QDebug>
16 #include <QPainter>
17 #include <cmath>
18
19 #define DPR ( 180.0 / M_PI )
20
21
22 //BEGIN class ResizeOverlay
ResizeOverlay(Item * parent)23 ResizeOverlay::ResizeOverlay( Item *parent )
24 : QObject(parent)
25 {
26 b_showResizeHandles = false;
27 b_visible = true;
28 p_item = parent;
29 }
30
31
~ResizeOverlay()32 ResizeOverlay::~ResizeOverlay()
33 {
34 const ResizeHandleMap::iterator end = m_resizeHandleMap.end();
35 for ( ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it )
36 {
37 if (it.value())
38 it.value()->setCanvas(nullptr);
39 delete (ResizeHandle*)it.value();
40 }
41 m_resizeHandleMap.clear();
42 }
43
44
showResizeHandles(bool show)45 void ResizeOverlay::showResizeHandles( bool show )
46 {
47 b_showResizeHandles = show;
48 const ResizeHandleMap::iterator end = m_resizeHandleMap.end();
49 for ( ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it )
50 {
51 it.value()->setVisible(b_showResizeHandles && b_visible);
52 }
53 }
54
55
setVisible(bool visible)56 void ResizeOverlay::setVisible( bool visible )
57 {
58 b_visible = visible;
59 const ResizeHandleMap::iterator end = m_resizeHandleMap.end();
60 for ( ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it )
61 {
62 it.value()->setVisible(b_showResizeHandles && b_visible);
63 }
64 }
65
66
createResizeHandle(int id,ResizeHandle::DrawType drawType,int xsnap,int ysnap)67 ResizeHandle *ResizeOverlay::createResizeHandle( int id, ResizeHandle::DrawType drawType, int xsnap, int ysnap )
68 {
69 ResizeHandleMap::iterator it = m_resizeHandleMap.find(id);
70 if ( it != m_resizeHandleMap.end() )
71 return it.value();
72
73 ResizeHandle *newResizeHandle = new ResizeHandle( this, id, drawType, xsnap, ysnap );
74 m_resizeHandleMap[id] = newResizeHandle;
75 connect( newResizeHandle, SIGNAL(rhMovedBy(int, double, double )), this, SLOT(slotResizeHandleMoved(int, double, double )) );
76 return newResizeHandle;
77 }
78
79
removeResizeHandle(int id)80 void ResizeOverlay::removeResizeHandle( int id )
81 {
82 ResizeHandleMap::iterator it = m_resizeHandleMap.find(id);
83 if ( it == m_resizeHandleMap.end() )
84 return;
85
86 ResizeHandle *rh = it.value();
87 disconnect( rh, SIGNAL(rhMovedBy(int, double, double )), this, SLOT(slotResizeHandleMoved(int, double, double )) );
88 delete rh;
89 m_resizeHandleMap.erase(it);
90 }
91
92
resizeHandle(int id)93 ResizeHandle *ResizeOverlay::resizeHandle( int id )
94 {
95 ResizeHandleMap::iterator it = m_resizeHandleMap.find(id);
96 if ( it != m_resizeHandleMap.end() )
97 return it.value();
98 return nullptr;
99 }
100
101
slotMoveAllResizeHandles(double dx,double dy)102 void ResizeOverlay::slotMoveAllResizeHandles( double dx, double dy )
103 {
104 const ResizeHandleMap::iterator end = m_resizeHandleMap.end();
105 for ( ResizeHandleMap::iterator it = m_resizeHandleMap.begin(); it != end; ++it )
106 {
107 it.value()->moveBy( dx, dy );
108 }
109 }
110
111
syncX(ResizeHandle * rh1,ResizeHandle * rh2,ResizeHandle * rh3)112 void ResizeOverlay::syncX( ResizeHandle *rh1, ResizeHandle *rh2, ResizeHandle *rh3 )
113 {
114 syncX( rh1, rh2 );
115 syncX( rh1, rh3 );
116 syncX( rh2, rh3 );
117 }
syncY(ResizeHandle * rh1,ResizeHandle * rh2,ResizeHandle * rh3)118 void ResizeOverlay::syncY( ResizeHandle *rh1, ResizeHandle *rh2, ResizeHandle *rh3 )
119 {
120 syncY( rh1, rh2 );
121 syncY( rh1, rh3 );
122 syncY( rh2, rh3 );
123 }
syncX(ResizeHandle * rh1,ResizeHandle * rh2)124 void ResizeOverlay::syncX( ResizeHandle *rh1, ResizeHandle *rh2 )
125 {
126 if ( !rh1 || !rh2 )
127 return;
128 connect( rh1, SIGNAL(rhMovedByX(double )), rh2, SLOT(slotMoveByX(double )) );
129 connect( rh2, SIGNAL(rhMovedByX(double )), rh1, SLOT(slotMoveByX(double )) );
130 }
syncY(ResizeHandle * rh1,ResizeHandle * rh2)131 void ResizeOverlay::syncY( ResizeHandle *rh1, ResizeHandle *rh2 )
132 {
133 if ( !rh1 || !rh2 )
134 return;
135 connect( rh1, SIGNAL(rhMovedByY(double )), rh2, SLOT(slotMoveByY(double )) );
136 connect( rh2, SIGNAL(rhMovedByY(double )), rh1, SLOT(slotMoveByY(double )) );
137 }
138 //END class ResizeOverlay
139
140
141
142 //BEGIN class MechanicsItemOverlay
MechanicsItemOverlay(MechanicsItem * parent)143 MechanicsItemOverlay::MechanicsItemOverlay( MechanicsItem *parent )
144 : ResizeOverlay(parent)
145 {
146 p_mechanicsItem = parent;
147 connect( parent, SIGNAL(moved()), this, SLOT(slotUpdateResizeHandles()) );
148 connect( parent, SIGNAL(resized()), this, SLOT(slotUpdateResizeHandles()) );
149
150 m_tl = createResizeHandle( ResizeHandle::rhp_topLeft, ResizeHandle::dt_resize_backwardsDiagonal );
151 m_tm = createResizeHandle( ResizeHandle::rhp_topMiddle, ResizeHandle::dt_resize_vertical );
152 m_tr = createResizeHandle( ResizeHandle::rhp_topRight, ResizeHandle::dt_resize_forwardsDiagonal );
153 m_mr = createResizeHandle( ResizeHandle::rhp_middleRight, ResizeHandle::dt_resize_horizontal );
154 m_br = createResizeHandle( ResizeHandle::rhp_bottomRight, ResizeHandle::dt_resize_backwardsDiagonal );
155 m_bm = createResizeHandle( ResizeHandle::rhp_bottomMiddle, ResizeHandle::dt_resize_vertical );
156 m_bl = createResizeHandle( ResizeHandle::rhp_bottomLeft, ResizeHandle::dt_resize_forwardsDiagonal );
157 m_ml = createResizeHandle( ResizeHandle::rhp_middleLeft, ResizeHandle::dt_resize_horizontal );
158 m_mm = createResizeHandle( ResizeHandle::rhp_center, ResizeHandle::dt_point_crosshair );
159
160 slotUpdateResizeHandles();
161 }
162
~MechanicsItemOverlay()163 MechanicsItemOverlay::~MechanicsItemOverlay()
164 {
165 }
166
slotUpdateResizeHandles()167 void MechanicsItemOverlay::slotUpdateResizeHandles()
168 {
169 const PositionInfo absPos = p_mechanicsItem->absolutePosition();
170 const QRect sizeRect = p_mechanicsItem->sizeRect();
171
172 QPolygon pa(9);
173 pa[0] = sizeRect.topLeft();
174 pa[2] = sizeRect.topRight();
175 pa[1] = (pa[0]+pa[2])/2;
176 pa[4] = sizeRect.bottomRight();
177 pa[3] = (pa[2]+pa[4])/2;
178 pa[6] = sizeRect.bottomLeft();
179 pa[5] = (pa[4]+pa[6])/2;
180 pa[7] = (pa[6]+pa[0])/2;
181 pa[8] = QPoint(0,0);
182
183 QMatrix m;
184 m.rotate(absPos.angle() * DPR);
185
186 pa = m.map(pa);
187
188 m_tl->move( absPos.x()+pa[0].x(), absPos.y()+pa[0].y() );
189 m_tm->move( absPos.x()+pa[1].x(), absPos.y()+pa[1].y() );
190 m_tr->move( absPos.x()+pa[2].x(), absPos.y()+pa[2].y() );
191 m_mr->move( absPos.x()+pa[3].x(), absPos.y()+pa[3].y() );
192 m_br->move( absPos.x()+pa[4].x(), absPos.y()+pa[4].y() );
193 m_bm->move( absPos.x()+pa[5].x(), absPos.y()+pa[5].y() );
194 m_bl->move( absPos.x()+pa[6].x(), absPos.y()+pa[6].y() );
195 m_ml->move( absPos.x()+pa[7].x(), absPos.y()+pa[7].y() );
196 m_mm->move( absPos.x()+pa[8].x(), absPos.y()+pa[8].y() );
197 }
198
slotResizeHandleMoved(int id,double dx,double dy)199 void MechanicsItemOverlay::slotResizeHandleMoved( int id, double dx, double dy )
200 {
201 Q_UNUSED(id);
202 Q_UNUSED(dx);
203 Q_UNUSED(dy);
204
205 switch (id)
206 {
207 case ResizeHandle::rhp_topLeft:
208 break;
209 case ResizeHandle::rhp_topMiddle:
210 break;
211 case ResizeHandle::rhp_topRight:
212 break;
213 case ResizeHandle::rhp_middleRight:
214 break;
215 case ResizeHandle::rhp_bottomRight:
216 break;
217 case ResizeHandle::rhp_bottomMiddle:
218 break;
219 case ResizeHandle::rhp_bottomLeft:
220 break;
221 case ResizeHandle::rhp_middleLeft:
222 break;
223 case ResizeHandle::rhp_center:
224 break;
225 default:
226 qCritical() << Q_FUNC_INFO << "Unknown resize handle id " << id << endl;
227 break;
228 }
229 }
230 //END class MechanicsItemOverlay
231
232
233
234 //BEGIN class RectangularOverlay
RectangularOverlay(Item * parent,int xsnap,int ysnap)235 RectangularOverlay::RectangularOverlay( Item *parent, int xsnap, int ysnap )
236 : ResizeOverlay(parent)
237 {
238 connect( parent, SIGNAL(resized()), this, SLOT(slotUpdateResizeHandles()) );
239 connect( parent, SIGNAL(movedBy(double, double )), this, SLOT(slotMoveAllResizeHandles(double, double )) );
240
241 m_tl = createResizeHandle( ResizeHandle::rhp_topLeft, ResizeHandle::dt_resize_backwardsDiagonal, xsnap, ysnap );
242 m_tm = createResizeHandle( ResizeHandle::rhp_topMiddle, ResizeHandle::dt_resize_vertical, xsnap, ysnap );
243 m_tr = createResizeHandle( ResizeHandle::rhp_topRight, ResizeHandle::dt_resize_forwardsDiagonal, xsnap, ysnap );
244 m_mr = createResizeHandle( ResizeHandle::rhp_middleRight, ResizeHandle::dt_resize_horizontal, xsnap, ysnap );
245 m_br = createResizeHandle( ResizeHandle::rhp_bottomRight, ResizeHandle::dt_resize_backwardsDiagonal, xsnap, ysnap );
246 m_bm = createResizeHandle( ResizeHandle::rhp_bottomMiddle, ResizeHandle::dt_resize_vertical, xsnap, ysnap );
247 m_bl = createResizeHandle( ResizeHandle::rhp_bottomLeft, ResizeHandle::dt_resize_forwardsDiagonal, xsnap, ysnap );
248 m_ml = createResizeHandle( ResizeHandle::rhp_middleLeft, ResizeHandle::dt_resize_horizontal, xsnap, ysnap );
249
250 syncX( m_tl, m_ml, m_bl );
251 syncX( m_tr, m_mr, m_br );
252 syncY( m_tl, m_tm, m_tr );
253 syncY( m_bl, m_bm, m_br );
254
255 slotUpdateResizeHandles();
256 }
257
258
removeTopMiddle()259 void RectangularOverlay::removeTopMiddle()
260 {
261 if (!m_tm)
262 return;
263 removeResizeHandle( m_tm->id() );
264 m_tm = nullptr;
265 }
266
267
removeBotMiddle()268 void RectangularOverlay::removeBotMiddle()
269 {
270 if (!m_bm)
271 return;
272 removeResizeHandle( m_bm->id() );
273 m_bm = nullptr;
274 }
275
276
slotUpdateResizeHandles()277 void RectangularOverlay::slotUpdateResizeHandles()
278 {
279 const QRect sizeRect = p_item->sizeRect();
280
281 int x1 = sizeRect.left() + int(p_item->x());
282 int x2 = x1 + sizeRect.width();
283
284 int y1 = sizeRect.top() + int(p_item->y());
285 int y2 = y1 + sizeRect.height();
286
287 m_tl->move( x1, y1 );
288 if (m_tm)
289 m_tm->move( (x1+x2)/2, y1 );
290 m_tr->move( x2, y1 );
291 m_mr->move( x2, (y1+y2)/2 );
292 m_br->move( x2, y2 );
293 if (m_bm)
294 m_bm->move( (x1+x2)/2, y2 );
295 m_bl->move( x1, y2 );
296 m_ml->move( x1, (y1+y2)/2 );
297 }
298
299
isValidXPos(ResizeHandle * rh)300 bool RectangularOverlay::isValidXPos( ResizeHandle *rh )
301 {
302 Q_UNUSED(rh);
303 bool ok;
304 getSizeRect( nullptr, &ok, nullptr );
305 return ok;
306 }
307
308
isValidYPos(ResizeHandle * rh)309 bool RectangularOverlay::isValidYPos( ResizeHandle *rh )
310 {
311 Q_UNUSED(rh);
312 bool ok;
313 getSizeRect( nullptr, nullptr, &ok );
314 return ok;
315 }
316
317
slotResizeHandleMoved(int id,double dx,double dy)318 void RectangularOverlay::slotResizeHandleMoved( int id, double dx, double dy )
319 {
320 Q_UNUSED(id);
321 Q_UNUSED(dx);
322 Q_UNUSED(dy);
323
324 bool ok;
325 QRect sizeRect = getSizeRect(&ok);
326 if (!ok)
327 return;
328
329 p_item->setSize(sizeRect);
330 slotUpdateResizeHandles();
331 }
332
333
getSizeRect(bool * ok,bool * widthOk,bool * heightOk) const334 QRect RectangularOverlay::getSizeRect( bool *ok, bool *widthOk, bool *heightOk ) const
335 {
336 bool t1,t2,t3;
337 if (!ok)
338 ok = &t1;
339 if (!widthOk)
340 widthOk = &t2;
341 if (!heightOk)
342 heightOk = &t3;
343
344 int width = int(m_br->x() - m_tl->x());
345 int height = int(m_br->y() - m_tl->y());
346
347 QRect sizeRect( int(m_tl->x() - p_item->x()),
348 int(m_tl->y() - p_item->y()),
349 width, height );
350
351 *widthOk = sizeRect.width() >= p_item->minimumSize().width();
352 *heightOk = sizeRect.height() >= p_item->minimumSize().height();
353 *ok = *widthOk && *heightOk;
354
355 return sizeRect;
356 }
357 //END class RectangularOverlay
358
359
360
361 //BEGIN class LineOverlay
LineOverlay(Item * parent)362 LineOverlay::LineOverlay( Item * parent )
363 : ResizeOverlay(parent)
364 {
365 connect( parent, SIGNAL(resized()), this, SLOT(slotUpdateResizeHandles()) );
366 connect( parent, SIGNAL(movedBy(double, double )), this, SLOT(slotMoveAllResizeHandles(double, double )) );
367
368 m_pStart = createResizeHandle( ResizeHandle::rhp_start, ResizeHandle::dt_point_rect );
369 m_pEnd = createResizeHandle( ResizeHandle::rhp_end, ResizeHandle::dt_point_rect );
370
371 slotUpdateResizeHandles();
372 }
373
374
startPoint() const375 QPoint LineOverlay::startPoint() const
376 {
377 return QPoint( int(m_pStart->x()), int(m_pStart->y()) );
378 }
endPoint() const379 QPoint LineOverlay::endPoint() const
380 {
381 return QPoint( int(m_pEnd->x()), int(m_pEnd->y()) );
382 }
383
384
slotUpdateResizeHandles()385 void LineOverlay::slotUpdateResizeHandles()
386 {
387 int _x = int(p_item->x() + p_item->offsetX());
388 int _y = int(p_item->y() + p_item->offsetY());
389
390 m_pStart->move( _x, _y );
391 m_pEnd->move( _x+p_item->width(), _y+p_item->height() );
392 }
393
394
slotResizeHandleMoved(int id,double dx,double dy)395 void LineOverlay::slotResizeHandleMoved( int id, double dx, double dy )
396 {
397 Q_UNUSED(id);
398 Q_UNUSED(dx);
399 Q_UNUSED(dy);
400
401 p_item->setSize( int(m_pStart->x()-p_item->x()), int(m_pStart->y()-p_item->y()),
402 int(m_pEnd->x()-m_pStart->x()), int(m_pEnd->y()-m_pStart->y()) );
403 }
404 //END class LineOverlay
405
406
407
408 //BEGIN class ResizeHandle
ResizeHandle(ResizeOverlay * resizeOverlay,int id,DrawType drawType,int xsnap,int ysnap)409 ResizeHandle::ResizeHandle( ResizeOverlay *resizeOverlay, int id, DrawType drawType, int xsnap, int ysnap )
410 : //QObject(),
411 KtlQCanvasRectangle( 0, 0, 13, 13, resizeOverlay->parentItem()->canvas() )
412 {
413 p_resizeOverlay = resizeOverlay;
414 m_drawType = drawType;
415 m_id = id;
416 b_hover = false;
417 m_xsnap = xsnap;
418 m_ysnap = ysnap;
419 setZ( ItemDocument::Z::ResizeHandle );
420 }
421
~ResizeHandle()422 ResizeHandle::~ResizeHandle()
423 {
424 hide();
425 }
426
setHover(bool hover)427 void ResizeHandle::setHover( bool hover )
428 {
429 if ( b_hover == hover )
430 return;
431
432 b_hover = hover;
433 canvas()->setChanged( QRect( int(x())-8, int(y())-8, 15, 15 ) );
434 }
435
areaPoints() const436 QPolygon ResizeHandle::areaPoints() const
437 {
438 // QPolygon pa = KtlQCanvasRectangle::areaPoints();
439 // pa.translate( -7, -7 );
440 // return pa;
441 return QPolygon( QRect( int(x())-8, int(y())-8, 15, 15 ) );
442 }
443
moveRH(double _x,double _y)444 void ResizeHandle::moveRH( double _x, double _y )
445 {
446 double dx = int((_x-4)/m_xsnap)*m_xsnap+4 - x();
447 double dy = int((_y-4)/m_ysnap)*m_ysnap+4 - y();
448 if ( (dx == 0) && (dy == 0) )
449 return;
450
451 //BEGIN Move and check
452 moveBy( dx, dy );
453 if ( dx != 0 )
454 emit rhMovedByX(dx);
455 if ( dy != 0 )
456 emit rhMovedByY(dy);
457
458 bool xOk = p_resizeOverlay->isValidXPos(this);
459 bool yOk = p_resizeOverlay->isValidYPos(this);
460
461 if (!xOk)
462 {
463 moveBy( -dx, 0 );
464 emit rhMovedByX(-dx);
465 dx = 0;
466 }
467 if (!yOk)
468 {
469 moveBy( 0, -dy );
470 emit rhMovedByY(-dy);
471 dy = 0;
472 }
473
474 if ( !xOk && !yOk )
475 return;
476 //END Move and check
477
478 emit rhMovedBy( id(), dx, dy );
479 }
480
setDrawType(DrawType drawType)481 void ResizeHandle::setDrawType( DrawType drawType )
482 {
483 m_drawType = drawType;
484 canvas()->setChanged(boundingRect());
485 }
486
drawShape(QPainter & p)487 void ResizeHandle::drawShape( QPainter &p )
488 {
489 p.drawPixmap( rect().topLeft()-QPoint( 7, 7 ), handlePixmap( m_drawType, b_hover ) );
490 }
491
handlePixmap(DrawType drawType,bool hover)492 const QPixmap& ResizeHandle::handlePixmap( DrawType drawType, bool hover )
493 {
494 const char * resize_forwardsDiagonal_hover_xpm[] = {
495 "13 13 3 1",
496 " c None",
497 ". c #000000",
498 "+ c #8EA5D0",
499 " ",
500 " ....... ",
501 " ..+++. ",
502 " .++++. ",
503 " .+++++. ",
504 " . .+++++.. ",
505 " ...+++++... ",
506 " ..+++++. . ",
507 " .+++++. ",
508 " .++++. ",
509 " .+++.. ",
510 " ....... ",
511 " "};
512 static QPixmap pixmap_forwardsDiagonal_hover(resize_forwardsDiagonal_hover_xpm);
513
514 const char * resize_forwardsDiagonal_nohover_xpm[] = {
515 "13 13 2 1",
516 " c None",
517 ". c #000000",
518 " ",
519 " ....... ",
520 " ...... ",
521 " ...... ",
522 " ....... ",
523 " . ........ ",
524 " ........... ",
525 " ........ . ",
526 " ....... ",
527 " ...... ",
528 " ...... ",
529 " ....... ",
530 " "};
531 static QPixmap pixmap_forwardsDiagonal_nohover(resize_forwardsDiagonal_nohover_xpm);
532
533
534 const char * resize_backwardsDiagonal_hover_xpm[] = {
535 "13 13 3 1",
536 " c None",
537 ". c #000000",
538 "+ c #8EA5D0",
539 " ",
540 " ....... ",
541 " .+++.. ",
542 " .++++. ",
543 " .+++++. ",
544 " ..+++++. . ",
545 " ...+++++... ",
546 " . .+++++.. ",
547 " .+++++. ",
548 " .++++. ",
549 " ..+++. ",
550 " ....... ",
551 " "};
552 static QPixmap pixmap_backwardsDiagonal_hover(resize_backwardsDiagonal_hover_xpm);
553
554 const char * resize_backwardsDiagonal_nohover_xpm[] = {
555 "13 13 2 1",
556 " c None",
557 ". c #000000",
558 " ",
559 " ....... ",
560 " ...... ",
561 " ...... ",
562 " ....... ",
563 " ........ . ",
564 " ........... ",
565 " . ........ ",
566 " ....... ",
567 " ...... ",
568 " ...... ",
569 " ....... ",
570 " "};
571 static QPixmap pixmap_backwardsDiagonal_nohover(resize_backwardsDiagonal_nohover_xpm);
572
573
574 const char * resize_vertical_hover_xpm[] = {
575 "13 13 3 1",
576 " c None",
577 ". c #000000",
578 "+ c #8EA5D0",
579 " . ",
580 " ... ",
581 " ..+.. ",
582 " ..+++.. ",
583 " ..+++++.. ",
584 " .+++. ",
585 " .+++. ",
586 " .+++. ",
587 " ..+++++.. ",
588 " ..+++.. ",
589 " ..+.. ",
590 " ... ",
591 " . "};
592 static QPixmap pixmap_vertical_hover(resize_vertical_hover_xpm);
593
594 const char * resize_vertical_nohover_xpm[] = {
595 "13 13 2 1",
596 " c None",
597 ". c #000000",
598 " . ",
599 " ... ",
600 " ..... ",
601 " ....... ",
602 " ......... ",
603 " ..... ",
604 " ..... ",
605 " ..... ",
606 " ......... ",
607 " ....... ",
608 " ..... ",
609 " ... ",
610 " . "};
611 static QPixmap pixmap_vertical_nohover(resize_vertical_nohover_xpm);
612
613
614 const char * resize_horizontal_hover_xpm[] = {
615 "13 13 3 1",
616 " c None",
617 ". c #000000",
618 "+ c #8EA5D0",
619 " ",
620 " ",
621 " . . ",
622 " .. .. ",
623 " ..+...+.. ",
624 " ..+++++++.. ",
625 "..+++++++++..",
626 " ..+++++++.. ",
627 " ..+...+.. ",
628 " .. .. ",
629 " . . ",
630 " ",
631 " "};
632 static QPixmap pixmap_horizontal_hover(resize_horizontal_hover_xpm);
633
634 const char * resize_horizontal_nohover_xpm[] = {
635 "13 13 2 1",
636 " c None",
637 ". c #000000",
638 " ",
639 " ",
640 " . . ",
641 " .. .. ",
642 " ......... ",
643 " ........... ",
644 ".............",
645 " ........... ",
646 " ......... ",
647 " .. .. ",
648 " . . ",
649 " ",
650 " "};
651 static QPixmap pixmap_horizontal_nohover(resize_horizontal_nohover_xpm);
652
653 const char * point_rect_hover_xpm[] = {
654 "13 13 3 1",
655 " c None",
656 ". c #000000",
657 "+ c #8EA5D0",
658 " ",
659 " ",
660 " ",
661 " ",
662 " ",
663 " ..... ",
664 " .+++. ",
665 " .+++. ",
666 " .+++. ",
667 " ..... ",
668 " ",
669 " ",
670 " "};
671 static QPixmap pixmap_point_rect_hover(point_rect_hover_xpm);
672
673 const char * point_rect_nohover_xpm[] = {
674 "13 13 3 1",
675 " c None",
676 ". c #000000",
677 "+ c #FFFFFF",
678 " ",
679 " ",
680 " ",
681 " ",
682 " ",
683 " ..... ",
684 " .+++. ",
685 " .+++. ",
686 " .+++. ",
687 " ..... ",
688 " ",
689 " ",
690 " "};
691 static QPixmap pixmap_point_rect_nohover(point_rect_nohover_xpm);
692
693 if (hover)
694 {
695 switch(drawType)
696 {
697 case ResizeHandle::dt_resize_forwardsDiagonal:
698 return pixmap_forwardsDiagonal_hover;
699 case ResizeHandle::dt_resize_backwardsDiagonal:
700 return pixmap_backwardsDiagonal_hover;
701 case ResizeHandle::dt_resize_vertical:
702 return pixmap_vertical_hover;
703 case ResizeHandle::dt_resize_horizontal:
704 return pixmap_horizontal_hover;
705 case ResizeHandle::dt_point_rect:
706 return pixmap_point_rect_hover;
707
708 case ResizeHandle::dt_point_crosshair:
709 case ResizeHandle::dt_rotate_topLeft:
710 case ResizeHandle::dt_rotate_topRight:
711 case ResizeHandle::dt_rotate_bottomRight:
712 case ResizeHandle::dt_rotate_bottomLeft:
713 qWarning() << Q_FUNC_INFO << "ResizeHandle of type " << drawType << " does not have an image." << endl;
714 }
715 }
716 else
717 {
718 switch(drawType)
719 {
720 case ResizeHandle::dt_resize_forwardsDiagonal:
721 return pixmap_forwardsDiagonal_nohover;
722 case ResizeHandle::dt_resize_backwardsDiagonal:
723 return pixmap_backwardsDiagonal_nohover;
724 case ResizeHandle::dt_resize_vertical:
725 return pixmap_vertical_nohover;
726 case ResizeHandle::dt_resize_horizontal:
727 return pixmap_horizontal_nohover;
728 case ResizeHandle::dt_point_rect:
729 return pixmap_point_rect_nohover;
730
731 case ResizeHandle::dt_point_crosshair:
732 case ResizeHandle::dt_rotate_topLeft:
733 case ResizeHandle::dt_rotate_topRight:
734 case ResizeHandle::dt_rotate_bottomRight:
735 case ResizeHandle::dt_rotate_bottomLeft:
736 qWarning() << Q_FUNC_INFO << "ResizeHandle of type " << drawType << " does not have an image." << endl;
737 }
738 }
739
740 static QPixmap blank;
741 return blank;
742 }
743 //END class ResizeHandle
744