commit du lundi matin ...
This commit is contained in:
parent
4a4c8fcbac
commit
202fa2ed5e
@ -26,6 +26,7 @@
|
||||
#include <ewol.h>
|
||||
#include <ewolFont.h>
|
||||
#include <widget/ewolButton.h>
|
||||
#include <widget/ewolCheckBox.h>
|
||||
#include <widget/ewolSizerHori.h>
|
||||
#include <widget/ewolSizerVert.h>
|
||||
#include <widget/ewolTest.h>
|
||||
@ -60,6 +61,15 @@ class Plop :public ewol::Windows
|
||||
ewol::Test * myTest = new ewol::Test();
|
||||
mySizerVert->SubWidgetAdd(myTest);
|
||||
|
||||
ewol::CheckBox * myCheckBox = new ewol::CheckBox("mon label d'exemple de test");
|
||||
mySizerVert->SubWidgetAdd(myCheckBox);
|
||||
myCheckBox = new ewol::CheckBox("Exemple 2");
|
||||
mySizerVert->SubWidgetAdd(myCheckBox);
|
||||
myCheckBox = new ewol::CheckBox("Exemple 3 et plus si afinité");
|
||||
mySizerVert->SubWidgetAdd(myCheckBox);
|
||||
|
||||
myTest = new ewol::Test();
|
||||
mySizerVert->SubWidgetAdd(myTest);
|
||||
myButton = new ewol::Button("4 4 BT");
|
||||
//myButton->SetExpendY(true);
|
||||
mySizerVert->SubWidgetAdd(myButton);
|
||||
|
@ -449,6 +449,13 @@ void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w,
|
||||
SetPoint(x , y + h);
|
||||
}
|
||||
|
||||
void ewol::OObject2DColored::RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness)
|
||||
{
|
||||
Line(x, y, x+w, y, thickness);
|
||||
Line(x+w, y, x+w, y+h, thickness);
|
||||
Line(x+w, y+h, x, y+h, thickness);
|
||||
Line(x, y+h, x, y, thickness);
|
||||
}
|
||||
|
||||
void ewol::OObject2DColored::Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ namespace ewol {
|
||||
void Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey, etkFloat_t thickness);
|
||||
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h);
|
||||
//void RectangleAngle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t angle);
|
||||
//void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness);
|
||||
void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness);
|
||||
//void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness, etkFloat_t angle);
|
||||
void Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness);
|
||||
void CirclePart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness, etkFloat_t angleStart, etkFloat_t angleStop);
|
||||
|
@ -44,6 +44,7 @@ ewol::Widget::Widget(void)
|
||||
SetFillY();
|
||||
m_genericDraw = true;
|
||||
m_specificDraw = false;
|
||||
|
||||
}
|
||||
|
||||
ewol::Widget::~Widget(void)
|
||||
|
@ -112,6 +112,7 @@ void ewol::Button::OnRegenerateDisplay(void)
|
||||
AddOObject(tmpOObjects, "BouttonDecoration");
|
||||
|
||||
*/
|
||||
int32_t borderWidth = 2;
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
||||
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
@ -126,18 +127,18 @@ void ewol::Button::OnRegenerateDisplay(void)
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->Rectangle( ((m_size.x-fontWidth-10)/2)+radius, posy, fontWidth-radius, radius*2);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
EWOL_DEBUG("m_textColorFg=(" << m_textColorFg.red << " " << m_textColorFg.green << " " << m_textColorFg.blue << " " << m_textColorFg.alpha << ")" );
|
||||
tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy, ((m_size.x-fontWidth-10)/2)+fontWidth, posy, 1);
|
||||
tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy+fontHeight, ((m_size.x-fontWidth-10)/2)+fontWidth, posy+fontHeight, 1);
|
||||
//EWOL_DEBUG("m_textColorFg=(" << m_textColorFg.red << " " << m_textColorFg.green << " " << m_textColorFg.blue << " " << m_textColorFg.alpha << ")" );
|
||||
tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy, ((m_size.x-fontWidth-10)/2)+fontWidth, posy, borderWidth);
|
||||
tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy+fontHeight, ((m_size.x-fontWidth-10)/2)+fontWidth, posy+fontHeight, borderWidth);
|
||||
posy += fontHeight/2;
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->DiscPart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, 180, 360);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, 1, 180, 360);
|
||||
tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, borderWidth, 180, 360);
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->DiscPart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, 0, 180);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, 1, 0, 180);
|
||||
tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, borderWidth, 0, 180);
|
||||
|
||||
AddOObject(tmpOObjects, "BouttonDecoration");
|
||||
AddOObject(tmpText, "BouttonText");
|
||||
|
@ -25,5 +25,140 @@
|
||||
|
||||
#include <widget/ewolCheckBox.h>
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
const char * ewolEventCheckBoxClicked = "ewol CheckBox Clicked";
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::CheckBox"
|
||||
|
||||
|
||||
void ewol::CheckBox::Init(void)
|
||||
{
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
|
||||
m_textColorBg.red = 1.0;
|
||||
m_textColorBg.green = 1.0;
|
||||
m_textColorBg.blue = 1.0;
|
||||
m_textColorBg.alpha = 1.0;
|
||||
m_value = false;
|
||||
}
|
||||
|
||||
ewol::CheckBox::CheckBox(void)
|
||||
{
|
||||
m_label = "No Label";
|
||||
Init();
|
||||
}
|
||||
|
||||
ewol::CheckBox::CheckBox(etk::String newLabel)
|
||||
{
|
||||
m_label = newLabel;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
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 minHeight = ewol::GetHeight(fontId);
|
||||
m_minSize.x = 25+minWidth;
|
||||
m_minSize.y = etk_max(25, minHeight);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ewol::CheckBox::SetLabel(etk::String newLabel)
|
||||
{
|
||||
m_label = newLabel;
|
||||
}
|
||||
|
||||
void ewol::CheckBox::SetValue(bool val)
|
||||
{
|
||||
if (m_value == val) {
|
||||
return;
|
||||
}
|
||||
m_value = val;
|
||||
OnRegenerateDisplay();
|
||||
}
|
||||
|
||||
bool ewol::CheckBox::GetValue(void)
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
void ewol::CheckBox::OnRegenerateDisplay(void)
|
||||
{
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
|
||||
int32_t borderWidth = 2;
|
||||
|
||||
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
||||
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(25, posy+3, m_label.c_str());
|
||||
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->Rectangle( 2.5, 2.5, 20, 20);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
tmpOObjects->RectangleBorder( 2.5, 2.5, 20, 20, borderWidth);
|
||||
if (m_value) {
|
||||
tmpOObjects->Line( 2.5, 2.5, 22.5, 22.5, borderWidth);
|
||||
tmpOObjects->Line( 2.5, 22.5, 22.5, 2.5, borderWidth);
|
||||
}
|
||||
|
||||
AddOObject(tmpOObjects, "Decoration");
|
||||
AddOObject(tmpText, "Text");
|
||||
|
||||
// Regenerate the event Area:
|
||||
EventAreaRemoveAll();
|
||||
coord origin;
|
||||
coord size;
|
||||
origin.x = 3.0;
|
||||
origin.y = 3.0;
|
||||
size.x = m_size.x-6;
|
||||
size.y = m_size.y-6;
|
||||
AddEventArea(origin, size, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventCheckBoxClicked);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
EWOL_DEBUG("Event on BT ...");
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool ewol::CheckBox::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
bool eventIsOK = false;
|
||||
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
|
||||
if(ewolEventCheckBoxClicked == generateEventId) {
|
||||
EWOL_INFO("CB pressed ... " << m_label);
|
||||
if(true == m_value) {
|
||||
m_value = false;
|
||||
} else {
|
||||
m_value = true;
|
||||
}
|
||||
OnRegenerateDisplay();
|
||||
eventIsOK = true;
|
||||
}
|
||||
return eventIsOK;
|
||||
}
|
||||
|
@ -33,8 +33,28 @@ namespace ewol {
|
||||
class CheckBox :public ewol::Widget
|
||||
{
|
||||
public:
|
||||
CheckBox(void) { };
|
||||
virtual ~CheckBox(void) { };
|
||||
CheckBox(void);
|
||||
CheckBox(etk::String newLabel);
|
||||
void Init(void);
|
||||
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:
|
||||
etk::String m_label;
|
||||
bool m_value;
|
||||
color_ts m_textColorFg; //!< Text color
|
||||
color_ts m_textColorBg; //!< Background color
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user