edn/sources/appl/global.cpp

200 lines
6.1 KiB
C++
Raw Normal View History

/**
* @author Edouard DUPIN
2012-11-25 11:55:06 +01:00
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
2012-04-24 09:42:14 +02:00
#include <appl/global.h>
#include <appl/globalMsg.h>
2013-12-13 21:50:40 +01:00
#include <ewol/object/Object.h>
#include <ewol/context/Context.h>
#include <ewol/resource/Manager.h>
2012-11-06 18:08:44 +01:00
#include <etk/os/FSNode.h>
#undef __class__
2013-10-09 22:00:24 +02:00
#define __class__ "globals"
2013-12-13 21:50:40 +01:00
class myParamGlobal : public ewol::Object {
2013-05-28 22:09:53 +02:00
public:
2014-08-13 22:30:47 +02:00
ewol::object::Param<bool> m_displayEOL;
ewol::object::Param<bool> m_AutoIndent;
ewol::object::Param<bool> m_displayTabChar;
ewol::object::Param<bool> m_displaySpaceChar;
2013-05-28 22:09:53 +02:00
public :
2014-08-13 22:30:47 +02:00
myParamGlobal() :
m_displayEOL(*this, "eol", false, "Display end of line character"),
m_AutoIndent(*this, "auto-indent", true, "Auto indent when create new line"),
m_displayTabChar(*this, "display-tab", true, "Display the Tab char"),
m_displaySpaceChar(*this, "display-space", true, "Display the space char") {
2013-10-07 22:04:21 +02:00
m_static = true; // Note : set the object static notification( Must be set or assert at the end of process)
setName("edn_global_param");
2013-05-28 22:09:53 +02:00
}
};
static myParamGlobal& l_obj() {
2013-05-28 22:09:53 +02:00
static myParamGlobal s_obj;
return s_obj;
}
void globals::init() {
2013-10-07 22:04:21 +02:00
//ewol::userConfig::addUserConfig(&l_obj());
}
void globals::UnInit() {
2013-05-28 22:09:53 +02:00
// nothing to do ...
//ewol::userConfig::RmUserConfig(&l_obj());
}
// -----------------------------------------------------------
bool globals::isSetDisplayEndOfLine() {
2013-05-28 22:09:53 +02:00
return l_obj().m_displayEOL;
}
2013-10-09 22:00:24 +02:00
void globals::setDisplayEndOfLine(bool newVal) {
2013-05-28 22:09:53 +02:00
l_obj().m_displayEOL = newVal;
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
bool globals::isSetDisplaySpaceChar() {
2013-05-28 22:09:53 +02:00
return l_obj().m_displaySpaceChar;
}
2013-10-09 22:00:24 +02:00
void globals::setDisplaySpaceChar(bool _newVal) {
l_obj().m_displaySpaceChar = _newVal;
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
2012-07-23 17:21:44 +02:00
// -----------------------------------------------------------
bool globals::isSetDisplayTabChar() {
2013-05-28 22:09:53 +02:00
return l_obj().m_displayTabChar;
2012-07-23 17:21:44 +02:00
}
2013-10-09 22:00:24 +02:00
void globals::setDisplayTabChar(bool _newVal) {
l_obj().m_displayTabChar = _newVal;
2012-07-23 17:21:44 +02:00
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
bool globals::isSetAutoIndent() {
2013-05-28 22:09:53 +02:00
return l_obj().m_AutoIndent;
}
2013-10-09 22:00:24 +02:00
void globals::setAutoIndent(bool _newVal) {
l_obj().m_AutoIndent = _newVal;
}
// -----------------------------------------------------------
bool globals::OrderTheBufferList() {
2012-10-18 11:09:19 +02:00
return true;
}
// -----------------------------------------------------------
int32_t globals::getNbColoneBorder() {
return 6;
}
int32_t globals::getNbLineBorder() {
return 3;
}
2012-07-23 17:21:44 +02:00
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/Spacer.h>
globals::ParameterGlobalsGui::ParameterGlobalsGui() {
addObjectType("globals::ParameterGlobalsGui");
}
void globals::ParameterGlobalsGui::init() {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
std::shared_ptr<ewol::widget::CheckBox> myCheckbox;
std::shared_ptr<ewol::widget::Spacer> mySpacer;
2012-07-23 17:21:44 +02:00
mySpacer = ewol::widget::Spacer::create();
2014-06-05 22:01:24 +02:00
if (nullptr == mySpacer) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
2013-10-07 22:04:21 +02:00
mySpacer->setExpand(bvec2(true,true));
subWidgetAdd(mySpacer);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create("Automatic Indentation");
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
2013-10-07 22:04:21 +02:00
myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetAutoIndent());
myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackIndentation);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')");
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
2013-10-07 22:04:21 +02:00
myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplaySpaceChar());
myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackSpace);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')");
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
2013-10-07 22:04:21 +02:00
myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayTabChar());
myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackTabulation);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create("Display end of line ('\\n')");
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
2013-10-07 22:04:21 +02:00
myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayEndOfLine());
myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackEndOfLine);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default");
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-11-06 18:08:44 +01:00
} else {
2013-10-07 22:04:21 +02:00
myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayEndOfLine());
myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackRounded);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-11-06 18:08:44 +01:00
}
2012-07-23 17:21:44 +02:00
}
globals::ParameterGlobalsGui::~ParameterGlobalsGui() {
2012-07-23 17:21:44 +02:00
}
void globals::ParameterGlobalsGui::onCallbackEndOfLine(const bool& _value) {
setDisplayEndOfLine(_value);
}
void globals::ParameterGlobalsGui::onCallbackIndentation(const bool& _value) {
setAutoIndent(_value);
}
void globals::ParameterGlobalsGui::onCallbackSpace(const bool& _value) {
setDisplaySpaceChar(_value);
}
void globals::ParameterGlobalsGui::onCallbackTabulation(const bool& _value) {
setDisplayTabChar(_value);
}
void globals::ParameterGlobalsGui::onCallbackRounded(const bool& _value) {
if (_value == true) {
etk::theme::setName("GUI", "rounded");;
} else {
etk::theme::setName("GUI", "default");;
2012-07-23 17:21:44 +02:00
}
// Reload shaders and graphic system ...
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
2012-08-19 16:56:59 +02:00
}