Change all in Unicode string for system normalisation

This commit is contained in:
Edouard Dupin 2012-02-15 16:24:06 +01:00
parent ef639438cb
commit ce3c976f02
58 changed files with 739 additions and 1293 deletions

View File

@ -47,7 +47,7 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::File &obj)
return os;
}
etk::File::File(etk::String &filename, etk::FileType_te type, int32_t LineNumber)
etk::File::File(etk::UString &filename, etk::FileType_te type, int32_t LineNumber)
{
m_lineNumberOpen = LineNumber;
m_PointerFile = NULL;
@ -57,17 +57,17 @@ etk::File::File(etk::String &filename, etk::FileType_te type, int32_t LineNumber
etk::File::File(const char *filename, etk::FileType_te type, int32_t LineNumber)
{
etk::String tmpString = filename;
etk::UString tmpString = filename;
m_lineNumberOpen = LineNumber;
m_PointerFile = NULL;
SetCompleateName(tmpString, type);
}
etk::File::File(etk::String &filename, etk::String &folder, etk::FileType_te type, int32_t lineNumber)
etk::File::File(etk::UString &filename, etk::UString &folder, etk::FileType_te type, int32_t lineNumber)
{
etk::String tmpString = folder;
tmpString += '/';
etk::UString tmpString = folder;
tmpString += "/";
tmpString += filename;
m_PointerFile = NULL;
SetCompleateName(tmpString, type);
@ -84,21 +84,21 @@ etk::File::~File(void)
}
etk::String etk::File::GetFolder(void) const
etk::UString etk::File::GetFolder(void) const
{
return m_folder;
}
etk::String etk::File::GetShortFilename(void) const
etk::UString etk::File::GetShortFilename(void) const
{
return m_shortFilename;
}
etk::String etk::File::GetCompleateName(void) const
etk::UString etk::File::GetCompleateName(void) const
{
etk::String out;
etk::UString out;
out = m_folder;
out += '/';
out += "/";
out += m_shortFilename;
return out;
}
@ -163,18 +163,18 @@ bool etk::File::operator!= (const etk::File &etkF) const
}
etk::String baseFolderData = "assets/";
etk::UString baseFolderData = "assets/";
#ifdef DATA_IN_APK
static etk::String s_fileAPK = "";
static etk::UString s_fileAPK = "";
static struct zip * s_APKArchive = NULL;
static int32_t s_APKnbFiles = 0;
static void loadAPK (const char* apkPath)
static void loadAPK (const etk::UString& apkPath)
{
TK_DEBUG("Loading APK \"" << apkPath << "\"");
s_APKArchive = zip_open(apkPath, 0, NULL);
s_APKArchive = zip_open(apkPath.Utf8Data(), 0, NULL);
TK_ASSERT(s_APKArchive != NULL, "Error loading APK ... \"" << apkPath << "\"");
//Just for debug, print APK contents
s_APKnbFiles = zip_get_num_files(s_APKArchive);
@ -189,15 +189,15 @@ static void loadAPK (const char* apkPath)
}
}
#endif
etk::String baseFolderDataUser = "~/.tmp/userData/";
etk::String baseFolderCache = "~/.tmp/cache/";
etk::UString baseFolderDataUser = "~/.tmp/userData/";
etk::UString baseFolderCache = "~/.tmp/cache/";
// for specific device contraint :
void etk::SetBaseFolderData(const char * folder)
{
#if defined(DATA_IN_APK)
baseFolderData = "assets/";
s_fileAPK = folder;
loadAPK(s_fileAPK.c_str());
loadAPK(s_fileAPK);
#else
baseFolderData = folder;
#endif
@ -212,7 +212,7 @@ void etk::SetBaseFolderCache(const char * folder)
}
void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type)
void etk::File::SetCompleateName(etk::UString &newFilename, etk::FileType_te type)
{
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
@ -228,18 +228,18 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
m_folder = "";
m_shortFilename = "";
m_lineNumberOpen = 0;
TK_VERBOSE("1 :Set Name : " << newFilename );
etk::String destFilename;
TK_DEBUG("1 :Set Name : " << newFilename );
etk::UString destFilename;
if (newFilename.Size() == 0) {
destFilename = "no-name";
} else {
destFilename = newFilename;
}
TK_VERBOSE("2 : Get file Name : " << destFilename );
if ('/' == *destFilename.c_str()) {
TK_DEBUG("2 : Get file Name : " << destFilename );
if (false == destFilename.StartWith('/')) {
m_type = etk::FILE_TYPE_DIRECT;
if (type != etk::FILE_TYPE_DIRECT) {
TK_WARNING("Incompatible type with a file=\"" << newFilename << "\" ==> force it in direct mode ...");
TK_DEBUG("Incompatible type with a file=\"" << newFilename << "\" ==> force it in direct mode ...");
}
} else {
if (type == etk::FILE_TYPE_DIRECT) {
@ -253,9 +253,9 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
return;
}
cCurrentPath[FILENAME_MAX - 1] = '\0';
etk::String tmpFilename = destFilename;
etk::UString tmpFilename = destFilename;
destFilename = cCurrentPath;
destFilename += '/';
destFilename += "/";
destFilename += tmpFilename;
@ -275,7 +275,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
mode = "FILE_TYPE_DATA";
#endif
#if defined(DATA_IN_APK)
etk::String tmpFilename = baseFolderData + destFilename;
etk::UString tmpFilename = baseFolderData + destFilename;
for (int iii=0; iii<s_APKnbFiles; iii++) {
const char* name = zip_get_name(s_APKArchive, iii, 0);
if (name == NULL) {
@ -292,7 +292,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
TK_INFO("File existed ... in APK : \"" << tmpFilename << "\" ==> id=" << m_idZipFile);
}
#else
//etk::String tmpFilename = destFilename;
//etk::UString tmpFilename = destFilename;
//destFilename = baseFolderData;
//destFilename += tmpFilename;
#endif
@ -303,7 +303,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
#if ETK_DEBUG_LEVEL > 2
mode = "FILE_TYPE_USER_DATA";
#endif
etk::String tmpFilename = destFilename;
etk::UString tmpFilename = destFilename;
destFilename = baseFolderDataUser;
destFilename += tmpFilename;
}
@ -314,7 +314,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
#if ETK_DEBUG_LEVEL > 2
mode = "FILE_TYPE_CACHE";
#endif
etk::String tmpFilename = destFilename;
etk::UString tmpFilename = destFilename;
destFilename = baseFolderCache;
destFilename += tmpFilename;
}
@ -328,20 +328,20 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
needUnpack = true;
break;
}
TK_VERBOSE("3 : Get file Name : " << destFilename );
TK_DEBUG("3 : Get file Name : " << destFilename );
if (true == needUnpack) {
// Get the real Path of the current File
ok = realpath(destFilename.c_str(), buf);
ok = realpath(destFilename.Utf8Data(), buf);
if (!ok) {
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
// Get the FileName
etk::String tmpFilename = destFilename.Extract(lastPos+1);
etk::UString tmpFilename = destFilename.Extract(lastPos+1);
destFilename.Remove(lastPos, destFilename.Size() - lastPos);
TK_VERBOSE("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" ");
ok = realpath(destFilename.c_str(), buf);
TK_DEBUG("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" ");
ok = realpath(destFilename.Utf8Data(), buf);
if (!ok) {
TK_VERBOSE("Can not find real Path name of \"" << destFilename << "\"");
TK_DEBUG("Can not find real Path name of \"" << destFilename << "\"");
m_shortFilename = tmpFilename;
m_folder = destFilename;
} else {
@ -350,7 +350,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
m_folder = destFilename;
}
} else {
TK_WARNING("file : \"" << destFilename << "\" ==> No data???");
TK_DEBUG("file : \"" << destFilename << "\" ==> No data???");
// Basic ERROR ...
m_shortFilename = destFilename;
}
@ -362,7 +362,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
m_folder = destFilename.Extract(0, lastPos);
} else {
// Basic ERROR ...
TK_WARNING("file : \"" << destFilename << "\" ==> No data???");
TK_DEBUG("file : \"" << destFilename << "\" ==> No data???");
m_shortFilename = destFilename;
}
}
@ -373,7 +373,7 @@ void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type
m_folder = destFilename.Extract(0, lastPos);
} else {
// Basic ERROR ...
TK_WARNING("file : \"" << destFilename << "\" ==> No data???");
TK_DEBUG("file : \"" << destFilename << "\" ==> No data???");
m_shortFilename = destFilename;
}
}
@ -404,9 +404,9 @@ bool etk::File::HasExtention(void)
}
etk::String etk::File::GetExtention(void)
etk::UString etk::File::GetExtention(void)
{
etk::String tmpExt = "";
etk::UString tmpExt = "";
int32_t lastPos = m_shortFilename.FindBack('.');
if( -1 != lastPos // not find the .
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
@ -477,8 +477,8 @@ int32_t etk::File::Size(void)
}
#endif
FILE *myFile=NULL;
etk::String myCompleateName = baseFolderData + GetCompleateName();
myFile=fopen(myCompleateName.c_str(),"rb");
etk::UString myCompleateName = baseFolderData + GetCompleateName();
myFile=fopen(myCompleateName.Utf8Data(),"rb");
if(NULL == myFile) {
//EWOL_ERROR("Can not find the file name=\"" << m_folder << "\" / \"" << m_shortFilename << "\"");
return -1;
@ -503,8 +503,8 @@ bool etk::File::Exist(void)
}
#endif
FILE *myFile=NULL;
etk::String myCompleateName = baseFolderData + GetCompleateName();
myFile=fopen(myCompleateName.c_str(),"rb");
etk::UString myCompleateName = baseFolderData + GetCompleateName();
myFile=fopen(myCompleateName.Utf8Data(),"rb");
if(NULL == myFile) {
return false;
}
@ -525,8 +525,8 @@ bool etk::File::fOpenRead(void)
TK_CRITICAL("File Already open : \"" << GetCompleateName() << "\"");
return true;
}
etk::String myCompleateName = baseFolderData + GetCompleateName();
m_PointerFile=fopen(myCompleateName.c_str(),"rb");
etk::UString myCompleateName = baseFolderData + GetCompleateName();
m_PointerFile=fopen(myCompleateName.Utf8Data(),"rb");
if(NULL == m_PointerFile) {
TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\"");
return false;
@ -545,8 +545,8 @@ bool etk::File::fOpenWrite(void)
TK_CRITICAL("File Already open : \"" << GetCompleateName() << "\"");
return true;
}
etk::String myCompleateName = baseFolderData + GetCompleateName();
m_PointerFile=fopen(myCompleateName.c_str(),"wb");
etk::UString myCompleateName = baseFolderData + GetCompleateName();
m_PointerFile=fopen(myCompleateName.Utf8Data(),"wb");
if(NULL == m_PointerFile) {
TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\"");
return false;

View File

@ -25,7 +25,7 @@
#ifndef __ETK_FILE_H__
#define __ETK_FILE_H__
#include <etk/String.h>
#include <etk/UString.h>
#define MAX_FILE_NAME (10240)
@ -59,21 +59,21 @@ namespace etk
class File
{
public:
File(void) { m_lineNumberOpen=0; m_type = etk::FILE_TYPE_DIRECT; m_PointerFile = NULL;}
File(etk::String &filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0);
File(const char *filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0);
File(etk::String &filename, etk::String &folder, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t lineNumber = 0);
~File(void);
etk::String GetFolder(void) const;
etk::String GetShortFilename(void) const;
etk::String GetCompleateName(void) const;
bool HasExtention(void);
etk::String GetExtention(void);
int32_t Size(void);
bool Exist(void);
int32_t GetLineNumber(void);
void SetLineNumber(int32_t newline);
void SetCompleateName(etk::String &newFilename, etk::FileType_te type);
File(void) { m_lineNumberOpen=0; m_type = etk::FILE_TYPE_DIRECT; m_PointerFile = NULL;}
File(etk::UString &filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0);
File(const char *filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0);
File(etk::UString &filename, etk::UString &folder, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t lineNumber = 0);
~File(void);
etk::UString GetFolder(void) const;
etk::UString GetShortFilename(void) const;
etk::UString GetCompleateName(void) const;
bool HasExtention(void);
etk::UString GetExtention(void);
int32_t Size(void);
bool Exist(void);
int32_t GetLineNumber(void);
void SetLineNumber(int32_t newline);
void SetCompleateName(etk::UString &newFilename, etk::FileType_te type);
const etk::File& operator= (const etk::File &etkF );
bool operator== (const etk::File &etkF ) const;
@ -101,8 +101,8 @@ namespace etk
int32_t m_zipDataSize;
int32_t m_zipReadingOffset;
#endif
etk::String m_folder;
etk::String m_shortFilename;
etk::UString m_folder;
etk::UString m_shortFilename;
int32_t m_lineNumberOpen;
};

View File

@ -28,7 +28,7 @@
#include <etk/Types.h>
#include <etk/DebugInternal.h>
#include <etk/Memory.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/VectorType.h>
namespace etk {
@ -1579,7 +1579,7 @@ template<class CLASS_TYPE> class RegExp {
* @param[in,out]
* @return
*/
RegExp(etk::String &exp)
RegExp(etk::UString &exp)
{
m_isOk = false;
m_areaFind.start=0;
@ -1622,7 +1622,7 @@ template<class CLASS_TYPE> class RegExp {
void SetRegExp(const char *exp)
{
TK_CHECK_INOUT(exp);
etk::String expressionRequested = exp;
etk::UString expressionRequested = exp;
SetRegExp(expressionRequested);
};
@ -1631,7 +1631,7 @@ template<class CLASS_TYPE> class RegExp {
* @param[in,out]
* @return
*/
void SetRegExp(etk::String &expressionRequested)
void SetRegExp(etk::UString &expressionRequested)
{
m_expressionRequested = expressionRequested; // TODO : Must be deprecated ...
etk::VectorType<int16_t> tmpExp;
@ -1643,7 +1643,8 @@ template<class CLASS_TYPE> class RegExp {
m_notBeginWithChar = false;
m_notEndWithChar = false;
char * exp = expressionRequested.c_str();
// TODO : Check this ... ==> could create some errors ...
char * exp = expressionRequested.Utf8Data();
int32_t regExpLen = strlen(exp);
// change in the regular Opcode ==> replace \x with the corect element ... x if needed
int32_t iii;
@ -1763,7 +1764,7 @@ template<class CLASS_TYPE> class RegExp {
* @param[in,out]
* @return
*/
etk::String GetRegExp(void)
etk::UString GetRegExp(void)
{
return m_expressionRequested;
};
@ -1963,7 +1964,7 @@ template<class CLASS_TYPE> class RegExp {
};
// internal parameters
private:
etk::String m_expressionRequested; // TODO : Remove ...
etk::UString m_expressionRequested; // TODO : Remove ...
elementPos_ts m_areaFind; //!< position around selection
RegExpNodePThese<CLASS_TYPE> m_exprRootNode; //!< The tree where data is set
bool m_isOk; //!< Known if we can process with this regExp

View File

@ -1,724 +0,0 @@
/**
*******************************************************************************
* @file etk/String.cpp
* @brief Ewol Tool Kit : normal sting management... (sources)
* @author Edouard DUPIN
* @date 26/01/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/String.h>
#include <etk/Memory.h>
#undef __class__
#define __class__ "etk::String"
etk::CCout& etk::operator <<(etk::CCout &os, const etk::String &obj)
{
os << (char*)&obj.m_data[0];
return os;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String::~String(void)
{
m_data.Clear();
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String::String(void)
{
//TK_INFO("new etk::String()");
m_data.Clear();
m_data.PushBack('\0');
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String::String(const char myInput)
{
m_data.Clear();
m_data.PushBack(myInput);
m_data.PushBack('\0');
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String::String(const char* inputData, int32_t len)
{
m_data.Clear();
m_data.PushBack('\0');
Set(inputData, len);
}
void etk::String::Set(const char * inputData, int32_t len)
{
if (NULL == inputData) {
// nothing to add ...
return;
}
// overwrite the len if needed :
if ((-1) == len) {
len = strlen(inputData);
}
if (len != 0) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data.PushBack((int8_t*)inputData, len);
// add the last '\0'
m_data.PushBack('\0');
}
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String::String(int inputData)
{
char tmpVal[256];
// generate the string :
sprintf(tmpVal, "%d", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String::String(unsigned int inputData)
{
char tmpVal[256];
// generate the string :
sprintf(tmpVal, "%d", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::String::String(const etk::String &etkS)
{
//etk_INFO("Constructeur de recopie");
m_data = etkS.m_data;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::String& etk::String::operator= (const etk::String &etkS )
{
//TK_INFO("OPERATOR de recopie");
if( this != &etkS ) // avoid copy to itself
{
m_data = etkS.m_data;
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::String& etk::String::operator= (const char * inputData)
{
m_data.Clear();
m_data.PushBack('\0');
if (NULL == inputData) {
return *this;
}
// calculate the size :
uint32_t len = strlen(inputData);
// check the new size ...
if (len > 0 ) {
// copy all data :
Set(inputData, len);
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::String& etk::String::operator= (etk::VectorType<int8_t> inputData)
{
m_data = inputData;
if (m_data.Size()>0) {
if (m_data[m_data.Size()-1] != '\0') {
m_data.PushBack('\0');
}
}
//TK_DEBUG("m_dataLen="<<m_dataLen << " m_dataLenUTF8="<<m_dataLenUTF8 << " description=" << m_data);
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::String::operator== (const etk::String& etkS) const
{
if( this != &etkS ) {
if (etkS.m_data.Size() != m_data.Size()) {
//TK_DEBUG(" not the same size : " << etkS.m_data.Size() << "!=" << m_data.Size());
return false;
}
for (int32_t iii= 0; iii<m_data.Size(); iii++) {
//TK_DEBUG(" check : " << etkS.m_data[iii] << "!=" << m_data[iii]);
if (etkS.m_data[iii]!= m_data[iii]){
return false;
}
}
return true;
}
return true;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::String::operator== (const char * inputData) const
{
// calculate the size :
int32_t len = strlen(inputData);
if (len+1 != m_data.Size()) {
return false;
}
for (int32_t iii= 0; iii<m_data.Size(); iii++) {
if (inputData[iii]!= m_data[iii]){
return false;
}
}
return true;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::String::operator!= (const etk::String& etkS) const
{
return !(*this == etkS);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::String::operator!= (const char * inputData) const
{
return !(*this == inputData);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::String& etk::String::operator+= (const etk::String &etkS)
{
if (0 < etkS.Size()) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data += etkS.m_data;
// This previous include the \0 in case of the 2 string are different...
if( this == &etkS ) {
// add the removed end string
m_data.PushBack('\0');
}
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::String& etk::String::operator+= (const char * inputData)
{
//TK_INFO(" string(arg) : \"" << inputData << "\"");
//TK_INFO(" string(direct) : \"" << m_data << "\"");
int32_t len = strlen(inputData);
if (len != 0) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data.PushBack((int8_t*)inputData, len+1 );
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String etk::String::operator+ (const etk::String &etkS)
{
etk::String temp;
//TK_INFO(" string(arg) : \"" << etkS.m_data << "\"");
//TK_INFO(" string(direct) : \"" << m_data << "\"");
temp += *this;
temp += etkS;
return temp;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::String etk::String::operator+ (const char * inputData)
{
etk::String temp;
//TK_INFO(" string(arg) : \"" << inputData << "\"");
//TK_INFO(" string(direct) : \"" << m_data << "\"");
temp += *this;
temp += inputData;
return temp;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::String::IsEmpty(void) const
{
if(1 >= m_data.Size() ) {
return true;
} else {
return false;
}
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
int32_t etk::String::Size(void) const
{
if (m_data.Size() == 0) {
return 0;
} else {
return m_data.Size() - 1;
}
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
void etk::String::Add(int32_t currentID, const char* inputData)
{
// get the input lenght
int32_t len = strlen(inputData);
if (0 == len) {
TK_WARNING("no data to add on the current string");
return;
} else if (currentID < 0) {
TK_WARNING("Curent ID(" << currentID << ") < 0 ==> Add at the start");
currentID = 0;
} else if (currentID > Size() ) {
TK_ERROR("Curent ID(" << currentID << ") > maxSize ... (" << Size() << ") ==> add at the end ...");
m_data.PushBack((int8_t*)inputData, len);
return;
}
m_data.Insert(currentID, (int8_t*)inputData, len);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
void etk::String::Remove(int32_t currentID, int32_t len)
{
if (0 >= len) {
TK_ERROR("no data to remove on the current string");
return;
}
// TODO : check the size of the data
m_data.EraseLen(currentID, len);
}
/**
* @brief Remove all element in the string
*
* @param ---
*
* @return ---
*
*/
void etk::String::Clear(void)
{
m_data.Clear();
m_data.PushBack('\0');
}
/**
* @brief find the first accurence after the position indicated
*
* @param[in] element Element that might be find in the string
* @param[in] startPos Stert position to begin the search
*
* @return the position of the first occurence or -1 if not find...
*
*/
int32_t etk::String::FindForward(const char element, int32_t startPos)
{
if (startPos < 0) {
startPos = 0;
} else if (startPos >= Size() ) {
return -1;
}
for (int32_t iii=startPos; iii< Size(); iii++) {
if (m_data[iii] == element) {
return iii;
}
}
return -1;
}
/**
* @brief find the first accurence before the position indicated.
*
* @param[in] element Element that might be find in the string
* @param[in] startPos Stert position to begin the search
*
* @return the position of the first occurence begining by the end or -1 if not find...
*
*/
int32_t etk::String::FindBack(const char element, int32_t startPos)
{
if (startPos < 0) {
return -1;
} else if (startPos >= Size() ) {
startPos = Size();
}
for (int32_t iii=startPos; iii>=0; iii--) {
if (m_data[iii] == element) {
return iii;
}
}
return -1;
}
/**
* @brief Extract data from the data between two position
*
* @param[in] posStart Start position where to extract data
* @param[in] posEnd End position where to extract data
*
* @return the extracted string
*
*/
etk::String etk::String::Extract(int32_t posStart, int32_t posEnd)
{
etk::String out;
if (posStart < 0) {
posStart = 0;
} else if (posStart >= Size() ) {
return out;
}
if (posEnd < 0) {
return out;
} else if (posEnd >= Size() ) {
posEnd = Size();
}
out.m_data = m_data.Extract(posStart, posEnd);
out.m_data.PushBack('\0');
return out;
}
/**
* @brief Get a basic vector in int8 data with no \0 at the end of the string
*
* @param ---
*
* @return The desired vector with data
*
*/
etk::VectorType<int8_t> etk::String::GetVector(void)
{
etk::VectorType<int8_t> out = m_data;
out.PopBack();
return out;
}
/**
* @brief Unitary test for the string system
*
* @param ---
*
* @return ---
*
*/
void etk::TestUntaire_String(void)
{
TK_WARNING("*********************************************************");
TK_WARNING("** Test Unitaire 'etkString' (START)");
TK_WARNING("*********************************************************");
int32_t iddd = 0;
etk::String * monString = new etk::String();
TK_INFO("phase : " << iddd++ << " : \"" << *monString << "\"");
delete(monString);
monString = new etk::String("test de direct data");
TK_INFO("phase : " << iddd++ << " : \"" << *monString << "\"");
delete(monString);
monString = new etk::String("test de direct data", 7);
TK_INFO("phase : " << iddd++ << " : \"" << *monString << "\"");
delete(monString);
int32_t testId = -6789;
monString = new etk::String(testId);
TK_INFO("phase : " << iddd++ << " : \"" << *monString << "\"");
delete(monString);
uint32_t testId2 = 12345;
monString = new etk::String((unsigned int)testId2);
TK_INFO("phase : " << iddd++ << " : \"" << *monString << "\"");
delete(monString);
etk::String plop = "otherString";
monString = new etk::String(plop);
TK_INFO("phase : " << iddd++ << " : \"" << *monString << "\"");
delete(monString);
etk::String s1 = "test de base ...";
s1 += s1;
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 += " plop 2 ";
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 += plop;
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 = plop;
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 = "test direct 44";
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
etk::VectorType<int8_t> vb1;
vb1.PushBack('v');
vb1.PushBack('b');
vb1.PushBack('1');
s1 = vb1;
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
vb1.Clear();
vb1.PushBack('v');
vb1.PushBack('b');
vb1.PushBack('2');
vb1.PushBack('\0');
s1 = vb1;
TK_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
if (s1 == "vb2") {
TK_INFO("phase : " << iddd++ << " : == OK");
} else {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
}
if (s1 == "vb3") {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
} else {
TK_INFO("phase : " << iddd++ << " : == OK");
}
if (s1 != "vb3") {
TK_INFO("phase : " << iddd++ << " : == OK");
} else {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
}
if (s1 != "vb2") {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
} else {
TK_INFO("phase : " << iddd++ << " : == OK");
}
etk::String s2 = "vb2";
etk::String s3 = "vb3";
if (s1 == s2) {
TK_INFO("phase : " << iddd++ << " : == OK");
} else {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
}
if (s1 == s3) {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
} else {
TK_INFO("phase : " << iddd++ << " : == OK");
}
if (s1 != s3) {
TK_INFO("phase : " << iddd++ << " : == OK");
} else {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
}
if (s1 != s2) {
TK_ERROR("phase : " << iddd++ << " : == ERROR");
} else {
TK_INFO("phase : " << iddd++ << " : == OK");
}
TK_WARNING("*********************************************************");
TK_WARNING("** Test Unitaire 'etkString' (STOP)");
TK_WARNING("*********************************************************");
}

View File

@ -1,93 +0,0 @@
/**
*******************************************************************************
* @file etk/String.h
* @brief Ewol Tool Kit : normal sting management... (header)
* @author Edouard DUPIN
* @date 26/01/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_STRING_H__
#define __ETK_STRING_H__
#include <etk/Stream.h>
#include <etk/VectorType.h>
namespace etk
{
class String
{
public:
// Constructeurs
String(void);
String(const char myInput);
String(const char* inputData, int32_t len = -1);//, bool noAllocation=false);
void Set(const char* inputData, int32_t len=-1);
// basic convertion integer en string
String(int inputData);
String(unsigned int inputData);
//String(const wchar_t *inputData);
String(const etk::String &etkS);
// destructor :
~String(void);
const etk::String& operator= (const etk::String &etkS ); // assigment
const etk::String& operator= (const char * inputData);
const etk::String& operator= (etk::VectorType<int8_t> inputData);
bool operator== (const etk::String& etkS) const; // == operator
bool operator== (const char * inputData) const;
bool operator!= (const etk::String& etkS) const; // != operator
bool operator!= (const char * inputData) const;
const etk::String& operator+= (const etk::String &etkS); // += operator
const etk::String& operator+= (const char * inputData);
etk::String operator+ (const etk::String &etkS); // + operator
etk::String operator+ (const char * inputData);
//operator const char *()
friend etk::CCout& operator <<( etk::CCout &os,const etk::String &obj);
bool IsEmpty(void) const;
int32_t Size(void) const;
void Add(int32_t currentID, const char* inputData);
void Remove(int32_t currentID, int32_t len);
void Clear(void);
etk::VectorType<int8_t> GetVector(void);
char * c_str(void) { return (char*)&m_data[0]; };
// Sting operation :
int32_t FindForward(const char element, int32_t startPos=0);
int32_t FindBack(const char element, int32_t startPos=0x7FFFFFFF);
etk::String Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF);
private :
etk::VectorType<int8_t> m_data;
};
void TestUntaire_String(void);
etk::CCout& operator <<(etk::CCout &os, const etk::String &obj);
}
#endif

View File

@ -65,6 +65,7 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::UString &obj)
etk::UString::~UString(void)
{
m_data.Clear();
m_dataUtf8.Clear();
}
@ -469,6 +470,26 @@ const etk::UString& etk::UString::operator+= (const char * inputData)
return *this;
}
const etk::UString& etk::UString::operator+= (const char data)
{
etk::UString tmpString(data);
*this += tmpString;
return *this;
}
const etk::UString& etk::UString::operator+= (const int data)
{
etk::UString tmpString(data);
*this += tmpString;
return *this;
}
const etk::UString& etk::UString::operator+= (const unsigned int data)
{
etk::UString tmpString(data);
*this += tmpString;
return *this;
}
/**
* @brief
@ -649,6 +670,10 @@ void etk::UString::Clear(void)
* @return the position of the first occurence or -1 if not find...
*
*/
int32_t etk::UString::FindForward(const char element, int32_t startPos)
{
return FindForward((uniChar_t)element, startPos);
}
int32_t etk::UString::FindForward(const uniChar_t element, int32_t startPos)
{
if (startPos < 0) {
@ -674,6 +699,10 @@ int32_t etk::UString::FindForward(const uniChar_t element, int32_t startPos)
* @return the position of the first occurence begining by the end or -1 if not find...
*
*/
int32_t etk::UString::FindBack(const char element, int32_t startPos)
{
return FindBack((uniChar_t)element, startPos);
}
int32_t etk::UString::FindBack(const uniChar_t element, int32_t startPos)
{
if (startPos < 0) {
@ -733,3 +762,107 @@ etk::VectorType<uniChar_t> etk::UString::GetVector(void)
return out;
}
// Start With ...
bool etk::UString::StartWith(const char* data)
{
etk::UString tmpString(data);
return StartWith(tmpString);
}
bool etk::UString::StartWith(const uniChar_t* data)
{
if (NULL == data) {
return false;
}
int32_t len = strlen(data);
if (len == 0) {
return false;
}
if (len > Size()) {
return false;
}
for (int32_t iii=0; iii<len; iii++) {
if (data[iii] != m_data[iii]) {
return false;
}
}
return true;
}
bool etk::UString::StartWith(const etk::UString& data)
{
if (data.Size() == 0) {
return false;
}
if (data.Size() > Size()) {
return false;
}
for (int32_t iii=0; iii<data.Size(); iii++) {
if (data[iii] != m_data[iii]) {
return false;
}
}
return false;
}
bool etk::UString::EndWith(const char* data)
{
etk::UString tmpString(data);
return EndWith(tmpString);
}
bool etk::UString::EndWith(const uniChar_t* data)
{
if (NULL == data) {
return false;
}
int32_t len = strlen(data);
if (len == 0) {
return false;
}
if (len > Size()) {
return false;
}
for( int32_t iii=Size()-1, jjj=len-1;
iii>=0 && jjj>=0;
iii--, jjj--) {
if (data[jjj] != m_data[iii]) {
return false;
}
}
return true;
}
bool etk::UString::EndWith(const etk::UString& data)
{
if (data.Size() == 0) {
return false;
}
if (data.Size() > Size()) {
return false;
}
for( int32_t iii=Size()-1, jjj=data.Size()-1;
iii>=0 && jjj>=0;
iii--, jjj--) {
if (data[jjj] != m_data[iii]) {
return false;
}
}
return true;
}
char * etk::UString::Utf8Data(void)
{
// UTF8 generation :
m_dataUtf8.Clear();
unicode::convertUnicodeToUtf8(m_data, m_dataUtf8);
m_dataUtf8.PushBack('\0');
return &m_dataUtf8[0];
}

View File

@ -70,6 +70,9 @@ namespace etk
* += operator
*****************************************************/
const etk::UString& operator+= (const etk::UString &etkS);
const etk::UString& operator+= (const char data);
const etk::UString& operator+= (const int data);
const etk::UString& operator+= (const unsigned int data);
const etk::UString& operator+= (const char * inputData);
const etk::UString& operator+= (const uniChar_t * inputData);
/*****************************************************
@ -79,28 +82,70 @@ namespace etk
etk::UString operator+ (const char * inputData);
etk::UString operator+ (const uniChar_t * inputData);
/*****************************************************
* * operator
* << operator
*****************************************************/
/*
const etk::UString& operator <<= (const char input);
const etk::UString& operator <<= (const int input);
const etk::UString& operator <<= (const unsigned int input);
*/
/*****************************************************
* >> operator
*****************************************************/
/*****************************************************
* Cout << operator
*****************************************************/
friend etk::CCout& operator <<( etk::CCout &os,const etk::UString &obj);
/*****************************************************
* [] operator
*****************************************************/
const uniChar_t& operator[] (int32_t pos) const {
return m_data[pos];
}
uniChar_t& operator[] (int32_t pos) {
return m_data[pos];
}
/*****************************************************
* toolbox
*****************************************************/
// Start With ...
bool StartWith(const char* data);
bool StartWith(const uniChar_t* data);
bool StartWith(const etk::UString& data);
// End With ...
bool EndWith(const char* data);
bool EndWith(const uniChar_t* data);
bool EndWith(const etk::UString& data);
// Find element
int32_t FindForward(const char data, int32_t startPos=0);
int32_t FindForward(const uniChar_t data, int32_t startPos=0);
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF);
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF);
bool IsEmpty(void) const;
int32_t Size(void) const;
/*****************************************************
* Generic modification function
*****************************************************/
void Add(int32_t currentID, const char* inputData);
void Add(int32_t currentID, const uniChar_t* inputData);
void Remove(int32_t currentID, int32_t len);
void Clear(void);
etk::VectorType<uniChar_t> GetVector(void);
uniChar_t * pointer(void) { return &m_data[0]; };
// generate temporary allocation (auto unallocated...)
char * Utf8Data(void);
// Sting operation :
int32_t FindForward(const uniChar_t element, int32_t startPos=0);
int32_t FindBack(const uniChar_t element, int32_t startPos=0x7FFFFFFF);
etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF);
private :
etk::VectorType<uniChar_t> m_data;
etk::VectorType<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
etk::VectorType<char> m_dataUtf8; //!< Tmp data for the Utf8Data() function
};
etk::CCout& operator <<(etk::CCout &os, const etk::UString &obj);

View File

@ -6,7 +6,6 @@ FILE_LIST = \
etk/Memory.cpp \
etk/unicode.cpp \
etk/unicodeTable.cpp \
etk/String.cpp \
etk/UString.cpp \
etk/Stream.cpp \
etk/File.cpp \

View File

@ -35,82 +35,38 @@ namespace ewol
// TODO : Create a subNameSpace:
/*
namespace font {
// set default folder name of the font :
void SetFolder(etk::String folderName);
void SetDefault(etk::String fontName, int32_t size);
// unload all font loaded
void Init(void);
void UnInit(void);
// load the fonts...
int32_t Load(etk::String fontName, int32_t size); // return ID of font
int32_t GetDefaultId(void);
void Unload(int32_t id);
// get the size of a long string in UTF8 (note that \n and \r represent unknown char...)
int32_t GetWidth(int32_t fontID, const uniChar_t * unicodeString);
int32_t GetWidth(int32_t fontID, const char * utf8String);
int32_t GetHeight(int32_t fontID);
void DrawText(int32_t fontID,
coord2D_ts & drawPosition,
const char * utf8String,
uint32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
void DrawText(int32_t fontID,
coord2D_ts & drawPosition,
const uniChar_t * unicodeString,
uint32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t Load(etk::File fontFileName);
void DrawText(etkFloat_t x, etkFloat_t y, const char * myString);
...
};
*/
// set default folder name of the font :
void SetFontFolder(etk::String folderName);
void SetDefaultFont(etk::String fontName, int32_t size);
void SetFontFolder(etk::UString folderName);
void SetDefaultFont(etk::UString fontName, int32_t size);
// unload all font loaded
void InitFont(void);
void UnInitFont(void);
// load the fonts...
int32_t LoadFont(etk::String fontName, int32_t size); // return ID of font
int32_t LoadFont(etk::UString fontName, int32_t size); // return ID of font
int32_t GetDefaultFontId(void);
void UnloadFont(int32_t id);
// get the size of a long string in UTF8 (note that \n and \r represent unknown char...)
int32_t GetWidth(int32_t fontID, const uniChar_t * unicodeString);
int32_t GetWidth(int32_t fontID, const char * utf8String);
int32_t GetWidth(int32_t fontID, const etk::UString& unicodeString);
int32_t GetHeight(int32_t fontID);
int32_t DrawText(int32_t fontID,
coord2D_ts & drawPosition,
coord2D_ts & clipSize,
const char * utf8String,
coord2D_ts textPos,
clipping_ts & drawClipping,
const etk::UString & unicodeString,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const uniChar_t * unicodeString,
const uniChar_t unicodeChar,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
/*
void DrawText(int32_t fontID,
coord2D_ts & drawPosition,
const uniChar_t * unicodeString,
uint32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
*/
int32_t LoadFont(etk::File fontFileName);
void DrawText(etkFloat_t x, etkFloat_t y, const char * myString);
int32_t LoadFont(etk::File fontFileName);
};
#endif

View File

@ -50,7 +50,7 @@ namespace ewol
class EbtFont
{
public:
EbtFont(etk::File newFile, etk::String fontName, int32_t size)
EbtFont(etk::File newFile, etk::UString fontName, int32_t size)
{
m_loadedOK = false;
m_filename = newFile;
@ -116,7 +116,7 @@ namespace ewol
// close the file at end of reading...
m_filename.fClose();
// Load Bitmap :
etk::String bitmapRealFile = m_filename.GetFolder() + "/" + m_bitmapName;
etk::UString bitmapRealFile = m_filename.GetFolder() + "/" + m_bitmapName;
EWOL_INFO("load text font image : \"" << bitmapRealFile << "\"");
etk::File tmpFile(bitmapRealFile, m_filename.GetTypeAccess());
m_textureId = ewol::LoadTexture(tmpFile);
@ -167,7 +167,7 @@ namespace ewol
{
return m_filename;
};
etk::String GetName(void)
etk::UString GetName(void)
{
return m_fontName;
};
@ -175,7 +175,7 @@ namespace ewol
{
return m_textureLoaded;
};
bool Check(etk::String fontName, int32_t size)
bool Check(etk::UString fontName, int32_t size)
{
if (m_loadedOK == -1) {
return false;
@ -191,11 +191,11 @@ namespace ewol
private:
etk::File m_filename;
bool m_loadedOK;
etk::String m_fontName;
etk::UString m_fontName;
int32_t m_size;
uint32_t m_textureId;
bool m_textureLoaded;
etk::String m_bitmapName;
etk::UString m_bitmapName;
etk::VectorType<UTF8Element_ts> m_elements; //
public:
etk::VectorType<UTF8Element_ts> & GetRefOnElement(void)
@ -219,11 +219,11 @@ namespace ewol
static etk::VectorType<ewol::EbtFont*> s_listLoadedFonts;
static etk::String s_currentFolderName = "";
static etk::String s_currentDefaultFontName = "";
static etk::UString s_currentFolderName = "";
static etk::UString s_currentDefaultFontName = "";
static int32_t s_currentDefaultFontId = -1;
void ewol::SetFontFolder(etk::String folderName)
void ewol::SetFontFolder(etk::UString folderName)
{
if (s_currentFolderName != "") {
EWOL_WARNING("Change the FontFolder, old=\"" << s_currentFolderName << "\"");
@ -243,7 +243,7 @@ void ewol::UnInitFont(void)
EWOL_TODO("later");
}
void ewol::SetDefaultFont(etk::String fontName, int32_t size)
void ewol::SetDefaultFont(etk::UString fontName, int32_t size)
{
if (s_currentDefaultFontName != "") {
EWOL_WARNING("Change the default Ewol Font, old=\"" << s_currentDefaultFontName << "\"");
@ -268,10 +268,10 @@ int32_t ewol::GetDefaultFontId(void)
return s_currentDefaultFontId;
}
int32_t ewol::LoadFont(etk::String fontName, int32_t size)
int32_t ewol::LoadFont(etk::UString fontName, int32_t size)
{
// check if folder file
etk::String tmpFileName = s_currentFolderName + "/" + fontName + ".ebt";
etk::UString tmpFileName = s_currentFolderName + "/" + fontName + ".ebt";
etk::File fileName(tmpFileName, etk::FILE_TYPE_DATA);
if (false == fileName.Exist()) {
EWOL_ERROR("Font does not exist: \"" << fileName.GetCompleateName() << "\"");

View File

@ -170,7 +170,7 @@ class FTFontInternal
//EWOL_INFO(" Current size = " << (int)m_fftFace->size);
}
public:
FTFontInternal(etk::File fontFileName, etk::String fontName)
FTFontInternal(etk::File fontFileName, etk::UString fontName)
{
m_fontName = fontName;
m_fileName = fontFileName;
@ -220,7 +220,7 @@ class FTFontInternal
}
}
public:
etk::String GetFontName(void) {return m_fontName;};
etk::UString GetFontName(void) {return m_fontName;};
bool GenerateBitmapFont(int32_t size, int32_t &height, int32_t & textureId, etk::VectorType<freeTypeFontElement_ts> & listElement)
{
// 300dpi (hight quality) 96 dpi (normal quality)
@ -369,7 +369,7 @@ class FTFontInternal
return false;
}
private:
etk::String m_fontName;
etk::UString m_fontName;
etk::File m_fileName;
FT_Byte * m_FileBuffer;
int32_t m_FileSize;
@ -379,13 +379,13 @@ class FTFontInternal
static etk::VectorType<FTFontInternal*> m_listLoadedTTFont;
static etk::String s_currentFolderName = "";
static etk::String s_currentDefaultFontName = "";
static etk::UString s_currentFolderName = "";
static etk::UString s_currentDefaultFontName = "";
static int32_t s_currentDefaultFontId = -1;
class FTFont{
public:
FTFont(etk::File fontfileName, etk::String fontName, int32_t size)
FTFont(etk::File fontfileName, etk::UString fontName, int32_t size)
{
m_trueTypeFontId = -1;
for (int32_t iii=0; iii < m_listLoadedTTFont.Size(); iii++) {
@ -421,7 +421,7 @@ class FTFont{
{
}
bool Check(etk::String fontName, int32_t size)
bool Check(etk::UString fontName, int32_t size)
{
if (m_trueTypeFontId == -1) {
return false;
@ -468,7 +468,7 @@ static etk::VectorType<FTFont*> m_listLoadedFont;
#undef __class__
#define __class__ "ewol::FontFreeType"
void ewol::SetFontFolder(etk::String folderName)
void ewol::SetFontFolder(etk::UString folderName)
{
if (s_currentFolderName != "") {
EWOL_WARNING("Change the FontFolder, old=\"" << s_currentFolderName << "\"");
@ -523,7 +523,7 @@ void ewol::UnInitFont(void)
m_listLoadedTTFont.Clear();
}
void ewol::SetDefaultFont(etk::String fontName, int32_t size)
void ewol::SetDefaultFont(etk::UString fontName, int32_t size)
{
if (s_currentDefaultFontName != "") {
EWOL_WARNING("Change the default Ewol Font, old=\"" << s_currentDefaultFontName << "\"");
@ -548,10 +548,10 @@ int32_t ewol::GetDefaultFontId(void)
return s_currentDefaultFontId;
}
int32_t ewol::LoadFont(etk::String fontName, int32_t size)
int32_t ewol::LoadFont(etk::UString fontName, int32_t size)
{
// check if folder file
etk::String tmpFileName = s_currentFolderName + "/" + fontName;
etk::UString tmpFileName = s_currentFolderName + "/" + fontName;
etk::File fileName(tmpFileName, etk::FILE_TYPE_DATA);
if (false == fileName.Exist()) {
EWOL_ERROR("Font does not exist: \"" << fileName.GetCompleateName() << "\"");
@ -572,39 +572,10 @@ void ewol::UnloadFont(int32_t id)
EWOL_TODO("I do not think it was a good idea... will be done later");
}
// TODO : Change this code ....
int32_t ewol::DrawText(int32_t fontID,
coord2D_ts & drawPosition,
coord2D_ts & clipSize,
const char * utf8String,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex)
{
// TODO : Remove this part of code ... ==> how???
int32_t nbElement = strlen(utf8String);
etk::VectorType<char> tmpStruct;
for (int32_t iii=0; iii<nbElement; iii++) {
tmpStruct.PushBack(utf8String[iii]);
}
clipping_ts tmpClip;
tmpClip.x = 0;
tmpClip.y = 0;
tmpClip.w = clipSize.x;
tmpClip.h = clipSize.y;
etk::VectorType<uniChar_t> outputData;
unicode::convertUtf8ToUnicode(tmpStruct, outputData);
outputData.PushBack(0);
return DrawText(fontID, drawPosition, tmpClip, &outputData[0], fontTextureId, coord, coordTex);
}
int32_t ewol::DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const uniChar_t * unicodeString,
const etk::UString& unicodeString,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex)
@ -614,15 +585,14 @@ int32_t ewol::DrawText(int32_t fontID,
return 0;
}
etk::VectorType<freeTypeFontElement_ts> & listOfElement = m_listLoadedFont[fontID]->GetRefOnElement();
uniChar_t * tmpVal = (uniChar_t *)unicodeString;
fontTextureId = m_listLoadedFont[fontID]->GetOglId();
int32_t fontSize = m_listLoadedFont[fontID]->GetSize();
etkFloat_t posDrawX = textPos.x;
while(*tmpVal != 0) {
uint32_t tmpChar = *tmpVal++;
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
uniChar_t tmpChar = unicodeString[iii];
int32_t charIndex;
if (tmpChar < 0x20) {
charIndex = 0;
@ -758,18 +728,172 @@ int32_t ewol::DrawText(int32_t fontID,
return sizeOut;
}
int32_t ewol::GetWidth(int32_t fontID, const uniChar_t * unicodeString)
// TODO : Simplify this ...
int32_t ewol::DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const uniChar_t unicodeChar,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex)
{
if(fontID>=m_listLoadedFont.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return 0;
}
etk::VectorType<freeTypeFontElement_ts> & listOfElement = m_listLoadedFont[fontID]->GetRefOnElement();
fontTextureId = m_listLoadedFont[fontID]->GetOglId();
int32_t fontSize = m_listLoadedFont[fontID]->GetSize();
etkFloat_t posDrawX = textPos.x;
int32_t charIndex;
if (unicodeChar < 0x20) {
charIndex = 0;
} else if (unicodeChar < 0x80) {
charIndex = unicodeChar - 0x1F;
} else {
charIndex = 0;
for (int32_t iii=0x80-0x20; iii < listOfElement.Size(); iii++) {
if (listOfElement[iii].unicodeCharVal == unicodeChar) {
charIndex = iii;
break;
}
}
}
// 0x01 == 0x20 == ' ';
if (unicodeChar != 0x01) {
/* Bitmap position
* xA xB
* yC *------*
* | |
* | |
* yD *------*
*/
etkFloat_t dxA = posDrawX + listOfElement[charIndex].bearing.x;
etkFloat_t dxB = posDrawX + listOfElement[charIndex].bearing.x + listOfElement[charIndex].size.x;
etkFloat_t dyC = textPos.y + fontSize - listOfElement[charIndex].bearing.y;
etkFloat_t dyD = textPos.y + fontSize - listOfElement[charIndex].bearing.y + listOfElement[charIndex].size.y;
etkFloat_t tuA = listOfElement[charIndex].posStart.u;
etkFloat_t tuB = listOfElement[charIndex].posStop.u;
etkFloat_t tvC = listOfElement[charIndex].posStart.v;
etkFloat_t tvD = listOfElement[charIndex].posStop.v;
// Clipping and drawing area
// TODO : clipping in Y too ...
if( dxB < drawClipping.x
|| dxA > drawClipping.x + drawClipping.w)
{
// Nothing to diplay ...
} else {
// generata positions...
etkFloat_t TexSizeX = tuB - tuA;
if (dxA < drawClipping.x) {
// clip display
etkFloat_t drawSize = drawClipping.x - dxA;
// Update element start display
dxA = drawClipping.x;
etkFloat_t addElement = TexSizeX * drawSize / listOfElement[charIndex].size.x;
// update texture start X Pos
tuA += addElement;
}
if (dxB > drawClipping.x + drawClipping.w) {
// clip display
etkFloat_t drawSize = dxB - (drawClipping.x + drawClipping.w);
// Update element start display
dxB = drawClipping.x + drawClipping.w;
etkFloat_t addElement = TexSizeX * drawSize / listOfElement[charIndex].size.x;
// update texture start X Pos
tuB -= addElement;
}
/* Bitmap position
* 0------1
* | |
* | |
* 3------2
*/
coord2D_ts bitmapDrawPos[4];
bitmapDrawPos[0].x = dxA;
bitmapDrawPos[1].x = dxB;
bitmapDrawPos[2].x = dxB;
bitmapDrawPos[3].x = dxA;
bitmapDrawPos[0].y = dyC;
bitmapDrawPos[1].y = dyC;
bitmapDrawPos[2].y = dyD;
bitmapDrawPos[3].y = dyD;
/* texture Position :
* 0------1
* | |
* | |
* 3------2
*/
texCoord_ts texturePos[4];
texturePos[0].u = tuA;
texturePos[1].u = tuB;
texturePos[2].u = tuB;
texturePos[3].u = tuA;
texturePos[0].v = tvC;
texturePos[1].v = tvC;
texturePos[2].v = tvD;
texturePos[3].v = tvD;
// NOTE : Android does not support the Quads elements ...
/* Step 1 :
* ********
* ******
* ****
* **
*
*/
// set texture coordonates :
coordTex.PushBack(texturePos[0]);
coordTex.PushBack(texturePos[1]);
coordTex.PushBack(texturePos[2]);
// set display positions :
coord.PushBack(bitmapDrawPos[0]);
coord.PushBack(bitmapDrawPos[1]);
coord.PushBack(bitmapDrawPos[2]);
/* Step 2 :
*
* **
* ****
* ******
* ********
*/
// set texture coordonates :
coordTex.PushBack(texturePos[0]);
coordTex.PushBack(texturePos[2]);
coordTex.PushBack(texturePos[3]);
// set display positions :
coord.PushBack(bitmapDrawPos[0]);
coord.PushBack(bitmapDrawPos[2]);
coord.PushBack(bitmapDrawPos[3]);
}
}
posDrawX += listOfElement[charIndex].advance;
int32_t sizeOut = posDrawX - textPos.x;
textPos.x = posDrawX;
return sizeOut;
}
int32_t ewol::GetWidth(int32_t fontID, const etk::UString& unicodeString)
{
if(fontID>=m_listLoadedFont.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return 0;
}
etk::VectorType<freeTypeFontElement_ts> & listOfElement = m_listLoadedFont[fontID]->GetRefOnElement();
uniChar_t * tmpVal = (uniChar_t*)unicodeString;
etkFloat_t posDrawX = 0.0;
while(*tmpVal != 0) {
uint32_t tmpChar = *tmpVal++;
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
uniChar_t tmpChar = unicodeString[iii];
int32_t charIndex;
if (tmpChar >= 0x80) {
charIndex = 0;
@ -793,40 +917,6 @@ int32_t ewol::GetWidth(int32_t fontID, const uniChar_t * unicodeString)
}
int32_t ewol::GetWidth(int32_t fontID, const char * utf8String)
{
if(fontID>=m_listLoadedFont.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return 0;
}
etk::VectorType<freeTypeFontElement_ts> & listOfElement = m_listLoadedFont[fontID]->GetRefOnElement();
char * tmpVal = (char*)utf8String;
etkFloat_t posDrawX = 0.0;
while(*tmpVal != 0) {
uint32_t tmpChar = *tmpVal++;
int32_t charIndex;
if (tmpChar >= 0x80) {
charIndex = 0;
} else if (tmpChar < 0x20) {
charIndex = 0;
} else if (tmpChar < 0x80) {
charIndex = tmpChar - 0x1F;
} else {
for (int32_t iii=0x80-0x20; iii < listOfElement.Size(); iii++) {
if (listOfElement[iii].unicodeCharVal == tmpChar) {
charIndex = iii;
break;
}
}
// TODO : Update if possible the mapping
charIndex = 0;
}
posDrawX += listOfElement[charIndex].advance;
}
return posDrawX;
}
int32_t ewol::GetHeight(int32_t fontID)
{
if(fontID>=m_listLoadedFont.Size() || fontID < 0) {

View File

@ -23,7 +23,7 @@
*/
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/OObject.h>
#include <ewol/importgl.h>
@ -43,7 +43,7 @@ ewol::OObject::~OObject(void)
}
void ewol::OObject::SetName(etk::String & name)
void ewol::OObject::SetName(etk::UString & name)
{
m_name = name;
}
@ -55,7 +55,7 @@ void ewol::OObject::SetName(const char * name)
}
}
etk::String ewol::OObject::GetName(void)
etk::UString ewol::OObject::GetName(void)
{
return m_name;
}

View File

@ -47,16 +47,16 @@ namespace ewol {
virtual ~OObject(void);
public:
virtual void Draw(void) = 0;
void SetName(etk::String & name);
void SetName(etk::UString & name);
void SetName(const char * name);
etk::String GetName(void);
etk::UString GetName(void);
public:
// use to crop element outside the display
virtual void UpdateSize(etkFloat_t sizeX, etkFloat_t sizeY) { };
// Move to the correct position display
virtual void UpdateOrigin(etkFloat_t x, etkFloat_t y) { };
private:
etk::String m_name;
etk::UString m_name;
};
/*

View File

@ -29,7 +29,7 @@
#undef __class__
#define __class__ "ewol::OObject2DText"
ewol::OObject2DText::OObject2DText(etk::String FontName, int32_t size, color_ts textColorFg)
ewol::OObject2DText::OObject2DText(etk::UString FontName, int32_t size, color_ts textColorFg)
{
m_textColorFg = textColorFg;
if (FontName == "") {
@ -77,40 +77,31 @@ void ewol::OObject2DText::Draw(void)
glDisable(GL_TEXTURE_2D);
}
void ewol::OObject2DText::Text(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX)
void ewol::OObject2DText::Clear(void)
{
m_FontTextureId = 0;
m_coord.Clear();
m_coordTex.Clear();
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return;
}
coord2D_ts drawPosition;
drawPosition.x = x;
drawPosition.y = y;
coord2D_ts clipSize;
clipSize.x = clippingPositionX;
clipSize.y = -1;
ewol::DrawText(m_FontId, drawPosition, clipSize, utf8String, m_FontTextureId, m_coord, m_coordTex);
}
void ewol::OObject2DText::TextAdd(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX)
int32_t ewol::OObject2DText::Text(coord2D_ts textPos, clipping_ts drawClipping, const etk::UString& unicodeString)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return;
return 0;
}
coord2D_ts drawPosition;
drawPosition.x = x;
drawPosition.y = y;
coord2D_ts clipSize;
clipSize.x = clippingPositionX;
clipSize.y = -1;
ewol::DrawText(m_FontId, drawPosition, clipSize, utf8String, m_FontTextureId, m_coord, m_coordTex);
return ewol::DrawText(m_FontId, textPos, drawClipping, unicodeString, m_FontTextureId, m_coord, m_coordTex);
}
int32_t ewol::OObject2DText::Text(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t unicodeChar)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
return ewol::DrawText(m_FontId, textPos, drawClipping, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
}
void ewol::OObject2DText::UpdateOrigin(etkFloat_t x, etkFloat_t y)
{
for (int32_t iii=0; iii<m_coord.Size(); iii++) {

View File

@ -26,19 +26,21 @@
#define __EWOL_O_OBJECT_2D_TEXT_H__
#include <ewol/OObject.h>
#include <etk/UString.h>
namespace ewol {
class OObject2DText :public ewol::OObject
{
public:
OObject2DText(etk::String FontName, int32_t size, color_ts textColorFg);
OObject2DText(etk::UString FontName, int32_t size, color_ts textColorFg);
OObject2DText(void);
virtual ~OObject2DText(void);
public:
virtual void Draw(void);
// set a specific text
void Text(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX);
void TextAdd(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX);
void Clear(void);
int32_t Text(coord2D_ts textPos, clipping_ts drawClipping, const etk::UString& unicodeString);
int32_t Text(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t unicodeChar);
protected:
int32_t m_FontId; //!< font internal ID
color_ts m_textColorFg; //!< text color ...

View File

@ -29,7 +29,7 @@
#undef __class__
#define __class__ "ewol::OObject2DTextColored"
ewol::OObject2DTextColored::OObject2DTextColored(etk::String FontName, int32_t size)
ewol::OObject2DTextColored::OObject2DTextColored(etk::UString FontName, int32_t size)
{
m_color.red = 0.0;
m_color.green = 0.0;
@ -96,37 +96,14 @@ void ewol::OObject2DTextColored::Draw(void)
glDisable(GL_TEXTURE_2D);
}
int32_t ewol::OObject2DTextColored::Text(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX)
void ewol::OObject2DTextColored::Clear(void)
{
m_coord.Clear();
m_coordTex.Clear();
m_coordColor.Clear();
// normal adding text :
return TextAdd(x, y, utf8String, clippingPositionX);
}
int32_t ewol::OObject2DTextColored::TextAdd(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
coord2D_ts drawPosition;
drawPosition.x = x;
drawPosition.y = y;
coord2D_ts clipSize;
clipSize.x = clippingPositionX;
clipSize.y = -1;
int32_t nbElementInTheArray = m_coord.Size();
int32_t size = ewol::DrawText(m_FontId, drawPosition, clipSize, utf8String, m_FontTextureId, m_coord, m_coordTex);
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
m_coordColor.PushBack(m_color);
}
return size;
}
int32_t ewol::OObject2DTextColored::TextAdd(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t* unicodeString)
int32_t ewol::OObject2DTextColored::Text(coord2D_ts textPos, clipping_ts drawClipping, const etk::UString& unicodeString)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
@ -141,6 +118,21 @@ int32_t ewol::OObject2DTextColored::TextAdd(coord2D_ts textPos, clipping_ts draw
return size;
}
int32_t ewol::OObject2DTextColored::Text(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t unicodeChar)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
int32_t nbElementInTheArray = m_coord.Size();
int32_t size = ewol::DrawText(m_FontId, textPos, drawClipping, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
m_coordColor.PushBack(m_color);
}
return size;
}
void ewol::OObject2DTextColored::UpdateOrigin(etkFloat_t x, etkFloat_t y)
{

View File

@ -31,7 +31,7 @@ namespace ewol {
class OObject2DTextColored :public ewol::OObject
{
public:
OObject2DTextColored(etk::String FontName, int32_t size);
OObject2DTextColored(etk::UString FontName, int32_t size);
OObject2DTextColored(int32_t fontID);
OObject2DTextColored(void);
virtual ~OObject2DTextColored(void);
@ -40,9 +40,9 @@ namespace ewol {
void SetColor(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha = 1.0);
void SetColor(color_ts color);
// set a specific text
int32_t Text(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX);
int32_t TextAdd(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX);
int32_t TextAdd(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t* unicodeString);
void Clear(void);
int32_t Text(coord2D_ts textPos, clipping_ts drawClipping, const etk::UString& unicodeString);
int32_t Text(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t unicodeChar);
protected:
int32_t m_FontId; //!< font internal ID
color_ts m_color; //!< tmp text color ...

View File

@ -311,7 +311,7 @@ class Bitmap
class LoadedTexture
{
public:
etk::String m_filename;
etk::UString m_filename;
int32_t m_nbTimeLoaded;
// openGl configuration :
uint32_t m_openGlTextureID;
@ -454,7 +454,7 @@ int32_t ewol::LoadTexture(int32_t target,
int32_t type,
const void* data,
int32_t nbBytes,
etk::String filename)
etk::UString filename)
{
LoadedTexture *tmpTex = new LoadedTexture();
@ -506,7 +506,7 @@ int32_t ewol::LoadTexture(etk::File fileName)
}
}
}
etk::String fileExtention = fileName.GetExtention();
etk::UString fileExtention = fileName.GetExtention();
if (fileExtention == "bmp") {
if (false == fileName.Exist()) {
EWOL_ERROR("File does not Exist ... " << fileName);

View File

@ -44,7 +44,7 @@ namespace ewol
void UnInit(void);
};
int32_t LoadTexture(etk::File fileName);
int32_t LoadTexture(int32_t target, int32_t level, int32_t internalFormat, int32_t width, int32_t height, int32_t border, int32_t format, int32_t type, const void* data, int32_t nbBytes, etk::String filename);
int32_t LoadTexture(int32_t target, int32_t level, int32_t internalFormat, int32_t width, int32_t height, int32_t border, int32_t format, int32_t type, const void* data, int32_t nbBytes, etk::UString filename);
void UnLoadTexture(uint32_t textureID);
int32_t GetTextureSize(uint32_t textureID);
uint32_t GetTextureGLID(uint32_t textureID);

View File

@ -251,7 +251,7 @@ bool ewol::Widget::ExternLinkOnEvent(const char * eventName, int32_t widgetId, c
void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name, int32_t pos)
void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::UString name, int32_t pos)
{
if (NULL == newObject) {
EWOL_ERROR("Try to add an empty object in the Widget generic display system : name=\"" << name << "\"");
@ -271,7 +271,7 @@ void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name, int32_
}
ewol::OObject* ewol::Widget::GetOObject(etk::String name)
ewol::OObject* ewol::Widget::GetOObject(etk::UString name)
{
for (int32_t iii=0; iii<m_listOObject[m_currentCreateId].Size(); iii++) {
if (m_listOObject[m_currentCreateId][iii]->GetName() == name) {
@ -281,7 +281,7 @@ ewol::OObject* ewol::Widget::GetOObject(etk::String name)
return NULL;
}
void ewol::Widget::RmOObjectElem(etk::String name)
void ewol::Widget::RmOObjectElem(etk::UString name)
{
for (int32_t iii=0; iii<m_listOObject[m_currentCreateId].Size(); iii++) {
if (m_listOObject[m_currentCreateId][iii]->GetName() == name) {

View File

@ -298,9 +298,9 @@ namespace ewol {
public:
void DoubleBufferFlipFlop(void);
protected:
void AddOObject(ewol::OObject* newObject, etk::String name = "", int32_t pos=-1);
ewol::OObject* GetOObject(etk::String name);
void RmOObjectElem(etk::String name);
void AddOObject(ewol::OObject* newObject, etk::UString name = "", int32_t pos=-1);
ewol::OObject* GetOObject(etk::UString name);
void RmOObjectElem(etk::UString name);
void ClearOObjectList(void);
void GenericDrawDisable(void) { m_genericDraw = false; };
void GenericDrawEnable(void) { m_genericDraw = true; };

View File

@ -103,4 +103,8 @@ void ewol::widgetMessageMultiCast::Send(int32_t widgetId, const char* const mess
}
}
void ewol::widgetMessageMultiCast::Send(int32_t widgetId, const char* const message, etk::UString& data)
{
Send(widgetId, message, data.Utf8Data());
}

View File

@ -30,6 +30,7 @@
#include <ewol/OObject.h>
#include <etk/VectorType.h>
#include <ewol/Widget.h>
#include <etk/UString.h>
namespace ewol {
namespace widgetMessageMultiCast {
@ -38,7 +39,9 @@ namespace ewol {
void Add( int32_t widgetId, const char* const message);
void Rm( int32_t widgetId);
void Send(int32_t widgetId, const char* const message, int32_t data);
// TODO : Mus be deprecated ....
void Send(int32_t widgetId, const char* const message, const char * data = NULL);
void Send(int32_t widgetId, const char* const message, etk::UString& data);
};
};

View File

@ -23,7 +23,7 @@
*/
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/Widget.h>
#include <ewol/Windows.h>
#include <ewol/OObject.h>

View File

@ -25,7 +25,7 @@
#include <ewol/Debug.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>

View File

@ -27,7 +27,7 @@
#define __GUI_ABSTRACTION_H__
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/Windows.h>
void EWOL_NativeResize(int w, int h );

View File

@ -31,7 +31,7 @@
#include <stdint.h>
#include <ewol/Debug.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/ewol.h>
@ -260,7 +260,7 @@ int32_t ewol::CmdLineNb(void)
return 0;
}
etk::String ewol::CmdLineGet(int32_t id)
etk::UString ewol::CmdLineGet(int32_t id)
{
return "";
}

View File

@ -24,7 +24,7 @@
#include <ewol/Debug.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/unicode.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
@ -713,14 +713,14 @@ bool guiAbstraction::IsPressedInput(int32_t inputID)
#include <ewol/ewol.h>
static etk::VectorType<etk::String*> listArgs;
static etk::VectorType<etk::UString*> listArgs;
int32_t ewol::CmdLineNb(void)
{
return listArgs.Size();
}
etk::String ewol::CmdLineGet(int32_t id)
etk::UString ewol::CmdLineGet(int32_t id)
{
if (id<0 && id>=listArgs.Size()) {
return "";
@ -736,7 +736,7 @@ int main(int argc, char *argv[])
{
for( int32_t i=1 ; i<argc; i++) {
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
etk::String* tmpString = new etk::String(argv[i]);
etk::UString* tmpString = new etk::UString(argv[i]);
if (NULL != tmpString) {
listArgs.PushBack(tmpString);
}

View File

@ -27,7 +27,7 @@
#define __EWOL_H__
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/Widget.h>
#include <ewol/Windows.h>
@ -42,8 +42,8 @@ namespace ewol {
void KeyboardShow(ewol::keyboardMode_te mode);
void KeyboardHide(void);
void ForceRedrawAll(void);
int32_t CmdLineNb(void);
etk::String CmdLineGet(int32_t id);
int32_t CmdLineNb(void);
etk::UString CmdLineGet(int32_t id);
bool IsSetCapsLock(void);
bool IsSetShift(void);

View File

@ -28,7 +28,7 @@
#define __EWOL_THEME_EOL_BASE__H__
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <ewol/OObject.h>
#include <tinyXML/tinyxml.h>

View File

@ -45,8 +45,8 @@ namespace ewol {
virtual void Parse(TiXmlNode * pNode);
virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
private:
etk::String m_colorBG;
etk::String m_colorBorder;
etk::UString m_colorBG;
etk::UString m_colorBorder;
coord2D_ts m_posCenter;
etkFloat_t m_radius;
etkFloat_t m_thickness;

View File

@ -45,7 +45,7 @@ namespace ewol {
virtual void Parse(TiXmlNode * pNode);
virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
private:
etk::String m_color;
etk::UString m_color;
coord2D_ts m_posStart;
coord2D_ts m_posStop;
etkFloat_t m_thickness;

View File

@ -46,8 +46,8 @@ namespace ewol {
virtual void Parse(TiXmlNode * pNode);
virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
private:
etk::String m_colorBG;
etk::String m_colorBorder;
etk::UString m_colorBG;
etk::UString m_colorBorder;
coord2D_ts m_position;
coord2D_ts m_size;
etkFloat_t m_thickness;

View File

@ -88,19 +88,19 @@ void ewol::theme::EolColor::Parse(TiXmlNode * pNode)
}
etk::String ewol::theme::EolColor::GetName(void) const
etk::UString ewol::theme::EolColor::GetName(void) const
{
return m_name;
}
void ewol::theme::EolColor::SetName(etk::String & newName)
void ewol::theme::EolColor::SetName(etk::UString & newName)
{
m_name = newName;
}
bool ewol::theme::EolColor::HasName(etk::String & newName) const
bool ewol::theme::EolColor::HasName(etk::UString & newName) const
{
return m_name == newName;
}

View File

@ -28,7 +28,7 @@
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/File.h>
#include <ewol/OObject.h>
#include <tinyXML/tinyxml.h>
@ -42,15 +42,15 @@ namespace ewol {
virtual ~EolColor(void);
void Parse(TiXmlNode * pNode);
etk::String GetName(void) const;
void SetName(etk::String & newName);
bool HasName(etk::String & newName) const;
etk::UString GetName(void) const;
void SetName(etk::UString & newName);
bool HasName(etk::UString & newName) const;
color_ts Get(void) const;
void Set(color_ts newColor);
void Set(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha = 1);
private:
color_ts m_color;
etk::String m_name;
color_ts m_color;
etk::UString m_name;
};
};
};

View File

@ -78,13 +78,13 @@ void ewol::theme::EolElement::Parse(TiXmlNode * root)
sscanf(tmp, "%lf", &xxx);
m_ratio=xxx;
}
etk::String tmpString = root->ToElement()->Attribute("ClipX");
etk::UString tmpString = root->ToElement()->Attribute("ClipX");
if (tmpString == "true") {
m_clipX = true;
} else {
m_clipX = false;
}
etk::String tmpString2 = root->ToElement()->Attribute("ClipY");
etk::UString tmpString2 = root->ToElement()->Attribute("ClipY");
if (tmpString2 == "true") {
m_clipY = true;
} else {
@ -119,10 +119,10 @@ void ewol::theme::EolElement::Parse(TiXmlNode * root)
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
continue;
}
etk::String nodeValue = pNode->Value();
etk::UString nodeValue = pNode->Value();
if (nodeValue == "group") {
//EWOL_INFO("Find group ... ");
etk::String groupNameTmp = pNode->ToElement()->Attribute("name");
etk::UString groupNameTmp = pNode->ToElement()->Attribute("name");
if (groupNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)");
// not added it
@ -152,7 +152,7 @@ void ewol::theme::EolElement::Parse(TiXmlNode * root)
}
} else if (nodeValue == "frame") {
//EWOL_INFO("Find frame ... ");
etk::String groupNameTmp = pNode->ToElement()->Attribute("name");
etk::UString groupNameTmp = pNode->ToElement()->Attribute("name");
if (groupNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)");
// not added it
@ -181,7 +181,7 @@ void ewol::theme::EolElement::Parse(TiXmlNode * root)
}
}
} else if (nodeValue == "color") {
etk::String colorNameTmp = pNode->ToElement()->Attribute("name");
etk::UString colorNameTmp = pNode->ToElement()->Attribute("name");
if (colorNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Color with NO name ... (not parsed)");
// not added it
@ -218,7 +218,7 @@ void ewol::theme::EolElement::Parse(TiXmlNode * root)
bool ewol::theme::EolElement::GetColor(etk::String colorName, color_ts & selectedColor) const
bool ewol::theme::EolElement::GetColor(etk::UString colorName, color_ts & selectedColor) const
{
for (int32_t iii=0; iii < m_listColor.Size(); iii++) {
if(NULL!=m_listColor[iii]) {
@ -241,7 +241,7 @@ int32_t ewol::theme::EolElement::GetNbFrame(void) const
}
int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName) const
int32_t ewol::theme::EolElement::GetFrameId(etk::UString & frameName) const
{
for (int32_t iii=0; iii < m_listElement.Size(); iii++) {
if(NULL!=m_listElement[iii]) {
@ -254,19 +254,19 @@ int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName) const
}
etk::String ewol::theme::EolElement::GetName(void) const
etk::UString ewol::theme::EolElement::GetName(void) const
{
return m_name;
}
void ewol::theme::EolElement::SetName(etk::String & newName)
void ewol::theme::EolElement::SetName(etk::UString & newName)
{
m_name = newName;
}
bool ewol::theme::EolElement::HasName(etk::String & newName) const
bool ewol::theme::EolElement::HasName(etk::UString & newName) const
{
return m_name == newName;
}

View File

@ -28,7 +28,7 @@
#define __EWOL_THEME_EOL_ELEMENT_H__
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/File.h>
#include <ewol/OObject.h>
#include <ewol/theme/EolColor.h>
@ -42,25 +42,25 @@ namespace ewol {
EolElement(void);
virtual ~EolElement(void);
void Parse(TiXmlNode * pNode);
etk::String GetName(void) const;
void SetName(etk::String & newName);
bool HasName(etk::String & newName) const;
etk::UString GetName(void) const;
void SetName(etk::UString & newName);
bool HasName(etk::UString & newName) const;
void Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GenerateGroup(const ewol::theme::Theme * myTheme, etk::String groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GetColor(etk::String colorName, color_ts & selectedColor) const;
bool GenerateGroup(const ewol::theme::Theme * myTheme, etk::UString groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GetColor(etk::UString colorName, color_ts & selectedColor) const;
int32_t GetNbFrame(void) const;
int32_t GetFrameId(etk::String & frameName) const;
int32_t GetFrameId(etk::UString & frameName) const;
private:
void RemoveAll(void);
etk::String m_name;
etk::UString m_name;
/*
void Load(etk::File & newFile) { };
void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) {};
int32_t GetNbFrame(int32_t id) {return 0;};
int32_t GetFrameId(int32_t id, etk::String & frameName) {return 0;};
int32_t GetObjectId(etk::String name) { return -1; };
int32_t GetFrameId(int32_t id, etk::UString & frameName) {return 0;};
int32_t GetObjectId(etk::UString name) { return -1; };
*/
private:
etk::VectorType<ewol::theme::EolColor*> m_listColor;

View File

@ -62,7 +62,7 @@ void ewol::theme::EolElementFrame::Parse(TiXmlNode * root)
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
continue;
}
etk::String nodeValue = pNode->Value();
etk::UString nodeValue = pNode->Value();
ewol::theme::EolBase * myBaseTmp = NULL;
if (nodeValue == "line") {
//EWOL_INFO("Find baseElement Line");
@ -102,19 +102,19 @@ void ewol::theme::EolElementFrame::Parse(TiXmlNode * root)
}
etk::String ewol::theme::EolElementFrame::GetName(void)
etk::UString ewol::theme::EolElementFrame::GetName(void)
{
return m_name;
}
void ewol::theme::EolElementFrame::SetName(etk::String & newName)
void ewol::theme::EolElementFrame::SetName(etk::UString & newName)
{
m_name = newName;
}
bool ewol::theme::EolElementFrame::HasName(etk::String & newName)
bool ewol::theme::EolElementFrame::HasName(etk::UString & newName)
{
return m_name == newName;
}

View File

@ -28,7 +28,7 @@
#define __EWOL_THEME_EOL_ELEMENT_FRAME_H__
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/File.h>
#include <ewol/OObject.h>
#include <ewol/theme/EolColor.h>
@ -51,12 +51,12 @@ namespace ewol {
void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
void Parse(TiXmlNode * pNode);
etk::String GetName(void);
void SetName(etk::String & newName);
bool HasName(etk::String & newName);
etk::UString GetName(void);
void SetName(etk::UString & newName);
bool HasName(etk::UString & newName);
private:
void RemoveAll(void);
etk::String m_name;
etk::UString m_name;
etk::VectorType<ewol::theme::EolBase*> m_description; // all element to draw the image ...
public:
// acces to manage and create object ==> drawing system

View File

@ -94,10 +94,10 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
continue;
}
etk::String nodeValue = pNode->Value();
etk::UString nodeValue = pNode->Value();
if (nodeValue == "element") {
//EWOL_INFO("Find ELEMENT ... ");
etk::String elementNameTmp = pNode->ToElement()->Attribute("name");
etk::UString elementNameTmp = pNode->ToElement()->Attribute("name");
if (elementNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Element with NO name ... (not parsed)");
// not added it
@ -127,7 +127,7 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
} else if (nodeValue == "group") {
//EWOL_INFO("Find group ... ");
etk::String groupNameTmp = pNode->ToElement()->Attribute("name");
etk::UString groupNameTmp = pNode->ToElement()->Attribute("name");
if (groupNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)");
// not added it
@ -156,7 +156,7 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
}
} else if (nodeValue == "color") {
etk::String colorNameTmp = pNode->ToElement()->Attribute("name");
etk::UString colorNameTmp = pNode->ToElement()->Attribute("name");
if (colorNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Color with NO name ... (not parsed)");
// not added it
@ -196,7 +196,7 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
bool ewol::theme::Theme::GetColor(etk::String colorName, color_ts & selectedColor)
bool ewol::theme::Theme::GetColor(etk::UString colorName, color_ts & selectedColor)
{
for (int32_t iii=0; iii < m_listColor.Size(); iii++) {
if(NULL!=m_listColor[iii]) {
@ -223,7 +223,7 @@ void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, ewol::OObject2DCo
}
}
bool ewol::theme::Theme::GenerateGroup(etk::String groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
bool ewol::theme::Theme::GenerateGroup(etk::UString groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
if (groupName == "") {
EWOL_ERROR("Did not find the group name=" << groupName);
@ -253,7 +253,7 @@ int32_t ewol::theme::Theme::GetNbFrame(int32_t id)
return 0;
}
int32_t ewol::theme::Theme::GetFrameId(int32_t id, etk::String & frameName)
int32_t ewol::theme::Theme::GetFrameId(int32_t id, etk::UString & frameName)
{
if (0 > id || id > m_listElement.Size()) {
EWOL_ERROR("Did not find the Element named=" << frameName);
@ -266,7 +266,7 @@ int32_t ewol::theme::Theme::GetFrameId(int32_t id, etk::String & frameName)
}
int32_t ewol::theme::Theme::GetObjectId(etk::String name)
int32_t ewol::theme::Theme::GetObjectId(etk::UString name)
{
if (name == "") {
return -1;

View File

@ -34,7 +34,7 @@ namespace ewol {
}
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/File.h>
#include <etk/VectorType.h>
#include <ewol/OObject.h>
@ -51,11 +51,11 @@ namespace ewol {
virtual ~Theme(void);
void Load(etk::File & newFile, bool defaultTheme=false);
void Generate(int32_t id, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GenerateGroup(etk::String groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GetColor(etk::String colorName, color_ts & selectedColor);
bool GenerateGroup(etk::UString groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GetColor(etk::UString colorName, color_ts & selectedColor);
int32_t GetNbFrame(int32_t id);
int32_t GetFrameId(int32_t id, etk::String & frameName);
int32_t GetObjectId(etk::String name);
int32_t GetFrameId(int32_t id, etk::UString & frameName);
int32_t GetObjectId(etk::UString name);
private:
etk::VectorType<ewol::theme::EolColor*> m_listColor;
etk::VectorType<ewol::theme::EolElementFrame*> m_listGroup;

View File

@ -68,7 +68,7 @@ void ewol::theme::Load(etk::File filename)
}
int32_t ewol::theme::GetObjectId(etk::String name)
int32_t ewol::theme::GetObjectId(etk::UString name)
{
if (NULL == localTheme) {
return 0;
@ -103,7 +103,7 @@ int32_t ewol::theme::GetNbFrame(int32_t id)
}
int32_t ewol::theme::GetFrameId(int32_t id, etk::String & frameName)
int32_t ewol::theme::GetFrameId(int32_t id, etk::UString & frameName)
{
if (NULL == localTheme) {
return 0;

View File

@ -28,7 +28,7 @@
#define __EWOL_THEME_MANAGER_H__
#include <etk/Types.h>
#include <etk/String.h>
#include <etk/UString.h>
#include <etk/File.h>
#include <ewol/OObject.h>
@ -38,11 +38,11 @@ namespace ewol {
void UnInit(void);
void LoadDefault(etk::File filename); // default system theme ==> when an element in not find in the user theme, it is search in this one ... not needed
void Load(etk::File filename); // add a user theme at the list ==> this remove previous declaration by the user...
int32_t GetObjectId(etk::String name);
int32_t GetObjectId(etk::UString name);
// ???? GetObjectType(int32_t id);
void Generate(int32_t id, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
int32_t GetNbFrame(int32_t id);
int32_t GetFrameId(int32_t id, etk::String & frameName);
int32_t GetFrameId(int32_t id, etk::UString & frameName);
};
};

View File

@ -62,7 +62,7 @@ ewol::Button::Button(void)
Init();
}
ewol::Button::Button(etk::String newLabel)
ewol::Button::Button(etk::UString newLabel)
{
m_label = newLabel;
Init();
@ -77,7 +77,7 @@ ewol::Button::~Button(void)
bool ewol::Button::CalculateMinSize(void)
{
int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
m_minSize.x = 16+minWidth;
m_minSize.y = 16+minHeight;
@ -86,7 +86,7 @@ bool ewol::Button::CalculateMinSize(void)
}
void ewol::Button::SetLabel(etk::String newLabel)
void ewol::Button::SetLabel(etk::UString newLabel)
{
m_label = newLabel;
}
@ -139,7 +139,15 @@ void ewol::Button::OnRegenerateDisplay(void)
int32_t fontHeight = ewol::GetHeight(fontId);
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
*/
tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_label.c_str(), m_size.x - borderSize - 2*paddingSize);
coord2D_ts textPos;
textPos.x = tmpTextOriginX;
textPos.y = tmpTextOriginY;
clipping_ts drawClipping;
drawClipping.x = paddingSize;
drawClipping.y = paddingSize;
drawClipping.w = m_size.x - borderSize - 2*paddingSize;
drawClipping.h = m_size.y - borderSize - 2*paddingSize;
tmpText->Text(textPos, drawClipping, m_label);
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
tmpOObjects->SetColor(m_textColorBg);

View File

@ -38,20 +38,20 @@ namespace ewol {
{
public:
Button(void);
Button(etk::String newLabel);
Button(etk::UString newLabel);
void Init(void);
virtual ~Button(void);
virtual bool CalculateMinSize(void);
void SetLabel(etk::String newLabel);
etk::String GetLabel(void) {return m_label;};
void SetLabel(etk::UString newLabel);
etk::UString GetLabel(void) {return m_label;};
// TODO :
//void SetSize(int32_t size);
//void SetFont(etk::String fontName);
//void SetFont(etk::UString fontName);
//void ResetDefaultParameters(void);
void SetValue(bool val);
bool GetValue(void);
private:
etk::String m_label;
etk::UString m_label;
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color
public:

View File

@ -57,7 +57,7 @@ ewol::CheckBox::CheckBox(void)
Init();
}
ewol::CheckBox::CheckBox(etk::String newLabel)
ewol::CheckBox::CheckBox(etk::UString newLabel)
{
m_label = newLabel;
Init();
@ -72,7 +72,7 @@ ewol::CheckBox::~CheckBox(void)
bool ewol::CheckBox::CalculateMinSize(void)
{
int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
etkFloat_t boxSize = etk_max(20, minHeight) + 5;
m_minSize.x = boxSize+minWidth;
@ -82,7 +82,7 @@ bool ewol::CheckBox::CalculateMinSize(void)
}
void ewol::CheckBox::SetLabel(etk::String newLabel)
void ewol::CheckBox::SetLabel(etk::UString newLabel)
{
m_label = newLabel;
}
@ -118,7 +118,18 @@ void ewol::CheckBox::OnRegenerateDisplay(void)
//int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t posy = (m_size.y - fontHeight - 6)/2 + 3;
//int32_t posx = (m_size.x - fontWidth - 6)/2 + 25;
tmpText->Text(boxSize+5, posy, m_label.c_str(), m_size.x - (boxSize+5));
coord2D_ts textPos;
textPos.x = boxSize+5;
textPos.y = posy;
clipping_ts drawClipping;
drawClipping.x = 0;
drawClipping.y = 0;
drawClipping.w = m_size.x - (boxSize+5);
drawClipping.h = m_size.y;
tmpText->Text(textPos, drawClipping, m_label);
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;

View File

@ -36,15 +36,15 @@ namespace ewol {
{
public:
CheckBox(void);
CheckBox(etk::String newLabel);
CheckBox(etk::UString newLabel);
void Init(void);
virtual ~CheckBox(void);
virtual bool CalculateMinSize(void);
void SetLabel(etk::String newLabel);
void SetLabel(etk::UString newLabel);
void SetValue(bool val);
bool GetValue(void);
private:
etk::String m_label;
etk::UString m_label;
bool m_value;
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color

View File

@ -71,7 +71,7 @@ ewol::Entry::Entry(void)
MarkToReedraw();
}
ewol::Entry::Entry(etk::String newData)
ewol::Entry::Entry(etk::UString newData)
{
Init();
SetValue(newData);
@ -97,14 +97,14 @@ bool ewol::Entry::CalculateMinSize(void)
}
void ewol::Entry::SetValue(etk::String newData)
void ewol::Entry::SetValue(etk::UString newData)
{
m_data = newData;
UpdateTextPosition();
MarkToReedraw();
}
etk::String ewol::Entry::GetValue(void)
etk::UString ewol::Entry::GetValue(void)
{
return m_data;
}
@ -140,7 +140,18 @@ void ewol::Entry::OnRegenerateDisplay(void)
tmpSizeY -= 2*m_paddingSize;
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_data.c_str() + m_displayStartPosition, m_size.x - (m_borderSize + 2*m_paddingSize));
etk::UString tmpDisplay = m_data.Extract(m_displayStartPosition);
coord2D_ts textPos;
textPos.x = tmpTextOriginX;
textPos.y = tmpTextOriginY;
clipping_ts drawClipping;
drawClipping.x = 0;
drawClipping.y = 0;
drawClipping.w = m_size.x - (m_borderSize + 2*m_paddingSize);
drawClipping.h = m_size.y;
tmpText->Text(textPos, drawClipping, tmpDisplay);
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
tmpOObjects->SetColor(m_textColorBg);
@ -150,7 +161,7 @@ void ewol::Entry::OnRegenerateDisplay(void)
if (true == m_displayCursor) {
int32_t fontId = GetDefaultFontId();
int32_t fontHeight = ewol::GetHeight(fontId);
int32_t fontWidth = ewol::GetWidth(fontId, m_data.c_str() + m_displayStartPosition);
int32_t fontWidth = ewol::GetWidth(fontId, tmpDisplay);
int32_t XCursorPos = fontWidth + m_borderSize + 2*m_paddingSize;
tmpOObjects->Line(XCursorPos, tmpTextOriginY, XCursorPos, tmpTextOriginY + fontHeight, 1);
}
@ -211,7 +222,7 @@ void ewol::Entry::UpdateTextPosition(void)
}
int32_t tmpUserSize = tmpSizeX - 2*(m_borderSize + 2*m_paddingSize);
while (iii > 0) {
if (ewol::GetWidth(fontId, m_data.c_str()+(iii-1)) > tmpUserSize) {
if (ewol::GetWidth(fontId, m_data[iii]) > tmpUserSize) {
break;
}
iii--;

View File

@ -38,18 +38,18 @@ namespace ewol {
{
public:
Entry(void);
Entry(etk::String newData);
Entry(etk::UString newData);
virtual ~Entry(void);
void Init(void);
virtual bool CalculateMinSize(void);
void SetValue(etk::String newData);
etk::String GetValue(void);
void SetValue(etk::UString newData);
etk::UString GetValue(void);
void SetWidth(int32_t width)
{
m_userSize = width;
}
private:
etk::String m_data;
etk::UString m_data;
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color
int32_t m_userSize;

View File

@ -52,7 +52,7 @@ ewol::Label::Label(void)
Init();
}
ewol::Label::Label(etk::String newLabel)
ewol::Label::Label(etk::UString newLabel)
{
m_label = newLabel;
Init();
@ -67,7 +67,7 @@ ewol::Label::~Label(void)
bool ewol::Label::CalculateMinSize(void)
{
int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
m_minSize.x = 3+minWidth;
m_minSize.y = 3+minHeight;
@ -76,7 +76,7 @@ bool ewol::Label::CalculateMinSize(void)
}
void ewol::Label::SetLabel(etk::String newLabel)
void ewol::Label::SetLabel(etk::UString newLabel)
{
m_label = newLabel;
}
@ -103,7 +103,16 @@ void ewol::Label::OnRegenerateDisplay(void)
tmpOriginY += paddingSize;
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
tmpText->Text(tmpOriginX, tmpOriginY, m_label.c_str(), m_size.x - 2*paddingSize);
coord2D_ts textPos;
textPos.x = tmpOriginX;
textPos.y = tmpOriginY;
clipping_ts drawClipping;
drawClipping.x = paddingSize;
drawClipping.y = paddingSize;
drawClipping.w = m_size.x - 2*paddingSize;
drawClipping.h = m_size.y - 2*paddingSize;
tmpText->Text(textPos, drawClipping, m_label);
AddOObject(tmpText, "LabelText");
}

View File

@ -36,13 +36,13 @@ namespace ewol {
{
public:
Label(void);
Label(etk::String newLabel);
Label(etk::UString newLabel);
void Init(void);
virtual ~Label(void);
virtual bool CalculateMinSize(void);
void SetLabel(etk::String newLabel);
void SetLabel(etk::UString newLabel);
private:
etk::String m_label;
etk::UString m_label;
color_ts m_textColorFg; //!< Text color
public:
virtual void OnRegenerateDisplay(void);

View File

@ -56,7 +56,7 @@ ewol::List::~List(void)
bool ewol::List::CalculateMinSize(void)
{
/*int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
m_minSize.x = 3+minWidth;
m_minSize.y = 3+minHeight;
@ -89,7 +89,7 @@ void ewol::List::OnRegenerateDisplay(void)
tmpOriginY += m_paddingSizeY;
int32_t fontId = GetDefaultFontId();
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
//int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
@ -97,7 +97,7 @@ void ewol::List::OnRegenerateDisplay(void)
uint32_t nbRaw = GetNuberOfRaw();
// For the scrooling windows
m_maxSize.x = m_size.x;
m_maxSize.y = minHeight * nbRaw;
m_maxSize.y = (minHeight + 2*m_paddingSizeY) * nbRaw;
etk::VectorType<int32_t> listSizeColomn;
@ -115,8 +115,15 @@ void ewol::List::OnRegenerateDisplay(void)
}
// We display only compleate lines ...
EWOL_VERBOSE("Request drawing list : " << startRaw << "-->" << (startRaw+displayableRaw) << " in " << nbRaw << "raws");
clipping_ts drawClipping;
drawClipping.x = 0;
drawClipping.y = 0;
drawClipping.w = m_size.x - (2*m_paddingSizeX);
drawClipping.h = m_size.y;
for(uint32_t iii=startRaw; iii<nbRaw && iii<(startRaw+displayableRaw); iii++) {
etk::String myTextToWrite;
etk::UString myTextToWrite;
color_ts fg;
color_ts bg;
GetElement(0, iii, myTextToWrite, fg, bg);
@ -125,7 +132,12 @@ void ewol::List::OnRegenerateDisplay(void)
tmpOriginYBG += minHeight+2*m_paddingSizeY;
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg);
tmpText->Text(tmpOriginX, tmpOriginY, myTextToWrite.c_str(), m_size.x - (2*m_paddingSizeX));
coord2D_ts textPos;
textPos.x = tmpOriginX;
textPos.y = tmpOriginY;
tmpText->Text(textPos, drawClipping, myTextToWrite);
AddOObject(tmpText);
tmpOriginY += minHeight + 2* m_paddingSizeY;
}

View File

@ -37,7 +37,7 @@ namespace ewol {
void Init(void);
virtual ~List(void);
virtual bool CalculateMinSize(void);
void SetLabel(etk::String newLabel);
void SetLabel(etk::UString newLabel);
private:
int32_t m_paddingSizeX;
int32_t m_paddingSizeY;
@ -59,14 +59,14 @@ namespace ewol {
virtual uint32_t GetNuberOfColomn(void) {
return 0;
};
virtual bool GetTitle(int32_t colomn, etk::String &myTitle, color_ts &fg, color_ts &bg) {
virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg) {
myTitle = "";
return false;
};
virtual uint32_t GetNuberOfRaw(void) {
return 0;
};
virtual bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) {
virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg) {
myTextToWrite = "";
fg.red = 0.0;
fg.green = 0.0;

View File

@ -44,9 +44,9 @@ extern "C" {
#define __class__ "ewol::FileChooser(FolderList)"
void SortList(etk::VectorType<etk::String *> &m_listDirectory)
void SortList(etk::VectorType<etk::UString *> &m_listDirectory)
{
etk::VectorType<etk::String *> tmpList = m_listDirectory;
etk::VectorType<etk::UString *> tmpList = m_listDirectory;
m_listDirectory.Clear();
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
m_listDirectory.PushBack(tmpList[iii]);
@ -60,8 +60,8 @@ const char * const ewolEventFileChooserSelectFolder = "ewol-event-file-chooser
class FileChooserFolderList : public ewol::List
{
private:
//etk::Vector<etk::String> m_listDirectory;
etk::VectorType<etk::String *> m_listDirectory;
//etk::Vector<etk::UString> m_listDirectory;
etk::VectorType<etk::UString *> m_listDirectory;
int32_t m_selectedLine;
public:
FileChooserFolderList(void)
@ -74,9 +74,9 @@ class FileChooserFolderList : public ewol::List
ClearElements();
};
void AddElement(etk::String element)
void AddElement(etk::UString element)
{
etk::String* tmpEmement = new etk::String(element);
etk::UString* tmpEmement = new etk::UString(element);
m_listDirectory.PushBack(tmpEmement);
MarkToReedraw();
}
@ -91,9 +91,9 @@ class FileChooserFolderList : public ewol::List
MarkToReedraw();
}
etk::String GetSelectedLine(void)
etk::UString GetSelectedLine(void)
{
etk::String tmpVal = "";
etk::UString tmpVal = "";
if (m_selectedLine >= 0) {
tmpVal = *(m_listDirectory[m_selectedLine]);
}
@ -113,14 +113,14 @@ class FileChooserFolderList : public ewol::List
uint32_t GetNuberOfColomn(void) {
return 1;
};
bool GetTitle(int32_t colomn, etk::String &myTitle, color_ts &fg, color_ts &bg) {
bool GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg) {
myTitle = "title";
return true;
};
uint32_t GetNuberOfRaw(void) {
return m_listDirectory.Size();
};
bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) {
bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg) {
if (raw >= 0 && raw < m_listDirectory.Size()) {
myTextToWrite = *(m_listDirectory[raw]);
} else {
@ -187,7 +187,7 @@ const char * const ewolEventFileChooserValidateFile = "ewol-event-file-chooser
class FileChooserFileList : public ewol::List
{
private:
etk::VectorType<etk::String *> m_listFile;
etk::VectorType<etk::UString *> m_listFile;
int32_t m_selectedLine;
public:
FileChooserFileList(void)
@ -208,9 +208,9 @@ class FileChooserFileList : public ewol::List
bg.alpha = 1.0;
return bg;
}
void AddElement(etk::String element)
void AddElement(etk::UString element)
{
etk::String* tmpEmement = new etk::String(element);
etk::UString* tmpEmement = new etk::UString(element);
m_listFile.PushBack(tmpEmement);
MarkToReedraw();
}
@ -225,9 +225,9 @@ class FileChooserFileList : public ewol::List
MarkToReedraw();
}
etk::String GetSelectedLine(void)
etk::UString GetSelectedLine(void)
{
etk::String tmpVal = "";
etk::UString tmpVal = "";
if (m_selectedLine >= 0) {
tmpVal = *(m_listFile[m_selectedLine]);
}
@ -238,14 +238,14 @@ class FileChooserFileList : public ewol::List
uint32_t GetNuberOfColomn(void) {
return 1;
};
bool GetTitle(int32_t colomn, etk::String &myTitle, color_ts &fg, color_ts &bg) {
bool GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg) {
myTitle = "title";
return true;
};
uint32_t GetNuberOfRaw(void) {
return m_listFile.Size();
};
bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) {
bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg) {
if (raw >= 0 && raw < m_listFile.Size()) {
myTextToWrite = *(m_listFile[raw]);
} else {
@ -445,7 +445,7 @@ ewol::FileChooser::~FileChooser(void)
}
void ewol::FileChooser::SetTitle(etk::String label)
void ewol::FileChooser::SetTitle(etk::UString label)
{
ewol::Label * tmpWidget = (ewol::Label*)ewol::widgetManager::Get(m_widgetTitleId);
if (NULL == tmpWidget) {
@ -454,7 +454,7 @@ void ewol::FileChooser::SetTitle(etk::String label)
tmpWidget->SetLabel(label);
}
void ewol::FileChooser::SetValidateLabel(etk::String label)
void ewol::FileChooser::SetValidateLabel(etk::UString label)
{
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::Get(m_widgetValidateId);
if (NULL == tmpWidget) {
@ -463,7 +463,7 @@ void ewol::FileChooser::SetValidateLabel(etk::String label)
tmpWidget->SetLabel(label);
}
void ewol::FileChooser::SetCancelLabel(etk::String label)
void ewol::FileChooser::SetCancelLabel(etk::UString label)
{
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::Get(m_widgetCancelId);
if (NULL == tmpWidget) {
@ -472,13 +472,13 @@ void ewol::FileChooser::SetCancelLabel(etk::String label)
tmpWidget->SetLabel(label);
}
void ewol::FileChooser::SetFolder(etk::String folder)
void ewol::FileChooser::SetFolder(etk::UString folder)
{
m_folder = folder;
UpdateCurrentFolder();
}
void ewol::FileChooser::SetFileName(etk::String filename)
void ewol::FileChooser::SetFileName(etk::UString filename)
{
m_file = filename;
ewol::Entry * tmpWidget = (ewol::Entry*)ewol::widgetManager::Get(m_widgetCurrentFileNameId);
@ -513,12 +513,12 @@ bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * gener
} else if (ewolEventFileChooserSelectFolder == generateEventId) {
//==> this is an internal event ...
FileChooserFolderList * myListFolder = (FileChooserFolderList *)ewol::widgetManager::Get(m_widgetListFolderId);
etk::String tmpString = myListFolder->GetSelectedLine();
etk::UString tmpString = myListFolder->GetSelectedLine();
m_folder = m_folder + tmpString;
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
char * ok;
ok = realpath(m_folder.c_str(), buf);
ok = realpath(m_folder.Utf8Data(), buf);
if (!ok) {
EWOL_ERROR("Error to get the real path");
m_folder = "/";
@ -535,7 +535,7 @@ bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * gener
} else if (ewolEventFileChooserSelectFile == generateEventId) {
m_hasSelectedFile = true;
FileChooserFileList * myListFile = (FileChooserFileList *)ewol::widgetManager::Get(m_widgetListFileId);
etk::String file = myListFile->GetSelectedLine();
etk::UString file = myListFile->GetSelectedLine();
SetFileName(file);
} else if (ewolEventFileChooserValidateFile == generateEventId) {
// select the File ==> generate a validate
@ -566,23 +566,23 @@ void ewol::FileChooser::UpdateCurrentFolder(void)
myEntry->SetValue(m_folder);
myListFolder->AddElement(etk::String("."));
myListFolder->AddElement(etk::String(".."));
myListFolder->AddElement(etk::UString("."));
myListFolder->AddElement(etk::UString(".."));
DIR *dir;
struct dirent *ent;
dir = opendir(m_folder.c_str());
dir = opendir(m_folder.Utf8Data());
if (dir != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir(dir)) != NULL) {
etk::String tmpString(ent->d_name);
etk::UString tmpString(ent->d_name);
if (DT_REG == ent->d_type) {
if (tmpString.c_str()[0] != '.' || true==ShowHidenFile)
if (false == tmpString.StartWith(".") || true==ShowHidenFile)
{
myListFile->AddElement(tmpString);
}
} else if (DT_DIR == ent->d_type) {
if (tmpString != "." && tmpString != "..") {
if (tmpString.c_str()[0] != '.' || true==ShowHidenFile)
if (false == tmpString.StartWith(".") || true==ShowHidenFile)
{
myListFolder->AddElement(tmpString);
}
@ -597,10 +597,10 @@ void ewol::FileChooser::UpdateCurrentFolder(void)
}
etk::String ewol::FileChooser::GetCompleateFileName(void)
etk::UString ewol::FileChooser::GetCompleateFileName(void)
{
etk::String tmpString = m_folder;
etk::UString tmpString = m_folder;
tmpString += "/";
tmpString += m_file;
return tmpString;

View File

@ -39,12 +39,12 @@ namespace ewol {
FileChooser(void);
~FileChooser(void);
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y);
void SetTitle(etk::String label);
void SetValidateLabel(etk::String label);
void SetCancelLabel(etk::String label);
void SetFolder(etk::String folder);
void SetFileName(etk::String filename);
etk::String GetCompleateFileName(void);
void SetTitle(etk::UString label);
void SetValidateLabel(etk::UString label);
void SetCancelLabel(etk::UString label);
void SetFolder(etk::UString folder);
void SetFileName(etk::UString filename);
etk::UString GetCompleateFileName(void);
void UpdateCurrentFolder(void);
private:
int32_t m_widgetTitleId;
@ -56,8 +56,8 @@ namespace ewol {
int32_t m_widgetListFileId;
int32_t m_widgetCheckBoxId;
bool m_hasSelectedFile;
etk::String m_folder;
etk::String m_file;
etk::UString m_folder;
etk::UString m_file;
};
};

View File

@ -31,9 +31,7 @@
#include <ewol/widget/Spacer.h>
#include <ewol/widget/Label.h>
#include <ewol/WidgetManager.h>
//#include <etk/Vector.h>
#include <etk/VectorType.h>
#include <etk/unicode.h>
#include <ewol/ewol.h>
#include <ewol/base/gui.h>
@ -182,7 +180,7 @@ bool ewol::Keyboard::OnEventAreaExternal(int32_t widgetID, const char * generate
if (ewolEventKeyEvent == generateEventId) {
ewol::Button * bt = (ewol::Button *)ewol::widgetManager::Get(widgetID);
EWOL_DEBUG("kbevent : \"" << bt->GetLabel() << "\"");
etk::String data = bt->GetLabel();
etk::UString data = bt->GetLabel();
if (data == "DEL") {
char tmppp[2] = {0x08, 0x00};
data = tmppp;
@ -193,10 +191,8 @@ bool ewol::Keyboard::OnEventAreaExternal(int32_t widgetID, const char * generate
if (data == "TAB") {
data = "\t";
}
uniChar_t unicodeValue;
unicode::convertUtf8ToUnicode(data.c_str(), unicodeValue);
guiAbstraction::SendKeyboardEvent(true, unicodeValue);
guiAbstraction::SendKeyboardEvent(false, unicodeValue);
guiAbstraction::SendKeyboardEvent(true, data[0]);
guiAbstraction::SendKeyboardEvent(false, data[0]);
return true;
} else if (ewolEventKeyboardHide == generateEventId) {
Hide();

View File

@ -128,7 +128,7 @@ ewol::StdPopUp::~StdPopUp(void)
}
void ewol::StdPopUp::SetTitle(etk::String label)
void ewol::StdPopUp::SetTitle(etk::UString label)
{
ewol::Label * tmpWidget = (ewol::Label*)ewol::widgetManager::Get(m_widgetTitleId);
if (NULL == tmpWidget) {
@ -137,7 +137,7 @@ void ewol::StdPopUp::SetTitle(etk::String label)
tmpWidget->SetLabel(label);
}
void ewol::StdPopUp::SetValidateLabel(etk::String label)
void ewol::StdPopUp::SetValidateLabel(etk::UString label)
{
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::Get(m_widgetValidateId);
if (NULL == tmpWidget) {
@ -146,7 +146,7 @@ void ewol::StdPopUp::SetValidateLabel(etk::String label)
tmpWidget->SetLabel(label);
}
void ewol::StdPopUp::SetCancelLabel(etk::String label)
void ewol::StdPopUp::SetCancelLabel(etk::UString label)
{
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::Get(m_widgetCancelId);
if (NULL == tmpWidget) {
@ -155,7 +155,7 @@ void ewol::StdPopUp::SetCancelLabel(etk::String label)
tmpWidget->SetLabel(label);
}
void ewol::StdPopUp::SetFolder(etk::String folder)
void ewol::StdPopUp::SetFolder(etk::UString folder)
{
m_folder = folder;
}

View File

@ -43,10 +43,10 @@ namespace ewol {
StdPopUp(void);
~StdPopUp(void);
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
void SetTitle(etk::String label);
void SetValidateLabel(etk::String label);
void SetCancelLabel(etk::String label);
void SetFolder(etk::String folder);
void SetTitle(etk::UString label);
void SetValidateLabel(etk::UString label);
void SetCancelLabel(etk::UString label);
void SetFolder(etk::UString folder);
private:
int32_t m_widgetTitleId;
int32_t m_widgetValidateId;
@ -54,7 +54,7 @@ namespace ewol {
int32_t m_widgetCurrentFolderId;
int32_t m_widgetListFolderId;
int32_t m_widgetListFileId;
etk::String m_folder;
etk::UString m_folder;
};
};