First port of edn on the android platform ==> can do nothing but not crach every 10 second

This commit is contained in:
2012-01-25 18:30:33 +01:00
parent ee80871434
commit 102e11b74a
20 changed files with 221 additions and 688 deletions

View File

@@ -2,19 +2,22 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ednpackage
LOCAL_STATIC_LIBRARIES := ewol
LOCAL_C_INCLUDES := $(LOCAL_PATH)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_MODULE := ednpackage
LOCAL_STATIC_LIBRARIES := ewol etk tinyxml libzip libpng
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := ewolAndroidAbstraction.cpp \
$(FILE_LIST)
LOCAL_LDLIBS := -llog -landroid
LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \
-DEDN_DEBUG_LEVEL=3
include $(BUILD_SHARED_LIBRARY)
NDK_MODULE_PATH := $(LOCAL_PATH)/../../

View File

@@ -6,15 +6,17 @@ include $(CLEAR_VARS)
include $(LOCAL_PATH)/file.mk
LOCAL_MODULE := ednn
LOCAL_STATIC_LIBRARIES := ewol etk tinyxml libzip libpng
LOCAL_STATIC_LIBRARIES := ewol etk tinyxml libzip libpng libfreetype
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) $(addprefix -I$(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \
-DEDN_DEBUG_LEVEL=3
LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \
-DEDN_DEBUG_LEVEL=3
include $(BUILD_EXECUTABLE)

View File

@@ -307,7 +307,6 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
int32_t fontId = ewol::GetDefaultFontId();
int32_t letterWidth = ewol::GetWidth(fontId, "A");
int32_t spaceWidth = ewol::GetWidth(fontId, " ");
int32_t letterHeight = ewol::GetHeight(fontId);
// update the number of element that can be displayed
@@ -345,12 +344,9 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
int mylen = m_EdnBuf.Size();
int32_t x_base=nbColoneForLineNumber*letterWidth + 3;
uint32_t xx = 0;
int32_t idX = 0;
color_ts bgColor;
color_ts & tmpppppp = myColorManager->Get(COLOR_CODE_BASIC_BG);
OOColored->SetColor(tmpppppp);
OOColored->SetColor(myColorManager->Get(COLOR_CODE_BASIC_BG));
OOColored->Rectangle( 0, 0, sizeX, sizeY);
int displayLines = 0;
@@ -433,7 +429,6 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
pixelX += drawSize;
// move to next line ...
if (currentChar=='\n') {
xx = 0;
idX =0;
pixelX = x_base;
y += letterHeight;

View File

@@ -99,7 +99,6 @@ class BufferText : public Buffer {
// internal function
void BasicInit(void);
void UpdateWindowsPosition(bool centerPage = false);
void displayLineNumber(DrawerManager &drawer);
void CleanSelectLine(void);

View File

@@ -95,7 +95,33 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
// allocate the document in the stack
TiXmlDocument XmlDocument;
// open the curent File
XmlDocument.LoadFile(xmlFilename);
etk::File fileName(xmlFilename, etk::FILE_TYPE_DATA);
if (false == fileName.Exist()) {
EWOL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.Size();
if (0==fileSize) {
EWOL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.fOpenRead()) {
EWOL_ERROR("Can not open the file : " << fileName);
return;
}
// allocate data
char * fileBuffer = new char[fileSize];
if (NULL == fileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
// load data from the file :
fileName.fRead(fileBuffer, 1, fileSize);
// close the file:
fileName.fClose();
// load the XML from the memory
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
if (NULL == root ) {
EDN_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
@@ -234,6 +260,9 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
pNode = pNode->NextSibling();
}
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
SendMessage(EDN_MSG__COLOR_HAS_CHANGE);
SendMessage(EDN_MSG__USER_DISPLAY_CHANGE);
}

View File

@@ -93,7 +93,7 @@ void HighlightManager::loadLanguages(void)
#else
homedir = "./data/";
#endif
/*
etk::String xmlFilename = homedir;
xmlFilename += "lang_c.xml";
Highlight *myHightline = new Highlight(xmlFilename);
@@ -138,7 +138,7 @@ void HighlightManager::loadLanguages(void)
xmlFilename += "lang_java.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
*/
//myHightline->Display();
}

View File

@@ -71,9 +71,9 @@ void APP_Init(int argc, char *argv[])
ewol::SetFontFolder("Font");
#ifdef EWOL_USE_FREE_TYPE
//ewol::SetDefaultFont("freefont/FreeMono.ttf", 12);
ewol::SetDefaultFont("freefont/FreeMono.ttf", 12);
//ewol::SetDefaultFont("freefont/FreeMonoBold.ttf", 12);
ewol::SetDefaultFont("ACharmingFont.ttf", 45);
//ewol::SetDefaultFont("ACharmingFont.ttf", 45);
//ewol::SetDefaultFont("Monospace/Monospace", 40);
//ewol::SetDefaultFont("unispace.ttf", 12);
#else
@@ -84,7 +84,6 @@ void APP_Init(int argc, char *argv[])
// init internal global value
globals::init();
ClipBoard::Init();
Display::Init();
// init ALL Singleton :
@@ -105,7 +104,7 @@ void APP_Init(int argc, char *argv[])
homedir = "./data/";
#endif
//homedir += "color_black.xml";
homedir += "color_white.xml";
homedir = "color_white.xml";
myColorManager->LoadFile( homedir.c_str() );
myColorManager->DisplayListOfColor();
@@ -138,6 +137,7 @@ void APP_Init(int argc, char *argv[])
}
}
}
/*
{
etk::File myfile((char *)"licence.txt", etk::FILE_TYPE_DIRECT);
if (false == myBufferManager->Exist(myfile) ) {
@@ -145,6 +145,7 @@ void APP_Init(int argc, char *argv[])
MsgBroadcastCore::getInstance()->SendMessage(NULL, EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idBuffOpened);
}
}
*/
if (NULL == basicWindows) {
EDN_ERROR("Can not allocate the basic windows");
ewol::Stop();
@@ -171,8 +172,6 @@ void APP_UnInit(void)
//Search::kill();
EDN_INFO("Stop Accel key");
//AccelKey::kill();
EDN_INFO("Stop Display");
Display::UnInit();
if (NULL != basicWindows) {
delete(basicWindows);
}

View File

@@ -26,82 +26,10 @@
#include <tools_debug.h>
#include <tools_globals.h>
#include <Display.h>
#include <ColorizeManager.h>
#include <etk/String.h>
#undef __class__
#define __class__ "Display"
#define FONT_BOLD_NO (0)
#define FONT_BOLD_YES (1)
#define FONT_ITALIC_NO (0)
#define FONT_ITALIC_YES (1)
// Variables privé du namespace
#define POLICE_NAME "Monospace"
/*
#ifdef USE_GTK_VERSION_3_0
#define POLICE_SIZE 15
static int32_t m_pangoFontWidth = 9;
static int32_t m_pangoFontHeight = 19;
#elif USE_GTK_VERSION_2_0
*/
#define POLICE_SIZE 12
static int32_t m_pangoFontWidth = 7;
static int32_t m_pangoFontHeight = 15;
//#endif
/*
#define POLICE_SIZE 11
static int32_t m_pangoFontWidth = 7;
static int32_t m_pangoFontHeight = 11;
static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}};
*/
//static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}};
void Display::Init(void)
{
/*
m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
if ( NULL == m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]) {
EDN_ASSERT(FALSE, "basic font ERROR");
}
if ( NULL == m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]) {
EDN_ERROR("Italic font error ... link with basic font");
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
}
if ( NULL == m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]) {
EDN_ERROR("Bold font error ... link with basic font");
m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
}
if ( NULL == m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]) {
EDN_ERROR("Italic & Bold font error ... link with basic font");
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
}
*/
}
void Display::UnInit(void)
{
/*
// clean the builder...
cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]);
cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]);
cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]);
cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]);
*/
}
int32_t Display::GetFontHeight(void)
{
int32_t fontId = ewol::GetDefaultFontId();
@@ -114,540 +42,3 @@ int32_t Display::GetFontWidth(void)
return ewol::GetWidth(fontId, "A");
}
void * Display::GetFont(bool bold, bool italic)
{
/*
if( false == bold
&& false == italic) {
return m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
} else if( true == bold
&& false == italic) {
return m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES];
} else if ( false == bold
&& true == italic) {
return m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO];
}
return m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES];
*/
return NULL;
}
#undef __class__
#define __class__ "DrawerManager"
/**
* @brief DrawerManager constructor : generate a memoryDC where we can draw everything...
*
* @param [in] window Current windows where the memoryDC must be paint
* @param [in] x Current width of the Display
* @param [in] y Current Height of the Display
*
* @note : No exeption
*
* @return ---
*
*/
DrawerManager::DrawerManager(void * widget, int32_t x, int32_t y)
{
m_size.x = x;
m_size.y = y;
m_haveWork = false;
m_nbElement = 0;
// Create the Cairo Element
/*
# if USE_GTK_VERSION_3_0
m_cairo = gdk_cairo_create(gtk_widget_get_window(widget));
# elif USE_GTK_VERSION_2_0
m_cairo = gdk_cairo_create(widget->window);
# endif
//cairo_translate(m_cairo, 0, 7);
cairo_set_source_rgb(m_cairo, 0, 0, 0);
cairo_paint(m_cairo);
cairo_set_font_size(m_cairo, POLICE_SIZE);
*/
m_dataToDisplay[0] = '\0';
//cairo_scale(m_cairo, 1.0, 1.0);
}
/**
* @brief main DrawerManager destructor : Copy data on the curent screen
*
* @param ---
*
* @note : No exeption
*
* @return ---
*
*/
DrawerManager::~DrawerManager()
{
//cairo_destroy(m_cairo);
}
/**
* @brief Draw Text with the specify color
*
* This function does not display the text directly, it save it while a flush appare or the y position differ, or the color differ.
* This is for the char by char writing ==> more efficient when we write multiple char.
*
* @param [in] SelectColor Color that is used to display data
* @param [in] x Horizontal position to display data
* @param [in] y Vertical position to display data
* @param [in] myText Text to write in UTF8 ...
* @param [in] displayBG unused
*
* @return ---
*
*/
void DrawerManager::Text(Colorize *SelectColor, int32_t x, int32_t y,const char *myUTF8Text, int32_t len)
{
/*
EDN_CHECK_INOUT(NULL!=SelectColor);
// check if flush is needed :
if (true == m_haveWork) {
if( m_pos.y != y
|| m_selectColor != SelectColor)
{
Flush();
}
}
// check change
if (false == m_haveWork) {
m_pos.x = x;
m_pos.y = y;
m_selectColor = SelectColor;
}
//EDN_WARNING("add data : \"" << myText << "\" x=" << x << " y=" << y );
// process :
m_haveWork = true;
strcat(m_dataToDisplay, myUTF8Text);
if (len != -1 ) {
m_nbElement+=len;
} else {
m_nbElement+=strUtf8Len(myUTF8Text);
}
*/
}
void DrawerManager::Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int32_t x, int32_t y,const char *myText)
{
/*
Flush();
cairo_set_font_face(m_cairo, Display::GetFont(false, false));
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
DirectRectangle(SelectColorBg, x, y, letterWidth*strlen(myText), letterHeight);
cairo_fill(m_cairo);
cairo_move_to(m_cairo, x, y+letterHeight-4);
cairo_set_source_rgb(m_cairo, SelectColorFg.red, SelectColorFg.green, SelectColorFg.blue);
cairo_show_text(m_cairo, myText);
cairo_fill(m_cairo);
*/
}
void DrawerManager::Text(color_ts & SelectColorFg, int32_t x, int32_t y,const char *myText)
{
/*
Flush();
cairo_set_font_face(m_cairo, Display::GetFont(false, false));
int32_t letterHeight = Display::GetFontHeight();
cairo_move_to(m_cairo, x, y+letterHeight-4);
cairo_set_source_rgb(m_cairo, SelectColorFg.red, SelectColorFg.green, SelectColorFg.blue);
cairo_show_text(m_cairo, myText);
cairo_fill(m_cairo);
*/
}
void DrawerManager::SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar)
{
/*
Flush();
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
DirectRectangle(SelectColor, x, y, letterWidth*nbChar, letterHeight);
cairo_fill(m_cairo);
*/
}
/**
* @brief Force de display of the curent Text
*
* The flush is to be more performent with the Pango display methode...
*
* @param ---
*
* @return ---
*
*/
void DrawerManager::Flush(void)
{
/*
if (true == m_haveWork) {
//EDN_WARNING("flush : \"" << m_dataToDisplay << "\"" << " bold=" << m_selectColor->GetBold() << " italic=" << m_selectColor->GetItalic());
m_haveWork = false;
cairo_set_font_face(m_cairo, Display::GetFont(m_selectColor->GetBold(), m_selectColor->GetItalic()));
int32_t letterHeight = Display::GetFontHeight();
if (true == m_selectColor->HaveBg() ) {
int32_t letterWidth = Display::GetFontWidth();
int32_t stringLen = m_nbElement;
// generate Clean BG:
DirectRectangle(m_selectColor, m_pos.x, m_pos.y, letterWidth*stringLen, letterHeight);
}
cairo_move_to(m_cairo, m_pos.x, m_pos.y+letterHeight-4);
m_selectColor->ApplyFG(m_cairo);
cairo_show_text(m_cairo, m_dataToDisplay);
cairo_fill(m_cairo);
m_dataToDisplay[0] = '\0';
m_nbElement = 0;
}
*/
}
/**
* @brief display a rectangle with the curent bgColor and no border
*
* This function in the open API to drow the rectangle, it flush the curent Text in the buffer
*
* @param [in] SelectColor Color that is used to display rectangle
* @param [in] x Horizontal position to display rectangle
* @param [in] y Vertical position to display rectangle
* @param [in] width Width of the rectangle
* @param [in] height Height of the rectangle
*
* @return ---
*
*/
void DrawerManager::Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{
//Flush();
//DirectRectangle(SelectColor, x, y, width, height);
}
/**
* @brief Real function to display the rectangle (no flush done (expectially for the Background display)
*
* @param [in] SelectColor Color that is used to display rectangle
* @param [in] x Horizontal position to display rectangle
* @param [in] y Vertical position to display rectangle
* @param [in] width Width of the rectangle
* @param [in] height Height of the rectangle
*
* @return ---
*
*/
void DrawerManager::DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{
/*
EDN_CHECK_INOUT(NULL!=SelectColor);
//EDN_INFO("x="<< x <<" y="<< y <<" width="<< width <<" height="<< height);
//gdk_draw_rectangle( p_pixmap, SelectColor->GetColorBG(), TRUE, x, y, width, height);
// set color
SelectColor->ApplyBG(m_cairo);
// set postion
cairo_rectangle(m_cairo, x, y, width, height);
//cairo_stroke(m_cairo);
// flush
cairo_fill(m_cairo);
*/
}
void DrawerManager::DirectRectangle(color_ts &SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{
/*
cairo_set_source_rgb(m_cairo, SelectColor.red, SelectColor.green, SelectColor.blue);
// set postion
cairo_rectangle(m_cairo, x, y, width, height);
//cairo_stroke(m_cairo);
// flush
cairo_fill(m_cairo);
*/
}
/**
* @brief Clean the curent Windows with the curent color
*
* @param [in] SelectColor Color that is used to display background
*
* @return ---
*
*/
void DrawerManager::Clean(Colorize *SelectColor)
{
/*
m_haveWork = false;
DirectRectangle(SelectColor, 0, 0, m_size.x, m_size.y);
*/
}
/**
* @brief Clean the curent Windows with the curent color
*
* @param [in] SelectColor Color that is used to display background
*
* @return ---
*
*/
void DrawerManager::Clean(color_ts & SelectColor)
{
/*
m_haveWork = false;
DirectRectangle(SelectColor, 0, 0, m_size.x, m_size.y);
*/
}
/**
* @brief Display a cursor with the cortect form.
*
* Automatic selection of the XML color "cursorColor"
*
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
*
* @return ---
*
*/
#define CURSOR_WIDTH (4)
void DrawerManager::Cursor(int32_t x, int32_t y)
{
/*
Flush();
// get the cursor Color :
color_ts myColor = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR);
cairo_set_source_rgb(m_cairo, myColor.red, myColor.green, myColor.blue);
// draw cursor
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
// depending on the inserting mode
if (false == globals::IsSetInsert()) {
cairo_set_line_width(m_cairo, 2);
cairo_move_to(m_cairo, x-CURSOR_WIDTH, y - letterHeight+1);
cairo_rel_line_to(m_cairo, CURSOR_WIDTH*2, 0);
cairo_rel_move_to(m_cairo, -CURSOR_WIDTH, 0);
cairo_rel_line_to(m_cairo, 0, letterHeight-2);
cairo_rel_move_to(m_cairo, -CURSOR_WIDTH, 0);
cairo_rel_line_to(m_cairo, CURSOR_WIDTH*2, 0);
} else {
cairo_set_line_width(m_cairo, 1);
cairo_move_to(m_cairo, x, y - letterHeight + 1);
cairo_rel_line_to(m_cairo, letterWidth, 0);
cairo_rel_line_to(m_cairo, 0, letterHeight);
cairo_rel_line_to(m_cairo, -letterWidth, 0);
cairo_rel_line_to(m_cairo, 0, -letterHeight);
}
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
*/
}
/**
* @brief Display a end of the curent line ...
*
* Automatic draw the end of line with the curent XML color "cursorColor"
*
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
*
* @return ---
*
*/
void DrawerManager::EndOfLine(int32_t x, int32_t y)
{
#if 0
if (true == globals::IsSetDisplayEndOfLine() ) {
Flush();
// get the cursor Color :
color_ts myColor = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR);
cairo_set_source_rgb(m_cairo, myColor.red, myColor.green, myColor.blue);
// draw cursor
int32_t letterHeight = Display::GetFontHeight();
// depending on the inserting mode
/*
x1 x2
y1 | |-----
| |-----
| |
y2 | |
*/
cairo_set_line_width(m_cairo, 2);
cairo_move_to(m_cairo, x, y - letterHeight+1);
cairo_rel_line_to(m_cairo, 0, letterHeight);
cairo_move_to(m_cairo, x+2, y - letterHeight+1);
cairo_rel_line_to(m_cairo, 0, letterHeight);
cairo_arc(m_cairo, x+3, y - letterHeight/4*3, 3.0, -3.149/2, 3.149/2);
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
}
#endif
}
/**
* @brief Display a Tabulation with the user form selection.
*
* @param [in] SelectColor Color that is used to display Tabulation
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
* @param [in] mbColomn Width of the current Tabulation caracter (in number of Char)
*
* @return ---
*
*/
void DrawerManager::Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int32_t mbColomn)
{
/*
Flush();
int32_t letterWidth = Display::GetFontWidth();
int32_t letterHeight = Display::GetFontHeight();
// generate Clean BG:
DirectRectangle(SelectColor, x, y-letterHeight, letterWidth*mbColomn, letterHeight);
// set the pen for the display
SelectColor->ApplyFG(m_cairo);
uint32_t yCalc = y - (letterHeight+1)/2;
cairo_move_to(m_cairo, x + 3, yCalc);
cairo_line_to(m_cairo, x + letterWidth*mbColomn - 2 , yCalc);
cairo_rel_line_to(m_cairo, -6 , -2);
cairo_move_to(m_cairo, x + letterWidth*mbColomn - 2 , yCalc);
cairo_rel_line_to(m_cairo, -6 , +2);
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
*/
}
/**
* @brief Display an unknow UTF8 character (a special rectangle)
*
* @param [in] SelectColor Color that is used to display Tabulation
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
* @param [in] utf8Size number of char used by the UTF8 character
* @param [in] ValidUtf8 true if the character UTF8 is well encoded
*
* @return ---
*
*/
void DrawerManager::UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t y, int8_t utf8Size, bool ValidUtf8)
{
#if 0
Flush();
int32_t letterWidth = Display::GetFontWidth();
int32_t letterHeight = Display::GetFontHeight();
// generate Clean BG:
DirectRectangle(SelectColor, x, y-letterHeight, letterWidth*2, letterHeight);
SelectColor->ApplyFG(m_cairo);
/*
y1 y2
x1 |-------|
| |
| |
x2 |-------|
*/
uint32_t x1 = x + 2;
uint32_t x2 = x + letterWidth*2 - 2;
uint32_t y1 = y - letterHeight + 2;
uint32_t y2 = y - 2;
// Box
cairo_move_to(m_cairo, x1 , y1);
cairo_line_to(m_cairo, x2 , y1);
cairo_line_to(m_cairo, x2 , y2);
cairo_line_to(m_cairo, x1 , y2);
cairo_line_to(m_cairo, x1 , y1);
// croix in the middle
switch(utf8Size)
{
case 1:
break;
case 2:
cairo_line_to(m_cairo, x2 , y2);
break;
case 3:
cairo_move_to(m_cairo, x1 , y2);
cairo_line_to(m_cairo, x2 , y1);
break;
default:
cairo_line_to(m_cairo, x2 , y2);
cairo_move_to(m_cairo, x1 , y2);
cairo_line_to(m_cairo, x2 , y1);
break;
}
if (false == ValidUtf8) {
cairo_move_to(m_cairo, x1 , y2-2);
cairo_line_to(m_cairo, x2 , y2-2);
}
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
#endif
}
/* Basic axample with cairo and pango...
cairo_t *cr;
cr = gdk_cairo_create(widget->window);
cairo_translate(cr, 0, 7);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_paint(cr);
gint pos = 18;//GTK_CPU(widget)->sel;
gint rect = pos / 5;
cairo_set_source_rgb(cr, 0.2, 0.4, 0);
gint i;
for ( i = 1; i <= 20; i++) {
if (i > 20 - rect) {
cairo_set_source_rgb(cr, 0.6, 1.0, 0);
} else {
cairo_set_source_rgb(cr, 0.2, 0.4, 0);
}
cairo_rectangle(cr, 8, i*4, 30, 3);
cairo_rectangle(cr, 42, i*4, 30, 3);
cairo_fill(cr);
}
//----
PangoLayout *layout;
PangoFontDescription *desc;
cairo_translate(cr, 10, 20);
layout = pango_cairo_create_layout(cr);
pango_layout_set_text(layout, "Hello World!", -1);
desc = pango_font_description_from_string("Sans Bold 12");
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
pango_cairo_update_layout(cr, layout);
pango_cairo_show_layout(cr, layout);
g_object_unref(layout);
//-----
cairo_destroy(cr);
*/

View File

@@ -27,8 +27,6 @@
#define __TOOLS_DISPLAY_H__
#include <tools_debug.h>
#include <Colorize.h>
#include <ColorizeManager.h>
/**
@@ -36,60 +34,10 @@
*/
namespace Display
{
void Init(void);
void UnInit(void);
//cairo_font_face_t * GetFont(bool bold, bool italic);
void * GetFont(bool bold, bool italic);
int32_t GetFontHeight(void);
int32_t GetFontWidth(void);
};
#define MAX_CARACTER_CYCLE (512)
/**
* class to abstrate the writing on the curent GUI (INTEFACE to be no dependent of the one chosen)
*/
class DrawerManager;
class DrawerManager {
public:
// Constructeur
//DrawerManager(GtkWidget * widget, int32_t x, int32_t y);
DrawerManager(void * widget, int32_t x, int32_t y);
~DrawerManager();
void Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);
void Rectangle(color_ts & SelectColor, int32_t x, int32_t y, int32_t width, int32_t height) {
DirectRectangle(SelectColor, x, y, width, height);
}
void Clean(Colorize *SelectColor);
void Clean(color_ts & SelectColor);
void Text(Colorize *SelectColor, int32_t x, int32_t y,const char *myUTF8Text, int32_t len = -1);
void Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int32_t x, int32_t y,const char *myText);
void Text(color_ts & SelectColorFg, int32_t x, int32_t y,const char *myText);
void SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar);
void Cursor(int32_t x, int32_t y);
void EndOfLine(int32_t x, int32_t y);
void Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int32_t mbColomn);
void UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t y, int8_t utf8Size, bool ValidUtf8);
void Flush(void);
int32_t GetWidth(void) { return m_size.x; };
int32_t GetHeight(void) { return m_size.y; };
private:
void DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);
void DirectRectangle(color_ts & SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);
bool m_haveWork; //!< if data might be print (true)
char m_dataToDisplay[MAX_CARACTER_CYCLE]; //!< curent string to display
uint32_t m_nbElement; //!< nb element in the string
position_ts m_pos; //!< position where start the string display (X,Y)
Colorize * m_selectColor; //!< curent color to display
position_ts m_size; //!< Total size
//cairo_t * m_cairo; //!< Cairo Layout pointer
};
#endif

View File

@@ -58,7 +58,7 @@ bool EdnBuf::SelectHasSelection(selectionType_te select)
*/
void EdnBuf::Select(selectionType_te select, int32_t start, int32_t end)
{
selection oldSelection = m_selectionList[select];
//selection oldSelection = m_selectionList[select];
m_selectionList[select].selected = start != end;
m_selectionList[select].zeroWidth = (start == end) ? true : false;
m_selectionList[select].rectangular = false;
@@ -77,7 +77,7 @@ void EdnBuf::Select(selectionType_te select, int32_t start, int32_t end)
*/
void EdnBuf::Unselect(selectionType_te select)
{
selection oldSelection = m_selectionList[select];
//selection oldSelection = m_selectionList[select];
m_selectionList[select].selected = false;
m_selectionList[select].zeroWidth = false;
}

View File

@@ -24,4 +24,4 @@
*/
const char * ednLog = "edn ";
const char * ednLog = "edn ";