예제 #1
0
Calculator::Calculator(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Calculator)
{
    ui->setupUi(this);

    pastNumber = 0;
    currentNumber = ui->lcd->value();
    state = '\0';
    point = false;
    in = false;
    count = 0;

    connect(ui->button0, SIGNAL(clicked()),
            this, SLOT(push0()));
    connect(ui->button1, SIGNAL(clicked()),
            this, SLOT(push1()));
    connect(ui->button2, SIGNAL(clicked()),
            this, SLOT(push2()));
    connect(ui->button3, SIGNAL(clicked()),
            this, SLOT(push3()));
    connect(ui->button4, SIGNAL(clicked()),
            this, SLOT(push4()));
    connect(ui->button5, SIGNAL(clicked()),
            this, SLOT(push5()));
    connect(ui->button6, SIGNAL(clicked()),
            this, SLOT(push6()));
    connect(ui->button7, SIGNAL(clicked()),
            this, SLOT(push7()));
    connect(ui->button8, SIGNAL(clicked()),
            this, SLOT(push8()));
    connect(ui->button9, SIGNAL(clicked()),
            this, SLOT(push9()));
    connect(ui->buttonDot, SIGNAL(clicked()),
            this, SLOT(pushpoint()));
    connect(ui->buttonCE, SIGNAL(clicked()),
            this, SLOT(ce()));
    connect(ui->buttonC, SIGNAL(clicked()),
            this, SLOT(c()));
    connect(ui->buttonPlus, SIGNAL(clicked()),
            this, SLOT(pushPlus()));
    connect(ui->buttonSub, SIGNAL(clicked()),
            this, SLOT(pushSub()));
    connect(ui->buttonTimes, SIGNAL(clicked()),
            this, SLOT(pushTimes()));
    connect(ui->buttonDiv, SIGNAL(clicked()),
            this, SLOT(pushDiv()));
    connect(ui->buttonEqual, SIGNAL(clicked()),
            this, SLOT(pushEqual()));

    QFont font = ui->button0->font();
    font.setPointSize(40);
    ui->button0->setFont(font);
    ui->button1->setFont(font);
    ui->button2->setFont(font);
    ui->button3->setFont(font);
    ui->button4->setFont(font);
    ui->button5->setFont(font);
    ui->button6->setFont(font);
    ui->button7->setFont(font);
    ui->button8->setFont(font);
    ui->button9->setFont(font);
    ui->buttonC->setFont(font);
    ui->buttonCE->setFont(font);
    ui->buttonEqual->setFont(font);
    ui->buttonDiv->setFont(font);
    ui->buttonTimes->setFont(font);
    ui->buttonPlus->setFont(font);
    ui->buttonSub->setFont(font);
    ui->buttonDot->setFont(font);
}
예제 #2
0
/* ----------------------------------------------------------------------------
   function:            for_()             author:              Andrew Cave
   creation date:       22-Oct-1987        last modification:   ##-###-####
   arguments:           none .
   description:

   See PostScript reference manual page 160.  The manual does not define
   correct behaviour when increment is zero, so we emulate behaviour observed
   in (Level 2 and 3) Adobe RIPs, which is to finish without looping if
   initial < limit, and loop forever otherwise, pushing initial on each iteration.

---------------------------------------------------------------------------- */
Bool for_(ps_context_t *pscontext)
{
  register int32 inc , current , ilimit ;
  register OBJECT *o1 , *o2 , *o3 , *o4 ;
  int32 loop ;
  SYSTEMVALUE args[ 3 ] ;

  UNUSED_PARAM(ps_context_t *, pscontext) ;

  if ( theStackSize( operandstack ) < 3 )
    return error_handler( STACKUNDERFLOW ) ;

  o4 = theTop( operandstack ) ;
  o3 = ( & o4[ -1 ] ) ;
  o2 = ( & o4[ -2 ] ) ;
  o1 = ( & o4[ -3 ] ) ;
  if ( ! fastStackAccess( operandstack )) {
    o3 = stackindex( 1 , & operandstack ) ;
    o2 = stackindex( 2 , & operandstack ) ;
    o1 = stackindex( 3 , & operandstack ) ;
  }

  switch ( oType(*o4) ) {
  case OARRAY :
  case OPACKEDARRAY :
    break ;
  default:
    return error_handler( TYPECHECK ) ;
  }
  if ( ! oCanExec(*o4) && !object_access_override(o4) )
    return error_handler( INVALIDACCESS ) ;

  if ( oType(*o1) == OINTEGER &&
       oType(*o2) == OINTEGER &&
       oType(*o3) == OINTEGER ) {
    current     = oInteger(*o1) ;
    inc         = oInteger(*o2) ;
    ilimit      = oInteger(*o3) ;

    /* Tests indicate we should loop forever iff inc == 0 && current >= ilimit */

    if (( inc > 0 ) ? ( current > ilimit ) : ( current < ilimit )) {
      npop( 4 , & operandstack ) ;
      return TRUE ;
    }

    if ( ! push4( o1, o2 , o3 , o4 , & executionstack ))
      return FALSE ;
    if ( ! xsetup_operator( NAME_xfastfori , 5 ))
      return FALSE ;
    if ( ! push( o4 , & executionstack ))
      return FALSE ;

    npop( 3 , & operandstack ) ;
    HQASSERT(oInteger(*o1) == current, "current changed mysteriously") ;

    return TRUE ;
  }
/* Slow default case. */

  if ( !object_get_numeric(o1, &args[0]) ||
       !object_get_numeric(o2, &args[1]) ||
       !object_get_numeric(o3, &args[2]) )
    return FALSE ;

  if ( oType(*o1) == OINTEGER && oType(*o2) == OINTEGER && intrange(args[2])) {
    if ( ! push4( o1 , o2 , o3 , o4 , & executionstack ))
      return FALSE ;
    if ( ! xsetup_operator( NAME_xfori , 5 ))
      return FALSE ;
  }
  else {
    for ( loop = 0 ; loop < 3 ; ++loop )
      if ( ! stack_push_real(args[loop], &executionstack) )
        return FALSE ;
    if ( ! push( o4 , & executionstack ))
      return FALSE ;
    if ( ! xsetup_operator( NAME_xforr , 5 ))
      return FALSE ;
  }
  npop( 4 , & operandstack ) ;
  return TRUE ;
}