1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * $Id: DrawingFactory.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
19 inherit "ObjectFactory";
25 #include <attributes.h>
27 class DrawingFactory : public ObjectFactory{
40 init_class_attribute(DRAWING_TYPE, CMD_TYPE_INT, "type",
41 0, EVENT_ATTRIBUTES_CHANGE, 0,
42 CONTROL_ATTR_CLIENT, 0);
44 init_class_attribute(DRAWING_WIDTH, CMD_TYPE_FLOAT, "width",
45 0, EVENT_ARRANGE_OBJECT, 0,
46 CONTROL_ATTR_CLIENT, 0.0);
48 init_class_attribute(DRAWING_HEIGHT, CMD_TYPE_FLOAT, "height",
49 0, EVENT_ARRANGE_OBJECT, 0,
50 CONTROL_ATTR_CLIENT, 0.0);
52 init_class_attribute(DRAWING_COLOR, CMD_TYPE_INT, "color",
53 0, EVENT_ARRANGE_OBJECT, 0,
54 CONTROL_ATTR_CLIENT, 0);
56 init_class_attribute(DRAWING_THICKNESS, CMD_TYPE_INT, "thickness",
57 0, EVENT_ARRANGE_OBJECT, 0,
58 CONTROL_ATTR_CLIENT, 0);
60 init_class_attribute(DRAWING_FILLED, CMD_TYPE_INT, "filled",
61 0, EVENT_ARRANGE_OBJECT, 0,
62 CONTROL_ATTR_CLIENT, 0);
66 object execute(mapping vars)
69 string name = vars["name"];
71 try_event(EVENT_EXECUTE, CALLER, obj);
72 if ( vars->transient ) {
73 if ( mappingp(vars->attributes) )
74 vars->attributes[OBJ_TEMP] = 1;
76 vars->attributes = ([ OBJ_TEMP : 1 ]);
79 obj = ::object_create(name, CLASS_NAME_DRAWING, 0,
81 vars["attributesAcquired"],
82 vars["attributesLocked"],
84 vars["sanctionMeta"]);
85 function obj_set_attribute = obj->get_function("do_set_attribute");
86 function obj_lock_attribute = obj->get_function("do_lock_attribute");
87 obj_set_attribute(DRAWING_TYPE, (int)vars["type"]);
88 obj_lock_attribute(DRAWING_TYPE);
90 run_event(EVENT_EXECUTE, CALLER, obj);
96 string get_identifier() { return "Drawing.factory"; }
97 string get_class_name() { return "Drawing"; }
98 int get_class_id() { return CLASS_DRAWING; }