Example #1
0
int w_pushbutton_init (w_window_t *window, w_pushbutton_t **pbutton, w_object_t *parent)
{
	w_pushbutton_t *pb;
	
	pb = (w_pushbutton_t *) s_malloc(sizeof(w_pushbutton_t));
	memset(pb, 0, sizeof(w_pushbutton_t));
	if (w_button_init(window, &pb->button, parent)) {
		goto err0;
	}
	if (w_textbox_init(window, &pb->textbox, pb->button->object)) {
		goto err1;
	}
	w_button_set_released(pb->button->object, w_pushbutton_released);
	w_textbox_set_properties(pb->textbox->object, TEXTBOX_VCENTER | TEXTBOX_HCENTER);
	w_textbox_set_style(pb->textbox->object, FRAME_NOFRAME, 0);
	w_object_show(pb->textbox->object);
	pb->object = pb->button->object;
	pb->object->type = OBJECT_PUSHBUTTON;
	pb->object->data[OBJECT_PUSHBUTTON] = pb;
	pb->object->draw = w_pushbutton_draw;
	pb->object->geometry = w_pushbutton_geometry;
	pb->object->destroy = w_pushbutton_uninit;
	*pbutton = pb;
	return 0;
err1:	w_button_uninit(pb->button->object);
err0:	*pbutton = NULL;
	return -1;
}
Example #2
0
File: code.c Project: jetlive/xynth
void code_generate_object_textbox (s_hashtable_t *htable, s_xml_node_t *node)
{
	s_xml_node_t *tmp;
	w_textbox_t *textbox;
	w_object_t *pobject;
	w_object_t *wobject;
	s_xml_node_t *window = s_xml_node_get_parent(node, "window");
	wobject = (w_object_t *) s_hashtable_get_data(htable, s_xml_node_get_attr_value(window, "id"));
	pobject = (w_object_t *) s_hashtable_get_data(htable, s_xml_node_get_attr_value(node->parent, "id"));
	w_textbox_init(wobject->window, &textbox, pobject);
	s_hashtable_add(htable, s_xml_node_get_attr_value(node, "id"), textbox->object);
	while ((tmp = s_xml_node_get_path(node, "style")) != NULL) {
		FRAME_SHAPE fshape;
		FRAME_SHADOW fshadow;
		code_get_style(htable, tmp, &fshape, &fshadow);
		w_textbox_set_style(textbox->object, fshape, fshadow); 
		tmp->dontparse = 1;
	}
	while ((tmp = s_xml_node_get_path(node, "image")) != NULL) {
		char **var;
		unsigned int count;
		unsigned int style;
		unsigned int rotate;
		code_get_image(htable, tmp, &style, &rotate, &count, &var);
		if (var != NULL) {
			w_textbox_set_image(textbox->object, style, rotate, count, var);
			while (count--) s_free(var[count]);
			s_free(var);
		}
		tmp->dontparse = 1;
	}
	while ((tmp = s_xml_node_get_path(node, "properties")) != NULL) {
		TEXTBOX_PROPERTIES prop;
		code_get_enum(htable, tmp->value, &prop);
		w_textbox_set_properties(textbox->object, prop);
		tmp->dontparse = 1;
	}
	while ((tmp = s_xml_node_get_path(node, "size")) != NULL) {
		int size = atoi(tmp->value);
		w_textbox_set_size(textbox->object, size);
		tmp->dontparse = 1;
	}
	if ((tmp = s_xml_node_get_path(node, "color")) != NULL) {
		int cr = atoi(s_xml_node_get_path_value(tmp, "red"));
		int cg = atoi(s_xml_node_get_path_value(tmp, "green"));
		int cb = atoi(s_xml_node_get_path_value(tmp, "blue"));
		w_textbox_set_rgb(textbox->object, cr, cg, cb);
		if ((tmp = s_xml_node_get_path(node, "color/red")) != NULL) { tmp->dontparse = 1; }
		if ((tmp = s_xml_node_get_path(node, "color/green")) != NULL) { tmp->dontparse = 1; }
		if ((tmp = s_xml_node_get_path(node, "color/blue")) != NULL) { tmp->dontparse = 1; }
		tmp->dontparse = 1;
	}
	if ((tmp = s_xml_node_get_path(node, "string")) != NULL) {
		w_textbox_set_str(textbox->object, code_trim_quota(tmp->value));
		tmp->dontparse = 1;
	}
}
Example #3
0
int w_listbox_set_active_style (w_object_t *object, unsigned int shape, unsigned int shadow)
{
    w_listbox_t *lb;
    w_listbox_item_t *li;
    lb = object->data[OBJECT_LISTBOX];
    lb->activeshape = shape;
    lb->activeshadow = shadow;
    li = w_listbox_item_active_get(object);
    if (li) {
        w_textbox_set_style(li->textbox->object, lb->activeshape, lb->activeshadow);
        w_object_draw(li->textbox->object);
    }
    return 0;
}
Example #4
0
void w_listbox_draw (w_object_t *object)
{
    int x;
    int y;
    int h;
    int w;
    int pos;
    w_listbox_t *lb;
    w_listbox_item_t *li;
    lb = object->data[OBJECT_LISTBOX];
    x = object->content->x;
    w = object->content->w;
    h = lb->itemheight;
    lb->height = lb->items->nb_elt * h;
    lb->yoffset = MAX(lb->yoffset, object->content->h - lb->height);
    lb->yoffset = MIN(0, lb->yoffset);
    y = object->content->y + lb->yoffset;
    if (object->surface->vbuf == NULL) {
        goto end;
    }
    if (lb->scrollbuffer) {
        if (((lb->active + 1) * h) + lb->yoffset > lb->object->content->h) {
            w_scrollbuffer_slide(lb->scrollbuffer, (((lb->active + 1) * h) + lb->yoffset) - lb->object->content->h, 0);
            return;
        }
        if ((lb->active * h) + lb->yoffset < 0) {
            w_scrollbuffer_slide(lb->scrollbuffer, ((lb->active * h) + lb->yoffset), 0);
            return;
        }
    }
    w_frame_draw(object);
    for (pos = 0; !s_list_eol(lb->items, pos); pos++, y += h) {
        li = (w_listbox_item_t *) s_list_get(lb->items, pos);
        if (!(pos == lb->active || pos == lb->pactive) &&
                (li->textbox->object->surface->buf->x == x &&
                 li->textbox->object->surface->buf->y == y &&
                 li->textbox->object->surface->buf->w == w &&
                 li->textbox->object->surface->buf->h == h)) {
#if 0
            printf("pos %d, active: %d, pactive: %d\n"
                   "%d %d %d %d, %d %d %d %d\n",
                   pos, lb->active, lb->pactive, x, y, w, h,
                   li->textbox->object->surface->buf->x, li->textbox->object->surface->buf->y,
                   li->textbox->object->surface->buf->w, li->textbox->object->surface->buf->h);
#endif
            continue;
        }
        if (pos == lb->active) {
            w_textbox_set_rgb(li->textbox->object, 0, 0, 0);
            w_textbox_set_style(li->textbox->object, lb->activeshape, lb->activeshadow);
        } else {
            w_textbox_set_rgb(li->textbox->object, 255, 255, 255);
            w_textbox_set_style(li->textbox->object, lb->inactiveshape, lb->inactiveshadow);
        }
        w_textbox_set_str(li->textbox->object, li->name);
        w_object_move_silent(li->textbox->object, x, y, w, h);
    }
    if (lb->pactive != lb->active) {
        if (lb->changed != NULL) {
            lb->changed(object, lb->active);
        }
        lb->pactive = lb->active;
    }
    w_object_update(lb->object, lb->object->surface->win);
end:
    return;
}