0

I am trying to use IUP matrix from C like I uses DataGrid from VB.
Till now I come to this:

int refreshl(Ihandle *mat, int from)  
{  
struct lotstruct lot;   

FILE *fol;
fol = fopen("C:/myfolder/myfile", "rb+");

int b;
int temp = 1;
for (b=from; b<(from+31); b++)
{
    int rec = sizeof(lot) * (b - 1);
    fseek(fol, rec, SEEK_SET);

    int fr;
    fr = fread(&lot, sizeof(lot), 1, fol);
    //------------------------------------
    char k1[36] = {0};
    strncpy(k1, lot.str1, 35);
    char* tp = ibm852_to_cp1250(k1);

    char row[6] = {0};
    sprintf(row, "%d", temp);
    char* ro = ibm852_to_cp1250(row);

    char cel1[10] = {0};
    sprintf(cel1, "%d%s", temp, ":0");
    IupSetAttribute(mat, cel1, ro);

    char cel2[10] = {0};
    sprintf(cel2, "%d%s", temp, ":1");
    IupSetAttribute(mat, cel2, tp);
    temp += 1;
}
fclose(fol);
IupSetAttribute(mat, "REDRAW", "ALL");

return 0;
}

With this I read data from binary file and I can see data on console. But mytrix don't refreshes by changing data. Data is changet by k_any + case K_DOWN function by increasing "from" integer.
So I call "REDRAW" "ALL" but also without result, starting data stays in matrix.

Since I am total beginner please answer to few questions.

1) Is this good idea to use IUP matrix like common windows Grid?
2) How to invoke refresh matrix to change data in it without loosing speed?
3) Can IUP work with UTF-8 strings on windows like gtk can? (I try but without results).

Wine Too
  • 4,515
  • 22
  • 83
  • 137

1 Answers1

1

1) Is this good idea to use IUP matrix like common windows Grid?

Yes. IupMatrix is exactly for that.

2) How to invoke refresh matrix to change data in it without loosing speed?

Your code is correct. Maybe you are updating the wrong cell in the IupMatrix. L=0 or C=0 are title cells, and exist if certain conditions are true. Maybe what you want is to set L=1 or C=1.

A suggestion, instead of this:

char row[6] = {0};
sprintf(row, "%d", temp);
char* ro = ibm852_to_cp1250(row);
char cel1[10] = {0};
sprintf(cel1, "%d%s", temp, ":0");
IupSetAttribute(mat, cel1, ro);

Try this:

IupMatSetfAttribute(mat, "", temp, 0, "%d", temp);

and IupMatStoreAttribute(mat, "", temp, 1, tp);

You only need the string conversion for the second part.

Also, have you checked the temp variable if it has a valid index?

3) Can IUP work with UTF-8 strings on windows like gtk can? (I try but without results).

Not yet. It will be in a (near) future version.

Antonio Scuri
  • 1,046
  • 6
  • 10
  • Hello Antonio. Thank you for informations and suggestions. It is much easier for me to manipulate with cells by integers. However, I didn't get wanted result like I was before on different OS-es, with different toolkits and different languages with same data. Complete Code::Blocks project with data and all relevant files is here: http://www.kalko.com.hr/antonio/ (about 550kb) and will be here few days. If you want to look I would be glad and curious why this don't go since I would like to start with IUP. – Wine Too Apr 10 '13 at 20:02
  • I find an error finally! I double reference matrix which handle was already declared as public, so now my program work as expected. Thank's again for help and now I will remove posted example since biggest problem is solved. – Wine Too Apr 11 '13 at 07:00