DISPLAY : add a menu to change the color on the fly

This commit is contained in:
Edouard Dupin 2011-08-31 09:42:30 +02:00
parent 4d2eced7a0
commit 72f63a8990
8 changed files with 56 additions and 24 deletions

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* @file ColoriseManager.cpp
* @file ColorizeManager.cpp
* @brief Editeur De N'ours : Colorising Manager
* @author Edouard DUPIN
* @date 14/12/2010
@ -57,19 +57,8 @@ void ColorizeManager::OnMessage(int32_t id, int32_t dataID)
{
case EDN_MSG__RELOAD_COLOR_FILE:
{
// Remove all current color
int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
// Reaload File
// TODO : Check this :
// TODO : Check this : Pb in the recopy Edn::String element
Edn::String plop = m_fileColor;
LoadFile(plop.c_str());
}
@ -85,6 +74,18 @@ void ColorizeManager::LoadFile(Edn::String &xmlFilename)
void ColorizeManager::LoadFile(const char * xmlFilename)
{
// Remove all old color :
int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
m_fileColor = xmlFilename;
EDN_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\"");
errorColor = new Colorize();
@ -96,22 +97,17 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
// open the curent File
XmlDocument.LoadFile(xmlFilename);
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
if (NULL == root )
{
if (NULL == root ) {
EDN_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
return;
}
else
{
} else {
TiXmlNode * pNode = root->FirstChild();
while(NULL != pNode)
{
while(NULL != pNode) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pNode->Value(), "gui")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode)
{
while(NULL != pGuiNode) {
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
@ -233,6 +229,7 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
}
}
SendMessage(EDN_MSG__COLOR_HAS_CHANGE);
SendMessage(EDN_MSG__USER_DISPLAY_CHANGE);
}
Colorize *ColorizeManager::Get(const char *colorName)

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* @file ColoriseManager.h
* @file ColorizeManager.h
* @brief Editeur De N'ours : Colorising Manager (header)
* @author Edouard DUPIN
* @date 14/12/2010

View File

@ -100,6 +100,10 @@ void BufferView::OnMessage(int32_t id, int32_t dataID)
// change Title :
gtk_widget_queue_draw(m_widget);
break;
case EDN_MSG__USER_DISPLAY_CHANGE:
// Redraw all the display ...
gtk_widget_queue_draw(m_widget);
break;
}
}

View File

@ -179,6 +179,9 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
case EDN_MSG__CURRENT_SET_CHARSET:
m_bufferManager->Get(m_bufferID)->SetCharset((charset_te)dataID);
break;
case EDN_MSG__USER_DISPLAY_CHANGE:
// Redraw all the display ... Done under ...
break;
}
// Force redraw of the widget
gtk_widget_queue_draw(m_widget);

View File

@ -28,6 +28,7 @@
#include "MenuBar.h"
#include "ClipBoard.h"
#include "charset.h"
#include "ColorizeManager.h"
#define MENU_MSG
const char * MSG_TogleDisplayChar = "Request a Togle of char displaying";
@ -36,6 +37,8 @@ const char * MSG_TogleAutoIndent = "Request a Togle of Auto Indent";
const char * MSG_SetCharsetIso559_1 = "Set ISO 5589-1";
const char * MSG_SetCharsetIso559_15 = "Set ISO 5589-15";
const char * MSG_SetCharsetUTF8 = "Set UTF 8";
const char * MSG_LoadColorBlack = "Load Color Black";
const char * MSG_LoadColorWhite = "Load Color White";
#define MSG_LINK(data)
@ -74,6 +77,26 @@ static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data)
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_15);
} else if (myPointer == MSG_SetCharsetUTF8) {
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8);
} else if (myPointer == MSG_LoadColorWhite) {
ColorizeManager * myColorSystem = ColorizeManager::getInstance();
Edn::String homedir;
# ifdef NDEBUG
homedir = "/usr/share/edn/";
# else
homedir = "./data/";
# endif
homedir += "color_white.xml";
myColorSystem->LoadFile(homedir);
} else if (myPointer == MSG_LoadColorBlack) {
ColorizeManager * myColorSystem = ColorizeManager::getInstance();
Edn::String homedir;
# ifdef NDEBUG
homedir = "/usr/share/edn/";
# else
homedir = "./data/";
# endif
homedir += "color_black.xml";
myColorSystem->LoadFile(homedir);
}
}
@ -254,6 +277,9 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
tmp->AddInternal("Set charset Internationnal (UTF 8)", NULL, MSG_SetCharsetUTF8, true);
tmp->AddSeparator();
tmp->AddGen( "Reload Color File", NULL, EDN_MSG__RELOAD_COLOR_FILE, true);
tmp->AddSeparator();
tmp->AddInternal("Set Color Black", NULL, MSG_LoadColorBlack, true);
tmp->AddInternal("Set Color White", NULL, MSG_LoadColorWhite, true);
m_listMenu.PushBack(tmp);
/*
tmp = new MenuBarMain("Project", m_mainWidget);

View File

@ -81,6 +81,7 @@ static char * GetMessageChar(messageType_te Id)
{
MACRO_DISPLAY_MSG(EDN_MSG__QUIT)
MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_CHANGE_CURRENT)
MACRO_DISPLAY_MSG(EDN_MSG__USER_DISPLAY_CHANGE)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_MAIN_WINDOWS)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_SEARCH)

View File

@ -41,6 +41,7 @@ typedef enum {
// Programm is Quitting... close all if needed ...
EDN_MSG__QUIT,
EDN_MSG__BUFFER_CHANGE_CURRENT, // set the new current BUFFER ...
EDN_MSG__USER_DISPLAY_CHANGE, // User change the display ==> need to reload all the display depending on color internal
// DESTINATION : GUI_MANAGER
MSG_TO_GUI_MANAGER__START,

View File

@ -18,7 +18,7 @@
<color name="SelectedText" FG="#AAAAAA" BG="#225a09"/>
<color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#00fF00"/>
<!-- hightline description : -->
<color name="type" FG="#56bf10" bold="yes"/>
<color name="storageKeyword" FG="#5c8fed"/>