Exemplo n.º 1
0
static void setgadget( p_gadget g, int pos, bool draw )
{
    g->pos = pos;
    setlinear( g );
    if( draw ) {
        drawgadget( g );
    }
}
Exemplo n.º 2
0
Arquivo: mouse.c Projeto: aahud/harvey
void
mousectl(Cmdbuf *cb)
{
	Proc *up = externup();
	Cmdtab *ct;

	qlock(&mousectlqlock);
	if(waserror()){
		qunlock(&mousectlqlock);
		nexterror();
	}

	ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg));
	switch(ct->index){
	case CMaccelerated:
		setaccelerated(cb->nf == 1 ? 1 : atoi(cb->f[1]));
		break;
	case CMintellimouse:
		setintellimouse();
		break;
	case CMlinear:
		setlinear();
		break;
	case CMps2:
		intellimouse = 0;
		ps2mouse();
		break;
	case CMps2intellimouse:
		ps2mouse();
		setintellimouse();
		break;
	case CMres:
		if(cb->nf >= 2)
			setres(atoi(cb->f[1]));
		else
			setres(1);
		break;
	case CMreset:
		resetmouse();
		if(accelerated)
			setaccelerated(accelerated);
		if(resolution)
			setres(resolution);
		if(intellimouse)
			setintellimouse();
		break;
	case CMhwaccel:
		if(strcmp(cb->f[1], "on")==0)
			mousehwaccel = 1;
		else if(strcmp(cb->f[1], "off")==0)
			mousehwaccel = 0;
		else
			cmderror(cb, "bad mouse control message");
	}

	qunlock(&mousectlqlock);
	poperror();
}
Exemplo n.º 3
0
EVENT uigadgetfilter( EVENT ev, p_gadget g )
{
    int         m_anchor, m_linear;
    int         tmp;
    EVENT       newev;
    ORD         start;
    int         length;
    int         pos = 0;

    if( uimouseinstalled() ) {
        uiunprotect( g->win );
        uimousepos( g->win, &m_anchor, &m_linear );
        uiprotect( g->win );
        if( g->dir == VERTICAL ) {
            tmp = m_linear;
            m_linear = m_anchor;
            m_anchor = tmp;
        }
        if( ( ev == EV_MOUSE_PRESS ) || ( ev == EV_MOUSE_DCLICK ) ) {
            if( ( m_anchor != g->anchor ) || ( m_linear < g->start ) ||
                ( m_linear > g->end ) || ( Pressed != NULL ) ) {
                return( ev );
            } else {
                Pressed = g;
            }
        }
        /* ignore everything if the gadget was not pressed */
        if( Pressed != g ) return( ev );
        length = g->end - g->start - 1;
        /* don't send pagefoward followed by pagebackward, then forward */
        /* ignore non-mouse events */
        switch( ev ) {
        case EV_MOUSE_PRESS :
            StartPos = g->pos;
        case EV_MOUSE_DCLICK :
            RepeatEvent = EV_NO_EVENT;
        case EV_MOUSE_REPEAT :
            if( Drag ) {
                break;
            }
            if( m_linear == g->start ) {
                return( g->backward );
            }
            if( m_linear == g->end ) {
                return( g->forward );
            }
            /* don't do page up and page down when total size is less than
               or equal to the page size */
            if( g->total_size <= g->page_size ) break;
            start = g->linear; //CalcStart( g, g->pos, length );
            if( m_linear < start ) {
                if( RepeatEvent == g->pageforward ) {
                    return( EV_NO_EVENT );
                } else {
                    RepeatEvent = g->pagebackward;
                    return( g->pagebackward );
                }
            }
            if( m_linear > start ) {
                if( RepeatEvent == g->pagebackward ) {
                    return( EV_NO_EVENT );
                } else {
                    RepeatEvent = g->pageforward;
                    return( g->pageforward );
                }
            }
            break;
        case EV_MOUSE_DRAG :
            /* don't do draging if total_size is less than or equal to the
               page size or mouse is too far from gadget */
            if( ( m_anchor < ( g->anchor -1 ) ) || ( m_anchor > (g->anchor+1) ) ||
                ( g->total_size <= g->page_size ) ) {
                return( EV_NO_EVENT );
            } else {
                Drag = TRUE; /* so we don't send page events on MOUSE_REPEAT */
                if( g->slider == EV_NO_EVENT ) {
                    return( EV_NO_EVENT );
                }
            }
        case EV_MOUSE_RELEASE :
            if( Pressed == NULL ) {
                break;
            }
            if( g->slider == EV_NO_EVENT ) {
                Drag = FALSE;
            }
            if( Drag ) {
                if( ( m_anchor < ( g->anchor -1 ) ) || ( m_anchor > (g->anchor+1) ) ) {
                    /* note : must have got EV_MOUSE_RELEASE */
                    pos = StartPos;
                    setgadget( g, pos, FALSE );
                    m_linear = g->linear;
                    Drag = FALSE;
                } else {
                    /* mouse drag to first scroll character or further left,
                       so pos = 0 */
                    if( m_linear <= ( g->start + 1 ) ) {
                        m_linear = g->start + 1;
                        pos = 0;
                    } else {
                        /* mouse drag to last scroll character or further right,
                           so pos = total_size */
                        if( m_linear >= ( g->end - 1 ) ) {
                            m_linear = g->end - 1;
                            pos = g->total_size - g->page_size;
                         } else {
                            pos = (int)((long)( m_linear - g->start ) *
                                        (long)( g->total_size - g->page_size ) /
                                        (long)length);
                         }
                    }
                }
                g->linear = m_linear;
                uidrawgadget( g );
            }
            if( ( ev == EV_MOUSE_RELEASE ) || ( g->flags & GADGET_TRACK ) ) {
                if( Drag ) {
                    StartPos = pos;
                    g->pos = pos;
                    g->linear = m_linear;
                    setlinear( g );
                    if( g->linear < m_linear ) {
                        g->pos++;
                        setlinear( g );
                    }
                    if( g->linear > m_linear ) {
                        g->pos--;
                        setlinear( g );
                    }
                    newev = g->slider;
                } else {
                    newev = EV_NO_EVENT;
                }
                if( ev == EV_MOUSE_RELEASE ) {
                    Drag = FALSE;
                    Pressed = NULL;
                }
            } else {
                newev = EV_NO_EVENT;
            }
            return( newev );
        case EV_MOUSE_HOLD :
            break;
        default :
            return( ev );
        }
    } else {
        return( ev );
    }
    return( EV_NO_EVENT );
}
Exemplo n.º 4
0
void uiinitgadget( p_gadget g )
{
    setlinear( g );
    drawgadget( g );
    /* do NOT uirefresh here please, it causes screen flashing */
}
Exemplo n.º 5
0
TMOGUIAdjust::TMOGUIAdjust(QWidget* parent, const char * name):
	QFrame(parent, name)
{
	iMode = 0;
	pValues = 0;
	bLog = true;
	bUpdate = false;

	setFrameStyle( QFrame::Panel | QFrame::Sunken );
	QGridLayout *pLayout = new QGridLayout(this, 8, 4);
	pLayout->setColStretch(0,0);
	pLayout->setColStretch(1,1);
	pLayout->setColStretch(2,0);
	pLayout->setColStretch(3,0);
	pLayout->addColSpacing(2,20);
	
	QSlider *pSlider = new QSlider(this, "HistoSlider");
	pSlider->setFixedSize(16,64);
	pSlider->setRange(-50, 50);
	pSlider->setValue(0);
	pSlider->setOrientation(Vertical);
	pSlider->setTickmarks(QSlider::Right);
	pSlider->setTickInterval(10);
	pLayout->addMultiCellWidget(pSlider, 0, 3, 0, 0);

	pHisto = new TMOGUIHisto(this, "Histogram");
	pLayout->addMultiCellWidget(pHisto, 0, 3, 1, 1, AlignBottom);

	pLayout->addRowSpacing(4, 2);

	pToneSlider = new TMOGUIToneSlider(this, "ToneSlider");
	pLayout->addWidget(pToneSlider, 5, 1);

	pRed = new QPushButton(this, "RedButton");
	pRed->setFlat(true);
	pRed->setFixedSize(16,16);
	pRed->setPixmap(*TMOResource::pResource->IconRed->pixmap());
	QToolTip::add(pRed, "Select Red Channel");
	pLayout->addWidget(pRed, 0, 2, AlignCenter);
	
	pGreen = new QPushButton(this, "GreenButton");
	pGreen->setFlat(true);
	pGreen->setFixedSize(16,16);
	pGreen->setPixmap(*TMOResource::pResource->IconGreen->pixmap());
	QToolTip::add(pGreen, "Select Green Channel");
	pLayout->addWidget(pGreen, 1, 2, AlignCenter);

	pBlue = new QPushButton(this, "BlueButton");
	pBlue->setFlat(true);
	pBlue->setFixedSize(16,16);
	pBlue->setPixmap(*TMOResource::pResource->IconBlue->pixmap());
	QToolTip::add(pBlue, "Select Blue Channel");
	pLayout->addWidget(pBlue, 2, 2, AlignCenter);

	pLum = new QPushButton(this, "LumButton");
	pLum->setFlat(true);
	pLum->setFixedSize(16,16);
	pLum->setPixmap(*TMOResource::pResource->IconLumDown->pixmap());	
	QToolTip::add(pLum, "Select Luminance");
	pLayout->addWidget(pLum, 3, 2, AlignCenter);
	
	pLinear = new QPushButton(this, "LinearButton");
	pLinear->setFlat(true);
	pLinear->setFixedSize(32,32);
	pLinear->setPixmap(*TMOResource::pResource->IconLin->pixmap());
	QToolTip::add(pLinear, "View In Linear Distribution");
	pLayout->addMultiCellWidget(pLinear, 0, 1, 3, 3, AlignCenter);

	pLog = new QPushButton(this, "LogarithmicButton");
	pLog->setFlat(true);
	pLog->setFixedSize(32,32);
	pLog->setPixmap(*TMOResource::pResource->IconLogDown->pixmap());
	QToolTip::add(pLog, "View In Logarithmic Distribution");
	pLayout->addMultiCellWidget(pLog, 2, 3, 3, 3, AlignCenter);
	
	pLayout->addRowSpacing(6, 2);

	QHBoxLayout* hbox = new QHBoxLayout();
	QLabel* pLabel = new QLabel(this, "BlackLabel");
	pLabel->setPixmap(*TMOResource::pResource->IconBlack->pixmap());
	pLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
	hbox->addWidget(pLabel);
	pBlack = new QLineEdit(this, "EditBlack");
	pBlack->setAlignment(Qt::AlignRight);
	pBlack->setFixedWidth(72);
	hbox->addWidget(pBlack);
	hbox->insertStretch(-1,1);
	pLabel = new QLabel(this, "GammaLabel");
	pLabel->setPixmap(*TMOResource::pResource->IconGamma->pixmap());
	pLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
	hbox->addWidget(pLabel);
	pGamma = new QLineEdit(this, "EditGamma");
	pGamma->setAlignment(Qt::AlignRight);
	pGamma->setFixedWidth(72);
	hbox->addWidget(pGamma);
	hbox->insertStretch(-1,1);
	pLabel = new QLabel(this, "WhiteLabel");
	pLabel->setPixmap(*TMOResource::pResource->IconWhite->pixmap());
	pLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
	hbox->addWidget(pLabel);
	pWhite = new QLineEdit(this, "EditWhite");
	pWhite->setAlignment(Qt::AlignRight);
	pWhite->setFixedWidth(72);
	hbox->addWidget(pWhite);
	pLayout->addLayout(hbox, 7, 1);


	connect (pSlider, SIGNAL(sliderMoved(int)), this, SLOT(scalechanged(int)));
	connect (pLinear, SIGNAL(clicked()), pHisto, SLOT(setlinear()));
	connect (pLog, SIGNAL(clicked()), pHisto, SLOT(setlog()));
	connect (pRed, SIGNAL(clicked()), pHisto, SLOT(setr()));
	connect (pGreen, SIGNAL(clicked()), pHisto, SLOT(setg()));
	connect (pBlue, SIGNAL(clicked()), pHisto, SLOT(setb()));
	connect (pLum, SIGNAL(clicked()), pHisto, SLOT(setl()));
	connect (pLinear, SIGNAL(clicked()), pToneSlider, SLOT(setlinear()));
	connect (pLog, SIGNAL(clicked()), pToneSlider, SLOT(setlog()));
	connect (pRed, SIGNAL(clicked()), pToneSlider, SLOT(setr()));
	connect (pGreen, SIGNAL(clicked()), pToneSlider, SLOT(setg()));
	connect (pBlue, SIGNAL(clicked()), pToneSlider, SLOT(setb()));
	connect (pLum, SIGNAL(clicked()), pToneSlider, SLOT(setl()));
	connect (pRed, SIGNAL(clicked()), this, SLOT(setr()));
	connect (pGreen, SIGNAL(clicked()), this, SLOT(setg()));
	connect (pBlue, SIGNAL(clicked()), this, SLOT(setb()));
	connect (pLum, SIGNAL(clicked()), this, SLOT(setl()));
	connect (pBlack, SIGNAL(textChanged(const QString &)), this, SLOT(setblack(const QString &)));
	connect (pWhite, SIGNAL(textChanged(const QString &)), this, SLOT(setwhite(const QString &)));
	connect (pGamma, SIGNAL(textChanged(const QString &)), this, SLOT(setgamma(const QString &)));
	connect (pBlack, SIGNAL(returnPressed()), this, SLOT(updateall()));
	connect (pWhite, SIGNAL(returnPressed()), this, SLOT(updateall()));
	connect (pGamma, SIGNAL(returnPressed()), this, SLOT(updateall()));
	connect (pLinear, SIGNAL(clicked()), this, SLOT(setlinear()));
	connect (pLog, SIGNAL(clicked()), this, SLOT(setlog()));
}