Пример #1
0
static void TestFocusInChild(Ihandle* ih, int pos)
{
  /* Works only in Windows, GTK will set the focus to the first child always */
  if(pos==0)
  {
    Ihandle* text = IupGetDialogChild(ih, "ATEXT");
    if (text)
      IupSetFocus(text);  
  }
  else if(pos==4)
  {
    Ihandle* button = IupGetDialogChild(ih, "EEEEEBUTTON");
    if (button)
      IupSetFocus(button);
  }
}
Пример #2
0
int iupKeyProcessMnemonic(Ihandle* ih, int code)
{
  Ihandle *ih_mnemonic, *dialog = IupGetDialog(ih);
  char attrib[16] = "_IUP_MNEMONIC_ ";
  attrib[14] = (char)code;
  iupStrUpper(attrib, attrib);
  ih_mnemonic = (Ihandle*)IupGetAttribute(dialog, attrib);
  if (iupObjectCheck(ih_mnemonic))
  {
    if (IupClassMatch(ih_mnemonic, "label"))
    {
      Ihandle* ih_next = iupFocusNextInteractive(ih_mnemonic);
      if (ih_next)
      {
        if (IupClassMatch(ih_next, "button") || IupClassMatch(ih_next, "toggle"))
          iupdrvActivate(ih_next);
        else
          IupSetFocus(ih_next);
      }
    }
    else if (IupClassMatch(ih_mnemonic, "tabs"))
      IupSetAttribute(ih_mnemonic, "VALUEPOS", IupGetAttribute(ih_mnemonic, attrib));
    else if (ih_mnemonic->handle)  /* button or toggle */
      iupdrvActivate(ih_mnemonic);

    return 1;
  }

  return 0;
}
Пример #3
0
int item_select_all_action_cb(Ihandle* item_select_all) 
{
  Ihandle* multitext = IupGetDialogChild(item_select_all, "MULTITEXT");
  IupSetFocus(multitext);
  IupSetAttribute(multitext, "SELECTION", "ALL");
  return IUP_DEFAULT;
}
Пример #4
0
static int SetFocus(lua_State *L)
{
  Ihandle *h1 = iuplua_checkihandle(L,1);
  Ihandle *h2 = IupSetFocus(h1);
  iuplua_pushihandle(L,h2);
  return 1;
}
Пример #5
0
static void iDialogAfterShow(Ihandle* ih)
{
  Ihandle* old_focus;
  IFni show_cb;
  int show_state;

  /* process all pending messages */
  IupFlush();

  old_focus = IupGetFocus();
  show_state = ih->data->show_state;

  show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
  if (show_cb && show_cb(ih, show_state) == IUP_CLOSE)
  {
    IupExitLoop();
    return;
  }

  if (show_state == IUP_SHOW)
  {
    if (show_cb)
      IupFlush();  /* again to update focus */

    /* do it only if show_cb did NOT changed the current focus */
    if (old_focus == IupGetFocus())
    {
      Ihandle *startfocus = IupGetAttributeHandle(ih, "STARTFOCUS");
      if (startfocus)
        IupSetFocus(startfocus);
      else
        IupNextField(ih);
    }
  }
}
Пример #6
0
static int btn_key_cb (Ihandle* ih)
{
  Ihandle *mltline = IupGetDialogChild(ih, "mltline");
  Ihandle *text = IupGetDialogChild(ih, "text");
  IupSetFocus(mltline);
  IupFlush();
  return IUP_DEFAULT;
}
Пример #7
0
static int btn_key_cb (Ihandle* ih)
{
  Ihandle *mltline = IupGetDialogChild(ih, "mltline");
  Ihandle *text = IupGetDialogChild(ih, "text");
  IupSetFocus(mltline);
  IupFlush();
  IupSetfAttribute(NULL, "KEY", "%d", IupGetInt(text, "VALUE"));
  return IUP_DEFAULT;
}
Пример #8
0
void iupmotCBstructure (Widget w, XtPointer data, XEvent *ev, Boolean *cont)
{
  Ihandle *n = (Ihandle*)data;
  Widget form = XtNameToWidget((Widget)handle(n),"*dialog_area");
  Iwidgetdata *wd;
  int state = -1;
  if (!form) return;
  XtVaGetValues (form, XmNuserData, &wd, NULL);
  if (!wd) return;

  switch(ev->type)
  {
    case MapNotify:
    {
      if ( iconic( wd->data ) ) /* IUP_RESTORE */
      {
        wd->data = (void*)(-((long)wd->data));
        state = IUP_RESTORE;
      }
      else /* IUP_SHOW */
      {
        Ihandle *startfocus = IupGetAttributeHandle(n, "STARTFOCUS");
        if (startfocus)
          IupSetFocus(startfocus);

        state = IUP_SHOW;
        iupmot_nvisiblewin++;
      }
      break;
    }

    case UnmapNotify:
    {
      if ( shown(wd->data) || popuped(wd->data) ) /* IUP_MINIMIZE */
      {
        wd->data = (void*)(-((long)wd->data));
        state = IUP_MINIMIZE;
      }
      break;
    }
  }
  {
    IFni cb = (IFni)IupGetCallback(n, IUP_SHOW_CB);
    if (cb && state>=0)
    {
      iupmot_incallback = TRUE;
      if (cb(n, state) == IUP_CLOSE) 
        iupmot_exitmainloop = 1;
      iupmot_incallback = FALSE;
    }
  }
}
Пример #9
0
static void iDialogCallShowCb(Ihandle* ih)
{
  IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
  if (show_cb && show_cb(ih, ih->data->show_state) == IUP_CLOSE)
    IupExitLoop();

  if (ih->data->show_state == IUP_SHOW)
  {
    Ihandle *startfocus = IupGetAttributeHandle(ih, "STARTFOCUS");
    if (startfocus)
      IupSetFocus(startfocus);
    else
      IupNextField(ih);
  }
}
Пример #10
0
Ihandle* IupNextField(Ihandle *ih)
{
  Ihandle *ih_next;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return NULL;

  ih_next = iupGetNextFocus(ih);
  if (ih_next)
  {
    IupSetFocus(ih_next);
    return ih_next;
  }

  return NULL;
}
Пример #11
0
void iupwinWmSetFocus(Ihandle *ih)
{
  Ihandle* dialog = IupGetDialog(ih);
  if (ih != dialog)
    iupAttribSetStr(dialog, "_IUPWIN_LASTFOCUS", (char*)ih);  /* used by IupMenu and here. */
  else
  {
    /* if a control inside that dialog had the focus, then reset to it when the dialog gets the focus */
    Ihandle* lastfocus = (Ihandle*)iupAttribGet(dialog, "_IUPWIN_LASTFOCUS");
    if (lastfocus)
    {
      /* call the callback and update current focus before changing it again */
      iupCallGetFocusCb(ih);

      IupSetFocus(lastfocus);
      return;
    }
  }

  iupCallGetFocusCb(ih);
}
Пример #12
0
int find_next_action_cb(Ihandle* bt_next)
{
  Ihandle* multitext = (Ihandle*)IupGetAttribute(bt_next, "MULTITEXT");
  char* str = IupGetAttribute(multitext, "VALUE");
  int find_pos = IupGetInt(multitext, "FIND_POS");

  Ihandle* txt = IupGetDialogChild(bt_next, "FIND_TEXT");
  char* str_to_find = IupGetAttribute(txt, "VALUE");

  Ihandle* find_case = IupGetDialogChild(bt_next, "FIND_CASE");
  int casesensitive = IupGetInt(find_case, "VALUE");

  int pos = str_find(str + find_pos, str_to_find, casesensitive);
  if (pos >= 0)
    pos += find_pos;
  else if (find_pos > 0)
    pos = str_find(str, str_to_find, casesensitive);  /* try again from the start */

  if (pos >= 0)
  {
    int lin, col, 
      end_pos = pos + (int)strlen(str_to_find);

    IupSetInt(multitext, "FIND_POS", end_pos);

    IupSetFocus(multitext);
    IupSetfAttribute(multitext, "SELECTIONPOS", "%d:%d", pos, end_pos);

    IupTextConvertPosToLinCol(multitext, pos, &lin, &col);
    IupTextConvertLinColToPos(multitext, lin, 0, &pos);  /* position at col=0, just scroll lines */
    IupSetInt(multitext, "SCROLLTOPOS", pos);
  }
  else
    IupMessage("Warning", "Text not found.");




  return IUP_DEFAULT;
}
Пример #13
0
static int iMatrixEditFinish(Ihandle* ih, int setfocus, int update, int accept_ignore)
{
    if (ih->data->editing)
    {
        int ret;

        /* Avoid calling EDITION_CB twice. Usually because a killfocus. */
        if (iupAttribGet(ih, "_IUPMAT_CALL_EDITION"))
            return IUP_DEFAULT;

        iupAttribSet(ih, "_IUPMAT_CALL_EDITION", "1");
        ret = iMatrixEditCallEditionCbUpdateValue(ih, 0, update);
        iupAttribSet(ih, "_IUPMAT_CALL_EDITION", NULL);

        if (ret == IUP_IGNORE && accept_ignore)
            return IUP_IGNORE;

        ih->data->editing = 0;

        iupAttribSet(ih, "_IUPMAT_IGNOREFOCUS", "1");

        IupSetAttribute(ih->data->datah, "VISIBLE", "NO");
        IupSetAttribute(ih->data->datah, "ACTIVE",  "NO");

        if (setfocus)
        {
            IupSetFocus(ih);
            ih->data->has_focus = 1; /* set this so even if getfocus_cb is not called the focus is drawn */
        }

        iupAttribSet(ih, "_IUPMAT_IGNOREFOCUS", NULL);

#ifdef SunOS
        /* Usually when the edit control is hidden the matrix is automatically repainted by the system, except in SunOS. */
        iupMatrixDrawUpdate(ih);
#endif
    }

    return IUP_DEFAULT;
}
Пример #14
0
Ihandle* IupPreviousField(Ihandle *ih)
{
  Ihandle *ih_previous = NULL;
  Ihandle *ih_next;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return NULL;

  ih_next = IupGetDialog(ih);

  for (;;)
  {
    ih_next = iupGetNextFocus(ih_next);

    if (((ih_next == NULL) || (ih_next == ih)) && ih_previous)
    {
      IupSetFocus(ih_previous);
      return ih_previous;
    }

    ih_previous = ih_next;
  }
}
Пример #15
0
void TextTest(void)
{
  int formatting = 0;
  Ihandle *dlg, *mltline, *text, *opt, *btn_def_enter, *btn_def_esc, *btn_active, *btn_overwrite,
          *btn_append, *btn_insert, *btn_caret, *btn_clip, *btn_key, *btn_readonly, *btn_tabsize,
          *btn_selection, *btn_selectedtext, *btn_nc, *btn_value, *lbl, *formattag, *btn_remformat;

//  IupSetGlobal("UTF8AUTOCONVERT", "NO");

  text = IupText (NULL);
  IupSetAttribute(text, "EXPAND", "HORIZONTAL");
//  IupSetAttribute(text, "VALUE", "Single Line Text");
  IupSetAttribute(text, "CUEBANNER", "Enter Attribute Value Here");
  IupSetAttribute(text, "NAME", "text");
  IupSetAttribute(text, "TIP", "Attribute Value");
//  IupSetAttribute(text, "FORMATTING", "YES");

  opt = IupToggle("Set/Get", NULL);
  IupSetAttribute (opt, "VALUE", "ON");
  IupSetHandle ("text2multi", opt);

  mltline = IupMultiLine(NULL);  
  //  mltline = IupText(NULL);  
//  IupSetAttribute(mltline, "MULTILINE", "YES");
  IupSetAttribute(mltline, "NAME", "mltline");

  IupSetCallback(mltline, "DROPFILES_CB", (Icallback)dropfiles_cb);
  IupSetCallback(mltline, "BUTTON_CB",    (Icallback)button_cb);
//  IupSetCallback(mltline, "MOTION_CB",    (Icallback)motion_cb);
  IupSetCallback(mltline, "HELP_CB",      (Icallback)help_cb);
  IupSetCallback(mltline, "GETFOCUS_CB",  (Icallback)getfocus_cb); 
  IupSetCallback(mltline, "KILLFOCUS_CB", (Icallback)killfocus_cb);
  IupSetCallback(mltline, "ENTERWINDOW_CB", (Icallback)enterwindow_cb);
  IupSetCallback(mltline, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb);
  IupSetCallback(mltline, "ACTION", (Icallback)action);
//  IupSetCallback(mltline, "VALUECHANGED_CB", (Icallback)valuechanged_cb);
//  IupSetCallback(mltline, "K_ANY", (Icallback)k_any);
  IupSetCallback(mltline, "K_F2", (Icallback)k_f2);
//  IupSetCallback(mltline, "CARET_CB", (Icallback)caret_cb);
//  IupSetAttribute(mltline, "WORDWRAP", "YES");
//  IupSetAttribute(mltline, "BORDER", "NO");
//  IupSetAttribute(mltline, "AUTOHIDE", "YES");
//  IupSetAttribute(mltline, "BGCOLOR", "255 0 128");
//  IupSetAttribute(mltline, "FGCOLOR", "0 128 192");
//  IupSetAttribute(mltline, "PADDING", "15x15");
  if (IupGetInt(NULL, "UTF8MODE"))
    IupSetAttribute(mltline, "VALUE", "First Line\nSecond Line Big Big Big\nThird Line\nmore\nmore\n(çãõáóé)"); // UTF-8
  else
  {
    char* txt = "First Line\nSecond Line Big Big Big\nThird Line\nmore\nmore\n(ηγυασι)";
    //int len = strlen(txt);
    IupSetAttribute(mltline, "VALUE", txt); // Windows-1252
  }
  IupSetAttribute(mltline, "TIP", "First Line\nSecond Line\nThird Line");
//  IupSetAttribute(mltline, "FONT", "Helvetica, 14");
//  IupSetAttribute(mltline, "MASK", IUP_MASK_FLOAT);
//  IupSetAttribute(mltline, "FILTER", "UPPERCASE");
//  IupSetAttribute(mltline, "ALIGNMENT", "ACENTER");
//  IupSetAttribute(mltline, "CANFOCUS", "NO");
//  IupSetAttribute(mltline, "SCROLLBAR", "NO");
//  IupSetAttribute(mltline, "NOHIDESEL", "Yes");

  /* Turns on multiline expand and text horizontal expand */
  IupSetAttribute(mltline, "SIZE", "80x40");
  IupSetAttribute(mltline, "EXPAND", "YES");

//  IupSetAttribute(mltline, "FONT", "Courier, 16");
//  IupSetAttribute(mltline, "FONT", "Arial, 12");
//    IupSetAttribute(mltline, "FORMATTING", "YES");

  formatting = 1;
  if (formatting)          /* just to make easier to comment this section */
  {
    /* formatting before Map */
    IupSetAttribute(mltline, "FORMATTING", "YES");

    formattag = IupUser();
    IupSetAttribute(formattag, "ALIGNMENT", "CENTER");
    IupSetAttribute(formattag, "SPACEAFTER", "10");
    IupSetAttribute(formattag, "FONTSIZE", "24");
    IupSetAttribute(formattag, "SELECTION", "3,1:3,50");
    IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag);

    formattag = IupUser();
    IupSetAttribute(formattag, "BGCOLOR", "255 128 64");
    IupSetAttribute(formattag, "UNDERLINE", "SINGLE");
    IupSetAttribute(formattag, "WEIGHT", "BOLD");
    IupSetAttribute(formattag, "SELECTION", "3,7:3,11");
    IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag);
  }

  /* Creates buttons */
  btn_append = IupButton ("&APPEND", NULL);
  btn_insert = IupButton ("INSERT", NULL);
  btn_caret = IupButton ("CARET", NULL);
  btn_readonly = IupButton ("READONLY", NULL);
  btn_selection = IupButton ("SELECTION", NULL);
  btn_selectedtext = IupButton ("SELECTEDTEXT", NULL);
  btn_nc = IupButton ("NC", NULL);
  btn_value = IupButton ("VALUE", NULL);
  btn_tabsize = IupButton ("TABSIZE", NULL);
  btn_clip = IupButton ("CLIPBOARD", NULL);
  btn_key = IupButton ("KEY", NULL);
  btn_def_enter = IupButton ("Default Enter", NULL);
  btn_def_esc = IupButton ("Default Esc", NULL);
  btn_active = IupButton("ACTIVE", NULL);
  btn_remformat = IupButton("REMOVEFORMATTING", NULL);
  btn_overwrite = IupButton("OVERWRITE", NULL);

  IupSetAttribute(btn_append, "TIP", "First Line\nSecond Line\nThird Line");

  /* Registers callbacks */
  IupSetCallback(btn_append, "ACTION", (Icallback) btn_append_cb);
  IupSetCallback(btn_insert, "ACTION", (Icallback) btn_insert_cb);
  IupSetCallback(btn_caret, "ACTION", (Icallback) btn_caret_cb);
  IupSetCallback(btn_readonly, "ACTION", (Icallback) btn_readonly_cb);
  IupSetCallback(btn_selection, "ACTION", (Icallback) btn_selection_cb);
  IupSetCallback(btn_selectedtext, "ACTION", (Icallback) btn_selectedtext_cb);
  IupSetCallback(btn_nc, "ACTION", (Icallback) btn_nc_cb);
  IupSetCallback(btn_value, "ACTION", (Icallback) btn_value_cb);
  IupSetCallback(btn_tabsize, "ACTION", (Icallback) btn_tabsize_cb);
  IupSetCallback(btn_clip, "ACTION", (Icallback) btn_clip_cb);
  IupSetCallback(btn_key, "ACTION", (Icallback) btn_key_cb);
  IupSetCallback(btn_def_enter, "ACTION", (Icallback) btn_def_enter_cb);
  IupSetCallback(btn_def_esc, "ACTION", (Icallback) btn_def_esc_cb);
  IupSetCallback(btn_active, "ACTION", (Icallback) btn_active_cb);
  IupSetCallback(btn_remformat, "ACTION", (Icallback) btn_remformat_cb);
  IupSetCallback(btn_overwrite, "ACTION", (Icallback) btn_overwrite_cb);

  lbl = IupLabel("&Multiline:");
  IupSetAttribute(lbl, "PADDING", "2x2");

  /* Creates dlg */
  dlg = IupDialog(IupVbox(lbl,
                          mltline, 
                          IupHbox (text, opt, NULL),
                          IupHbox (btn_append, btn_insert, btn_caret, btn_readonly, btn_selection, NULL),
                          IupHbox (btn_selectedtext, btn_nc, btn_value, btn_tabsize, btn_clip, btn_key, NULL), 
                          IupHbox (btn_def_enter, btn_def_esc, btn_active, btn_remformat, btn_overwrite, NULL), 
                          NULL));
  IupSetCallback(dlg, "K_cO", (Icallback)file_open);
  IupSetAttribute(dlg, "TITLE", "IupText Test");
  IupSetAttribute(dlg, "MARGIN", "10x10");
  IupSetAttribute(dlg, "GAP", "5");
  IupSetAttributeHandle(dlg, "DEFAULTENTER", btn_def_enter);
  IupSetAttributeHandle(dlg, "DEFAULTESC", btn_def_esc);
  IupSetAttribute(dlg, "SHRINK", "YES");

  if (formatting)          /* just to make easier to comment this section */
  {
    IupMap(dlg);
    /* formatting after Map */

    formattag = IupUser();
    IupSetAttribute(formattag, "ITALIC", "YES");
    IupSetAttribute(formattag, "STRIKEOUT", "YES");
    IupSetAttribute(formattag, "SELECTION", "2,1:2,12");
    IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag);

    if (1)
    {
      int count = IupGetInt(mltline, "COUNT");
      IupSetAttribute(mltline, "APPEND", "Append Test");

      formattag = IupUser();
      IupSetAttribute(formattag, "FGCOLOR", "0 128 64");
      IupSetfAttribute(formattag, "SELECTIONPOS", "%d:%d", count+1, IupGetInt(mltline, "COUNT"));
      IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag);
    }
  }

  /* Shows dlg in the center of the screen */
  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
  IupSetFocus(mltline);
}
Пример #16
0
static void SetFocus(void)
{
  IupSetFocus(iuplua_checkihandle(1));
}
Пример #17
0
int iupMatrixEditShowXY(Ihandle* ih, int x, int y)
{
    char* mask;

    /* work around for Windows when using Multiline */
    if (iupAttribGet(ih, "_IUPMAT_IGNORE_SHOW"))
    {
        iupAttribSet(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;

    if (ih->data->editing || iupMatrixEditIsVisible(ih))
    {
        if (ih->data->edit_hide_onfocus)
            return 0;

        iupMatrixEditHide(ih);
    }

    ih->data->edit_lin = ih->data->lines.focus_cell;
    ih->data->edit_col = ih->data->columns.focus_cell;

    /* notify application */
    if (iMatrixEditCallEditionCbUpdateValue(ih, 1, 0) == IUP_IGNORE)  /* only place where mode=1 */
        return 0;

    if (iMatrixEditCallMenuDropCb(ih, ih->data->edit_lin, ih->data->edit_col))
        return 0;

    ih->data->editing = 1;

    /* 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->edit_lin, ih->data->edit_col))
        iupMatrixScrollToVisible(ih, ih->data->edit_lin, ih->data->edit_col);

    /* set attributes */
    iupMatrixPrepareDrawData(ih);
    IupStoreAttribute(ih->data->datah, "BGCOLOR", iupMatrixGetBgColorStr(ih, ih->data->edit_lin, ih->data->edit_col));
    IupStoreAttribute(ih->data->datah, "FGCOLOR", iupMatrixGetFgColorStr(ih, ih->data->edit_lin, ih->data->edit_col));
    IupSetAttribute(ih->data->datah, "FONT", iupMatrixGetFont(ih, ih->data->edit_lin, ih->data->edit_col));

    mask = IupGetAttributeId2(ih, "MASK", ih->data->edit_lin, ih->data->edit_col);
    if (mask)
    {
        IupSetAttribute(ih->data->datah, "MASKCASEI", IupGetAttributeId2(ih, "MASKCASEI", ih->data->edit_lin, ih->data->edit_col));
        IupSetAttribute(ih->data->datah, "MASKNOEMPTY", IupGetAttributeId2(ih, "MASKNOEMPTY", ih->data->edit_lin, ih->data->edit_col));
        IupSetAttribute(ih->data->datah, "MASK", mask);
    }
    else
    {
        mask = IupGetAttributeId2(ih, "MASKINT", ih->data->edit_lin, ih->data->edit_col);
        if (mask)
            IupSetAttribute(ih->data->datah, "MASKINT", mask);
        else
        {
            mask = IupGetAttributeId2(ih, "MASKFLOAT", ih->data->edit_lin, ih->data->edit_col);
            if (mask)
                IupSetAttribute(ih->data->datah, "MASKFLOAT", mask);
            else
                IupSetAttribute(ih->data->datah, "MASK", NULL);
        }
    }

    iupMatrixEditUpdatePos(ih);

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

    if (ih->data->datah == ih->data->texth)
    {
        if (iupAttribGetBoolean(ih, "EDITALIGN"))
            IupSetStrAttribute(ih->data->datah, "ALIGNMENT", IupGetAttributeId(ih, "ALIGNMENT", ih->data->edit_col));

        if (x || y)
        {
            int pos;

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

            pos = IupConvertXYToPos(ih->data->datah, x, y);
            IupSetInt(ih->data->datah, "CARETPOS", pos);
        }
    }

    return 1;
}
Пример #18
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;
}