📄 gridcelltext.java
字号:
/*
* WExtLib - A class library for the Superwaba Virtual Machine
* Copyright (C) 2005, Virgilio Alexandre Fornazin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package wextlib.ui.grid;
import waba.fx.*;
import waba.ui.*;
/**
* This class implements a default Grid Cell with editing support (text)
*
* @author Virgilio Alexandre Fornazin (mailto:virgiliofornazin@gmail.com)
*/
public final class GridCellText extends GridCell
{
/** Valid chars */
private String m_strValidChars;
/** In-place editor */
private Edit m_Editor;
/**
* Default constructor
*/
public GridCellText()
{
m_strValidChars = null;
m_Editor = null;
}
/**
* Get valid chars
*/
public String getValidChars()
{
return m_strValidChars;
}
/**
* Set valid chars
*/
public void setValidChars(String strValidChars)
{
m_strValidChars = strValidChars;
}
public boolean supportEditing()
{
return true;
}
public boolean onStartEdit(Grid grid, GridCellID cellID, Rect cellRect, Color clrForeColor, Color clrBackColor, Font cellFont, int chrCode)
{
super.onStartEdit(grid, cellID, cellRect, clrForeColor, clrBackColor, cellFont, chrCode);
m_Editor = new GridCellTextEditor();
m_EditGrid.add(m_Editor);
m_EditControl = m_Editor;
m_Editor.setVisible(false);
m_Editor.setRect(m_EditRect);
if (m_strValidChars != null)
{
m_Editor.setValidChars(m_strValidChars);
}
if (m_EditBackColor != null)
{
m_Editor.setBackColor(m_EditBackColor);
}
if (m_EditForeColor != null)
{
m_Editor.setForeColor(m_EditForeColor);
}
if (m_EditFont != null)
{
m_Editor.setFont(m_EditFont);
}
m_Editor.setText(getCellText());
m_Editor.setVisible(true);
m_Editor.setCursorPos(0, m_Editor.getText().length());
m_Editor.requestFocus();
return true;
}
public boolean onEndEdit()
{
if (m_Editor == null)
{
return false;
}
setCellText(m_Editor.getText());
m_Editor = null;
m_EditGrid.remove(m_EditControl);
m_EditControl = null;
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -