Пример #1
0
static char* iMatrixListGetCountAttrib(Ihandle* ih)
{
  ImatrixListData* mtxList = (ImatrixListData*)iupAttribGet(ih, "_IUPMTXLIST_DATA");
  if (mtxList->editable)
    return iupStrReturnInt(ih->data->lines.num-2);
  else
    return iupStrReturnInt(ih->data->lines.num-1);  /* the attribute does not include the title */
}
Пример #2
0
static char* motListGetValueAttrib(Ihandle* ih)
{
  if (ih->data->has_editbox)
  {
    char *str, *xstr;
    Widget cbedit;
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    xstr = XmTextFieldGetString(cbedit);
    str = iupStrReturnStr(xstr);
    XtFree(xstr);
    return str;
  }
  else 
  {
    if (ih->data->is_dropdown)
    {
      int pos;
      XtVaGetValues(ih->handle, XmNselectedPosition, &pos, NULL);
      return iupStrReturnInt(pos+1);  /* IUP starts at 1 */
    }
    else
    {
      int *pos, sel_count;
      if (XmListGetSelectedPos(ih->handle, &pos, &sel_count))  /* XmListGetSelectedPos starts at 1 */
      {
        if (!ih->data->is_multiple)
        {
          int ret = pos[0];  
          XtFree((char*)pos);
          return iupStrReturnInt(ret);
        }
        else
        {
          int i, count;
          char* str;
          XtVaGetValues(ih->handle, XmNitemCount, &count, NULL);
          str = iupStrGetMemory(count+1);
          memset(str, '-', count);
          str[count]=0;
          for (i=0; i<sel_count; i++)
            str[pos[i]-1] = '+';
          XtFree((char*)pos);
          return str;
        }
      }
    }
  }

  return NULL;
}
Пример #3
0
static char* iBoxGetCGapAttrib(Ihandle* ih)
{
  if (IupClassMatch(ih, "vbox"))
  {
    int charheight;
    iupdrvFontGetCharSize(ih, NULL, &charheight);
    return iupStrReturnInt(iupRASTER2HEIGHT(ih->data->gap, charheight));
  }
  else
  {
    int charwidth;
    iupdrvFontGetCharSize(ih, &charwidth, NULL);
    return iupStrReturnInt(iupRASTER2WIDTH(ih->data->gap, charwidth));
  }
}
Пример #4
0
static char* iScintillaGetBraceMatchAttribId(Ihandle* ih, int pos)
{
  if (pos < 0)
    return "-1";

  return iupStrReturnInt(iupScintillaSendMessage(ih, SCI_BRACEMATCH, pos, 0));
}
Пример #5
0
static char* iMatrixGetSortLineIndexAttrib(Ihandle* ih, int lin)
{
  if (lin > 0 && lin < ih->data->lines.num && ih->data->sort_has_index)
    return iupStrReturnInt(ih->data->sort_line_index[lin]);
  else
    return NULL;
}
Пример #6
0
static char* iGridBoxGetNumLinAttrib(Ihandle* ih)
{
  if (!ih->handle)
    iupBaseComputeNaturalSize(ih);

  return iupStrReturnInt(ih->data->num_lin);
}
Пример #7
0
static char* iBaseGetYAttrib(Ihandle *ih)
{
  int x = 0, y = 0;
  iupdrvClientToScreen(ih, &x, &y);
  iupdrvAddScreenOffset(&x, &y, -1);
  return iupStrReturnInt(y);
}
Пример #8
0
char* iupListGetSpacingAttrib(Ihandle* ih)
{
  if (!ih->data->is_dropdown)
    return iupStrReturnInt(ih->data->spacing);
  else
    return NULL;
}
Пример #9
0
char* iupListGetNCAttrib(Ihandle* ih)
{
  if (ih->data->has_editbox)
    return iupStrReturnInt(ih->data->nc);
  else
    return NULL;
}
Пример #10
0
static char* iMatrixExGetNumericUnitCountAttrib(Ihandle* ih, int col)
{
  int quantity = IupGetIntId(ih, "NUMERICQUANTITYINDEX", col);
  if (!quantity)
    return NULL;
  else
    return iupStrReturnInt(imatex_quantities[quantity].units_count);
}
Пример #11
0
static char* iMatrixGetUndoCountAttrib(Ihandle* ih)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  int undo_stack_count = iupArrayCount(matex_data->undo_stack);
  if (matex_data->undo_stack && undo_stack_count)
    return iupStrReturnInt(undo_stack_count);
  return NULL; 
}
Пример #12
0
static char* iTabsGetValuePosAttrib(Ihandle* ih)
{
  if (ih->handle)
  {
    int pos = iupdrvTabsGetCurrentTab(ih);
    return iupStrReturnInt(pos);
  }
  else
  {
    Ihandle* child = (Ihandle*)iupAttribGet(ih, "_IUPTABS_VALUE_HANDLE");
    int pos = IupGetChildPos(ih, child);
    if (pos != -1) /* found child */
      return iupStrReturnInt(pos);
  }

  return NULL;
}
Пример #13
0
static char* iScintillaGetFontSizeStyleAttrib(Ihandle* ih, int style)
{
  int size;

  if(style == IUP_INVALID_ID)
    style = 0;  /* Lexer style default */

  size = (int)IupScintillaSendMessage(ih, SCI_STYLEGETSIZE, style, 0);
  return iupStrReturnInt(size);
}
Пример #14
0
static char* iScintillaGetWeightStyleAttrib(Ihandle* ih, int style)
{
  int weight = (int)IupScintillaSendMessage(ih, SCI_STYLEGETWEIGHT, style, 0);

  if(style == IUP_INVALID_ID)
    style = 0;  /* Lexer style default */

  weight = (int)IupScintillaSendMessage(ih, SCI_STYLEGETWEIGHT, style, 0);
  return iupStrReturnInt(weight);
}
Пример #15
0
static char* motTextGetLineCountAttrib(Ihandle* ih)
{
  if (ih->data->is_multiline)
  {
    int linecount;
    XtVaGetValues(ih->handle, XmNtotalLines, &linecount, NULL);
    return iupStrReturnInt(linecount);
  }
  else
    return "1";
}
Пример #16
0
static char* motTextGetSpinValueAttrib(Ihandle* ih)
{
  Widget spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (spinbox && XmIsSpinBox(spinbox))
  {
    int pos;
    XtVaGetValues(ih->handle, XmNposition, &pos, NULL);
    return iupStrReturnInt(pos);
  }
  return NULL;
}
Пример #17
0
static char* motListGetCaretPosAttrib(Ihandle* ih)
{
  if (ih->data->has_editbox)
  {
    XmTextPosition pos;
    Widget cbedit;
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    pos = XmTextFieldGetInsertionPosition(cbedit);
    return iupStrReturnInt((int)pos);
  }
  else
    return NULL;
}
Пример #18
0
static char* iMatrixGetNumericFormatPrecisionAttrib(Ihandle* ih, int col)
{
  int precision;
  char* value = iupAttribGetId(ih, "NUMERICFORMAT", col);
  if (!value)
    value = iupMatrixGetNumericFormatDef(ih);

  if (!value)
    return NULL;

  precision = iupStrGetFormatPrecision(value);
  if (precision == -1)
    return NULL;

  return iupStrReturnInt(precision);
}
Пример #19
0
static char* iZboxGetValuePosAttrib(Ihandle* ih)
{
  Ihandle* child;
  int pos;

  if (!iupObjectCheck(ih->data->value_handle))
    return NULL;

  for (pos=0, child = ih->firstchild; child; child = child->brother, pos++)
  {
    if (child == ih->data->value_handle) /* found child */
      return iupStrReturnInt(pos);
  }

  return NULL;
}
Пример #20
0
static char* motTextGetCaretAttrib(Ihandle* ih)
{
  XmTextPosition pos = XmTextGetInsertionPosition(ih->handle);

  if (ih->data->is_multiline)
  {
    int col, lin;

    char *value = XmTextGetString(ih->handle);
    motTextGetLinColFromPosition(value, pos, &lin, &col);
    XtFree(value);

    return iupStrReturnIntInt(lin, col, ',');
  }
  else
  {
    pos++; /* IUP starts at 1 */
    return iupStrReturnInt((int)pos);
  }
}
Пример #21
0
static char* iScintillaGetLineCountAttrib(Ihandle* ih)
{
  int count = iupScintillaSendMessage(ih, SCI_GETLINECOUNT, 0, 0);
  return iupStrReturnInt(count);
}
Пример #22
0
static char* iScintillaGetCountAttrib(Ihandle* ih)
{
  int count = iupScintillaSendMessage(ih, SCI_GETTEXTLENGTH, 0, 0);
  return iupStrReturnInt(count);
}
Пример #23
0
static char* iScintillaGetVisibleLinesCountAttrib(Ihandle* ih)
{
  int count = iupScintillaSendMessage(ih, SCI_LINESONSCREEN, 0, 0);
  return iupStrReturnInt(count);
}
Пример #24
0
static char* iScintillaGetCaretPosAttrib(Ihandle* ih)
{
  return iupStrReturnInt(iupScintillaSendMessage(ih, SCI_GETCURRENTPOS, 0, 0));
}
Пример #25
0
static char* iBoxGetGapAttrib(Ihandle* ih)
{
  return iupStrReturnInt(ih->data->gap);
}
Пример #26
0
static char* iButtonGetSpacingAttrib(Ihandle *ih)
{
  return iupStrReturnInt(ih->data->spacing);
}
char* iupdrvGetGlobal(const char* name)
{
  if (iupStrEqual(name, "VIRTUALSCREEN"))
  {
    int x = GetSystemMetrics(SM_XVIRTUALSCREEN); 
    int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
    int w = GetSystemMetrics(SM_CXVIRTUALSCREEN); 
    int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
    return iupStrReturnStrf("%d %d %d %d", x, y, w, h);
  }
  if (iupStrEqual(name, "MONITORSINFO"))
  {
    int i;
    int monitors_count = GetSystemMetrics(SM_CMONITORS);
    RECT* monitors_rect = malloc(monitors_count*sizeof(RECT));
    char* str = iupStrGetMemory(monitors_count*50);
    char* pstr = str;

    win_monitor_index = 0;
    EnumDisplayMonitors(NULL, NULL, winGlobalMonitorInfoEnum, (LPARAM)monitors_rect);

    for (i=0; i < monitors_count; i++)
      pstr += sprintf(pstr, "%d %d %d %d\n", (int)monitors_rect[i].left, (int)monitors_rect[i].top, (int)(monitors_rect[i].right-monitors_rect[i].left), (int)(monitors_rect[i].bottom-monitors_rect[i].top));

    free(monitors_rect);
    return str;
  }
  if (iupStrEqual(name, "TRUECOLORCANVAS"))
  {
    return iupStrReturnBoolean(iupdrvGetScreenDepth() > 8);
  }
  if (iupStrEqual(name, "UTF8MODE"))
  {
    return iupStrReturnBoolean(iupwinStrGetUTF8Mode());
  }
  if (iupStrEqual(name, "UTF8MODE_FILE"))
  {
    return iupStrReturnBoolean(iupwinStrGetUTF8ModeFile());
  }
  if (iupStrEqual(name, "DLL_HINSTANCE"))
  {
    return (char*)iupwin_dll_hinstance;
  }
  if (iupStrEqual(name, "COMCTL32VER6"))
  {
    return iupStrReturnBoolean(iupwin_comctl32ver6);
  }
  if (iupStrEqual(name, "SYSTEMCODEPAGE"))
  {
    CPINFOEX info;
    GetCPInfoEx(CP_ACP, 0, &info);
    return iupStrReturnInt(info.CodePage);
  }
  if (iupStrEqual(name, "LASTERROR"))
  {
    DWORD error = GetLastError();
    if (error)
    {
      LPTSTR lpMsgBuf = NULL;
      FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
                    FORMAT_MESSAGE_FROM_SYSTEM|
                    FORMAT_MESSAGE_IGNORE_INSERTS,
                    NULL, error, 0, 
                    (LPTSTR)&lpMsgBuf,  /* weird but that's correct */
                    0, NULL);
      if (lpMsgBuf)
      {
        char* str = iupStrReturnStr(iupwinStrFromSystem(lpMsgBuf));
        LocalFree(lpMsgBuf);
        return str;
      }
      else
        return "Unknown Error";
    }
  }
  if (iupStrEqual(name, "DWM_COMPOSITION"))
  {
    typedef HRESULT(STDAPICALLTYPE *PtrDwmIsCompositionEnabled)(BOOL*);
    static PtrDwmIsCompositionEnabled dwmIsCompositionEnabled = NULL;
    if (dwmIsCompositionEnabled == NULL) 
    {
      HMODULE dwmLibrary = LoadLibrary(TEXT("dwmapi.dll"));
      if (dwmLibrary)
        dwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)GetProcAddress(dwmLibrary, "DwmIsCompositionEnabled");
    }
    if (dwmIsCompositionEnabled != NULL) 
    {
      /* windows vista or higher (has aero): see if disabled */
      BOOL enabled;
      dwmIsCompositionEnabled(&enabled);
      return iupStrReturnBoolean(enabled);
    }
    else
      return NULL;
  }
  return NULL;
}
Пример #28
0
static char* iListGetCountAttrib(Ihandle* ih)
{
  return iupStrReturnInt(iListGetCount(ih));
}
Пример #29
0
static int iListDropData_CB(Ihandle *ih, char* type, void* data, int len, int x, int y)
{
  int pos = IupConvertXYToPos(ih, x, y);
  int is_ctrl = 0;
  char key[5];

  /* Data is not the pointer, it contains the pointer */
  Ihandle* ih_source;
  memcpy((void*)&ih_source, data, len);

  /* A copy operation is enabled with the CTRL key pressed, or else a move operation will occour.
     A move operation will be possible only if the attribute DRAGSOURCEMOVE is Yes.
     When no key is pressed the default operation is copy when DRAGSOURCEMOVE=No and move when DRAGSOURCEMOVE=Yes. */
  iupdrvGetKeyState(key);
  if (key[1] == 'C')
    is_ctrl = 1;

  if (ih_source->data->is_multiple)
  {
    char *buffer = IupGetAttribute(ih_source, "VALUE");

    /* Copy all selected items */
    int i = 1;  /* IUP starts at 1 */
    while(buffer[i-1] != '\0')
    {
      if(buffer[i-1] == '+')
      {
        iupdrvListInsertItem(ih, pos, IupGetAttribute(ih_source, iupStrReturnInt(i)));
        iupdrvListSetImageHandle(ih, ++pos, iupdrvListGetImageHandle(ih_source, i));
      }

      i++;
    }

    if (IupGetInt(ih_source, "DRAGSOURCEMOVE") && !is_ctrl)
    {
      /* Remove all item from source if MOVE */
      i = 1;  /* IUP starts at 1 */
      while(*buffer != '\0')
      {
        if (*buffer == '+')
          iupdrvListRemoveItem(ih_source, --i);  /* update index in the source */

        i++;
        buffer++;
      }
    }
  }
  else
  {
    iupdrvListInsertItem(ih, pos, IupGetAttribute(ih_source, IupGetAttribute(ih_source, "VALUE")));
    iupdrvListSetImageHandle(ih, ++pos, iupdrvListGetImageHandle(ih_source, IupGetInt(ih_source, "VALUE")));

    if(IupGetInt(ih_source, "DRAGSOURCEMOVE") && !is_ctrl)
    {
      int srcPos = iupAttribGetInt(ih_source, "_IUP_LIST_SOURCEPOS");
      iupdrvListRemoveItem(ih_source, --srcPos);  /* IUP starts at 1 */
    }
  }

  (void)type;
  return IUP_DEFAULT;
}
Пример #30
0
static char* iDetachBoxGetBarSizeAttrib(Ihandle* ih)
{
  return iupStrReturnInt(ih->data->barsize);
}