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 
66  { mVPadding = p; return *this; }
67 
72  { mHPadding = p; return *this; }
73 
78  { mAlign[0] = a; return *this; }
79 
84  { mAlign[1] = a; return *this; }
85 
89  LayoutCell &at(const int x, const int y) A_WARN_UNUSED;
90 
94  LayoutCell &place(Widget *const wg,
95  const int x,
96  const int y,
97  const int w,
98  const int h);
99 
103  void matchColWidth(const int n1, const int n2);
104 
108  void setColWidth(const int n, const int w);
109 
113  void setRowHeight(const int n, const int h);
114 
118  void extend(const int x, const int y,
119  const int w, const int h);
120 
125  void computeSizes();
126 
127  void setType(int t)
128  { mType = t; }
129 
130  int getWidth() const noexcept2 A_WARN_UNUSED
131  { return mExtent[0]; }
132 
133  int getHeight() const noexcept2 A_WARN_UNUSED
134  { return mExtent[1]; }
135 
136  void setWidth(const int w) noexcept2
137  { mExtent[0] = w; }
138 
139  void setHeight(const int h) noexcept2
140  { mExtent[1] = h; }
141 
142  enum
143  {
144  NONE = 0,
147  };
148 
150 
151  private:
153  mWidget(nullptr),
154  mHPadding(0),
155  mVPadding(0),
156  mType(NONE)
157  {
158  mExtent[0] = 0;
159  mExtent[1] = 0;
160  mAlign[0] = LEFT;
161  mAlign[1] = LEFT;
162  mNbFill[0] = 0;
163  mNbFill[1] = 0;
164  mSize[0] = 0;
165  mSize[1] = 0;
166  }
167 
168  // Copy not allowed, as the cell may own an array.
169  explicit LayoutCell(LayoutCell const &);
170  LayoutCell &operator=(LayoutCell const &);
171 
172  union
173  {
176  };
177 
183 
187  void reflow(int nx, int ny, int nw, int nh);
188 
189  int mSize[2];
192  int mExtent[2];
194  int mNbFill[2];
195  int mType;
196 };
197 
198 #endif // GUI_WIDGETS_LAYOUTCELL_H
void matchColWidth(const int n1, const int n2)
Definition: layoutcell.cpp:117
int mHPadding
Definition: layoutcell.h:190
LayoutCell & setVAlign(const Alignment a)
Definition: layoutcell.h:83
LayoutArray & getArray()
Definition: layoutcell.cpp:41
LayoutCell & setHPadding(int p)
Definition: layoutcell.h:71
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:172
static LayoutCell emptyCell
Definition: layoutcell.h:149
int mVPadding
Definition: layoutcell.h:191
void setColWidth(const int n, const int w)
Definition: layoutcell.cpp:122
int mNbFill[2]
Definition: layoutcell.h:194
void setHeight(const int h)
Definition: layoutcell.h:139
LayoutCell & setVPadding(int p)
Definition: layoutcell.h:65
Widget * mWidget
Definition: layoutcell.h:174
int mSize[2]
Definition: layoutcell.h:189
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:40
virtual ~LayoutCell()
Definition: layoutcell.cpp:35
void setType(int t)
Definition: layoutcell.h:127
int mExtent[2]
Definition: layoutcell.h:192
LayoutCell & at(const int x, const int y)
Definition: layoutcell.cpp:105
#define notfinal
Definition: localconsts.h:289
#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:175
Definition: widget.h:97
Alignment mAlign[2]
Definition: layoutcell.h:193
int getHeight() const
Definition: layoutcell.h:133
int getWidth() const
Definition: layoutcell.h:130
void setWidth(const int w)
Definition: layoutcell.h:136
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:77
Definition: layout.h:43
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
#define noexcept2
Definition: localconsts.h:49