1 /* Dia -- an diagram creation/manipulation program
2  * Copyright (C) 1998 Alexander Larsson
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  * File:    class.h
19  *
20  * Purpose: This is the interface file for the class icon and dialog.
21  */
22 
23 /** \file objects/UML/class.h  Declaration of the 'UML - Class' type */
24 #ifndef CLASS_H
25 #define CLASS_H
26 
27 #include "object.h"
28 #include "element.h"
29 #include "connectionpoint.h"
30 #include "widgets.h"
31 
32 #include "uml.h"
33 
34 #define DIA_OBJECT(x) (DiaObject*)(x)
35 
36 /** The number of regular connectionpoints on the class (not cps for
37  * attributes and operands and not the mainpoint). */
38 #define UMLCLASS_CONNECTIONPOINTS 8
39 /** default wrap length for member functions */
40 #define UMLCLASS_WRAP_AFTER_CHAR 40
41 /** default wrap length for comments */
42 #define UMLCLASS_COMMENT_LINE_LENGTH 40
43 
44 /* The code behind the following preprocessor symbol should stay disabled until
45  * the dynamic relocation of connection points (caused by attribute and
46  * operation changes) is taken into account. It probably has other issues we are
47  * not aware of yet. Some more information maybe available at
48  * http://bugzilla.gnome.org/show_bug.cgi?id=303301
49  *
50  * Enabling 29/7 2005: Not known to cause any problems.
51  * 7/11 2005: Still seeing problems after dialog update, needs work.  --LC
52  * 18/1 2006: Can't make it break, enabling.
53  */
54 #define UML_MAINPOINT 1
55 
56 
57 typedef struct _UMLClass UMLClass;
58 typedef struct _UMLClassDialog UMLClassDialog;
59 
60 /**
61  * \brief The most complex object Dia has
62  *
63  * What should I say? Don't try this at home :)
64  */
65 struct _UMLClass {
66   Element element; /**< inheritance */
67 
68   /** static connection point storage,  the mainpoint must be behind the dynamics in Element::connections */
69 #ifdef UML_MAINPOINT
70   ConnectionPoint connections[UMLCLASS_CONNECTIONPOINTS + 1];
71 #else
72   ConnectionPoint connections[UMLCLASS_CONNECTIONPOINTS];
73 #endif
74 
75   /* Class info: */
76 
77   real line_width;
78   real font_height;
79   real abstract_font_height;
80   real polymorphic_font_height;
81   real classname_font_height;
82   real abstract_classname_font_height;
83   real comment_font_height;
84 
85   DiaFont *normal_font;
86   DiaFont *abstract_font;
87   DiaFont *polymorphic_font;
88   DiaFont *classname_font;
89   DiaFont *abstract_classname_font;
90   DiaFont *comment_font;
91 
92   char *name;
93   char *stereotype; /**< NULL if no stereotype */
94   char *comment; /**< Comments on the class */
95   int abstract;
96   int suppress_attributes;
97   int suppress_operations;
98   int visible_attributes; /**< ie. don't draw strings. */
99   int visible_operations;
100   int visible_comments;
101 
102   int wrap_operations; /**< wrap operations with many parameters */
103   int wrap_after_char;
104   int comment_line_length; /**< Maximum line length for comments */
105   int comment_tagging; /**< bool: if the {documentation = }  tag should be used */
106 
107   Color line_color;
108   Color fill_color;
109   Color text_color;
110 
111   /** Attributes: aka member variables */
112   GList *attributes;
113 
114   /** Operators: aka member functions */
115   GList *operations;
116 
117   /** Template: if it's a template class */
118   int template;
119   /** Template parameters */
120   GList *formal_params;
121 
122   /* Calculated variables: */
123 
124   real namebox_height;
125   char *stereotype_string;
126 
127   real attributesbox_height;
128 
129   real operationsbox_height;
130 /*
131   GList *operations_wrappos;*/
132   int max_wrapped_line_width;
133 
134   real templates_height;
135   real templates_width;
136 
137   /* Dialog: */
138   UMLClassDialog *properties_dialog;
139 
140   /** Until GtkList replaced by something better, set this when being
141    * destroyed, and don't do umlclass_calculate_data when it is set.
142    * This is to avoid a half-way destroyed list being updated.
143    */
144   gboolean destroyed;
145 };
146 
147 void umlclass_dialog_free (UMLClassDialog *dialog);
148 extern GtkWidget *umlclass_get_properties(UMLClass *umlclass, gboolean is_default);
149 extern ObjectChange *umlclass_apply_props_from_dialog(UMLClass *umlclass, GtkWidget *widget);
150 extern void umlclass_calculate_data(UMLClass *umlclass);
151 extern void umlclass_update_data(UMLClass *umlclass);
152 
153 extern void umlclass_sanity_check(UMLClass *c, gchar *msg);
154 
155 #endif /* CLASS_H */
156