0

By trying to use IUP matrix I find it's usage very intuitive and it work surprisingly fast even on weak computer. So I see that I can get from that control most of I need. But, since IUP has very original way of setting properties I can't get that matrix behaves like common multicolumn list or MS listview.

This is how I format it:

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;
}

All properties and events with callbacks work as expected. Since I have a bit specific way of using/managing data it is needed that when click to any cell full row becames selected or when I change position by keyboard also.

I would also like to be able to select full row with code like it selects by clicking to row header.
Besides a click (which I catch as expected), how to check doubleclick on matrix?

And finally, not most important but it will be good to know if here exists a way to get selected line in system color (mostly blue) instead of gray?

How to easiest achieve that functionality?
(Windows7/64)

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

1 Answers1

2

The simplest form to select the row the way you want is to use the ENTERITEM_CB callback:

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;
}

There is currently no way to change the selected line color. Actually because it is not a specific color. The marked cells are drawn with an attenuation at the foreground and background colors.

Antonio Scuri
  • 1,046
  • 6
  • 10
  • 1
    Thanks for advice which helps me a bit. Since I have to "ignore" UP/DOWN key events and take it for my own management (of loading chunks from file) ENTERITEM event don't happen when row is changed by keyboard. But never mind, I solved a problem. "MARKED", NULL was missed to me. Also, It is easy to get selected line in matrix in any color after canceling built in MARKMODE. Did exist any community (like forums) where person can get prompt answers to problems with IUP or contribute to such a nice and unique project? – Wine Too Apr 12 '13 at 19:56
  • Yes, IUP has a mailing list: https://lists.sourceforge.net/lists/listinfo/iup-users – Antonio Scuri Apr 28 '13 at 20:07