Пример #1
0
static char* iScintillaGetCharAttribId(Ihandle* ih, int pos)
{
  char str[2];
  str[0] = (char)IupScintillaSendMessage(ih, SCI_GETCHARAT, pos, 0);
  str[1] = 0;
  return iupStrReturnStr(str);
}
Пример #2
0
static char* motTextGetValueAttrib(Ihandle* ih)
{
  char* value = XmTextGetString(ih->handle);
  char* str = iupStrReturnStr(value);
  XtFree(value);
  return str;
}
Пример #3
0
static char* motTextGetSelectedTextAttrib(Ihandle* ih)
{
  char* selectedtext = XmTextGetSelection(ih->handle);
  char* str = iupStrReturnStr(selectedtext);
  XtFree(selectedtext);
  return str;
}
Пример #4
0
static char* gtkWebBrowserGetItemHistoryAttrib(Ihandle* ih, int id)
{
  WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list ((WebKitWebView*)ih->handle);
  WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(back_forward_list, id);
  if (item)
    return iupStrReturnStr(webkit_web_history_item_get_uri(item));
  else
    return NULL;
}
Пример #5
0
static char* iMatrixExReturnUnit(const char* name)
{
  if (imatex_unity_spell)
  {
    char am_name[30];
    if (iMatrixGetUnity(name, am_name))
      return iupStrReturnStr(am_name);
  }

  return (char*)name;
}
Пример #6
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;
}
Пример #7
0
static char* iMatrixGetUndoNameAttrib(Ihandle* ih, int id)
{
  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)
  {
    IundoData* undo_stack_data = (IundoData*)iupArrayGetData(matex_data->undo_stack);

    if (id < 0 || id >= undo_stack_count)
      return NULL;

    return iupStrReturnStr(undo_stack_data[id].name);
  }
  return NULL; 
}
Пример #8
0
static char* motListGetSelectedTextAttrib(Ihandle* ih)
{
  if (ih->data->has_editbox)
  {
    char* selectedtext, *str;
    Widget cbedit;
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    selectedtext = XmTextFieldGetSelection(cbedit);
    str = iupStrReturnStr(selectedtext);
    XtFree(selectedtext);
    return str;
  }
  else
    return NULL;
}
Пример #9
0
static char* iVboxGetAlignmentAttrib(Ihandle* ih)
{
  char* align2str[3] = {"ALEFT", "ACENTER", "ARIGHT"};
  return iupStrReturnStr(align2str[ih->data->alignment]);
}
Пример #10
0
char* iupdrvLocaleInfo(void)
{
  CPINFOEXA info;
  GetCPInfoExA(CP_ACP, 0, &info);
  return iupStrReturnStr(info.CodePageName);
}
Пример #11
0
static char* iButtonGetImagePositionAttrib(Ihandle *ih)
{
  char* img_pos2str[4] = {"LEFT", "RIGHT", "TOP", "BOTTOM"};
  return iupStrReturnStr(img_pos2str[ih->data->img_position]);
}
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;
}
Пример #13
0
static char* gtkWebBrowserGetValueAttrib(Ihandle* ih)
{
  const gchar* value = webkit_web_view_get_uri((WebKitWebView*)ih->handle);
  return iupStrReturnStr(value);
}
Пример #14
0
char *iupdrvGetGlobal(const char *name)
{
  if (iupStrEqual(name, "VIRTUALSCREEN"))
  {
    GdkScreen *screen = gdk_screen_get_default();
    GdkWindow *root = gdk_screen_get_root_window(gdk_screen_get_default());
    int x = 0;
    int y = 0;
    int w = gdk_screen_get_width(screen);
    int h = gdk_screen_get_height(screen);
    gdk_window_get_root_origin(root, &x, &y);
    return iupStrReturnStrf("%d %d %d %d", x, y, w, h);
  }
  if (iupStrEqual(name, "MONITORSINFO"))
  {
    int i;
#if GTK_CHECK_VERSION(3, 22, 0)
    GdkDisplay *display = gdk_display_get_default();
    int monitors_count = gdk_display_get_n_monitors(display);
#else
    GdkScreen *screen = gdk_screen_get_default();
    int monitors_count = gdk_screen_get_n_monitors(screen);
#endif
    char *str = iupStrGetMemory(monitors_count * 50);
    char* pstr = str;
    GdkRectangle rect;

    for (i = 0; i < monitors_count; i++)
    {
#if GTK_CHECK_VERSION(3, 22, 0)
      GdkMonitor* monitor = gdk_display_get_monitor(display, i);
      gdk_monitor_get_geometry(monitor, &rect);
#else
      gdk_screen_get_monitor_geometry(screen, i, &rect);
#endif
      pstr += sprintf(pstr, "%d %d %d %d\n", rect.x, rect.y, rect.width, rect.height);
    }

    return str;
  }
  if (iupStrEqual(name, "MONITORSCOUNT"))
  {
#if GTK_CHECK_VERSION(3, 22, 0)
    GdkDisplay *display = gdk_display_get_default();
    int monitors_count = gdk_display_get_n_monitors(display);
#else
    GdkScreen *screen = gdk_screen_get_default();
    int monitors_count = gdk_screen_get_n_monitors(screen);
#endif
    return iupStrReturnInt(monitors_count);
  }
  if (iupStrEqual(name, "TRUECOLORCANVAS"))
  {
    return iupStrReturnBoolean(gdk_visual_get_best_depth() > 8);
  }
  if (iupStrEqual(name, "UTF8MODE"))
  {
    return iupStrReturnBoolean(iupgtkStrGetUTF8Mode());
  }
  if (iupStrEqual(name, "UTF8AUTOCONVERT"))
  {
    return iupStrReturnBoolean(!iupgtkStrGetUTF8Mode());
  }
#ifndef WIN32
  if (iupStrEqual(name, "EXEFILENAME"))
  {
    char* argv0 = IupGetGlobal("ARGV0");
    if (argv0)
    {
      char* exefilename = realpath(argv0, NULL);
      if (exefilename)
      {
        char* str = iupStrReturnStr(exefilename);
        free(exefilename);
        return str;
      }
    }
  }
#endif
  if (iupStrEqual(name, "SHOWMENUIMAGES"))
  {
    gboolean menu_images;
    g_object_get (gtk_settings_get_default (), "gtk-menu-images", &menu_images, NULL);
    return iupStrReturnBoolean(menu_images);
  }
  return NULL;
}