ManaPlus
layoutarray.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2007-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef GUI_WIDGETS_LAYOUTARRAY_H
25 #define GUI_WIDGETS_LAYOUTARRAY_H
26 
27 #include "utils/vector.h"
28 
29 #include "localconsts.h"
30 
31 class LayoutCell;
32 class Widget;
33 
38 {
39  friend class LayoutCell;
40 
41  public:
42  LayoutArray();
43 
45 
46  ~LayoutArray();
47 
51  LayoutCell &at(const int x,
52  const int y,
53  const int w,
54  const int h) A_WARN_UNUSED;
55 
63  LayoutCell &place(Widget *const widget,
64  const int x,
65  const int y,
66  const int w,
67  const int h);
68 
72  void setColWidth(const int n, const int w);
73 
77  void setRowHeight(const int n, const int h);
78 
82  void matchColWidth(const int n1, const int n2);
83 
87  void extend(const int x, const int y, const int w, const int h);
88 
94  void reflow(const int nX, const int nY, const int nW, const int nH);
95 
96  private:
97  // Copy not allowed, as the array owns all its cells.
98  explicit LayoutArray(LayoutArray const &);
100 
104  void align(int &restrict pos,
105  int &restrict size,
106  const int dim,
107  LayoutCell const &restrict cell,
108  const int *restrict const sizes,
109  const int sizeCount) const A_NONNULL(6);
110 
114  void resizeGrid(int w, const int h);
115 
120  STD_VECTOR<int> getSizes(const int dim, int upp) const A_WARN_UNUSED;
121 
125  int getSize(const int dim) const A_WARN_UNUSED;
126 
127  STD_VECTOR<int> mSizes[2];
128  STD_VECTOR< STD_VECTOR < LayoutCell * > > mCells;
129 
130  int mSpacing;
131 };
132 
133 #endif // GUI_WIDGETS_LAYOUTARRAY_H
std::vector< std::vector< LayoutCell * > > mCells
Definition: layoutarray.h:128
void resizeGrid(int w, const int h)
Definition: layoutarray.cpp:70
void extend(const int x, const int y, const int w, const int h)
int getSize(const int dim) const
LayoutArray(LayoutArray const &)
void align(int &pos, int &size, const int dim, LayoutCell const &cell, const int *const sizes, const int sizeCount) const
LayoutArray & operator=(LayoutArray const &)
void setColWidth(const int n, const int w)
void matchColWidth(const int n1, const int n2)
void setRowHeight(const int n, const int h)
std::vector< int > getSizes(const int dim, int upp) const
LayoutCell & at(const int x, const int y, const int w, const int h)
Definition: layoutarray.cpp:60
LayoutCell & place(Widget *const widget, const int x, const int y, const int w, const int h)
void reflow(const int nX, const int nY, const int nW, const int nH)
std::vector< int > mSizes[2]
Definition: layoutarray.h:127
Definition: widget.h:99
#define restrict
Definition: localconsts.h:165
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define final
Definition: localconsts.h:46
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:41
int size()
Definition: emotedb.cpp:306