/usr/include/MYGUI/MyGUI_Widget.h is in libmygui-dev 3.2.2+dfsg-1.
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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | /*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_WIDGET_H_
#define MYGUI_WIDGET_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Any.h"
#include "MyGUI_ICroppedRectangle.h"
#include "MyGUI_WidgetUserData.h"
#include "MyGUI_WidgetInput.h"
#include "MyGUI_ResourceSkin.h"
#include "MyGUI_ResourceLayout.h"
#include "MyGUI_IObject.h"
#include "MyGUI_SkinItem.h"
#include "MyGUI_BackwardCompatibility.h"
namespace MyGUI
{
typedef delegates::CMultiDelegate3<Widget*, const std::string&, const std::string&> EventHandle_WidgetStringString;
/** \brief @wpage{Widget}
Widget widget description should be here.
*/
class MYGUI_EXPORT Widget :
public IObject,
public ICroppedRectangle,
public UserData,
public WidgetInput,
public delegates::IDelegateUnlink,
public SkinItem,
public MemberObsolete<Widget>
{
// для вызова закрытых деструкторов
friend class WidgetManager;
MYGUI_RTTI_DERIVED( Widget )
public:
Widget();
/** Create child widget
@param _type widget type
@param _skin widget skin
@param _coord int coordinates of widget (_left, _top, _width, _height)
@param _align widget align (possible values can be found in enum Align)
@param _name if needed (you can use it for finding widget by name later)
*/
Widget* createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _name = "");
/** See Widget::createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _name = "") */
Widget* createWidgetT(const std::string& _type, const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _name = "");
/** Create widget using coordinates relative to parent. see Widget::createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _name = "") */
Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _name = "");
/** Create widget using coordinates relative to parent. see Widget::createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _name = "") */
Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _name = "");
// templates for creating widgets by type
/** Same as Widget::createWidgetT but return T pointer instead of Widget* */
template <typename T>
T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _name = "")
{
return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _name));
}
/** Same as Widget::createWidgetT but return T pointer instead of Widget* */
template <typename T>
T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _name = "")
{
return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _name));
}
/** Same as Widget::createWidgetRealT but return T* instead of Widget* */
template <typename T>
T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _name = "")
{
return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _name));
}
/** Same as Widget::createWidgetRealT but return T* instead of Widget* */
template <typename T>
T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _name = "")
{
return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _name));
}
/** Create child widget
@param _style Child, Popup or Overlapped widget style
@param _type widget type
@param _skin widget skin
@param _coord int coordinates of widget (_left, _top, _width, _height)
@param _align widget align (possible values can be found in enum Align)
@param _layer layer where widget will be created (all layers usually defined in core_layer.xml file).
@param _name optional widget name (you can use it for finding widget by name later)
*/
Widget* createWidgetT(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer = "", const std::string& _name = "");
/** Same as Widget::createWidgetT but return T* instead of Widget* */
template <typename T>
T* createWidget(WidgetStyle _style, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer = "", const std::string& _name = "")
{
return static_cast<T*>(createWidgetT(_style, T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
}
/** Set widget position (position of left top corner) */
virtual void setPosition(const IntPoint& _value);
/** Set widget size */
virtual void setSize(const IntSize& _value);
/** Set widget position and size */
virtual void setCoord(const IntCoord& _value);
/** See Widget::setPosition(const IntPoint& _pos) */
void setPosition(int _left, int _top);
/** See Widget::setSize(const IntSize& _size) */
void setSize(int _width, int _height);
/** See Widget::setCoord(const IntCoord& _coord) */
void setCoord(int _left, int _top, int _width, int _height);
/** Set widget position (position of left top corner)*/
void setRealPosition(const FloatPoint& _value);
/** Set widget size */
void setRealSize(const FloatSize& _value);
/** Set widget position and size*/
void setRealCoord(const FloatCoord& _value);
/** See Widget::setRealPosition(const FloatPoint& _point) */
void setRealPosition(float _left, float _top);
/** See Widget::setRealSize(const FloatSize& _size) */
void setRealSize(float _width, float _height);
/** See Widget::setRealPosition(const FloatCoord& _coord) */
void setRealCoord(float _left, float _top, float _width, float _height);
//! Get name of widget
const std::string& getName() const;
/** Hide or show widget */
virtual void setVisible(bool _value);
/** Return true if visible */
bool getVisible() const;
/** Set child widget rendering depth for ordering child widgets.
Widget with higher depth is rendered below widget with lower depth.
Available only for child widgets. For root widgets use layer property instead.
*/
void setDepth(int _value);
/** Get child widget rendering depth */
int getDepth() const;
/** Return widget's visibility based on it's and parents visibility. */
bool getInheritedVisible() const;
/** Set align */
virtual void setAlign(Align _value);
/** Get align */
Align getAlign() const;
/** Set widget opacity */
void setAlpha(float _value);
/** Get widget opacity */
float getAlpha() const;
/** Enable or disable inherits alpha mode.\n
Inherits alpha mode: when enabled widget alpha is it's own
alpha value multiplied by parent's real alpha (that depend
on parent's parent and so on).\n
When disabled widget's alpha doesn't depend on parent's alpha.
So this is used when you need things like semi-transparent
window with non-transparent text on it and window's alpha
changes.\n
Enabled (true) by default.
*/
void setInheritsAlpha(bool _value);
/** Get inherits alpha mode flag */
bool getInheritsAlpha() const;
void setColour(const Colour& _value);
// являемся ли мы рутовым виджетом
/** Is this widget is root widget (root == without parents) */
bool isRootWidget() const;
/** Get parent widget or nullptr if no parent */
Widget* getParent() const;
IntSize getParentSize() const;
/** Get child widgets Enumerator */
EnumeratorWidgetPtr getEnumerator() const;
/** Get child count */
size_t getChildCount();
/** Get child by index (index from 0 to child_count - 1) */
Widget* getChildAt(size_t _index);
/** Find widget by name.
Search recursively through all childs starting from this widget.
@return Return first found widget with given name
*/
Widget* findWidget(const std::string& _name);
/** Find all widgets with given name and add them into _result.
Search recursively through all childs starting from this widget.
*/
void findWidgets(const std::string& _name, VectorWidgetPtr& _result);
/** Enable or disable widget */
virtual void setEnabled(bool _value);
/** Enable or disable widget without changing widget's state */
void setEnabledSilent(bool _value);
/** Is widget enabled */
bool getEnabled() const;
/** Is widget enabled and all it's parents in hierarchy are enabled. */
bool getInheritedEnabled() const;
/** Get rectangle where child widgets placed */
IntCoord getClientCoord();
/** Get client area widget or nullptr if widget don't have client */
Widget* getClientWidget();
/** Detach widget from widgets hierarchy
@param _layer Attach to specified layer (if any)
*/
void detachFromWidget(const std::string& _layer = "");
/** Attach widget to parent
@param _parent New parent
@param _style New widget style (see WidgetStyle::Enum)
@param _layer Attach to specified layer (if any)
*/
void attachToWidget(Widget* _parent, WidgetStyle _style = WidgetStyle::Child, const std::string& _layer = "");
/** Change widget skin */
void changeWidgetSkin(const std::string& _skinName);
/** Set widget style.
@param _style New widget style (see WidgetStyle::Enum)
@param _layer Attach to specified layer (if any)
@note When choosing WidgetStyle::Popup style you also need attach widget to layer
*/
void setWidgetStyle(WidgetStyle _style, const std::string& _layer = "");
/** Get widget style */
WidgetStyle getWidgetStyle() const;
/** Set any widget property
@param _key Property name (for example Alpha or Enabled)
@param _value Value converted to string
*/
void setProperty(const std::string& _key, const std::string& _value);
/** Event : Widget property changed through setProperty (in code, or from layout)\n
signature : void method(MyGUI::Widget* _sender, const std::string& _key, const std::string& _value);
@param _sender widget that called this event
@param _key
@param _value
*/
EventHandle_WidgetStringString eventChangeProperty;
/** Event : Widget coordinate changed (widget was resized or moved).\n
signature : void method(MyGUI::Widget* _sender)
@param _sender widget that called this event
*/
EventHandle_WidgetVoid eventChangeCoord;
/*internal:*/
// метод для запроса номера айтема и контейнера
virtual size_t _getItemIndex(Widget* _item);
// дает приоритет виджету при пиккинге
void _forcePick(Widget* _widget);
void _initialise(WidgetStyle _style, const IntCoord& _coord, const std::string& _skinName, Widget* _parent, ICroppedRectangle* _croppedParent, const std::string& _name);
void _shutdown();
// удяляет неудачника
void _destroyChildWidget(Widget* _widget);
void _setContainer(Widget* _value);
Widget* _getContainer();
void _setAlign(const IntSize& _oldsize, const IntSize& _newSize);
bool _checkPoint(int _left, int _top) const;
Widget* _createSkinWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer = "", const std::string& _name = "");
// сброс всех данных контейнера, тултипы и все остальное
virtual void _resetContainer(bool _update);
bool _setWidgetState(const std::string& _value);
// перерисовывает детей
void _updateChilds();
protected:
// все создание только через фабрику
virtual ~Widget();
virtual void shutdownOverride();
virtual void initialiseOverride();
void _updateView(); // обновления себя и детей
// создает виджет
Widget* baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name, bool _template);
// удаляет всех детей
void _destroyAllChildWidget();
// запрашиваем у конейтера айтем по позиции мыши
virtual size_t _getContainerIndex(const IntPoint& _point);
virtual void baseUpdateEnable();
// наследуемся он LayerInfo
virtual ILayerItem* getLayerItemByPoint(int _left, int _top) const;
virtual const IntCoord& getLayerItemCoord() const;
template <typename T>
void assignWidget(T*& _widget, const std::string& _name)
{
_widget = nullptr;
for (VectorWidgetPtr::iterator iter = mWidgetChildSkin.begin(); iter != mWidgetChildSkin.end(); ++iter)
{
Widget* find = (*iter)->findWidget(_name);
if (nullptr != find)
{
_widget = find->castType<T>(false);
break;
}
}
}
VectorWidgetPtr getSkinWidgetsByName(const std::string& _name);
void destroySkinWidget(Widget* _widget);
virtual void onWidgetCreated(Widget* _widget);
virtual void onWidgetDestroy(Widget* _widget);
void setWidgetClient(Widget* _widget);
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
private:
void frameEntered(float _frame);
const WidgetInfo* initialiseWidgetSkinBase(ResourceSkin* _info, ResourceLayout* _templateInfo);
void shutdownWidgetSkinBase();
void _updateAlpha();
void _updateAbsolutePoint();
// для внутреннего использования
void _updateVisible();
void _updateEnabled();
float _getRealAlpha() const;
void _createChildSkinWidget(ResourceSkin* _info);
void _destroyChildSkinWidget();
void _parseSkinProperties(ResourceSkin* _info);
void _checkInheristProperties();
void _linkChildWidget(Widget* _widget);
void _unlinkChildWidget(Widget* _widget);
void setSkinProperty(ResourceSkin* _info);
virtual void resizeLayerItemView(const IntSize& _oldView, const IntSize& _newView);
void addWidget(Widget* _widget);
private:
// клиентская зона окна
// если виджет имеет пользовательские окна не в себе
// то обязательно проинициализировать Client
Widget* mWidgetClient;
// вектор всех детей виджетов
VectorWidgetPtr mWidgetChild;
// вектор детей скина
VectorWidgetPtr mWidgetChildSkin;
// доступен ли на виджет
bool mEnabled;
bool mInheritsEnabled;
// для иерархического скрытия
bool mInheritsVisible;
// прозрачность и флаг наследования альфы нашего оверлея
float mAlpha;
float mRealAlpha;
bool mInheritsAlpha;
// имя виджета
std::string mName;
// наш отец в иерархии виджетов
Widget* mParent;
// поведение виджета, перекрывающийся дочерний или всплывающий
WidgetStyle mWidgetStyle;
Widget* mContainer;
Align mAlign;
bool mVisible;
int mDepth;
};
} // namespace MyGUI
#endif // MYGUI_WIDGET_H_
|