blob: 5c78ef238f99ecd6900afab58cd1d0a29264cede (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2004-2006 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
// own header
#include "widget_utils.h"
// qt/kde includes
#include <tqcanvas.h>
#include <tqbrush.h>
#include <tqpen.h>
#include <kiconloader.h>
#include <kdebug.h>
// app includes
#include "uml.h"
#include "umlview.h"
#include "umlwidget.h"
#include "objectwidget.h"
namespace Widget_Utils {
UMLWidget* findWidget(Uml::IDType id,
const UMLWidgetList& widgets,
const MessageWidgetList* pMessages /* = NULL */)
{
UMLWidgetListIt it( widgets );
UMLWidget * obj = NULL;
while ( (obj = it.current()) != NULL ) {
++it;
if (obj->getBaseType() == Uml::wt_Object) {
if (static_cast<ObjectWidget *>(obj)->getLocalID() == id)
return obj;
} else if (obj->getID() == id) {
return obj;
}
}
if (pMessages == NULL)
return NULL;
MessageWidgetListIt mit( *pMessages );
while ( (obj = (UMLWidget*)mit.current()) != NULL ) {
++mit;
if( obj -> getID() == id )
return obj;
}
return NULL;
}
TQIconSet iconSet(Uml::Diagram_Type dt) {
TQIconSet diagramIconSet;
switch (dt) {
case Uml::dt_UseCase:
diagramIconSet = BarIconSet("umbrello_diagram_usecase");
break;
case Uml::dt_Collaboration:
diagramIconSet = BarIconSet("umbrello_diagram_collaboration");
break;
case Uml::dt_Class:
diagramIconSet = BarIconSet("umbrello_diagram_class");
break;
case Uml::dt_Sequence:
diagramIconSet = BarIconSet("umbrello_diagram_sequence");
break;
case Uml::dt_State:
diagramIconSet = BarIconSet("umbrello_diagram_state");
break;
case Uml::dt_Activity:
diagramIconSet = BarIconSet("umbrello_diagram_activity");
break;
case Uml::dt_Component:
diagramIconSet = BarIconSet("umbrello_diagram_component");
break;
case Uml::dt_Deployment:
diagramIconSet = BarIconSet("umbrello_diagram_deployment");
break;
case Uml::dt_EntityRelationship:
diagramIconSet = BarIconSet("umbrello_diagram_entityrelationship");
break;
default:
kDebug() << "Widget_Utils::iconSet: unknown diagram type " << dt << endl;
diagramIconSet = BarIconSet("unknown");
}
return diagramIconSet;
}
TQCanvasRectangle *decoratePoint(const TQPoint& p) {
const int SIZE = 4;
UMLView *currentView = UMLApp::app()->getCurrentView();
TQCanvasRectangle *rect;
rect = new TQCanvasRectangle(p.x() - SIZE / 2,
p.y() - SIZE / 2,
SIZE, SIZE, currentView->canvas());
rect->setBrush( TQBrush(TQt::blue) );
rect->setPen( TQPen(TQt::blue) );
rect->setVisible(true);
return rect;
}
} // namespace Widget_Utils
|