⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qimpensetup.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.7平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    pw = new QIMPenWidget( this );    pw->setFixedHeight( 75 );    gl->addMultiCellWidget( pw, 2, 3, 0, 0 );    connect( pw, SIGNAL(stroke(QIMPenStroke *)),                 SLOT(newStroke(QIMPenStroke *)) );    QVBoxLayout *vb = new QVBoxLayout();    gl->addLayout( vb, 1, 1 );    newBtn = new QPushButton( tr("New..."), this );    connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) );    vb->addWidget( newBtn );    addBtn = new QPushButton( tr("Add"), this );    connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) );    vb->addWidget( addBtn );    removeBtn = new QPushButton( tr("Remove"), this );    connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) );    vb->addWidget( removeBtn );    QPushButton *pb = new QPushButton( tr("Default"), this );    connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) );    vb->addWidget( pb );    QHBoxLayout *hb = new QHBoxLayout();    gl->addLayout( hb, 2, 1 );    prevBtn = new QPushButton( this );    prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) );    connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar()));    hb->addWidget( prevBtn );    nextBtn = new QPushButton( this );    nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) );    connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar()));    hb->addWidget( nextBtn );    pb = new QPushButton( tr("Clear"), this );    connect( pb, SIGNAL(clicked()), SLOT(clearChar()) );    gl->addWidget( pb, 3, 1 );    //--#if !defined(Q_WS_QWS)    hb = new QHBoxLayout( tvb );    pb = new QPushButton( tr("OK"), this );    connect( pb, SIGNAL(clicked()), SLOT(accept()) );    hb->addWidget( pb );    pb = new QPushButton( tr("Cancel"), this );    connect( pb, SIGNAL(clicked()), SLOT(reject()) );    hb->addWidget( pb );#endif    int ch = lastCh;    if ( lastCs > int(profile->charSets().count())-1 )	lastCs = 0;    charSetCombo->setCurrentItem( lastCs );    selectCharSet( lastCs );    if ( ch < int(charList->count()) ) {	selectChar( ch );        charList->setSelected( ch, TRUE );    } else {	lastCh = 0;    }    charList->setFocus();    resize( minimumSize() );    enableButtons();}void QIMPenEdit::setProfile( QIMPenProfile *p ){    profile = p;    charSetCombo->clear();    QIMPenCharSetIterator it( profile->charSets() );    for ( ; it.current(); ++it ) {        charSetCombo->insertItem( it.current()->description() );    }    selectCharSet( 0 );    charList->setFocus();    enableButtons();}void QIMPenEdit::selectCharSet( QIMPenCharSet *c ){    int i = 0;    QIMPenCharSetIterator it( profile->charSets() );    for ( ; it.current(); ++it, i++ ) {        if ( it.current() == c ) {	    charSetCombo->setCurrentItem( i );	    selectCharSet( i );	}    }}/*!  Fill the character list box with the characters.  Duplicates are not  inserted.*/void QIMPenEdit::fillCharList(){    charList->clear();    QIMPenCharIterator it( currentSet->characters() );    CharListItem *li = 0;    for ( ; it.current(); ++it ) {	uint ch = it.current()->character();	QString n = it.current()->name();	if ( !n.isEmpty() )	    li = new CharListItem( n, ch );	if ( li ) {	    CharListItem *i = (CharListItem *)charList->findItem( li->text() );	    if ( !i || i->code() != ch ) {		charList->insertItem( li );	    } else {		delete li;		li = 0;	    }	}    }    currentChar = 0;}void QIMPenEdit::enableButtons(){    bool add =  !inputChar->isEmpty();    newBtn->setEnabled( add );    addBtn->setEnabled( add );    removeBtn->setEnabled( currentChar );}/*!  Find the previous character with the same code as the current one.  returns 0 if there is no previous character.*/QIMPenChar *QIMPenEdit::findPrev(){    if ( !currentChar )	return 0;    QIMPenCharIterator it( currentSet->characters() );    bool found = FALSE;    for ( it.toLast(); it.current(); --it ) {        if ( !found && it.current() == currentChar )            found = TRUE;        else if ( found && it.current()->character() == currentCode &&                !it.current()->testFlag( QIMPenChar::Deleted ) ) {            return it.current();        }    }    return 0;}/*!  Find the next character with the same code as the current one.  returns 0 if there is no next character.*/QIMPenChar *QIMPenEdit::findNext(){    if ( !currentChar )	return 0;    QIMPenCharIterator it( currentSet->characters() );    bool found = FALSE;    for ( ; it.current(); ++it ) {	if ( !found && it.current() == currentChar )	    found = TRUE;	else if ( found && it.current()->character() == currentCode &&		    !it.current()->testFlag( QIMPenChar::Deleted ) ) {	    return it.current();	}    }    return 0;}void QIMPenEdit::setCurrentChar( QIMPenChar *pc ){    currentChar = pc;    pw->showCharacter( currentChar );    if ( currentChar ) {	prevBtn->setEnabled( findPrev() != 0 );	nextBtn->setEnabled( findNext() != 0 );    }}void QIMPenEdit::prevChar(){    QIMPenChar *pc = findPrev();    if ( pc )	setCurrentChar( pc );}void QIMPenEdit::nextChar(){    QIMPenChar *pc = findNext();    if ( pc )	setCurrentChar( pc );}void QIMPenEdit::clearChar(){    inputChar->clear();    pw->clear();    enableButtons();}void QIMPenEdit::selectChar( int i ){    currentChar = 0;    currentCode = ((CharListItem *)charList->item(i))->code();    QIMPenCharIterator it(currentSet->characters() );    for ( ; it.current(); ++it ) {	if ( it.current()->character() == currentCode &&	     !it.current()->testFlag( QIMPenChar::Deleted ) ) {	    setCurrentChar( it.current() );	    break;	}    }    if ( !it.current() )	setCurrentChar( 0 );    inputChar->clear();    enableButtons();    lastCh = i;}void QIMPenEdit::selectCharSet( int i ){    if ( currentSet )        pw->removeCharSet( 0 );    currentSet = profile->charSets().at( i );    fillCharList();    pw->insertCharSet( currentSet );    inputChar->clear();    if ( charList->count() ) {        charList->setSelected( 0, TRUE );        selectChar(0);    }    lastCs = i;}void QIMPenEdit::addChar(){    if ( !inputChar->isEmpty() ) {        QIMPenChar *pc = new QIMPenChar( *inputChar );        pc->setCharacter( currentCode );	// User characters override all matching system characters.	// Copy and mark deleted identical system characters.	QIMPenCharIterator it(currentSet->characters() );	QIMPenChar *sc = 0;	while ( (sc = it.current()) != 0 ) {	    ++it;	    if ( sc->character() == currentCode &&		 sc->testFlag( QIMPenChar::System ) &&		 !sc->testFlag( QIMPenChar::Deleted ) ) {		QIMPenChar *cc = new QIMPenChar( *sc );		cc->clearFlag( QIMPenChar::System );		currentSet->addChar( cc );		sc->setFlag( QIMPenChar::Deleted );	    }	}        currentSet->addChar( pc );        setCurrentChar( pc );        inputChar->clear();	enableButtons();    }}void QIMPenEdit::addNewChar(){    if ( !inputChar->isEmpty() ) {	QIMPenInputCharDlg dlg( 0, 0, TRUE );	if ( dlg.exec() ) {	    currentCode = dlg.unicode();	    addChar();	    fillCharList();	    for ( unsigned int i = 0; i < charList->count(); i++ ) {		CharListItem *li = (CharListItem *)charList->item(i);		if ( li->code() == dlg.unicode() ) {		    charList->setSelected( i, TRUE );		    break;		}	    }	}    }}void QIMPenEdit::removeChar(){    if ( currentChar ) {	QIMPenChar *pc = findPrev();	if ( !pc ) pc = findNext();	if ( currentChar->testFlag( QIMPenChar::System ) )	    currentChar->setFlag( QIMPenChar::Deleted );	else	    currentSet->removeChar( currentChar );	setCurrentChar( pc );    }}void QIMPenEdit::defaultChars(){    if ( currentCode ) {	currentChar = 0;	bool haveSystem = FALSE;	QIMPenCharIterator it(currentSet->characters() );	for ( ; it.current(); ++it ) {	    if ( it.current()->character() == currentCode &&		 it.current()->testFlag( QIMPenChar::System ) ) {		haveSystem = TRUE;		break;	    }	}	if ( haveSystem ) {	    it.toFirst();	    while ( it.current() ) {		QIMPenChar *pc = it.current();		++it;		if ( pc->character() == currentCode ) {		    if ( pc->testFlag( QIMPenChar::System ) ) {			pc->clearFlag( QIMPenChar::Deleted );			if ( !currentChar )			    currentChar = pc;		    } else {			currentSet->removeChar( pc );		    }		}	    }	    setCurrentChar( currentChar );	}    }}void QIMPenEdit::newStroke( QIMPenStroke *st ){    inputChar->addStroke( st );    enableButtons();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -