Ejemplo n.º 1
0
Pixel GetColor(char *name)
{
  XColor color;
  XWindowAttributes attributes;
  XGetWindowAttributes(dpy,Root,&attributes);
  color.pixel=0;
  if (!XParseColor(dpy,attributes.colormap,name,&color))
    nocolor("parse",name);
  else if(!XAllocColor (dpy,attributes.colormap,&color))
    nocolor("alloc",name);
  return color.pixel;
}
Ejemplo n.º 2
0
/****************************************************************************
 *
 * This routine computes the hilight color from the background color
 *
 ****************************************************************************/
Pixel GetHilite(Pixel background) 
{
  XColor bg_color, white_p;
  XWindowAttributes attributes;
  
  XGetWindowAttributes(dpy,Root,&attributes);
  
  bg_color.pixel = background;
  XQueryColor(dpy,attributes.colormap,&bg_color);

  white_p.pixel = GetColor("white");
  XQueryColor(dpy,attributes.colormap,&white_p);
  
#ifndef min
#define min(a,b) (((a)<(b)) ? (a) : (b))
#define max(a,b) (((a)>(b)) ? (a) : (b))
#endif

  bg_color.red = max((white_p.red/5), bg_color.red);
  bg_color.green = max((white_p.green/5), bg_color.green);
  bg_color.blue = max((white_p.blue/5), bg_color.blue);
  
  bg_color.red = min(white_p.red, (bg_color.red*140)/100);
  bg_color.green = min(white_p.green, (bg_color.green*140)/100);
  bg_color.blue = min(white_p.blue, (bg_color.blue*140)/100);
  
  if(!XAllocColor(dpy,attributes.colormap,&bg_color))
    nocolor("alloc hilight","");
  
  return bg_color.pixel;
}
Ejemplo n.º 3
0
/* convert the XPMIcons to XImage */
void GetXPM(void)
{
  static char **alt_xpm;
  XColor col;
  XWindowAttributes attributes;
  int ret;
  char tempc1[12],tempc2[12],tempc3[12];
  float colr,colg,colb;

  alt_xpm =ONLYSHAPE ? mask_xpm : back_xpm;

  /* for the colormap */
  XGetWindowAttributes(dpy,Root,&attributes);

  /* get user-defined color or validate the default */
  if (!XParseColor (dpy, attributes.colormap, LedColor, &col))
    {
      nocolor("parse",LedColor);
    }
  else
    {
      /* scale down the Xcolor values */
      colr = col.red   / 257;
      colg = col.green / 257;
      colb = col.blue  / 257;
      /* the brightest color */
      sprintf(tempc1, "S c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
      back_xpm[47] = tempc1;

      /* make medium color */
      colr = (colr /100) *89;
      colg = (colg /100) *89;
      colb = (colb /100) *89;
      sprintf(tempc2, "R c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
      back_xpm[46] = tempc2;

      /* make darkest color */
      colr = (colr /100) *89;
      colg = (colg /100) *89;
      colb = (colb /100) *89;
      sprintf(tempc3, "Q c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
      back_xpm[45] = tempc3;
    }

  wmload.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
  ret = XpmCreatePixmapFromData(dpy, Root, alt_xpm, &wmload.pixmap,
				&wmload.mask, &wmload.attributes);
  if(ret != XpmSuccess)
    {fprintf(stderr, "%s\n", ERR_colorcells);exit(1);}

  visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
  ret = XpmCreatePixmapFromData(dpy, Root, back_xpm, &visible.pixmap,
				&visible.mask, &visible.attributes);
  if(ret != XpmSuccess)
    {fprintf(stderr, "%s\n", ERR_colorcells);exit(1);}

}
Ejemplo n.º 4
0
 void VarItemDelegate::drawBar (VarPtr dt, QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const {
   (void)index;
   //  QItemDelegate::drawBackground(painter,option,index);
 
   if (dt!=0) {
     if (dt->getType() != VARTYPE_ID_BOOL && dt->hasValue() && dt->hasMinValue() && dt->hasMaxValue()) {
       painter->save();  
   
       QRectF rect=option.rect;
       double border_x=2.0;
       double width=rect.width()-(border_x*2.0);
       if (width < 0.0) width=0.0;
       rect.setX(rect.x()+border_x);
       rect.setWidth(width);
 
       double range=dt->getMaxValue() - dt->getMinValue();
       double value=dt->getValue()-dt->getMinValue();
       double pos=0.0;
       if (range!=0.0) pos=(value/range)*width;
       if (pos < 0.0) pos=0.0;
       if (pos > width) pos=width;
 
       QRectF bar=rect;
       double height=2;
       bar.setY(bar.y()+(bar.height() - (height + 1)));
       bar.setHeight(height);
       QRectF frame=bar;
       bar.setWidth(pos);
 
       QColor high_c;
       if (option.state & QStyle::State_Selected) {
         high_c=option.palette.color(QPalette::HighlightedText);
       } else {
         high_c=option.palette.color(QPalette::Highlight);
       }
       high_c.setAlpha(96);
       //painter->setPen(QPen(high_c,1));
       //painter->setBrush(Qt::NoBrush);
       painter->setPen(Qt::NoPen);
       painter->setBrush(QBrush(high_c));
       painter->drawRect(frame);
 
       high_c.setAlpha(192);
       QColor nocolor(255,255,255,0) ;
       painter->setPen(Qt::NoPen);
       painter->setBrush(QBrush(high_c));
       painter->drawRect(bar);
 
       painter->restore();
     }
   }
 }
Ejemplo n.º 5
0
/****************************************************************************
 *
 * This routine computes the shadow color from the background color
 *
 ****************************************************************************/
Pixel GetShadow(Pixel background) 
{
  XColor bg_color;
  XWindowAttributes attributes;
  
  XGetWindowAttributes(dpy,Root,&attributes);
  
  bg_color.pixel = background;
  XQueryColor(dpy,attributes.colormap,&bg_color);
  
  bg_color.red = (unsigned short)((bg_color.red*60)/100);
  bg_color.green = (unsigned short)((bg_color.green*60)/100);
  bg_color.blue = (unsigned short)((bg_color.blue*60)/100);
  
  if(!XAllocColor(dpy,attributes.colormap,&bg_color))
    nocolor("alloc shadow","");
  
  return bg_color.pixel;
}
Ejemplo n.º 6
0
/* Konvertiere XPMIcons nach XImage */
void GetXPM(void)
{
  XWindowAttributes attributes;
  int ret;

  /* for the colormap */
  XGetWindowAttributes(dpy,Root,&attributes);


  /* ---------------------------------------------------------------- */

  asclock.attributes.closeness = 40000; /* Allow for "similar" colors */
  asclock.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);

  if (clock_xpm_fn[0])
    ret = XpmReadFileToPixmap(dpy, Root, clock_xpm_fn,
			      &asclock.pixmap, &asclock.mask, &asclock.attributes);
  else 
    ret = XpmCreatePixmapFromData(dpy, Root, clock_xpm, &asclock.pixmap, 
				  &asclock.mask, &asclock.attributes);
 
  if(ret != XpmSuccess)
    {nocolor("create asclock xpm", ERR_colorcells);exit(1);}
  
  /* ---------------------------------------------------------------- */


  visible.attributes.closeness = 40000; /* Allow for "similar" colors */
  visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);

 if (clock_xpm_fn[0])
  ret = XpmReadFileToPixmap(dpy, Root, clock_xpm_fn, &visible.pixmap, 
				&visible.mask, &visible.attributes);
 else
  ret = XpmCreatePixmapFromData(dpy, Root, clock_xpm, &visible.pixmap, 
				&visible.mask, &visible.attributes);
 if(ret != XpmSuccess)
   {nocolor("create visible xpm", ERR_colorcells);exit(1);}


  /* ---------------------------------------------------------------- */

  if (led_visible) {
    led.attributes.closeness = 40000; /* Allow for "similar" colors */
    led.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);

    if(led_xpm_fn[0])
      ret = XpmReadFileToPixmap(dpy, Root, led_xpm_fn, &led.pixmap, 
			        &led.mask, &led.attributes);
    else
      ret = XpmCreatePixmapFromData(dpy, Root, led_xpm, &led.pixmap, 
  				    &led.mask, &led.attributes);
    if(ret != XpmSuccess)
      {nocolor("create led xpm", ERR_colorcells);exit(1);}

    if(led_elem_width==UNDEFINED) led_elem_width = led.attributes.width/15;
    if(led_elem_height==UNDEFINED) led_elem_height = led.attributes.height;
  }
  /* ---------------------------------------------------------------- */

  if (month_visible) 
  {
    month.attributes.closeness = 40000; /* Allow for "similar" colors */
    month.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);

    if( month_xpm_fn[0])
      ret = XpmReadFileToPixmap(dpy, Root, month_xpm_fn,
			        &month.pixmap, &month.mask, &month.attributes);
    else 
      ret = XpmCreatePixmapFromData(dpy, Root, month_xpm, &month.pixmap, 
				  &month.mask, &month.attributes);
    if(ret != XpmSuccess)
      {nocolor("create month xpm", ERR_colorcells);exit(1);}

    if(month_elem_width==UNDEFINED) month_elem_width = month.attributes.width;
    if(month_elem_height==UNDEFINED) month_elem_height = month.attributes.height/12;
  }
  /* ---------------------------------------------------------------- */

  if (day_visible)
  {
    date.attributes.closeness = 40000; /* Allow for "similar" colors */
    date.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);

    if (date_xpm_fn[0]) 
      ret = XpmReadFileToPixmap(dpy, Root, date_xpm_fn, &date.pixmap, 
			        &date.mask, &date.attributes);
    else
      ret = XpmCreatePixmapFromData(dpy, Root, date_xpm, &date.pixmap, 
 				    &date.mask, &date.attributes);
    if(ret != XpmSuccess)
      {nocolor("create date xpm", ERR_colorcells);exit(1);}

    if(day_elem_width==UNDEFINED) day_elem_width = date.attributes.width/10;
    if(day_elem_height==UNDEFINED) day_elem_height = date.attributes.height;
  }
  /* ---------------------------------------------------------------- */

  if (week_visible) 
  { 
    weekday.attributes.closeness = 40000; /* Allow for "similar" colors */
    weekday.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);

    if(weekday_xpm_fn[0]) 
      ret = XpmReadFileToPixmap(dpy, Root, weekday_xpm_fn,
			        &weekday.pixmap, &weekday.mask, &weekday.attributes);
    else
      ret = XpmCreatePixmapFromData(dpy, Root, weekday_xpm, &weekday.pixmap,
				    &weekday.mask, &weekday.attributes);
    if(ret != XpmSuccess)
      {nocolor("create weekday xpm", ERR_colorcells);exit(1);}

    if(week_elem_width==UNDEFINED) week_elem_width = weekday.attributes.width;
    if(week_elem_height==UNDEFINED) week_elem_height = weekday.attributes.height/7;
  }
  /* ---------------------------------------------------------------- */

  if (beats_visible) {

    beats.attributes.closeness = 40000; /* Allow for "similar" colors */
    beats.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions | XpmCloseness);
   
    if(beats_xpm_fn[0])
      ret = XpmReadFileToPixmap(dpy, Root, beats_xpm_fn,
                              &beats.pixmap, &beats.mask, &beats.attributes);
    else
      ret = XpmCreatePixmapFromData(dpy, Root, beats_xpm, &beats.pixmap,
                                    &beats.mask, &beats.attributes);
    if(ret != XpmSuccess)
      {nocolor("create beats xpm", ERR_colorcells);exit(1);}
 
    if(beats_elem_width==UNDEFINED) beats_elem_width = beats.attributes.width/12;
    if(beats_elem_height==UNDEFINED) beats_elem_height = beats.attributes.height;

  }

}