def __init__(self, parent):
        # initialize the super class
        QWidget.__init__(self, parent)

        self._hue = 0  # defines red color
        self._saturation = 255
        self._lightness = 255
        self._alpha = 255
        self._showAlpha = True
        self._editing = None
    def __init__( self, parent ):
        # initialize the super class
        QWidget.__init__( self, parent )

        self._hue			= 0			# defines red color
        self._saturation	= 255
        self._lightness		= 255
        self._alpha			= 255
        self._showAlpha		= True
        self._editing		= None
    def mouseReleaseEvent(self, event):
        if (self._editing and not self.signalsBlocked()):
            self.editingFinished.emit()

        self._editing = None

        return QWidget.mouseReleaseEvent(self, event)
    def mouseReleaseEvent( self, event ):
        if ( self._editing and not self.signalsBlocked() ):
            self.editingFinished.emit()

        self._editing = None

        return QWidget.mouseReleaseEvent( self,event )
    def mouseMoveEvent(self, event):
        # edit the color
        if (self._editing == 'color'):
            self.setSaturationAndLightnessFromPoint(event.pos())

        # edit the alpha
        elif (self._editing == 'alpha'):
            self.setAlphaFromPoint(event.pos())

        # edit the hue
        elif (self._editing == 'hue'):
            self.setHueFromPoint(event.pos())

        return QWidget.mouseMoveEvent(self, event)
    def mousePressEvent(self, event):
        # edit the hue
        r = self.hueRect()
        if (r.contains(event.pos())):
            self._editing = 'hue'
            self.setHueFromPoint(event.pos())
            return QWidget.mousePressEvent(self, event)

        # edit the alpha
        r = self.alphaRect()
        if (r.contains(event.pos())):
            self._editing = 'alpha'
            self.setAlphaFromPoint(event.pos())
            return QWidget.mousePressEvent(self, event)

        # edit the color
        r = self.colorRect()
        if (r.contains(event.pos())):
            self._editing = 'color'
            self.setSaturationAndLightnessFromPoint(event.pos())
            return QWidget.mousePressEvent(self, event)

        return QWidget.mousePressEvent(self, event)
    def mouseMoveEvent( self, event ):
        # edit the color
        if ( self._editing == 'color' ):
            self.setSaturationAndLightnessFromPoint( event.pos() )

        # edit the alpha
        elif ( self._editing == 'alpha' ):
            self.setAlphaFromPoint( event.pos() )

        # edit the hue
        elif ( self._editing == 'hue' ):
            self.setHueFromPoint( event.pos() )

        return QWidget.mouseMoveEvent( self, event )
    def mousePressEvent( self, event ):
        # edit the hue
        r = self.hueRect()
        if ( r.contains( event.pos() ) ):
            self._editing = 'hue'
            self.setHueFromPoint( event.pos() )
            return QWidget.mousePressEvent( self, event )

        # edit the alpha
        r = self.alphaRect()
        if ( r.contains( event.pos() ) ):
            self._editing = 'alpha'
            self.setAlphaFromPoint( event.pos() )
            return QWidget.mousePressEvent( self, event )

        # edit the color
        r = self.colorRect()
        if ( r.contains( event.pos() ) ):
            self._editing = 'color'
            self.setSaturationAndLightnessFromPoint( event.pos() )
            return QWidget.mousePressEvent( self, event )

        return QWidget.mousePressEvent( self, event )