Пример #1
0
static void
Delete(void *p)
{
	VG_Text *vt = p;

	if (VG_DelRef(vt, vt->p1) == 0)
		VG_Delete(vt->p1);
	if (VG_DelRef(vt, vt->p2) == 0)
		VG_Delete(vt->p2);
}
Пример #2
0
static void
Delete(void *p)
{
	VG_Circle *vc = p;

	if (VG_DelRef(vc, vc->p) == 0)
		VG_Delete(vc->p);
}
Пример #3
0
static int
MouseButtonDown(void *p, VG_Vector vPos, int button)
{
	VG_TextTool *t = p;
	VG_View *vv = VGTOOL(t)->vgv;
	VG *vg = vv->vg;
	VG_Point *p1, *p2;

	switch (button) {
	case AG_MOUSE_LEFT:
		if (t->vtIns == NULL) {
			if (!(p1 = VG_NearestPoint(vv, vPos, NULL))) {
				p1 = VG_PointNew(vg->root, vPos);
			}
			p2 = VG_PointNew(vg->root, vPos);
			t->vtIns = VG_TextNew(vg->root, p1, p2);
			VG_TextString(t->vtIns, t->text);
			if (VGTOOL(t)->p != NULL)
				VG_TextSubstObject(t->vtIns, VGTOOL(t)->p);
		} else {
			if ((p2 = VG_NearestPoint(vv, vPos,
			    t->vtIns->p2))) {
				VG_DelRef(t->vtIns, t->vtIns->p2);
				VG_Delete(t->vtIns->p2);
				t->vtIns->p2 = p2;
				VG_AddRef(t->vtIns, p2);
			} else {
				VG_SetPosition(t->vtIns->p2, vPos);
			}
			t->vtIns = NULL;
		}
		return (1);
	case AG_MOUSE_RIGHT:
		if (t->vtIns != NULL) {
			VG_Delete(t->vtIns);
			t->vtIns = NULL;
		}
		return (1);
	default:
		return (0);
	}
}