Пример #1
0
/*********************************************************
 *                          draw                         *
 *********************************************************/
void Menu::draw(int pos)
{
   Font fnt;
   Options opt;
   fnt.defineFont(opt.getDefaultFont(), 10);
   fnt.defineFontAlign(Font::ALIGN_LEFT);
   fnt.defineFontStyle(Font::STYLE_NORMAL);

   /* Define Coordinates */
   int x1 = x;
   int x2 = x1 + (maxCharac)*(fnt.getIncCP()+1)+4; 
   int y1 = y;
   int y2 = (((int)list.size()-numPictures) * ITEM_HEIGHT) + 
                                         y1 + 5; /* bizarre from DOS version */
   
   /* Verify Sides */
   if(x2 > wWidth-1)
   {
      x1 = (wWidth-1) - (x2 - x1);
      x2 = wWidth-1;
      x = x1;
   }
   if(y2 > wHeight-1)
   {
      y1 = (wHeight-1) - (y2 - y1);
      y2 = wHeight-1;
      y = y1;
   }

   /* Draw the Menu */
   color_Set(colors.colorMenu.R, colors.colorMenu.G,
             colors.colorMenu.B, colors.colorMenu.A);
   rectangle_Fill(wSurface,x1+1,y1+1,x2-1,y2-1);
   color_Set(colors.colorCont[2].R, colors.colorCont[2].G,
             colors.colorCont[2].B, colors.colorCont[2].A);
   rectangle_Oval(wSurface,x1,y1,x2,y2,colors.colorCont[1].R,
                  colors.colorCont[1].G, colors.colorCont[1].B,
                  colors.colorCont[1].A);
      /*itens*/  
   int xa = x1+4;
   int ya = y1+3;
   int med = (ITEM_HEIGHT - 10) / 2;
   GuiObject* item;

   std::list<GuiObject*>::iterator it;
   for(it=list.begin(); it != list.end(); it++)
   {
      item = (*it);
      /* Treat Pictures */
      if(item->type == Farso::OBJECT_PICTURE)
      {
         Picture* pic = (Picture*)item;
         pic->setCoordinate(xa, ya+med+1, xa+10, ya+10+med+1);
         pic->draw();
         /* The next text will be translated right */
         xa = x1+15;
      }
      /* treat Texts */
      else if(item->type == Farso::OBJECT_TEXT_BOX)
      {
         color_Set(colors.colorText.R,
               colors.colorText.G,
               colors.colorText.B,
               colors.colorText.A);

         /* Menu Texts */
         if (item->getText().compare("-"))
         {
            if (item->isAvailable()) 
            {
               fnt.write(wSurface,xa,ya+med,item->getText());
            }
            else
            {
               color_Set(colors.colorCont[2].R, colors.colorCont[2].G,
                     colors.colorCont[2].B, colors.colorCont[2].A);
               fnt.write(wSurface,xa+1,ya+med+1,item->getText());
               color_Set(colors.colorCont[1].R, colors.colorCont[1].G,
                     colors.colorCont[1].B, colors.colorCont[1].A);
               fnt.write(wSurface,xa,ya+med,item->getText());
            }
         } 

         /* Menu Separators */
         else 
         {
            color_Set(colors.colorCont[1].R, colors.colorCont[1].G,
                  colors.colorCont[1].B, colors.colorCont[1].A);
            rectangle_2Colors(wSurface,xa-2,ya+6,x2-2,ya+7,
                  colors.colorCont[0].R,
                  colors.colorCont[0].G,colors.colorCont[0].B,
                  colors.colorCont[0].A);
         }
         xa = x1+4;
         ya += ITEM_HEIGHT;
      }
   }
  
}