void ei_geometrymanager_unmap(ei_widget_t* widget)
{
	if(widget->geom_params) {
		// Call of the function ei_releasefunc_placer
		widget->geom_params->manager->releasefunc(widget);

		free(widget->geom_params);
		widget->geom_params = NULL;
	}

	// Invalidate widget
	ei_app_invalidate_rect(&widget->screen_location) ;

	// Screen Location reset to 0
	widget->screen_location.top_left = ei_point_zero() ;
	widget->screen_location.size = ei_size_zero();
}
Exemple #2
0
// Dessine le texte d'un widget
void ei_draw_widget_text(	ei_surface_t	surface,
							ei_widget_t*	widget,
							char*			text,
							ei_font_t		text_font,
							ei_color_t		text_color,
							ei_anchor_t		anchor		)
{
    // Calcul du point d'ancrage "where" du type ei_point_t*

    ei_point_t where = ei_point_zero();
    
    // Taille du texte
    ei_size_t tsize;
    hw_text_compute_size(text,text_font,&(tsize.width),&(tsize.height));
    
    // Paramètres du widget
    ei_size_t wsize = widget->screen_location.size;
    ei_point_t wtopleft = widget->screen_location.top_left;

    if ((tsize.width >= wsize.width + 10) 
		|| (tsize.height >= wsize.height + 12)) {
        // Texte plus grand que le frame
        fprintf(stderr, "Texte trop grand pour être affiché.\n");
        return;
    }
	
    ei_switch_anchor(anchor, &where, tsize, wtopleft, wsize);
    ei_rect_t text_clipper;
    
    if (widget->parent == NULL) {
    	text_clipper = widget->screen_location;
    } else {
    	text_clipper = ei_rectangles_intersect(widget->screen_location,
    					widget->parent->screen_location);
    }
    ei_draw_text(surface, &where, text, text_font, &text_color, &text_clipper);
}
Exemple #3
0
void ei_runfunc_placer(struct ei_widget_t* widget)
{
	// we load the location of the father widget
	ei_rect_t* container = widget->parent->content_rect;
	ei_geometrymanager_param_placer_t* prm_placer = (ei_geometrymanager_param_placer_t*)widget->geom_params;
	float width, height ;

	assert(prm_placer);
	assert(prm_placer->rel_width);
	width = container->size.width * 
		*(prm_placer->rel_width) + 
		*(prm_placer->width);
	height = container->size.height * 
		*(prm_placer->rel_height) +
		*(prm_placer->height);

	ei_point_t pos_rel;

	switch (*(prm_placer->anchor)) {
		case ei_anc_none:
		case ei_anc_northwest:
			pos_rel = ei_point_zero();
			break;
		case ei_anc_center:
			pos_rel = ei_point(width / 2, height / 2);
			break;
		case ei_anc_north:
			pos_rel = ei_point(width / 2, 0);
			break;
		case ei_anc_northeast:
			pos_rel = ei_point(width , 0);
			break;
		case ei_anc_east:
			pos_rel = ei_point(width, height / 2);
			break;
		case ei_anc_southeast:
			pos_rel = ei_point(width, height );
			break;
		case ei_anc_south:
			pos_rel = ei_point(width / 2, height);
			break;
		case ei_anc_southwest:
			pos_rel = ei_point(0 , height );
			break;
		case ei_anc_west:
			pos_rel = ei_point(0 , height / 2 );
			break;
	}

	ei_point_t pos_abs = ei_point(
			container->size.width * 
			*(prm_placer->rel_x) + 
			*(prm_placer->x), 
			container->size.height *
			*(prm_placer->rel_y) +
			*(prm_placer->y));

//	ei_app_invalidate_rect(&widget->screen_location);	

	widget->screen_location = ei_rect(
			ei_point_add(ei_point_sub(pos_abs, pos_rel),container->top_left),  
			ei_size(width, height));

	ei_app_invalidate_rect(&widget->screen_location);	

	widget->wclass->geomnotifyfunc(widget, widget->screen_location);

	ei_widget_t * current = widget->children_head;
	while(current) {
		if(current->geom_params) {
			current->geom_params->manager->runfunc(current);
		}
		current = current->next_sibling;
	}
}