当前位置: 首页>>代码示例>>C++>>正文


C++ DrawingContext::draw_rect方法代码示例

本文整理汇总了C++中DrawingContext::draw_rect方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawingContext::draw_rect方法的具体用法?C++ DrawingContext::draw_rect怎么用?C++ DrawingContext::draw_rect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DrawingContext的用法示例。


在下文中一共展示了DrawingContext::draw_rect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Color

void
SliderBox::draw(DrawingContext& gc)
{
  if (globals::developer_mode)
    gc.draw_rect(rect, Color(0, 255, 255));

  if (value == 0)
  {
    gc.print_center(Fonts::chalk_normal, Vector2i(rect.left + rect.get_width()/2, rect.top), "off");
  }
  else
  {
    for(int i = 0; i < m_steps; ++i)
    {
      if (i < value)
        gc.print_left(Fonts::chalk_normal, Vector2i(rect.left + i*(rect.get_width()-12)/m_steps + 6, rect.top), "|");
      //gc.print_left(Fonts::chalk_normal, rect.left + i*(rect.get_width()-12)/20 + 6, rect.top, "l");
    }
  }

  gc.print_left(Fonts::chalk_normal, Vector2i(rect.left, rect.top),
                "[");
  gc.print_right(Fonts::chalk_normal, Vector2i(rect.right, rect.top),
                 "]");
}
开发者ID:bugdebugger,项目名称:pingus,代码行数:25,代码来源:slider_box.cpp

示例2: Color

void 
Checkbox::draw(DrawingContext& gc)
{
	gc.draw_rect(pos.x, pos.y, pos.x + width, pos.y + height, 
                     Color(0,0,0));
	if (is_checked)
		gc.draw(checkmark, pos);
	
	gc.print_right(Fonts::pingus_small, pos.x, pos.y, label);
}
开发者ID:jinguoliang,项目名称:Maemo-pingus,代码行数:10,代码来源:checkbox.cpp

示例3: int

void
SmallMap::draw(DrawingContext& gc)
{
  // FIXME: This is potentially dangerous, since we don't know how
  // long 'gc' will be alive. Should use a DrawingContext for caching.
  gc_ptr = &gc;

  World* const& world  = server->get_world();

  Vector2i of = playfield->get_pos();
  Rect view_rect;

  if (world->get_width() > gc.get_width())
  {
    int rwidth = int(gc.get_width()  * rect.get_width()  / world->get_width());
    view_rect.left  = rect.left + (of.x * rect.get_width()  / world->get_width()) - rwidth/2;
    view_rect.right = view_rect.left + rwidth;
  }
  else
  {
    view_rect.left  = rect.left;
    view_rect.right = rect.left + rect.get_width();
  }

  if (world->get_height() > gc.get_height())
  {
    int rheight = int(gc.get_height() * rect.get_height() / world->get_height());
    view_rect.top    = rect.top + (of.y * rect.get_height() / world->get_height()) - rheight/2;
    view_rect.bottom = view_rect.top + rheight;
  }
  else
  {
    view_rect.top    = rect.top;
    view_rect.bottom = rect.top + rect.get_height();
  }

  gc.draw(image->get_surface(), Vector2i(rect.left, rect.top));
  gc.draw_rect(view_rect, Color(0, 255, 0));

  server->get_world()->draw_smallmap(this);

  // Draw Pingus
  PinguHolder* pingus = world->get_pingus();
  for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
  {
    int x = static_cast<int>(static_cast<float>(rect.left) + ((*i)->get_x() * static_cast<float>(rect.get_width())
                                                              / static_cast<float>(world->get_width())));
    int y = static_cast<int>(static_cast<float>(rect.top)  + ((*i)->get_y() * static_cast<float>(rect.get_height())
                                                              / static_cast<float>(world->get_height())));

    gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0));
  }

  gc_ptr = 0;
}
开发者ID:drewbug,项目名称:pingus,代码行数:55,代码来源:smallmap.cpp

示例4: Color

void
Inputbox::draw(DrawingContext& gc)
{
  gc.draw_fillrect(rect, Color(255,255,255));
  gc.draw_rect(rect, has_focus() ? Color(255,128,0) : Color(0,0,0));
  
  gc.print_left(Fonts::verdana11, 
                Vector2i(rect.left + 5, 
                         rect.top + rect.get_height()/2 - Fonts::verdana11.get_height()/2),
                text);
}
开发者ID:Tkachov,项目名称:ceu_pingus,代码行数:11,代码来源:inputbox.cpp

示例5: Color

void
Combobox::draw(DrawingContext &gc)
{
  { // draw the unopened box
    gc.draw_fillrect(rect, Color(255,255,255));
    gc.draw(sprite, Vector2i(rect.right - 12, rect.top));
    gc.draw_rect(rect, Color(0,0,0));

    if (current_item != -1)
    {
      gc.print_left(Fonts::verdana11, 
                    Vector2i(rect.left + 5, 
                             rect.top + rect.get_height()/2 - Fonts::verdana11.get_height()/2),
                    item_list[current_item].label);
    }
  }

  if (drop_down && !item_list.empty())
  {
    gc.draw_fillrect(list_rect, Color(255,255,255), 90);

    for (int i = 0; i < int(item_list.size()); ++i)
    {
      if (i == hover_item)
        gc.draw_fillrect(Rect(Vector2i(rect.left, list_rect.top + rect.get_height()*i),
                              Size(rect.get_width(), rect.get_height())),
                         Color(150,200,255), 95);

      gc.print_left(Fonts::verdana11, 
                    Vector2i(list_rect.left + 5, 
                             list_rect.top + i * rect.get_height() + rect.get_height()/2 - Fonts::verdana11.get_height()/2),
                    item_list[i].label, 100);
    }

    gc.draw_rect(list_rect, Color(0,0,0), 100);
  }
}
开发者ID:jcs12311,项目名称:pingus,代码行数:37,代码来源:combobox.cpp

示例6: Color

void
ChoiceBox::draw(DrawingContext& gc)
{
  if (globals::developer_mode)
    gc.draw_rect(rect, Color(0, 255, 255));  

  if (!choices.empty())
  {
    if (current_choice >= 0 && current_choice < int(choices.size()))
    {
      //if (current_choice != 0) 
      gc.print_left(Fonts::chalk_normal,  Vector2i(rect.left, rect.top), "<");

      //if (current_choice != int(choices.size())-1)
      gc.print_right(Fonts::chalk_normal, Vector2i(rect.right, rect.top), ">");

      gc.print_center(Fonts::chalk_normal, Vector2i(rect.left + rect.get_width()/2, rect.top), 
                      choices[current_choice]);
    }
  }
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:21,代码来源:choice_box.cpp

示例7: if

void
FileList::draw(DrawingContext& gc)
{
  GUIStyle::draw_lowered_box(gc, rect, Color(255, 255, 255));

  int end = (page+1) * items_per_page();
  if (end > int(directory.size()))
    end = static_cast<int>(directory.size());

  int x = rect.left;
  int y = rect.top;
  for(System::Directory::iterator i = directory.begin() + page * items_per_page();
      i != directory.begin() + end; ++i)
  {
    if (i->type == System::DE_DIRECTORY)
      gc.draw(directory_icon, Vector2i(x, y));
    else if (i->type == System::DE_FILE)
      gc.draw(file_icon, Vector2i(x, y));

    if ((click_item == -1 && (i - directory.begin()) == current_item) ||
        (i - directory.begin()) == click_item)
    {
      if (click_item == current_item)
        gc.draw_fillrect(Rect(x, y, x + hspace, y + vspace), Color(0, 0, 255));
      else
        gc.draw_rect(Rect(x, y, x + hspace, y + vspace), Color(0, 0, 255));
    }

    gc.print_left(Fonts::verdana11, Vector2i(x + 4, y + 3),
                  ((i->type == System::DE_DIRECTORY) ? "[DIR]  " : "[FILE] ") + i->name);

    y += 20;
    if (y > rect.bottom - vspace)
    {
      y = rect.top;
      x += hspace;
    }
  }
}
开发者ID:drewbug,项目名称:pingus,代码行数:39,代码来源:file_list.cpp

示例8: if

// Draw the sprite
void
LevelObj::draw(DrawingContext &gc)
{
  if (attribs & HAS_SURFACE || attribs & HAS_SURFACE_FAKE)
  {
    if (attribs & HAS_REPEAT)
    {
      for(int x = static_cast<int>(pos.x); x < static_cast<int>(pos.x) + sprite.get_width() * repeat; x += sprite.get_width())
      {
        gc.draw(sprite, Vector3f(static_cast<float>(x), pos.y, pos.z));
      }
    }
#if 0
    else if(attribs & HAS_STRETCH)
    {
      // Surface Background - tile it
      for (int x = 0; x < level->size.width; x += sprite.get_width())
        for (int y = 0; y < level->size.height; y += sprite.get_height())
          gc.draw(sprite, Vector3f((float)x, (float)y, pos.z));
    }
#endif
    else if (attribs & HAS_COLOR && section_name == "solidcolor-background")
    { // FIXME: Should we have the object type in non-string form?
      gc.draw_fillrect(get_rect(), color, pos.z);
      gc.draw(sprite, pos);
    }
    else
    {
      gc.draw(sprite, pos);
    }

    // If selected, draw a highlighted box around it
    if (selected)
    {
      gc.draw_fillrect(get_rect(), Color(255,0,0,50), pos.z);
      gc.draw_rect(get_rect(), Color(255,0,0), pos.z);
    }
  }
}
开发者ID:jcs12311,项目名称:pingus,代码行数:40,代码来源:level_objs.cpp

示例9: Color

void
GenericLevelObj::draw_selection(DrawingContext &gc)
{
  gc.draw_fillrect(get_rect(), Color(255,0,0,50), pos.z);
  gc.draw_rect(get_rect(), Color(255,0,0), pos.z);
}
开发者ID:gcourtois,项目名称:pingus,代码行数:6,代码来源:generic_level_obj.cpp


注:本文中的DrawingContext::draw_rect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。