1
/***************************************************************************
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
* copyright (C) 2002-2008 *
9
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
10
***************************************************************************/
13
#include "regionwidget.h"
22
#include <kinputdialog.h>
27
#include "docwindow.h"
28
#include "umlwidget.h"
30
#include "floatingtextwidget.h"
32
RegionWidget::RegionWidget(UMLView * view, Uml::IDType id)
33
: UMLWidget(view, id) {
34
UMLWidget::setBaseType( Uml::wt_Region );
35
updateComponentSize();
38
RegionWidget::~RegionWidget() {}
40
void RegionWidget::draw(QPainter & p, int offsetX, int offsetY)
42
setPenFromSettings(p);
43
const int w = width();
44
const int h = height();
47
setPenFromSettings(p);
48
pen.setColor ( Qt::red );
49
pen.setStyle ( Qt::DashLine );
51
p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);
55
drawSelected(&p, offsetX, offsetY);
58
QSize RegionWidget::calculateSize() {
60
int width = 10, height = 10;
61
const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
62
const int fontHeight = fm.lineSpacing();
63
int textWidth = fm.width(getName());
66
width = textWidth > REGION_WIDTH?textWidth:REGION_WIDTH;
67
height = height > REGION_HEIGHT ? height : REGION_HEIGHT;
68
width += REGION_MARGIN * 2;
69
height += REGION_MARGIN * 2;
71
return QSize(width, height);
74
void RegionWidget::setName(const QString &strName) {
76
updateComponentSize();
77
adjustAssocs( getX(), getY() );
80
QString RegionWidget::getName() const {
85
void RegionWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
86
QDomElement regionElement = qDoc.createElement( "regionwidget" );
87
UMLWidget::saveToXMI( qDoc, regionElement );
88
regionElement.setAttribute( "regionname", m_Text );
89
regionElement.setAttribute( "documentation", m_Doc );
91
qElement.appendChild( regionElement );
94
bool RegionWidget::loadFromXMI( QDomElement & qElement ) {
95
if( !UMLWidget::loadFromXMI( qElement ) )
97
m_Text = qElement.attribute( "regionname", "" );
98
m_Doc = qElement.attribute( "documentation", "" );
103
#include "regionwidget.moc"