~ubuntu-branches/ubuntu/utopic/tcm/utopic

« back to all changes in this revision

Viewing changes to src/dg/sizeshapebordercmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 2000, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
//#include "grafport.h"
 
23
//#include "gshape.h"
 
24
//#include "shapeview.h"
 
25
//#include "diagram.h"
 
26
//#include "diagramviewer.h"
 
27
//#include "drawwindow.h"
 
28
#include "sizeshapebordercmd.h"
 
29
#include "nodeshape.h"
 
30
 
 
31
SizeShapeBorderCmd::SizeShapeBorderCmd(GShape *s, int dir)
 
32
        :SizeShapeCmd(s, dir)
 
33
{
 
34
        if ( ! constrainX ) {
 
35
                if ( 1 == dir || 4 == dir || 7 == dir ) {
 
36
                        shape->GetShapeType()->GetRight(&centre);
 
37
                        shape->GetShapeType()->GetLeft(&corner);
 
38
                        fixpoint.x = shape->GetRightMost();
 
39
                } else {
 
40
                        shape->GetShapeType()->GetLeft(&centre);
 
41
                        shape->GetShapeType()->GetRight(&corner);
 
42
                        fixpoint.x = shape->GetLeftMost();
 
43
                }
 
44
                // centre.x = -centre.x;
 
45
                centre.SetXUnscaled   (-centre.GetXUnscaled()   );
 
46
                centre.SetXHorizScaled(-centre.GetXHorizScaled());
 
47
                centre.SetXVertScaled (-centre.GetXVertScaled() );
 
48
                centre.SetXNameScaled (-centre.GetXNameScaled() );
 
49
                // corner.x += centre.x;
 
50
                corner.SetXUnscaled   (corner.GetXUnscaled()    +
 
51
                        centre.GetXUnscaled()   );
 
52
                corner.SetXHorizScaled(corner.GetXHorizScaled() +
 
53
                        centre.GetXHorizScaled());
 
54
                corner.SetXVertScaled (corner.GetXVertScaled()  +
 
55
                        centre.GetXVertScaled() );
 
56
                corner.SetXNameScaled (corner.GetXNameScaled()  +
 
57
                        centre.GetXNameScaled() );
 
58
        }
 
59
        if ( ! constrainY ) {
 
60
                if ( 3 == dir || 4 == dir || 5 == dir ) {
 
61
                        shape->GetShapeType()->GetTop(&centre);
 
62
                        shape->GetShapeType()->GetBottom(&corner);
 
63
                        fixpoint.y = shape->GetTopMost();
 
64
                } else {
 
65
                        shape->GetShapeType()->GetBottom(&centre);
 
66
                        shape->GetShapeType()->GetTop(&corner);
 
67
                        fixpoint.y = shape->GetBottomMost();
 
68
                }
 
69
                // centre.y = -centre.y;
 
70
                centre.SetYUnscaled   (-centre.GetYUnscaled()   );
 
71
                centre.SetYHorizScaled(-centre.GetYHorizScaled());
 
72
                centre.SetYVertScaled (-centre.GetYVertScaled() );
 
73
                centre.SetYNameScaled (-centre.GetYNameScaled() );
 
74
                // corner.y += centre.y;
 
75
                corner.SetYUnscaled   (corner.GetYUnscaled()    +
 
76
                        centre.GetYUnscaled()   );
 
77
                corner.SetYHorizScaled(corner.GetYHorizScaled() +
 
78
                        centre.GetYHorizScaled());
 
79
                corner.SetYVertScaled (corner.GetYVertScaled()  +
 
80
                        centre.GetYVertScaled() );
 
81
                corner.SetYNameScaled (corner.GetYNameScaled()  +
 
82
                        centre.GetYNameScaled() );
 
83
        }
 
84
}
 
85
 
 
86
 
 
87
//void SizeShapeBorderCmd::DrawOutline(const Point *pt) {
 
88
//      Point p = ScaleCorrect(pt);
 
89
//      if (!constrainX) {
 
90
//              if (direction==1||direction==4||direction==7) {
 
91
//              // left side moved.
 
92
//                      p.x = min(p.x, newTopLeft.x+newWidth-Shape::MIN_WIDTH);
 
93
//                      newWidth += newTopLeft.x-p.x;
 
94
//                      newTopLeft.x = p.x;
 
95
//              }
 
96
//              else {
 
97
//              // right side moved.
 
98
//                      p.x = max(p.x, newTopLeft.x+Shape::MIN_WIDTH);
 
99
//                      newWidth = p.x - newTopLeft.x;
 
100
//              }
 
101
//      }
 
102
//      if (!constrainY) {
 
103
//              if (direction==1||direction==2||direction==6) {
 
104
//                      // top side moved.
 
105
//                      p.y = min(p.y,newTopLeft.y+newHeight-Shape::MIN_HEIGHT);
 
106
//                      newHeight += newTopLeft.y-p.y;
 
107
//                      newTopLeft.y = p.y;
 
108
//              }
 
109
//              else {
 
110
//                      // bottom side moved.
 
111
//                      p.y = max(p.y, newTopLeft.y+Shape::MIN_HEIGHT);
 
112
//                      newHeight = p.y - newTopLeft.y;
 
113
//              }
 
114
//      }
 
115
//      newWidth = max(1, newWidth);
 
116
//      newHeight = max(1, newHeight);
 
117
//      GetGrafport()->SetLineStyle(LineStyle::DOTTED);
 
118
//      GetGrafport()->SetLineWidth(1);
 
119
//      GetGrafport()->SetForegroundColor("black");
 
120
//      GetGrafport()->DrawRectangle(newTopLeft.x, newTopLeft.y, 
 
121
//                                   newWidth, newHeight);
 
122
//}
 
123
//
 
124
//void SizeShapeBorderCmd::Execute() {
 
125
//      Command::Execute();
 
126
//      Point pt;
 
127
//      pt.x = newTopLeft.x + newWidth/2;
 
128
//      pt.y = newTopLeft.y + newHeight/2;
 
129
//      shape->UpdatePosition(&pt);
 
130
//      shape->UpdateSize(newWidth, newHeight);
 
131
//      shape->GetView()->GetViewer()->ShapePositionUpdate(shape);      
 
132
//      GetMainWindow()->FitDocument();
 
133
//}
 
134
//
 
135
//void SizeShapeBorderCmd::UnExecute() {
 
136
//      Command::UnExecute();
 
137
//      Point pt;
 
138
//      shape->UpdateSize(oldWidth, oldHeight);
 
139
//      pt.x = oldTopLeft.x + oldWidth/2;
 
140
//      pt.y = oldTopLeft.y + oldHeight/2;
 
141
//      shape->UpdatePosition(&pt);
 
142
//      shape->GetView()->GetViewer()->ShapePositionUpdate(shape);      
 
143
//}