コード例 #1
0
	void decomposeReorderMatras ( const IndicClassTable *classTable, le_int32 beginSyllable, le_int32 nextSyllable, le_int32 inv_count ) {
		le_int32 i;
        LEErrorCode success = LE_NO_ERROR;

		for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
			if ( classTable->isMatra(fOutChars[i+inv_count])) {
				IndicClassTable::CharClass matraClass = classTable->getCharClass(fOutChars[i+inv_count]);	
				if ( classTable->isSplitMatra(matraClass)) {
					le_int32 saveIndex = fGlyphStorage.getCharIndex(i+inv_count,success);
					le_uint32 saveAuxData = fGlyphStorage.getAuxData(i+inv_count,success);
                    const SplitMatra *splitMatra = classTable->getSplitMatra(matraClass);
                    int j;
                    for (j = 0 ; *(splitMatra)[j] != 0 ; j++) {
                        LEUnicode piece = (*splitMatra)[j];
						if ( j == 0 ) {
							fOutChars[i+inv_count] = piece;
							matraClass = classTable->getCharClass(piece);
						} else {
							insertCharacter(piece,i+1+inv_count,saveIndex,saveAuxData);
							nextSyllable++;
						}
 				    }
				}
				
				if ((matraClass & CF_POS_MASK) == CF_POS_BEFORE) {
                    moveCharacter(i+inv_count,beginSyllable+inv_count);
				}
			}
		}
	}
コード例 #2
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/**
	 テキスト挿入
	 @param text
	 */
	void TextArea::insertText(const char* text)
	{
		while (*text) {
			insertCharacter(*text++);
		}
		repaint();
	}
コード例 #3
0
ファイル: TextField.cpp プロジェクト: ShotaroTsuji/mona
    void TextField::processKeyEvent(KeyEvent* event)
    {
        int keycode = event->getKeycode();
        int modifiers = event->getModifiers();

        // Toggle IME ON/OFF
        if (keycode == '\\' && modifiers == KeyEvent::VKEY_CTRL) {
            _imeManager->processEvent(event);
            return;
        }

        if (isImeOn()) {
            _imeManager->processEvent(event);
            return;
        }

        switch(keycode) {
        case  KeyEvent::VKEY_BACKSPACE:
            backspace();
            break;
        case KeyEvent::VKEY_LEFT:
            if (cursorLeft()) {
                repaint();
            }
            break;
        case KeyEvent::VKEY_RIGHT:
            if (cursorRight()) {
                repaint();
            }
            break;
            // case KeyEvent::VKEY_ENTER:
            //     if (getParent()) {
            //         getParent()->processEvent(&this->textEvent);
            //     }
            //     break;
        default:
            ASSERT(keycode < 128);
            insertCharacter(keycode);
            repaint();
            break;
        }
    }
コード例 #4
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/** イベント処理 */
	void TextArea::processEvent(Event* event)
	{
		// 非活性の時はイベントを受け付けない
		if (getEnabled() == false) return;

		// キー押下
		if (event->getType() == KeyEvent::KEY_PRESSED) {
			int keycode = ((KeyEvent *)event)->getKeycode();
			if (keycode == KeyEvent::VKEY_BACKSPACE) {
				if (_ptr_x > 0 || _ptr_y > 0) {
					// バックスペース
					SetPos( XY2P(_ptr_x,_ptr_y) - 1 );
					OffsetChange();
					deleteCharacter();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_DELETE) {
				// 一文字削除
				if (text[XY2P(_ptr_x,_ptr_y)] != '\0' ) {
					deleteCharacter();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_INSERT) {
				// 上書き設定変更
				_overwrite = !_overwrite;
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_LEFT) {
				// ←移動
				if( _ptr_x != 0 || _ptr_y != 0 ) {
					SetPos( XY2P(_ptr_x,_ptr_y) - 1 );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_RIGHT) {
				// →移動
				if (text[XY2P(_ptr_x,_ptr_y)] != '\0' ) {
					SetPos( XY2P(_ptr_x,_ptr_y) + 1 );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_UP) {
				// ↑移動
				if (_ptr_y > 0) {
					SetPos( XY2P(_ptr_x,_ptr_y-1) );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_DOWN) {
				// ↓移動
				if (_ptr_y < LineCount()-1) {
					SetPos( XY2P(_ptr_x,_ptr_y+1) );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_PGUP) {
				// 前ページ
				_ptr_y -= _max_line - 1;
				if( _ptr_y < 0 ) _ptr_y = 0;
				_offset_y -= _max_line - 1;
				if( _offset_y < 0 ) _offset_y = 0;
				SetPos( XY2P(_ptr_x,_ptr_y) );
				OffsetChange();
				updateScrollbar();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_PGDOWN) {
				// 次ページ
				_ptr_y += _max_line - 1;
				if( _ptr_y > LineCount() ) _ptr_y = LineCount();
				_offset_y += _max_line - 1;
				if( _offset_y > LineCount() - _max_line / 2 ) _offset_y = LineCount() - _max_line / 2;
				if( _offset_y < 0 ) _offset_y = 0;
				SetPos( XY2P(_ptr_x,_ptr_y) );
				OffsetChange();
				updateScrollbar();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_HOME) {
				// 行の先頭へ移動
				SetPos( Y2P(_ptr_y) );
				OffsetChange();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_END) {
				// 行の末尾へ移動
				SetPos( Y2P(_ptr_y+1) - 1 );
				OffsetChange();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_TAB) {
				// タブの挿入
				insertCharacter( '\t' );
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_ENTER) {
				// 改行
				insertCharacter( '\n' );
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode < 128) {
				// 1文字挿入
				if (_overwrite && text[XY2P(_ptr_x,_ptr_y)] != '\n') deleteCharacter();
				insertCharacter(keycode);
				/*if (firstpaint == true)*/ repaint();
			}
		// マウスで押された
		} else if (event->getType() == MouseEvent::MOUSE_PRESSED) {
			int ry = ((MouseEvent*)event)->getY();
			int rx = ((MouseEvent*)event)->getX();
			int fh = getFontMetrics()->getHeight(WIDTH_BASE);
			int fw = getFontMetrics()->getWidth(WIDTH_BASE);
			
			int draw_left = 4 - (fw >> 1);
			int draw_top = 4;
			if( _draw_line ) {
				draw_left += 2 + _keta * fw;
			}
			draw_left -= _offset_x * fw;
			draw_top -= _offset_y * fh;

			SetPos( XY2P( ( rx - draw_left ) / fw, ( ry - draw_top ) / fh ) );
			OffsetChange();
			/*if (firstpaint == true)*/ repaint();
		// フォーカス状態変更
		} else if (event->getType() == Event::FOCUS_IN || event->getType() == Event::FOCUS_OUT) {
コード例 #5
0
	virtual void preload(std::string const & characters)
	{
		for(size_t i = 0; i < characters.size(); i++) {
			insertCharacter(characters[i]);
		}
	}