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

« back to all changes in this revision

Viewing changes to backend/wbpublic/wbcanvas/note_figure.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
#include "stdafx.h"
 
20
 
 
21
#include "note_figure.h"
 
22
 
 
23
using namespace wbfig;
 
24
using namespace MySQL::Geometry;
 
25
using namespace MySQL::Drawing;
 
26
 
 
27
Note::Note(mdc::Layer *layer, FigureEventHub *hub, const model_ObjectRef &self)
 
28
: BaseFigure(layer, hub, self), _text(layer)
 
29
{
 
30
  set_allowed_resizing(true, true);
 
31
  set_accepts_focus(true);
 
32
  set_accepts_selection(true);
 
33
  set_auto_sizing(true);
 
34
 
 
35
  set_border_color(Color(0.5, 0.5, 0.5, 0.2));
 
36
  set_background_color(Color::White());
 
37
  set_draw_background(true);
 
38
 
 
39
  _text.set_padding(8, 8);
 
40
  _text.set_font(mdc::FontSpec(DEFAULT_FONT_FACE, mdc::SNormal, mdc::WNormal, 11));
 
41
  _text.set_pen_color(Color::Black());
 
42
  _text.set_multi_line(true);
 
43
 
 
44
  add(&_text, false, false, true);
 
45
}
 
46
 
 
47
 
 
48
Note::~Note()
 
49
{
 
50
}
 
51
 
 
52
 
 
53
void Note::set_text(const std::string &text)
 
54
{
 
55
  _text.set_text(text);
 
56
  set_needs_relayout();
 
57
}
 
58
 
 
59
 
 
60
void Note::set_text_color(const Color &color)
 
61
{
 
62
  _text.set_pen_color(color);
 
63
}
 
64
 
 
65
 
 
66
void Note::set_content_font(const mdc::FontSpec &font)
 
67
{
 
68
  _text.set_font(font);
 
69
  set_needs_relayout();
 
70
}
 
71
 
 
72
//--------------------------------------------------------------------------------------------------
 
73
 
 
74
bool Note::on_click(mdc::CanvasItem *target, const Point &point, mdc::MouseButton button, mdc::EventState state)
 
75
{
 
76
  if (!_hub->figure_click(represented_object(), target, point, button, state))
 
77
    return super::on_click(target, point, button, state);
 
78
  return false;
 
79
}
 
80
 
 
81
//--------------------------------------------------------------------------------------------------
 
82
 
 
83
bool Note::on_double_click(mdc::CanvasItem *target, const Point &point, mdc::MouseButton button, mdc::EventState state)
 
84
{
 
85
  if (!_hub->figure_double_click(represented_object(), target, point, button, state))
 
86
    return super::on_double_click(target, point, button, state);
 
87
  return false;
 
88
}
 
89
 
 
90
//--------------------------------------------------------------------------------------------------