First step to generate the keyboard event directly on the correct widget

This commit is contained in:
Edouard Dupin 2011-11-22 17:56:04 +01:00
parent e438b70f0e
commit 6e92491a9f
6 changed files with 56 additions and 8 deletions

View File

@ -25,6 +25,7 @@
#include <ewolDebug.h> #include <ewolDebug.h>
#include <etkString.h> #include <etkString.h>
#include <ewolWidgetManager.h>
#include <guiX11.h> #include <guiX11.h>
#include <stdlib.h> #include <stdlib.h>
@ -642,17 +643,25 @@ namespace guiAbstraction {
break; break;
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease:
EWOL_DEBUG("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" "); //EWOL_DEBUG("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
{ {
char buf[11]; char buf[11];
KeySym keysym; KeySym keysym;
XComposeStatus status; XComposeStatus status;
int count = XLookupString(&event.xkey, buf, 10, &keysym, &status); int count = XLookupString(&event.xkey, buf, 10, &keysym, &status);
buf[count] = '\0'; buf[count] = '\0';
if(event.type == KeyPress) { // Get the current Focused Widget :
// TODO : set the char here... ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
} else { if (NULL != tmpWidget) {
// TODO : set the char here... if(event.type == KeyPress) {
// TODO : set the char here...
EWOL_DEBUG("X11 PRESSED : \"" << buf << "\" size=" << count);
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, buf);
} else {
// TODO : set the char here...
EWOL_DEBUG("X11 Release : \"" << buf << "\" size=" << count);
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, buf);
}
} }
break; break;
} }

View File

@ -84,6 +84,7 @@ void generatePolyGone(etk::VectorType<coord2D_ts> & input, etk::VectorType<coord
return; return;
} }
coord2D_ts basePoint = input[0]; coord2D_ts basePoint = input[0];
// TODO : Regenerate a linear poligone generation
for (int32_t iii=1; iii<input.Size()-1; iii++) { for (int32_t iii=1; iii<input.Size()-1; iii++) {
output.PushBack(basePoint); output.PushBack(basePoint);
output.PushBack(input[iii]); output.PushBack(input[iii]);
@ -451,6 +452,7 @@ void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w,
void ewol::OObject2DColored::RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness) void ewol::OObject2DColored::RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness)
{ {
// TODO : This did not manage the thickness of the line ...
Line(x, y, x+w, y, thickness); Line(x, y, x+w, y, thickness);
Line(x+w, y, x+w, y+h, thickness); Line(x+w, y, x+w, y+h, thickness);
Line(x+w, y+h, x, y+h, thickness); Line(x+w, y+h, x, y+h, thickness);
@ -552,6 +554,7 @@ void ewol::OObject2DColored::Disc(etkFloat_t x, etkFloat_t y, etkFloat_t radius)
nbOcurence = 15; nbOcurence = 15;
} }
// TODO : Generate a poligone instead if this ...
for (int32_t iii=0; iii<nbOcurence; iii++) { for (int32_t iii=0; iii<nbOcurence; iii++) {
SetPoint(x, y); SetPoint(x, y);
@ -588,7 +591,7 @@ void ewol::OObject2DColored::DiscPart(etkFloat_t x, etkFloat_t y, etkFloat_t rad
nbOcurence = 15; nbOcurence = 15;
} }
// TODO : Generate a poligone instead if this ...
for (int32_t iii=0; iii<nbOcurence; iii++) { for (int32_t iii=0; iii<nbOcurence; iii++) {
SetPoint(x, y); SetPoint(x, y);

View File

@ -25,7 +25,7 @@
#include <widget/ewolButton.h> #include <widget/ewolButton.h>
#include <ewolOObject.h> #include <ewolOObject.h>
#include <ewolWidgetManager.h>
const char * const ewolEventButtonPressed = "ewol Button Pressed"; const char * const ewolEventButtonPressed = "ewol Button Pressed";
@ -49,6 +49,7 @@ void ewol::Button::Init(void)
m_textColorBg.green = 0.0; m_textColorBg.green = 0.0;
m_textColorBg.blue = 0.0; m_textColorBg.blue = 0.0;
m_textColorBg.alpha = 0.25; m_textColorBg.alpha = 0.25;
SetCanHaveFocus(true);
} }
ewol::Button::Button(void) ewol::Button::Button(void)
@ -172,8 +173,23 @@ bool ewol::Button::OnEventArea(const char * generateEventId, etkFloat_t x, etkFl
if(ewolEventButtonPressed == generateEventId) { if(ewolEventButtonPressed == generateEventId) {
EWOL_INFO("BT pressed ... " << m_label); EWOL_INFO("BT pressed ... " << m_label);
eventIsOK = true; eventIsOK = true;
ewol::widgetManager::FocusKeep(this);
} else if(ewolEventButtonEnter == generateEventId) { } else if(ewolEventButtonEnter == generateEventId) {
OnRegenerateDisplay(); OnRegenerateDisplay();
} }
return eventIsOK; return eventIsOK;
} }
bool ewol::Button::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE])
{
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( UTF8_data != NULL
&& typeEvent == ewol::EVENT_KB_TYPE_DOWN
&& UTF8_data[0] == '\r') {
return OnEventArea(ewolEventButtonPressed, -1, -1);
}
return false;
}

View File

@ -54,6 +54,7 @@ namespace ewol {
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]);
}; };
}; };

View File

@ -26,6 +26,8 @@
#include <widget/ewolCheckBox.h> #include <widget/ewolCheckBox.h>
#include <ewolOObject.h> #include <ewolOObject.h>
#include <ewolWidgetManager.h>
const char * ewolEventCheckBoxClicked = "ewol CheckBox Clicked"; const char * ewolEventCheckBoxClicked = "ewol CheckBox Clicked";
@ -45,6 +47,7 @@ void ewol::CheckBox::Init(void)
m_textColorBg.blue = 1.0; m_textColorBg.blue = 1.0;
m_textColorBg.alpha = 1.0; m_textColorBg.alpha = 1.0;
m_value = false; m_value = false;
SetCanHaveFocus(true);
} }
ewol::CheckBox::CheckBox(void) ewol::CheckBox::CheckBox(void)
@ -109,7 +112,7 @@ void ewol::CheckBox::OnRegenerateDisplay(void)
int32_t fontHeight = ewol::GetHeight(fontId); int32_t fontHeight = ewol::GetHeight(fontId);
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str()); int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t posy = (m_size.y - fontHeight - 6)/2 + 3; int32_t posy = (m_size.y - fontHeight - 6)/2 + 3;
int32_t posx = (m_size.x - fontWidth - 6)/2 + 25; //int32_t posx = (m_size.x - fontWidth - 6)/2 + 25;
tmpText->Text(25, posy+3, m_label.c_str()); tmpText->Text(25, posy+3, m_label.c_str());
@ -151,6 +154,7 @@ bool ewol::CheckBox::OnEventArea(const char * generateEventId, etkFloat_t x, etk
bool eventIsOK = false; bool eventIsOK = false;
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\""); //EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
if(ewolEventCheckBoxClicked == generateEventId) { if(ewolEventCheckBoxClicked == generateEventId) {
ewol::widgetManager::FocusKeep(this);
EWOL_INFO("CB pressed ... " << m_label); EWOL_INFO("CB pressed ... " << m_label);
if(true == m_value) { if(true == m_value) {
m_value = false; m_value = false;
@ -162,3 +166,17 @@ bool ewol::CheckBox::OnEventArea(const char * generateEventId, etkFloat_t x, etk
} }
return eventIsOK; return eventIsOK;
} }
bool ewol::CheckBox::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE])
{
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( UTF8_data != NULL
&& typeEvent == ewol::EVENT_KB_TYPE_DOWN
&& ( UTF8_data[0] == '\r'
|| UTF8_data[0] == ' ')
) {
return OnEventArea(ewolEventCheckBoxClicked, -1, -1);
}
return false;
}

View File

@ -55,6 +55,7 @@ namespace ewol {
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]);
}; };
}; };