diff --git a/Sources/appl/Buffer/BufferEmpty.cpp b/Sources/appl/Buffer/BufferEmpty.cpp index f97936b..32771f9 100644 --- a/Sources/appl/Buffer/BufferEmpty.cpp +++ b/Sources/appl/Buffer/BufferEmpty.cpp @@ -76,8 +76,7 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored& OOTextNormal, // Get color : Colorize *myColor = NULL; - int32_t fontId = OOTextNormal.GetFontID(); - int32_t letterHeight = ewol::GetHeight(fontId); + int32_t letterHeight = OOTextNormal.GetHeight(); Vector2D textPos; textPos.x = 20; diff --git a/Sources/appl/Buffer/BufferText.cpp b/Sources/appl/Buffer/BufferText.cpp index a1834db..44f4f2e 100644 --- a/Sources/appl/Buffer/BufferText.cpp +++ b/Sources/appl/Buffer/BufferText.cpp @@ -289,9 +289,8 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal, bool selIsRect; int32_t selHave; - int32_t fontId = OOTextNormal.GetFontID(); - int32_t letterWidth = ewol::GetWidth(fontId, "A"); - int32_t letterHeight = ewol::GetHeight(fontId); + int32_t letterWidth = OOTextNormal.GetSize("A").x; + int32_t letterHeight = OOTextNormal.GetHeight(); int32_t displayStartLineId = offsetY / letterHeight - 1; displayStartLineId = etk_max(0, displayStartLineId); @@ -479,9 +478,18 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal, int32_t BufferText::GetMousePosition(int32_t fontId, int32_t width, int32_t height) { + // TODO : Set it back ... + #if 1 + int32_t letterWidth = 8; + int32_t letterHeight = 15; + #else int32_t letterWidth = ewol::GetWidth(fontId, "9"); int32_t letterHeight = ewol::GetHeight(fontId); - + /* + int32_t letterWidth = OOTextNormal.GetSize("A").x; + int32_t letterHeight = OOTextNormal.GetHeight(); + */ + #endif int32_t lineOffset = height / letterHeight; //******************************* get the X position : ******************************************* @@ -513,7 +521,9 @@ int32_t BufferText::GetMousePosition(int32_t fontId, int32_t width, int32_t heig new_i = iii; displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar); if (currentChar!='\n') { - int32_t drawSize = ewol::GetWidth(fontId, displayChar); + // TODO : Set it back ... + //int32_t drawSize = ewol::GetWidth(fontId, displayChar); + int32_t drawSize = 50; APPL_VERBOSE(" Element : " << currentChar << "=\"" << (char)currentChar << "\" display offset=" << pixelX << "px width=" << drawSize << "px"); pixelX += drawSize; if (width <= pixelX) { @@ -870,8 +880,13 @@ Vector2D BufferText::GetPosition(int32_t fontId, bool& centerRequested) // get font porperties : // TODO : change this : + // TODO : Set it back ... + /* float letterWidth = ewol::GetWidth(fontId, "A"); float letterHeight = ewol::GetHeight(fontId); + */ + float letterWidth = 10; + float letterHeight = 15; outputPosition.x *= letterWidth; outputPosition.y *= letterHeight; return outputPosition; diff --git a/Sources/appl/Gui/CodeView.cpp b/Sources/appl/Gui/CodeView.cpp index 83ae722..188a96c 100644 --- a/Sources/appl/Gui/CodeView.cpp +++ b/Sources/appl/Gui/CodeView.cpp @@ -45,11 +45,6 @@ CodeView::CodeView(void) { m_label = "CodeView is disable ..."; - m_fontNormal = -1; - m_fontBold = -1; - m_fontItalic = -1; - m_fontBoldItalic = -1; - m_fontSize = 15; m_bufferID = -1; m_buttunOneSelected = false; @@ -111,7 +106,7 @@ bool CodeView::CalculateMinSize(void) void CodeView::CalculateMaxSize(void) { m_maxSize.x = 2048; - int32_t letterHeight = ewol::GetHeight(m_fontNormal); + int32_t letterHeight = m_OObjectTextNormal.GetHeight(); m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight; } @@ -134,12 +129,6 @@ void CodeView::OnRegenerateDisplay(void) // For the scrooling windows CalculateMaxSize(); - // clean internal elements ... - m_OObjectTextNormal.SetFontID(m_fontNormal); - m_OObjectTextBold.SetFontID(m_fontBold); - m_OObjectTextItalic.SetFontID(m_fontItalic); - m_OObjectTextBoldItalic.SetFontID(m_fontBoldItalic); - m_OObjectTextNormal.Clear(); m_OObjectTextBold.Clear(); m_OObjectTextItalic.Clear(); @@ -150,7 +139,8 @@ void CodeView::OnRegenerateDisplay(void) if(true == BufferManager::Get(m_bufferID)->NeedToUpdateDisplayPosition() ) { Vector2D borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize(); bool centerRequested = false; - Vector2D currentPosition = BufferManager::Get(m_bufferID)->GetPosition(m_OObjectTextNormal.GetFontID(), centerRequested); + // TODO : set it back ... + Vector2D currentPosition = BufferManager::Get(m_bufferID)->GetPosition(999/*m_OObjectTextNormal.GetFontID()*/, centerRequested); SetScrollingPositionDynamic(borderWidth, currentPosition, centerRequested); } // else : nothing to do ... @@ -233,7 +223,8 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { m_buttunOneSelected = true; ewol::widgetManager::FocusKeep(this); - BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y); + // TODO : Set something good + BufferManager::Get(m_bufferID)->MouseEvent(999/*m_fontNormal*/, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y); MarkToRedraw(); } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { m_buttunOneSelected = false; @@ -267,13 +258,15 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even yyy = 0; } //APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy); - BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(m_fontNormal, xxx+m_originScrooled.x, yyy+m_originScrooled.y); + // TODO : Set something good + BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(999/*m_fontNormal*/, xxx+m_originScrooled.x, yyy+m_originScrooled.y); MarkToRedraw(); } } } else if (2 == IdInput) { if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { - BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y); + // TODO : Set something good + BufferManager::Get(m_bufferID)->MouseEvent(999/*m_fontNormal*/, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y); ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_SELECTION); ewol::widgetManager::FocusKeep(this); } @@ -408,38 +401,29 @@ void CodeView::OnLostFocus(void) void CodeView::SetFontSize(int32_t size) { - m_fontSize = size; - SetScrollingSize(m_fontSize*3.0*1.46); // 1.46 is a magic nmber ... + m_OObjectTextNormal.SetSize(size); + m_OObjectTextBold.SetSize(size); + m_OObjectTextItalic.SetSize(size); + m_OObjectTextBoldItalic.SetSize(size); + SetScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ... } void CodeView::SetFontNameNormal(etk::UString fontName) { - int32_t fontID = ewol::LoadFont(fontName, m_fontSize); - if (fontID >= 0) { - m_fontNormal = fontID; - } + m_OObjectTextNormal.SetFont(fontName); } void CodeView::SetFontNameBold(etk::UString fontName) { - int32_t fontID = ewol::LoadFont(fontName, m_fontSize); - if (fontID >= 0) { - m_fontBold = fontID; - } + m_OObjectTextBold.SetFont(fontName); } void CodeView::SetFontNameItalic(etk::UString fontName) { - int32_t fontID = ewol::LoadFont(fontName, m_fontSize); - if (fontID >= 0) { - m_fontItalic = fontID; - } + m_OObjectTextItalic.SetFont(fontName); } void CodeView::SetFontNameBoldItalic(etk::UString fontName) { - int32_t fontID = ewol::LoadFont(fontName, m_fontSize); - if (fontID >= 0) { - m_fontBoldItalic = fontID; - } + m_OObjectTextBoldItalic.SetFont(fontName); } diff --git a/Sources/appl/Gui/CodeView.h b/Sources/appl/Gui/CodeView.h index 1ab6e04..517d935 100644 --- a/Sources/appl/Gui/CodeView.h +++ b/Sources/appl/Gui/CodeView.h @@ -33,6 +33,7 @@ #include #include +#include class CodeView :public ewol::WidgetScrooled { @@ -48,13 +49,13 @@ class CodeView :public ewol::WidgetScrooled const char * const GetObjectType(void) { return "ApplCodeView"; }; virtual bool CalculateMinSize(void); private: - etk::UString m_label; - draw::Color m_textColorFg; //!< Text color - draw::Color m_textColorBg; //!< Background color - int32_t m_bufferID; - bool m_buttunOneSelected; + etk::UString m_label; + draw::Color m_textColorFg; //!< Text color + draw::Color m_textColorBg; //!< Background color + int32_t m_bufferID; + bool m_buttunOneSelected; etk::Vector > m_lineNumberList; - void UpdateNumberOfLineReference(int32_t bufferID); + void UpdateNumberOfLineReference(int32_t bufferID); // drawing elements : ewol::OObject2DTextColored m_OObjectTextNormal; ewol::OObject2DTextColored m_OObjectTextBold; @@ -95,12 +96,6 @@ class CodeView :public ewol::WidgetScrooled virtual void OnGetFocus(void); virtual void OnLostFocus(void); - private: - int32_t m_fontSize; - int32_t m_fontNormal; - int32_t m_fontBold; - int32_t m_fontItalic; - int32_t m_fontBoldItalic; public: void SetFontSize(int32_t size); void SetFontNameNormal(etk::UString fontName); diff --git a/Sources/appl/init.cpp b/Sources/appl/init.cpp index c013112..54c938d 100644 --- a/Sources/appl/init.cpp +++ b/Sources/appl/init.cpp @@ -41,6 +41,7 @@ #include #include #include +#include MainWindows * basicWindows = NULL; @@ -66,14 +67,13 @@ void APP_Init(void) ewol::ChangeSize(Vector2D(800, 600)); etk::InitDefaultFolder(PROJECT_NAME); - ewol::SetFontFolder("Font"); - + ewol::font::SetFontFolder("Font"); + ewol::font::SetDefaultFont("freefont/FreeSerif.ttf"); #ifdef __TARGET_OS__Android - ewol::SetDefaultFont("freefont/FreeSerif.ttf", 19); + ewol::font::SetDefaultSize(19); #else - ewol::SetDefaultFont("freefont/FreeSerif.ttf", 14); + ewol::font::SetDefaultSize(14); #endif - // init internal global value globals::init();