Exemple #1
0
static gboolean gtkToggleButtonEvent(GtkWidget *widget, GdkEventButton *evt, Ihandle *ih)
{
  if (iupAttribGet(ih, "_IUPGTK_IGNORE_TOGGLE"))
    return FALSE;

  if (ih->data->type == IUP_TOGGLE_IMAGE)
  {
    char* name = iupAttribGet(ih, "IMPRESS");
    if (name)
    {
      if (evt->type == GDK_BUTTON_PRESS)
        gtkToggleUpdateImage(ih, iupdrvIsActive(ih), 1);
      else
        gtkToggleUpdateImage(ih, iupdrvIsActive(ih), 0);
    }
  }
  else
  {
    if (evt->type == GDK_BUTTON_RELEASE)
    {
      if (gtkToggleUpdate3StateCheck(ih, 0))
        return TRUE; /* ignore message to avoid change toggle state */
    }
  }
    
  (void)widget;
  return FALSE;
}
Exemple #2
0
char* iupBaseGetActiveAttrib(Ihandle *ih)
{
  if (iupdrvIsActive(ih))
    return "YES";
  else
    return "NO";
}
Exemple #3
0
/* Draw the column titles, visible, between col and lastcol, include it. 
   Column titles marked will be draw with the appropriate feedback.
   -> col1 - First column to have its title drawn
   -> col2 - Last column to have its title drawn */
void iupMatrixDrawColumnTitle(Ihandle* ih, int col1, int col2)
{
  int x1, y1, x2, y2;
  int col, active;
  char str[100];
  long framecolor;
  IFniiiiiiC draw_cb;

  if (!ih->data->lines.sizes[0])
    return;

  if (col1 > ih->data->columns.last ||
      col2 < ih->data->columns.first)
    return;

  if (col1 < ih->data->columns.first)
    col1 = ih->data->columns.first;
  if (col2 > ih->data->columns.last)
    col2 = ih->data->columns.last;

  /* Start the position of the first column title */
  y1 = 0;
  y2 = ih->data->lines.sizes[0];

  x1 = ih->data->columns.sizes[0];
  for(col = ih->data->columns.first; col < col1; col++)
    x1 += ih->data->columns.sizes[col];

  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  active = iupdrvIsActive(ih);
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  /* Draw the titles */
  for(col = col1; col <= col2; col++)
  {
    /* If it is an hide column (size = 0), no draw the title */
    if(ih->data->columns.sizes[col] == 0)
      continue;

    x2 = x1 + ih->data->columns.sizes[col];

    /* If it doesn't have title, the loop just calculate the final position */
    if (ih->data->lines.sizes[0])
    {
      int marked = iupMatrixColumnIsMarked(ih, col);

      iMatrixDrawFrameRectTitle(ih, 0, col, x1, x2, y1, y2, framecolor, str);

      iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, 0, col);

      iMatrixDrawCellValue(ih, x1, x2, y1, y2, IMAT_T_CENTER, marked, active, 0, col, draw_cb);

      iMatrixDrawSortSign(ih, x2, y1, y2, col, active, str);
    }

    x1 = x2;
  }
}
Exemple #4
0
/* Draw the line titles, visible, between lin and lastlin, include it. 
   Line titles marked will be draw with the appropriate feedback.
   -> lin1 - First line to have its title drawn
   -> lin2 - Last line to have its title drawn */
void iupMatrixDrawLineTitle(Ihandle* ih, int lin1, int lin2)
{
  int x1, y1, x2, y2;
  int lin, alignment, active;
  char str[100];
  long framecolor;
  IFniiiiiiC draw_cb;

  if (!ih->data->columns.sizes[0])
    return;

  if (lin1 > ih->data->lines.last ||
      lin2 < ih->data->lines.first)
    return;

  if (lin1 < ih->data->lines.first)
    lin1 = ih->data->lines.first;
  if (lin2 > ih->data->lines.last)
    lin2 = ih->data->lines.last;

  /* Start the position of the line title */
  x1 = 0;
  x2 = ih->data->columns.sizes[0];

  y1 = ih->data->lines.sizes[0];
  for(lin = ih->data->lines.first; lin < lin1; lin++)
    y1 += ih->data->lines.sizes[lin];

  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  active = iupdrvIsActive(ih);
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  alignment = iMatrixDrawGetColAlignment(ih, 0, str);

  /* Draw the titles */
  for(lin = lin1; lin <= lin2; lin++)
  {
    /* If it is a hidden line (size = 0), don't draw the title */
    if(ih->data->lines.sizes[lin] == 0)
      continue;

    y2 = y1 + ih->data->lines.sizes[lin];

    /* If it doesn't have title, the loop just calculate the final position */
    if (ih->data->columns.sizes[0])
    {
      int marked = iupMatrixLineIsMarked(ih, lin);

      iMatrixDrawFrameRectTitle(ih, lin, 0, x1, x2, y1, y2, framecolor, str);

      iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, lin, 0);

      iMatrixDrawCellValue(ih, x1, x2, y1, y2, alignment, marked, active, lin, 0, draw_cb);
    }

    y1 = y2;
  }
}
Exemple #5
0
static int iBaseNativeParentIsActive(Ihandle* ih)
{
  if (!ih->parent)
    return 1;

  if (ih->parent->iclass->nativetype == IUP_TYPEVOID)
    return iBaseNativeParentIsActive(ih->parent);
  else 
    return iupdrvIsActive(ih->parent);
}
Exemple #6
0
static int iColorbarSetActiveAttrib(Ihandle* ih, const char* value)
{
  iupBaseSetActiveAttrib(ih, value);

  cdIupCalcShadows(ih->data->bgcolor, &ih->data->light_shadow, &ih->data->mid_shadow, &ih->data->dark_shadow);
  if (!iupdrvIsActive(ih))
    ih->data->light_shadow = ih->data->mid_shadow;

  iColorbarRepaint(ih);
  return 0;   /* do not store value in hash table */
}
Exemple #7
0
static int gtkToggleSetImPressAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->type == IUP_TOGGLE_IMAGE)
  {
    if (value != iupAttribGet(ih, "IMPRESS"))
      iupAttribSetStr(ih, "IMPRESS", (char*)value);
    gtkToggleUpdateImage(ih, iupdrvIsActive(ih), gtkToggleGetCheck(ih));
    return 1;
  }
  else
    return 0;
}
static void winLabelDrawImage(Ihandle* ih, HDC hDC, int rect_width, int rect_height)
{
  int xpad = ih->data->horiz_padding, 
      ypad = ih->data->vert_padding;
  int x, y, width, height, bpp;
  HBITMAP hBitmap, hMask = NULL;
  char *name;
  int make_inactive = 0;

  if (iupdrvIsActive(ih))
    name = iupAttribGet(ih, "IMAGE");
  else
  {
    name = iupAttribGet(ih, "IMINACTIVE");
    if (!name)
    {
      name = iupAttribGet(ih, "IMAGE");
      make_inactive = 1;
    }
  }

  hBitmap = iupImageGetImage(name, ih, make_inactive);
  if (!hBitmap)
    return;

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(hBitmap, &width, &height, &bpp);

  if (ih->data->horiz_alignment == IUP_ALIGN_ARIGHT)
    x = rect_width - (width + 2*xpad);
  else if (ih->data->horiz_alignment == IUP_ALIGN_ACENTER)
    x = (rect_width - (width + 2*xpad))/2;
  else  /* ALEFT */
    x = 0;

  if (ih->data->vert_alignment == IUP_ALIGN_ABOTTOM)
    y = rect_height - (height + 2*ypad);
  else if (ih->data->vert_alignment == IUP_ALIGN_ATOP)
    y = 0;
  else  /* ACENTER */
    y = (rect_height - (height + 2*ypad))/2;

  x += xpad;
  y += ypad;

  if (bpp == 8)
    hMask = iupdrvImageCreateMask(IupGetHandle(name));

  iupwinDrawBitmap(hDC, hBitmap, hMask, x, y, width, height, bpp);

  if (hMask)
    DeleteObject(hMask);
}
Exemple #9
0
static void iMatrixDrawTitleCorner(Ihandle* ih)
{
  char str[100];
  long framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  int active = iupdrvIsActive(ih);
  IFniiiiiiC draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  iMatrixDrawFrameRectTitle(ih, 0, 0, 0, ih->data->columns.sizes[0], 0, ih->data->lines.sizes[0], framecolor, str);

  iMatrixDrawBackground(ih, 0, ih->data->columns.sizes[0], 0, ih->data->lines.sizes[0], 0, active, 0, 0);

  iMatrixDrawCellValue(ih, 0, ih->data->columns.sizes[0], 0, ih->data->lines.sizes[0], IMAT_T_CENTER, 0, active, 0, 0, draw_cb);
}
Exemple #10
0
static int gtkToggleSetValueAttrib(Ihandle* ih, const char* value)
{
  if (iupStrEqualNoCase(value,"NOTDEF"))
    gtk_toggle_button_set_inconsistent((GtkToggleButton*)ih->handle, TRUE);
  else 
  {
    int check;
    Ihandle* last_ih = NULL;
    Ihandle* radio = iupRadioFindToggleParent(ih);
    gtk_toggle_button_set_inconsistent((GtkToggleButton*)ih->handle, FALSE);

    /* This action causes the toggled signal to be emitted. */
    iupAttribSet(ih, "_IUPGTK_IGNORE_TOGGLE", "1");
    if (radio)
    {
      last_ih = (Ihandle*)IupGetAttribute(radio, "VALUE_HANDLE");
      if (last_ih)
        iupAttribSet(last_ih, "_IUPGTK_IGNORE_TOGGLE", "1");
    }

    if (iupStrEqualNoCase(value,"TOGGLE"))
    {
      if (gtk_toggle_button_get_active((GtkToggleButton*)ih->handle))
        check = 0;
      else
        check = 1;
    }
    else
      check = iupStrBoolean(value);

    if (check)
      gtk_toggle_button_set_active((GtkToggleButton*)ih->handle, TRUE);
    else
    {
      gtk_toggle_button_set_active((GtkToggleButton*)ih->handle, FALSE);

      if (ih->data->type == IUP_TOGGLE_IMAGE && ih->data->flat)
        gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE);
    }

    if (ih->data->type == IUP_TOGGLE_IMAGE)
      gtkToggleUpdateImage(ih, iupdrvIsActive(ih), gtkToggleGetCheck(ih));

    iupAttribSet(ih, "_IUPGTK_IGNORE_TOGGLE", NULL);
    if (last_ih)
      iupAttribSet(last_ih, "_IUPGTK_IGNORE_TOGGLE", NULL);
  }

  return 0;
}
Exemple #11
0
static int iColorbarSetBgColorAttrib(Ihandle* ih, const char* value)
{
  if (!value)
    value = iupControlBaseGetParentBgColor(ih);

  ih->data->bgcolor = cdIupConvertColor(value);

  cdIupCalcShadows(ih->data->bgcolor, &ih->data->light_shadow, &ih->data->mid_shadow, &ih->data->dark_shadow);
  if (!iupdrvIsActive(ih))
    ih->data->light_shadow = ih->data->mid_shadow;
  
  iColorbarRepaint(ih);
  return 1;
}
gboolean iupgtkFocusInOutEvent(GtkWidget *widget, GdkEventFocus *evt, Ihandle *ih)
{
  (void)widget;

  if (evt->in)
  {
    /* even when ACTIVE=NO the dialog gets this evt */
    if (!iupdrvIsActive(ih))
      return TRUE;

    iupCallGetFocusCb(ih);
  }
  else
    iupCallKillFocusCb(ih);

  return FALSE;
}
Exemple #13
0
static void iMatrixDrawTitleCorner(Ihandle* ih)
{
  if (ih->data->lines.dt[0].size && ih->data->columns.dt[0].size)
  {
    long framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
    int active = iupdrvIsActive(ih);
    IFniiiiiiC draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");
    int alignment = iMatrixDrawGetAlignmentLin0(ih);
    int framehighlight = iupAttribGetInt(ih, "FRAMETITLEHIGHLIGHT");

    iMatrixDrawBackground(ih, 0, ih->data->columns.dt[0].size, 0, ih->data->lines.dt[0].size, 0, active, 0, 0);

    iMatrixDrawFrameRectTitle(ih, 0, 0, 0, ih->data->columns.dt[0].size, 0, ih->data->lines.dt[0].size, framecolor, framehighlight);

    iMatrixDrawCellValue(ih, 0, ih->data->columns.dt[0].size, 0, ih->data->lines.dt[0].size, alignment, 0, active, 0, 0, draw_cb, framecolor);
  }
}
Exemple #14
0
static void iDialUpdateFgColors(Ihandle* ih, unsigned char r, unsigned char g, unsigned char b)
{
  int i, max, deltar, deltag, deltab;

  /* this function is also called before mapping */
  max = (ih->handle && iupdrvIsActive(ih))? 255 : 192;
  deltar = (max-r) / IDIAL_NCOLORS;
  deltag = (max-g) / IDIAL_NCOLORS;
  deltab = (max-b) / IDIAL_NCOLORS;

  for (i=0; i<=IDIAL_NCOLORS; i++)
  {
    ih->data->fgcolor[i] = cdEncodeColor(r, g, b);
    r = (unsigned char)(r + deltar);
    g = (unsigned char)(g + deltag);
    b = (unsigned char)(b + deltab);
  }
}
Exemple #15
0
static int iDialSetActiveAttrib(Ihandle* ih, const char* value)
{
  unsigned char r, g, b;

  iupBaseSetActiveAttrib(ih, value);

  value = iupAttribGetStr(ih, "FGCOLOR");
  if (!iupStrToRGB(value, &r, &g, &b))
    return 0;
  iDialUpdateFgColors(ih, r, g, b);

  cdIupCalcShadows(ih->data->bgcolor, &ih->data->light_shadow, &ih->data->mid_shadow, &ih->data->dark_shadow);
  if (!iupdrvIsActive(ih))
    ih->data->light_shadow = ih->data->mid_shadow;

  iDialRepaint(ih);
  return 0;   /* do not store value in hash table */
}
Exemple #16
0
static void gtkToggleToggled(GtkToggleButton *widget, Ihandle* ih)
{
  IFni cb;
  int check;

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

  check = gtkToggleGetCheck(ih);

  if (ih->data->type == IUP_TOGGLE_IMAGE)
    gtkToggleUpdateImage(ih, iupdrvIsActive(ih), check);

  cb = (IFni)IupGetCallback(ih, "ACTION");
  if (cb && cb(ih, check) == IUP_CLOSE)
    IupExitLoop();

  (void)widget;
}
Exemple #17
0
static int iMatrixListDrawColorCol(Ihandle *ih, int lin, int x1, int x2, int y1, int y2, cdCanvas *cnv)
{
  unsigned char red, green, blue;
  char* color = iupAttribGetId(ih, "COLOR", lin);

  if (iupStrToRGB(color, &red, &green, &blue))
  {
    static const int DX_BORDER = 2;
    static const int DY_BORDER = 3;
    static const int DX_FILL = 3;
    static const int DY_FILL = 4;
    int active = iupdrvIsActive(ih);
    int itemactive = IupGetIntId(ih, "ITEMACTIVE", lin);
    long framecolor;

    if (!itemactive)
    {
      red = IMAT_LIGHTER(red);
      green = IMAT_LIGHTER(green);
      blue = IMAT_LIGHTER(blue);
    }

    if (!active)
    {
      unsigned char bg_r, bg_g, bg_b;
      iupStrToRGB(ih->data->bgcolor, &bg_r, &bg_g, &bg_b);
      iupImageColorMakeInactive(&red, &green, &blue, bg_r, bg_g, bg_b);
    }

    /* Fill the box with the color */
    cdCanvasForeground(cnv, cdEncodeColor(red, green, blue));
    cdCanvasBox(cnv, x1 + DX_FILL, x2 - DX_FILL, y1 - DY_FILL, y2 + DY_FILL);

    /* Draw the border */
    framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
    cdCanvasForeground(cnv, framecolor);

    cdCanvasRect(cnv, x1 + DX_BORDER, x2 - DX_BORDER, y1 - DY_BORDER, y2 + DY_BORDER);
  }

  return IUP_DEFAULT;  /* draw nothing more */
}
static void winLabelDrawText(Ihandle* ih, HDC hDC, int rect_width, int rect_height)
{
  int xpad = ih->data->horiz_padding, 
      ypad = ih->data->vert_padding;
  int x, y, width, height, style;
  HFONT hFont = (HFONT)iupwinGetHFontAttrib(ih);
  COLORREF fgcolor;

  char* title = iupdrvBaseGetTitleAttrib(ih);
  char* str = iupStrProcessMnemonic(title, NULL, 0);   /* remove & */
  iupdrvFontGetMultiLineStringSize(ih, str, &width, &height);
  if (str && str!=title) free(str);

  if (ih->data->horiz_alignment == IUP_ALIGN_ARIGHT)
    style = DT_RIGHT;
  else if (ih->data->horiz_alignment == IUP_ALIGN_ACENTER)
    style = DT_CENTER;
  else  /* ALEFT */
    style = DT_LEFT;

  if (ih->data->vert_alignment == IUP_ALIGN_ABOTTOM)
    y = rect_height - (height + 2*ypad);
  else if (ih->data->vert_alignment == IUP_ALIGN_ATOP)
    y = 0;
  else  /* ACENTER */
    y = (rect_height - (height + 2*ypad))/2;

  /* let DrawText do the horizontal alignment */
  x = xpad;
  width = rect_width - 2*xpad;
  y += ypad;

  if (iupdrvIsActive(ih))
    fgcolor = ih->data->fgcolor;
  else
    fgcolor = GetSysColor(COLOR_GRAYTEXT);

  /* WORDWRAP and ELLIPSIS */
  style |= ih->data->text_style;

  iupwinDrawText(hDC, title, x, y, width, height, hFont, fgcolor, style);
}
Exemple #19
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;
}
Exemple #20
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;
}
Exemple #21
0
/* This function is used to draw a box for a cell. */
static void iColorbarDrawBox(Ihandle* ih, int xmin, int xmax, int ymin, int ymax, int idx)
{
  long int color = ih->data->colors[idx];
  cdCanvasInteriorStyle(ih->data->cddbuffer, CD_SOLID);

  if (color == ih->data->transparency)
  { 
    int xm = (xmin+xmax)/2;
    int ym = (ymin+ymax)/2;
    cdCanvasForeground(ih->data->cddbuffer,0xeeeeee);
    cdCanvasBox(ih->data->cddbuffer,xmin, xm, ymin, ym);
    cdCanvasBox(ih->data->cddbuffer,xm, xmax, ym, ymax);
    cdCanvasForeground(ih->data->cddbuffer,0xcccccc);
    cdCanvasBox(ih->data->cddbuffer,xmin, xm, ym, ymax);
    cdCanvasBox(ih->data->cddbuffer,xm, xmax, ymin, ym);
  }
  else
  {
    if (!iupdrvIsActive(ih))
    {
      unsigned char r, g, b, bg_r, bg_g, bg_b;
      cdDecodeColor(color, &r, &g, &b);
      cdDecodeColor(ih->data->bgcolor, &bg_r, &bg_g, &bg_b);
      iupImageColorMakeInactive(&r, &g, &b, bg_r, bg_g, bg_b);
      color = cdEncodeColor(r, g, b);
    }
    cdCanvasForeground(ih->data->cddbuffer,color);
    cdCanvasBegin(ih->data->cddbuffer,CD_FILL);
    cdCanvasVertex(ih->data->cddbuffer,xmin, ymin); cdCanvasVertex(ih->data->cddbuffer,xmin, ymax);
    cdCanvasVertex(ih->data->cddbuffer,xmax, ymax); cdCanvasVertex(ih->data->cddbuffer,xmax, ymin);
    cdCanvasEnd(ih->data->cddbuffer);
  }

  cdCanvasForeground(ih->data->cddbuffer,CD_BLACK);
  cdCanvasBegin(ih->data->cddbuffer,CD_CLOSED_LINES);
  cdCanvasVertex(ih->data->cddbuffer,xmin, ymin); cdCanvasVertex(ih->data->cddbuffer,xmin, ymax);
  cdCanvasVertex(ih->data->cddbuffer,xmax, ymax); cdCanvasVertex(ih->data->cddbuffer,xmax, ymin);
  cdCanvasEnd(ih->data->cddbuffer);
}
Exemple #22
0
static void iColorBrowserUpdateDisplay(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
    return;

  cdCanvasFlush(ih->data->cddbuffer);  /* swap the RGB to the display canvas */

  if (iupdrvIsActive(ih))
  {
    cdCanvasForeground(ih->data->cdcanvas, CD_GRAY);
    cdCanvasArc(ih->data->cdcanvas, ih->data->h_x+1, ih->data->h_y, ICB_MARKSIZE, ICB_MARKSIZE, 0, 360);
    cdCanvasArc(ih->data->cdcanvas, ih->data->si_x+1, ih->data->si_y, ICB_MARKSIZE, ICB_MARKSIZE, 0, 360);
    cdCanvasForeground(ih->data->cdcanvas, CD_WHITE);
    cdCanvasArc(ih->data->cdcanvas, ih->data->h_x, ih->data->h_y, ICB_MARKSIZE, ICB_MARKSIZE, 0, 360);
    cdCanvasArc(ih->data->cdcanvas, ih->data->si_x, ih->data->si_y, ICB_MARKSIZE, ICB_MARKSIZE, 0, 360);
  }
  else
  {
    cdCanvasForeground(ih->data->cdcanvas, CD_DARK_GRAY);
    cdCanvasSector(ih->data->cdcanvas, ih->data->h_x, ih->data->h_y, ICB_MARKSIZE+1, ICB_MARKSIZE+1, 0, 360);
    cdCanvasSector(ih->data->cdcanvas, ih->data->si_x, ih->data->si_y, ICB_MARKSIZE+1, ICB_MARKSIZE+1, 0, 360);
  }
}
Exemple #23
0
static int gtkToggleSetValueAttrib(Ihandle* ih, const char* value)
{
  if (iupStrEqualNoCase(value,"NOTDEF"))
    gtk_toggle_button_set_inconsistent((GtkToggleButton*)ih->handle, TRUE);
  else 
  {
    gtk_toggle_button_set_inconsistent((GtkToggleButton*)ih->handle, FALSE);

    /* This action causes the toggled signal to be emitted. */
    iupAttribSetStr(ih, "_IUPGTK_IGNORE_TOGGLE", "1");

    if (iupStrBoolean(value))
      gtk_toggle_button_set_active((GtkToggleButton*)ih->handle, TRUE);
    else
      gtk_toggle_button_set_active((GtkToggleButton*)ih->handle, FALSE);

    if (ih->data->type == IUP_TOGGLE_IMAGE)
      gtkToggleUpdateImage(ih, iupdrvIsActive(ih), gtkToggleGetCheck(ih));

    iupAttribSetStr(ih, "_IUPGTK_IGNORE_TOGGLE", NULL);
  }

  return 0;
}
Exemple #24
0
static void motDialogCBclose(Widget w, XtPointer client_data, XtPointer call_data)
{
  Icallback cb;
  Ihandle *ih = (Ihandle*)client_data;
  if (!ih) return;
  (void)call_data;
  (void)w;

  /* even when ACTIVE=NO the dialog gets this event */
  if (!iupdrvIsActive(ih))
    return;

  cb = IupGetCallback(ih, "CLOSE_CB");
  if (cb)
  {
    int ret = cb(ih);
    if (ret == IUP_IGNORE)
      return;
    if (ret == IUP_CLOSE)
      IupExitLoop();
  }

  IupHide(ih); /* default: close the window */
}
Exemple #25
0
gboolean iupgtkDialogDeleteEvent(GtkWidget *widget, GdkEvent *evt, Ihandle *ih)
{
  Icallback cb;
  (void)widget;
  (void)evt;

  /* even when ACTIVE=NO the dialog gets this evt */
  if (!iupdrvIsActive(ih))
    return TRUE;

  cb = IupGetCallback(ih, "CLOSE_CB");
  if (cb)
  {
    int ret = cb(ih);
    if (ret == IUP_IGNORE)
      return TRUE;
    if (ret == IUP_CLOSE)
      IupExitLoop();
  }

  IupHide(ih); /* default: close the window */

  return TRUE; /* do not propagate */
}
Exemple #26
0
static int iMatrixListDrawImageCol(Ihandle *ih, ImatrixListData* mtxList, int lin, int col, int x1, int x2, int y1, int y2, cdCanvas *cnv)
{
  char* image_name;
  int make_inactive = 0, itemactive, imageactive, imagevalue, showdelete,
      active = iupdrvIsActive(ih), linedelete;
  int lines_num = ih->data->lines.num;
  Ihandle* image;

  itemactive = IupGetIntId(ih, "ITEMACTIVE", lin);
  imageactive = IupGetIntId(ih, "IMAGEACTIVE", lin);
  imagevalue = IupGetIntId(ih, "IMAGEVALUE", lin);
  showdelete = IupGetInt(ih, "SHOWDELETE");
  linedelete = IupGetIntId(ih, "LINEDELETE", lin);

  if (!active || !itemactive || !imageactive)
    make_inactive = 1;

  image_name = iupAttribGetId(ih, "IMAGE", lin);
  if (!image_name)
  {
    char* attrib_name;
    if (mtxList->editable)
    {
      if (lin == lines_num-1)
        attrib_name = "IMAGEADD";
      else
      {
        if (showdelete || linedelete)
          attrib_name = "IMAGEDEL";
        else
        {
          if (imagevalue)
            attrib_name = "IMAGECHECK";
          else
            attrib_name = "IMAGEUNCHECK";
        }
      }
    }
    else
    {
      if (imagevalue)
        attrib_name = "IMAGECHECK";
      else
        attrib_name = "IMAGEUNCHECK";
    }

    image_name = iupAttribGetStr(ih, attrib_name);  /* this will check for the default values also */
  }

  image = iupImageGetHandle(image_name);
  if (image)
  {
    int width  = IupGetInt(image, "WIDTH");
    int height = IupGetInt(image, "HEIGHT");

    long bgcolor = cdIupConvertColor(IupGetAttributeId2(ih, "CELLBGCOLOR", lin, col));

    /* Calc the image_name position */
    int x = x2 - x1 - width;
    int y = y1 - y2 - 1 - height;
    x /= 2; x += x1;
    y /= 2; y += y2;

    cdIupDrawImage(cnv, image, x, y, 0, 0, make_inactive, bgcolor);
  }

  return IUP_DEFAULT;  /* draw nothing more */
}
Exemple #27
0
/* Draw the column titles, visible, between col and lastcol, include it. 
   Column titles marked will be draw with the appropriate feedback.
   -> col1 - First column to have its title drawn
   -> col2 - Last column to have its title drawn */
void iupMatrixDrawTitleColumns(Ihandle* ih, int col1, int col2)
{
  int x1, y1, x2, y2, first_col;
  int col, active, alignment, framehighlight;
  long framecolor;
  IFniiiiiiC draw_cb;

  if (!ih->data->lines.dt[0].size)
    return;

  if (ih->data->columns.num_noscroll>1 && col1==1 && col2==ih->data->columns.num_noscroll-1)
  {
    first_col = 0;
    x1 = 0;
  }
  else
  {
    if (col1 > ih->data->columns.last ||
        col2 < ih->data->columns.first)
      return;

    if (col1 < ih->data->columns.first)
      col1 = ih->data->columns.first;
    if (col2 > ih->data->columns.last)
      col2 = ih->data->columns.last;

    first_col = ih->data->columns.first;
    x1 = 0;
    for (col = 0; col< ih->data->columns.num_noscroll; col++)
      x1 += ih->data->columns.dt[col].size;
  }

  /* Start the position of the first column title */
  y1 = 0;
  y2 = ih->data->lines.dt[0].size;

  iupMATRIX_CLIPAREA(ih, x1, ih->data->w-1, y1, y2);
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA);

  /* Find the initial position of the first column */
  if (first_col==ih->data->columns.first)
    x1 -= ih->data->columns.first_offset;
  for(col = first_col; col < col1; col++)
    x1 += ih->data->columns.dt[col].size;

  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  framehighlight = iupAttribGetInt(ih, "FRAMETITLEHIGHLIGHT");
  active = iupdrvIsActive(ih);
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");
  alignment = iMatrixDrawGetAlignmentLin0(ih);

  /* Draw the titles */
  for(col = col1; col <= col2; col++)
  {
    /* If it is an hide column (size = 0), no draw the title */
    if(ih->data->columns.dt[col].size == 0)
      continue;

    x2 = x1 + ih->data->columns.dt[col].size;

    /* If it doesn't have title, the loop just calculate the final position */
    if (ih->data->lines.dt[0].size)
    {
      int sort = 0;
      int marked = iupMatrixColumnIsMarked(ih, col);

      iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, 0, col);

      iMatrixDrawFrameRectTitle(ih, 0, col, x1, x2, y1, y2, framecolor, framehighlight);

      if (iMatrixDrawSortSign(ih, x2, y1, y2, col, active))
        sort = IMAT_DROPBOX_W; /* same space is used by the sort sign */

      iMatrixDrawCellValue(ih, x1, x2-sort, y1, y2, alignment, marked, active, 0, col, draw_cb, framecolor);
    }

    x1 = x2;
  }

  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);
}
Exemple #28
0
char* iupBaseGetActiveAttrib(Ihandle *ih)
{
  return iupStrReturnBoolean (iupdrvIsActive(ih)); 
}
Exemple #29
0
/* Draw the line titles, visible, between lin and lastlin, include it.
   Line titles marked will be draw with the appropriate feedback.
   -> lin1 - First line to have its title drawn
   -> lin2 - Last line to have its title drawn */
void iupMatrixDrawTitleLines(Ihandle* ih, int lin1, int lin2)
{
  int x1, y1, x2, y2, first_lin;
  int lin, alignment, active, framehighlight;
  long framecolor;
  IFniiiiiiC draw_cb;

  if (!ih->data->columns.dt[0].size)
    return;

  if (ih->data->lines.num_noscroll>1 && lin1==1 && lin2==ih->data->lines.num_noscroll-1)
  {
    first_lin = 0;
    y1 = 0;
  }
  else
  {
    if (lin1 > ih->data->lines.last ||
        lin2 < ih->data->lines.first)
      return;

    if (lin1 < ih->data->lines.first)
      lin1 = ih->data->lines.first;
    if (lin2 > ih->data->lines.last)
      lin2 = ih->data->lines.last;

    first_lin = ih->data->lines.first;
    y1 = 0;
    for (lin = 0; lin< ih->data->lines.num_noscroll; lin++)
      y1 += ih->data->lines.dt[lin].size;
  }

  /* Start the position of the line title */
  x1 = 0;
  x2 = ih->data->columns.dt[0].size;

  iupMATRIX_CLIPAREA(ih, x1, x2, y1, ih->data->h-1);
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA);

  /* Find the initial position of the first line */
  if (first_lin == ih->data->lines.first)
    y1 -= ih->data->lines.first_offset;
  for(lin = first_lin; lin < lin1; lin++)
    y1 += ih->data->lines.dt[lin].size;

  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  framehighlight = iupAttribGetInt(ih, "FRAMETITLEHIGHLIGHT");
  active = iupdrvIsActive(ih);
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  alignment = iMatrixDrawGetColAlignment(ih, 0);

  /* Draw the titles */
  for(lin = lin1; lin <= lin2; lin++)
  {
    /* If it is a hidden line (size = 0), don't draw the title */
    if(ih->data->lines.dt[lin].size == 0)
      continue;

    y2 = y1 + ih->data->lines.dt[lin].size;

    /* If it doesn't have title, the loop just calculate the final position */
    if (ih->data->columns.dt[0].size)
    {
      int marked = iupMatrixLineIsMarked(ih, lin);

      iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, lin, 0);

      iMatrixDrawFrameRectTitle(ih, lin, 0, x1, x2, y1, y2, framecolor, framehighlight);

      iMatrixDrawCellValue(ih, x1, x2, y1, y2, alignment, marked, active, lin, 0, draw_cb, framecolor);
    }

    y1 = y2;
  }

  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);
}
Exemple #30
0
/* Redraw a block of cells of the matrix. Handle marked cells, change
   automatically the background color of them.
   - lin1, col1 : cell coordinates that mark the left top corner of the area to be redrawn
   - lin2, col2 : cell coordinates that mark the right bottom corner of the area to be redrawn */
void iupMatrixDrawCells(Ihandle* ih, int lin1, int col1, int lin2, int col2)
{
  int x1, y1, x2, y2, old_x2, old_y1, old_y2;
  int alignment, lin, col, active, first_col, first_lin;
  long framecolor, emptyarea_color = -1;
  IFnii mark_cb;
  IFnii dropcheck_cb;
  IFniiiiiiC draw_cb;

  x2 = ih->data->w-1;
  y2 = ih->data->h-1;

  old_x2 = x2;
  old_y1 = 0;
  old_y2 = y2;

  if (ih->data->lines.num <= 1 ||
      ih->data->columns.num <= 1)
    return;

  if (ih->data->columns.num_noscroll>1 && col1==1 && col2==ih->data->columns.num_noscroll-1)
  {
    first_col = 0;
    x1 = 0;
  }
  else
  {
    if (col1 > ih->data->columns.last ||
        col2 < ih->data->columns.first)
      return;

    if (col1 < ih->data->columns.first)
      col1 = ih->data->columns.first;
    if (col2 > ih->data->columns.last)
      col2 = ih->data->columns.last;

    first_col = ih->data->columns.first;
    x1 = 0;
    for (col = 0; col< ih->data->columns.num_noscroll; col++)
      x1 += ih->data->columns.dt[col].size;
  }

  if (ih->data->lines.num_noscroll>1 && lin1==1 && lin2==ih->data->lines.num_noscroll-1)
  {
    first_lin = 0;
    y1 = 0;
  }
  else
  {
    if (lin1 > ih->data->lines.last ||
        lin2 < ih->data->lines.first)
      return;

    if (lin1 < ih->data->lines.first)
      lin1 = ih->data->lines.first;
    if (lin2 > ih->data->lines.last)
      lin2 = ih->data->lines.last;

    first_lin = ih->data->lines.first;
    y1 = 0;
    for (lin = 0; lin< ih->data->lines.num_noscroll; lin++)
      y1 += ih->data->lines.dt[lin].size;
  }

  iupMATRIX_CLIPAREA(ih, x1, x2, y1, y2);
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);  /* wait for background */

  /* Find the initial position of the first column */
  if (first_col==ih->data->columns.first)
    x1 -= ih->data->columns.first_offset;
  for(col = first_col; col < col1; col++)
    x1 += ih->data->columns.dt[col].size;

  /* Find the initial position of the first line */
  if (first_lin == ih->data->lines.first)
    y1 -= ih->data->lines.first_offset;
  for(lin = first_lin; lin < lin1; lin++)
    y1 += ih->data->lines.dt[lin].size;

  /* Find the final position of the last column */
  x2 = x1;
  for( ; col <= col2; col++)
    x2 += ih->data->columns.dt[col].size;

  /* Find the final position of the last line */
  y2 = y1;
  for( ; lin <= lin2; lin++)
    y2 += ih->data->lines.dt[lin].size;

  if ((col2 == ih->data->columns.num-1) && (old_x2 > x2))
  {
    emptyarea_color = cdIupConvertColor(ih->data->bgcolor_parent);
    cdCanvasForeground(ih->data->cd_canvas, emptyarea_color);

    /* If it was drawn until the last column and remains space in the right of it,
       then delete this area with the the background color. */
    iupMATRIX_BOX(ih, x2, old_x2, old_y1, old_y2);
  }

  if ((lin2 == ih->data->lines.num-1) && (old_y2 > y2))
  {
    if (emptyarea_color == -1)
      emptyarea_color = cdIupConvertColor(ih->data->bgcolor_parent);
    cdCanvasForeground(ih->data->cd_canvas, emptyarea_color);

    /* If it was drawn until the last line visible and remains space below it,
       then delete this area with the the background color. */
    iupMATRIX_BOX(ih, 0, old_x2, y2, old_y2);
  }

  /* after the background */
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA);

  /***** Draw the cell values and frame */
  old_y1 = y1;
  framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR"));
  active = iupdrvIsActive(ih);

  mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB");
  dropcheck_cb = (IFnii)IupGetCallback(ih, "DROPCHECK_CB");
  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");

  for(col = col1; col <= col2; col++)  /* For all the columns in the region */
  {
    if (ih->data->columns.dt[col].size == 0)
      continue;

    alignment = iMatrixDrawGetColAlignment(ih, col);

    x2 = x1 + ih->data->columns.dt[col].size;

    for(lin = lin1; lin <= lin2; lin++)     /* For all lines in the region */
    {
      int drop = 0;
      int marked = 0;

      if (ih->data->lines.dt[lin].size == 0)
        continue;

      y2 = y1 + ih->data->lines.dt[lin].size;

      /* If the cell is marked, then draw it with attenuation color */
      marked = iupMatrixMarkCellGet(ih, lin, col, mark_cb);

      iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, lin, col);

      iMatrixDrawFrameRectCell(ih, lin, col, x1, x2, y1, y2, framecolor);

      if (dropcheck_cb)
      {
        int ret = dropcheck_cb(ih, lin, col);
        if (ret == IUP_DEFAULT)
        {
          drop = IMAT_DROPBOX_W+IMAT_PADDING_W/2;
          iMatrixDrawDropFeedback(ih, x2, y1, y2, active, framecolor);
        }
        else if (ret == IUP_CONTINUE)
        {
          drop = IMAT_TOGGLE_SIZE + IMAT_PADDING_W;
          iMatrixDrawToggle(ih, x2, y1, y2, lin, col, marked, active);
        }
      }
        
      /* draw the cell contents */
      iMatrixDrawCellValue(ih, x1, x2-drop, y1, y2, alignment, marked, active, lin, col, draw_cb, framecolor);

      y1 = y2;
    }

    x1 = x2;
    y1 = old_y1;  /* must reset also y */
  }

  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);
}