End of the first dev of the Entry
This commit is contained in:
parent
663a6dfe46
commit
583688c3b7
@ -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_OUT ( 300) /* ) */
|
||||
#define REGEXP_OPCODE_BRACKET_IN (-301) /* [ */
|
||||
|
@ -157,7 +157,7 @@ namespace ewol {
|
||||
coord GetOrigin(void) { return m_origin; };
|
||||
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 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 GetSize(void) { return m_size; };
|
||||
void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; };
|
||||
|
@ -39,10 +39,6 @@ namespace ewol {
|
||||
virtual ~CheckBox(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
void SetLabel(etk::String newLabel);
|
||||
// TODO :
|
||||
//void SetSize(int32_t size);
|
||||
//void SetFont(etk::String fontName);
|
||||
//void ResetDefaultParameters(void);
|
||||
void SetValue(bool val);
|
||||
bool GetValue(void);
|
||||
private:
|
||||
|
@ -39,6 +39,12 @@ const char * const ewolEventEntryEnter = "ewol Entry Enter";
|
||||
|
||||
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.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
@ -53,14 +59,17 @@ void ewol::Entry::Init(void)
|
||||
|
||||
ewol::Entry::Entry(void)
|
||||
{
|
||||
m_data = "";
|
||||
Init();
|
||||
m_data = "";
|
||||
UpdateTextPosition();
|
||||
}
|
||||
|
||||
ewol::Entry::Entry(etk::String newData)
|
||||
{
|
||||
m_data = newData;
|
||||
Init();
|
||||
m_data = newData;
|
||||
m_displayCursorPos = m_data.Size();
|
||||
UpdateTextPosition();
|
||||
}
|
||||
|
||||
|
||||
@ -72,10 +81,10 @@ ewol::Entry::~Entry(void)
|
||||
bool ewol::Entry::CalculateMinSize(void)
|
||||
{
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
int32_t minWidth = ewol::GetWidth(fontId, m_data.c_str());
|
||||
int32_t minHeight = ewol::GetHeight(fontId);
|
||||
m_minSize.x = 16+minWidth;
|
||||
m_minSize.y = 16+minHeight;
|
||||
m_minSize.x = m_userSize;
|
||||
m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize);
|
||||
UpdateTextPosition();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -97,35 +106,43 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
||||
ClearOObjectList();
|
||||
|
||||
// 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 tmpOriginX = 0;
|
||||
int32_t tmpOriginY = (m_size.y - tmpSizeY) / 2;
|
||||
// no change for the text orogin :
|
||||
int32_t tmpTextOriginX = borderSize + 2*paddingSize;
|
||||
int32_t tmpTextOriginY = (m_size.y - tmpSizeY) / 2 + borderSize + 2*paddingSize;
|
||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||
int32_t tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
|
||||
|
||||
// m_userFillX ==> in every case start at the left ...
|
||||
if (true==m_userFillY) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
if (true==m_userFillX) {
|
||||
tmpSizeX = m_size.x;
|
||||
}
|
||||
tmpOriginX += paddingSize;
|
||||
tmpOriginY += paddingSize;
|
||||
tmpSizeX -= 2*paddingSize;
|
||||
tmpSizeY -= 2*paddingSize;
|
||||
if (true==m_userFillY) {
|
||||
//tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
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);
|
||||
tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_data.c_str());
|
||||
tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_data.c_str() + m_displayStartPosition);
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
||||
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");
|
||||
|
||||
@ -178,6 +195,7 @@ bool ewol::Entry::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SI
|
||||
} else if(UTF8_data[0] >= 20) {
|
||||
m_data += UTF8_data;
|
||||
}
|
||||
UpdateTextPosition();
|
||||
OnRegenerateDisplay();
|
||||
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();
|
||||
}
|
||||
|
@ -40,16 +40,30 @@ namespace ewol {
|
||||
virtual bool CalculateMinSize(void);
|
||||
void SetValue(etk::String newData);
|
||||
etk::String GetValue(void);
|
||||
void SetWidth(int32_t width)
|
||||
{
|
||||
m_userSize = width;
|
||||
}
|
||||
private:
|
||||
etk::String m_data;
|
||||
color_ts m_textColorFg; //!< Text 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:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
//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 OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
|
||||
protected:
|
||||
virtual void OnGetFocus(void);
|
||||
virtual void OnLostFocus(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ void ewol::Label::Init(void)
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
SetCanHaveFocus(true);
|
||||
SetCanHaveFocus(false);
|
||||
}
|
||||
|
||||
ewol::Label::Label(void)
|
||||
|
@ -111,6 +111,7 @@ bool ewol::SizerVert::CalculateMinSize(void)
|
||||
m_userExpendY = true;
|
||||
}
|
||||
coord tmpSize = m_subWidget[iii]->GetMinSize();
|
||||
//EWOL_DEBUG(" Get minSize[" << iii << "] ("<< tmpSize.x << "," << tmpSize.y << ")");
|
||||
m_minSize.y += tmpSize.y;
|
||||
if (tmpSize.x>m_minSize.x) {
|
||||
m_minSize.x = tmpSize.x;
|
||||
|
Loading…
x
Reference in New Issue
Block a user