通过尝试使用IUP矩阵,我发现它的用法非常直观,即使在较弱的计算机上也能以惊人的速度工作。所以我看到我可以从那个控件中得到我需要的大部分东西。但是,由于IUP有非常新颖的设置属性的方法,所以我无法获得像常见的多列列表或MS listview那样的矩阵行为。
我是这样格式化它的:
Ihandle *create_mat(void)
{
mat = IupMatrix(NULL);
IupSetAttribute(mat, "READONLY", "YES");
IupSetAttribute(mat, "HIDEFOCUS", "YES");
IupSetAttribute(mat, "FRAMECOLOR", "220 220 220");
IupSetAttribute(mat, "NUMCOL", "5");
IupSetAttribute(mat, "NUMCOL_VISIBLE", "5");
IupSetAttribute(mat, "NUMLIN", "30");
IupSetAttribute(mat, "NUMLIN_VISIBLE", "30");
IupSetAttribute(mat, "RESIZEMATRIX", "YES");
IupSetAttribute(mat, "MARKMODE", "LIN");
IupSetAttribute(mat, "MARKAREA", "CONTINUOUS");
IupSetAttribute(mat, "MULTIPLE", "NO");
IupSetAttribute(mat, "BORDER", "NO");
IupSetAttribute(mat, "CURSOR", "ARROW");
IupSetAttribute(mat, "ALIGNMENT", "ARIGHT");
IupSetAttribute(mat, "ALIGNMENT1", "ALEFT");
IupSetAttribute(mat, "ALIGNMENT5", "ACENTER");
//
IupSetAttribute(mat, "WIDTH0", "30");
IupSetAttribute(mat, "WIDTH1", "150");
IupSetAttribute(mat, "WIDTH2", "50");
IupSetAttribute(mat, "WIDTH3", "50");
IupSetAttribute(mat, "WIDTH4", "50");
//
IupSetAttribute(mat, "0:0", "Row H");
IupSetAttribute(mat, "0:1", "Col1");
IupSetAttribute(mat, "0:2", "Col2");
IupSetAttribute(mat, "0:3", "Col3");
IupSetAttribute(mat, "0:4", "Col4");
IupSetAttribute(mat, "0:5", "Col5");
//
IupSetCallback(mat, "CLICK_CB", (Icallback)click);
IupSetCallback(mat, "LEAVEITEM_CB", (Icallback)leave);
IupSetCallback(mat, "ENTERITEM_CB", (Icallback)enter);
IupSetCallback(mat, "WHEEL_CB", (Icallback)wheel);
return mat;
}所有带有回调的属性和事件都按预期工作。因为我有一些特定的方式来使用/管理数据,所以当单击到任何单元格时,整行变为选中,或者当我通过键盘改变位置时,也需要这样做。
我也希望能够选择像它通过点击行头选择代码整行。
除了点击(不出所料地捕捉到),如何检查在矩阵上双击?
最后,不是最重要的,但最好知道这里是否有一种方法可以用系统颜色(主要是蓝色)而不是灰色来选择线条?
如何以最简单的方式实现该功能?
(Windows7 7/64)
发布于 2013-04-13 02:38:58
选择所需行的最简单形式是使用ENTERITEM_CB回调:
static int enteritem_cb(Ihandle *ih, int lin, int col)
{
IupSetAttribute(ih,"MARKED", NULL); /* clear all marks */
IupMatSetAttribute(ih,"MARK", lin, 0, "Yes");
IupSetfAttribute(ih,"REDRAW", "L%d", lin);
return IUP_DEFAULT;
}当前无法更改选定的线条颜色。实际上是因为它不是特定的颜色。所标记的单元格以前景和背景颜色的衰减绘制。
https://stackoverflow.com/questions/15959555
复制相似问题