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


C++ CL_Rect类代码示例

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


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

示例1: draw

void Map::draw(float elapsed)
{
	CL_Vec2<float> fieldSize;
	CL_Pointf p;

	CL_Rect viewport = window.get_viewport();
	
	fieldSize.x = (float)viewport.get_width() / size.width;
	fieldSize.y = (float)viewport.get_height() / size.height;

	for (int row = 0; row < size.height; row++)
		for (int col = 0; col < size.width; col++)
		{
			p = CL_Pointf(col * fieldSize.x, row * fieldSize.y) + fieldSize / 2;	

			if (row < size.height - 1)
			{
				CL_Colorf color(getEdge(CL_Point(col, row), CL_Point(col, row + 1)).pheromone / 10, 0, 0);
				CL_Draw::line(window.get_gc(), p, p + CL_Vec2<float>(0, fieldSize.y), color);
			}

			if (col < size.width - 1)
			{
				CL_Colorf color(getEdge(CL_Point(col, row), CL_Point(col + 1, row)).pheromone / 10, 0, 0);
				CL_Draw::line(window.get_gc(), p, p + CL_Vec2<float>(fieldSize.x, 0), color);
			}
		}

	p = CL_Pointf(start.x * fieldSize.x, start.y * fieldSize.y);
	CL_Draw::fill(window.get_gc(), p, p + fieldSize, CL_Colorf::red);

	p = CL_Pointf(target.x * fieldSize.x, target.y * fieldSize.y);
	CL_Draw::fill(window.get_gc(), p, p + fieldSize, CL_Colorf::green);
}
开发者ID:sp-alex-osou,项目名称:Ants,代码行数:34,代码来源:Map.cpp

示例2: highlight

void
WindowImpl::draw()
{
  CL_Display::push_translate (parent->get_screen_x(), parent->get_screen_y());

  CL_Color highlight(255, 255, 255);
  CL_Color midtone(150, 150, 150);

  CL_Rect rect = parent->get_position() ;

  Box::draw_window(CL_Rect(CL_Point(0, 0), CL_Size(rect.get_width()-1, rect.get_height()-1)));
  Box::draw_panel_down(client_area->get_position());

  /*
    CL_Display::fill_rect(CL_Rect(CL_Point(0, 0), rect.get_size()), CL_Color(220, 220, 220));
    CL_Display::draw_rect(CL_Rect(CL_Point(0, 0), rect.get_size()), CL_Color(0, 0, 0));
 
    CL_Display::draw_line(1, rect.get_height()-2,
    rect.get_width()-2, rect.get_height()-2, midtone);
    CL_Display::draw_line(rect.get_width()-2, 1,
    rect.get_width()-2, rect.get_height()-2, midtone);

    CL_Display::draw_line(1, 1,
    rect.get_width()-2, 1, highlight);
    CL_Display::draw_line(1, 1,
    1, rect.get_height()-2, highlight);
  */

  CL_Display::pop_modelview();
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:30,代码来源:window.cpp

示例3: impl

Viewport::Viewport(CL_Component* child, const CL_Rect& rect, CL_Component* parent)
  : CL_Component(rect, parent),
    impl(new ViewportImpl())
{
  impl->child = child;
  impl->gc_state.set_size(rect.get_width(), rect.get_height());
}
开发者ID:Flexlay,项目名称:flexlay,代码行数:7,代码来源:viewport.cpp

示例4: set_geometry

void CL_GUIComponent_Impl::set_geometry(CL_Rect new_geometry, bool client_area)
{
	if (parent == 0)
	{
		CL_GUITopLevelWindow *handle = gui_manager.lock()->get_toplevel_window(component);
		gui_manager.lock()->window_manager.set_geometry(handle, new_geometry, client_area);
		new_geometry = gui_manager.lock()->window_manager.get_geometry(handle, true);
	}

	// repaint parent at old geometry
	if (component->get_parent_component())
		component->get_parent_component()->request_repaint(geometry);

	// Check for resize
	if ((geometry.get_width() != new_geometry.get_width()) || (geometry.get_height() != new_geometry.get_height()) )
	{
		geometry = new_geometry;
		geometry_updated();
	}
	else
	{
		geometry = new_geometry;
		component->request_repaint();
	}
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:25,代码来源:gui_component_impl.cpp

示例5: while

void CL_ListViewHeader_Impl::on_render(CL_GraphicContext &gc, const CL_Rect &update_rect)
{
	CL_Rect rect = listview_header->get_geometry();
	part_component.render_box(gc, rect.get_size(), update_rect);
	
	// draw listview column headers and backgrounds
	text_height = font.get_text_size(gc, "l").height;
	CL_ListViewColumnHeader col = first_column;
	while (!col.is_null())
	{
		CL_GUIThemePart &part = col.impl->part;
		CL_Rect &crect = col.impl->rect;
		if (display_mode != listview_mode_details)
			crect.right = rect.right;
		part.render_box(gc, crect, update_rect);
		CL_Rect content_rect = part.get_content_box(crect);

		part.render_text(gc, col.get_caption(), content_rect, update_rect);

		col = col.get_next_sibling();

		if (display_mode != listview_mode_details)
			break;
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:25,代码来源:listview_header.cpp

示例6: calculateCircleBounds

void Sandpit::build()
{
	CL_Rect bounds = calculateCircleBounds();

	setPosition(CL_Pointf(bounds.left, bounds.top));

	const float MAX_WIDTH = 512;
	const float MAX_HEIGHT = 512;

	// prepare image data
	const int width = bounds.get_width() + 1;
	const int height = bounds.get_height() + 1;

	assert(width <= MAX_WIDTH && width > 0);
	assert(height <= MAX_HEIGHT && height > 0);

	// prepare pixel data
	m_pixelData = CL_SharedPtr<CL_PixelBuffer>(new CL_PixelBuffer(width, height, width * 4, CL_PixelFormat::rgba8888));

	fillCircles(width, height, bounds);

	// unset the texture to create is at the next draw
	m_texture.disconnect();

	m_built = true;
}
开发者ID:genail,项目名称:gear,代码行数:26,代码来源:Sandpit.cpp

示例7: CL_Component

Window::Window(const CL_Rect& rect, const std::string& title, CL_Component* parent)
  : CL_Component(rect, parent), impl(new WindowImpl())
{
  impl->titlebar = new Titlebar(CL_Rect(CL_Point(3+16,3), 
                                        CL_Size(get_width()-6-18-18-18, 12+3)), title,
                                this);
  //Fonts::verdana11.draw(8+15, 3, title);

  impl->close = new Icon(CL_Rect(CL_Point(3, 3), CL_Size(18,18)), 
                         make_sprite(datadir + "/images/window/close.png"),
                         "", this);
  impl->minimize = new Icon(CL_Rect(CL_Point(get_width()-3-18-18, 3), CL_Size(18,18)), 
                            make_sprite(datadir + "/images/window/minimize.png"),
                            "", this);
  impl->maximize = new Icon(CL_Rect(CL_Point(get_width()-3-18, 3), CL_Size(18,18)), 
                            make_sprite(datadir + "/images/window/maximize.png"),
                            "", this);

  impl->client_area = new CL_Component(CL_Rect(CL_Point(4, 3+12+7), 
                                               CL_Size(rect.get_width()-10,
                                                       rect.get_height()-28)), this);
  impl->parent  = this;
  impl->is_maximized = false;

  impl->slots.push_back(sig_resize().connect(impl.get(),      &WindowImpl::on_resize));

  impl->slots.push_back(sig_paint().connect(impl.get(),      &WindowImpl::draw));
  impl->slots.push_back(impl->maximize->sig_clicked().connect(impl.get(), &WindowImpl::do_maximize));
  impl->slots.push_back(impl->close->sig_clicked().connect(impl.get(), &WindowImpl::do_close));
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:30,代码来源:window.cpp

示例8: get_viewport

bool CL_OpenGLWindowProvider_GLX::on_clicked(XButtonEvent &event)
{
	if (event.button != 1)	// Left mouse button
		return true;

	int height = get_viewport().get_height();

	glDrawBuffer(GL_BACK);
	glReadBuffer(GL_FRONT);

	CL_Rect rect = CL_Rect(event.x,event.y, CL_Size(1,1));

	CL_PixelBuffer pixelbuffer(rect.get_width(), rect.get_height(), cl_rgba8);
	glReadPixels(
		rect.left, height - rect.bottom,
		rect.right - rect.left, rect.bottom - rect.top,
		GL_RGBA,
		GL_UNSIGNED_INT_8_8_8_8,
		pixelbuffer.get_data());

	const cl_ubyte32 *xptr = (const cl_ubyte32 *) (pixelbuffer.get_data());
	if (((*xptr) & 0xFF) < 10)
	{
		XLowerWindow(x11_window.get_display(), x11_window.get_window());
		return false;
	}

	return true;
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:29,代码来源:opengl_window_provider_glx.cpp

示例9: get_content_box

CL_Rect CL_GUIThemePart::get_content_box(const CL_Rect &render_box_rect) const
{
	impl->check_content_shrink_box_is_cached(*this);
	CL_Rect box = render_box_rect;
	CL_Rect &R = impl->cached_content_box_shrink_rect;
	box.shrink(R.left, R.top, R.right, R.bottom);
	return box;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:8,代码来源:gui_theme_part.cpp

示例10: set_clip_children

void CL_GUIComponent::set_clip_children(bool clip, const CL_Rect &rect)
{
	impl->clip_children = clip;
	if (rect.get_width() == 0 || rect.get_height() == 0)
		impl->clip_children_rect = get_size();
	else
		impl->clip_children_rect = rect;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:8,代码来源:gui_component.cpp

示例11: CL_Rect

std::vector<CL_ClanImageStretch::ImagePart> CL_ClanImageStretch::calc_stretch_image_parts(const CL_Rect &dest, CL_Image &sprite, int sizing_left, int sizing_top, int sizing_right, int sizing_bottom)
{
	int src_width = sprite.get_width();
	int src_height = sprite.get_height();
	int dest_width = dest.get_width();
	int dest_height = dest.get_height();

	int src_grid_x[4];
	int src_grid_y[4];
	int dest_grid_x[4];
	int dest_grid_y[4];

	int rows = 0;
	int cols = 0;

	src_grid_x[cols++] = 0;
	src_grid_x[cols++] = sizing_left;
	src_grid_x[cols++] = src_width - sizing_right;
	src_grid_x[cols++] = src_width;

	src_grid_y[rows++] = 0;
	src_grid_y[rows++] = sizing_top;
	src_grid_y[rows++] = src_height - sizing_bottom;
	src_grid_y[rows++] = src_height;

	rows = 0;
	cols = 0;

	dest_grid_x[cols++] = dest.left;
	dest_grid_x[cols++] = dest.left + sizing_left;
	dest_grid_x[cols++] = dest.right - sizing_right;
	dest_grid_x[cols++] = dest.right;

	dest_grid_y[rows++] = dest.top;
	dest_grid_y[rows++] = dest.top + sizing_top;
	dest_grid_y[rows++] = dest.bottom - sizing_bottom;
	dest_grid_y[rows++] = dest.bottom;

	std::vector<ImagePart> image_parts;
	for (int y = 0; y < rows-1; y++)
	{
		for (int x = 0; x < cols-1; x++)
		{
			ImagePart part;
			part.source_rect = CL_Rect(src_grid_x[x], src_grid_y[y], src_grid_x[x+1], src_grid_y[y+1]);
			part.dest_rect = CL_Rect(dest_grid_x[x], dest_grid_y[y], dest_grid_x[x+1], dest_grid_y[y+1]);
			if (part.source_rect.get_width() > 0 && part.source_rect.get_height() > 0 &&
				part.dest_rect.get_width() > 0 && part.dest_rect.get_height() > 0)
			{
				image_parts.push_back(part);
			}
		}
	}

	return image_parts;
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:56,代码来源:clan_image_stretch.cpp

示例12: CL_Color

void CL_TreeItem_Silver::on_paint()
{
	CL_Rect rect = item->get_screen_rect();
	
	int height = rect.get_height();
	int font_height = font->get_height(item->get_text(0));
	
	if(item->has_mouse_over())
		CL_Display::fill_rect(rect, CL_Color(232, 236, 241));
	if(item->get_node()->is_selected())
		CL_Display::fill_rect(rect, CL_Color(184, 195, 209, 150));

	CL_TreeView *treeview = item->get_node()->get_treeview();
	int columns = treeview->get_column_count();
	if(columns == 0)
		columns = 1;

	// Draw columns
	for(int x = 0, i = 0; i < columns; ++i)
	{
		int dx = 0;
		if(i == 0)
		{
			dx += item->get_text_margin();

			CL_Surface *icon = item->get_icon();
			if(icon)
			{
				icon->draw(
					rect.left + x + 1,
					rect.top + (height - icon->get_height()) / 2);
				dx += icon->get_width();
			}
		}

		CL_Component *comp = item->get_component(i);
		if(comp)
		{
			comp->set_position(CL_Rect(x + dx + 4, 0, x + dx + 4 + treeview->get_column_width(i), height));
			comp->paint();
		}
		else
		{
			font->draw(
				rect.left + x + dx + 4,
				rect.top + (height - font_height) / 2,
				item->get_text(i));
		}

		x += treeview->get_column_width(i);
		if(i == 0)
			x -= item->get_node()->get_placement_offset();
	}
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:54,代码来源:treeitem_silver.cpp

示例13: on_get_preferred_size

void CL_InputBox_Silver::on_get_preferred_size(CL_Size &size)
{
	border_size = 3;
	
	// Override height for font-height
	CL_Rect position = inputbox->get_position();
	position.bottom = position.top + font->get_height() + border_size * 2;

	size.width = position.get_width();
	size.height = position.get_height();
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:11,代码来源:inputbox_silver.cpp

示例14: scale

CL_Vec2f Firework::scale(const CL_Vec2f& v) const
{
	CL_Vec2f scaled;

	CL_Rect viewport = window.get_viewport();

	scaled.x = v.x + viewport.get_width() / 2.0f;
	scaled.y = viewport.get_height() - v.y;
	
	return scaled;
}
开发者ID:sp-alex-osou,项目名称:Firework,代码行数:11,代码来源:Firework.cpp

示例15: get_size

void CL_GUIComponent::render(CL_GraphicContext &gc, const CL_Rect &clip_rect, bool include_children)
{
	if (!impl->visible)
		return;

	if (!impl->css_layout.is_null())
	{
		impl->css_layout.layout(gc, get_size());
		impl->css_layout.render(gc, this);
	}

	if (impl->func_render.is_null() == false)
	{
		impl->func_render.invoke(gc, clip_rect);
	}
	else
	{
		CL_GUIThemePart part(this);
		CL_Rect geometry = get_size();
		part.render_box(gc, CL_RectPS(0, 0, geometry.get_width(), geometry.get_height()), clip_rect);
	}

	if (include_children)
	{
		if (impl->clip_children)
		{
			push_cliprect(gc, impl->clip_children_rect);
		}

		CL_GUIComponent *cur = impl->first_child;
		while (cur)
		{
			CL_Rect cur_geometry = cur->get_geometry();

			CL_Rect update_rect = component_to_window_coords(clip_rect);
			update_rect.overlap(component_to_window_coords(cur_geometry));
			if (update_rect.get_width() > 0 && update_rect.get_height() > 0)
			{
				CL_Rect child_dirty_rect = cur->window_to_component_coords(update_rect);

				gc.push_translate((float)cur_geometry.left, (float)cur_geometry.top);
				cur->render(gc, child_dirty_rect, true);
				gc.pop_modelview();
			}
			cur = cur->impl->next_sibling;
		}

		if (impl->clip_children)
		{
			pop_cliprect(gc);
		}
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:53,代码来源:gui_component.cpp


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