2
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
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
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.
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
22
#include "mforms/table.h"
30
class TableImpl : public ViewImpl
34
virtual Gtk::Widget *get_outer() const { return _table; }
36
TableImpl(::mforms::Table *self)
39
_table= Gtk::manage(new Gtk::Table());
43
static bool create(::mforms::Table *self)
45
return new TableImpl(self);
49
static void set_row_count(Table *self, int count)
51
TableImpl *table= self->get_data<TableImpl>();
53
table->_table->property_n_rows()= count;
57
static void set_col_count(Table *self, int count)
59
TableImpl *table= self->get_data<TableImpl>();
61
table->_table->property_n_columns()= count;
65
static void add(Table *self, View *child, int left, int right,
66
int top, int bottom, int flags)
68
TableImpl *table= self->get_data<TableImpl>();
69
Gtk::AttachOptions roptions= (Gtk::AttachOptions)0, coptions= (Gtk::AttachOptions)0;
71
roptions= Gtk::SHRINK;
72
coptions= Gtk::SHRINK;
74
if (flags & mforms::VExpandFlag)
75
roptions|= Gtk::EXPAND;
76
if (flags & mforms::VFillFlag)
79
if (flags & mforms::HExpandFlag)
80
coptions|= Gtk::EXPAND;
81
if (flags & mforms::HFillFlag)
84
table->_table->attach(*child->get_data<ViewImpl>()->get_outer(),
85
left, right, top, bottom,
90
static void remove(Table *self, View *child)
92
TableImpl *table= self->get_data<TableImpl>();
94
table->_table->remove(*child->get_data<ViewImpl>()->get_outer());
97
static void set_row_spacing(Table *self, int space)
99
TableImpl *table= self->get_data<TableImpl>();
101
table->_table->set_row_spacings(space);
105
static void set_col_spacing(Table *self, int space)
107
TableImpl *table= self->get_data<TableImpl>();
109
table->_table->set_col_spacings(space);
112
static void set_homogeneous(Table *self, bool flag)
114
TableImpl *table= self->get_data<TableImpl>();
116
table->_table->set_homogeneous(flag);
119
virtual void set_padding_impl(int left, int top, int right, int bottom)
121
_table->set_border_width(left);
127
::mforms::ControlFactory *f = ::mforms::ControlFactory::get_instance();
129
f->_table_impl.create= &TableImpl::create;
130
f->_table_impl.set_row_count= &TableImpl::set_row_count;
131
f->_table_impl.set_column_count= &TableImpl::set_col_count;
132
f->_table_impl.add= &TableImpl::add;
133
f->_table_impl.remove= &TableImpl::remove;
134
f->_table_impl.set_row_spacing= &TableImpl::set_row_spacing;
135
f->_table_impl.set_column_spacing= &TableImpl::set_col_spacing;
136
f->_table_impl.set_homogeneous= &TableImpl::set_homogeneous;
148
#endif /* _LF_TABLE_H_ */