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

📄 sdagrid.java

📁 很好的UI界面源码..还有自己的输入法,可以更换风格.可以学习和使用
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                }                if (Cursor > EndRow) {                    Cursor = EndRow;                    DataSet.doDataChangeScroll(Cursor);                }                //指针,画三角                int Curpos = Cursor - StartRow;                SetClip(g, 0, rowHeight * (Curpos + 1), FixedWidth, rowHeight * (Curpos + 2));                g.setColor(foreColor);                fillTriangle(g, FixedWidth / 2 - 2, rowHeight * (Curpos + 1) + rowHeight / 2 - 4,                        FixedWidth / 2 - 2, rowHeight * (Curpos + 1) + rowHeight / 2 + 4,                        FixedWidth / 2 + 2, rowHeight * (Curpos + 1) + rowHeight / 2);            }            //滚动条            if (borderStyle == SDAConsts.bsFixed3D) {                SetClip(g, 2, 2, thisWidth - 2, thisHeight - 2);            } else {                SetClip(g, 1, 1, thisWidth - 1, thisHeight - 1);            }            if ((scrollBars == SDAConsts.srHorizontal) || (scrollBars == SDAConsts.srBoth)) {                g.setColor(backColor);                fillRect(g, 0, thisHeight - barwidth, thisWidth, barwidth);                //水平                g.setColor(FixedColor);                fillRect(g, 0, thisHeight - barwidth, barwidth, barwidth);                fillRect(g, HBarWidth - barwidth, thisHeight - barwidth, barwidth, barwidth);                g.setColor(getBorderColor());                drawRect(g, 0, thisHeight - barwidth, barwidth, barwidth);                drawRect(g, HBarWidth - barwidth, thisHeight - barwidth, barwidth, barwidth);                //滚动块                g.setColor(backColor);                fillRect(g, barwidth, thisHeight - barwidth, HBarWidth - 2 * barwidth, barwidth);                g.setColor(this.getBorderColor());                drawRect(g, barwidth, thisHeight - barwidth, HBarWidth - 2 * barwidth, barwidth);                //块大小                int pwidth = HBarWidth - 2 * barwidth;                if (maxLineLenght > HBarWidth - 4) {                    pwidth = ((HBarWidth - 4) * (HBarWidth - 2 * barwidth)) / maxLineLenght;                }                startLeft = getForeWidth();                //计算块位置                int ppos = 0;                if (maxLineLenght > 0) {                    ppos = (startLeft * (HBarWidth - 2 * barwidth)) / maxLineLenght;                }                //修正位置                if (ppos + pwidth > HBarWidth - 2 * barwidth) {                    ppos = HBarWidth - 2 * barwidth - pwidth;                }                if (maxLineLenght - startLeft - (HBarWidth - 4) < getFont().charWidth('x')) {                    ppos = HBarWidth - 2 * barwidth - pwidth;                }                //画块                g.setColor(FixedColor);                fillRect(g, barwidth + ppos, thisHeight - barwidth, pwidth, barwidth);                g.setColor(getBorderColor());                drawRect(g, barwidth + ppos, thisHeight - barwidth, pwidth, barwidth);                //记录大小                HSLeft = barwidth + ppos;                HSTop = thisHeight - barwidth;                HSWidth = pwidth;                HSHeight = barwidth;                //画块上的线                int tpos = HSWidth / 2 + HSLeft;                drawRect(g, tpos, HSTop + 2, 0, HSHeight - 4);                if (tpos - 2 > HSLeft) {                    drawRect(g, tpos - 2, HSTop + 2, 0, HSHeight - 4);                }                if (tpos + 2 < HSLeft + HSWidth) {                    drawRect(g, tpos + 2, HSTop + 2, 0, HSHeight - 4);                }                //三角                g.setColor(getBorderColor());                fillTriangle(g, barwidth / 2 - 2, thisHeight - barwidth / 2,                        barwidth / 2 + 2, thisHeight - barwidth / 2 - 4,                        barwidth / 2 + 2, thisHeight - barwidth / 2 + 4);                fillTriangle(g, HBarWidth - barwidth + barwidth / 2 + 2, thisHeight - barwidth / 2,                        HBarWidth - barwidth + barwidth / 2 - 2, thisHeight - barwidth / 2 - 4,                        HBarWidth - barwidth + barwidth / 2 - 2, thisHeight - barwidth / 2 + 4);            }            if ((scrollBars == SDAConsts.srVertical) || (scrollBars == SDAConsts.srBoth)) {                //垂直                g.setColor(FixedColor);                fillRect(g, thisWidth - barwidth, 0, barwidth, barwidth);                fillRect(g, thisWidth - barwidth, VBarHeight - barwidth, barwidth, barwidth);                g.setColor(getBorderColor());                drawRect(g, thisWidth - barwidth, 0, barwidth, barwidth);                drawRect(g, thisWidth - barwidth, VBarHeight - barwidth, barwidth, barwidth);                //滚动块                g.setColor(backColor);                fillRect(g, thisWidth - barwidth, barwidth, barwidth, VBarHeight - 2 * barwidth);                g.setColor(getBorderColor());                drawRect(g, thisWidth - barwidth, barwidth, barwidth, VBarHeight - 2 * barwidth);                //块大小                int pheight = VBarHeight - 2 * barwidth;                int allHeight = getAllHeight();                int valwidth = (VBarHeight - footheight - rowHeight) / rowHeight * rowHeight;                if (allHeight > valwidth) {                    pheight = (valwidth * (VBarHeight - 2 * barwidth) / allHeight);                }                //计算块位置                int ppos = 0;                if (allHeight > 0) {                    ppos = (StartRow * getRowHeight() * (VBarHeight - 2 * barwidth)) / allHeight;                }                //修正位置                if (ppos + pheight > VBarHeight - 2 * barwidth) {                    ppos = VBarHeight - 2 * barwidth - pheight;                }                //画块                g.setColor(FixedColor);                fillRect(g, thisWidth - barwidth, barwidth + ppos, barwidth, pheight);                g.setColor(getBorderColor());                drawRect(g, thisWidth - barwidth, barwidth + ppos, barwidth, pheight);                //记录大小                VSLeft = thisWidth - barwidth;                VSTop = barwidth + ppos;                VSWidth = barwidth;                VSHeight = pheight;                //画块上的线                int tpos = VSHeight / 2 + VSTop;                drawRect(g, VSLeft + 2, tpos, barwidth - 4, 0);                if (tpos - 2 > VSTop) {                    drawRect(g, VSLeft + 2, tpos - 2, VSWidth - 4, 0);                }                if (tpos + 2 < VSTop + VSHeight) {                    drawRect(g, VSLeft + 2, tpos + 2, VSWidth - 4, 0);                }                //三角                g.setColor(getBorderColor());                fillTriangle(g, thisWidth - barwidth + barwidth / 2, barwidth / 2 - 2,                        thisWidth - barwidth + barwidth / 2 - 4, barwidth / 2 + 2,                        thisWidth - barwidth + barwidth / 2 + 4, barwidth / 2 + 2);                fillTriangle(g, thisWidth - barwidth + barwidth / 2 - 4, VBarHeight - barwidth + barwidth / 2 - 2,                        thisWidth - barwidth + barwidth / 2 + 4, VBarHeight - barwidth + barwidth / 2 - 2,                        thisWidth - barwidth + barwidth / 2, VBarHeight - barwidth / 2 + 2);            }            /*            //焦点                        SetClip(g);            if (isFoucsed()) {                g.setColor(SDAConsts.clFocusShadow);                drawRect(g, 1, 1, thisWidth - 2, thisHeight - 2);            }             */         }    }    public int getSelectedFontColor() {        return selectedFontColor;    }    public void setSelectedFontColor(int selectedFontColor) {        this.selectedFontColor = selectedFontColor;        paint();    }    public int getBorderStyle() {        return borderStyle;    }    public void setBorderStyle(int borderStyle) {        this.borderStyle = borderStyle;        paint();    }    public boolean isHideSelection() {        return hideSelection;    }    public void setHideSelection(boolean hideSelection) {        this.hideSelection = hideSelection;    }    public int getScrollBars() {        return scrollBars;    }    public void setScrollBars(int scrollBars) {        this.scrollBars = scrollBars;        paint();    }    public int getScrollBarWidth() {        return barwidth;    }    public void setScrollBarWidth(int barwidth) {        this.barwidth = barwidth;        paint();    }    private int getCursor() {        return Cursor;    }    private void setCursor(int Cursor) {        this.Cursor = Cursor;    }    public int getDefaultColWidth() {        return DefaultColWidth;    }    public void setDefaultColWidth(int DefaultColWidth) {        this.DefaultColWidth = DefaultColWidth;        paint();    }    public int getFixedWidth() {        return FixedWidth;    }    public void setFixedWidth(int FixedWidth) {        this.FixedWidth = FixedWidth;        paint();    }    public int getFootRowColor() {        return footRowColor;    }    public void setFootRowColor(int footRowColor) {        this.footRowColor = footRowColor;        paint();    }    public int getRowHeight() {        int fontheight = getFont().getHeight() + 2;        if (RowHeight < fontheight) {            RowHeight = fontheight;        }        return RowHeight;    }    public void setRowHeight(int RowHeight) {        //根据字体大小判断        int fontheight = getFont().getHeight() + 2;        if (fontheight > RowHeight) {            this.RowHeight = fontheight;        } else {            this.RowHeight = RowHeight;        }        paint();    }    public int getBorderColor() {        return borderColor;    }    public void setBorderColor(int borderColor) {        this.borderColor = borderColor;        paint();    }    public int getFixedColor() {        return FixedColor;    }    public void setFixedColor(int FixedColor) {        this.FixedColor = FixedColor;        paint();    }    private int getForeWidth() {        int foreWidth = 0;        for (int i = 0; i < StartCol; i++) {            foreWidth += ((Column) ColumnsList.elementAt(i)).ColWidth;        }        return foreWidth;    }    public boolean isShowFootRow() {        return showFootRow;    }    public void setShowFootRow(boolean showFootRow) {        this.showFootRow = showFootRow;        paint();    }    public int getSelectedBackColor() {        return selectedBackColor;    }    public void setSelectedBackColor(int selectedBackColor) {        this.selectedBackColor = selectedBackColor;        paint();    }    public int getLostFocusSelectedBackColor() {        return lostFocusSelectedBackColor;    }    public void setLostFocusSelectedBackColor(int lostFocusSelectedBackColor) {        this.lostFocusSelectedBackColor = lostFocusSelectedBackColor;    }    private int getAllWidth() {        int allWidth = 0;        for (int i = 0; i < ColumnsList.size(); i++) {            allWidth += ((Column) ColumnsList.elementAt(i)).ColWidth;        }        return allWidth;    }    private int getForeHeight() {        int foreHeight = getRowHeight() * StartRow;        return foreHeight;    }    private int getAllHeight() {        int allHeight = 0;        if (DataSet != null) {            allHeight = getRowHeight() * DataSet.getRecordCount();        }        return allHeight;    }    private int getMaxRowsNum() {        int rowHeight = getRowHeight();        return (getVBarHeight() - rowHeight - (showFootRow ? rowHeight : 0)) / rowHeight;    }    //读取数据填充各列表    public void setDataSet(SDADataSet DataSet) {        interalSetDataSet(DataSet);    }    private void interalSetDataSet(SDADataSet DataSet) {        //设置观察        if (DataSet == null) {            if (oldDataSet != null) {                oldDataSet.setWatchControl(this, false);            }            this.DataSet = null;            oldDataSet = null;            return;        } else {            oldDataSet = DataSet;            this.DataSet = DataSet;            oldDataSet.setWatchControl(this, true);        }        //数据        SDADataSet.Field fd = null;        if ((DataSet != null) && (ColumnsList.size() == 0)) {            for (int i = 0; i < DataSet.getFieldsCount(); i++) {                fd = DataSet.getField(i);                Column ct = new Column();                ct.ColWidth = DefaultColWidth;                ct.FieldName = fd.getFiledName();                ct.Title = ct.FieldName;                ct.DisplayFormat = "";                ColumnsList.addElement(ct);            }        }        Cursor = 0;        StartCol = 0;        StartRow = 0;        EndRow = 0;        //是否为最后一行        IsEndRow = false;        //是否为最后一列        IsEndCol = false;        //数据集合

⌨️ 快捷键说明

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