/usr/include/Nux-4.0/Nux/Button.h is in libnux-4.0-dev 4.0.8+16.04.20160209-0ubuntu2.
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 | /*
* Copyright 2010 Inalogic® Inc.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License, as
* published by the Free Software Foundation; either version 2.1 or 3.0
* of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the applicable version of the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of both the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>
*
* Authored by: Jay Taoko <jaytaoko@inalogic.com>
*
*/
#ifndef BUTTON_H
#define BUTTON_H
#include "AbstractButton.h"
namespace nux
{
class HLayout;
class VLayout;
class TextureArea;
class StaticText;
// Deprecated
// Image position with regard to the text
enum Position
{
NUX_POSITION_LEFT, // image on left, text on the right
NUX_POSITION_RIGHT, // text on the left, image on right
NUX_POSITION_TOP, // image above text
NUX_POSITION_BOTTOM // image below text
};
//! A Button with styling(image + text)
/*!
The Button class has a non persistent active state. It returns to a normal state after a mouse click.
For a Button is a persistent active state, use the ToggleButton class. This widget is also known as a PushButton.
*/
class Button: public AbstractButton
{
NUX_DECLARE_OBJECT_TYPE(Button, View);
public:
enum LayoutType
{
HORIZONTAL,
VERTICAL,
};
enum ItemOrder
{
IMAGE_FIRST,
LABEL_FIRST,
};
enum Distribution
{
START_OF_LAYOUT,
END_OF_LAYOUT,
CENTER_OF_LAYOUT,
SPREAD_OVER_LAYOUT,
};
Button(TextureArea *image, NUX_FILE_LINE_PROTO);
Button(const std::string& button_label, NUX_FILE_LINE_PROTO);
Button(const std::string& button_label, TextureArea *image, NUX_FILE_LINE_PROTO);
Button(NUX_FILE_LINE_PROTO);
virtual ~Button();
//! Emitted when the button is clicked.
sigc::signal<void, Button*> click;
//! Emitted when the active state changes.
/*!
Emitted when the active state changes, as a result of a mouse click or an API call.\n
\sa Activate, Deactivate.
*/
sigc::signal<void, Button*> state_change;
//! Set the label.
/*!
Set the label of this Button. If the \a label argument is an empty string, then the the Button label is destroyed,
and the content of the Button is re-arranged accordingly.
@param label The label of the Button.
*/
void SetLabel(const std::string &button_label);
//!Return the label of this Button.
/*!
Return the label of this Button.
@return The Button label string.
*/
std::string GetLabel() const;
//! Set the image.
/*!
Set the image of this Button. If the \a image argument is NULL and this Button has an image, then the image is destroyed,
and the content of the button is re-arranged accordingly.\n
This Button make a copy of the \a image argument if it is not NULL. The source image should be destroyed after if it is no longer needed.\n
The minimum and maximum size of the internal image are set to the minimum and maximum size of the \a image argument.
\sa SetImageMinimumSize, SetImageMaximumSize.
@param A TextureArea.
*/
void SetImage(TextureArea *image);
//! Get the image.
/*!
Returns a new TextureArea with the same content as the internal TextureArea of this Button.
The returned TextureArea has a floating reference.\n
If the Button doesn't have an image, the function returns NULL.
@return A TextureArea.
*/
TextureArea* GetImage();
//! Set the minimum size of the image in the Button.
/*!
Set the minimum size of the image in the Button.\n
When setting an image into this Button with \a SetImage, the minimum size is set to the one of the \a image argument
of \a SetImage.
\sa SetImage.
@param width Minimum width of the image.
@param height Minimum height of the image.
*/
void SetImageMinimumSize(int width, int height);
//! Set the maximum size of the image in the Button.
/*!
Set the maximum size of the image in the Button.\n
When setting an image into this Button with \a SetImage, the maximum size is set to the one of the \a image argument
of \a SetImage.
\sa SetImage.
@param width Maximum width of the image.
@param height Maximum height of the image.
*/
void SetImageMaximumSize(int width, int height);
//! Set the padding of the internal layout.
/*!
Set the padding of the internal layout.\n
The default value is 2 for top, right, bottom and left padding.
@param top Top padding.
@param right Right padding.
@param bottom Bottom padding.
@param left Left padding.
*/
void SetLayoutPadding(int top, int right, int bottom, int left);
//! Add a clipping rectangle inside the button.
/*!
Add an internal clipping rectangle inside the button. This will clip the rendering of anything
inside the button. The default value is 2 for top, right, bottom and left clipping.
@param top Top clipping.
@param right Right clipping.
@param bottom Bottom clipping.
@param left Left clipping.
*/
void SetButtonClipRegion(int top_clip, int right_clip, int bottom_clip, int left_clip);
//! Set the distribution of elements inside the layout.
/*!
Set how elements are distributed in the layout. The distribution takes effect only if the element don't
use all the space available in the layout. In that case, they may be distributed toward the start, middle
or end of the layout.
@param distribution Distribution of elements inside the layout.
*/
void SetDistribution(Distribution distribution);
//! Set the order of the image and label inside the layout.
/*!
Set the order of the image and label in the layout. Either the image comes first or the label. This is true in
an horizontal or vertical layout configuration.
@param item_order Order of the image and label inside the layout.
*/
void SetItemOrder(ItemOrder item_order);
//! Set the layout type.
/*!
Set the layout type. With an horizontal layout type, the image and the label are arranged horizontally, while with a
vertical layout type, they are arranged vertically. You may call SetItemOrder to choose if the image or the label
come first in an horizontal(from left to right) or vertical(top to bottom) configuration.
@param layout_type The layout type.
*/
void SetLayoutType(LayoutType layout_type);
//! Set the space between the image and the label.
/*!
Set the space between the image and the label.
@param space_between_items The space between the image and the label inside the layout.
*/
void SetSpaceBetweenItems(int space_between_items);
//! Activate the button.
/*!
Activate the button. If this object is a Button, then it has no persistent state and the function does nothing.
*/
void Activate();
//! Deactivate the button.
/*!
Deactivate the button. If this object is a Button, then it has no persistent state and the function does nothing.
*/
void Deactivate();
virtual void SetLabelFontSize(int point);
protected:
LayoutType layout_type_; //!< The button layout type.
ItemOrder item_order_; //!< Ordering of the text and image.
Distribution distribution_; //!< Distribution of the image and text inside the Button layout.
int space_between_items_; //!< Space between the Button image and text.
bool persistent_active_state_; //!< The button's persistent state flag.
int layout_left_padding_;
int layout_right_padding_;
int layout_top_padding_;
int layout_bottom_padding_;
int left_clip_;
int right_clip_;
int top_clip_;
int bottom_clip_;
bool SetLabelProperty(std::string &value, std::string const &str);
void Initialize(const std::string &str, TextureArea* texture_area);
void BuildLayout(const std::string &str, TextureArea* texture_area);
TextureArea *image_;
Size image_minimum_size_;
Size image_maximum_size_;
virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
virtual void RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
// virtual void PreLayoutManagement();
// virtual long PostLayoutManagement(long LayoutResult);
virtual long ComputeContentSize();
};
//typedef Button ToggleButton;
}
#endif // BUTTON_H
|