3 * Copyright (C) 2005 Laboratoire d'Informatique de Paris 6
4 * Author: Pierre Duquesne
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "pixmaps/aadlmemory.xpm"
24 /***********************************************
26 ***********************************************/
28 static void aadlmemory_draw_borders(Aadlbox
*aadlbox
, DiaRenderer
*renderer
)
30 DiaRendererClass
*renderer_ops
= DIA_RENDERER_GET_CLASS (renderer
);
35 assert(aadlbox
!= NULL
);
36 assert(renderer
!= NULL
);
38 elem
= &aadlbox
->element
;
45 bez
[0].type
= BEZ_MOVE_TO
;
46 bez
[1].type
= BEZ_CURVE_TO
;
47 bez
[2].type
= BEZ_LINE_TO
;
48 bez
[3].type
= BEZ_CURVE_TO
;
49 bez
[4].type
= BEZ_LINE_TO
;
52 bez
[0].p1
.y
= y
+ h
*AADL_MEMORY_FACTOR
;
59 bez
[1].p3
.y
= y
+ h
*AADL_MEMORY_FACTOR
;
62 bez
[2].p1
.y
= y
+ h
- h
*AADL_MEMORY_FACTOR
;
69 bez
[3].p3
.y
= y
+ h
- h
*AADL_MEMORY_FACTOR
;
71 point_copy(&bez
[4].p1
, &bez
[0].p1
);
73 renderer_ops
->set_fillstyle(renderer
, FILLSTYLE_SOLID
);
74 renderer_ops
->set_linewidth(renderer
, AADLBOX_BORDERWIDTH
);
75 renderer_ops
->set_linestyle(renderer
, LINESTYLE_SOLID
);
77 renderer_ops
->fill_bezier(renderer
, bez
, 5, &aadlbox
->fill_color
);
78 renderer_ops
->draw_bezier(renderer
, bez
, 5, &aadlbox
->line_color
);
81 bez
[1].p1
.y
= y
+ 2*h
*AADL_MEMORY_FACTOR
;
83 bez
[1].p2
.y
= y
+ 2*h
*AADL_MEMORY_FACTOR
;
85 bez
[1].p3
.y
= y
+ h
*AADL_MEMORY_FACTOR
;
87 renderer_ops
->draw_bezier(renderer
, bez
, 3, &aadlbox
->line_color
);
91 static Aadlbox_specific aadlmemory_specific
=
93 (AadlProjectionFunc
) aadldata_project_point_on_nearest_border
,
94 (AadlTextPosFunc
) aadlmemory_text_position
,
95 (AadlSizeFunc
) aadlmemory_minsize
100 static void aadlmemory_draw(Aadlbox
*aadlbox
, DiaRenderer
*renderer
)
102 aadlmemory_draw_borders(aadlbox
, renderer
);
103 aadlbox_draw(aadlbox
, renderer
);
106 ObjectTypeOps aadlmemory_type_ops
;
108 DiaObjectType aadlmemory_type
=
110 "AADL - Memory", /* name */
112 (char **) aadlmemory_xpm
, /* pixmap */
114 &aadlmemory_type_ops
, /* ops */
116 &aadlmemory_specific
/* user data */
120 static ObjectOps aadlmemory_ops
=
122 (DestroyFunc
) aadlbox_destroy
,
123 (DrawFunc
) aadlmemory_draw
, /* redefined */
124 (DistanceFunc
) aadlbox_distance_from
,
125 (SelectFunc
) aadlbox_select
,
126 (CopyFunc
) aadlbox_copy
,
127 (MoveFunc
) aadlbox_move
,
128 (MoveHandleFunc
) aadlbox_move_handle
,
129 (GetPropertiesFunc
) object_create_props_dialog
,
130 (ApplyPropertiesFunc
) object_apply_props_from_dialog
,
131 (ObjectMenuFunc
) aadlbox_get_object_menu
,
132 (DescribePropsFunc
) aadlbox_describe_props
,
133 (GetPropsFunc
) aadlbox_get_props
,
134 (SetPropsFunc
) aadlbox_set_props
139 static DiaObject
*aadlmemory_create(Point
*startpoint
, void *user_data
, Handle
**handle1
, Handle
**handle2
)
141 DiaObject
*obj
= aadlbox_create(startpoint
, user_data
, handle1
, handle2
);
143 obj
->type
= &aadlmemory_type
;
144 obj
->ops
= &aadlmemory_ops
;
149 static DiaObject
*aadlmemory_load(ObjectNode obj_node
, int version
, const char *filename
)
152 Point startpoint
= {0.0,0.0};
153 Handle
*handle1
,*handle2
;
155 obj
= aadlmemory_create(&startpoint
,&aadlmemory_specific
, &handle1
,&handle2
);
156 aadlbox_load(obj_node
, version
, filename
, (Aadlbox
*) obj
);
161 ObjectTypeOps aadlmemory_type_ops
=
163 (CreateFunc
) aadlmemory_create
,
164 (LoadFunc
) aadlmemory_load
,/*using_properties*/ /* load */
165 (SaveFunc
) aadlbox_save
, /* save */
166 (GetDefaultsFunc
) NULL
,
167 (ApplyDefaultsFunc
) NULL