/usr/include/simgear/canvas/layout/BoxLayout.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 | /// @file
//
// 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_BOX_LAYOUT_HXX_
#define SG_CANVAS_BOX_LAYOUT_HXX_
#include "Layout.hxx"
namespace simgear
{
namespace canvas
{
/**
* Align LayoutItems horizontally or vertically in a box.
*
* @see http://qt-project.org/doc/qt-4.8/qboxlayout.html#details
*/
class BoxLayout:
public Layout
{
public:
enum Direction
{
LeftToRight,
RightToLeft,
TopToBottom,
BottomToTop
};
BoxLayout(Direction dir);
~BoxLayout();
virtual void addItem(const LayoutItemRef& item);
void addItem( const LayoutItemRef& item,
int stretch,
uint8_t alignment = 0 );
void addStretch(int stretch = 0);
void addSpacing(int size);
void insertItem( int index,
const LayoutItemRef& item,
int stretch = 0,
uint8_t alignment = 0 );
void insertStretch(int index, int stretch = 0);
void insertSpacing(int index, int size);
virtual size_t count() const;
virtual LayoutItemRef itemAt(size_t index);
virtual LayoutItemRef takeAt(size_t index);
virtual void clear();
/**
* Set the stretch factor of the item at position @a index to @a stretch.
*/
void setStretch(size_t index, int stretch);
/**
* Set the stretch factor of the given @a item to @a stretch, if it exists
* in this layout.
*
* @return true, if the @a item was found in the layout
*/
bool setStretchFactor(const LayoutItemRef& item, int stretch);
/**
* Get the stretch factor of the item at position @a index
*/
int stretch(size_t index) const;
virtual void setSpacing(int spacing);
virtual int spacing() const;
void setDirection(Direction dir);
Direction direction() const;
virtual bool hasHeightForWidth() const;
virtual void setCanvas(const CanvasWeakPtr& canvas);
bool horiz() const;
protected:
typedef const int& (SGVec2i::*CoordGetter)() const;
CoordGetter _get_layout_coord, //!< getter for coordinate in layout
// direction
_get_fixed_coord; //!< getter for coordinate in secondary
// (fixed) direction
int _padding;
Direction _direction;
typedef std::vector<ItemData> LayoutItems;
mutable LayoutItems _layout_items;
mutable ItemData _layout_data;
// Cache for last height-for-width query
mutable int _hfw_width,
_hfw_height,
_hfw_min_height;
void updateSizeHints() const;
void updateWFHCache(int w) const;
virtual SGVec2i sizeHintImpl() const;
virtual SGVec2i minimumSizeImpl() const;
virtual SGVec2i maximumSizeImpl() const;
virtual int heightForWidthImpl(int w) const;
virtual int minimumHeightForWidthImpl(int w) const;
virtual void doLayout(const SGRecti& geom);
virtual void visibilityChanged(bool visible);
};
/**
* Shortcut for creating a horizontal box layout
*/
class HBoxLayout:
public BoxLayout
{
public:
HBoxLayout();
};
/**
* Shortcut for creating a vertical box layout
*/
class VBoxLayout:
public BoxLayout
{
public:
VBoxLayout();
};
typedef SGSharedPtr<BoxLayout> BoxLayoutRef;
} // namespace canvas
} // namespace simgear
#endif /* SG_CANVAS_BOX_LAYOUT_HXX_ */
|