]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/grid.h
Add some classes for automatically creating basic layouts
[libs/gltk.git] / source / grid.h
diff --git a/source/grid.h b/source/grid.h
new file mode 100644 (file)
index 0000000..789672a
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2011  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GLTK_GRID_H_
+#define MSP_GLTK_GRID_H_
+
+#include "layout.h"
+
+namespace Msp {
+namespace GLtk {
+
+/**
+Arranges widgets in a grid.
+
+This layout class places widgets in a grid, lining up their edges in rows and
+columns.  Widgets are placed on rows left-to-right and rows are placed top-to-
+bottom.
+
+The start of each row must be indicated manually.  Individual cells can be
+skipped to leave them empty.
+*/
+class Grid: public Layout
+{
+private:
+       bool uniform;
+       std::vector<Slot *> columns;
+       unsigned cur_column;
+       bool first;
+       bool skipped;
+
+public:
+       Grid(bool = false);
+
+       void start_row();
+       void skip_cell();
+
+private:
+       Slot *create_slot(Widget &);
+};
+
+} // namespace GLtk
+} // namespace Msp
+
+#endif