Ejemplo n.º 1
0
static int motButtonSetBgColorAttrib(Ihandle* ih, const char* value)
{
  if (iupAttribGet(ih, "IMPRESS") || iupAttribGetBoolean(ih, "FLAT"))
  {
    /* ignore given value, must use only from parent */
    value = iupBaseNativeParentGetBgColor(ih);

    if (iupdrvBaseSetBgColorAttrib(ih, value))
      return 1;
  }

  return iupdrvBaseSetBgColorAttrib(ih, value);
}
Ejemplo n.º 2
0
static int gtkDialogSetBackgroundAttrib(Ihandle* ih, const char* value)
{
  if (iupdrvBaseSetBgColorAttrib(ih, value))
  {
    GtkStyle *style = gtk_widget_get_style(ih->handle);
    if (style->bg_pixmap[GTK_STATE_NORMAL])
    {
      style = gtk_style_copy(style);
      style->bg_pixmap[GTK_STATE_NORMAL] = NULL;
      gtk_widget_set_style(ih->handle, style);
    }
    return 1;
  }
  else
  {
    GdkPixbuf* pixbuf = iupImageGetImage(value, ih, 0);
    if (pixbuf)
    {
      GdkPixmap* pixmap;
      GtkStyle *style;

      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 255);

      style = gtk_style_copy(gtk_widget_get_style(ih->handle));
      style->bg_pixmap[GTK_STATE_NORMAL] = pixmap;
      gtk_widget_set_style(ih->handle, style);

      return 1;
    }
  }

  return 0;
}
Ejemplo n.º 3
0
static int motTextSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (sb_win)
  {
    Pixel color;

    /* ignore given value for the scrollbars, must use only from parent */
    char* parent_value = iupBaseNativeParentGetBgColor(ih);

    color = iupmotColorGetPixelStr(parent_value);
    if (color != (Pixel)-1)
    {
      Widget sb = NULL;

      iupmotSetBgColor(sb_win, color);

      XtVaGetValues(sb_win, XmNverticalScrollBar, &sb, NULL);
      if (sb) iupmotSetBgColor(sb, color);

      XtVaGetValues(sb_win, XmNhorizontalScrollBar, &sb, NULL);
      if (sb) iupmotSetBgColor(sb, color);
    }
  }

  return iupdrvBaseSetBgColorAttrib(ih, value);   /* use given value for contents */
}
Ejemplo n.º 4
0
static int motCanvasSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Pixel color;

  /* ignore given value, must use only from parent for the scrollbars */
  char* parent_value = iupBaseNativeParentGetBgColor(ih);

  color = iupmotColorGetPixelStr(parent_value);
  if (color != (Pixel)-1)
  {
    Widget sb;
    Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");

    iupmotSetBgColor(sb_win, color);

    sb = (Widget)iupAttribGet(ih, "_IUPMOT_SBVERT");
    if (sb) iupmotSetBgColor(sb, color);

    sb = (Widget)iupAttribGet(ih, "_IUPMOT_SBHORIZ");
    if (sb) iupmotSetBgColor(sb, color);
  }

  if (!IupGetCallback(ih, "ACTION")) 
    iupdrvBaseSetBgColorAttrib(ih, value);  /* Use the given value only here */
  else
  {
    XSetWindowAttributes attrs;
    attrs.background_pixmap = None;
    XChangeWindowAttributes(iupmot_display, XtWindow(ih->handle), CWBackPixmap, &attrs);
    iupAttribSet(ih, "_IUPMOT_NO_BGCOLOR", "1");
  }

  return 1;
}
Ejemplo n.º 5
0
static int motToggleSetBgColorAttrib(Ihandle* ih, const char* value)
{
    if (ih->data->type == IUP_TOGGLE_TEXT)
    {
        char* parent_value = iupAttribGetInheritNativeParent(ih, "BGCOLOR");
        if (!parent_value)
        {
            /* if not defined at a native parent,
               then change the toggle button color to the given color instead using the default */
            if (iupdrvBaseSetBgColorAttrib(ih, value))  /* let XmChangeColor do its job */
            {
                parent_value = IupGetGlobal("DLGBGCOLOR");
                XtVaSetValues(ih->handle, XmNbackground, iupmotColorGetPixelStr(parent_value), NULL);  /* reset just the background */

                if (ih->data->is_radio)
                    XtVaSetValues(ih->handle, XmNselectColor, iupmotColorGetPixel(0, 0, 0), NULL);
                XtVaSetValues(ih->handle, XmNunselectColor, iupmotColorGetPixelStr(value), NULL);
                return 1;
            }
        }
        else
        {
            /* ignore given value, must use only from parent */
            if (iupdrvBaseSetBgColorAttrib(ih, parent_value))
            {
                if (ih->data->is_radio)
                    XtVaSetValues(ih->handle, XmNselectColor, iupmotColorGetPixel(0, 0, 0), NULL);
                XtVaSetValues(ih->handle, XmNunselectColor, iupmotColorGetPixelStr(parent_value), NULL);
                return 1;
            }
        }
        return 0;
    }
    else
    {
        if (ih->data->flat)
        {
            /* ignore given value, must use only from parent */
            value = iupBaseNativeParentGetBgColor(ih);

            if (iupdrvBaseSetBgColorAttrib(ih, value))
                return 1;
        }

        return iupdrvBaseSetBgColorAttrib(ih, value);
    }
}
Ejemplo n.º 6
0
static int motLabelSetBgColorAttrib(Ihandle* ih, const char* value)
{
  /* ignore given value, must use only from parent */
  value = iupBaseNativeParentGetBgColor(ih);

  if (iupdrvBaseSetBgColorAttrib(ih, value))
    return 1;
  return 0; 
}
Ejemplo n.º 7
0
static int gtkListSetBgColorAttrib(Ihandle* ih, const char* value)
{
  unsigned char r, g, b;

  GtkScrolledWindow* scrolled_window = (GtkScrolledWindow*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (scrolled_window && !ih->data->is_dropdown)
  {
    /* ignore given value, must use only from parent for the scrollbars */
    char* parent_value = iupBaseNativeParentGetBgColor(ih);

    if (iupStrToRGB(parent_value, &r, &g, &b))
    {
      GtkWidget* sb;

      if (!GTK_IS_SCROLLED_WINDOW(scrolled_window))
        scrolled_window = (GtkScrolledWindow*)iupAttribGet(ih, "_IUPGTK_SCROLLED_WINDOW");

      iupgtkBaseSetBgColor((GtkWidget*)scrolled_window, r, g, b);

#if GTK_CHECK_VERSION(2, 8, 0)
      sb = gtk_scrolled_window_get_hscrollbar(scrolled_window);
      if (sb) iupgtkBaseSetBgColor(sb, r, g, b);

      sb = gtk_scrolled_window_get_vscrollbar(scrolled_window);
      if (sb) iupgtkBaseSetBgColor(sb, r, g, b);
#endif
    }
  }

  if (!iupStrToRGB(value, &r, &g, &b))
    return 0;

  if (ih->data->has_editbox)
  {
    GtkWidget* entry = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_ENTRY");
    iupgtkBaseSetBgColor(entry, r, g, b);
  }

  {
    GtkCellRenderer* renderer = (GtkCellRenderer*)iupAttribGet(ih, "_IUPGTK_RENDERER");
    GdkColor color = {0L,0,0,0};

    color.red = iupCOLOR8TO16(r);
    color.green = iupCOLOR8TO16(g);
    color.blue = iupCOLOR8TO16(b);

    if (renderer)
      g_object_set(G_OBJECT(renderer), "cell-background-gdk", &color, NULL);
  }

  return iupdrvBaseSetBgColorAttrib(ih, value);
}
Ejemplo n.º 8
0
static int motToggleSetBackgroundAttrib(Ihandle* ih, const char* value)
{
    if (ih->data->type == IUP_TOGGLE_TEXT)
    {
        Pixel color;

        /* ignore given value, must use only from parent */
        value = iupAttribGetInheritNativeParent(ih, "BACKGROUND");

        color = iupmotColorGetPixelStr(value);
        if (color != (Pixel)-1)
        {
            XtVaSetValues(ih->handle, XmNbackground, color, NULL);
            return 1;
        }
        else
        {
            Pixmap pixmap = (Pixmap)iupImageGetImage(value, ih, 0);
            if (pixmap)
            {
                XtVaSetValues(ih->handle, XmNbackgroundPixmap, pixmap, NULL);
                return 1;
            }
        }
    }
    else
    {
        if (ih->data->flat)
        {
            /* ignore given value, must use only from parent */
            value = iupAttribGetInheritNativeParent(ih, "BACKGROUND");

            if (iupdrvBaseSetBgColorAttrib(ih, value))
                return 1;
            else
            {
                Pixmap pixmap = (Pixmap)iupImageGetImage(value, ih, 0);
                if (pixmap)
                {
                    XtVaSetValues(ih->handle, XmNbackgroundPixmap, pixmap, NULL);
                    return 1;
                }
            }
        }
    }
    return 0;
}
Ejemplo n.º 9
0
static int gtkButtonSetBgColorAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->type == IUP_BUTTON_TEXT)
  {
    GtkWidget* frame = gtk_button_get_image(GTK_BUTTON(ih->handle));
    if (frame && GTK_IS_FRAME(frame))
    {
      unsigned char r, g, b;
      if (!iupStrToRGB(value, &r, &g, &b))
        return 0;

      iupgtkSetBgColor(gtk_bin_get_child(GTK_BIN(frame)), r, g, b);
      return 1;
    }
  }

  return iupdrvBaseSetBgColorAttrib(ih, value);
}
Ejemplo n.º 10
0
static int motLabelSetBackgroundAttrib(Ihandle* ih, const char* value)
{
  /* ignore given value, must use only from parent */
  value = iupAttribGetInheritNativeParent(ih, "BACKGROUND");

  if (iupdrvBaseSetBgColorAttrib(ih, value))
    return 1;
  else
  {
    Pixmap pixmap = (Pixmap)iupImageGetImage(value, ih, 0);
    if (pixmap)
    {
      XtVaSetValues(ih->handle, XmNbackgroundPixmap, pixmap, NULL);
      return 1;
    }
  }
  return 0; 
}
Ejemplo n.º 11
0
static int motValSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Pixel color;
  unsigned char r, g, b;
  if (!iupStrToRGB(value, &r, &g, &b))
    return 0;

  r = (r*8)/10;
  g = (g*8)/10;
  b = (b*8)/10;

  color = iupmotColorGetPixel(r, g, b);
  if (color != (Pixel)-1)
  {
    Widget w = XtNameToWidget(ih->handle, "*Scrollbar");
    XtVaSetValues(w, XmNtroughColor, color, NULL);
  }

  return iupdrvBaseSetBgColorAttrib(ih, value);
}
Ejemplo n.º 12
0
static int gtkCanvasSetBgColorAttrib(Ihandle* ih, const char* value)
{
  GtkWidget* sb_win = (GtkWidget*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  unsigned char r, g, b;

  /* ignore given value, must use only from parent for the scrollbars */
  char* parent_value = iupBaseNativeParentGetBgColor(ih);

  if (iupStrToRGB(parent_value, &r, &g, &b))
  {
    GtkWidget* sb;

    iupgtkSetBgColor(sb_win, r, g, b);

    sb = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_SBHORIZ");
    if (sb) iupgtkSetBgColor(sb, r, g, b);
    sb = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_SBVERT");
    if (sb) iupgtkSetBgColor(sb, r, g, b);
  }

  if (!IupGetCallback(ih, "ACTION")) 
  {
    /* enable automatic double buffering */
    gtk_widget_set_double_buffered(ih->handle, TRUE);
    gtk_widget_set_double_buffered(sb_win, TRUE);
    return iupdrvBaseSetBgColorAttrib(ih, value);
  }
  else
  {
    /* disable automatic double buffering */
    gtk_widget_set_double_buffered(ih->handle, FALSE);
    gtk_widget_set_double_buffered(sb_win, FALSE);
#if !GTK_CHECK_VERSION(3, 0, 0)
    gdk_window_set_back_pixmap(iupgtkGetWindow(ih->handle), NULL, FALSE);
#endif
    iupAttribSetStr(ih, "_IUPGTK_NO_BGCOLOR", "1");
    return 1;
  }
}
Ejemplo n.º 13
0
static int gtkCanvasSetBgColorAttrib(Ihandle* ih, const char* value)
{
  GtkScrolledWindow* scrolled_window = gtkCanvasGetScrolledWindow(ih);
  unsigned char r, g, b;

  /* ignore given value, must use only from parent for the scrollbars */
  char* parent_value = iupBaseNativeParentGetBgColor(ih);

  if (iupStrToRGB(parent_value, &r, &g, &b))
  {
    GtkWidget* sb;

    iupgtkBaseSetBgColor((GtkWidget*)scrolled_window, r, g, b);

#if GTK_CHECK_VERSION(2, 8, 0)
    sb = gtk_scrolled_window_get_hscrollbar(scrolled_window);
    if (sb) iupgtkBaseSetBgColor(sb, r, g, b);
    sb = gtk_scrolled_window_get_vscrollbar(scrolled_window);
    if (sb) iupgtkBaseSetBgColor(sb, r, g, b);
#endif
  }

  if (!IupGetCallback(ih, "ACTION")) 
  {
    /* enable automatic double buffering */
    gtk_widget_set_double_buffered(ih->handle, TRUE);
    gtk_widget_set_double_buffered((GtkWidget*)scrolled_window, TRUE);
    return iupdrvBaseSetBgColorAttrib(ih, value);
  }
  else
  {
    /* disable automatic double buffering */
    gtk_widget_set_double_buffered(ih->handle, FALSE);
    gtk_widget_set_double_buffered((GtkWidget*)scrolled_window, FALSE);
    gdk_window_set_back_pixmap(iupgtkGetWindow(ih->handle), NULL, FALSE);
    iupAttribSetStr(ih, "_IUPGTK_NO_BGCOLOR", "1");
    return 1;
  }
}
Ejemplo n.º 14
0
static int gtkDialogSetBackgroundAttrib(Ihandle* ih, const char* value)
{
  if (iupdrvBaseSetBgColorAttrib(ih, value))
  {
#if GTK_CHECK_VERSION(3, 0, 0)
    GdkWindow* window = iupgtkGetWindow(ih->handle);
    if (window)
      gdk_window_set_background_pattern(window, NULL);
#else
    GtkStyle *style = gtk_widget_get_style(ih->handle);
    if (style->bg_pixmap[GTK_STATE_NORMAL])
    {
      style = gtk_style_copy(style);
      style->bg_pixmap[GTK_STATE_NORMAL] = NULL;
      gtk_widget_set_style(ih->handle, style);
    }
#endif
    return 1;
  }
  else
  {
    GdkPixbuf* pixbuf = iupImageGetImage(value, ih, 0);
    if (pixbuf)
    {
#if GTK_CHECK_VERSION(3, 0, 0)
    GdkWindow* window = iupgtkGetWindow(ih->handle);
    if (window)
    {
      /* TODO: this is NOT working!!!! */
      cairo_pattern_t* pattern;
      int width = gdk_pixbuf_get_width(pixbuf);
      int height = gdk_pixbuf_get_height(pixbuf);

      cairo_surface_t* surface = gdk_window_create_similar_surface(window, CAIRO_CONTENT_COLOR_ALPHA, width, height);
      cairo_t* cr = cairo_create(surface);
      gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
      cairo_paint(cr);
      cairo_destroy(cr);

      pattern = cairo_pattern_create_for_surface(surface);
      cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);

      gdk_window_set_background_pattern(window, pattern);
      cairo_pattern_destroy (pattern);

      cairo_surface_destroy(surface);
    }
#else
      GdkPixmap* pixmap;
      GtkStyle *style = gtk_style_copy(gtk_widget_get_style(ih->handle));

      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 255);

      style->bg_pixmap[GTK_STATE_NORMAL] = pixmap;
      gtk_widget_set_style(ih->handle, style);
#endif

      return 1;
    }
  }

  return 0;
}
Ejemplo n.º 15
0
static int motListSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (sb_win)
  {
    Pixel color;

    /* ignore given value for the scrollbars, must use only from parent */
    char* parent_value = iupBaseNativeParentGetBgColor(ih);

    color = iupmotColorGetPixelStr(parent_value);
    if (color != (Pixel)-1)
    {
      Widget sb = NULL;

      iupmotSetBgColor(sb_win, color);

      XtVaGetValues(sb_win, XmNverticalScrollBar, &sb, NULL);
      if (sb) iupmotSetBgColor(sb, color);

      XtVaGetValues(sb_win, XmNhorizontalScrollBar, &sb, NULL);
      if (sb) iupmotSetBgColor(sb, color);
    }

    return iupdrvBaseSetBgColorAttrib(ih, value);    /* use given value for contents */
  }
  else
  {
    char* parent_value;

    /* use given value for Edit and List also */
    Pixel color = iupmotColorGetPixelStr(value);
    if (color != (Pixel)-1)
    {
      Widget cbedit, cblist, sb;

      iupmotSetBgColor(ih->handle, color);

      XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
      if (cbedit) iupmotSetBgColor(cbedit, color);

      XtVaGetValues(ih->handle, XmNlist, &cblist, NULL);
      if (cblist) iupmotSetBgColor(cblist, color);

      XtVaGetValues(cblist, XmNverticalScrollBar, &sb, NULL);
      if (sb) iupmotSetBgColor(sb, color);

      XtVaGetValues(cblist, XmNhorizontalScrollBar, &sb, NULL);
      if (sb) iupmotSetBgColor(sb, color);
    }

    /* but reset just the background, so the combobox will look like a button */
    parent_value = iupBaseNativeParentGetBgColor(ih);

    color = iupmotColorGetPixelStr(parent_value);
    if (color != (Pixel)-1)
      XtVaSetValues(ih->handle, XmNbackground, color, NULL);

    return 1;
  }
}