Example #1
0
static void gtkTabsUpdatePageFont(Ihandle* ih)
{
  Ihandle* child;
  PangoFontDescription* fontdesc = (PangoFontDescription*)iupgtkGetPangoFontDescAttrib(ih);

  for (child = ih->firstchild; child; child = child->brother)
  {
    GtkWidget* tab_label = (GtkWidget*)iupAttribGet(child, "_IUPGTK_TABLABEL");
    if (tab_label)
    {
#if GTK_CHECK_VERSION(3, 0, 0)
      gtk_widget_override_font(tab_label, fontdesc);
#else
      gtk_widget_modify_font(tab_label, fontdesc);
#endif
      iupgtkFontUpdatePangoLayout(ih, gtk_label_get_layout((GtkLabel*)tab_label));
    }
  }
}
Example #2
0
char* iupMatrixCellGetValue (Ihandle* ih, int lin, int col)
{
  if (!ih->handle)
  {
    char str[100];
    sprintf(str, "%d:%d", lin, col);
    return iupAttribGet(ih, str);
  }
  else
  {
    if (ih->data->callback_mode)
    {
      sIFnii value_cb = (sIFnii)IupGetCallback(ih, "VALUE_CB");
      return value_cb(ih, lin, col);
    }
    else
      return ih->data->cells[lin][col].value;
  }
}
Example #3
0
static int iMatrixDrawGetColAlignment(Ihandle* ih, int col)
{
  char* align = iupAttribGetId(ih, "ALIGNMENT", col);
  if (!align)
    align = iupAttribGet(ih, "ALIGNMENT");
  if (!align)
  {
    if (col == 0)
      return IMAT_ALIGN_START;
    else
      return IMAT_ALIGN_CENTER;
  }
  else if (iupStrEqualNoCase(align, "ARIGHT"))
    return IMAT_ALIGN_END;
  else if(iupStrEqualNoCase(align, "ACENTER"))
    return IMAT_ALIGN_CENTER;
  else
    return IMAT_ALIGN_START;
}
Example #4
0
static int winDialogSetMdiActivateAttrib(Ihandle *ih, const char *value)
{
  Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
  if (client)
  {
    Ihandle* child = IupGetHandle(value);
    if (child)
      SendMessage(client->handle, WM_MDIACTIVATE, (WPARAM)child->handle, 0);
    else
    {
      HWND hchild = (HWND)SendMessage(client->handle, WM_MDIGETACTIVE, 0, 0);
      if (iupStrEqualNoCase(value, "NEXT"))
        SendMessage(client->handle, WM_MDINEXT, (WPARAM)hchild, TRUE);
      else if (iupStrEqualNoCase(value, "PREVIOUS"))
        SendMessage(client->handle, WM_MDINEXT, (WPARAM)hchild, FALSE);
    }
  }
  return 0;
}
Example #5
0
static int winDialogSetTaskBarProgressStateAttrib(Ihandle *ih, const char *value)
{
  ITaskbarList3* tbl = (ITaskbarList3*)iupAttribGet(ih, "_IUPWIN_TASKBARLIST");
  if(tbl)
  {
    if(iupStrEqualNoCase(value, "NOPROGRESS"))
      tbl->lpVtbl->SetProgressState(tbl, ih->handle, TBPF_NOPROGRESS);
    else if(iupStrEqualNoCase(value, "INDETERMINATE"))
      tbl->lpVtbl->SetProgressState(tbl, ih->handle, TBPF_INDETERMINATE);
    else if(iupStrEqualNoCase(value, "ERROR"))
      tbl->lpVtbl->SetProgressState(tbl, ih->handle, TBPF_ERROR);
    else if(iupStrEqualNoCase(value, "PAUSED"))
      tbl->lpVtbl->SetProgressState(tbl, ih->handle, TBPF_PAUSED);
    else  /* NORMAL */
      tbl->lpVtbl->SetProgressState(tbl, ih->handle, TBPF_NORMAL);
  }

  return 0;
}
Example #6
0
static char* winDialogGetMdiActiveAttrib(Ihandle *ih)
{
  Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
  if (client)
  {
    HWND hchild = (HWND)SendMessage(client->handle, WM_MDIGETACTIVE, 0, 0);
    Ihandle* child = iupwinHandleGet(hchild); 
    if (child)
    {
      iupwin_mdinext = NULL;
      iupwin_mdifirst = hchild;
      return IupGetName(child);
    }
  }

  iupwin_mdifirst = NULL;
  iupwin_mdinext = NULL;
  return NULL;
}
Example #7
0
static int iMatrixMenuItemAction_CB(Ihandle* ih_item)
{
    Ihandle* ih_menu = ih_item->parent;
    Ihandle* ih = (Ihandle*)iupAttribGet(ih_menu, "_IUP_MATRIX");
    char* title = IupGetAttribute(ih_item, "TITLE");
    IFniinsii cb = (IFniinsii)IupGetCallback(ih, "DROPSELECT_CB");
    if(cb)
    {
        int i = IupGetChildPos(ih_menu, ih_item) + 1;
        cb(ih, ih->data->edit_lin, ih->data->edit_col, ih_menu, title, i, 1);
    }

    IupStoreAttribute(ih_menu, "VALUE", title);

    iMatrixEditCallEditionCbUpdateValue(ih, 0, 1);  /* always update, similar to iupMatrixEditConfirm */
    iupMatrixDrawUpdate(ih);

    return IUP_DEFAULT;
}
Example #8
0
static int iMatrixMenuItemAction(Ihandle* ih)
{
  Ihandle* ih_menu = ih->parent;
  Ihandle* ih_matrix = (Ihandle*)iupAttribGet(ih_menu, "_IUP_MATRIX");
  char* t = IupGetAttribute(ih, "TITLE"); 
  IFniinsii cb = (IFniinsii)IupGetCallback(ih_matrix, "DROPSELECT_CB");
  if(cb)
  {
    int i = IupGetChildPos(ih_menu, ih) + 1;
    cb(ih_matrix, ih_matrix->data->lines.focus_cell, ih_matrix->data->columns.focus_cell, ih_menu, t, i, 1);
  }

  IupStoreAttribute(ih_menu, "VALUE", t);

  iMatrixEditCallEditionCb(ih_matrix, 0, 1);  /* always update */
  iupMatrixDrawUpdate(ih_matrix);

  return IUP_DEFAULT;
}
Example #9
0
void iupListSingleCallActionCb(Ihandle* ih, IFnsii cb, int pos)
{
  char* old_str = iupAttribGet(ih, "_IUPLIST_OLDVALUE");
  if (old_str)
  {
    int oldpos = atoi(old_str);
    if (oldpos != pos)
    {
      iListCallActionCallback(ih, cb, oldpos, 0);
      iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", pos);
      iListCallActionCallback(ih, cb, pos, 1);
    }
  }
  else
  {
    iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", pos);
    iListCallActionCallback(ih, cb, pos, 1);
  }
}
Example #10
0
static int winListSetCaretPosAttrib(Ihandle* ih, const char* value)
{
  int pos = 0;
  HWND cbedit;
  if (!ih->data->has_editbox)
    return 0;

  if (!value)
    return 0;

  sscanf(value,"%i",&pos);    /* be permissive in SetCaret, do not abort if invalid */
  if (pos < 0) pos = 0;

  cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX");
  SendMessage(cbedit, EM_SETSEL, (WPARAM)pos, (LPARAM)pos);
  SendMessage(cbedit, EM_SCROLLCARET, 0L, 0L);

  return 0;
}
Example #11
0
static int winToggleSetImInactiveAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->type == IUP_TOGGLE_IMAGE)
  {
    if (value != iupAttribGet(ih, "IMINACTIVE"))
      iupAttribSetStr(ih, "IMINACTIVE", (char*)value);

    if (iupwin_comctl32ver6)
      iupdrvDisplayRedraw(ih);
    else
    {
      int check = SendMessage(ih->handle, BM_GETCHECK, 0L, 0L);
      winToggleUpdateImage(ih, winToggleIsActive(ih), check);
    }
    return 1;
  }
  else
    return 0;
}
static int winToggleSetImPressAttrib(Ihandle* ih, const char* value)
{
    if (ih->data->type==IUP_TOGGLE_IMAGE)
    {
        if (value != iupAttribGet(ih, "IMPRESS"))
            iupAttribSet(ih, "IMPRESS", (char*)value);

        if (iupwin_comctl32ver6 || ih->data->flat)
            iupdrvRedrawNow(ih);
        else
        {
            int check = SendMessage(ih->handle, BM_GETCHECK, 0L, 0L);
            winToggleUpdateImage(ih, winToggleIsActive(ih), check);
        }
        return 1;
    }
    else
        return 0;
}
Example #13
0
void gtkTabSwitchPage(GtkNotebook* notebook, GtkNotebookPage *page, int pos, Ihandle* ih)
{
  IFnnn cb;

  if (iupAttribGet(ih, "_IUPGTK_IGNORE_CHANGE"))
    return;

  cb = (IFnnn)IupGetCallback(ih, "TABCHANGE_CB");
  if (cb)
  {
    Ihandle* child = IupGetChild(ih, pos);
    int prev_pos = gtk_notebook_get_current_page((GtkNotebook*)ih->handle);
    Ihandle* prev_child = IupGetChild(ih, prev_pos);
    cb(ih, child, prev_child);
  }

  (void)notebook;
  (void)page;
}
Example #14
0
Ihandle* IupSetHandle(const char *name, Ihandle *ih)
{
  Ihandle *old_ih;

  iupASSERT(name!=NULL);
  if (!name)
    return NULL;

  /* ih here can be also an user pointer, not just an Ihandle* */

  /* we do not check if the handle already has names, it may has many different names */

  old_ih = iupTableGet(inames_strtable, name);

  if (ih != NULL)
  {
    iupTableSet(inames_strtable, name, ih, IUPTABLE_POINTER);

    /* save the name in the cache if it is a valid handle */
    if (iupObjectCheck(ih))
      iupAttribSetStr(ih, "HANDLENAME", name);
  }
  else
  {
    iupTableRemove(inames_strtable, name);

    /* clear the name from the cache if it is a valid handle */
    if (iupObjectCheck(old_ih))
    {
      char* last_name = iupAttribGet(old_ih, "HANDLENAME");
      if (last_name && iupStrEqual(last_name, name))
      {
        iupAttribSet(old_ih, "HANDLENAME", NULL);  /* remove also from the cache */

        last_name = iNameFindHandle(old_ih);
        if (last_name)
          iupAttribSetStr(old_ih, "HANDLENAME", last_name);  /* if found another name save it in the cache */
      }
    }
  }

  return old_ih;
}
Example #15
0
static int gtkListSetPaddingAttrib(Ihandle* ih, const char* value)
{
  if (!ih->data->has_editbox)
    return 0;

  iupStrToIntInt(value, &ih->data->horiz_padding, &ih->data->vert_padding, 'x');
  if (ih->handle)
  {
    GtkEntry* entry;
    GtkBorder border;
    border.bottom = border.top = ih->data->vert_padding;
    border.left = border.right = ih->data->horiz_padding;
    entry = (GtkEntry*)iupAttribGet(ih, "_IUPGTK_ENTRY");
#if GTK_CHECK_VERSION(2, 10, 0)
    gtk_entry_set_inner_border(entry, &border);
#endif
  }
  return 0;
}
Example #16
0
static LRESULT CALLBACK winDialogMDIFrameProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{   
  LRESULT result;
  HWND hWndClient = NULL;
  Ihandle *ih = iupwinHandleGet(hwnd); 
  if (!ih)
  {
    /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
    if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
    {
      if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
        return 0;
    }

    return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
  }

  {
    Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
    if (client) hWndClient = client->handle;
  }

  if (winDialogBaseProc(ih, msg, wp, lp, &result))
    return result;

  switch (msg)
  {
  case WM_MENUCOMMAND:
    {
      int menuId = GetMenuItemID((HMENU)lp, (int)wp);
      if (menuId >= IUP_MDICHILD_START && hWndClient)
      {
        Ihandle* child = winDialogGetMdiChildId(ih, menuId-IUP_MDICHILD_START);
        if (child)
          SendMessage(hWndClient, WM_MDIACTIVATE, (WPARAM)child->handle, 0);
        break;
      }
    }
  }


  return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
}
static void wGLCanvasUnMapMethod(Ihandle* ih)
{
  IGlControlData* gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA");

  if (gldata->context)
  {
    if (gldata->context == wglGetCurrentContext())
      wglMakeCurrent(NULL, NULL);

    wglDeleteContext(gldata->context);
  }

  if (gldata->palette)
    DeleteObject((HGDIOBJ)gldata->palette);

  if (gldata->device)
    ReleaseDC(gldata->window, gldata->device);

  memset(gldata, 0, sizeof(IGlControlData));
}
Example #18
0
static void gtkTabsUpdatePagePadding(Ihandle* ih)
{
  Ihandle* child;

  for (child = ih->firstchild; child; child = child->brother)
  {
    GtkWidget* tab_label = (GtkWidget*)iupAttribGet(child, "_IUPGTK_TABLABEL");
    if (tab_label)
    {
#if GTK_CHECK_VERSION(3, 14, 0)
      g_object_set(G_OBJECT(tab_label), "margin-bottom", ih->data->vert_padding, NULL);
      g_object_set(G_OBJECT(tab_label), "margin-top", ih->data->vert_padding, NULL);
      g_object_set(G_OBJECT(tab_label), "margin-left", ih->data->horiz_padding, NULL);
      g_object_set(G_OBJECT(tab_label), "margin-right", ih->data->horiz_padding, NULL);
#else
      gtk_misc_set_padding((GtkMisc*)tab_label, ih->data->horiz_padding, ih->data->vert_padding);
#endif
    }
  }
}
Example #19
0
static int motLabelSetImageAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->type == IUP_LABEL_IMAGE)
  {
    iupmotSetPixmap(ih, value, XmNlabelPixmap, 0);

    if (!iupdrvIsActive(ih))
    {
      if (!iupAttribGet(ih, "IMINACTIVE"))
      {
        /* if not active and IMINACTIVE is not defined 
           then automaticaly create one based on IMAGE */
        iupmotSetPixmap(ih, value, XmNlabelInsensitivePixmap, 1); /* make_inactive */
      }
    }
    return 1;
  }
  else
    return 0;
}
Example #20
0
static int gtkListSetClipboardAttrib(Ihandle *ih, const char *value)
{
  GtkEntry* entry;
  if (!ih->data->has_editbox)
    return 0;

  /* disable callbacks */
  iupAttribSetStr(ih, "_IUPGTK_DISABLE_TEXT_CB", "1");
  entry = (GtkEntry*)iupAttribGet(ih, "_IUPGTK_ENTRY");
  if (iupStrEqualNoCase(value, "COPY"))
    gtk_editable_copy_clipboard(GTK_EDITABLE(entry));
  else if (iupStrEqualNoCase(value, "CUT"))
    gtk_editable_cut_clipboard(GTK_EDITABLE(entry));
  else if (iupStrEqualNoCase(value, "PASTE"))
    gtk_editable_paste_clipboard(GTK_EDITABLE(entry));
  else if (iupStrEqualNoCase(value, "CLEAR"))
    gtk_editable_delete_selection(GTK_EDITABLE(entry));
  iupAttribSetStr(ih, "_IUPGTK_DISABLE_TEXT_CB", NULL);
  return 0;
}
Example #21
0
static char* gtkListGetSelectionAttrib(Ihandle* ih)
{
  char *str;
  int start, end;
  GtkEntry* entry;
  if (!ih->data->has_editbox)
    return NULL;

  entry = (GtkEntry*)iupAttribGet(ih, "_IUPGTK_ENTRY");
  if (gtk_editable_get_selection_bounds(GTK_EDITABLE(entry), &start, &end))
  {
    start++; /* IUP starts at 1 */
    end++;
    str = iupStrGetMemory(100);
    sprintf(str, "%d:%d", (int)start, (int)end);
    return str;
  }

  return NULL;
}
Example #22
0
static int iFlatButtonMapMethod(Ihandle* ih)
{
  if (iupAttribGetBoolean(ih, "TOGGLE"))
  {
    Ihandle* radio = iupRadioFindToggleParent(ih);
    if (radio)
    {
      if (!iupAttribGet(radio, "_IUP_FLATBUTTON_LASTRADIO"))
      {
        /* this is the first toggle in the radio, and then set it with VALUE=ON */
        iupAttribSet(ih, "VALUE", "ON");
      }

      /* make sure it has at least one name */
      if (!iupAttribGetHandleName(ih))
        iupAttribSetHandleName(ih);
    }
  }
  return IUP_NOERROR;
}
static int iMatrixSetUndoPushCellAttrib(Ihandle* ih, int lin, int col, const char* value)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  IundoData* undo_stack_data;

  if (matex_data->undo_stack_hold)
  {
    undo_stack_data = (IundoData*)iupArrayGetData(matex_data->undo_stack);
    iMatrixExUndoDataAddCell(&(undo_stack_data[matex_data->undo_stack_pos]), lin, col, value);
  }
  else
  {
    iMatrixUndoStackAdd(matex_data, "SETCELL");
    undo_stack_data = (IundoData*)iupArrayGetData(matex_data->undo_stack);
    iMatrixExUndoDataAddCell(&(undo_stack_data[matex_data->undo_stack_pos]), lin, col, value);
    matex_data->undo_stack_pos++;
  }

  return 0;
}
static int iOleControlSetProgIdAttrib(Ihandle* ih, const char* value)
{
    CLSID clsid;

    if (!value || iupAttribGet(ih, "PROGID"))  /* can only be set once */
        return 1;

    size_t len = strlen(value)+1;
    wchar_t* wcProgId = (wchar_t*) malloc(len * sizeof(wchar_t));
    mbstowcs(wcProgId, value, len);
    HRESULT hr = CLSIDFromProgID(wcProgId, &clsid);
    free(wcProgId);
    if(FAILED(hr))
        return 0;

    if (ih->data->olehandler->Create(&clsid) == CREATE_FAILED)
        return 0;

    return 1;
}
Example #25
0
static int winListSetCaretAttrib(Ihandle* ih, const char* value)
{
  int pos = 1;
  HWND cbedit;
  if (!ih->data->has_editbox)
    return 0;

  if (!value)
    return 0;

  sscanf(value,"%i",&pos);
  if (pos < 1) pos = 1;
  pos--; /* IUP starts at 1 */

  cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX");
  SendMessage(cbedit, EM_SETSEL, (WPARAM)pos, (LPARAM)pos);
  SendMessage(cbedit, EM_SCROLLCARET, 0L, 0L);

  return 0;
}
Example #26
0
static int gtkButtonSetImInactiveAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->type & IUP_BUTTON_IMAGE)
  {
    if (!iupdrvIsActive(ih))
    {
      if (value)
        gtkButtonSetPixbuf(ih, value, 0);
      else
      {
        /* if not defined then automaticaly create one based on IMAGE */
        char* name = iupAttribGet(ih, "IMAGE");
        gtkButtonSetPixbuf(ih, name, 1); /* make_inactive */
      }
    }
    return 1;
  }
  else
    return 0;
}
Example #27
0
static int winListSetScrollToAttrib(Ihandle* ih, const char* value)
{
  int pos = 1;
  HWND cbedit;
  if (!ih->data->has_editbox)
    return 0;

  if (!value)
    return 0;

  sscanf(value,"%i",&pos);
  if (pos < 1) pos = 1;

  pos--;  /* return to Windows referece */

  cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX");
  SendMessage(cbedit, EM_LINESCROLL, (WPARAM)pos, (LPARAM)0);

  return 0;
}
Example #28
0
void iupdrvReparent(Ihandle* ih)
{
  /* Intrinsics and Motif do NOT support reparent. 
     XReparentWindow can NOT be used because will reparent only the X-Windows windows.
     So must unmap and map again to obtain the same effect. */
  Widget new_parent = iupChildTreeGetNativeParentHandle(ih);
  Widget widget = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");  /* here is used as the native child because is the outmost component of the elemement */
  if (!widget) widget = ih->handle;
  if (XtParent(widget) != new_parent)
  {
    int old_visible = IupGetInt(ih, "VISIBLE");
    if (old_visible)
      IupSetAttribute(ih, "VISIBLE", "NO");
    motSaveAttributesRec(ih); /* this does not save everything... */
    IupUnmap(ih);
    IupMap(ih);
    if (old_visible)
      IupSetAttribute(ih, "VISIBLE", "Yes");
  }
}
Example #29
0
void IupGLSwapBuffers(Ihandle* ih)
{
  IGlControlData* gldata;

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

  /* must be an IupGLCanvas */
  if (ih->iclass->nativetype != IUP_TYPECANVAS || 
      !IupClassMatch(ih, "glcanvas"))
    return;

  /* must be mapped */
  gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA");
  if (!gldata->window)
    return;

  SwapBuffers(gldata->device);
}
Example #30
0
static int winDialogSetTrayAttrib(Ihandle *ih, const char *value)
{
    int tray = iupStrBoolean(value);
    if (iupAttribGet(ih, "_IUPDLG_HASTRAY"))
    {
        if (!tray)
        {
            winDialogTrayMessage(ih->handle, NIM_DELETE, NULL, NULL);
            iupAttribSetStr(ih, "_IUPDLG_HASTRAY", NULL);
        }
    }
    else
    {
        if (tray)
        {
            winDialogTrayMessage(ih->handle, NIM_ADD, NULL, NULL);
            iupAttribSetStr(ih, "_IUPDLG_HASTRAY", "YES");
        }
    }
    return 1;
}