예제 #1
0
void
WindowImpl::do_maximize()
{
  // FIXME: Move this to scripting language
  if (!is_maximized)
  {
    is_maximized = true;
    old_position = parent->get_position();
    parent->set_position(parent->get_parent()->get_position());
  }
  else
  {
    is_maximized = false;
    parent->set_position(old_position);
  }
}
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();
	}
}
예제 #3
0
void
WindowImpl::on_resize(int, int)
{
  titlebar->set_position(CL_Rect(CL_Point(3+16,3), CL_Size(parent->get_width()-6-18-18-18, 12+3)));
  close->set_position(3, 3);
  minimize->set_position(parent->get_width()-3-18-18, 3);
  maximize->set_position(parent->get_width()-3-18, 3);
  CL_Rect rect = parent->get_position();
  client_area->set_position(CL_Rect(CL_Point(4, 3+12+7), 
                                    CL_Size(rect.get_width()-10,
                                            rect.get_height()-28)));
}
예제 #4
0
void
TitlebarImpl::on_mouse_move(const CL_InputEvent& event)
{
  if(pressed)
  {
    CL_Rect rect = window->get_position();

    CL_Point move(old_pos.left - (click_pos.x - (rect.left + event.mouse_pos.x)),
                  old_pos.top  - (click_pos.y - (rect.top  + event.mouse_pos.y)));

    window->set_position(move.x, move.y);
  }
}
void CL_TreeView_Silver::on_paint_node(CL_TreeNode *node, CL_Point &point)
{
	CL_Component *component = node->get_component();
	CL_Component *client_area = treeview->get_client_area();

	int height = component->get_height();
	int mid = (height) / 2;

	// Should we draw decoration ?
	bool draw_decoration = true;
	if(node->is_root())
		draw_decoration = node->get_treeview()->is_root_decoration_visible();

	// Find what y offset we're drawing at
	point.y -= scrollbar->get_value();

	// Find what x offset we're drawing at
	int x_offset = 0;
	if(draw_decoration)
		x_offset = 12;

	int screen_x = client_area->get_screen_x();
	int screen_y = client_area->get_screen_y();
	
	// Is the node visible?
	if (point.y + height >= 0 && point.y <= client_area->get_height())
	{
		if(draw_decoration)
		{
			// Draw collapse box
			if(node->has_children())
			{
				CL_Display::draw_rect(
					CL_Rect(
						screen_x + point.x,
						screen_y + point.y + mid - 5,
						screen_x + point.x + 9,
						screen_y + point.y + mid + 4),
					CL_Color(128, 142, 159));

				CL_Display::fill_rect(
					CL_Rect(
						screen_x + point.x + 1,
						screen_y + point.y + mid - 4,
						screen_x + point.x + 8,
						screen_y + point.y + mid + 3),
					CL_Gradient(
						CL_Color::white,
						CL_Color::white,
						CL_Color(230, 235, 240),
						CL_Color(230, 235, 240)));

				CL_Display::fill_rect(
					CL_Rect(
						screen_x + point.x + 2,
						screen_y + point.y + mid - 3,
						screen_x + point.x + 7,
						screen_y + point.y + mid + 2),
					CL_Gradient(
						CL_Color(217, 222, 227),
						CL_Color(217, 222, 227),
						CL_Color::white,
						CL_Color::white));

				// Horizontal line
				CL_Display::draw_line(
					screen_x + point.x + 2.0f,
					screen_y + point.y + mid - 1.0f,
					screen_x + point.x + 7.0f,
					screen_y + point.y + mid - 1,
					CL_Color::black);

				// Vertical line
				if(node->is_collapsed())
					CL_Display::draw_line(
						screen_x + point.x + 4.0f,
						screen_y + point.y + mid - 3.0f,
						screen_x + point.x + 4.0f,
						screen_y + point.y + mid + 2.0f,
						CL_Color::black);
			}
		}

		// Size and place child component
		component->set_position(point.x + x_offset, point.y);
		node->set_placement_offset(point.x + x_offset);

		// Draw component
		component->show(true);
		component->sig_begin_paint();
		component->sig_paint()();
		component->sig_end_paint();
	}
	else
	{
		component->show(false);
	}

	// Move down for next component
	point.y += scrollbar->get_value();
	point.y += height;

	// If it has any children, adjust the x-position for the children
	if(node->is_collapsed() == false)
		point.x += 3 + x_offset;
}