Example #1
0
static int motFrameSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Pixel color;

  if (!iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR"))
  {
    /* ignore given value, must use only from parent */
    value = iupBaseNativeParentGetBgColor(ih);
  }

  color = iupmotColorGetPixelStr(value);
  if (color != (Pixel)-1)
  {
    Widget child_manager = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMECONTAINER");

    if (!iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR"))
    {
      Widget title_label;

      iupmotSetBgColor(ih->handle, color);
      iupmotSetBgColor(child_manager, color);

      title_label = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMELABEL");
      if (title_label) 
        iupmotSetBgColor(title_label, color);
    }
    else
      iupmotSetBgColor(child_manager, color);

    return 1;
  }
  return 0; 
}
Example #2
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 */
}
Example #3
0
static int gtkFrameSetBgColorAttrib(Ihandle* ih, const char* value)
{
  unsigned char r, g, b;
  GtkWidget* widget = gtk_frame_get_label_widget((GtkFrame*)ih->handle);

  if (!iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR"))
  {
    /* ignore given value, must use only from parent */
    value = iupBaseNativeParentGetBgColor(ih);
  }

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

  if (widget)
    iupgtkSetBgColor(widget, r, g, b);

  widget = gtk_bin_get_child((GtkBin*)ih->handle);
  iupgtkSetBgColor(widget, r, g, b);

  if (iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR"))
    return 1;  /* save on the hash table */
  else
    return 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;
}
Example #5
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; 
}
Example #6
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);
}
Example #7
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);
}
Example #8
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);
    }
}
Example #9
0
static int motTabsSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Pixel color;

  /* given value is used only for child, to the Tabs must use only from parent */
  char* parent_value = iupBaseNativeParentGetBgColor(ih);

  color = iupmotColorGetPixelStr(parent_value);
  if (color != (Pixel)-1)
  {
    iupmotSetBgColor(ih->handle, color);
    motTabsUpdatePageBgColor(ih, color);
  }

  color = iupmotColorGetPixelStr(value);
  if (color != (Pixel)-1)
    motTabsUpdateButtonsBgColor(ih, color);

  return 1; 
}
Example #10
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;
  }
}
Example #11
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;
  }
}
Example #12
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;
  }
}