End of the first dev of the Entry

This commit is contained in:
Edouard Dupin 2011-12-23 18:02:33 +01:00
parent 663a6dfe46
commit 583688c3b7
7 changed files with 89 additions and 27 deletions

View File

@ -60,7 +60,7 @@ multiplicity :
*/ */
// internal define to permit to have all neeed system // internal define to permit to have all needed system
#define REGEXP_OPCODE_PTHESE_IN (-300) /* ( */ #define REGEXP_OPCODE_PTHESE_IN (-300) /* ( */
#define REGEXP_OPCODE_PTHESE_OUT ( 300) /* ) */ #define REGEXP_OPCODE_PTHESE_OUT ( 300) /* ) */
#define REGEXP_OPCODE_BRACKET_IN (-301) /* [ */ #define REGEXP_OPCODE_BRACKET_IN (-301) /* [ */

View File

@ -157,7 +157,7 @@ namespace ewol {
coord GetOrigin(void) { return m_origin; }; coord GetOrigin(void) { return m_origin; };
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ...
virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; return true; }; //update the min Size ... and the expend parameters for the sizer virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; return true; }; //update the min Size ... and the expend parameters for the sizer
virtual void SetMinSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; }; virtual void SetMinSize(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; };
coord GetMinSize(void) { return m_minSize; }; coord GetMinSize(void) { return m_minSize; };
coord GetSize(void) { return m_size; }; coord GetSize(void) { return m_size; };
void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; }; void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; };

View File

@ -39,10 +39,6 @@ namespace ewol {
virtual ~CheckBox(void); virtual ~CheckBox(void);
virtual bool CalculateMinSize(void); virtual bool CalculateMinSize(void);
void SetLabel(etk::String newLabel); void SetLabel(etk::String newLabel);
// TODO :
//void SetSize(int32_t size);
//void SetFont(etk::String fontName);
//void ResetDefaultParameters(void);
void SetValue(bool val); void SetValue(bool val);
bool GetValue(void); bool GetValue(void);
private: private:

View File

@ -39,6 +39,12 @@ const char * const ewolEventEntryEnter = "ewol Entry Enter";
void ewol::Entry::Init(void) void ewol::Entry::Init(void)
{ {
m_displayStartPosition = 0;
m_displayCursorPos = 0;
m_userSize = 50;
m_borderSize = 2;
m_paddingSize = 3;
m_displayCursor = false;
m_textColorFg.red = 0.0; m_textColorFg.red = 0.0;
m_textColorFg.green = 0.0; m_textColorFg.green = 0.0;
m_textColorFg.blue = 0.0; m_textColorFg.blue = 0.0;
@ -53,14 +59,17 @@ void ewol::Entry::Init(void)
ewol::Entry::Entry(void) ewol::Entry::Entry(void)
{ {
m_data = "";
Init(); Init();
m_data = "";
UpdateTextPosition();
} }
ewol::Entry::Entry(etk::String newData) ewol::Entry::Entry(etk::String newData)
{ {
m_data = newData;
Init(); Init();
m_data = newData;
m_displayCursorPos = m_data.Size();
UpdateTextPosition();
} }
@ -72,10 +81,10 @@ ewol::Entry::~Entry(void)
bool ewol::Entry::CalculateMinSize(void) bool ewol::Entry::CalculateMinSize(void)
{ {
int32_t fontId = GetDefaultFontId(); int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_data.c_str());
int32_t minHeight = ewol::GetHeight(fontId); int32_t minHeight = ewol::GetHeight(fontId);
m_minSize.x = 16+minWidth; m_minSize.x = m_userSize;
m_minSize.y = 16+minHeight; m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize);
UpdateTextPosition();
return true; return true;
} }
@ -97,35 +106,43 @@ void ewol::Entry::OnRegenerateDisplay(void)
ClearOObjectList(); ClearOObjectList();
// TODO later : Add this in the basic element of the widget ... // TODO later : Add this in the basic element of the widget ...
int32_t borderSize = 2;
int32_t paddingSize = 3;
int32_t tmpSizeX = m_size.x; int32_t tmpSizeX = m_minSize.x;
int32_t tmpSizeY = m_minSize.y; int32_t tmpSizeY = m_minSize.y;
int32_t tmpOriginX = 0; int32_t tmpOriginX = 0;
int32_t tmpOriginY = (m_size.y - tmpSizeY) / 2; int32_t tmpOriginY = (m_size.y - tmpSizeY) / 2;
// no change for the text orogin : // no change for the text orogin :
int32_t tmpTextOriginX = borderSize + 2*paddingSize; int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
int32_t tmpTextOriginY = (m_size.y - tmpSizeY) / 2 + borderSize + 2*paddingSize; int32_t tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
// m_userFillX ==> in every case start at the left ... if (true==m_userFillX) {
if (true==m_userFillY) { tmpSizeX = m_size.x;
tmpSizeY = m_size.y;
tmpOriginY = 0;
} }
tmpOriginX += paddingSize; if (true==m_userFillY) {
tmpOriginY += paddingSize; //tmpSizeY = m_size.y;
tmpSizeX -= 2*paddingSize; tmpOriginY = 0;
tmpSizeY -= 2*paddingSize; tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
}
tmpOriginX += m_paddingSize;
tmpOriginY += m_paddingSize;
tmpSizeX -= 2*m_paddingSize;
tmpSizeY -= 2*m_paddingSize;
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg); ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_data.c_str()); tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_data.c_str() + m_displayStartPosition);
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored; ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
tmpOObjects->SetColor(m_textColorBg); tmpOObjects->SetColor(m_textColorBg);
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY); tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
tmpOObjects->SetColor(m_textColorFg); tmpOObjects->SetColor(m_textColorFg);
tmpOObjects->RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, borderSize); tmpOObjects->RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, m_borderSize);
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 XCursorPos = fontWidth + m_borderSize + 2*m_paddingSize;
tmpOObjects->Line(XCursorPos, tmpTextOriginY, XCursorPos, tmpTextOriginY + fontHeight, 1);
}
AddOObject(tmpOObjects, "BouttonDecoration"); AddOObject(tmpOObjects, "BouttonDecoration");
@ -178,6 +195,7 @@ bool ewol::Entry::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SI
} else if(UTF8_data[0] >= 20) { } else if(UTF8_data[0] >= 20) {
m_data += UTF8_data; m_data += UTF8_data;
} }
UpdateTextPosition();
OnRegenerateDisplay(); OnRegenerateDisplay();
return true; return true;
} }
@ -185,3 +203,36 @@ bool ewol::Entry::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SI
} }
void ewol::Entry::UpdateTextPosition(void)
{
int32_t iii=m_data.Size();
int32_t fontId = GetDefaultFontId();
int32_t tmpSizeX = m_minSize.x;
if (true==m_userFillX) {
tmpSizeX = m_size.x;
}
int32_t tmpUserSize = tmpSizeX - 2*(m_borderSize + 2*m_paddingSize);
while (iii > 0) {
if (ewol::GetWidth(fontId, m_data.c_str()+(iii-1)) > tmpUserSize) {
break;
}
iii--;
}
iii++;
m_displayStartPosition = iii-1;
m_displayCursorPos = m_data.Size();
}
void ewol::Entry::OnGetFocus(void)
{
m_displayCursor = true;
OnRegenerateDisplay();
}
void ewol::Entry::OnLostFocus(void)
{
m_displayCursor = false;
OnRegenerateDisplay();
}

View File

@ -40,16 +40,30 @@ namespace ewol {
virtual bool CalculateMinSize(void); virtual bool CalculateMinSize(void);
void SetValue(etk::String newData); void SetValue(etk::String newData);
etk::String GetValue(void); etk::String GetValue(void);
void SetWidth(int32_t width)
{
m_userSize = width;
}
private: private:
etk::String m_data; etk::String m_data;
color_ts m_textColorFg; //!< Text color color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color color_ts m_textColorBg; //!< Background color
int32_t m_userSize;
int32_t m_displayStartPosition;
int32_t m_displayCursorPos;
int32_t m_borderSize;
int32_t m_paddingSize;
void UpdateTextPosition(void);
bool m_displayCursor;
public: public:
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
public: public:
//virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y); //virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y); virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]); virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
protected:
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
}; };
}; };

View File

@ -42,7 +42,7 @@ void ewol::Label::Init(void)
m_textColorFg.green = 0.0; m_textColorFg.green = 0.0;
m_textColorFg.blue = 0.0; m_textColorFg.blue = 0.0;
m_textColorFg.alpha = 1.0; m_textColorFg.alpha = 1.0;
SetCanHaveFocus(true); SetCanHaveFocus(false);
} }
ewol::Label::Label(void) ewol::Label::Label(void)

View File

@ -111,6 +111,7 @@ bool ewol::SizerVert::CalculateMinSize(void)
m_userExpendY = true; m_userExpendY = true;
} }
coord tmpSize = m_subWidget[iii]->GetMinSize(); coord tmpSize = m_subWidget[iii]->GetMinSize();
//EWOL_DEBUG(" Get minSize[" << iii << "] ("<< tmpSize.x << "," << tmpSize.y << ")");
m_minSize.y += tmpSize.y; m_minSize.y += tmpSize.y;
if (tmpSize.x>m_minSize.x) { if (tmpSize.x>m_minSize.x) {
m_minSize.x = tmpSize.x; m_minSize.x = tmpSize.x;