~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to library/canvas/src/mdc_vertex_handle.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; version 2 of the
 
7
 * License.
 
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., 51 Franklin St, Fifth Floor, Boston, MA
 
17
 * 02110-1301  USA
 
18
 */
 
19
 
 
20
#include "stdafx.h"
 
21
 
 
22
#include "mdc_vertex_handle.h"
 
23
 
 
24
using namespace mdc;
 
25
using namespace MySQL::Geometry;
 
26
using namespace MySQL::Drawing;
 
27
 
 
28
VertexHandle::VertexHandle(InteractionLayer *ilayer, CanvasItem *item, const Point &pos, bool connectable)
 
29
: ItemHandle(ilayer, item, pos), _connectable(connectable)
 
30
{
 
31
}
 
32
 
 
33
 
 
34
VertexHandle::~VertexHandle()
 
35
{
 
36
}
 
37
 
 
38
 
 
39
void VertexHandle::repaint(CairoCtx *cr)
 
40
{
 
41
  Rect r= get_bounds();
 
42
  
 
43
  cr->set_color(Color(1, 1, 1, 0.8));
 
44
  cr->set_line_width(1);
 
45
  if (_connectable)
 
46
  {
 
47
    cr->move_to(r.left() + r.width()/2, r.top());
 
48
    cr->line_to(r.left(), r.top() + r.height()/2);
 
49
    cr->line_to(r.left() + r.width()/2, r.bottom());
 
50
    cr->line_to(r.right(), r.top() + r.height()/2);
 
51
    cr->close_path();
 
52
  }
 
53
  else
 
54
  {
 
55
    cr->rectangle(r);
 
56
  }
 
57
  cr->fill_preserve();
 
58
  
 
59
  if (_highlighted)
 
60
    cr->set_color(Color(0, 1, 1, 1));
 
61
  else
 
62
    cr->set_color(Color(0.0, 0.0, 0.9, 1));
 
63
  cr->stroke();
 
64
}
 
65
 
 
66
 
 
67
Rect VertexHandle::get_bounds() const
 
68
{
 
69
  Rect r;
 
70
  r.pos.x= _pos.x - 4.5;
 
71
  r.pos.y= _pos.y - 4.5;
 
72
  r.size.width= 9;
 
73
  r.size.height= 9;
 
74
  return r;
 
75
}
 
76