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
|
/*
* Copyright (c) 2008, 2013, 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
*/
#pragma once
#include <mforms/base.h>
#include <mforms/container.h>
namespace mforms {
class Table;
enum TableItemFlags
{
NoFillExpandFlag = 0, //!< Neither expand nor fill.
VExpandFlag = (1 << 0), //!< whether item should try using vertical space leftover from table
HExpandFlag = (1 << 1), //!< same for horizontal expansion
VFillFlag = (1 << 2), //!< whether all allocated vertical space should be filled, or just centered in it
HFillFlag = (1 << 3), //!< same for horizontal filling
FillAndExpand = HFillFlag | VFillFlag | VExpandFlag | HExpandFlag,
};
inline TableItemFlags operator| (TableItemFlags a, TableItemFlags b)
{
return (TableItemFlags)((int)a|(int)b);
}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef SWIG
struct MFORMS_EXPORT TableImplPtrs
{
bool (*create)(Table*);
void (*set_row_count)(Table *self, int);
void (*set_column_count)(Table *self, int);
void (*add)(Table *self,View*, int, int, int, int, int);
void (*remove)(Table *self, View*);
void (*set_row_spacing)(Table *self, int);
void (*set_column_spacing)(Table *self, int);
void (*set_homogeneous)(Table *self, bool);
};
#endif
#endif
/** Container to layout child items in a grid of rows and columns.
*/
class MFORMS_EXPORT Table : public Container
{
public:
Table();
/** Sets number of rows */
void set_row_count(int c);
/** Sets number of columns */
void set_column_count(int c);
/** Sets spacing between rows. */
void set_row_spacing(int s);
/** Sets spacing between columns. */
void set_column_spacing(int s);
/** Sets whether sizing of table children should be equal among items */
void set_homogeneous(bool value);
/** Adds an item to the table.
@param left - left column to put the item in
@param right - column that the item ends at (ie at least left+1)
@param top - top row to put the item in
@param bottom - row that the item ends at (ie at least top+1)
@param flags -
*/
void add(View *subview, int left, int right, int top, int bottom, int flags= HExpandFlag | VExpandFlag | HFillFlag | VFillFlag);
/** Remove a child item from the table */
virtual void remove(View *sv);
protected:
TableImplPtrs *_table_impl;
};
};
|