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

« back to all changes in this revision

Viewing changes to library/forms/gtk/src/lf_splitter.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) 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 "../lf_mforms.h"
 
21
#include "../lf_splitter.h"
 
22
 
 
23
mforms::gtk::SplitterImpl::SplitterImpl(::mforms::Splitter *self, bool horiz)
 
24
  : ViewImpl(self)
 
25
{
 
26
  if (horiz)
 
27
    _paned= new Gtk::HPaned();
 
28
  else
 
29
    _paned= new Gtk::VPaned();
 
30
  _paned->show();
 
31
}
 
32
 
 
33
bool mforms::gtk::SplitterImpl::create(::mforms::Splitter *self, bool horiz)
 
34
{
 
35
  return new SplitterImpl(self, horiz);
 
36
}
 
37
 
 
38
void mforms::gtk::SplitterImpl::add(Splitter *self, View *child, int minwidth)
 
39
{
 
40
  SplitterImpl *splitview= self->get_data<SplitterImpl>();
 
41
 
 
42
  if (!splitview->_paned->get_child1())
 
43
    splitview->_paned->pack1(*child->get_data<ViewImpl>()->get_outer(), true, true);
 
44
  else
 
45
    splitview->_paned->pack2(*child->get_data<ViewImpl>()->get_outer(), true, true);
 
46
}
 
47
 
 
48
void mforms::gtk::SplitterImpl::remove(Splitter *self, View *child)
 
49
{
 
50
  SplitterImpl *splitview= self->get_data<SplitterImpl>();
 
51
 
 
52
  splitview->_paned->remove(*child->get_data<ViewImpl>()->get_outer());
 
53
}
 
54
 
 
55
void mforms::gtk::SplitterImpl::set_position(Splitter *self, int pos)
 
56
{
 
57
  SplitterImpl *splitview= self->get_data<SplitterImpl>();
 
58
  
 
59
  splitview->_paned->set_position(pos);
 
60
}
 
61
 
 
62
int mforms::gtk::SplitterImpl::get_position(Splitter *self)
 
63
{
 
64
  SplitterImpl *splitview= self->get_data<SplitterImpl>();
 
65
  
 
66
  return splitview->_paned->get_position();
 
67
}
 
68
 
 
69
void mforms::gtk::SplitterImpl::set_expanded(Splitter *self, bool first, bool expand)
 
70
{
 
71
  SplitterImpl *sv = self->get_data<SplitterImpl>();
 
72
 
 
73
  if (sv && sv->_paned)
 
74
  {
 
75
    Gtk::Widget* child = first ? sv->_paned->get_child1() : sv->_paned->get_child2();
 
76
    if (child)
 
77
    {
 
78
      if (expand)
 
79
        child->show();
 
80
      else
 
81
        child->hide();
 
82
    }
 
83
  }
 
84
}
 
85
 
 
86
void mforms::gtk::SplitterImpl::init()
 
87
{
 
88
  ::mforms::ControlFactory *f = ::mforms::ControlFactory::get_instance();
 
89
 
 
90
  f->_splitter_impl.create= &SplitterImpl::create;
 
91
  f->_splitter_impl.add= &SplitterImpl::add;
 
92
  f->_splitter_impl.remove= &SplitterImpl::remove;
 
93
  f->_splitter_impl.set_position= &SplitterImpl::set_position;
 
94
  f->_splitter_impl.get_position= &SplitterImpl::get_position;
 
95
  f->_splitter_impl.set_expanded= &SplitterImpl::set_expanded;
 
96
}
 
97
 
 
98
mforms::gtk::SplitterImpl::~SplitterImpl()
 
99
{
 
100
  delete _paned;
 
101
}