00001
00002
00003
00004
00005
00006 #include "QColorSelector.h"
00007 #include "QColorSelect.h"
00008 #include <QGraphicsScene>
00009 #include <QGraphicsSceneMouseEvent>
00010
00011 #include <iostream>
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 QColorSelector::QColorSelector(QColorSelect * view)
00023 : QGraphicsRectItem()
00024 {
00025 points[0] = QPointF(-0.02,0);
00026 points[1] = QPointF(-points[0].x(),0);
00027 points[2] = QPointF(0,0.4);
00028 setRect(points[0].x(),0,points[1].x()*2,0.4);
00029 }
00030
00031
00032 QColorSelector::~QColorSelector()
00033 {
00034
00035 }
00036
00037
00038
00039
00040
00041
00042 QRectF QColorSelector::boundingRect()
00043 {
00044 return this->rect();
00045 }
00046
00047
00048 void QColorSelector::mouseMoveEvent( QGraphicsSceneMouseEvent *event )
00049 {
00050 double dx = event->scenePos().x() - event->lastScenePos().x();
00051
00052 if(this->scenePos().x() + dx > 0 && this->scenePos().x() + dx < 1){
00053 this->translate(dx,0);
00054 }else{
00055
00056 }
00057 }
00058
00059
00060 void QColorSelector::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
00061 {
00062 painter->setRenderHint(QPainter::Antialiasing);
00063 painter->setBrush(this->brush());
00064 painter->drawPolygon(points,3);
00065 }
00066
00067 void QColorSelector::ScaleX(float scale){
00068
00069
00070
00071
00072
00073
00074 }