[DEV] Better Entry widget & change the short-cut system to permit to have multiple shortcut depending of the widget
This commit is contained in:
parent
809c8a3d5c
commit
95a7ecb29f
@ -64,8 +64,8 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::UString &obj)
|
||||
*/
|
||||
etk::UString::~UString(void)
|
||||
{
|
||||
m_data.Clear();
|
||||
m_dataUtf8.Clear();
|
||||
//m_data.Clear();
|
||||
//m_dataUtf8.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -638,12 +638,15 @@ namespace etk
|
||||
if(newSize <= 0) {
|
||||
newSize = 1;
|
||||
}
|
||||
if (m_allocated<0) {
|
||||
m_allocated = 0;
|
||||
}
|
||||
int32_t requestSize = m_allocated;
|
||||
// set the size with the corect chose type :
|
||||
if (newSize == requestSize) {
|
||||
return;
|
||||
} else if (newSize < requestSize) {
|
||||
// we did not reove data ???
|
||||
// we did not remove data ???
|
||||
} else {
|
||||
while(newSize > requestSize) {
|
||||
if (0 == requestSize) {
|
||||
@ -654,7 +657,7 @@ namespace etk
|
||||
}
|
||||
}
|
||||
// No reallocation needed :
|
||||
if (requestSize == m_allocated) {
|
||||
if (requestSize <= m_allocated) {
|
||||
return;
|
||||
}
|
||||
//TK_INFO("Change vector allocation : " << m_allocated << "==>" << requestSize);
|
||||
@ -664,6 +667,7 @@ namespace etk
|
||||
m_data = new MY_TYPE[requestSize];
|
||||
if (NULL==m_data) {
|
||||
TK_CRITICAL("Vector : Error in data allocation request allocation:" << requestSize << "*" << (int32_t)(sizeof(MY_TYPE)) << "bytes" );
|
||||
m_allocated = 0;
|
||||
return;
|
||||
}
|
||||
// no data to copy
|
||||
@ -672,6 +676,7 @@ namespace etk
|
||||
MY_TYPE* m_dataTmp = new MY_TYPE[requestSize];
|
||||
if (NULL==m_dataTmp) {
|
||||
TK_CRITICAL("Vector : Error in data allocation request allocation:" << requestSize << "*" << (int32_t)(sizeof(MY_TYPE)) << "bytes" );
|
||||
m_allocated = 0;
|
||||
return;
|
||||
}
|
||||
// copy data in the new pool
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
|
||||
/*
|
||||
class EventShortCut {
|
||||
public:
|
||||
const char * generateEventId; // event generate ID (to be unique it was pointer on the string name)
|
||||
@ -39,8 +39,9 @@ class EventShortCut {
|
||||
uniChar_t UnicodeValue; // 0 if not used
|
||||
ewol::eventKbMoveType_te keyboardMoveValue; // 0 if not used
|
||||
};
|
||||
*/
|
||||
|
||||
static etk::Vector<EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event
|
||||
static etk::Vector<ewol::EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event
|
||||
|
||||
namespace ewol {
|
||||
namespace shortCut {
|
||||
@ -58,17 +59,17 @@ void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta,
|
||||
const char * generateEventId,
|
||||
etk::UString data)
|
||||
{
|
||||
EventShortCut * newEvent = new EventShortCut();
|
||||
ewol::EventShortCut * newEvent = new ewol::EventShortCut();
|
||||
if (NULL == newEvent) {
|
||||
EWOL_ERROR("Allocation Error on the shortcut ...");
|
||||
return;
|
||||
}
|
||||
newEvent->generateEventId = generateEventId;
|
||||
newEvent->shift = shift;
|
||||
newEvent->control = control;
|
||||
newEvent->alt = alt;
|
||||
newEvent->meta = meta;
|
||||
newEvent->UnicodeValue = unicodeValue;
|
||||
newEvent->specialKey.shift = shift;
|
||||
newEvent->specialKey.ctrl = control;
|
||||
newEvent->specialKey.alt = alt;
|
||||
newEvent->specialKey.meta = meta;
|
||||
newEvent->unicodeValue = unicodeValue;
|
||||
newEvent->keyboardMoveValue = kbMove;
|
||||
newEvent->eventData = data;
|
||||
l_inputShortCutEvent.PushBack(newEvent);
|
||||
@ -194,21 +195,21 @@ void ewol::shortCut::UnInit(void)
|
||||
|
||||
|
||||
|
||||
bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown)
|
||||
bool ewol::shortCut::Process(ewol::specialKey_ts& special, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown)
|
||||
{
|
||||
if (unicodeValue >= 'A' && unicodeValue <='Z') {
|
||||
unicodeValue += 'a' - 'A';
|
||||
}
|
||||
//EWOL_INFO("Try to find generic shortcut ...");
|
||||
for(int32_t iii=l_inputShortCutEvent.Size()-1; iii>=0; iii--) {
|
||||
if( l_inputShortCutEvent[iii]->shift == shift
|
||||
&& l_inputShortCutEvent[iii]->control == control
|
||||
&& l_inputShortCutEvent[iii]->alt == alt
|
||||
&& l_inputShortCutEvent[iii]->meta == meta
|
||||
if( l_inputShortCutEvent[iii]->specialKey.shift == special.shift
|
||||
&& l_inputShortCutEvent[iii]->specialKey.ctrl == special.ctrl
|
||||
&& l_inputShortCutEvent[iii]->specialKey.alt == special.alt
|
||||
&& l_inputShortCutEvent[iii]->specialKey.meta == special.meta
|
||||
&& ( ( l_inputShortCutEvent[iii]->keyboardMoveValue == ewol::EVENT_KB_MOVE_TYPE_NONE
|
||||
&& l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue)
|
||||
&& l_inputShortCutEvent[iii]->unicodeValue == unicodeValue)
|
||||
|| ( l_inputShortCutEvent[iii]->keyboardMoveValue == kbMove
|
||||
&& l_inputShortCutEvent[iii]->UnicodeValue == 0)
|
||||
&& l_inputShortCutEvent[iii]->unicodeValue == 0)
|
||||
) )
|
||||
{
|
||||
if (isDown) {
|
||||
|
@ -33,7 +33,7 @@ namespace ewol {
|
||||
namespace shortCut {
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown);
|
||||
bool Process(ewol::specialKey_ts& special, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -82,7 +82,8 @@ void ewol::ForceRedrawAll(void)
|
||||
}
|
||||
|
||||
|
||||
eSystem::specialKey_ts specialCurrentKey;
|
||||
ewol::specialKey_ts specialCurrentKey;
|
||||
|
||||
bool ewol::IsSetCapsLock(void)
|
||||
{
|
||||
return specialCurrentKey.capLock;
|
||||
|
@ -351,9 +351,9 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||
|
||||
|
||||
// Clipping and drawing area
|
||||
if( dxB < clipping.x
|
||||
|| dxA > clipping.x + clipping.w)
|
||||
{
|
||||
if( true == hasClipping
|
||||
&& ( dxB < clipping.x
|
||||
|| dxA > clipping.x + clipping.w) ) {
|
||||
// Nothing to diplay ...
|
||||
} else {
|
||||
if (true == hasClipping) {
|
||||
|
@ -104,7 +104,7 @@ typedef struct {
|
||||
static etk::MessageFifo<eSystemMessage_ts> l_msgSystem;
|
||||
|
||||
|
||||
extern eSystem::specialKey_ts specialCurrentKey;
|
||||
extern ewol::specialKey_ts specialCurrentKey;
|
||||
|
||||
static bool requestEndProcessing = false;
|
||||
|
||||
@ -154,22 +154,27 @@ void ewolProcessEvents(void)
|
||||
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
|
||||
{
|
||||
specialCurrentKey = data.keyboardKey.special;
|
||||
if (false==ewol::shortCut::Process(data.keyboardKey.special.shift,
|
||||
data.keyboardKey.special.ctrl,
|
||||
data.keyboardKey.special.alt,
|
||||
data.keyboardKey.special.meta,
|
||||
// check main shortcut
|
||||
if (false==ewol::shortCut::Process(data.keyboardKey.special,
|
||||
data.keyboardKey.myChar,
|
||||
ewol::EVENT_KB_MOVE_TYPE_NONE,
|
||||
data.keyboardKey.isDown)) {
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(true == data.keyboardKey.isDown) {
|
||||
EWOL_VERBOSE("GUI PRESSED : \"" << data.keyboardKey.myChar << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, data.keyboardKey.myChar);
|
||||
} else {
|
||||
EWOL_VERBOSE("GUI Release : \"" << data.keyboardKey.myChar << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, data.keyboardKey.myChar);
|
||||
// check Widget shortcut
|
||||
if (false==tmpWidget->OnEventShortCut(data.keyboardKey.special,
|
||||
data.keyboardKey.myChar,
|
||||
ewol::EVENT_KB_MOVE_TYPE_NONE,
|
||||
data.keyboardKey.isDown)) {
|
||||
// generate the direct event ...
|
||||
if(true == data.keyboardKey.isDown) {
|
||||
EWOL_VERBOSE("GUI PRESSED : \"" << data.keyboardKey.myChar << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, data.keyboardKey.myChar);
|
||||
} else {
|
||||
EWOL_VERBOSE("GUI Release : \"" << data.keyboardKey.myChar << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, data.keyboardKey.myChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,10 +182,8 @@ void ewolProcessEvents(void)
|
||||
break;
|
||||
case THREAD_KEYBORAD_MOVE:
|
||||
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE");
|
||||
if (false==ewol::shortCut::Process(data.keyboardKey.special.shift,
|
||||
data.keyboardKey.special.ctrl,
|
||||
data.keyboardKey.special.alt,
|
||||
data.keyboardKey.special.meta,
|
||||
// check main shortcut
|
||||
if (false==ewol::shortCut::Process(data.keyboardKey.special,
|
||||
0,
|
||||
data.keyboardMove.move,
|
||||
data.keyboardKey.isDown)) {
|
||||
@ -188,10 +191,17 @@ void ewolProcessEvents(void)
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(true == data.keyboardMove.isDown) {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, data.keyboardMove.move);
|
||||
} else {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, data.keyboardMove.move);
|
||||
// check Widget shortcut
|
||||
if (false==tmpWidget->OnEventShortCut(data.keyboardKey.special,
|
||||
data.keyboardKey.myChar,
|
||||
ewol::EVENT_KB_MOVE_TYPE_NONE,
|
||||
data.keyboardKey.isDown)) {
|
||||
// generate the direct event ...
|
||||
if(true == data.keyboardMove.isDown) {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, data.keyboardMove.move);
|
||||
} else {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, data.keyboardMove.move);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,26 +48,15 @@ namespace eSystem
|
||||
void SetMouseState(int pointerID, bool isUp, float x, float y);
|
||||
|
||||
typedef struct {
|
||||
bool capLock;
|
||||
bool shift;
|
||||
bool ctrl;
|
||||
bool meta;
|
||||
bool alt;
|
||||
bool altGr;
|
||||
bool verNum;
|
||||
bool insert;
|
||||
} specialKey_ts;
|
||||
|
||||
typedef struct {
|
||||
bool isDown;
|
||||
uniChar_t myChar;
|
||||
eSystem::specialKey_ts special;
|
||||
bool isDown;
|
||||
uniChar_t myChar;
|
||||
ewol::specialKey_ts special;
|
||||
} keyboardKey_ts;
|
||||
|
||||
typedef struct {
|
||||
bool isDown;
|
||||
ewol::eventKbMoveType_te move;
|
||||
eSystem::specialKey_ts special;
|
||||
ewol::specialKey_ts special;
|
||||
} keyboardMove_ts;
|
||||
|
||||
void SetKeyboard(eSystem::keyboardKey_ts& keyInput);
|
||||
|
@ -85,7 +85,7 @@ static int attrListDbl[] = {
|
||||
None
|
||||
};
|
||||
|
||||
static eSystem::specialKey_ts guiKeyBoardMode;
|
||||
static ewol::specialKey_ts guiKeyBoardMode;
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
@ -176,14 +176,14 @@ void ewol::Button::OnRegenerateDisplay(void)
|
||||
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + m_padding.x;
|
||||
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + m_padding.y;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
|
||||
tmpTextOriginX = m_padding.x;
|
||||
}
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
|
@ -146,14 +146,14 @@ void ewol::ButtonColor::OnRegenerateDisplay(void)
|
||||
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + m_padding.x;
|
||||
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + m_padding.y;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
|
||||
tmpTextOriginX = m_padding.x;
|
||||
}
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
|
@ -130,11 +130,11 @@ void ewol::ButtonImage::OnRegenerateDisplay(void)
|
||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
@ -254,11 +254,11 @@ bool ewol::ButtonImage::OnEventInput(ewol::inputType_te type, int32_t IdInput, e
|
||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
|
@ -33,8 +33,8 @@
|
||||
|
||||
ewol::ContextMenu::ContextMenu(void)
|
||||
{
|
||||
m_userExpendX = true;
|
||||
m_userExpendY = true;
|
||||
m_userExpend.x = true;
|
||||
m_userExpend.y = true;
|
||||
|
||||
m_padding.x = 4;
|
||||
m_padding.y = 4;
|
||||
@ -134,8 +134,8 @@ bool ewol::ContextMenu::CalculateSize(float availlableX, float availlableY)
|
||||
bool ewol::ContextMenu::CalculateMinSize(void)
|
||||
{
|
||||
EWOL_DEBUG("CalculateMinSize");
|
||||
m_userExpendX=false;
|
||||
m_userExpendY=false;
|
||||
m_userExpend.x=false;
|
||||
m_userExpend.y=false;
|
||||
m_minSize.x = 50.0;
|
||||
m_minSize.y = 50.0;
|
||||
if (NULL != m_subWidget) {
|
||||
|
@ -34,6 +34,11 @@ extern const char * const ewolEventEntryClick = "ewol-Entry-click";
|
||||
extern const char * const ewolEventEntryEnter = "ewol-Entry-Enter";
|
||||
extern const char * const ewolEventEntryModify = "ewol-Entry-Modify";
|
||||
|
||||
const char * const ewolEventEntryCut = "ewol-Entry-Cut";
|
||||
const char * const ewolEventEntryCopy = "ewol-Entry-Copy";
|
||||
const char * const ewolEventEntryPaste = "ewol-Entry-Paste";
|
||||
const char * const ewolEventEntryClean = "ewol-Entry-Clean";
|
||||
const char * const ewolEventEntrySelect = "ewol-Entry-Select";
|
||||
|
||||
|
||||
#undef __class__
|
||||
@ -56,6 +61,12 @@ void ewol::Entry::Init(void)
|
||||
m_textColorBg = draw::color::white;
|
||||
m_textColorBg.a = 0xAF;
|
||||
SetCanHaveFocus(true);
|
||||
ShortCutAdd("ctrl+w", ewolEventEntryClean);
|
||||
ShortCutAdd("ctrl+x", ewolEventEntryCut);
|
||||
ShortCutAdd("ctrl+c", ewolEventEntryCopy);
|
||||
ShortCutAdd("ctrl+v", ewolEventEntryPaste);
|
||||
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
||||
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
||||
}
|
||||
|
||||
ewol::Entry::Entry(void)
|
||||
@ -126,10 +137,10 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||
int32_t tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
//tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
|
||||
@ -165,6 +176,38 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change the cursor position with the curent position requested on the display
|
||||
* @param[in] pos Absolute position of the event
|
||||
* @note The display is automaticly requested when change apear.
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Entry::UpdateCursorPosition(Vector2D<float>& pos)
|
||||
{
|
||||
Vector2D<float> relPos = RelativePosition(pos);
|
||||
// try to find the new cursor position :
|
||||
etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition);
|
||||
int32_t displayHidenSize = m_oObjectText.GetSize(tmpDisplay).x;
|
||||
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
|
||||
int32_t newCursorPosition = -1;
|
||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
tmpDisplay = m_data.Extract(0, iii);
|
||||
int32_t tmpWidth = m_oObjectText.GetSize(tmpDisplay).x - displayHidenSize;
|
||||
if (tmpWidth>=relPos.x-tmpTextOriginX) {
|
||||
newCursorPosition = iii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newCursorPosition == -1) {
|
||||
newCursorPosition = m_data.Size();
|
||||
}
|
||||
if (m_displayCursorPos != newCursorPosition) {
|
||||
m_displayCursorPos = newCursorPosition;
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event on an input of this Widget
|
||||
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
|
||||
@ -176,31 +219,13 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
||||
*/
|
||||
bool ewol::Entry::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, Vector2D<float> pos)
|
||||
{
|
||||
//EWOL_DEBUG("Event on Entry ...");
|
||||
//EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput);
|
||||
if (1 == IdInput) {
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
GenerateEventId(ewolEventEntryClick);
|
||||
KeepFocus();
|
||||
MarkToRedraw();
|
||||
Vector2D<float> relPos = RelativePosition(pos);
|
||||
// try to find the new cursor position :
|
||||
etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition);
|
||||
int32_t displayHidenSize = m_oObjectText.GetSize(tmpDisplay).x;
|
||||
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
|
||||
int32_t newCursorPosition = -1;
|
||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
tmpDisplay = m_data.Extract(0, iii);
|
||||
int32_t tmpWidth = m_oObjectText.GetSize(tmpDisplay).x - displayHidenSize;
|
||||
if (tmpWidth>=relPos.x-tmpTextOriginX) {
|
||||
newCursorPosition = iii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newCursorPosition == -1) {
|
||||
newCursorPosition = m_data.Size();
|
||||
}
|
||||
m_displayCursorPos = newCursorPosition;
|
||||
UpdateCursorPosition(pos);
|
||||
return true;
|
||||
} else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) {
|
||||
// TODO : selected area ...
|
||||
@ -208,6 +233,31 @@ bool ewol::Entry::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventIn
|
||||
// TODO : select all the line
|
||||
}
|
||||
}
|
||||
else if( ewol::INPUT_TYPE_MOUSE == type
|
||||
&& 2 == IdInput) {
|
||||
if( typeEvent == ewol::EVENT_INPUT_TYPE_DOWN
|
||||
|| typeEvent == ewol::EVENT_INPUT_TYPE_MOVE
|
||||
|| typeEvent == ewol::EVENT_INPUT_TYPE_UP) {
|
||||
// updatethe cursor position :
|
||||
UpdateCursorPosition(pos);
|
||||
}
|
||||
// Paste current selection only when up button
|
||||
if (typeEvent == ewol::EVENT_INPUT_TYPE_UP) {
|
||||
// middle button => past data...
|
||||
// get current selection :
|
||||
etk::UString tmpData = Get(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
// add it on the current display :
|
||||
if (tmpData.Size() >= 0) {
|
||||
m_data.Add(m_displayCursorPos, &tmpData[0]);
|
||||
if (m_data.Size() == tmpData.Size()) {
|
||||
m_displayCursorPos = tmpData.Size()-1;
|
||||
} else {
|
||||
m_displayCursorPos += tmpData.Size();
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -284,12 +334,62 @@ bool ewol::Entry::OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te mov
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
|
||||
* @note : need to have focus ...
|
||||
* @param[in] mode Mode of data requested
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Entry::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
// get current selection :
|
||||
etk::UString tmpData = Get(ewol::clipBoard::CLIPBOARD_STD);
|
||||
// add it on the current display :
|
||||
if (tmpData.Size() >= 0) {
|
||||
m_data.Add(m_displayCursorPos, &tmpData[0]);
|
||||
if (m_data.Size() == tmpData.Size()) {
|
||||
m_displayCursorPos = tmpData.Size()-1;
|
||||
} else {
|
||||
m_displayCursorPos += tmpData.Size();
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Entry::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::Widget::OnReceiveMessage(CallerObject, eventId, data);
|
||||
if(eventId == ewolEventEntryClean) {
|
||||
m_data = "";
|
||||
m_displayStartPosition = 0;
|
||||
m_displayCursorPos = 0;
|
||||
MarkToRedraw();
|
||||
} else if(eventId == ewolEventEntryCut) {
|
||||
|
||||
} else if(eventId == ewolEventEntryCopy) {
|
||||
|
||||
} else if(eventId == ewolEventEntryPaste) {
|
||||
ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if(eventId == ewolEventEntrySelect) {
|
||||
if(data == "ALL") {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::Entry::UpdateTextPosition(void)
|
||||
{
|
||||
int32_t tmpSizeX = m_minSize.x;
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
}
|
||||
int32_t tmpUserSize = tmpSizeX - 2*(m_borderSize + 2*m_paddingSize);
|
||||
|
@ -60,8 +60,8 @@ namespace ewol {
|
||||
ewol::OObject2DTextColored m_oObjectText;
|
||||
ewol::OObject2DColored m_oObjectDecoration;
|
||||
etk::UString m_data;
|
||||
draw::Color m_textColorFg; //!< Text color
|
||||
draw::Color m_textColorBg; //!< Background color
|
||||
draw::Color m_textColorFg; //!< Text color
|
||||
draw::Color m_textColorBg; //!< Background color
|
||||
int32_t m_userSize;
|
||||
int32_t m_displayStartPosition;
|
||||
int32_t m_displayCursorPos;
|
||||
@ -97,7 +97,29 @@ namespace ewol {
|
||||
* @return false if the event has not been used
|
||||
*/
|
||||
virtual bool OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te moveTypeEvent);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
/**
|
||||
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
|
||||
* @note : need to have focus ...
|
||||
* @param[in] mode Mode of data requested
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
protected:
|
||||
/**
|
||||
* @brief Change the cursor position with the curent position requested on the display
|
||||
* @param[in] pos Absolute position of the event
|
||||
* @note The display is automaticly requested when change apear.
|
||||
* @return ---
|
||||
*/
|
||||
virtual void UpdateCursorPosition(Vector2D<float>& pos);
|
||||
virtual void OnGetFocus(void);
|
||||
virtual void OnLostFocus(void);
|
||||
};
|
||||
|
@ -112,11 +112,11 @@ void ewol::Image::OnRegenerateDisplay(void)
|
||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
|
@ -92,10 +92,10 @@ void ewol::Label::OnRegenerateDisplay(void)
|
||||
int32_t tmpOriginX = 0;
|
||||
int32_t tmpOriginY = 0;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||
}
|
||||
tmpOriginX += paddingSize;
|
||||
|
@ -61,18 +61,18 @@ bool ewol::Layer::CalculateSize(float availlableX, float availlableY)
|
||||
|
||||
bool ewol::Layer::CalculateMinSize(void)
|
||||
{
|
||||
m_userExpendX=false;
|
||||
m_userExpendY=false;
|
||||
m_userExpend.x=false;
|
||||
m_userExpend.y=false;
|
||||
m_minSize.x = 0.0;
|
||||
m_minSize.y = 0.0;
|
||||
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
|
||||
if (NULL != m_subWidget[iii]) {
|
||||
m_subWidget[iii]->CalculateMinSize();
|
||||
if (true == m_subWidget[iii]->CanExpentX()) {
|
||||
m_userExpendX = true;
|
||||
m_userExpend.x = true;
|
||||
}
|
||||
if (true == m_subWidget[iii]->CanExpentY()) {
|
||||
m_userExpendY = true;
|
||||
m_userExpend.y = true;
|
||||
}
|
||||
Vector2D<float> tmpSize = m_subWidget[iii]->GetMinSize();
|
||||
m_minSize.x = etk_max(tmpSize.x, m_minSize.x);
|
||||
@ -97,7 +97,7 @@ bool ewol::Layer::CanExpentX(void)
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendX;
|
||||
return m_userExpend.x;
|
||||
}
|
||||
|
||||
void ewol::Layer::SetExpendY(bool newExpend)
|
||||
@ -110,7 +110,7 @@ bool ewol::Layer::CanExpentY(void)
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendY;
|
||||
return m_userExpend.y;
|
||||
}
|
||||
|
||||
void ewol::Layer::LockExpendContamination(bool lockExpend)
|
||||
|
@ -119,10 +119,10 @@ void ewol::List::OnRegenerateDisplay(void)
|
||||
int32_t tmpOriginX = 0;
|
||||
int32_t tmpOriginY = 0;
|
||||
/*
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpOriginY = 0;
|
||||
}*/
|
||||
tmpOriginX += m_paddingSizeX;
|
||||
|
@ -33,8 +33,8 @@
|
||||
ewol::PopUp::PopUp(void) :
|
||||
m_subWidgetNext(NULL)
|
||||
{
|
||||
m_userExpendX = true;
|
||||
m_userExpendY = true;
|
||||
m_userExpend.x = true;
|
||||
m_userExpend.y = true;
|
||||
|
||||
m_colorBackGroung = draw::color::white;
|
||||
|
||||
@ -92,8 +92,8 @@ bool ewol::PopUp::CalculateSize(float availlableX, float availlableY)
|
||||
bool ewol::PopUp::CalculateMinSize(void)
|
||||
{
|
||||
//EWOL_DEBUG("CalculateMinSize");
|
||||
m_userExpendX=false;
|
||||
m_userExpendY=false;
|
||||
m_userExpend.x=false;
|
||||
m_userExpend.y=false;
|
||||
m_minSize.x = 50.0;
|
||||
m_minSize.y = 50.0;
|
||||
if (NULL != m_subWidget) {
|
||||
|
@ -97,18 +97,18 @@ bool ewol::SizerHori::CalculateSize(float availlableX, float availlableY)
|
||||
bool ewol::SizerHori::CalculateMinSize(void)
|
||||
{
|
||||
//EWOL_DEBUG("Update minimum Size");
|
||||
m_userExpendX=false;
|
||||
m_userExpendY=false;
|
||||
m_userExpend.x=false;
|
||||
m_userExpend.y=false;
|
||||
m_minSize.x = 0.0;
|
||||
m_minSize.y = 0.0;
|
||||
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
|
||||
if (NULL != m_subWidget[iii]) {
|
||||
m_subWidget[iii]->CalculateMinSize();
|
||||
if (true == m_subWidget[iii]->CanExpentX()) {
|
||||
m_userExpendX = true;
|
||||
m_userExpend.x = true;
|
||||
}
|
||||
if (true == m_subWidget[iii]->CanExpentY()) {
|
||||
m_userExpendY = true;
|
||||
m_userExpend.y = true;
|
||||
}
|
||||
Vector2D<float> tmpSize = m_subWidget[iii]->GetMinSize();
|
||||
m_minSize.x += tmpSize.x;
|
||||
@ -117,7 +117,7 @@ bool ewol::SizerHori::CalculateMinSize(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("Result : expend X="<< m_userExpendX << " Y=" << m_userExpendY);
|
||||
//EWOL_DEBUG("Result : expend X="<< m_userExpend.x << " Y=" << m_userExpend.y);
|
||||
//EWOL_DEBUG(" minSize ("<< m_minSize.x << "," << m_minSize.y << ")");
|
||||
return true;
|
||||
}
|
||||
@ -137,7 +137,7 @@ bool ewol::SizerHori::CanExpentX(void)
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendX;
|
||||
return m_userExpend.x;
|
||||
}
|
||||
|
||||
void ewol::SizerHori::SetExpendY(bool newExpend)
|
||||
@ -150,7 +150,7 @@ bool ewol::SizerHori::CanExpentY(void)
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendY;
|
||||
return m_userExpend.y;
|
||||
}
|
||||
|
||||
void ewol::SizerHori::LockExpendContamination(bool lockExpend)
|
||||
|
@ -99,18 +99,18 @@ bool ewol::SizerVert::CalculateSize(float availlableX, float availlableY)
|
||||
bool ewol::SizerVert::CalculateMinSize(void)
|
||||
{
|
||||
//EWOL_DEBUG("Update minimum Size");
|
||||
m_userExpendX=false;
|
||||
m_userExpendY=false;
|
||||
m_userExpend.x=false;
|
||||
m_userExpend.y=false;
|
||||
m_minSize.x = 0.0;
|
||||
m_minSize.y = 0.0;
|
||||
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
|
||||
if (NULL != m_subWidget[iii]) {
|
||||
m_subWidget[iii]->CalculateMinSize();
|
||||
if (true == m_subWidget[iii]->CanExpentX()) {
|
||||
m_userExpendX = true;
|
||||
m_userExpend.x = true;
|
||||
}
|
||||
if (true == m_subWidget[iii]->CanExpentY()) {
|
||||
m_userExpendY = true;
|
||||
m_userExpend.y = true;
|
||||
}
|
||||
Vector2D<float> tmpSize = m_subWidget[iii]->GetMinSize();
|
||||
//EWOL_DEBUG(" Get minSize[" << iii << "] ("<< tmpSize.x << "," << tmpSize.y << ")");
|
||||
@ -120,7 +120,7 @@ bool ewol::SizerVert::CalculateMinSize(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
//EWOL_DEBUG("Result : expend X="<< m_userExpendX << " Y=" << m_userExpendY);
|
||||
//EWOL_DEBUG("Result : expend X="<< m_userExpend.x << " Y=" << m_userExpend.y);
|
||||
//EWOL_DEBUG(" minSize ("<< m_minSize.x << "," << m_minSize.y << ")");
|
||||
return true;
|
||||
}
|
||||
@ -140,7 +140,7 @@ bool ewol::SizerVert::CanExpentX(void)
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendX;
|
||||
return m_userExpend.x;
|
||||
}
|
||||
|
||||
void ewol::SizerVert::SetExpendY(bool newExpend)
|
||||
@ -153,7 +153,7 @@ bool ewol::SizerVert::CanExpentY(void)
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendY;
|
||||
return m_userExpend.y;
|
||||
}
|
||||
|
||||
void ewol::SizerVert::LockExpendContamination(bool lockExpend)
|
||||
|
@ -115,7 +115,7 @@ void ewol::WSlider::SetMinSise(float x, float y)
|
||||
|
||||
bool ewol::WSlider::CanExpentX(void)
|
||||
{
|
||||
if (m_userExpendX == true) {
|
||||
if (m_userExpend.x == true) {
|
||||
return true;
|
||||
}
|
||||
if (true == m_lockExpendContamination) {
|
||||
@ -126,7 +126,7 @@ bool ewol::WSlider::CanExpentX(void)
|
||||
|
||||
bool ewol::WSlider::CanExpentY(void)
|
||||
{
|
||||
if (m_userExpendY == true) {
|
||||
if (m_userExpend.y == true) {
|
||||
return true;
|
||||
}
|
||||
if (true == m_lockExpendContamination) {
|
||||
|
@ -32,6 +32,7 @@ char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type)
|
||||
{
|
||||
char * returnValue = "?";
|
||||
switch(type) {
|
||||
case ewol::EVENT_KB_MOVE_TYPE_NONE: returnValue = "---"; break;
|
||||
case ewol::EVENT_KB_MOVE_TYPE_LEFT: returnValue = "LEFT"; break;
|
||||
case ewol::EVENT_KB_MOVE_TYPE_RIGHT: returnValue = "RIGHT"; break;
|
||||
case ewol::EVENT_KB_MOVE_TYPE_UP: returnValue = "UP"; break;
|
||||
@ -113,6 +114,9 @@ ewol::Widget::~Widget(void)
|
||||
{
|
||||
// Remove his own focus...
|
||||
ewol::widgetManager::Rm(this);
|
||||
// clean all the short-cut ...
|
||||
ShortCutClean();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -333,3 +337,172 @@ void ewol::Widget::MarkToRedraw(void)
|
||||
m_needRegenerateDisplay = true;
|
||||
ewol::widgetManager::MarkDrawingIsNeeded();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Shortcut : management of the shortcut
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Add a specific shortcut with his description
|
||||
* @param[in] descriptiveString Description string of the shortcut
|
||||
* @param[in] generateEventId Event generic of the element
|
||||
* @param[in] data Associate data wit the event
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Widget::ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data, bool broadcast)
|
||||
{
|
||||
if( NULL==descriptiveString
|
||||
|| 0==strlen(descriptiveString))
|
||||
{
|
||||
EWOL_ERROR("try to add shortcut with no descriptive string ...");
|
||||
return;
|
||||
}
|
||||
|
||||
EventShortCut* tmpElement = new EventShortCut();
|
||||
if (NULL == tmpElement) {
|
||||
EWOL_ERROR("allocation error ... Memory error ...");
|
||||
return;
|
||||
}
|
||||
tmpElement->broadcastEvent = broadcast;
|
||||
tmpElement->generateEventId = generateEventId;
|
||||
tmpElement->eventData = data;
|
||||
// parsing of the string :
|
||||
//"ctrl+shift+alt+meta+s"
|
||||
const char * tmp = strstr(descriptiveString, "ctrl");
|
||||
if(NULL != tmp) {
|
||||
tmpElement->specialKey.ctrl = true;
|
||||
}
|
||||
tmp = strstr(descriptiveString, "shift");
|
||||
if(NULL != tmp) {
|
||||
tmpElement->specialKey.shift = true;
|
||||
}
|
||||
tmp = strstr(descriptiveString, "alt");
|
||||
if(NULL != tmp) {
|
||||
tmpElement->specialKey.alt = true;
|
||||
}
|
||||
tmp = strstr(descriptiveString, "meta");
|
||||
if(NULL != tmp) {
|
||||
tmpElement->specialKey.meta = true;
|
||||
}
|
||||
if(NULL != strstr(descriptiveString, "F12") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F12;
|
||||
} else if(NULL != strstr(descriptiveString, "F11") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F11;
|
||||
} else if(NULL != strstr(descriptiveString, "F10") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F10;
|
||||
} else if(NULL != strstr(descriptiveString, "F9") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F9;
|
||||
} else if(NULL != strstr(descriptiveString, "F8") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F8;
|
||||
} else if(NULL != strstr(descriptiveString, "F7") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F7;
|
||||
} else if(NULL != strstr(descriptiveString, "F6") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F6;
|
||||
} else if(NULL != strstr(descriptiveString, "F5") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F5;
|
||||
} else if(NULL != strstr(descriptiveString, "F4") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F4;
|
||||
} else if(NULL != strstr(descriptiveString, "F3") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F3;
|
||||
} else if(NULL != strstr(descriptiveString, "F2") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F2;
|
||||
} else if(NULL != strstr(descriptiveString, "F1") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_F1;
|
||||
} else if(NULL != strstr(descriptiveString, "LEFT") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_LEFT;
|
||||
} else if(NULL != strstr(descriptiveString, "RIGHT") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_RIGHT;
|
||||
} else if(NULL != strstr(descriptiveString, "UP") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_UP;
|
||||
} else if(NULL != strstr(descriptiveString, "DOWN") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_DOWN;
|
||||
} else if(NULL != strstr(descriptiveString, "PAGE_UP") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_PAGE_UP;
|
||||
} else if(NULL != strstr(descriptiveString, "PAGE_DOWN") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN;
|
||||
} else if(NULL != strstr(descriptiveString, "START") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_START;
|
||||
} else if(NULL != strstr(descriptiveString, "END") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_END;
|
||||
} else if(NULL != strstr(descriptiveString, "CENTER") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_CENTER;
|
||||
} else if(NULL != strstr(descriptiveString, "ARRET_DEFIL") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_ARRET_DEFIL;
|
||||
} else if(NULL != strstr(descriptiveString, "WAIT") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_WAIT;
|
||||
} else if(NULL != strstr(descriptiveString, "INSERT") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_INSERT;
|
||||
} else if(NULL != strstr(descriptiveString, "CAPLOCK") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_CAPLOCK;
|
||||
} else if(NULL != strstr(descriptiveString, "CONTEXT_MENU") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_CONTEXT_MENU;
|
||||
} else if(NULL != strstr(descriptiveString, "VER_NUM") ) {
|
||||
tmpElement->keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_VER_NUM;
|
||||
} else {
|
||||
tmpElement->unicodeValue = descriptiveString[strlen(descriptiveString) -1];
|
||||
}
|
||||
// add it on the List ...
|
||||
m_localShortcut.PushBack(tmpElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove all curent shortCut
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Widget::ShortCutClean(void)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_localShortcut.Size(); iii++) {
|
||||
if (NULL != m_localShortcut[iii]) {
|
||||
delete(m_localShortcut[iii]);
|
||||
m_localShortcut[iii]=NULL;
|
||||
}
|
||||
}
|
||||
m_localShortcut.Clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb)
|
||||
* @param[in] special all the special kay pressed at this time
|
||||
* @param[in] unicodeValue key pressed by the user not used if the kbMove!=ewol::EVENT_KB_MOVE_TYPE_NONE
|
||||
* @param[in] kbMove special key of the keyboard
|
||||
* @return true if the event has been used
|
||||
* @return false if the event has not been used
|
||||
* @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some ununderstanding error
|
||||
*/
|
||||
bool ewol::Widget::OnEventShortCut(ewol::specialKey_ts& special, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown)
|
||||
{
|
||||
if (unicodeValue >= 'A' && unicodeValue <='Z') {
|
||||
unicodeValue += 'a' - 'A';
|
||||
}
|
||||
//EWOL_INFO("Try to find generic shortcut ...");
|
||||
for(int32_t iii=m_localShortcut.Size()-1; iii>=0; iii--) {
|
||||
if(NULL != m_localShortcut[iii]) {
|
||||
if( m_localShortcut[iii]->specialKey.shift == special.shift
|
||||
&& m_localShortcut[iii]->specialKey.ctrl == special.ctrl
|
||||
&& m_localShortcut[iii]->specialKey.alt == special.alt
|
||||
&& m_localShortcut[iii]->specialKey.meta == special.meta
|
||||
&& ( ( m_localShortcut[iii]->keyboardMoveValue == ewol::EVENT_KB_MOVE_TYPE_NONE
|
||||
&& m_localShortcut[iii]->unicodeValue == unicodeValue)
|
||||
|| ( m_localShortcut[iii]->keyboardMoveValue == kbMove
|
||||
&& m_localShortcut[iii]->unicodeValue == 0)
|
||||
) )
|
||||
{
|
||||
if (isDown) {
|
||||
if (true == m_localShortcut[iii]->broadcastEvent) {
|
||||
// send message at all the widget
|
||||
SendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
|
||||
} else {
|
||||
// send message direct to the current widget
|
||||
OnReceiveMessage(this, m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
|
||||
}
|
||||
} // no else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -111,6 +111,42 @@ namespace ewol {
|
||||
Vector2D<int32_t> m_size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
bool capLock;
|
||||
bool shift;
|
||||
bool ctrl;
|
||||
bool meta;
|
||||
bool alt;
|
||||
bool altGr;
|
||||
bool verNum;
|
||||
bool insert;
|
||||
} specialKey_ts;
|
||||
|
||||
class EventShortCut {
|
||||
public:
|
||||
bool broadcastEvent; // if it is true, then the message is sent to all the system
|
||||
const char * generateEventId; // Local generated event
|
||||
etk::UString eventData; // data link with the event
|
||||
ewol::specialKey_ts specialKey; // special board key
|
||||
uniChar_t unicodeValue; // 0 if not used
|
||||
ewol::eventKbMoveType_te keyboardMoveValue; // ewol::EVENT_KB_MOVE_TYPE_NONE if not used
|
||||
EventShortCut(void) {
|
||||
broadcastEvent = false;
|
||||
generateEventId = NULL;
|
||||
eventData = "";
|
||||
specialKey.capLock = false;
|
||||
specialKey.shift = false;
|
||||
specialKey.ctrl = false;
|
||||
specialKey.meta = false;
|
||||
specialKey.alt = false;
|
||||
specialKey.altGr = false;
|
||||
specialKey.verNum = false;
|
||||
specialKey.insert = false;
|
||||
unicodeValue = 0;
|
||||
keyboardMoveValue = ewol::EVENT_KB_MOVE_TYPE_NONE;
|
||||
};
|
||||
~EventShortCut(void) { };
|
||||
};
|
||||
|
||||
class Widget : public EObject {
|
||||
public:
|
||||
@ -146,10 +182,8 @@ namespace ewol {
|
||||
Vector2D<float> m_minSize; //!< user define the minimum size of the widget
|
||||
// user configuaration
|
||||
Vector2D<float> m_userMinSize; //!< user define the minimum size of the widget
|
||||
bool m_userExpendX;
|
||||
bool m_userExpendY;
|
||||
bool m_userFillX;
|
||||
bool m_userFillY;
|
||||
Vector2D<bool> m_userExpend;
|
||||
Vector2D<bool> m_userFill;
|
||||
public:
|
||||
/**
|
||||
* @brief Set the zoom property of the widget
|
||||
@ -225,49 +259,49 @@ namespace ewol {
|
||||
* @param[in] newExpend new Expend state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; };
|
||||
virtual void SetExpendX(bool newExpend=false) { m_userExpend.x = newExpend; };
|
||||
/**
|
||||
* @brief Get the horizontal expend capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to expend
|
||||
*/
|
||||
virtual bool CanExpentX(void) { if (false==IsHide()) { return m_userExpendX; } return false; };
|
||||
virtual bool CanExpentX(void) { if (false==IsHide()) { return m_userExpend.x; } return false; };
|
||||
/**
|
||||
* @brief Set the vertical expend capacity
|
||||
* @param[in] newExpend new Expend state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetExpendY(bool newExpend=false) { m_userExpendY = newExpend; };
|
||||
virtual void SetExpendY(bool newExpend=false) { m_userExpend.y = newExpend; };
|
||||
/**
|
||||
* @brief Get the vertical expend capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to expend
|
||||
*/
|
||||
virtual bool CanExpentY(void) { if (false==IsHide()) { return m_userExpendY; } return false; };
|
||||
virtual bool CanExpentY(void) { if (false==IsHide()) { return m_userExpend.y; } return false; };
|
||||
/**
|
||||
* @brief Set the horizontal filling capacity
|
||||
* @param[in] newFill new fill state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetFillX(bool newFill=false) { m_userFillX = newFill; };
|
||||
virtual void SetFillX(bool newFill=false) { m_userFill.x = newFill; };
|
||||
/**
|
||||
* @brief Get the horizontal filling capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to horizontal filling
|
||||
*/
|
||||
bool CanFillX(void) { return m_userFillX; };
|
||||
bool CanFillX(void) { return m_userFill.x; };
|
||||
/**
|
||||
* @brief Set the vertical filling capacity
|
||||
* @param[in] newFill new fill state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetFillY(bool newFill=false) { m_userFillY = newFill; };
|
||||
virtual void SetFillY(bool newFill=false) { m_userFill.y = newFill; };
|
||||
/**
|
||||
* @brief Get the vertical filling capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to vertical filling
|
||||
*/
|
||||
bool CanFillY(void) { return m_userFillY; };
|
||||
bool CanFillY(void) { return m_userFill.y; };
|
||||
/**
|
||||
* @brief Set the widget hidden
|
||||
* @param ---
|
||||
@ -400,17 +434,6 @@ namespace ewol {
|
||||
* @return false the event is not used
|
||||
*/
|
||||
virtual bool OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, Vector2D<float> pos) { return false; };
|
||||
/**
|
||||
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb)
|
||||
* @param[in] shift The key Shift (left or/and right) is pressed (if true)
|
||||
* @param[in] control The key control (left or/and right) is pressed (if true)
|
||||
* @param[in] alt The key Alt is pressed (if true)
|
||||
* @param[in] meta The key Meta (windows key/Apple key) (left or/and right) is pressed (if true)
|
||||
* @param[in] unicodeValue key pressed by the user
|
||||
* @return true if the event has been used
|
||||
* @return false if the event has not been used
|
||||
*/
|
||||
virtual bool OnEventShortCut(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue) { return false; };
|
||||
/**
|
||||
* @brief Event on the keybord (if no shortcut has been detected before).
|
||||
* @param[in] type of the event (ewol::EVENT_KB_TYPE_DOWN or ewol::EVENT_KB_TYPE_UP)
|
||||
@ -434,6 +457,37 @@ namespace ewol {
|
||||
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID) { };
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Shortcut : management of the shortcut
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
private:
|
||||
etk::Vector<EventShortCut*> m_localShortcut;
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a specific shortcut with his description
|
||||
* @param[in] descriptiveString Description string of the shortcut
|
||||
* @param[in] generateEventId Event generic of the element
|
||||
* @param[in] data Associate data wit the event
|
||||
* @return ---
|
||||
*/
|
||||
void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false);
|
||||
/**
|
||||
* @brief Remove all curent shortCut
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void ShortCutClean(void);
|
||||
public:
|
||||
/**
|
||||
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb)
|
||||
* @param[in] special all the special kay pressed at this time
|
||||
* @param[in] unicodeValue key pressed by the user not used if the kbMove!=ewol::EVENT_KB_MOVE_TYPE_NONE
|
||||
* @param[in] kbMove special key of the keyboard
|
||||
* @return true if the event has been used
|
||||
* @return false if the event has not been used
|
||||
* @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some ununderstanding error
|
||||
*/
|
||||
virtual bool OnEventShortCut(ewol::specialKey_ts& special, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown);
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working...
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
protected:
|
||||
|
@ -127,10 +127,10 @@ void ewol::ParameterList::OnRegenerateDisplay(void)
|
||||
int32_t tmpOriginX = 0;
|
||||
int32_t tmpOriginY = 0;
|
||||
/*
|
||||
if (true==m_userFillX) {
|
||||
if (true==m_userFill.x) {
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
if (true==m_userFill.y) {
|
||||
tmpOriginY = 0;
|
||||
}*/
|
||||
tmpOriginX += m_paddingSizeX;
|
||||
|
Loading…
Reference in New Issue
Block a user