亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? swttextview.java

?? Java開發圖文混排的編輯器
?? JAVA
字號:
/*
 * Created on 2004-7-24
 * Author: Xuefeng, Copyright (C) 2004, Xuefeng.
 */
package jexi.ui.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

import jexi.core.Position;
import jexi.core.command.*;
import jexi.ui.Color;

/**
 * The actual view displayed on the screen. 
 * 
 * @author Xuefeng
 */
public final class SWTTextView extends jexi.ui.TextView {

    private static final int KEY_BACK   = 8;
    private static final int KEY_RETURN = 13;
    private static final int KEY_DELETE = 127;

    private static final int KEY_UP    = 16777217;
    private static final int KEY_DOWN  = 16777218;
    private static final int KEY_LEFT  = 16777219;
    private static final int KEY_RIGHT = 16777220;

    private static final int KEY_PGUP = 16777221;
    private static final int KEY_PGDN = 16777222;
    private static final int KEY_HOME = 16777223;
    private static final int KEY_END  = 16777224;

    // view control used to display:
    private Canvas canvas;
    // image buffer:
    private Image backBuffer = null;
    // cursor:
    private Cursor cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_IBEAM);

    // store the size of the view:
    private int width;
    private int height;

    // store the size of the document:
    private int doc_width;
    private int doc_height;

    // IMPORTANT!!!
    // this point (x, y) is the position of the document's relative to view:
    private int offset_x = 0;
    private int offset_y = 0;

    // if the cursor is in the edit region:
    private boolean bEdit = false;
    // and the left button is pressed?
    private boolean bLButtonDown = false;

    // store the start position:
    Position startPosition = null;

    public SWTTextView(Canvas canvas) {
        this.canvas = canvas;
        this.width = canvas.getBounds().width;
        this.height = canvas.getBounds().height;
        this.backBuffer = new Image(Display.getCurrent(),1, 1);
    }

    /**
     * Init the view.
     */
    public void init(jexi.core.Document document) {
        this.document = document;
        onDocumentSizeChanged();
        this.document.updateCaret();
    }

    /**
     * Get the actual height. 
     * 
     * @see jexi.ui.View#getHeight()
     */
    public int getHeight() {
        return this.height;
    }

    /**
     * Get the actual width. 
     * 
     * @see jexi.ui.View#getWidth()
     */
    public int getWidth() {
        return this.width;
    }

    /**
     * dispose view. 
     * 
     * @see jexi.ui.View#dispose()
     */
    public void dispose() {
        if(this.backBuffer!=null)
            this.backBuffer.dispose();
    }

    /**
     * To ensure the caret is visible. 
     * 
     * @see jexi.ui.View#ensureCaretVisible()
     */
    public void ensureCaretVisible() {
        // TODO Auto-generated method stub

    }

    /**
     * Update view. 
     * 
     * @see jexi.ui.View#update()
     */
    public void update() {
        // the drawing start point is (offset_x, offset_y):
        offset_x = getOffsetX();
        offset_y = getOffsetY();

        // ok, now we get (x, y) and know from where to draw the document,
        // create a Graphics:
        SWTGraphics g = new SWTGraphics(new org.eclipse.swt.graphics.GC(this.backBuffer));
        //SWTGraphics g2 = new SWTGraphics(new org.eclipse.swt.graphics.GC(this.canvas));

        // store the orginal color:
        org.eclipse.swt.graphics.Color org_foreColor = g.gc.getForeground();
        org.eclipse.swt.graphics.Color org_backColor = g.gc.getBackground();

        // fill the view's background:
        g.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        g.fillRect(0, 0, this.width, this.height);

        // set the back color to WHITE:
        g.gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

        // locate the start point where to draw:
        g.moveTo(offset_x, offset_y);

        // draw the document: (offset_x, offset_y) is the document point, 
        // and (width, height) is the size of view.
        document.draw(g, offset_x, offset_y, this.width, this.height);

        // copy to canvas:
        GC g2 = new GC(this.canvas);
        g2.drawImage(this.backBuffer, 0, 0);
        g2.dispose();

        // release the Graphics:
        g.gc.setForeground(org_foreColor);
        g.gc.setBackground(org_backColor);
        g.dispose();

    }

    // if x is in the range [min, max], x is returned, 
    // else the closest value (min or max) is returned.
    private int ensureInRange(int min, int max, int v) {
        if(v<min) return min;
        if(v>max) return max;
        return v;
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onSizeChanged(int, int)
     */
    public void onSizeChanged(int width, int height) {
        if(width<=0 || height<=0) return;

        System.out.println("TextView::onSizeChanged() width=" + width + " height=" + height);
        this.width = width;
        this.height = height;

        // reset back buffer:
        this.backBuffer.dispose();
        this.backBuffer = new Image(Display.getCurrent(),width, height);

        setOffsetX(getOffsetX());
        setOffsetY(getOffsetY());
        this.document.updateCaret();
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#getOffsetX()
     */
    public int getOffsetX() {
        return this.offset_x;
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#getOffsetY()
     */
    public int getOffsetY() {
        return this.offset_y;
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onDocumentSizeChanged()
     */
    public void onDocumentSizeChanged() {
        if(this.document!=null) {
            doc_width = this.document.width();
            doc_height = this.document.height();
            setOffsetX(getOffsetX());
            setOffsetY(getOffsetY());
        }
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#setOffsetX(int)
     */
    public void setOffsetX(int x) {
        this.offset_x = x;
        if(doc_width<=this.width)
            offset_x = ( this.width - doc_width ) / 2;
        else
            offset_x = ensureInRange( this.width-doc_width, 0, offset_x);
        }

    /* (non-Javadoc)
     * @see jexi.ui.View#setOffsetY(int)
     */
    public void setOffsetY(int y) {
        this.offset_y = y;
        if(doc_height<=this.height)
            offset_y = ( this.height - doc_height ) / 2;
        else
            offset_y = ensureInRange(this.height-doc_height, 0, offset_y);
    }

    /**
     * Translate the point of view to point of document. 
     * 
     * @param x The point x.
     * @return The point of document.
     */
    public int transX(int x) {
        return x - offset_x;
    }

    /**
     * Translate the point of view to point of document. 
     * 
     * @param y The point y.
     * @return The point of document.
     */
    public int transY(int y) {
        return y - offset_y;
    }

    public void onMouseMove(int x, int y) {
        //System.out.println("[event]MouseMove");
        int dx = transX(x);
        int dy = transY(y);
        if(dx>=0 && dy>=0) {
            bEdit = this.document.isEditRegion(dx, dy);
            if(bEdit) {
                //System.out.println("I");
                this.canvas.setCursor(cursor);
                if(bLButtonDown) {
                    document.getCaret().setLocation(dx, dy);
                    document.getSelection().select(startPosition, document.getCaret().getPosition());
                    document.getSelection().debug();
                    update();
                }
            }
            else
                this.canvas.setCursor(null);
        }
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onLButtonDown(int, int)
     */
    public void onLButtonDown(int x, int y) {
        System.out.println("[event]LButtonDown");
        // TODO Auto-generated method stub
        bLButtonDown = true;
        if(bEdit) {
            int dx = transX(x);
            int dy = transY(y);
            if(dx>=0 && dy>=0) {
                this.document.getSelection().unselect();
                this.document.getCaret().setLocation(dx, dy);
                this.startPosition = this.document.getCaret().getPosition();
            }
        }

    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onLButtonUp(int, int)
     */
    public void onLButtonUp(int x, int y) {
        System.out.println("[event]LButtonUp");
        bLButtonDown = false;
        if(bEdit) {
            int dx = transX(x);
            int dy = transY(y);
            if(dx>=0 && dy>=0) {
                document.getCaret().setLocation(dx, dy);
                document.getSelection().select(startPosition, document.getCaret().getPosition());
                document.getSelection().debug();
                update();
            }
        }
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onRButtonDown(int, int)
     */
    public void onRButtonDown(int x, int y) {
        // TODO Auto-generated method stub
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onRButtonUp(int, int)
     */
    public void onRButtonUp(int x, int y) {
        // TODO Auto-generated method stub
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onLButtonDblClick(int, int)
     */
    public void onLButtonDblClick(int x, int y) {
        // TODO Auto-generated method stub
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onSetCaret(int, int, int)
     */
    public void onSetCaret(int x, int y, int height) {
        System.out.println("set caret at x=" + x + " y=" + y + " height=" + height);
        Caret c = this.canvas.getCaret();
        c.setBounds(x+offset_x, y+offset_y, 2, height);
        this.canvas.setCaret(c);
        update();
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onKeyPressed(char)
     */
    public void onKeyPressed(char c) {
        CommandManager.instance().newInsertCommand(this.document, c);
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onFunctionKeyPressed(int, boolean, boolean, boolean)
     */
    public void onFunctionKeyPressed(int keycode, boolean shift, boolean ctrl, boolean alt) {
        // TODO Auto-generated method stub
        System.out.println("keycode=" + keycode + " shift=" + shift + " ctrl=" + ctrl + " alt=" + alt);
        switch(keycode) {
        case KEY_RETURN:
            CommandManager.instance().newSplitCommand(document);
            break;

        case KEY_DELETE:
            CommandManager.instance().newDeleteCommand(document);
            break;

        case KEY_BACK:
            // in fact the back command is just like the delete:
            if(document.getCaret().moveLeft()) {
                CommandManager.instance().newDeleteCommand(document);
                document.updateCaret();
            }
            break;

        case KEY_LEFT:
            this.document.getSelection().unselect();
            this.document.getCaret().moveLeft();
            this.document.updateCaret();
            break;

        case KEY_RIGHT:
            this.document.getSelection().unselect();
            this.document.getCaret().moveRight();
            this.document.updateCaret();
            break;

        case KEY_UP:
            // TODO: this.document.getCaret().moveUp();
            break;

        case KEY_DOWN:
            // TODO: this.document.getCaret().moveDown();
            break;
        }
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onFormatChanged(java.lang.String, java.lang.Integer, java.lang.Boolean, java.lang.Boolean, java.lang.Boolean, jexi.ui.Color)
     */
    public void onFormatChanged(String fontName, Integer fontSize,
        Boolean bold, Boolean italic, Boolean underlined, Color color)
    {
        CommandManager.instance().newFormatCommand(document, fontName, fontSize, bold, italic, underlined, color);
    }

    /* (non-Javadoc)
     * @see jexi.ui.View#onInsertPictureFromFile(java.lang.String)
     */
    public void onInsertPictureFromFile(String filename) {
        CommandManager.instance().newInsertPictureCommand(document, filename);
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影免费观看高清完整版在线观看 | av在线不卡电影| 欧美视频一区二区在线观看| 精品三级av在线| 亚洲亚洲精品在线观看| 男人的j进女人的j一区| 91麻豆国产福利精品| 久久女同性恋中文字幕| 日韩成人午夜电影| 在线视频欧美区| 国产精品国产三级国产专播品爱网 | 秋霞电影网一区二区| www.亚洲色图| 国产欧美日本一区视频| 久久国产成人午夜av影院| 在线精品视频一区二区三四| 国产精品久久久久久久久免费桃花| 午夜精品福利一区二区蜜股av| 波多野结衣中文字幕一区| 久久久精品人体av艺术| 全国精品久久少妇| 欧美一区二区在线免费播放| 一区二区成人在线视频| 色综合久久中文综合久久97| 国产欧美一区二区精品秋霞影院| 奇米影视一区二区三区小说| 777午夜精品视频在线播放| 亚洲综合成人在线| 91同城在线观看| 中文字幕五月欧美| 99久久婷婷国产| 国产精品成人网| 成人av在线网| 亚洲人快播电影网| 99精品视频在线播放观看| 国产精品欧美久久久久无广告| 韩国一区二区三区| 久久久久九九视频| av电影天堂一区二区在线观看| 国产欧美日韩一区二区三区在线观看| 国产一区免费电影| 欧美国产精品一区二区| 夫妻av一区二区| 国产精品麻豆欧美日韩ww| 成人av电影在线观看| **性色生活片久久毛片| 色综合天天综合网天天看片| 亚洲国产精品一区二区久久| 欧美美女bb生活片| 精品在线观看免费| 国产视频911| 91麻豆免费看| 日本美女一区二区三区| 久久久久久毛片| 成人app网站| 伊人一区二区三区| 91精品福利在线一区二区三区 | 欧美一级日韩一级| 国产精品一区二区免费不卡| 久久久精品天堂| 一本高清dvd不卡在线观看| 亚洲国产精品天堂| 久久久国产一区二区三区四区小说 | 国产精品18久久久久久久久| 国产精品萝li| 欧美日韩国产bt| 久久超碰97中文字幕| 亚洲国产电影在线观看| 欧美性猛片xxxx免费看久爱| 奇米精品一区二区三区四区| 精品国产免费一区二区三区四区 | 亚洲视频一二区| 欧美丰满美乳xxx高潮www| 狂野欧美性猛交blacked| 国产免费观看久久| 欧美麻豆精品久久久久久| 国产一本一道久久香蕉| 亚洲综合在线免费观看| 欧美成人video| 色偷偷久久人人79超碰人人澡| 麻豆精品一二三| 亚洲精品视频在线| 久久―日本道色综合久久| 91精品福利视频| 国产一区不卡视频| 日韩不卡一二三区| 亚洲欧美韩国综合色| 久久久久国产精品麻豆| 欧美美女一区二区三区| 91一区二区在线| 久久激情综合网| 亚洲一二三区在线观看| 国产精品第一页第二页第三页 | 日本精品视频一区二区三区| 国产乱码精品一品二品| 日韩成人一级片| 亚洲成人先锋电影| 一区二区三区国产| 中文字幕中文乱码欧美一区二区| 日韩欧美在线观看一区二区三区| 色综合欧美在线视频区| 高清国产一区二区三区| 国产在线一区观看| 奇米在线7777在线精品| 日韩成人免费看| 亚洲成人资源在线| 天堂成人国产精品一区| 亚洲一区日韩精品中文字幕| 亚洲人快播电影网| √…a在线天堂一区| 亚洲天堂av一区| 中文字幕制服丝袜一区二区三区| 欧美大片一区二区三区| 日韩午夜在线影院| 这里只有精品电影| 欧美一区二区女人| 欧美一区二区三区成人| 欧美一区二区啪啪| 日韩你懂的电影在线观看| 日韩一区二区三区电影在线观看| 欧美日韩国产精品成人| 777欧美精品| 日韩欧美中文字幕一区| 26uuu成人网一区二区三区| 久久影院电视剧免费观看| 26uuu亚洲| 国产亚洲制服色| 国产精品久久久久久妇女6080| 国产日韩精品一区二区浪潮av| 国产视频亚洲色图| 亚洲欧美国产77777| 曰韩精品一区二区| 视频一区在线播放| 久久99国产精品免费| 成人小视频在线| 91免费视频大全| 欧美日韩久久不卡| 欧美tickling挠脚心丨vk| 久久久精品国产99久久精品芒果 | 26uuu亚洲| 自拍偷自拍亚洲精品播放| 亚洲最新在线观看| 久久aⅴ国产欧美74aaa| 成人综合激情网| 欧美羞羞免费网站| 精品国产乱码久久久久久免费| 久久只精品国产| 亚洲资源在线观看| 美国十次综合导航| 成人午夜电影网站| 精品视频123区在线观看| 精品国产乱码久久久久久老虎| 中文字幕乱码久久午夜不卡 | 国产一区二区三区黄视频| 99这里都是精品| 欧美一区二区三区啪啪| 中文字幕亚洲精品在线观看| 奇米777欧美一区二区| 99久免费精品视频在线观看| 在线播放欧美女士性生活| 国产日韩欧美不卡在线| 午夜精品免费在线| 成人性色生活片免费看爆迷你毛片| 欧美日韩亚洲另类| 国产精品每日更新在线播放网址| 亚洲不卡在线观看| 不卡视频在线观看| 日韩一区二区免费视频| 自拍偷拍国产精品| 国产酒店精品激情| 666欧美在线视频| 亚洲精品日日夜夜| 国产不卡一区视频| 日韩欧美综合一区| 五月天中文字幕一区二区| 成人国产亚洲欧美成人综合网| 91精品国产91久久久久久一区二区 | 亚洲三级免费观看| 国产一区二三区| 91 com成人网| 亚洲一线二线三线久久久| 成人做爰69片免费看网站| 精品国产区一区| 免播放器亚洲一区| 欧美日韩免费在线视频| 亚洲人成伊人成综合网小说| 国产成人日日夜夜| 日韩免费视频一区二区| 亚洲成人自拍网| 欧美色偷偷大香| 一区二区三区资源| 一本一道久久a久久精品| 国产精品三级av在线播放| 国产精品一区二区在线看| 欧美精品一区男女天堂| 美女被吸乳得到大胸91| 日韩欧美高清一区| 久久99国产精品麻豆| 日韩欧美一区二区免费| 日韩av一区二|