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

« back to all changes in this revision

Viewing changes to backend/wbprivate/model/relationship_canvas_floater.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, 2010, 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 "relationship_canvas_floater.h"
 
23
#include "model/wb_model_diagram_form.h"
 
24
#include "base/string_utilities.h"
 
25
 
 
26
using namespace wb;
 
27
using namespace MySQL::Geometry;
 
28
using namespace MySQL::Drawing;
 
29
 
 
30
RelationshipFloater::RelationshipFloater(ModelDiagramForm *view)
 
31
: Floater(view->get_floater_layer(), _("Foreign Key Columns")), _columns_box(view->get_floater_layer(), mdc::Box::Vertical, true),
 
32
  _text(view->get_floater_layer()), _button(view->get_floater_layer())
 
33
{
 
34
  _text.set_multi_line(true);
 
35
  _text.set_pen_color(Color(0.8, 0.8, 0.8));
 
36
  _text.set_font(mdc::FontSpec("Helvetica", mdc::SNormal, mdc::WNormal, 11));
 
37
  _columns_box.set_spacing(4);
 
38
  _content_box.set_spacing(8);
 
39
  _content_box.add(&_columns_box, false, false);
 
40
  _content_box.add(&_text, false, false);
 
41
  _content_box.add(&_button, false, false);
 
42
 
 
43
  setup_pick_source();
 
44
 
 
45
  _content_box.set_needs_relayout();
 
46
}
 
47
 
 
48
 
 
49
RelationshipFloater::~RelationshipFloater()
 
50
{
 
51
  for (std::vector<mdc::TextFigure*>::iterator iter= _columns.begin(); iter != _columns.end(); ++iter)
 
52
    delete *iter;
 
53
  _columns.clear();
 
54
}
 
55
 
 
56
void RelationshipFloater::setup_pick_source()
 
57
{
 
58
  set_title(_("Foreign Key Columns"));
 
59
  _text.set_text(_("Pick one or more columns\nfor the foreign key."));
 
60
  //_text.set_needs_relayout();
 
61
  //set_needs_relayout();
 
62
 
 
63
  _button.set_text(_("Pick Referenced Columns"));
 
64
}
 
65
 
 
66
 
 
67
void RelationshipFloater::add_column(const std::string &name)
 
68
{
 
69
  mdc::TextFigure *text= new mdc::TextFigure(get_layer());
 
70
  text->set_text(name);
 
71
  text->set_pen_color(Color::White());
 
72
 
 
73
  _columns.push_back(text);
 
74
 
 
75
  _columns_box.add(text, false, false);
 
76
}
 
77
 
 
78
 
 
79
void RelationshipFloater::setup_pick_target()
 
80
{
 
81
  set_title(_("Referenced Columns"));
 
82
  _text.set_text(_("Pick matching columns for\nthe referenced table."));
 
83
 
 
84
  _button.set_visible(false);
 
85
 
 
86
  _current_column= 0;
 
87
 
 
88
  mdc::FontSpec font(_columns[_current_column]->get_font());
 
89
  font.toggle_bold(true);
 
90
  _columns[_current_column]->set_font(font);
 
91
}
 
92
 
 
93
 
 
94
void RelationshipFloater::pick_next_target()
 
95
{
 
96
  mdc::FontSpec font(_columns[_current_column]->get_font());
 
97
 
 
98
  font.toggle_bold(true);
 
99
  _columns[_current_column]->set_font(font);
 
100
 
 
101
  _current_column++;
 
102
  if (_current_column < _columns.size())
 
103
  {
 
104
    font.toggle_bold(false);
 
105
    _columns[_current_column]->set_font(font);
 
106
  }
 
107
}