OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
DialogCfg.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
9#include "OTCore/Flags.h"
10#include "OTCore/Serializable.h"
12#include "OTCore/Size2D.h"
14
15// std header
16#include <string>
17
18#pragma warning(disable:4251)
19
20namespace ot {
21
23 public:
25 NoFlags = 0x00,
26 CancelOnNoChange = 0x01,
27 MoveGrabAnywhere = 0x02,
28 RecenterOnF11 = 0x04
29 };
31
32 static std::string toString(DialogFlag _flag);
33 static DialogFlag stringToFlag(const std::string& _flag);
34 static std::list<std::string> toStringList(DialogFlags _flags);
35 static DialogFlags stringListToFlags(const std::list<std::string>& _flags);
36
37 DialogCfg(DialogFlags _flags = DialogFlags(NoFlags));
38 DialogCfg(const std::string& _title, DialogFlags _flags = DialogFlags(NoFlags));
39 DialogCfg(const DialogCfg& _other);
40 virtual ~DialogCfg() {};
41
42 DialogCfg& operator = (const DialogCfg& _other);
43
47 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
48
52 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
53
54 void setName(const std::string& _name) { m_name = _name; };
55 const std::string& getName(void) const { return m_name; };
56
57 void setTitle(const std::string& _title) { m_title = _title; };
58 const std::string& getTitle(void) const { return m_title; };
59
60 void setFlag(DialogFlag _flag, bool _active = true) { m_flags.setFlag(_flag, _active); };
61 void setFlags(DialogFlags _flags) { m_flags = _flags; };
62 DialogFlags getFlags(void) const { return m_flags; };
63
64 void setMinSize(int _width, int _height) { this->setMinSize(ot::Size2D(_width, _height)); };
65 void setMinSize(const ot::Size2D& _size) { m_minSize = _size; };
66 const ot::Size2D& getMinSize(void) const { return m_minSize; };
67
68 void setMaxSize(int _width, int _height) { this->setMaxSize(ot::Size2D(_width, _height)); };
69 void setMaxSize(const ot::Size2D& _size) { m_maxSize = _size; };
70 const ot::Size2D& getMaxSize(void) const { return m_maxSize; };
71
72 private:
73 std::string m_name;
74 std::string m_title;
75 DialogFlags m_flags;
76 ot::Size2D m_minSize;
77 ot::Size2D m_maxSize;
78 };
79
80}
81
#define OT_ADD_FLAG_FUNCTIONS(___enumName)
Will add the default bitwise operations for the provided private 32/64 bit bitfield....
Definition Flags.h:129
This file contains defines that may be used simplyfy class creation.
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
Definition DialogCfg.h:22
DialogFlags getFlags(void) const
Definition DialogCfg.h:62
const std::string & getTitle(void) const
Definition DialogCfg.h:58
void setMaxSize(const ot::Size2D &_size)
Definition DialogCfg.h:69
DialogFlag
Definition DialogCfg.h:24
void setMinSize(int _width, int _height)
Definition DialogCfg.h:64
void setFlag(DialogFlag _flag, bool _active=true)
Definition DialogCfg.h:60
virtual ~DialogCfg()
Definition DialogCfg.h:40
void setMinSize(const ot::Size2D &_size)
Definition DialogCfg.h:65
void setFlags(DialogFlags _flags)
Definition DialogCfg.h:61
const ot::Size2D & getMaxSize(void) const
Definition DialogCfg.h:70
void setTitle(const std::string &_title)
Definition DialogCfg.h:57
void setName(const std::string &_name)
Definition DialogCfg.h:54
const ot::Size2D & getMinSize(void) const
Definition DialogCfg.h:66
const std::string & getName(void) const
Definition DialogCfg.h:55
void setMaxSize(int _width, int _height)
Definition DialogCfg.h:68
Flags< DialogFlag > DialogFlags
Definition DialogCfg.h:30
The Flags class is a wrapper around a enum that allows bitwise operations (flags)....
Definition Flags.h:214
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
2D Size with integer values
Definition Size2D.h:15
Definition Connector.h:8
OT_GUI_API_EXPORT std::list< std::string > toStringList(const LockTypeFlags &_flags)
Definition GuiTypes.cpp:426
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
OT_GUI_API_EXPORT std::string toString(ColorStyleName _colorStyleName)
Definition ColorStyleTypes.cpp:10
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30