File: routine_group_figure.cpp

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (128 lines) | stat: -rw-r--r-- 3,653 bytes parent folder | download | duplicates (2)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* 
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
 *
 * 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; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#include "routine_group_figure.h"

using namespace wbfig;
using namespace base;

RoutineGroup::RoutineGroup(mdc::Layer *layer, FigureEventHub *hub, const model_ObjectRef &self)
: BaseFigure(layer, hub, self), _title(layer, hub, this, true), _footer(layer, hub, this, false),
  _content_box(layer, mdc::Box::Vertical)
{
  _title.set_icon(mdc::ImageManager::get_instance()->get_image("workbench.physical.RoutineGroupFigure.16x16.png"));

  scoped_connect(_title.signal_expand_toggle(),boost::bind(&RoutineGroup::toggle, this, _1));

  set_allowed_resizing(false, false);
  set_accepts_focus(true);
  set_accepts_selection(true);

  set_border_color(Color(0.5, 0.5, 0.5));
  set_draw_background(true);
  set_background_color(Color::White());
  set_background_corners(mdc::CAll, 8.0);

  _title.set_rounded(mdc::CTop);
  _title.set_draggable(true);
  _title.set_expanded(true);
  _title.set_has_shadow(true);
  _title.set_title("View");
  _title.set_font(mdc::FontSpec("Helvetica", mdc::SNormal, mdc::WBold, 12));
  _title.set_color(Color(0.59, 0.85, 0.59));
  add(&_title, false, false, true);

  _content_box.set_spacing(1);
  add(&_content_box, true, true, true);

  _footer.set_rounded(mdc::CBottom);
  _footer.set_draggable(true);
  _footer.set_expanded(true);
  _footer.set_has_shadow(true);
  _footer.set_title("0 routines");
  _footer.set_font(mdc::FontSpec("Helvetica", mdc::SNormal, mdc::WNormal, 9));
  _footer.set_text_color(Color(0.5, 0.5, 0.5));
  _footer.set_color(Color(0.59, 0.85, 0.59));
  add(&_footer, false, false, true);
}


RoutineGroup::~RoutineGroup()
{
  for (ItemList::iterator i= _routines.begin(); i != _routines.end(); ++i)
    delete *i;
}


void RoutineGroup::set_title(const std::string &title, const std::string &subtitle)
{
  _title.set_title(title);
  _footer.set_title(subtitle);
}


void RoutineGroup::set_title_font(const mdc::FontSpec &font)
{
  _title.set_font(font);
}


void RoutineGroup::set_content_font(const mdc::FontSpec &font)
{
  super::set_content_font(font);

  for (ItemList::iterator i= _routines.begin(); i != _routines.end(); ++i)
    (*i)->set_font(font);
}


void RoutineGroup::set_color(const Color &color)
{
  _title.set_color(color);
  _footer.set_color(color);
  set_needs_render();
}


void RoutineGroup::toggle(bool flag)
{
  _title.set_expanded(flag);
  _content_box.set_visible(flag);
}



RoutineGroup::ItemList::iterator RoutineGroup::begin_routines_sync()
{
  return begin_sync(_content_box, _routines);
}


RoutineGroup::ItemList::iterator RoutineGroup::sync_next_routine(ItemList::iterator iter,
                                                  const std::string &id,
                                                  const std::string &text)
{
  return sync_next(_content_box, _routines, iter, id, 0, text);
}


void RoutineGroup::end_routines_sync(ItemList::iterator iter)
{
  end_sync(_content_box, _routines, iter);
}