예제 #1
0
void QKeyPushButton::getKeyPress(bool capsStatus)
{
	int 		keyCode = 0;
	QKeyEvent	*key = NULL;
	QString		text = this->text();
	//
	// per tutti i car speciali tranne il CAPS (RETURN, ALT, SHIFT, ecc...) inoltra al componente widgetKeyBoard:
        if (NO_SPECIAL_KEY(text) == false && (IS_BACK(text) == true || IS_BACK_EMB(text) == true || IS_TAB(text) == true || IS_RETURN(text) == true || IS_CTRL_LEFT(text) == true ||
                        IS_ALT(text) == true || IS_CANC(text) == true || IS_CUT_LEFT(text) == true || IS_PASSWORD(text) || IS_PASSWORD_EMB(text) || IS_PASTE(text) || IS_COPY(text)))
		key = new QKeyEvent(QEvent::KeyPress, keyCode, Qt::NoModifier, text);
	else { // trattasi di caratteri stampabili
		keyCode = text.toAscii()[0]; // prende il valore numerico (sempre maiuscolo)
                if (capsStatus == false) { // se deve prendere minuscolo, controlla se il carattere è alfabetico
                    if (keyCode >= tr("A")[0] && keyCode <= tr("Z")[0]) {
                            keyCode += 32; // carattere piccolo
                            text = (char ) keyCode; // carattere piccolo
                    }
                    key = new QKeyEvent(QEvent::KeyPress, keyCode, Qt::NoModifier, text);
		}
		else
                    key = new QKeyEvent(QEvent::KeyPress, keyCode, Qt::ShiftModifier, text);
	}
        ((widgetKeyBoard *) this->m_parent)->receiptChildKey(key, NULL);
	QCoreApplication::processEvents();
}
예제 #2
0
static void trickyRemoveHandler (NXHandler *handler, int removingAlt)
{
  AltHandler *altNode;
  NXHandler *node;
  NXHandler **nodePtr;
  ExceptionHandlerStack *me = findme ();
  
  /* try to find the node anywhere on the stack */
  node = me->handlerStack;
  while (node != handler && node)
    {
      /* Watch for attempts to remove handlers which are outside the
	 active portion of the stack.  This happens when you return
	 from an NX_DURING context without removing the handler.
	 This code assumes the stack grows downward. */
#if hppa
	/* stack grows upward */
      if (IS_ALT (node) || (void *) node < (void *) &altNode)
	node = NEXT_HANDLER (node);
      else
#else
      if (IS_ALT (node) || (void *) node > (void *) &altNode)
	node = NEXT_HANDLER (node);
      else
#endif
	{
	  _NXLogError ("Exception handlers were not properly removed.");
#if defined(WIN32)
	  (void)RaiseException(0xdead, EXCEPTION_NONCONTINUABLE, 0, NULL);
#else
	  (void)abort ();
#endif
	}
    }
  
  if (node)
    {
      /* 
      * Clean off the stack up to the out of place node.  If we are trying
      * to remove an non-alt handler, we pop eveything off the stack
      * including that handler, calling any alt procs along the way.  If
      * we are removing an alt handler, we leave all the non-alt handlers
      * alone as we clean off the stack, but pop off all the alt handlers
      * we find, including the node we were asked to remove.
      */
      if (!removingAlt)
	_NXLogError ("Exception handlers were not properly removed.");
      
      nodePtr = &me->handlerStack;
      do
	{
	  node = *nodePtr;
	  if (IS_ALT(node))
	    {
	      altNode = ALT_CODE_TO_PTR(node);
	      if (removingAlt)
	        {
		  if (node == handler)
		    *nodePtr = altNode->next;	/* del matching node */
		  else
		    nodePtr = &altNode->next;	/* skip node */
	        }
	      else
	        {
		  if (node != handler)
		    (*altNode->proc)(altNode->context, 1, 0, 0);
		  me->altHandlersUsed = altNode - me->altHandlers;
		  *nodePtr = altNode->next;	/* del any alt node */
	        }
	    }
	  else
	    {
	      if (removingAlt)
		nodePtr = &node->next;		/* skip node */
	      else
		*nodePtr = node->next;		/* nuke non-alt node */
	    }
	}
      while (node != handler);
    }
  else
    {
#ifdef KERNEL
      ;
#else /* KERNEL */
      _NXLogError ("Attempt to remove unrecognized exception handler.");
#endif /* KERNEL */
    }
}
예제 #3
0
//
// riceve i caratteri che sono stati digitati:
void widgetKeyBoard::receiptChildKey(QKeyEvent *event, QLineEdit *focusThisControl, bool reset)
{
        static QLineEdit    *nextInput = NULL;

	if (reset == true) { // reinizializza il controllo
                nextInput = this->getNextTextbox(focusThisControl, true);
		return;
	}        
	if (nextInput == NULL)
		return;        
	//
	// inizia l'analisi del carattere ricevuto:
	QString	newKey = event->text();
	QString tmpReceiptString = nextInput->text();
        int     tmpPos = nextInput->cursorPosition();

        if (NO_SPECIAL_KEY(newKey) == false) {
            if (IS_RETURN(newKey) == true || IS_TAB(newKey) == true) { // trattasi di TAB, si sposta alla text successiva
                nextInput = this->setDefaultTextStyle(nextInput);
                nextInput->deselect();
                nextInput = this->getNextTextbox();
                this->controlKeyEcho(nextInput); // status of key echo here
                if (nextInput != NULL) {
                    nextInput->setCursorPosition(nextInput->text().length()); // comment this line if you want caret position at current char inserted
                    nextInput->setFocus(Qt::TabFocusReason);
                }
            }
            else if (IS_BACK(newKey) == true || IS_BACK_EMB(newKey) == true) { // trattasi di CANCELLARE carattere, elimina il carattere a sinistra
                if (tmpPos-1 >= 0) {
                    tmpReceiptString = tmpReceiptString.remove(tmpPos-1, 1);
                    nextInput->setText(tmpReceiptString);
                    nextInput->setCursorPosition(tmpPos-1);
                    nextInput->setSelection(tmpPos-2, 1);
                }
            }
            else if (IS_CANC(newKey) == true) { // trattasi di CANC carattere, elimina il carattere a destra
                 tmpReceiptString = tmpReceiptString.remove(tmpPos, 1);
                 nextInput->setText(tmpReceiptString);
                 nextInput->setCursorPosition(tmpPos);
                 nextInput->setSelection(tmpPos-1, 1);
            }
            else if (IS_COPY(newKey) == true || IS_CUT_LEFT(newKey) == true) {
                QPushButton *button = this->findChild<QPushButton *>(KEY_PASTE);

                if (button != NULL) {
                    if (nextInput->text().length() != 0) {
                        this->m_clipboard->setText(nextInput->text());
                        if (IS_CUT_LEFT(newKey) == true)
                            nextInput->setText("");
                        button->setEnabled(true);
                    }
                    else
                        button->setEnabled(false);
                }
            }
            else if (IS_PASTE(newKey) == true)
                nextInput->setText(this->m_clipboard->text());
            else if (IS_ALT(newKey) == true || IS_CTRL_LEFT(newKey) == true)
                ; // non esegue nessuna operazione
        }
        else { // si tratta di un carattere da visualizzare nella casella di testo corrente
            tmpReceiptString = tmpReceiptString.insert(tmpPos, newKey);
            nextInput->setText(tmpReceiptString);
            nextInput->setCursorPosition(tmpPos+1);
            nextInput->setSelection(tmpPos, 1);
	}
}