1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iup.h"
#include "iupcontrols.h"
//static char data[3][3][50] =
//{
// {"1:1", "1:2", "1:3"},
// {"2:1", "2:2", "2:3"},
// {"3:1", "3:2", "3:3"},
//};
static int dropcheck_cb(Ihandle *self, int lin, int col)
{
if (lin == 3 && col == 1)
return IUP_DEFAULT;
return IUP_IGNORE;
}
static int drop(Ihandle *self, Ihandle *drop, int lin, int col)
{
printf("drop_cb(%d, %d)\n", lin, col);
if(lin == 3 && col == 1)
{
IupSetAttribute(drop, "1", "A - Test of Very Big String for Dropdown!");
IupSetAttribute(drop, "2", "B");
IupSetAttribute(drop, "3", "C");
IupSetAttribute(drop, "4", "XXX");
IupSetAttribute(drop, "5", "5");
IupSetAttribute(drop, "6", "6");
IupSetAttribute(drop, "7", "7");
IupSetAttribute(drop, "8", NULL);
return IUP_DEFAULT;
}
return IUP_IGNORE;
}
static char* value_cb(Ihandle *self, int lin, int col)
{
if (lin == 0 || col == 0)
return "Title";
return "cell";
// return data[lin-1][col-1];
}
static int value_edit_cb(Ihandle *self, int lin, int col, char* newvalue)
{
// strcpy(data[lin-1][col-1], newvalue);
return IUP_DEFAULT;
}
static Ihandle* create_matrix(void)
{
Ihandle* mat = IupMatrix(NULL);
int lin, col;
IupSetAttribute(mat, "NUMCOL", "20");
IupSetAttribute(mat, "NUMLIN", "5000");
IupSetAttribute(mat, "NUMCOL_VISIBLE", "3");
IupSetAttribute(mat, "NUMLIN_VISIBLE", "3");
// IupSetAttribute(mat, "WIDTH2", "90");
// IupSetAttribute(mat, "HEIGHT2", "30");
// IupSetAttribute(mat, "WIDTHDEF", "34");
// IupSetAttribute(mat,"RESIZEMATRIX", "YES");
IupSetAttribute(mat,"SCROLLBAR", "YES");
IupSetCallback(mat,"VALUE_CB",(Icallback)value_cb);
// IupSetCallback(mat,"VALUE_EDIT_CB",(Icallback)value_edit_cb);
// IupSetCallback(mat, "DROPCHECK_CB", (Icallback)dropcheck_cb);
// IupSetCallback(mat,"DROP_CB",(Icallback)drop);
// IupSetAttribute(mat, "HEIGHT0", "10");
// IupSetAttribute(mat, "WIDTH0", "90");
// IupSetAttribute(mat,"MARKMODE","LIN");
// IupSetAttribute(mat,"MARKMULTIPLE","NO");
IupSetAttribute(mat,"MARKMODE","CELL");
IupSetAttribute(mat,"MARKMULTIPLE","YES");
IupSetAttribute(mat,"USETITLESIZE","YES");
//IupSetAttribute(mat, "NUMCOL_VISIBLE_LAST", "YES");
//IupSetAttribute(mat, "NUMLIN_VISIBLE_LAST", "YES");
// IupSetAttribute(mat, "WIDTHDEF", "15");
// IupSetAttribute(mat,"FRAMEVERTCOLOR1:2","BGCOLOR");
// IupSetAttribute(mat,"FRAMEHORIZCOLOR2:1","BGCOLOR");
for (lin = 0; lin < 3000; lin++)
{
for (col = 0; col < 20; col++)
{
IupMatSetAttribute(mat,"BGCOLOR", lin, col, "192 192 192");
IupMatSetAttribute(mat,"FGCOLOR", lin, col, "1 1 1");
}
}
return mat;
}
void MatrixCbModeTest(void)
{
Ihandle* dlg, *box;
box = IupVbox(create_matrix(), NULL);
IupSetAttribute(box, "MARGIN", "10x10");
dlg = IupDialog(box);
IupSetAttribute(dlg, "TITLE", "IupMatrix Simple Test");
IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
}
#ifndef BIG_TEST
int main(int argc, char* argv[])
{
IupOpen(&argc, &argv);
IupControlsOpen();
MatrixCbModeTest();
IupMainLoop();
IupClose();
return EXIT_SUCCESS;
}
#endif
|