This file is indexed.

/usr/include/simgear/canvas/layout/LayoutItem.hxx is in libsimgear-dev 3.4.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
///@file
/// Basic element for layouting canvas elements.
//
// Copyright (C) 2014  Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA

#ifndef SG_CANVAS_LAYOUT_ITEM_HXX_
#define SG_CANVAS_LAYOUT_ITEM_HXX_

#include <simgear/canvas/canvas_fwd.hxx>
#include <simgear/math/SGMath.hxx>
#include <simgear/math/SGRect.hxx>
#include <simgear/misc/stdint.hxx>
#include <simgear/structure/SGWeakReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>

namespace simgear
{
namespace canvas
{
  class LayoutItem;
  typedef SGSharedPtr<LayoutItem> LayoutItemRef;
  typedef SGWeakPtr<LayoutItem> LayoutItemWeakRef;

  /**
   * Holds the four margins for a rectangle.
   */
  struct Margins
  {
    int l, t, r, b;

    /**
     * Set all margins to the same value @a m.
     */
    explicit Margins(int m = 0);

    /**
     * Set horizontal and vertical margins to the same values @a h and @a v
     * respectively.
     *
     * @param h Horizontal margins
     * @param v Vertical margins
     */
    Margins(int h, int v);

    /**
     * Set the margins to the given values.
     */
    Margins(int left, int top, int right, int bottom);

    /**
     * Get the total horizontal margin (sum of left and right margin).
     */
    int horiz() const;

    /**
     * Get the total vertical margin (sum of top and bottom margin).
     */
    int vert() const;

    /**
     * Get total horizontal and vertical margin as vector.
     */
    SGVec2i size() const;

    /**
     * Returns true if all margins are 0.
     */
    bool isNull() const;
  };

  /**
   * Flags for LayoutItem alignment inside {@link Layout Layouts}.
   *
   * @note You can only use one horizontal and one vertical flag at the same.
   */
  enum AlignmentFlag
  {
#define ALIGN_ENUM_MAPPING(key, val, comment) key = val, /*!< comment */
#  include "AlignFlag_values.hxx"
#undef ALIGN_ENUM_MAPPING
  };

  /**
   * Base class for all layouting elements. Specializations either implement a
   * layouting algorithm or a widget.
   */
  class LayoutItem:
    public virtual SGVirtualWeakReferenced
  {
    public:

      /** Maximum item size (indicating no limit) */
      static const SGVec2i MAX_SIZE;

      LayoutItem();
      virtual ~LayoutItem();

      /**
       * Set the margins to use by the layout system around the item.
       *
       * The margins define the size of the clear area around an item. It
       * increases the size hints and reduces the size of the geometry()
       * available to child layouts and widgets.
       *
       * @see Margins
       */
      void setContentsMargins(const Margins& margins);

      /**
       * Set the individual margins.
       *
       * @see setContentsMargins(const Margins&)
       */
      void setContentsMargins(int left, int top, int right, int bottom);

      /**
       * Set all margins to the same value.
       *
       * @see setContentsMargins(const Margins&)
       */
      void setContentsMargin(int margin);

      /**
       * Get the currently used margins.
       *
       * @see setContentsMargins(const Margins&)
       * @see Margins
       */
      Margins getContentsMargins() const;

      /**
       * Get the area available to the contents.
       *
       * This is equal to the geometry() reduced by the sizes of the margins.
       *
       * @see setContentsMargins(const Margins&)
       * @see geometry()
       */
      SGRecti contentsRect() const;

      /**
       * Get the preferred size of this item.
       */
      SGVec2i sizeHint() const;

      /**
       * Get the minimum amount of the space this item requires.
       */
      SGVec2i minimumSize() const;

      /**
       * Get the maximum amount of space this item can use.
       */
      SGVec2i maximumSize() const;

      /**
       * Returns true if this items preferred and minimum height depend on its
       * width.
       *
       * The default implementation returns false. Reimplement for items
       * providing height for width.
       *
       * @see heightForWidth()
       * @see minimumHeightForWidth()
       */
      virtual bool hasHeightForWidth() const;

      /**
       * Returns the preferred height for the given width @a w.
       *
       * Reimplement heightForWidthImpl() for items providing height for width.
       *
       * @see hasHeightForWidth()
       */
      int heightForWidth(int w) const;

      /**
       * Returns the minimum height for the given width @a w.
       *
       * Reimplement minimumHeightForWidthImpl() for items providing height for
       * width.
       *
       * @see hasHeightForWidth()
       */
      int minimumHeightForWidth(int w) const;

      /**
       * Set alignment of item within {@link Layout Layouts}.
       *
       * @param alignment Bitwise combination of vertical and horizontal
       *                  alignment flags.
       * @see AlignmentFlag
       */
      void setAlignment(uint8_t alignment);

      /**
       * Get all alignment flags.
       *
       * @see AlignmentFlag
       */
      uint8_t alignment() const;

      virtual void setVisible(bool visible);
      virtual bool isVisible() const;

      bool isExplicitlyHidden() const;

      void show() { setVisible(true); }
      void hide() { setVisible(false); }

      /**
       * Mark all cached data as invalid and require it to be recalculated.
       */
      virtual void invalidate();

      /**
       * Mark all cached data of parent item as invalid (if the parent is set).
       */
      void invalidateParent();

      /**
       * Apply any changes not applied yet.
       */
      void update();

      /**
       * Set position and size of this element. For layouts this triggers a
       * recalculation of the layout.
       */
      virtual void setGeometry(const SGRecti& geom);

      /**
       * Get position and size of this element.
       */
      virtual SGRecti geometry() const;

      /**
       * Get the actual geometry of this item given the rectangle \a geom
       * taking into account the alignment flags and size hints.
       *
       * @param geom    Area available to this item.
       * @return The resulting geometry for this item.
       *
       * @see setAlignment()
       * @see minimumSize()
       * @see maximumSize()
       * @see sizeHint()
       */
      virtual SGRecti alignmentRect(const SGRecti& geom) const;

      /**
       * Set the canvas this item is attached to.
       */
      virtual void setCanvas(const CanvasWeakPtr& canvas);

      /**
       * Get the canvas this item is attached to.
       */
      CanvasPtr getCanvas() const;

      /**
       * Set the parent layout item (usually this is a layout).
       */
      void setParent(const LayoutItemWeakRef& parent);

      /**
       * Get the parent layout.
       */
      LayoutItemRef getParent() const;

      /// Called before item is removed from a layout
      virtual void onRemove() {}

    protected:

      friend class Canvas;

      enum Flags
      {
        SIZE_HINT_DIRTY = 1,
        MINIMUM_SIZE_DIRTY = SIZE_HINT_DIRTY << 1,
        MAXIMUM_SIZE_DIRTY = MINIMUM_SIZE_DIRTY << 1,
        SIZE_INFO_DIRTY = SIZE_HINT_DIRTY
                        | MINIMUM_SIZE_DIRTY
                        | MAXIMUM_SIZE_DIRTY,
        EXPLICITLY_HIDDEN = MAXIMUM_SIZE_DIRTY << 1,
        VISIBLE = EXPLICITLY_HIDDEN << 1,
        LAYOUT_DIRTY = VISIBLE << 1,
        LAST_FLAG = LAYOUT_DIRTY
      };

      CanvasWeakPtr     _canvas;
      LayoutItemWeakRef _parent;

      SGRecti           _geometry;
      Margins           _margins;
      uint8_t           _alignment;

      mutable uint32_t  _flags;
      mutable SGVec2i   _size_hint,
                        _min_size,
                        _max_size;

      virtual SGVec2i sizeHintImpl() const;
      virtual SGVec2i minimumSizeImpl() const;
      virtual SGVec2i maximumSizeImpl() const;

      /**
       * Returns the preferred height for the given width @a w.
       *
       * The default implementation returns -1, indicating that the preferred
       * height is independent of the given width.
       *
       * Reimplement this function for items supporting height for width.
       *
       * @note Do not take margins into account, as this is already handled
       *       before calling this function.
       *
       * @see hasHeightForWidth()
       */
      virtual int heightForWidthImpl(int w) const;

      /**
       * Returns the minimum height for the given width @a w.
       *
       * The default implementation returns -1, indicating that the minimum
       * height is independent of the given width.
       *
       * Reimplement this function for items supporting height for width.
       *
       * @note Do not take margins into account, as this is already handled
       *       before calling this function.
       *
       * @see hasHeightForWidth()
       */
      virtual int minimumHeightForWidthImpl(int w) const;

      /**
       * @return whether the visibility has changed.
       */
      void setVisibleInternal(bool visible);

      virtual void contentsRectChanged(const SGRecti& rect) {};

      virtual void visibilityChanged(bool visible) {}

      /**
       * Allow calling the protected setVisibleImpl from derived classes
       */
      static void callSetVisibleInternal(LayoutItem* item, bool visible);

  };

} // namespace canvas
} // namespace simgear

#endif /* SG_CANVAS_LAYOUT_ITEM_HXX_ */