/** * @author Edouard DUPIN * * @copyright 2010, Edouard DUPIN, all right reserved * * @license GPL v3 (see license file) */ #include #include #include #include #include #include #undef __class__ #define __class__ "globals" erreurCode_te globals::init(void) { erreurCode_te ret = ERR_NONE; return ret; } // ----------------------------------------------------------- static bool displayEOL = false; bool globals::IsSetDisplayEndOfLine(void) { return displayEOL; } void globals::SetDisplayEndOfLine(bool newVal) { APPL_INFO("Set EndOfLine " << newVal); displayEOL = newVal; //ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange); } // ----------------------------------------------------------- static bool displaySpaceChar = true; bool globals::IsSetDisplaySpaceChar(void) { return displaySpaceChar; } void globals::SetDisplaySpaceChar(bool newVal) { APPL_INFO("Set SpaceChar " << newVal); displaySpaceChar = newVal; //ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange); } // ----------------------------------------------------------- static bool displayTabChar = true; bool globals::IsSetDisplayTabChar(void) { return displayTabChar; } void globals::SetDisplayTabChar(bool newVal) { APPL_INFO("Set SpaceChar " << newVal); displayTabChar = newVal; //ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange); } // ----------------------------------------------------------- static bool AutoIndent = true; bool globals::IsSetAutoIndent(void) { return AutoIndent; } void globals::SetAutoIndent(bool newVal) { APPL_INFO("Set AutoIndent " << newVal); AutoIndent = newVal; } // ----------------------------------------------------------- bool globals::OrderTheBufferList(void) { return true; } // ----------------------------------------------------------- int32_t globals::getNbColoneBorder(void) { return 6; } int32_t globals::getNbLineBorder(void) { return 3; } #include #include static const char * const l_changeIndentation = "edn-event-change-indentation"; static const char * const l_changeSpace = "edn-event-change-spaces"; static const char * const l_changeTabulation = "edn-event-change-tabulation"; static const char * const l_changeEndOfLine = "edn-event-change-endOfLine"; static const char * const l_changeRounded = "edn-event-change-rounded"; globals::ParameterGlobalsGui::ParameterGlobalsGui(void) : widget::Sizer(widget::Sizer::modeVert) { widget::CheckBox* myCheckbox = NULL; widget::Spacer* mySpacer = NULL; mySpacer = new widget::Spacer(); if (NULL == mySpacer) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { mySpacer->SetExpand(bvec2(true,true)); SubWidgetAdd(mySpacer); } myCheckbox = new widget::CheckBox("Automatic Indentation"); if (NULL == myCheckbox) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { myCheckbox->SetExpand(bvec2(true,false)); myCheckbox->SetValue(IsSetAutoIndent()); myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeIndentation); SubWidgetAdd(myCheckbox); } myCheckbox = new widget::CheckBox("Display space char (' ')"); if (NULL == myCheckbox) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { myCheckbox->SetExpand(bvec2(true,false)); myCheckbox->SetValue(IsSetDisplaySpaceChar()); myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeSpace); SubWidgetAdd(myCheckbox); } myCheckbox = new widget::CheckBox("Display tabulation char ('\\t')"); if (NULL == myCheckbox) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { myCheckbox->SetExpand(bvec2(true,false)); myCheckbox->SetValue(IsSetDisplayTabChar()); myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeTabulation); SubWidgetAdd(myCheckbox); } myCheckbox = new widget::CheckBox("Display end of line ('\\n')"); if (NULL == myCheckbox) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { myCheckbox->SetExpand(bvec2(true,false)); myCheckbox->SetValue(IsSetDisplayEndOfLine()); myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeEndOfLine); SubWidgetAdd(myCheckbox); } myCheckbox = new widget::CheckBox("switch Rounded/default"); if (NULL == myCheckbox) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { myCheckbox->SetExpand(bvec2(true,false)); myCheckbox->SetValue(IsSetDisplayEndOfLine()); myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeRounded); SubWidgetAdd(myCheckbox); } } globals::ParameterGlobalsGui::~ParameterGlobalsGui(void) { } void globals::ParameterGlobalsGui::OnReceiveMessage(const ewol::EMessage& _msg) { widget::Sizer::OnReceiveMessage(_msg); if (_msg.GetMessage() == l_changeEndOfLine) { if (_msg.GetData() == "true") { SetDisplayEndOfLine(true); } else { SetDisplayEndOfLine(false); } } else if (_msg.GetMessage() == l_changeIndentation) { if (_msg.GetData() == "true") { SetAutoIndent(true); } else { SetAutoIndent(false); } } else if (_msg.GetMessage() == l_changeSpace) { if (_msg.GetData() == "true") { SetDisplaySpaceChar(true); } else { SetDisplaySpaceChar(false); } } else if (_msg.GetMessage() == l_changeTabulation) { if (_msg.GetData() == "true") { SetDisplayTabChar(true); } else { SetDisplayTabChar(false); } } else if (_msg.GetMessage() == l_changeRounded) { if (_msg.GetData() == "true") { etk::theme::SetName("GUI", "rounded");; } else { etk::theme::SetName("GUI", "default");; } // Reload shaders and graphic system ... ewol::resource::ReLoadResources(); } }