/* flip - pageflipper for TIFF animations * Copyright (C) 1999 Mark B. Allan (mba@reptilelabour.com) * * "flip" is free software; you can redistribute it and/or use * it and/or modify it under the terms of the "Artistic License" */ #include "InputLCD.h" #include #include InputLCD::InputLCD (QWidget* parent, const char* name) : QLCDNumber (parent, name) { setFrameStyle( QFrame::Sunken | QFrame::Panel ); setNumDigits( 4 ); setMode( QLCDNumber::DEC ); setCursor (sizeHorCursor); // setSegmentStyle( QLCDNumber::Flat ); minInt = -(INT_MAX-1); maxInt = (INT_MAX-1); LCDactive = FALSE; display (" "); } //---------------------------------------------------------------- void InputLCD::setActive (bool status) { LCDactive = status; if (LCDactive == FALSE) { display (" "); } } //---------------------------------------------------------------- void InputLCD::setValue (int val) { LCDactive = TRUE; if (val < minInt) val = minInt; if (val > maxInt) val = maxInt; display (val); } //---------------------------------------------------------------- void InputLCD::setMinInt (int val) { minInt = val; } void InputLCD::setMaxInt (int val) { maxInt = val; } void InputLCD::setMinMaxInt (int min, int max) { minInt = min; maxInt = max; } //---------------------------------------------------------------- void InputLCD::mousePressEvent ( QMouseEvent *msEv ) { lastXPos = msEv->x(); } //---------------------------------------------------------------- void InputLCD::mouseMoveEvent ( QMouseEvent *msEv ) { int tempInt; int newInt; if (LCDactive) { tempInt = msEv->x()-lastXPos; switch (msEv->state()) { case (LeftButton): break; case (LeftButton | ControlButton) : tempInt *= 10; break; default : tempInt = 0; } newInt = intValue() + tempInt; if (newInt < minInt) newInt = minInt; else if (newInt > maxInt) newInt = maxInt; if (intValue() != newInt ) { emit valueChanged(newInt); display (newInt); } } lastXPos = msEv->x(); }