Пример #1
0
void kdvi::makeToolBar2(QWidget *parent)
{
    QPixmap pm;

    toolBar2 = new QFrame( parent );

    QBoxLayout * gl = new QBoxLayout( toolBar2, QBoxLayout::Down );

    sbox = new ScrollBox( toolBar2 );
    connect( sbox, SIGNAL(valueChanged(QPoint)),
             dviwin, SLOT(scroll(QPoint)) );
    connect( sbox, SIGNAL(button3Pressed()), dviwin, SLOT(nextPage()) );
    connect( sbox, SIGNAL(button2Pressed()), dviwin, SLOT(prevPage()) );
    connect( dviwin, SIGNAL(pageSizeChanged( QSize )),
             sbox, SLOT(setPageSize( QSize )) );
    connect( dviwin, SIGNAL(viewSizeChanged( QSize )),
             sbox, SLOT(setViewSize( QSize )) );
    connect( dviwin, SIGNAL(currentPosChanged( QPoint )),
             sbox, SLOT(setViewPos( QPoint )) );
    QToolTip::add( sbox, 0, tipgroup, i18n("Scroll window and switch the page") );
    sbox->setFixedSize(70,80);
    gl->addWidget( sbox );

    // Create a MarkList

    marklist = new MarkList( toolBar2 );
    connect( marklist, SIGNAL(selected(const char *)),
             SLOT(pageActivated(const char *)) );
    QToolTip::add( marklist, 0, tipgroup, i18n("Select page and mark pages for printing") );

    gl->addWidget( marklist );
    gl->activate();

    sbox->setPageSize( dviwin->pageSize() );
}
Пример #2
0
void ScrollBox::mousePressEvent(QMouseEvent* e)
{
    m_mouse = e->pos();
    if (e->button() == Qt::RightButton)
        emit button3Pressed();
    if (e->button() == Qt::MidButton)
        emit button2Pressed();
}
Пример #3
0
Frame::Frame(QWidget* parent, const char* name): QFrame(parent, name){
    button1 = new QPushButton("Simple Popup", this);
    connect ( button1, SIGNAL( clicked() ), SLOT( button1Clicked() ) );
    button2 = new QPushButton("Fancy Popup", this);
    connect ( button2, SIGNAL( pressed() ), SLOT( button2Pressed() ) );

    QBoxLayout * l = new QHBoxLayout( this );
    button1->setMaximumSize(button1->sizeHint());
    button2->setMaximumSize(button2->sizeHint());
    l->addWidget( button1 );
    l->addWidget( button2 );
    l->activate();

//     button1->setGeometry(20,20,100,30);
//     button2->setGeometry(140,20,100,30);
    resize(270, 70);

    //create a very simple popup: it is just composed with other
    //widget and will be shown after clicking on button1

    popup1 = new QFrame( this ,0, WType_Popup);
    popup1->setFrameStyle( WinPanel|Raised );
    popup1->resize(150,100);
    QLineEdit *tmpE = new QLineEdit( popup1 );
    connect( tmpE, SIGNAL( returnPressed() ), popup1, SLOT( hide() ) );
    tmpE->setGeometry(10,10, 130, 30);
    tmpE->setFocus();
    QPushButton *tmpB = new QPushButton("Click me!", popup1);
    connect( tmpB, SIGNAL( clicked() ), popup1, SLOT( close() ) );
    tmpB->setGeometry(10, 50, 130, 30);

    // the fancier version uses its own class. It will be shown when
    // pressing button2, so they behavior is more like a modern menu
    // or toolbar.

    popup2 = new FancyPopup( this );

    // you might also add new widgets to the popup, just like you do
    // it with any other widget.  The next four lines (if not
    // commented out) will for instance add a line edit widget.

//     tmpE = new QLineEdit( popup2 );
//     tmpE->setFocus();
//     connect( tmpE, SIGNAL( returnPressed() ), popup2, SLOT( close() ) );
//     tmpE->setGeometry(10, 10, 130, 30);
}
Пример #4
0
int main(void)
{
	// init hardware setup
	init();

	// setup temperature resolution
	// write temperature register pointer
	i2c_start(TEMPSENS_ADDRESS, I2C_WRITE);
	i2c_write(0x01);
	i2c_write(0b01100000);
	i2c_stop();

    while(1)
    {
		// change mode by pressed button
		if (button1Pressed())
		{
			mode = MODE_1;
		}
		else if (button2Pressed())
		{
			mode = MODE_2;
		}
		else if (button3Pressed())
		{
			mode = MODE_3;
		}

		// mode1
		if (mode == MODE_1)
		{
			// read analog value from potentiometer
			uint32_t pot = readAnalog(POT_CHANNEL);
			pot *= 4888;
			pot += 500;
			pot /= 1000;

			if (++mydelay >= 10)
			{
				writeDisplayNumber(pot, 0);
				mydelay = 0;
			}
			

			// led1 on
			sbit(OUTPORT(LED1_PORT), LED1_BIT);
		}
		else
		{
			// led1 off
			cbit(OUTPORT(LED1_PORT), LED1_BIT);			
		}

		// mode2
		if (mode == MODE_2)
		{

			int16_t temp = readTemperature();
			writeDisplayTemp(temp, 2);

			// led2 on
			sbit(OUTPORT(LED2_PORT), LED2_BIT);
		}
		else
		{
			// led2 off
			cbit(OUTPORT(LED2_PORT), LED2_BIT);
		}

		// show potentiometer value		
		if (mode == MODE_3)
		{
			// led3 on
			sbit(OUTPORT(LED3_PORT), LED3_BIT);
			
			mode3();
			
			/*
			if (mydelay < 12)
			{
				// turn-on buzzer
				// frequency 2kHz
				ICR1 = 2000;
				OCR1A = 1000;
				// write to display
				writeDisplayData(convertBcd(DIGIT_MINUS, DIGIT_MINUS, DIGIT_BLANK, DIGIT_BLANK, 255));
			}
			else
			{
				// turn-on buzzer
				// frequency 2kHz
				ICR1 = 4000;
				OCR1A = 2000;
				// write to display
				writeDisplayData(convertBcd(DIGIT_BLANK, DIGIT_BLANK, DIGIT_MINUS, DIGIT_MINUS, 255));			}
			if (++mydelay >= 25) mydelay = 0;
			*/
		}
		else
		{
			// turn-off buzzer
			ICR1 = 0;
			// led3 off
			cbit(OUTPORT(LED3_PORT), LED3_BIT);
		}


		// wait until all mode buttons are released
		while (button1Pressed() || button2Pressed() || button3Pressed());
		_delay_ms(20);
    }
}