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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/*
* Copyright (c) 2008, 2010, 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
*/
#ifndef _LF_TABLE_H_
#define _LF_TABLE_H_
#include "mforms/table.h"
#include "lf_view.h"
namespace mforms {
namespace gtk {
class TableImpl : public ViewImpl
{
protected:
Gtk::Table *_table;
virtual Gtk::Widget *get_outer() const { return _table; }
TableImpl(::mforms::Table *self)
: ViewImpl(self)
{
_table= Gtk::manage(new Gtk::Table());
_table->show();
}
static bool create(::mforms::Table *self)
{
return new TableImpl(self);
}
static void set_row_count(Table *self, int count)
{
TableImpl *table= self->get_data<TableImpl>();
table->_table->property_n_rows()= count;
}
static void set_col_count(Table *self, int count)
{
TableImpl *table= self->get_data<TableImpl>();
table->_table->property_n_columns()= count;
}
static void add(Table *self, View *child, int left, int right,
int top, int bottom, int flags)
{
TableImpl *table= self->get_data<TableImpl>();
Gtk::AttachOptions roptions= (Gtk::AttachOptions)0, coptions= (Gtk::AttachOptions)0;
roptions= Gtk::SHRINK;
coptions= Gtk::SHRINK;
if (flags & mforms::VExpandFlag)
roptions|= Gtk::EXPAND;
if (flags & mforms::VFillFlag)
roptions|= Gtk::FILL;
if (flags & mforms::HExpandFlag)
coptions|= Gtk::EXPAND;
if (flags & mforms::HFillFlag)
coptions|= Gtk::FILL;
table->_table->attach(*child->get_data<ViewImpl>()->get_outer(),
left, right, top, bottom,
coptions, roptions);
child->show();
}
static void remove(Table *self, View *child)
{
TableImpl *table= self->get_data<TableImpl>();
table->_table->remove(*child->get_data<ViewImpl>()->get_outer());
}
static void set_row_spacing(Table *self, int space)
{
TableImpl *table= self->get_data<TableImpl>();
table->_table->set_row_spacings(space);
}
static void set_col_spacing(Table *self, int space)
{
TableImpl *table= self->get_data<TableImpl>();
table->_table->set_col_spacings(space);
}
static void set_homogeneous(Table *self, bool flag)
{
TableImpl *table= self->get_data<TableImpl>();
table->_table->set_homogeneous(flag);
}
virtual void set_padding_impl(int left, int top, int right, int bottom)
{
_table->set_border_width(left);
}
public:
static void init()
{
::mforms::ControlFactory *f = ::mforms::ControlFactory::get_instance();
f->_table_impl.create= &TableImpl::create;
f->_table_impl.set_row_count= &TableImpl::set_row_count;
f->_table_impl.set_column_count= &TableImpl::set_col_count;
f->_table_impl.add= &TableImpl::add;
f->_table_impl.remove= &TableImpl::remove;
f->_table_impl.set_row_spacing= &TableImpl::set_row_spacing;
f->_table_impl.set_column_spacing= &TableImpl::set_col_spacing;
f->_table_impl.set_homogeneous= &TableImpl::set_homogeneous;
}
virtual ~TableImpl()
{
}
};
}
}
#endif /* _LF_TABLE_H_ */
|