ManaPlus
layoutcell.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-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef GUI_WIDGETS_LAYOUTCELL_H
24 #define GUI_WIDGETS_LAYOUTCELL_H
25 
26 #include "localconsts.h"
27 
28 class LayoutArray;
29 class Widget;
30 
39 {
40  friend class Layout;
41  friend class LayoutArray;
42 
43  public:
45 
46  enum Alignment
47  {
48  LEFT = 0,
52  };
53 
54  virtual ~LayoutCell();
55 
60  { mHPadding = p; mVPadding = p; return *this; }
61 
62  int getVPadding() const
63  { return mVPadding; }
64 
65  int getHPadding() const
66  { return mHPadding; }
67 
72  { mVPadding = p; return *this; }
73 
78  { mHPadding = p; return *this; }
79 
84  { mAlign[0] = a; return *this; }
85 
90  { mAlign[1] = a; return *this; }
91 
95  LayoutCell &at(const int x, const int y) A_WARN_UNUSED;
96 
100  LayoutCell &place(Widget *const wg,
101  const int x,
102  const int y,
103  const int w,
104  const int h);
105 
109  void matchColWidth(const int n1, const int n2);
110 
114  void setColWidth(const int n, const int w);
115 
119  void setRowHeight(const int n, const int h);
120 
124  void extend(const int x, const int y,
125  const int w, const int h);
126 
131  void computeSizes();
132 
133  void setType(int t)
134  { mType = t; }
135 
136  int getWidth() const noexcept2 A_WARN_UNUSED
137  { return mExtent[0]; }
138 
139  int getHeight() const noexcept2 A_WARN_UNUSED
140  { return mExtent[1]; }
141 
142  void setWidth(const int w) noexcept2
143  { mExtent[0] = w; }
144 
145  void setHeight(const int h) noexcept2
146  { mExtent[1] = h; }
147 
148  enum
149  {
150  NONE = 0,
153  };
154 
156 
157  private:
159  mWidget(nullptr),
160  mHPadding(0),
161  mVPadding(0),
162  mType(NONE)
163  {
164  mExtent[0] = 0;
165  mExtent[1] = 0;
166  mAlign[0] = LEFT;
167  mAlign[1] = LEFT;
168  mNbFill[0] = 0;
169  mNbFill[1] = 0;
170  mSize[0] = 0;
171  mSize[1] = 0;
172  }
173 
174  // Copy not allowed, as the cell may own an array.
175  explicit LayoutCell(LayoutCell const &);
176  LayoutCell &operator=(LayoutCell const &);
177 
178  union
179  {
182  };
183 
189 
193  void reflow(int nx, int ny, int nw, int nh);
194 
195  int mSize[2];
198  int mExtent[2];
200  int mNbFill[2];
201  int mType;
202 };
203 
204 #endif // GUI_WIDGETS_LAYOUTCELL_H
void matchColWidth(const int n1, const int n2)
Definition: layoutcell.cpp:117
int mHPadding
Definition: layoutcell.h:196
LayoutCell & setVAlign(const Alignment a)
Definition: layoutcell.h:89
LayoutArray & getArray()
Definition: layoutcell.cpp:41
LayoutCell & setHPadding(int p)
Definition: layoutcell.h:77
void reflow(int nx, int ny, int nw, int nh)
Definition: layoutcell.cpp:63
void extend(const int x, const int y, const int w, const int h)
Definition: layoutcell.cpp:132
#define A_WARN_UNUSED
Definition: localconsts.h:160
static LayoutCell emptyCell
Definition: layoutcell.h:155
int mVPadding
Definition: layoutcell.h:197
void setColWidth(const int n, const int w)
Definition: layoutcell.cpp:122
int mNbFill[2]
Definition: layoutcell.h:200
void setHeight(const int h)
Definition: layoutcell.h:145
LayoutCell & setVPadding(int p)
Definition: layoutcell.h:71
Widget * mWidget
Definition: layoutcell.h:180
int mSize[2]
Definition: layoutcell.h:195
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:40
int getVPadding() const
Definition: layoutcell.h:62
virtual ~LayoutCell()
Definition: layoutcell.cpp:35
void setType(int t)
Definition: layoutcell.h:133
int mExtent[2]
Definition: layoutcell.h:198
int getHPadding() const
Definition: layoutcell.h:65
LayoutCell & at(const int x, const int y)
Definition: layoutcell.cpp:105
#define notfinal
Definition: localconsts.h:260
#define nullptr
Definition: localconsts.h:44
LayoutCell & setPadding(int p)
Definition: layoutcell.h:59
void computeSizes()
Definition: layoutcell.cpp:78
LayoutArray * mArray
Definition: layoutcell.h:181
Definition: widget.h:97
Alignment mAlign[2]
Definition: layoutcell.h:199
int getHeight() const
Definition: layoutcell.h:139
int getWidth() const
Definition: layoutcell.h:136
void setWidth(const int w)
Definition: layoutcell.h:142
LayoutCell & place(Widget *const wg, const int x, const int y, const int w, const int h)
Definition: layoutcell.cpp:110
LayoutCell & operator=(LayoutCell const &)
LayoutCell & setHAlign(const Alignment a)
Definition: layoutcell.h:83
Definition: layout.h:43
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
#define noexcept2
Definition: localconsts.h:49