void g2LabelEdit::Render(int pX, int pY)
{
    // Ignore if not null
    if(TextBuffer == NULL)
        return;
    
    // Total offset from the far left
    int OffsetX = 0;
    
    // For each character...
    for(size_t i = ViewIndex; i < strlen(TextBuffer); i++)
    {
        // Get target character and width
        int CharWidth;
        GetTheme()->GetCharacterSize(TextBuffer[i], &CharWidth, NULL);
        
        // Stop drawing if this one or the next character is out of bounds
        if((OffsetX + CharWidth) >= Width)
            break;
        
        // Draw shadow if on
        if(Shadow)
        {
            // Get active color for shadow
            float Sr, Sg, Sb;
            GetColor(&Sr, &Sg, &Sb);
            DrawCharacter(pX + OffsetX + 1, pY + 1, 1.0f, 1.0f, Sr, Sg, Sb, 0.2f, TextBuffer[i]);
        }
        
        // Render text normally
        DrawCharacter(pX + OffsetX, pY, TextBuffer[i]);
        
        // Grow the offset
        OffsetX += CharWidth + g2LabelEdit_CharacterSpacing;
    }
    
    // Draw the blinking cursor
    if(( (GetActive() && !GetDisabled()) || CursorAlwaysVisible ) && CursorState)
    {
        // Reset offset for rendering again
        OffsetX = 0;
        
        // Go through each character attempting to render
        for(size_t i = ViewIndex; i <= strlen(TextBuffer); i++)
        {
            // Draw and stop at the cursor index
            if((int)i == CursorIndex)
            {
                DrawCharacter(pX + OffsetX - 1, pY, '|');
                break;
            }
            
            // Grow offset
            int CharWidth;
            GetTheme()->GetCharacterSize(TextBuffer[i], &CharWidth, NULL);
            OffsetX += CharWidth + g2LabelEdit_CharacterSpacing;
        }
    }
    
    // Done with rendering...
}
Example #2
0
/** Get a scaled icon. */
ScaledIconNode *GetScaledIcon(IconNode *icon, long fg,
                              int rwidth, int rheight)
{

   XColor color;
   XImage *image;
   ScaledIconNode *np;
   GC maskGC;
   int x, y;
   int scalex, scaley;     /* Fixed point. */
   int srcx, srcy;         /* Fixed point. */
   int ratio;              /* Fixed point. */
   int nwidth, nheight;
   unsigned char *data;

   Assert(icon);
   Assert(icon->image);

   if(rwidth == 0) {
      rwidth = icon->image->width;
   }
   if(rheight == 0) {
      rheight = icon->image->height;
   }

   ratio = (icon->image->width << 16) / icon->image->height;
   nwidth = Min(rwidth, (rheight * ratio) >> 16);
   nheight = Min(rheight, (nwidth << 16) / ratio);
   nwidth = (nheight * ratio) >> 16;
   if(nwidth < 1) {
      nwidth = 1;
   }
   if(nheight < 1) {
      nheight = 1;
   }

   /* Check if this size already exists.
    * Note that XRender scales on the fly.
    */
   for(np = icon->nodes; np; np = np->next) {
#ifdef USE_XRENDER
      if(np->imagePicture != None) {
         np->width = nwidth;
         np->height = nheight;
         return np;
      }
#endif
      if(np->width == nwidth && np->height == nheight) {
         if(!icon->image->bitmap || np->fg == fg) {
            return np;
         }
      }
   }

   /* See if we can use XRender to create the icon. */
#ifdef USE_XRENDER
   if(haveRender) {
      np = CreateScaledRenderIcon(icon, fg, nwidth, nheight);

      /* Don't keep the image data around after creating the icon. */
      Release(icon->image->data);
      icon->image->data = NULL;

      return np;
   }
#endif

   /* Create a new ScaledIconNode the old-fashioned way. */
   np = Allocate(sizeof(ScaledIconNode));
   np->fg = fg;
   np->width = nwidth;
   np->height = nheight;
   np->next = icon->nodes;
#ifdef USE_XRENDER
   np->imagePicture = None;
#endif
   icon->nodes = np;

   /* Create a mask. */
   np->mask = JXCreatePixmap(display, rootWindow, nwidth, nheight, 1);
   maskGC = JXCreateGC(display, np->mask, 0, NULL);
   JXSetForeground(display, maskGC, 0);
   JXFillRectangle(display, np->mask, maskGC, 0, 0, nwidth, nheight);
   JXSetForeground(display, maskGC, 1);

   /* Create a temporary XImage for scaling. */
   image = JXCreateImage(display, rootVisual, rootDepth, ZPixmap, 0,
                         NULL, nwidth, nheight, 8, 0);
   image->data = Allocate(sizeof(unsigned long) * nwidth * nheight);

   /* Determine the scale factor. */
   scalex = (icon->image->width << 16) / nwidth;
   scaley = (icon->image->height << 16) / nheight;

   data = icon->image->data;
   srcy = 0;
   for(y = 0; y < nheight; y++) {
      const int yindex = (srcy >> 16) * icon->image->width;
      srcx = 0;
      for(x = 0; x < nwidth; x++) {
         if(icon->image->bitmap) {
            const int index = yindex + (srcx >> 16);
            const int offset = index >> 3;
            const int mask = 1 << (index & 7);
            if(data[offset] & mask) {
               JXDrawPoint(display, np->mask, maskGC, x, y);
               XPutPixel(image, x, y, fg);
            }
         } else {
            const int yindex = (srcy >> 16) * icon->image->width;
            const int index = 4 * (yindex + (srcx >> 16));
            color.red = data[index + 1];
            color.red |= color.red << 8;
            color.green = data[index + 2];
            color.green |= color.green << 8;
            color.blue = data[index + 3];
            color.blue |= color.blue << 8;
            GetColor(&color);
            XPutPixel(image, x, y, color.pixel);
            if(data[index] >= 128) {
               JXDrawPoint(display, np->mask, maskGC, x, y);
            }
         }
         srcx += scalex;
      }
      srcy += scaley;
   }
void ScheduledTransItem::DrawItem(BView *owner, BRect frame, bool complete)
{
	BString string;
	Locale locale = fAccount->GetLocale();
	
	BRect r(frame);
	r.right--;
	
	rgb_color linecolor;
	
	if(IsSelected())
	{
		linecolor.red=120;
		linecolor.green=120;
		linecolor.blue=120;
		owner->SetHighColor(GetColor(BC_SELECTION_FOCUS));
		owner->SetLowColor(GetColor(BC_SELECTION_FOCUS));
		owner->FillRect(frame);
		owner->SetHighColor(linecolor);
		owner->StrokeRect(frame);
		owner->SetHighColor(255,255,255);
	}
	else
	{
		linecolor.red=200;
		linecolor.green=200;
		linecolor.blue=200;
		
		owner->SetHighColor(255, 255, 255);
		owner->SetLowColor(255, 255, 255);
		owner->FillRect(frame);
//		owner->SetHighColor(222, 222, 222);
		owner->SetHighColor(linecolor);
		owner->StrokeLine(r.LeftBottom(),r.RightBottom());
	}
	owner->SetHighColor(0, 0, 0);

	BRect cliprect;
	BRegion clip(cliprect);
	float xpos = TLeftPadding();
	float ypos = r.top + TRowHeight();

	// Date
	cliprect.left = xpos;
	cliprect.right = xpos + TDateWidth();
	cliprect.top = ypos - TRowHeight();
	cliprect.bottom = ypos;
	
	clip = cliprect;
	owner->ConstrainClippingRegion(&clip);
	owner->DrawString(fDate.String(), BPoint(xpos, ypos - 3));
	owner->ConstrainClippingRegion(NULL);
	
	xpos += TDateWidth();
	owner->SetHighColor(linecolor);
	
	//Line Between Date & Type
	owner->StrokeLine(BPoint(xpos, ypos - TRowHeight()), BPoint(xpos, ypos));
	
	owner->StrokeLine(BPoint(0,ypos),BPoint(r.right,ypos));
	owner->SetHighColor(0, 0, 0);
	
	// Type
	owner->SetHighColor(0,0,0);
	owner->DrawString(fType.String(), BPoint(xpos + 5, ypos - 3));

	// Line between Type and Payee
	xpos += TNumWidth();
	owner->SetHighColor(linecolor);
	owner->StrokeLine(BPoint(xpos, ypos - TRowHeight()), BPoint(xpos, ypos));
	
	// Calculate the rectangle for the payee, but this field depends on the
	// width of the view, so we can't yet easily calculate the right coordinate
	// of the rectangle just yet
	BRect payee_rect(xpos, ypos, xpos, ypos - TRowHeight());
	
	
	// Balance
	xpos = r.right - TAmountWidth();
	cliprect.right = r.right;
	cliprect.left = xpos;
	clip = cliprect;
	owner->SetHighColor(0, 0, 0);
	
/*	Fixed balance = fAccount->BalanceAt(fDate);
	if(balance.AsFixed()<0)
		owner->SetHighColor(150, 0, 0);
	locale.CurrencyToString(balance,string);
	owner->DrawString(string.String(), BPoint(xpos + 5, ypos - 3));
*/	
	// Line between Balance and Amount
	owner->SetHighColor(linecolor);
	owner->StrokeLine(BPoint(xpos, ypos - TRowHeight()), BPoint(xpos, ypos));
	
	// Amount
	xpos -= TAmountWidth();
	cliprect.right = cliprect.left;
	cliprect.left = xpos;
	clip = cliprect;
	owner->SetHighColor(0,0,0);
	
	owner->ConstrainClippingRegion(&clip);
	owner->DrawString(fAmount.String(), BPoint(xpos + 5, ypos - 3));
	owner->ConstrainClippingRegion(NULL);
	
	// Line between Amount and Payee
	owner->SetHighColor(linecolor);
	owner->StrokeLine(BPoint(xpos, ypos - TRowHeight()), BPoint(xpos, ypos));
	
	// Payee
	payee_rect.right = xpos;
	payee_rect.top = ypos - TRowHeight();
	payee_rect.bottom = ypos;
	xpos = payee_rect.left;
	
	owner->SetHighColor(0, 0, 0);
	clip = payee_rect;
	owner->ConstrainClippingRegion(&clip);
	owner->DrawString(fPayee.String(), BPoint(xpos + 5, ypos - 3));
	owner->ConstrainClippingRegion(NULL);
	
	owner->SetHighColor(linecolor);
	owner->StrokeLine(BPoint(r.left, ypos), BPoint(r.right, ypos));
	
	// Category
	owner->SetHighColor(0,0,0);
	ypos += TRowHeight();
	xpos = TLeftPadding();
	cliprect.left = TLeftPadding();
	cliprect.right = r.right / 2;
	cliprect.top = cliprect.bottom;
	cliprect.bottom += TRowHeight();
	clip = cliprect;
	owner->ConstrainClippingRegion(&clip);
	owner->DrawString(fCategory.String(), BPoint(xpos, ypos - 3));
	owner->ConstrainClippingRegion(NULL);
	
	xpos = r.right / 2;
	cliprect.left = xpos;
	cliprect.right = r.right;
	
	// Line between Category and Memo
	owner->SetHighColor(linecolor);
	owner->StrokeLine(BPoint(xpos, ypos - TRowHeight()), BPoint(xpos, ypos));
	
	// Memo
	clip = cliprect;
	owner->ConstrainClippingRegion(&clip);
	if(fMemo.CountChars()>0)
	{
		owner->SetHighColor(0,0,0);
		owner->DrawString(fMemo.String(), BPoint(xpos + 5, ypos - 3));
	}
	else
	{
		owner->SetHighColor(linecolor);
		owner->DrawString("No Memo", BPoint(xpos + 5, ypos - 3));
	}
	owner->ConstrainClippingRegion(NULL);
}
Example #4
0
/**
 * @function HeaderDraw
 * @brief List header draw function
 * @param void *_g_obj: pointer to the generic object of the header
 * @param void *_obj: pointer to the specific object of the header
 * @return none
 */
static void HeaderDraw(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  list_header_st *header;
  list_st *list;
  color_t colBack, colLine, colText;
  coord_t x0, x1, y0, y1, xImg, yImg, xTxt, yTxt, xOffset;
  gui_img_t img;
  rect_st lrec;
  category_st *category;

  /*retreive generic & specific object + pointer to the associated list*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    header = (list_header_st *) _obj;
    list = GetList(header->g_obj_list);

    colBack = GetColor(G_COL_BACKGROUND);
    colLine = GetColor(G_COL_LOWER_REC);
    colText = GetColor(G_COL_TEXT);

    /*P2D configuration*/
    P2D_SetDisplayMode(DISPLAY_SOLID);
    P2D_SetLineType(LINE_SOLID);
    SetFont(list->font);

    /*draw header background*/
    P2D_SetColor(colBack);
    (void) P2D_RectToCoord(&(g_obj->rec), &x0, &y0, &x1, &y1);
    x0++; y0++; x1--; y1--;
    (void) P2D_CoordToRect(&lrec, x0, y0, x1, y1);
    P2D_SetColor(colBack);
    P2D_FillRect(&lrec);

    /*display categories*/
    category = list->pCategory;
    P2D_SetColors(colText, colBack);
    xTxt = g_obj->rec.x - list->hScroll.offset;
    yTxt = y0 + ((y1 - y0) - list->hItem) / 2;
    xOffset = list->wSpriteMax + 4;

    while(category != NULL) {
      P2D_PutText(xTxt + xOffset, yTxt, category->name);
      xTxt += category->w;
      xOffset = 0;

      /*current category is the selected one? display the up/down sprite*/
      if(category == list->pSelectedCategory) {

        img = (list->bReversedSort == true)? G_IMG_SORT_DOWN: G_IMG_SORT_UP;
        xImg = xTxt - SpriteGetWidth(img) - 2;
        yImg = y0 + ((y1 - y0) - SpriteGetHeight(img)) / 2;

        Sprite(xImg, yImg, img);
      }

      category = category->next;
    }

    /*draw header rect*/
    P2D_SetColor(colLine);
    P2D_Rect(&(g_obj->rec));
  }
}
Example #5
0
//creer une carte de texture en melangeant les quatres types de textures de base
void TERRAIN::GenerateTextureMap( unsigned int size )
{
  unsigned char Red, Green, Blue;
  unsigned int tempID;
  unsigned int x, z;
  unsigned int  TexX,  TexZ;
  float totalRed, totalGreen, totalBlue;
  float blend[4];
  float mapRatio;
  int lastHeight;
  int i;

  //determiner le nombre de textures de bases presentes
  textures.numTextures= 0;
  for( i=0; i<TRN_NUM_TILES; i++ )
    {
      if( !textures.data[i].isNull( ) )
	textures.numTextures++;
    }

  //determiner les intervalles d'affichage pour chaque type de texture de base
  lastHeight= -1;
  for( i=0; i<TRN_NUM_TILES; i++ )
    {
      if( !textures.data[i].isNull( ) )
	{
	  //on a trois valeurs a determiner: inf, opt,sup
	  textures.region[i].lowHeight=lastHeight+1;
	  lastHeight+= 255/textures.numTextures;
	  textures.region[i].optimalHeight=lastHeight;
	  textures.region[i].highHeight= ( lastHeight-textures.region[i].lowHeight )+lastHeight;
	}
    }

#if QT_VERSION < 0x040000
  myTexture.create( size, size, 32 );
#else
  myTexture = QImage(size, size, QImage::Format_ARGB32);
#endif

  //determiner relation entre resolution de la carte d'hauteur et la res. de la texture
  //.. en general, la texture aura une res. plus elevee
  mapRatio= ( float )sizeHeightMap/ size;

  //creation de texture
  for( z=0; z< size; z++ )
    {
      for( x=0; x< size; x++ )
	{
	  totalRed  = 0.0f;
	  totalGreen= 0.0f;
	  totalBlue = 0.0f;

	  //pour chaque texture de base
	  for( i=0; i<TRN_NUM_TILES; i++ )
	    {
	      if( !textures.data[i].isNull( ) )
		{
		  TexX= x;
		  TexZ= z;

		  //quel pixel de texture a choisir pour cette position sur la carte?
		  GetTexCoords( textures.data[i], &TexX, &TexZ );

		  //quelle est la couleur actuelle a cet endroit?
		  GetColor( textures.data[i], TexX,  TexZ, &Red, &Green, &Blue );

		  //combien de pourcent de cette texture de base faut-il ajouter a cet endroit?
		  //.. on interpole la vraie hauteur pour avoir des textures plus realistes
		  blend[i]= RegionPercent( i, Limit( InterpolateHeight( x, z, mapRatio ) ) );

		  //ajouter ce pourcentage a la couleur
		  totalRed  += Red*blend[i];
		  totalGreen+= Green*blend[i];
		  totalBlue += Blue*blend[i];
		}
	    }

	  //modifier la couleur de la texture a cet endroit, limiter les valeurs a 0..255
	  SetColor( myTexture, x, z, Limit( totalRed ),Limit( totalGreen ),Limit( totalBlue ) );
	}
    }

  //construire la texture
  glGenTextures( 1, &tempID );
  glBindTexture( GL_TEXTURE_2D, tempID );
  //utiliser la moyenne ponderee lineairement pour elargir ou reduire les textures
  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );


  //le plus grand mystere de tout le code: pour une raison completement pourrie, QImage inverse
  //.. les canaux rouge et bleu lors de l'ecriture dans l'image; mais si j'utilise QGLWidget::convertToGLFormat,
  //.. l'image est inversee; la solution swapRGB marche (apres 3h de recherche desesperee) pour une raison mysterieuse
#if QT_VERSION < 0x040000
  myTexture = myTexture.swapRGB();
#else
  myTexture = myTexture.rgbSwapped();
#endif

  //definir la source de donnees pour la texture
  glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, size,  size, 0, GL_RGBA, GL_UNSIGNED_BYTE, myTexture.bits() );

  //associer un no. ID a la texture
  textureColorID =  tempID;

  myTexture.save("texture.bmp","BMP");
}
 virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
 {
   aAttrs = ColorLayerAttributes(GetColor(), GetBounds());
 }
Example #7
0
/**
 * @function EntryDraw
 * @brief user entry draw function
 * @param void *_g_obj: generic object
 * @param void *_obj: frame object
 * @return none
 */
static void EntryDraw(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  usr_entry_st *entry;

  uint8_t glyph;
  uint16_t ii, selStart, selStop;
  coord_t x, xInsertLine, xMin, yMin, xMax, yMax;
  rect_st rec;
  color_t colBack, colText;

  /*retreive generic & specific object*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    entry =  (usr_entry_st*) _obj;

    /*P2D configuration*/
    P2D_SetDisplayMode(DISPLAY_SOLID);
    P2D_SetLineType(LINE_SOLID);
    SetFont(entry->font);

    if(GUI_ObjIsDisabled(g_obj)) {
      colBack = GetColor(G_COL_BACKGROUND);
      colText = GetColor(G_COL_D_TEXT);
    }
    else {
      colBack = GetColor(G_COL_E_BACKGROUND);
      colText = entry->colText;
    }

    /*retrieve text coord*/
    GetTextCoords(&(g_obj->rec), &xMin, &yMin, &xMax, &yMax);

    /*display usr_entry glyphs, one by one*/
    selStart = _MIN(entry->cursStart, entry->cursStop);
    selStop = _MAX(entry->cursStart, entry->cursStop);
    x = xMin;
    xInsertLine = x;
    ii = entry->offsetDisplay;

    while(x < xMax && entry->buffer[ii] != 0) {

      /*select the color of the text, according to the user selection (i.e. reverse colors if the current glyph is a part of the user selection)*/
      if(entry->bEditable == false || selStart == selStop || ii < selStart || ii >= selStop) {
        P2D_SetColors(colText, colBack);
      }
      else {
        P2D_SetColors(colBack, GetColor(G_COL_SPECIAL));
      }

      /*display the glyph*/
      glyph = entry->buffer[ii];
      P2D_PutGlyph(x, yMin, glyph);
      x += P2D_GetGlyphWidth(glyph);

      /*if the car corresponds to the user selection bar, store its coord*/
      if(ii == entry->cursStop - 1) xInsertLine = x;

      /*next car*/
      ii++;
    }

    /*clear from last car to the end of the entry*/
    P2D_SetColors(colBack, colBack);
    (void) P2D_CoordToRect(&rec, x, yMin, xMax, yMax);
    P2D_FillRect(&rec);

    /*clear between text and object rect (1 px width)*/
    (void) P2D_CoordToRect(&rec, xMin-1, yMin-1, xMax+1, yMax+1);
    P2D_Rect(&rec);

    /*display the insert line*/
    if(entry->bEditable && entry->bBlink) {
      P2D_SetColor(colText);
      P2D_Line(xInsertLine, yMin, xInsertLine, yMax);
    }

    /*object rect*/
    P2D_SetColor(GetColor(G_COL_LOWER_REC));
    P2D_Rect(&(g_obj->rec));
  }
}
Example #8
0
void PictTestText::SetTestFontColor(int f_R, int f_G, int f_B)
{
	f_color = GetColor(f_R, f_G, f_B);
}
Example #9
0
void PictTestText::SetTestFontEdgeColor(int fe_R, int fe_G, int fe_B)
{
	f_edge_color = GetColor(fe_R, fe_G, fe_B);
}
Example #10
0
/*******************************************************************************\
|* openXwindow																   *|
\*******************************************************************************/
void openXwindow (int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height)
{

  unsigned int borderwidth = 1;
  XClassHint classHint;
  char *display_name = NULL;
  char *wname = argv[0];
  XTextProperty name;

  XGCValues gcv;
  unsigned long gcm;

  char *geometry = NULL;

  int dummy = 0;
  int i, wx, wy;

  for (i = 1; argv[i]; i++)
    {
      if (!strcmp (argv[i], "-display"))
	{
	  display_name = argv[i + 1];
	  i++;
	}
      if (!strcmp (argv[i], "-geometry"))
	{
	  geometry = argv[i + 1];
	  i++;
	}
      if (!strcmp (argv[i], "-color"))
	{
	  textColor= argv[i + 1];
	  i++;
	}
    }


  if (!(display = XOpenDisplay (display_name)))
  {
    fprintf (stderr, "%s: can't open display %s\n",
	wname, XDisplayName (display_name));
    exit (1);
  }


  screen = DefaultScreen (display);
  Root = RootWindow (display, screen);
  d_depth = DefaultDepth (display, screen);
  x_fd = XConnectionNumber (display);

  /* Convert XPM to XImage */
  GetXPM (&wmgen, pixmap_bytes);

  /* Create a window to hold the stuff */
  mysizehints.flags = USSize | USPosition;
  mysizehints.x = 0;
  mysizehints.y = 0;

  back_pix = GetColor ("white");
  fore_pix = GetColor ("black");

  XWMGeometry (display, screen, Geometry, NULL, borderwidth, &mysizehints,
	       &mysizehints.x, &mysizehints.y, &mysizehints.width, &mysizehints.height, &dummy);

  mysizehints.width = 64;
  mysizehints.height = 64;

  win = XCreateSimpleWindow (display, Root, mysizehints.x, mysizehints.y,
    mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);

  iconwin = XCreateSimpleWindow (display, win, mysizehints.x, mysizehints.y,
    mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);

  /* Activate hints */
  XSetWMNormalHints (display, win, &mysizehints);
  classHint.res_name = wname;
  classHint.res_class = wname;
  XSetClassHint (display, win, &classHint);

  XSelectInput (display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
  XSelectInput (display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);

  if (XStringListToTextProperty (&wname, 1, &name) == 0)
    {
      fprintf (stderr, "%s: can't allocate window name\n", wname);
      exit (1);
    }

  XSetWMName (display, win, &name);

  /* Create GC for drawing */

  gcm = GCForeground | GCBackground | GCGraphicsExposures;
  gcv.foreground = fore_pix;
  gcv.background = back_pix;
  gcv.graphics_exposures = 0;
  NormalGC = XCreateGC (display, Root, gcm, &gcv);

  /* ONLYSHAPE ON */

  pixmask = XCreateBitmapFromData (display, win, pixmask_bits, pixmask_width, pixmask_height);

  XShapeCombineMask (display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
  XShapeCombineMask (display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);

  /* ONLYSHAPE OFF */

  mywmhints.initial_state = WithdrawnState;
  mywmhints.icon_window = iconwin;
  mywmhints.icon_x = mysizehints.x;
  mywmhints.icon_y = mysizehints.y;
  mywmhints.window_group = win;
  mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;

  XSetWMHints (display, win, &mywmhints);

  XSetCommand (display, win, argv, argc);
  XMapWindow (display, win);

  if (geometry)
    {
      if (sscanf (geometry, "+%d+%d", &wx, &wy) != 2)
	{
	  fprintf (stderr, "Bad geometry string.\n");
	  exit (1);
	}
      XMoveWindow (display, win, wx, wy);
    }
}
Example #11
0
void PictTestText::DefPictTestText(int x, int y, TCHAR* text)
{
	f_color = GetColor(255, 255, 255);
	f_edge_color = GetColor(0, 0, 0);
	DrawString(x, y, text, f_color, f_edge_color);
}
Example #12
0
bool nuiLabel::Draw(nuiDrawContext* pContext)
{
//  NGL_OUT(_T("Draw 0x%x\n"), this);
  nuiColor Color = GetTextColor();
  nuiColor ColorBg = GetBackgroundColor();

  CalcLayout();

  pContext->SetFont(mpFont);
  
  if (mIgnoreState)
  {
    if (!mBackColorSet)
      ColorBg = GetColor(eNormalTextBg);
    if (!mTextColorSet)
      Color = GetColor(eNormalTextFg);
  }
  else
  {
    if (IsEnabled())
    {
      if (IsSelected())
      {
        if (!mBackColorSet)
          ColorBg = GetColor(eSelectedTextBg);
        if (!mTextColorSet)
          Color = GetColor(eSelectedTextFg);
      }
      else
      {
        if (!mBackColorSet)
          ColorBg = GetColor(eNormalTextBg);
        if (!mTextColorSet)
          Color = GetColor(eNormalTextFg);
      }
    }
    else
    {
      if (IsSelected())
      {
        if (!mBackColorSet)
          ColorBg = GetColor(eSelectedTextBg);
        if (!mTextColorSet)
          Color = GetColor(eDisabledTextFg);
      }
      else
      {
        if (!mBackColorSet)
          ColorBg = GetColor(eDisabledTextBg);
        if (!mTextColorSet)
          Color = GetColor(eDisabledTextFg);
      }
    }
  }

  nuiGlyphInfo GlyphInfo;
  mpLayout->GetMetrics(GlyphInfo);

  nuiFontInfo info;
  mpFont->GetInfo(info);
  //info.Dump(0);

  float alpha = GetMixedAlpha();
  Color.Multiply(alpha);
  ColorBg.Multiply(alpha);
  
  nuiRect rect = mpLayout->GetRect();

  rect.SetPosition(mTextPosition, mRect.Size());
  //pContext->DrawRect(rect, eStrokeShape);
  
  rect.mTop += (nuiSize)ToNearest(info.Ascender) + mVMargin;
  rect.mLeft +=  mHMargin;

  if (mClearBg)
  {
    if (ColorBg.Alpha() < 1.0)
    {
      pContext->SetBlendFunc(nuiBlendTransp);
      pContext->EnableBlending(true);
    }
    pContext->SetFillColor(ColorBg);   
    pContext->DrawRect(mRect.Size(),eFillShape);
    if (ColorBg.Alpha() < 1.0)
    {
      pContext->SetBlendFunc(nuiBlendSource);
      pContext->EnableBlending(false);
    }
  }

  if (mpLayout)
  {
    /* currently disabled as it doesn't look that good in many cases
    if (GetState() == nuiDisabled && !mIgnoreState)
    {
      nuiColor c = Color;
      c.Red()   *= 2;
      c.Green() *= 2;
      c.Blue()  *= 2;
      pContext->SetTextColor(c);
      pContext->DrawText((nuiSize)ToNearest(rect.mLeft+1), (nuiSize)ToNearest(rect.mTop+1), *mpLayout);
    }
    */
    pContext->SetTextColor(Color);

    pContext->DrawText((nuiSize)ToNearest(rect.mLeft), (nuiSize)ToNearest(rect.mTop), *mpLayout);
  }
  else
  {
//    NGL_OUT(_T("F**K 0x%x!"), this);
  }
  return true;
}
Example #13
0
wxGISSimpleEllipseSymbol* wxGISSimpleEllipseSymbol::Clone() const
{
    return new wxGISSimpleEllipseSymbol(GetColor(), m_pLineSymbol->Clone());
}
void CConfigAppearance::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// Do not call CPropertyPage::OnPaint() for painting messages

	CRect Rect, ParentRect;
	GetWindowRect(ParentRect);

	CWnd *pWnd = GetDlgItem(IDC_COL_PREVIEW);
	pWnd->GetWindowRect(Rect);

	Rect.top -= ParentRect.top;
	Rect.bottom -= ParentRect.top;
	Rect.left -= ParentRect.left;
	Rect.right -= ParentRect.left;

	CBrush BrushColor;
	BrushColor.CreateSolidBrush(m_iColors[m_iSelectedItem]);

	// Solid color box
	CBrush *pOldBrush = dc.SelectObject(&BrushColor);
	dc.Rectangle(Rect);
	dc.SelectObject(pOldBrush);

	// Preview all colors

	pWnd = GetDlgItem(IDC_PREVIEW);
	pWnd->GetWindowRect(Rect);

	Rect.top -= ParentRect.top;
	Rect.bottom -= ParentRect.top;// - 16;
	Rect.left -= ParentRect.left;
	Rect.right -= ParentRect.left;

	int WinHeight = Rect.bottom - Rect.top;

	CFont Font;		// // //
	Font.CreateFontW(-m_iFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET,
		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, m_strFont.data());
	CFont *OldFont = OldFont = dc.SelectObject(&Font);

	// Background
	dc.FillSolidRect(Rect, GetColor(COL_BACKGROUND));
	dc.SetBkMode(TRANSPARENT);

	COLORREF ShadedCol = DIM(GetColor(COL_PATTERN_TEXT), .5);
	COLORREF ShadedHiCol = DIM(GetColor(COL_PATTERN_TEXT_HILITE), .5);

	int iRowSize = m_iFontSize;
	int iRows = (WinHeight - 12) / iRowSize;// 12;

	COLORREF CursorCol = GetColor(COL_CURSOR);
	COLORREF CursorShadedCol = DIM(CursorCol, .5);
	COLORREF BgCol = GetColor(COL_BACKGROUND);
	COLORREF HilightBgCol = GetColor(COL_BACKGROUND_HILITE);
	COLORREF Hilight2BgCol = GetColor(COL_BACKGROUND_HILITE2);

	const auto BAR = [&] (int x, int y) {
		dc.FillSolidRect(x + 3, y + (iRowSize / 2) + 1, 10 - 7, 1, ShadedCol);
	};

	for (int i = 0; i < iRows; ++i) {

		int OffsetTop = Rect.top + (i * iRowSize) + 6;
		int OffsetLeft = Rect.left + 9;

		if (OffsetTop > (Rect.bottom - iRowSize))
			break;

		if ((i & 3) == 0) {
			if ((i & 6) == 0)
				GradientBar(dc, Rect.left, OffsetTop, Rect.right - Rect.left, iRowSize, Hilight2BgCol, BgCol);		// // //
			else
				GradientBar(dc, Rect.left, OffsetTop, Rect.right - Rect.left, iRowSize, HilightBgCol, BgCol);

			if (i == 0) {
				dc.SetTextColor(GetColor(COL_PATTERN_TEXT_HILITE));
				GradientBar(dc, Rect.left + 5, OffsetTop, 40, iRowSize, CursorCol, GetColor(COL_BACKGROUND));
				dc.Draw3dRect(Rect.left + 5, OffsetTop, 40, iRowSize, CursorCol, CursorShadedCol);
			}
			else
				dc.SetTextColor(ShadedHiCol);
		}
		else {
			dc.SetTextColor(ShadedCol);
		}

		if (i == 0) {
			dc.TextOutW(OffsetLeft, OffsetTop - 2, L"C");
			dc.TextOutW(OffsetLeft + 12, OffsetTop - 2, L"-");
			dc.TextOutW(OffsetLeft + 24, OffsetTop - 2, L"4");
		}
		else {
			BAR(OffsetLeft, OffsetTop - 2);
			BAR(OffsetLeft + 12, OffsetTop - 2);
			BAR(OffsetLeft + 24, OffsetTop - 2);
		}

		if ((i & 3) == 0) {
			dc.SetTextColor(ShadedHiCol);
		}
		else {
			dc.SetTextColor(ShadedCol);
		}

		BAR(OffsetLeft + 40, OffsetTop - 2);
		BAR(OffsetLeft + 52, OffsetTop - 2);
		BAR(OffsetLeft + 68, OffsetTop - 2);
		BAR(OffsetLeft + 84, OffsetTop - 2);
		BAR(OffsetLeft + 96, OffsetTop - 2);
		BAR(OffsetLeft + 108, OffsetTop - 2);
	}

	dc.SelectObject(OldFont);
}
Example #15
0
RadioButton::RadioButton(const Color& body_color, const wstr& text):
	Parent(body_color, text) {
	SetBaseColor(GetColor());
}
Example #16
0
	bool PixelPassesThreshold(int32 X, int32 Y) const
	{
		return GetColor(X, Y).A > AlphaThreshold;
	}
Example #17
0
/*
 * DisplayNumericStat:  Display the given numeric type stat from the current group on the
 *   main window.
 */
void DisplayNumericStat(Statistic *s)
{
   RECT r;
   HDC hdc;
   HFONT hOldFont;
   char *name, *str;
   AREA stats_area;
   AREA a;

	//	ajw - Avoid drawing if Inventory is selected as the "group".
	if( StatsGetCurrentGroup() == STATS_INVENTORY )
		return;
	
   StatsGetArea(&stats_area);

   r.left   = 0;
   r.right  = stats_area.cx / 2;
   r.top    = s->y;
   r.bottom = r.top + s->cy;

   /* If stat is out of stats area, abort */
   if (r.bottom > stats_area.cy || s->num <= top_stat)
      return;

   hdc = GetDC(hStats);
//   DrawWindowBackground(hdc, &r, stats_area.x + r.left, stats_area.y + r.top);
   DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 );

   hOldFont = (HFONT) SelectObject(hdc, GetFont(FONT_STATS));

   SetBkMode(hdc, TRANSPARENT);

   name = LookupNameRsc(s->name_res);

   // Draw with drop shadow
   SetTextColor(hdc, GetColor(COLOR_STATSBGD));
   DrawText(hdc, name, strlen(name), &r, DT_LEFT);
   OffsetRect(&r, 1, 1);
   SetTextColor(hdc, GetColor(COLOR_STATSFGD));
   DrawText(hdc, name, strlen(name), &r, DT_LEFT);

   switch (s->numeric.tag)
   {
   case STAT_RES:
      r.left  = stats_area.cx / 2;
      r.right = stats_area.cx;
      DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 );

      str = LookupNameRsc(s->numeric.value);
      DrawText(hdc, str, strlen(str), &r, DT_RIGHT);
      break;

   case STAT_INT:
      // Draw background around stat bar
     a.x = stats_area.cx / 2;
     a.cx = stats_bar_width;
     a.y = s->y + (s->cy - STATS_BAR_HEIGHT) / 2;
     a.cy = STATS_BAR_HEIGHT;
     InterfaceDrawBarBorder( pinventory_bkgnd(), hdc, &a );
     break;
   }

   SelectObject(hdc, hOldFont);
   ReleaseDC(hStats, hdc);

   InvalidateRect( s->hControl, NULL, FALSE );
}
Example #18
0
void NTextInput::Draw(NCamera* View)
{
    GenerateBuffers();
    if (Texture == NULL || GetColor().w == 0)
    {
        return;
    }
    if (Shader == NULL)
    {
        glEnableClientState(GL_VERTEX_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
        glVertexPointer(2,GL_FLOAT,0,NULL);

        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
        glTexCoordPointer(2,GL_FLOAT,0,NULL);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        if (Texture != NULL)
        {
            glBindTexture(GL_TEXTURE_2D,Texture->GetID());
        }

        glMatrixMode(GL_PROJECTION);
        glLoadMatrixf(&View->GetOrthoMatrix()[0][0]);
        glMatrixMode(GL_MODELVIEW);
        glm::mat4 MVP = View->GetViewMatrix()*GetModelMatrix();
        glLoadMatrixf(&MVP[0][0]);

        glColor4fv(&(GetColor()[0]));
        glDrawArrays(GL_QUADS,0,Verts.size());
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_BLEND);

        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        return;
    }
    glUseProgram(Shader->GetID());
    glActiveTexture(GL_TEXTURE0);
    if (Texture != NULL)
    {
        glBindTexture(GL_TEXTURE_2D,Texture->GetID());
    }
    glUniform1i(TextureLoc,0);
    glm::mat4 MVP = View->GetOrthoMatrix()*View->GetViewMatrix()*GetModelMatrix();
    glUniformMatrix4fv(MatrixLoc,1,GL_FALSE,&MVP[0][0]);
    glUniform4fv(ColorLoc,1,&(GetColor()[0]));
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
    glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,NULL);
    glEnableVertexAttribArray(1);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
    glVertexAttribPointer(1,2,GL_FLOAT,GL_FALSE,0,NULL);
    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    glDrawArrays(GL_QUADS,0,Verts.size());
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glUseProgram(0);
}
/**
 * @function RotValDraw
 * @brief rotary value draw function
 * @param void *_g_obj: generic object
 * @param void *_obj: rot val object
 * @return none
 */
static void RotValDraw(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  rot_val_st *rval;
  rect_st lrec;
  color_t colBack, colLine, colText, colSetText;
  uint8_t digitId, len, glyph, str[MAX_VAL_STR];
  bool bNeg;

  /*retrieve generic & specific object*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    rval = (rot_val_st*) _obj;

    /*color selection*/
    if(GUI_ObjIsDisabled(g_obj)) {
      colBack = GetColor(G_COL_BACKGROUND);
      colLine = GetColor(G_COL_LOWER_REC);
      colText = GetColor(G_COL_D_TEXT);
      colSetText = rval->colorText;
    }
    else if(GUI_ObjIsPressed(g_obj)) {
      colBack = GetColor(G_COL_E_BACKGROUND);
      colLine = GetColor(G_COL_LOWER_REC);
      colText = rval->colorText;
      colSetText = GetColor(G_COL_SPECIAL);
    }
    else {
      colBack = GetColor(G_COL_E_BACKGROUND);
      colLine = GetColor(G_COL_LOWER_REC);
      colText = rval->colorText;
      if(rval->lock != 0) colSetText = rval->colorText;
      else colSetText = GetColor(G_COL_SPECIAL);
    }

    /*P2D configuration*/
    P2D_SetDisplayMode(DISPLAY_SOLID);
    P2D_SetLineType(LINE_SOLID);
    SetFont(rval->font);
    P2D_SetColors(colBack, colBack);

    /*background*/
    lrec = g_obj->rec;
    lrec.x += 1; lrec.y += 1;
    lrec.w -= 2; lrec.h -= 2;
    P2D_FillRect(&lrec);

    /*display the value's unit string*/
    P2D_SetColor(colText);
    lrec.y = g_obj->rec.y + ((coord_t)g_obj->rec.h - P2D_GetTextHeight()) / 2;
    P2D_PutText(rval->xUnit, lrec.y, rval->strUnit);

    /*format value*/
    (void) snprintf( (char *)str, MAX_VAL_STR, "%d", *(rval->pVar));
    len = gstrlen(str);
    bNeg = *(rval->pVar) < 0 ? true : false;

    /*display each digit, one by one, from right to left*/
    for(digitId = 0; IsValidDigit(rval, digitId) == true; digitId++) {

      /*get the x coord of the current digit*/
      lrec.x = GetDigitCoord(rval, digitId);

      /*special color + highlighted if the current digit is the selected one*/
      if(digitId == rval->selectedDigit && rval->lock == false) {
        P2D_SetColor(colSetText);
        lrec.h = P2D_GetTextHeight();
        lrec.w = rval->wCar;
        P2D_FillRect(&lrec);
        P2D_SetColors(colBack, colSetText);
      }
      else {
        P2D_SetColors(colText, colBack);
      }

      /*display the snprintf content, excepting the '-'*/
      if(digitId < len) {
        glyph = str[len - digitId - 1];
        if(glyph == (uint8_t)'-') glyph = (uint8_t)'0'; /*will be displayed at end*/
      }
      /*for small value (i.e. digitId >= strlen), fill with '0'*/
      else {
        glyph = (uint8_t)'0';
      }

      P2D_PutGlyph(lrec.x, lrec.y, glyph);
    }

    /*display the sign, only if negative*/
    if(bNeg) {
      P2D_SetColors(colText, colBack);
      lrec.x = GetDigitCoord(rval, digitId);
      P2D_PutGlyph(lrec.x, lrec.y, (uint8_t)'-');
    }

    /*display the dot, if any*/
    if(rval->posDot > 0) {
      P2D_SetColor(colText);
      lrec.x = GetDigitCoord(rval, rval->posDot - 1) - rval->spacing;
      P2D_SetColors(colText, colBack);
      P2D_PutGlyph(lrec.x, lrec.y, (uint8_t) '.');
    }

    /*rect*/
    P2D_SetColor(colLine);
    P2D_Rect(&(g_obj->rec));
  }
}
Example #20
0
void msgDumpReset(){
	static int BLACK = GetColor(0, 0, 0);
	_dumpCoordinateY = 20;
	graresource.drawbox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
}
Example #21
0
/**
 * @function GUI_W_ListCreate
 * @brief add list container
 * @param const rect_st *rec: list dimension
 * @param bool bHeader: if true, categories will be displayed (*rec will be shared between list & its header)
 * @param scroll_param_st **pvScroll: if non null, will recieve the addr of the internal vertical scroll struct
 * @param scroll_param_st **phScroll: if non null, will recieve the addr of the internal horizontal scroll struct
 * @return g_obj_st *: pointer to the associated generic object if succedeed, NULL if error.
 */
g_obj_st /*@null@*/ *GUI_W_ListCreate(const rect_st *rec, bool bHeader, scroll_param_st /*@null@*/ **pvScroll, scroll_param_st /*@null@*/ **phScroll) {

  g_obj_st *g_obj = NULL, *g_obj_header = NULL, *res = NULL;
  list_st *list = NULL;
  list_header_st *header = NULL;
  length_t hItem = P2D_GetTextHeight();
  rect_st lrec;

  /*create the generic object for the list's header; configure it later*/
  if(bHeader) {
    g_obj_header = GUI_AddGenericObject();
    if(g_obj_header != NULL) {
      header = (list_header_st *) salloc(sizeof(list_header_st));
    }
  }

  /*check parameters*/
  if(rec != NULL && rec->w >= LIST_W_MIN && hItem > 0 && rec->h >= hItem * LIST_H_MIN && (header != NULL || bHeader == false)) {

    /*allocate a generic object*/
    g_obj = GUI_AddGenericObject();
    if(g_obj != NULL) {

      /*allocate and init the list*/
      list = (list_st *) salloc(sizeof(list_st));
      if(list != NULL) {

        /* *rec may be shared between list & its header*/
        lrec = *rec;
        if(bHeader) {
          lrec.y += hItem + 2;
          lrec.h -= hItem + 2;
        }

        /*ensures that all internal links are NULL & var = 0*/
        gmemset( (void *) list, 0, sizeof(list_st));

        /*init. the list*/
        list->font = GetCurrentFont();
        list->hItem = hItem;
        list->colBackOdd = GetColor(G_COL_E_BACKGROUND);
        list->colBackEven = P2D_Alpha_a_on_b(GetColor(G_COL_SPECIAL), list->colBackOdd, 32);
        list->vScroll.wndSize = lrec.h / hItem;
        list->hScroll.wndSize = lrec.w;
        list->g_obj_header = g_obj_header;

        /*return scroller addresses*/
        if(pvScroll != NULL) *pvScroll = &(list->vScroll);
        if(phScroll != NULL) *phScroll = &(list->hScroll);

        /*linkage between generic obj & list*/
        g_obj->rec = lrec;
        g_obj->draw = ListDraw;
        g_obj->task = ListRefresh;
        g_obj->obj = list;
        GUI_ObjSetStatic(g_obj, true);  /*list_st handle refresh event itself*/

        /*header linkage, if any*/
        if(header != NULL) {
          lrec.y = rec->y;
          lrec.h = hItem + 2;
          header->xt = -1;
          header->g_obj_list = g_obj;
          g_obj_header->rec = lrec;
          g_obj_header->draw = HeaderDraw;
          g_obj_header->task = HeaderRefresh;
          g_obj_header->obj = header;
          GUI_ObjSetStatic(g_obj, true);  /*header handles refresh event itself*/
        }

        res = g_obj;
      }
    }
  }

  return res;
}
Example #22
0
int main(int argc,char *argv[])
{
  int i;
  unsigned int borderwidth ;
  char *display_name = NULL;
  char *wname = "wmload";
  XGCValues gcv;
  unsigned long gcm;
  XEvent Event;
  XTextProperty name;
  XClassHint classHint;
  Pixmap pixmask;
  Atom _XA_WM_DELETE_WINDOW 	= None;
  Geometry = "";
  mywmhints.initial_state = NormalState;

  /* Parse command line options */
  ProgName = argv[0];

  for(i=1;i<argc;i++) {
    char *arg= argv[i];

    if (arg[0] == '-') {
      switch(arg[1]) {
      case 'u':
	if(++i >=argc) usage();
	sscanf(argv[i], "%d", &updatespeed);
	continue;
      case 'e':
	if(++i >=argc) usage();
	strcpy(&Execute[0], argv[i]);
	strcat(&Execute[0], " &");
	continue;
      case 's':
	ONLYSHAPE=1;
	continue;
      case 'p':
	if(++i >=argc) usage();
	Geometry = argv[i];
	continue;
      case 'i':
	mywmhints.initial_state = IconicState;
	continue;
      case 'w':
	mywmhints.initial_state = WithdrawnState;
	continue;
      case 'l':
	if(++i >=argc) usage();
	LedColor = argv[i];
	continue;
      case 'v':
	fprintf(stdout, "\nwmload version: %i.%i.%i\n", major_VER, minor_VER, patch_VER);
	if(argc == 2) exit(0);
	continue;
      default:
	usage();
      }
    }
    else
      {
        fprintf(stderr, "\nInvalid argument: %s\n", arg);
        usage();
      }
  }

  /* Open the display */
  if (!(dpy = XOpenDisplay(display_name)))
    {
      fprintf(stderr,"wmload: can't open display %s\n",
	      XDisplayName(display_name));
      exit (1);
    }

  screen= DefaultScreen(dpy);
  Root = RootWindow(dpy, screen);
  d_depth = DefaultDepth(dpy, screen);
  x_fd = XConnectionNumber(dpy);
  _XA_WM_DELETE_WINDOW = XInternAtom (dpy, "WM_DELETE_WINDOW", False);

  /* Convert XPM Data to XImage */
  GetXPM();

  /* Create a window to hold the banner */
  mysizehints.flags= USSize|USPosition;
  mysizehints.x = 0;
  mysizehints.y = 0;

  back_pix = GetColor("white");
  fore_pix = GetColor("black");

  XWMGeometry(dpy, screen, Geometry, NULL, (borderwidth =1), &mysizehints,
	      &mysizehints.x,&mysizehints.y,&mysizehints.width,&mysizehints.height, &i);

  mysizehints.width = wmload.attributes.width;
  mysizehints.height= wmload.attributes.height;

  win = XCreateSimpleWindow(dpy,Root,mysizehints.x,mysizehints.y,
			    mysizehints.width,mysizehints.height,
			    borderwidth,fore_pix,back_pix);
  iconwin = XCreateSimpleWindow(dpy,win,mysizehints.x,mysizehints.y,
				mysizehints.width,mysizehints.height,
				borderwidth,fore_pix,back_pix);

  /* activate hints */
  XSetWMNormalHints(dpy, win, &mysizehints);
  classHint.res_name =  "wmload";
  classHint.res_class = "WMLoad";
  XSetClassHint(dpy, win, &classHint);

  XSelectInput(dpy,win,MW_EVENTS);
  XSelectInput(dpy,iconwin,MW_EVENTS);
  XSetCommand(dpy,win,argv,argc);

  if (XStringListToTextProperty(&wname, 1, &name) ==0) {
    fprintf(stderr, "wmload: can't allocate window name\n");
    exit(-1);
  }
  XSetWMName(dpy, win, &name);

  /* Create a GC for drawing */
  gcm = GCForeground|GCBackground|GCGraphicsExposures;
  gcv.foreground = fore_pix;
  gcv.background = back_pix;
  gcv.graphics_exposures = FALSE;
  NormalGC = XCreateGC(dpy, Root, gcm, &gcv);

  if (ONLYSHAPE) { /* try to make shaped window here */
    pixmask = XCreateBitmapFromData(dpy, win, (char *)mask2_bits, mask2_width,
				    mask2_height);
    XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
    XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
  }

  mywmhints.icon_window = iconwin;
  mywmhints.icon_x = mysizehints.x;
  mywmhints.icon_y = mysizehints.y;
  mywmhints.window_group = win;
  mywmhints.flags = StateHint | IconWindowHint | IconPositionHint
      | WindowGroupHint;
  XSetWMHints(dpy, win, &mywmhints);
  XSetWMProtocols (dpy, win, &_XA_WM_DELETE_WINDOW, 1);

  XMapWindow(dpy,win);
  InitLoad();
  InsertLoad();
  RedrawWindow(&visible);
  while(1)
    {
      if (actualtime != time(0))
	{
	  actualtime = time(0);

	  if(actualtime % updatespeed == 0)
	    InsertLoad();

	  RedrawWindow(&visible);
	}

      /* read a packet */
      while (XPending(dpy))
	{
	  XNextEvent(dpy,&Event);
	  switch(Event.type)
	    {
	    case Expose:
	      if(Event.xexpose.count == 0 )
		RedrawWindow(&visible);
	      break;
	    case ButtonPress:
	      ExecuteExternal();
	      break;
	    case ClientMessage:
    	      if ((Event.xclient.format != 32) ||
		  ((Atom)Event.xclient.data.l[0] != _XA_WM_DELETE_WINDOW))
		break;
	    case DestroyNotify:
	      XFreeGC(dpy, NormalGC);
	      XDestroyWindow(dpy, iconwin);
              XDestroyWindow(dpy, win);
              XCloseDisplay(dpy);
	      exit(0);
	      break ;
	    default:
	      break;
	    }
	}
      XFlush(dpy);
#ifdef SYSV
      poll((struct poll *) 0, (size_t) 0, 50);
#else
      {
        struct timespec ts;

        ts.tv_sec = 0;
        ts.tv_nsec = 50000000L;        /* 5/100 sec */
        nanosleep(&ts, NULL);
      }
#endif
    }
  return 0;
}
Example #23
0
int c_player::Process(){
	control->UpdateKeyInput();
	board->Draw();
	board->DrawPuyo();
	board->DrawScoreBoard(this->score);

	switch(mode){
	case 0:
		DrawString(10,360,"Press SPACE key to start.",GetColor(255,255,255));
		DrawString(10,380,"Change Colors <- -> Key.",GetColor(255,255,255));
		DrawFormatString(10,400,GetColor(255,255,255),"Colors:%d",colors);

		//change colors much
		if(control->GetStateKey(KEY_INPUT_LEFT) == 1) colors--;
		if(control->GetStateKey(KEY_INPUT_RIGHT) == 1)colors++;
		if(colors < 2) colors = 2;
		if(colors > 5) colors = 5;

		if(control->GetStateKey(KEY_INPUT_SPACE) == 1){
			GameInit();
			loop_count = 0;
			mode = 1;
			DelMode = 0;
		}
		break;
	case 1:
		board->DrawNextPuyo(next_puyo);

		if(DelMode == 0){
			DropControl();
			board->DrawDropPuyo(next_x,next_y,n_drop);
		}else if(DelMode == 1){
			int rr = 0;
			if(r_del > 0)DrawFormatString(250,300,GetColor(255,255,255),"%d Chains!",r_del);
			if( loop_count % 20 == 0 ){
				if(board->DownPuyo() == 0){
					int ma = 0;
					rr = board->DeletePuyo(&ma);
					if(rr > 0)r_del++;

					score += sqrt(pow(SCORE_MULTIPLIER,r_del) * sqrt(pow((SCORE_MULTIPLIER * ma),rr) * colors));

					if(rr == 0){
						if(board->CheckGameOver() != 0) mode = 2;
						else{
							DelMode = 0;
							r_del = 0;
							SetNext();
						}
					}
				}
			}
		}
		loop_count++;
		break;
	case 2:
		board->DrawGameOver();
		if(control->GetStateKey(KEY_INPUT_SPACE) == 1)
			board->Init(),mode = 0,score = 0;
		break;
	}

	if(control->GetStateKey(KEY_INPUT_ESCAPE) == 1) return 1;
	return 0;
}
Example #24
0
float JSpriteProbe::GetAlpha() const
{
    ColorF color( GetColor() );
    return color.a;
}
Example #25
0
	int getClr()const{return GetColor(r,g,b);}
Example #26
0
void Render::SetAlpha(DWORD alpha) {
    SetColor((alpha << 24) | (GetColor() & 0xFFFFFF));
}
void ButtonControl::OnPaint(DibBitmap *pbm)
{
	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	bool fSelected = m_pfrm->IsControlInside(this);
	if (m_ptbmDown != NULL && m_ptbmUp != NULL) {
		// Draw up / down image (if present)

		TBitmap *ptbm;
		if (m_wf & kfCtlDisabled)
			ptbm = m_ptbmDisabled;
		else
			ptbm = fSelected ? m_ptbmDown : m_ptbmUp;

		ptbm->BltTo(pbm, m_rc.left + rcForm.left, m_rc.top + rcForm.top, m_wf & kfCtlUseSide1Colors ? kside1 : ksideNeutral);

		// Center the text (if present)

		if (m_szLabel[0] != 0) {
			Font *pfnt = gapfnt[m_nfnt];
			int cx = pfnt->GetTextExtent(m_szLabel);
			int cy = pfnt->GetHeight();
			int x = m_rc.left + (m_rc.Width() - cx + 1) / 2;
			int y = m_rc.top + (m_rc.Height() - cy + gcxyBorder) / 2;
			if (fSelected) {
				x++;
				y++;
			}
			gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top);
		}
	} else {
#if 0 // old-style filled-rect buttons
		Rect rcT = m_rc;
		rcT.Offset(rcForm.left, rcForm.top);

		int cxyBorder2x = gcxyBorder * 2;
		pbm->Fill(rcT.left + gcxyBorder, rcT.top + gcxyBorder, rcT.Width() - cxyBorder2x, rcT.Height() - cxyBorder2x, GetColor(fSelected ? kiclrButtonFillHighlight : kiclrButtonFill));

		int iclr = GetColor(fSelected ? kiclrWhite : kiclrButtonBorder);
		pbm->Fill(rcT.left + gcxyBorder, rcT.top, rcT.Width() - cxyBorder2x, gcxyBorder, iclr);
		pbm->Fill(rcT.left, rcT.top + gcxyBorder, gcxyBorder, rcT.Height() - cxyBorder2x, iclr);
		pbm->Fill(rcT.right - gcxyBorder, rcT.top + gcxyBorder, gcxyBorder, rcT.Height() - cxyBorder2x, iclr);
		pbm->Fill(rcT.left + gcxyBorder, rcT.bottom - gcxyBorder, rcT.Width() - cxyBorder2x, gcxyBorder, iclr);

		if (m_szLabel[0] != 0) {
			Font *pfnt = gapfnt[m_nfnt];
			int cx = pfnt->GetTextExtent(m_szLabel);
			int cy = pfnt->GetHeight();
			int x = m_rc.left + (m_rc.Width() - cx + 1) / 2;
			int y = m_rc.top + (m_rc.Height() - cy + gcxyBorder) / 2;
			gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top);
		}
#else
		Rect rcT = m_rc;
		rcT.Offset(rcForm.left, rcForm.top);

		TBitmap *ptbmLeft, *ptbmMid, *ptbmRight;
		if (!fSelected) {
			ptbmLeft = s_ptbmLeftUp;
			ptbmMid = s_ptbmMidUp;
			ptbmRight = s_ptbmRightUp;
		} else {
			ptbmLeft = s_ptbmLeftDown;
			ptbmMid = s_ptbmMidDown;
			ptbmRight = s_ptbmRightDown;
		}

		Size sizLeft, sizMid, sizRight;
		ptbmLeft->GetSize(&sizLeft);
		ptbmMid->GetSize(&sizMid);
		ptbmRight->GetSize(&sizRight);

		int x = rcT.left;
		int xRight = rcT.right - sizRight.cx;

		ptbmLeft->BltTo(pbm, x, rcT.top);
		x += sizLeft.cx;
#if 0
		while (x < xRight) {
			ptbmMid->BltTo(pbm, x, rcT.top);
			x += sizMid.cx;
		}
#else
		ptbmMid->FillTo(0, pbm, x, rcT.top, xRight - x, rcT.Height());
		x = xRight;
#endif

		ptbmRight->BltTo(pbm, xRight, rcT.top);

		if (m_szLabel[0] != 0) {
			Font *pfnt = gapfnt[m_nfnt];
			int cx = pfnt->GetTextExtent(m_szLabel);
			int cy = pfnt->GetHeight();
			int x = m_rc.left + (m_rc.Width() - cx + 1) / 2;
			int y = m_rc.top + ((sizMid.cy - gapfnt[m_nfnt]->GetHeight() + 1) / 2);
			gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top);
		}
#endif
	}
}
Example #28
0
void CHandDrawEffect::DrawEdge(IplImage* image, IplImage* image2, IplImage* base, int plane)
{
	CvSeq* contourSeq0 = NULL;

	int height    = image->height;
	int width     = image->width;
	int step      = image->widthStep;
	int channels  = image->nChannels;
	uchar* data   = (uchar*)image->imageData;

	if(plane < 3) {
		cvCvtColor(image, hsv, CV_BGR2HSV);				// HSVのplaneを線画生成の元にする
		for(int i = 0; i < height * width; i++)
			grayImage->imageData[i] = hsv->imageData[i * 3 + plane];
	} else {
		cvCvtColor(image, grayImage, CV_BGR2GRAY);		// グレーイメージを作り線画生成の元にする
	}

	IplImage* target = base;					// 書き込むターゲットイメージ

	for(int x = 20; x < 240; x += Y) {
		cvThreshold(grayImage, binaryImage, x, 255, CV_THRESH_BINARY);	// x の値を境に2値化し輪郭を抽出
		contourSeq0 = 0;
		cvFindContours(binaryImage, memStorage0, &contourSeq0, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_NONE, cvPoint(0, 0)); // 輪郭線探索

		if(lineNoise > 0) { // 不連続ラインの場合
			for(; contourSeq0 != 0; contourSeq0 = contourSeq0->h_next) {
				CvPoint *p;
				if(contourSeq0->total< X * 5) continue;		// 5角形以下の細かいのは排除

				int index = 0;
				for(int i = 0; i < contourSeq0->total; i += X) {
					p = CV_GET_SEQ_ELEM(CvPoint, contourSeq0, i);				// 点の場所と色を登録
					CvScalar color = GetColor(image2, p->x, p->y);
					MulScaler(color, DARK);										// 輝度を修正
					color.val[3] = CheckPoint(image, p->x, p->y, lineNoise);	// 有効点かどうかを近接ピクセルから判断して[3]へ格納
					SetPoint(index, p, color);									// pointTableへ保存
					index++;
					if(index > MAX_POINT) {
					//	printf("INDEX ERROR\n"); 
						index = 0;
					}
				}
				// 5連続以下の有効点は無効 (Pending:高速化)
				for(int i = 0; i < index; i++) {
					int p1 = i;
					int p2, p3, p4, p0;
					if(pointTable[p1].color.val[3]) {
						p2 = (p1 + 1) % index;
						p3 = (p1 + 2) % index;
						p4 = (p1 + 3) % index;
						p0 = (p1 - 1 + index) % index;
						if(pointTable[p0].color.val[3]) continue;
						if(!pointTable[p2].color.val[3] ||
							!pointTable[p3].color.val[3] ||
							!pointTable[p4].color.val[3]) {						
							pointTable[p1].color.val[3] = 0;
						}
					}
				}
				// 接続された有効点を描く
				for(int i = 0; i < index; i++) {
					int p1 = i;
					int p2 = (i + 1) % index;	// if (p2==index) p2 = 0;
					if(pointTable[p1].color.val[3] && pointTable[p2].color.val[3]) {
						CvScalar c = pointTable[p1].color;
						MulScaler(c, DARK);
						cvLine(target, pointTable[p1].p, pointTable[p2].p, c, lineWidth, CV_AA);
					}
				}
			}
		} else {
			// 全部描く場合
			for(; contourSeq0 != 0; contourSeq0 = contourSeq0->h_next) {

				CvPoint *p1 = 0;
				CvPoint *p2;

				if(contourSeq0->total < X * 5) continue;		

				for(int i = 0; i < contourSeq0->total; i += X) {
					p1 = CV_GET_SEQ_ELEM(CvPoint, contourSeq0, (i) % contourSeq0->total);//始点
					p2 = CV_GET_SEQ_ELEM(CvPoint, contourSeq0, (i + X + Z) % contourSeq0->total);// 終点
					CvScalar color = GetColor(image, p1->x, p1->y);
					MulScaler(color, DARK);
					cvLine(target, *p1, *p2, color, lineWidth, CV_AA);
				}
			}
		}
	}
	cvClearMemStorage(memStorage0);
}
Example #29
0
void KeyValues::UnpackIntoStructure(KeyValuesUnpackStructure const *pUnpackTable, void *pDest)
{
	uint8 *dest = (uint8 *) pDest;

	while (pUnpackTable->m_pKeyName)
	{
		uint8 *dest_field = dest + pUnpackTable->m_nFieldOffset;
		KeyValues *find_it = FindKey(pUnpackTable->m_pKeyName);

		switch (pUnpackTable->m_eDataType)
		{
			case UNPACK_TYPE_FLOAT:
			{
				float default_value = (pUnpackTable->m_pKeyDefault) ? atof(pUnpackTable->m_pKeyDefault) : 0.0;
				*((float *) dest_field) = GetFloat(pUnpackTable->m_pKeyName, default_value);
				break;
			}

			case UNPACK_TYPE_VECTOR:
			{
				float *dest_v = (float *)dest_field;
				char const *src_string = GetString(pUnpackTable->m_pKeyName, pUnpackTable->m_pKeyDefault);

				if ((!src_string) || (sscanf(src_string, "%f %f %f", &(dest_v[0]), &(dest_v[1]), &(dest_v[2])) != 3))
					memset(dest_v, 0, 3 * sizeof(float));

				break;
			}

			case UNPACK_TYPE_FOUR_FLOATS:
			{
				float *dest_f = (float *)dest_field;
				char const *src_string = GetString(pUnpackTable->m_pKeyName, pUnpackTable->m_pKeyDefault);

				if ((!src_string) || (sscanf(src_string, "%f %f %f %f", dest_f, dest_f + 1, dest_f + 2, dest_f + 3)) != 4)
					memset(dest_f, 0, 4 * sizeof(float));

				break;
			}

			case UNPACK_TYPE_TWO_FLOATS:
			{
				float *dest_f = (float *)dest_field;
				char const *src_string = GetString(pUnpackTable->m_pKeyName, pUnpackTable->m_pKeyDefault);

				if ((!src_string) || (sscanf(src_string,"%f %f", dest_f, dest_f + 1)) != 2)
					memset(dest_f, 0, 2 * sizeof(float));

				break;
			}

			case UNPACK_TYPE_STRING:
			{
				char *dest_s = (char *)dest_field;
				strncpy(dest_s, GetString(pUnpackTable->m_pKeyName, pUnpackTable->m_pKeyDefault), pUnpackTable->m_nFieldSize);
				break;
			}

			case UNPACK_TYPE_INT:
			{
				int *dest_i = (int *)dest_field;
				int default_int = 0;

				if (pUnpackTable->m_pKeyDefault)
					default_int = atoi(pUnpackTable->m_pKeyDefault);

				*(dest_i) = GetInt(pUnpackTable->m_pKeyName, default_int);
				break;
			}

			case UNPACK_TYPE_VECTOR_COLOR:
			{
				float *dest_v = (float *)dest_field;

				if (find_it)
				{
					Color c = GetColor(pUnpackTable->m_pKeyName);
					dest_v[0] = c.r();
					dest_v[1] = c.g();
					dest_v[2] = c.b();
				}
				else
				{
					if (pUnpackTable->m_pKeyDefault)
						sscanf(pUnpackTable->m_pKeyDefault, "%f %f %f", &(dest_v[0]), &(dest_v[1]), &(dest_v[2]));
					else
						memset(dest_v, 0, 3 * sizeof(float));
				}

				*(dest_v) *= (1.0 / 255);
			}
		}

		pUnpackTable++;
	}
}
Example #30
0
int	main( int argc, char *argv[] )
{
	Display					*w_dis;
	Window					w_win;
	XSetWindowAttributes	w_att;
	GC						w_gc;
	XEvent					w_eve;
	XPoint					p1[10], p2[10];
	XSegment				s1[10], s2[10];
	XArc					arc1[10], arc2[10];
	XRectangle				rect1[10], rect2[10];
	char					w_title[]		= "kt-draw";
	char					w_icon_title[]	= "ICON!";
	int						i;

	w_dis = XOpenDisplay( NULL );
	w_win = XCreateSimpleWindow( w_dis, RootWindow( w_dis, 0 ),20 ,20 ,
				500, 400, 2, 0, 1);

	XSetStandardProperties( w_dis, w_win, w_title, w_icon_title,
		None, argv, argc, NULL );

	w_att.override_redirect = True;
	XChangeWindowAttributes( w_dis, w_win, CWOverrideRedirect, &w_att );

    XSelectInput( w_dis, w_win, ExposureMask ); 
    XMapWindow( w_dis, w_win ); 

    do{ 
        XNextEvent( w_dis, &w_eve); 
    }while( w_eve.type != Expose ); 

	w_gc = XCreateGC( w_dis, w_win, 0, 0 );
    XSetForeground( w_dis, w_gc, GetColor( w_dis, "green" ));

// sample start
	XDrawLine( w_dis, w_win, w_gc, 50, 100, 450, 100 );
	XDrawLine( w_dis, w_win, w_gc, 50, 100+50, 450, 100+50 );

	for( i = 0; i < 10; i++ ) {
		s1[i].x1 = (i * 5) + 250;
		s1[i].y1 = 110;
		s1[i].x2 = (i * 5) + 250;
		s1[i].y2 = 130;
	}
	XDrawSegments( w_dis, w_win, w_gc, s1, 10 );
	
	for( i = 0; i < 10; i++ ) {
		s2[i].x1 = 310;
		s2[i].y1 = (i * 4) + 110;
		s2[i].x2 = 350;
		s2[i].y2 = (i * 4) + 110;
	}
	XDrawSegments( w_dis, w_win, w_gc, s2, 10 );
	
	for( i = 0; i < 10; i++ ) {
		p1[i].x = (i * 5) + 280;
		if (i==0 || i==2 || i==4 || i==6 || i==8 ) {
			p1[i].y = (i * 5) + 200;
		}
		else {
			p1[i].y = (i * (-5)) + 200;
		}
	}
	XDrawLines( w_dis, w_win, w_gc, p1, 10, CoordModeOrigin );

	p2[0].x = 340;
	p2[0].y = 200;
	for( i = 1; i < 10; i++ ) {
		p2[i].x = 5;
				if (i==0 || i==2 || i==4 || i==6 || i==8 ) {
			p2[i].y = i * 5;
		}
		else {
			p2[i].y = i * (-5);
		}
	}
	XDrawLines( w_dis, w_win, w_gc, p2, 10, CoordModePrevious );

	XDrawPoint( w_dis, w_win, w_gc, 55, 105 );
	XDrawPoint( w_dis, w_win, w_gc, 55+10, 105+10 );

	for( i = 0; i < 10; i++ ) {
		p1[i].x = (i * 5) + 100;
		p1[i].y = 300;
	}
	XDrawPoints( w_dis, w_win, w_gc, p1, 10, CoordModeOrigin );

	p2[0].x = 100;
	p2[0].y = 310;
	for( i = 1; i < 10; i++ ) {
		p2[i].x = 5;
		p2[i].y = 0;
	}
	XDrawPoints( w_dis, w_win, w_gc, p2, 10, CoordModePrevious );

	XDrawArc( w_dis, w_win, w_gc, 50, 50, 50, 50, 45*64, 135*64 );
	XDrawArc( w_dis, w_win, w_gc, 50+100, 50, 50, 50, (45+30)*64, (135+30)*64 );

	for( i = 0; i < 10; i++ ) {
		arc1[i].x = (i * 15) + 250;
		arc1[i].y = 50;
		arc1[i].width = 10;
		arc1[i].height = 10;
		arc1[i].angle1 = 0;
		arc1[i].angle2 = ((i + 1) * 36) * 64;
	}
	XDrawArcs( w_dis, w_win, w_gc, arc1, 10 );
	
	for( i = 0; i < 10; i++ ) {
		arc2[i].x = (i * 15) + 250;
		arc2[i].y = 50 + 15;
		arc2[i].width = 10;
		arc2[i].height = 10;
		arc2[i].angle1 = 0;
		arc2[i].angle2 = ((10 - i) * 36) * 64;
	}
	XDrawArcs( w_dis, w_win, w_gc, arc2, 10 );
	
	XFillArc( w_dis, w_win, w_gc, 100, 50, 50, 50, 45*64, 135*64 );
	XFillArc( w_dis, w_win, w_gc, 100+100, 50, 50, 50, (45+30)*64, (135+30)*64 );

	for( i = 0; i < 10; i++ ) {
		arc1[i].x = (i * 15) + 250;
		arc1[i].y = 50 + 25;
		arc1[i].width = 10;
		arc1[i].height = 10;
		arc1[i].angle1 = 0;
		arc1[i].angle2 = ((i + 1) * 36) * 64;
	}
	XFillArcs( w_dis, w_win, w_gc, arc1, 10 );
	
	for( i = 0; i < 10; i++ ) {
		arc2[i].x = (i * 15) + 250;
		arc2[i].y = 50 + 37;
		arc2[i].width = 10;
		arc2[i].height = 10;
		arc2[i].angle1 = 0;
		arc2[i].angle2 = ((10 - i) * 36) * 64;
	}
	XFillArcs( w_dis, w_win, w_gc, arc2, 10 );

	XDrawRectangle( w_dis, w_win, w_gc, 60, 110, 160, 210 );
	XDrawRectangle( w_dis, w_win, w_gc, 60+30, 110+30, 160, 210 );

	for( i = 0; i < 10; i++ ) {
		rect1[i].x = (i * 15) + 280;
		rect1[i].y = 300;
		rect1[i].width = 10;
		rect1[i].height = 10;
	}
	XDrawRectangles( w_dis, w_win, w_gc, rect1, 10 );

	for( i = 0; i < 10; i++ ) {
		rect2[i].x = (i * 15) + 280;
		rect2[i].y = 300 + 20;
		rect2[i].width = 10;
		rect2[i].height = 10;
	}
	XDrawRectangles( w_dis, w_win, w_gc, rect2, 10 );

	XFillRectangle( w_dis, w_win, w_gc, 70, 120, 100, 100 );
	XFillRectangle( w_dis, w_win, w_gc, 70+100, 120+100, 100, 100 );

	for( i = 0; i < 10; i++ ) {
		rect1[i].x = (i * 15) + 280;
		rect1[i].y = 300 + 40;
		rect1[i].width = 10;
		rect1[i].height = 10;
	}
	XFillRectangles( w_dis, w_win, w_gc, rect1, 10 );

	for( i = 0; i < 10; i++ ) {
		rect2[i].x = (i * 15) + 280;
		rect2[i].y = 300 + 60;
		rect2[i].width = 10;
		rect2[i].height = 10;
	}
	XFillRectangles( w_dis, w_win, w_gc, rect2, 10 );

// sample end

	XFlush( w_dis );

    printf( "Push return key." );
	getchar( );

	XDestroyWindow( w_dis , w_win );
	XCloseDisplay( w_dis );

	return( 0 );
}