Exemple #1
0
static void iMatrixDrawFocus(Ihandle* ih)
{
  int x1, y1, x2, y2, dx, dy;

  if (iupAttribGetBoolean(ih, "HIDEFOCUS"))
    return;

  /* there are no cells that can get the focus */
  if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1)
    return;

  if (!iupMatrixAuxIsCellVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
    return;

  iupMatrixGetVisibleCellDim(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, &x1, &y1, &dx, &dy);

  x2 = x1 + dx - 1;
  y2 = y1 + dy - 1;

  if (ih->data->columns.focus_cell == 1 && ih->data->columns.dt[0].size == 0)
    x1++;
  if (ih->data->lines.focus_cell == 1 && ih->data->lines.dt[0].size == 0)
    y1++;

  {
    cdCanvas* cd_canvas_front = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");  /* front buffer canvas */
    IupCdDrawFocusRect(ih, cd_canvas_front, x1, iupMATRIX_INVERTYAXIS(ih, y1), x2, iupMATRIX_INVERTYAXIS(ih, y2));
  }
}
Exemple #2
0
static void iMatrixDrawFocus(Ihandle* ih)
{
    int x1, y1, x2, y2, dx, dy;

    if (iupAttribGetBoolean(ih, "HIDEFOCUS"))
        return;

    /* there are no cells that can get the focus */
    if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1)
        return;

    if (!iupMatrixAuxIsCellVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
        return;

    iupMatrixGetVisibleCellDim(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, &x1, &y1, &dx, &dy);

    x2 = x1 + dx - 1;
    y2 = y1 + dy - 1;

    if (ih->data->columns.focus_cell == 1 && ih->data->columns.sizes[0] == 0)
        x1++;
    if (ih->data->lines.focus_cell == 1 && ih->data->lines.sizes[0] == 0)
        y1++;

    cdIupDrawFocusRect(ih, ih->data->cdcanvas, x1, iupMATRIX_INVERTYAXIS(ih, y1), x2, iupMATRIX_INVERTYAXIS(ih, y2));
}
Exemple #3
0
static int iMatrixEditCallMenuDropCb(Ihandle* ih, int lin, int col)
{
    IFnnii cb = (IFnnii)IupGetCallback(ih, "MENUDROP_CB");
    if(cb)
    {
        Ihandle* ih_menu = IupMenu(NULL);
        int ret;
        char* value = iupMatrixGetValueDisplay(ih, lin, col);
        if (!value) value = "";

        iupAttribSet(ih_menu, "PREVIOUSVALUE", value);
        iupAttribSet(ih_menu, "_IUP_MATRIX", (char*)ih);

        ret = cb(ih, ih_menu, lin, col);
        if (ret == IUP_DEFAULT)
        {
            int x, y, w, h;

            ih->data->datah = ih_menu;

            /* create items and set common callback */
            iMatrixEditInitMenu(ih_menu);

            /* calc position */
            iupMatrixGetVisibleCellDim(ih, lin, col, &x, &y, &w, &h);

            x += IupGetInt(ih, "X");
            y += IupGetInt(ih, "Y");

            IupPopup(ih_menu, x, y+h);
            IupDestroy(ih_menu);

            /* restore a valid handle */
            ih->data->datah = ih->data->texth;

            return 1;
        }

        IupDestroy(ih_menu);
    }

    return 0;
}
Exemple #4
0
void iupMatrixEditUpdatePos(Ihandle* ih)
{
    int w, h, x, y, visible;
    visible = iupMatrixGetVisibleCellDim(ih, ih->data->edit_lin, ih->data->edit_col, &x, &y, &w, &h);
    if (!visible && !ih->data->edit_hide_onfocus)
        IupSetAttribute(ih->data->datah, "VISIBLE", "NO");

    ih->data->datah->x = x;
    ih->data->datah->y = y;

    ih->data->datah->currentwidth = w;
    ih->data->datah->currentheight = h;

    if (ih->data->datah==ih->data->texth && iupAttribGetBoolean(ih, "EDITFITVALUE"))
    {
        char* value = IupGetAttribute(ih->data->texth, "VALUE");
        int value_w, value_h;

        value_w = iupdrvFontGetStringWidth(ih->data->texth, value);
        iupdrvFontGetCharSize(ih->data->texth, NULL, &value_h);

        if (iupAttribGetBoolean(ih->data->texth, "BORDER"))
        {
            value_w += 2*4;
            value_h += 2*4;
        }

        if (value_w > ih->data->datah->currentwidth)
            ih->data->datah->currentwidth = value_w;
        if (value_h > ih->data->datah->currentheight)
            ih->data->datah->currentheight = value_h;
    }

    iupClassObjectLayoutUpdate(ih->data->datah);

    if (visible && !ih->data->edit_hide_onfocus)
        IupSetAttribute(ih->data->datah, "VISIBLE", "YES");
}
Exemple #5
0
int iupMatrixEditShow(Ihandle* ih)
{
  char* mask;
  int w, h, x, y;

  /* work around for Windows when using Multiline */
  if (iupAttribGet(ih, "_IUPMAT_IGNORE_SHOW"))
  {
    iupAttribSetStr(ih, "_IUPMAT_IGNORE_SHOW", NULL);
    return 0;
  }

  /* there are no cells that can be edited */
  if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1)
    return 0;

  /* not active */
  if(!IupGetInt(ih, "ACTIVE"))
    return 0;

  /* already visible */
  if(IupGetInt(ih->data->datah, "VISIBLE"))
    return 0;

  /* notify application */
  if (iMatrixEditCallEditionCb(ih, 1, 0) == IUP_IGNORE)
    return 0;

  if (iMatrixEditCallMenuDropCb(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
    return 0;

  /* select edit control */
  iMatrixEditChooseElement(ih);

  /* position the cell to make it visible */
  /* If the focus is not visible, a scroll is done for that the focus to be visible */
  if (!iupMatrixAuxIsCellStartVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
    iupMatrixScrollToVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell);

  /* set attributes */
  iupMatrixPrepareDrawData(ih);
  IupStoreAttribute(ih->data->datah, "BGCOLOR", iupMatrixGetBgColor(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell));
  IupStoreAttribute(ih->data->datah, "FGCOLOR", iupMatrixGetFgColor(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell));
  IupSetAttribute(ih->data->datah, "FONT", iupMatrixGetFont(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell));

  mask = IupMatGetAttribute(ih,"MASK", ih->data->lines.focus_cell, ih->data->columns.focus_cell);
  if (mask)
  {
    IupSetAttribute(ih->data->datah, "MASKCASEI", IupMatGetAttribute(ih,"MASKCASEI", ih->data->lines.focus_cell, ih->data->columns.focus_cell));
    IupSetAttribute(ih->data->datah, "MASK", mask);
  }
  else
  {
    mask = IupMatGetAttribute(ih,"MASKINT", ih->data->lines.focus_cell, ih->data->columns.focus_cell);
    if (mask)
      IupSetAttribute(ih->data->datah, "MASKINT", mask);
    else
    {
      mask = IupMatGetAttribute(ih,"MASKFLOAT", ih->data->lines.focus_cell, ih->data->columns.focus_cell);
      if (mask)
        IupSetAttribute(ih->data->datah, "MASKFLOAT", mask);
      else
        IupSetAttribute(ih->data->datah, "MASK", NULL);
    }
  }

  /* calc size */
  iupMatrixGetVisibleCellDim(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, &x, &y, &w, &h);

  ih->data->datah->x = x;
  ih->data->datah->y = y;

  ih->data->datah->currentwidth  = w;
  ih->data->datah->currentheight = h;
  iupClassObjectLayoutUpdate(ih->data->datah);

  /* activate and show */
  IupSetAttribute(ih->data->datah, "ACTIVE",  "YES");
  IupSetAttribute(ih->data->datah, "VISIBLE", "YES");
  IupSetFocus(ih->data->datah);

  return 1;
}