示例#1
0
void LoginForm::onChar(wxKeyEvent& event)
{
	if (event.m_keyCode == WXK_TAB)
	{
		processTab(!event.ShiftDown(), event.GetId());
	}
	else
	{
		if (event.GetId() == m_cbRemPass->GetId())
		{
			if (event.m_keyCode == WXK_RETURN)
				doLogin();
			else if (event.m_keyCode == ' ')
				m_cbRemPass->SetValue(!m_cbRemPass->GetValue());
		}

		if (event.GetKeyCode() == WXK_CONTROL_A)
		{
			if (event.GetId() == m_tbPassword->GetId())
				m_tbPassword->SelectAll();
			else if (event.GetId() == m_tbUsername->GetId())
				m_tbUsername->SelectAll();
		}

		event.Skip();
	}
}
示例#2
0
void LoginForm::onFormChar(wxKeyEvent& event)
{
	if (event.m_keyCode == WXK_TAB)
	{
		processTab(!event.ShiftDown(), event.GetId());
	}
	else
	{
		int32 keyCode = event.GetKeyCode();
		if (!event.HasModifiers() && ((keyCode >= '0' && keyCode <= '9') || (keyCode >= 'a' && keyCode <= 'z') || (keyCode >= 'A' && keyCode <= 'Z' )))
		{
			m_tbUsername->SetFocus();
			m_tbUsername->SetValue((char)keyCode);
			m_tbUsername->SetInsertionPointEnd();
		}
	}
}
示例#3
0
文件: waver.c 项目: cruel2/devel
int main(int argc, char ** argv)
{
    int i;
    float t;
    float amplitude = 16000;
    float freq_Hz = 440;
    float phase1 = 0.0;
    float phase2 = 0.0;
    float phase3 = 0.0;
    
    // initialization for global variables
    noNotes = 0;
    VOLUME = 0.0;
    
    init();
    
    if (readConfig("config.ini") != 1)
    {
      fprintf(stderr, "Couldn't read config file!\n");
      return -1;
    }
    
    if (readTab("test.tab") != 1)
    {
      fprintf(stderr, "Couldn't read tab file!\n");
      return -1;
    }
    
    printf("length: %f\n", getTabLength());
    
    // TODO : miert kell ide a 2-es szorzo?
    bufferSize = 2*(int)ceil(S_RATE * getTabLength());
    buffer = (int*)calloc(sizeof(int), bufferSize);
    
    processTab();
 
    write_wav("test.wav", bufferSize, buffer, S_RATE);
    
    free(buffer);
    
    destroy();
 
    return 0;
}
示例#4
0
void LoginForm::onChar(wxKeyEvent& event)
{ 
	if (event.m_keyCode == WXK_TAB)
	{
		processTab(!event.ShiftDown(), event.GetId());
	}
	else
	{
#ifndef UI_HIDE_AUTOLOGIN
		if (event.GetId() == m_cbRemPass->GetId())
		{
			if (event.m_keyCode == WXK_RETURN)
				doLogin();
			else if (event.m_keyCode == ' ')
				m_cbRemPass->SetValue(!m_cbRemPass->GetValue());
		}
#endif

		event.Skip(); 
	}
}
 void QFCompleterTextEditWidget::keyPressEvent(QKeyEvent *event) {
     if (c && c->popup()->isVisible()) {
         // The following keys are forwarded by the completer to the widget
        switch (event->key()) {
            case Qt::Key_Enter:
            case Qt::Key_Return:
            case Qt::Key_Escape:
            case Qt::Key_Tab:
            case Qt::Key_Backtab:
                 event->ignore();
                 return; // completer widgets handles these keys!
            default:
                break;
        }
     } else {
        // if the completer is not visible, we may treat some special
        // key press events (convert TAB to spaces ...
        if (event->key()==Qt::Key_Tab) { // convert TAB to <tabwidth> spaces
            processTab(event);
            return; // let the completer do default behavior
        } else if (event->key()==Qt::Key_Backtab || (event->key()==Qt::Key_Tab && event->modifiers()==Qt::ShiftModifier)) {
            indentDec();
            return; // let the completer do default behavior
        } else if (event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) {
            // indent when last non-space character in current line is '{'
            QTextCursor tc = textCursor();

            // if text has been selected, the user wants to overwrite this text
            // with a linebreak, so we first delete the text
            if (tc.hasSelection()) tc.deleteChar();
            //tc.select(QTextCursor::LineUnderCursor);
            tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
            QString line=tc.selectedText();

            // count leading spaces
            int lspaces=0;
            QChar* data=line.data();
            while (data->isSpace()) {
                ++data;
                lspaces++;
            }
            // get right-most non-space character
            int indx=line.size()-1;
            data=line.data();
            if (indx>=0) while (data[indx].isSpace() && (indx>0)) {
                indx--;
            }
            QChar last=data[indx];

            if (last=='{') {
                QTextCursor c(textCursor());
                c.insertText("\n"+QString(lspaces, QChar(' '))+tabToSpaces());
                setTextCursor(c);
            } else if (last=='}' && line.indexOf('}')==lspaces) {
                // '}' is the first non-space character in this line
                QTextCursor c(textCursor());
                QTextCursor c1(textCursor());
                c1.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
                QString left=c1.selectedText();
                if (lspaces>0 && left=="}") {
                    long clspaces=lspaces; // the number of leading spaces in the current line
                    long indention=qMax((long)0, (long)lspaces-(long)tabwidth); // new number of leading spaces
                    // here we try to find the matching '{' and reduce the indention to the
                    // indention of the matching '{'. If the matching '{' was not found,
                    // the indention will not be reduced
                    QTextCursor cc(textCursor());
                    int cnt=1;
                    int pos=cc.selectionStart()-2;
                    while ((cnt>0) && (pos>=0)) {
                        cc.setPosition(pos);
                        cc.setPosition(pos+1, QTextCursor::KeepAnchor);
                        QString curChar=cc.selectedText();
                        if (curChar=="{") cnt--;
                        if (curChar=="}") cnt++;
                        //std::cout<<"'"<<(char*)curChar.toLatin1().data()<<"'  cnt="<<cnt<<"  pos="<<pos<<std::endl;
                        pos--;
                    }
                    // here we found the matching '{' and count its leading spaces
                    if (pos>=0){
                        cc.select(QTextCursor::LineUnderCursor);
                        lspaces=0;
                        QChar* data=cc.selectedText().data();
                        while (data->isSpace()) {
                            ++data;
                            lspaces++;
                        }
                        indention=lspaces;
                    }
                    //std::cout<<"indention="<<indention<<"   clspaces="<<clspaces<<"    lspaces="<<lspaces<<std::endl;
                    c=textCursor();
                    c.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
                    c.insertText(QString(indention, QChar(' '))+line.right(qMax((long)1,(long)line.size()-clspaces))+"\n"+QString(indention, QChar(' ')));
                    //c.movePosition(QTextCursor::Left);
                    //c.insertText("\n"+QString(lspaces, QChar(' ')));
                } else {
                    c=textCursor();
                    c.insertText("\n");
                }
                setTextCursor(c);
            } else {
                QTextCursor c(textCursor());
                c.insertText("\n"+QString(lspaces, QChar(' ')));
                setTextCursor(c);
            }
            return;
        }
     }


     bool isShortcut = ((event->modifiers() & Qt::ControlModifier) && event->key() == Qt::Key_E); // CTRL+E
     if (!c || !isShortcut) // dont process the shortcut when we have a completer
         QTextEdit::keyPressEvent(event);

     const bool ctrlOrShift = event->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
     if (!c || (ctrlOrShift && event->text().isEmpty()))
         return;

     static QString eow("~!@#$%^&*()+{}|:\"<>?,./;'[]\\-="); // end of word
     bool hasModifier = (event->modifiers() != Qt::NoModifier) && !ctrlOrShift;
     QString completionPrefix = textUnderCursor();
     /*QMessageBox::information(this, "", tr("completionPrefix=%1\nisShortcut=%2\nctrlOrShif=%3\nhasModifier=%4")
                                            .arg(completionPrefix)
                                            .arg(isShortcut)
                                            .arg(ctrlOrShift)
                                            .arg(hasModifier)
                                            );*/

     if (!isShortcut && (hasModifier || event->text().isEmpty()|| completionPrefix.length() < 2
                       || eow.contains(event->text().right(1)))) {
         c->popup()->hide();
         return;
     }
     /*QMessageBox::information(this, "", tr("c->completionPrefix=%1\ncompletionPrefix=%2")
                                            .arg(c->completionPrefix())
                                            .arg(completionPrefix)
                                            );*/
     if (completionPrefix != c->completionPrefix()) {
         c->setCompletionPrefix(completionPrefix);
         /*QMessageBox::information(this, "", tr("c->completionModel()->rowCount()=%1")
                                            .arg(c->completionModel()->rowCount())
                                            );*/
         c->popup()->setCurrentIndex(c->completionModel()->index(0, 0));
     }
     QRect cr = cursorRect();
     cr.setWidth(c->popup()->sizeHintForColumn(0)
                 + c->popup()->verticalScrollBar()->sizeHint().width());
     c->complete(cr); // popup it up!
     /*QMessageBox::information(this, "", tr("cr.width=%1\ncr.height=%2\ncr.x=%3\ncr.y=%4")
                                            .arg(cr.width())
                                            .arg(cr.height())
                                            .arg(cr.x())
                                            .arg(cr.y())
                                            );*/
}