From c61876b9198f0620fb525be2e5bdc4112e33fe71 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Mon, 16 Jan 2012 14:37:09 +0100 Subject: [PATCH] Some correction of the Display color is now availlable --- ctags.sh | 3 +++ jni/edn/Buffer/Buffer.cpp | 2 +- jni/edn/Buffer/Buffer.h | 2 +- jni/edn/Buffer/BufferEmpty.cpp | 14 +++++++++- jni/edn/Buffer/BufferEmpty.h | 2 +- jni/edn/Buffer/BufferManager.h | 24 ++++++++--------- jni/edn/Buffer/BufferText.cpp | 18 ++++++------- jni/edn/Buffer/BufferText.h | 4 +-- jni/edn/Colorize/Colorize.cpp | 30 +++++++++++++++++----- jni/edn/Colorize/ColorizeManager.cpp | 14 +++++++--- jni/edn/CustumWidget/CodeView/CodeView.cpp | 8 +++--- jni/edn/init.cpp | 2 -- jni/edn/tools/Display/Display.cpp | 6 +++-- 13 files changed, 84 insertions(+), 45 deletions(-) create mode 100755 ctags.sh diff --git a/ctags.sh b/ctags.sh new file mode 100755 index 0000000..8e7cabf --- /dev/null +++ b/ctags.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +ctags -R --fields=+n jni/ ../../../../usr/include/freetype2 ../ewol/ diff --git a/jni/edn/Buffer/Buffer.cpp b/jni/edn/Buffer/Buffer.cpp index 89bbc94..d1a624e 100644 --- a/jni/edn/Buffer/Buffer.cpp +++ b/jni/edn/Buffer/Buffer.cpp @@ -146,7 +146,7 @@ void Buffer::SetLineDisplay(uint32_t lineNumber) * @return --- * */ -int32_t Buffer::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) +int32_t Buffer::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) { return ERR_NONE; } diff --git a/jni/edn/Buffer/Buffer.h b/jni/edn/Buffer/Buffer.h index 5f95ecf..06f9010 100644 --- a/jni/edn/Buffer/Buffer.h +++ b/jni/edn/Buffer/Buffer.h @@ -82,7 +82,7 @@ class Buffer { virtual void GetInfo(infoStatBuffer_ts &infoToUpdate); virtual void SetLineDisplay(uint32_t lineNumber); - virtual int32_t Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); + virtual int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); virtual void ForceReDraw(bool allElement); virtual void AddChar(char * UTF8data); virtual void cursorMove(int32_t gtkKey); diff --git a/jni/edn/Buffer/BufferEmpty.cpp b/jni/edn/Buffer/BufferEmpty.cpp index 4968f02..566bdfb 100644 --- a/jni/edn/Buffer/BufferEmpty.cpp +++ b/jni/edn/Buffer/BufferEmpty.cpp @@ -67,8 +67,14 @@ BufferEmpty::~BufferEmpty(void) * @return --- * */ -int32_t BufferEmpty::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) +int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) { + ColorizeManager * myColorManager = ColorizeManager::getInstance(); + // Get color : + Colorize *myColor = NULL; + //drawer.Flush(); + + if (NULL == OOText) { EDN_ERROR("Input VALUE is NULL"); return ERR_FAIL; @@ -77,7 +83,13 @@ int32_t BufferEmpty::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored EDN_ERROR("Input VALUE is NULL"); return ERR_FAIL; } + + myColor = myColorManager->Get("normal"); + OOText->SetColor(myColor->GetFG()); OOText->TextAdd(20, 20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique", sizeX); + + myColor = myColorManager->Get("commentDoxygen"); + OOText->SetColor(myColor->GetFG()); OOText->TextAdd(20, 50, "No Buffer Availlable to display", sizeX); diff --git a/jni/edn/Buffer/BufferEmpty.h b/jni/edn/Buffer/BufferEmpty.h index 7a63963..031a4bb 100644 --- a/jni/edn/Buffer/BufferEmpty.h +++ b/jni/edn/Buffer/BufferEmpty.h @@ -32,7 +32,7 @@ class BufferEmpty : public Buffer { public: BufferEmpty(void); virtual ~BufferEmpty(void); - int32_t Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); + int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); }; diff --git a/jni/edn/Buffer/BufferManager.h b/jni/edn/Buffer/BufferManager.h index 6149827..02ce835 100644 --- a/jni/edn/Buffer/BufferManager.h +++ b/jni/edn/Buffer/BufferManager.h @@ -46,28 +46,28 @@ class BufferManager: public etk::Singleton, public MsgBroadcast // return the ID of the buffer allocated // create a buffer with no element - int32_t Create(void); + int32_t Create(void); // open curent filename - int32_t Open(etk::File &myFile); + int32_t Open(etk::File &myFile); int32_t GetSelected(void) { return m_idSelected;}; void SetSelected(int32_t id) {m_idSelected = id;}; Buffer * Get(int32_t BufferID); - bool Exist(int32_t BufferID); - bool Exist(etk::File &myFile); - int32_t GetId(etk::File &myFile); + bool Exist(int32_t BufferID); + bool Exist(etk::File &myFile); + int32_t GetId(etk::File &myFile); // return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5 - uint32_t Size(void); - int32_t WitchBuffer(int32_t iEmeElement); + uint32_t Size(void); + int32_t WitchBuffer(int32_t iEmeElement); - bool Remove(int32_t BufferID); + bool Remove(int32_t BufferID); private: - etk::VectorType listBuffer; //!< element List of the char Elements + etk::VectorType listBuffer; //!< element List of the char Elements - void RemoveAll(void); //!< remove all buffer - int32_t m_idSelected; - Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable) + void RemoveAll(void); //!< remove all buffer + int32_t m_idSelected; + Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable) }; #endif diff --git a/jni/edn/Buffer/BufferText.cpp b/jni/edn/Buffer/BufferText.cpp index 1792ba8..2f77f35 100644 --- a/jni/edn/Buffer/BufferText.cpp +++ b/jni/edn/Buffer/BufferText.cpp @@ -238,11 +238,12 @@ void BufferText::SetLineDisplay(uint32_t lineNumber) } -void BufferText::DrawLineNumber(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY) +void BufferText::DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY) { char tmpLineNumber[50]; sprintf(tmpLineNumber, myPrint, lineNumber); //drawer.Text(myColorManager->Get(COLOR_CODE_LINE_NUMBER), 1, positionY, tmpLineNumber); + OOText->SetColor(myColorManager->Get(COLOR_CODE_LINE_NUMBER)); OOText->TextAdd(1, positionY, tmpLineNumber, -1); } @@ -250,14 +251,12 @@ void BufferText::DrawLineNumber(ewol::OObject2DText* OOText, ewol::OObject2DColo void BufferText::CursorDisplay(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth) { - EWOL_ERROR("RequestCursorDisplay(" << x << "," << y << ")" ); -/* + //EDN_ERROR("RequestCursorDisplay(" << x << "," << y << ")" ); color_ts & tmpppppp = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR); OOColored->SetColor(tmpppppp); OOColored->Rectangle( x, y, letterWidth, letterHeight); -*/ // get the cursor Color : //color_ts myColor = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR); @@ -326,7 +325,7 @@ void BufferText::UpdatePointerNumber(void) * @return * */ -int32_t BufferText::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) +int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) { int32_t selStart, selEnd, selRectStart, selRectEnd; bool selIsRect; @@ -468,9 +467,11 @@ int32_t BufferText::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* } if (currentChar <= 0x7F) { //drawer.Text(selectColor, pixelX ,y, tmpDisplayOfset); + OOText->SetColor(selectColor->GetFG()); OOText->TextAdd(pixelX, y, tmpDisplayOfset, -1); } else { //drawer.Text(selectColor, pixelX ,y, displayChar); + OOText->SetColor(selectColor->GetFG()); OOText->TextAdd(pixelX, y, displayChar, -1); } } @@ -481,12 +482,8 @@ int32_t BufferText::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* // display cursor : //EDN_DEBUG(" is equal : " << m_cursorPos << "=" << iii); if (m_cursorPos == iii) { - EDN_DEBUG("Yes ..."); // display the cursor: - CursorDisplay(OOColored, pixelX, y+letterHeight, letterHeight, letterWidth); - color_ts & tmpppppp = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR); - OOColored->SetColor(tmpppppp); - OOColored->Rectangle( pixelX, y+letterHeight, letterWidth, letterHeight); + CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth); /*if (true == m_cursorOn) { //Cursor(OOColored, pixelX, y+letterHeight, letterHeight, letterWidth); //m_cursorOn = false; @@ -529,6 +526,7 @@ int32_t BufferText::Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* void BufferText::GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y) { + x = (width - 3) / Display::GetFontWidth() - nbColoneForLineNumber; y = height / Display::GetFontHeight(); if (x < 0) { diff --git a/jni/edn/Buffer/BufferText.h b/jni/edn/Buffer/BufferText.h index 8d4c813..f46cc3a 100644 --- a/jni/edn/Buffer/BufferText.h +++ b/jni/edn/Buffer/BufferText.h @@ -46,7 +46,7 @@ class BufferText : public Buffer { void GetInfo(infoStatBuffer_ts &infoToUpdate); void SetLineDisplay(uint32_t lineNumber); - int32_t Display(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); + int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); void ForceReDraw(bool allElement); void AddChar(char * UTF8data); void cursorMove(int32_t gtkKey); @@ -114,7 +114,7 @@ class BufferText : public Buffer { void GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y); void MoveUpDown(int32_t ofset); - void DrawLineNumber(ewol::OObject2DText* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY); + void DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY); void CursorDisplay(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth); diff --git a/jni/edn/Colorize/Colorize.cpp b/jni/edn/Colorize/Colorize.cpp index 1031c9f..2f01928 100644 --- a/jni/edn/Colorize/Colorize.cpp +++ b/jni/edn/Colorize/Colorize.cpp @@ -38,9 +38,11 @@ Colorize::Colorize( etk::String &newColorName) m_colorFG.red=0; m_colorFG.green=0; m_colorFG.blue=0; + m_colorFG.alpha=1; m_colorBG.red=0; m_colorBG.green=0; m_colorBG.blue=0; + m_colorBG.alpha=1; italic = false; bold = false; @@ -57,9 +59,11 @@ Colorize::Colorize(void) m_colorFG.red=0; m_colorFG.green=0; m_colorFG.blue=0; + m_colorFG.alpha=1; m_colorBG.red=0; m_colorBG.green=0; m_colorBG.blue=0; + m_colorBG.alpha=1; italic = false; bold = false; @@ -97,24 +101,38 @@ etk::String Colorize::GetName(void) void Colorize::SetFgColor(const char *myColor) { haveFG = true; - unsigned int r=0; - unsigned int v=0; - unsigned int b=0; - sscanf(myColor, "#%02x%02x%02x", &r,&v,&b); + signed int r=0; + signed int v=0; + signed int b=0; + signed int a=-1; + sscanf(myColor, "#%02x%02x%02x%02x", &r, &v, &b, &a); m_colorFG.red = (float)r/255.0; m_colorFG.green = (float)v/255.0; m_colorFG.blue = (float)b/255.0; + if (-1 == a) { + m_colorFG.alpha = 1; + } else { + m_colorFG.alpha = (float)a/255.0; + } //EDN_INFO(myColor << " ==> r="<< r <<" v="<< v <<" b="<< b ); } void Colorize::SetBgColor(const char *myColor) { haveBG = true; - unsigned int r,v,b; - sscanf(myColor, "#%02x%02x%02x", &r,&v,&b); + signed int r=0; + signed int v=0; + signed int b=0; + signed int a=-1; + sscanf(myColor, "#%02x%02x%02x%02x", &r, &v, &b, &a); m_colorBG.red = (float)r/255.0; m_colorBG.green = (float)v/255.0; m_colorBG.blue = (float)b/255.0; + if (-1 == a) { + m_colorBG.alpha = 1; + } else { + m_colorBG.alpha = (float)a/255.0; + } } bool Colorize::HaveBg(void) diff --git a/jni/edn/Colorize/ColorizeManager.cpp b/jni/edn/Colorize/ColorizeManager.cpp index 6b25cd2..2ca1dfa 100644 --- a/jni/edn/Colorize/ColorizeManager.cpp +++ b/jni/edn/Colorize/ColorizeManager.cpp @@ -150,13 +150,19 @@ void ColorizeManager::LoadFile(const char * xmlFilename) } const char *color = pGuiNode->ToElement()->Attribute("val"); if (NULL != color) { - unsigned int r=0; - unsigned int v=0; - unsigned int b=0; - sscanf(color, "#%02x%02x%02x", &r,&v,&b); + int r=0; + int v=0; + int b=0; + int a=-1; + sscanf(color, "#%02x%02x%02x%02x", &r, &v, &b, &a); basicColors[id].red = (float)r/255.0; basicColors[id].green = (float)v/255.0; basicColors[id].blue = (float)b/255.0; + if (-1 == a) { + basicColors[id].alpha = 1; + } else { + basicColors[id].alpha = (float)a/255.0; + } /* EDN_INFO(" Specify color for system ID="<< id ); EDN_INFO(" " << color << " ==> r="<< r <<" v="<< v <<" b="<< b ); diff --git a/jni/edn/CustumWidget/CodeView/CodeView.cpp b/jni/edn/CustumWidget/CodeView/CodeView.cpp index 33aa316..66f13e7 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.cpp +++ b/jni/edn/CustumWidget/CodeView/CodeView.cpp @@ -81,8 +81,8 @@ bool CodeView::CalculateMinSize(void) void CodeView::OnRegenerateDisplay(void) { // create tmp object : - ewol::OObject2DText* myOObjectText = new ewol::OObject2DText("", -1, m_textColorFg); - ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored(); + ewol::OObject2DTextColored* myOObjectText = new ewol::OObject2DTextColored("", -1); + ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored(); // generate the objects : m_bufferID = 0; @@ -128,6 +128,8 @@ bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y) { + x -= m_origin.x; + y -= m_origin.y; /* etk::String type = (int)typeEvent; switch (typeEvent) @@ -232,7 +234,7 @@ void CodeView::OnMessage(int32_t id, int32_t dataID) //EDN_INFO("Select a new Buffer ... " << dataID); m_bufferID = dataID; m_bufferManager->Get(m_bufferID)->ForceReDraw(true); - // request the dispplay of the curent Editor + // request the display of the curent Editor SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID); break; case EDN_MSG__CURRENT_SAVE: diff --git a/jni/edn/init.cpp b/jni/edn/init.cpp index 36003f7..2be97ef 100644 --- a/jni/edn/init.cpp +++ b/jni/edn/init.cpp @@ -137,13 +137,11 @@ void APP_Init(int argc, char *argv[]) { EDN_INFO("need load file : \"" << "avancement.boo" << "\"" ); etk::File myfile("avancement.boo", etk::FILE_TYPE_DIRECT); - if (false == myBufferManager->Exist(myfile) ) { int32_t idBuffOpened = myBufferManager->Open(myfile); MsgBroadcastCore::getInstance()->SendMessage(NULL, EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idBuffOpened); } } - basicWindows = new MainWindows(); if (NULL == basicWindows) { EDN_ERROR("Can not allocate the basic windows"); diff --git a/jni/edn/tools/Display/Display.cpp b/jni/edn/tools/Display/Display.cpp index cf4e902..5685e5f 100644 --- a/jni/edn/tools/Display/Display.cpp +++ b/jni/edn/tools/Display/Display.cpp @@ -105,12 +105,14 @@ void Display::UnInit(void) int32_t Display::GetFontHeight(void) { - return m_pangoFontHeight; + int32_t fontId = ewol::GetDefaultFontId(); + return ewol::GetHeight(fontId); } int32_t Display::GetFontWidth(void) { - return m_pangoFontWidth; + int32_t fontId = ewol::GetDefaultFontId(); + return ewol::GetWidth(fontId, "A"); }