upgrade the windows display and the file chooser system

This commit is contained in:
Edouard Dupin 2012-02-09 17:22:52 +01:00
parent 1ba8901f74
commit 6446535f31
14 changed files with 111 additions and 91 deletions

View File

@ -39,17 +39,11 @@
//list of local events : //list of local events :
const char * ewolEventWindowsClose = "ewol Windows close"; extern const char * const ewolEventWindowsHideKeyboard = "ewol Windows hideKeyboard";
const char * ewolEventWindowsMinimize = "ewol Windows minimize";
const char * ewolEventWindowsExpend = "ewol Windows expend/unExpend";
const char * ewolEventWindowsHideKeyboard = "ewol Windows hideKeyboard";
ewol::Windows::Windows(void) ewol::Windows::Windows(void)
{ {
AddEventId(ewolEventWindowsClose);
AddEventId(ewolEventWindowsMinimize);
AddEventId(ewolEventWindowsExpend);
SetCanHaveFocus(true); SetCanHaveFocus(true);
m_subWidget = NULL; m_subWidget = NULL;
m_popUpWidget = NULL; m_popUpWidget = NULL;
@ -198,26 +192,6 @@ bool ewol::Windows::OnDraw(void)
} }
bool ewol::Windows::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y)
{
bool eventIsOK = false;
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
if(ewolEventWindowsClose == generateEventId) {
EWOL_INFO("Request close of the windows");
ewol::Stop();
eventIsOK = true;
} else if(ewolEventWindowsMinimize == generateEventId) {
EWOL_INFO("Request Minimize of the windows");
eventIsOK = true;
} else if(ewolEventWindowsExpend == generateEventId) {
EWOL_INFO("Request Expend of the windows");
eventIsOK = true;
}
return eventIsOK;
}
void ewol::Windows::SetSubWidget(ewol::Widget * widget) void ewol::Windows::SetSubWidget(ewol::Widget * widget)
{ {
@ -260,12 +234,14 @@ bool ewol::Windows::OnEventAreaExternal(int32_t widgetID, const char * generateE
if(ewolEventWindowsHideKeyboard == generateEventId) { if(ewolEventWindowsHideKeyboard == generateEventId) {
EWOL_INFO("Request Hide keyboard"); EWOL_INFO("Request Hide keyboard");
KeyboardHide(); KeyboardHide();
}
return true; return true;
} }
return false;
}
void ewol::Windows::KeyboardShow(ewol::keyboardMode_te mode) void ewol::Windows::KeyboardShow(ewol::keyboardMode_te mode)
{ {
#if defined(__PLATFORM__Android)
if (NULL == m_keyBoardwidget) { if (NULL == m_keyBoardwidget) {
// Create the keyboard ... // Create the keyboard ...
m_keyBoardwidget = new ewol::Keyboard(); m_keyBoardwidget = new ewol::Keyboard();
@ -281,6 +257,7 @@ void ewol::Windows::KeyboardShow(ewol::keyboardMode_te mode)
} }
CalculateSize(m_size.x, m_size.y); CalculateSize(m_size.x, m_size.y);
MarkToReedraw(); MarkToReedraw();
#endif
} }

View File

@ -51,11 +51,8 @@ namespace ewol {
virtual bool OnKill(void) { return true; }; virtual bool OnKill(void) { return true; };
virtual void OnReduce(void) { }; virtual void OnReduce(void) { };
virtual void On(void) { }; virtual void On(void) { };
// from Widget management :
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY);
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
// Widget overwrite function
public: public:
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY);
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 OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
private: private:

View File

@ -77,10 +77,10 @@ void guiAbstraction::SendKeyboardEvent(bool isDown, etk::String &keyInput)
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (NULL != tmpWidget) { if (NULL != tmpWidget) {
if(true == isDown) { if(true == isDown) {
EWOL_DEBUG("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size()); EWOL_VERBOSE("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size());
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str()); tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str());
} else { } else {
EWOL_DEBUG("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size()); EWOL_VERBOSE("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size());
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str()); tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str());
} }
} }
@ -150,7 +150,7 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
if(0<=pointerID && pointerID < NB_MAX_INPUT ) { if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
// Send Down message // Send Down message
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOWN] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOWN] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y);
} }
// Check double or triple click event ... // Check double or triple click event ...
@ -180,7 +180,7 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
if(0<=pointerID && pointerID < NB_MAX_INPUT ) { if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
// Send Down message // Send Down message
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [UP] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [UP] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y);
} }
if (m_previousBouttonId != pointerID) { if (m_previousBouttonId != pointerID) {
@ -193,14 +193,14 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
m_previousDouble = false; m_previousDouble = false;
} else { } else {
int64_t currentTime = GetCurrentTime(); // return the tic in 1ms int64_t currentTime = GetCurrentTime(); // return the tic in 1ms
EWOL_DEBUG("time is : " << (int)currentTime << " "<< (int)(currentTime/1000) <<"s " << (int)((currentTime%100)*10) << "ms delta : " << (currentTime - m_previousTime) << "<" << separateClickTime ); EWOL_VERBOSE("time is : " << (int)currentTime << " "<< (int)(currentTime/1000) <<"s " << (int)((currentTime%100)*10) << "ms delta : " << (currentTime - m_previousTime) << "<" << separateClickTime );
if (currentTime - m_previousTime >= separateClickTime) { if (currentTime - m_previousTime >= separateClickTime) {
//check if the same area click : //check if the same area click :
if( abs(m_previousDown_x - x) < offsetMoveClicked if( abs(m_previousDown_x - x) < offsetMoveClicked
&& abs(m_previousDown_y - y) < offsetMoveClicked ) && abs(m_previousDown_y - y) < offsetMoveClicked )
{ {
// might generate an sigle event : // might generate an sigle event :
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [SINGLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [SINGLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y);
m_previous_x = m_previousDown_x; m_previous_x = m_previousDown_x;
m_previous_y = m_previousDown_y; m_previous_y = m_previousDown_y;
@ -223,12 +223,12 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
{ {
// might generate an sigle event : // might generate an sigle event :
if (false == m_previousDouble) { if (false == m_previousDouble) {
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOUBLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOUBLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)x, (etkFloat_t)y);
m_previousTime = currentTime; m_previousTime = currentTime;
m_previousDouble = true; m_previousDouble = true;
} else { } else {
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [TRIPLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [TRIPLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)x, (etkFloat_t)y);
// reset values ... // reset values ...
m_previousDown_x = -1; m_previousDown_x = -1;

View File

@ -161,6 +161,7 @@ bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, et
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
// nothing to do ... // nothing to do ...
GenEventInputExternal(ewolEventButtonPressed, x, y); GenEventInputExternal(ewolEventButtonPressed, x, y);
MarkToReedraw();
return true; return true;
} }
} }

View File

@ -58,7 +58,6 @@ namespace ewol {
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 OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]); virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
}; };
}; };

View File

@ -149,6 +149,7 @@ bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent,
} }
GenEventInputExternal(ewolEventCheckBoxClicked, x, y); GenEventInputExternal(ewolEventCheckBoxClicked, x, y);
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
MarkToReedraw();
return true; return true;
} }
} }
@ -169,6 +170,7 @@ bool ewol::CheckBox::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX
} else { } else {
m_value = true; m_value = true;
} }
MarkToReedraw();
return GenEventInputExternal(ewolEventCheckBoxClicked, -1,-1); return GenEventInputExternal(ewolEventCheckBoxClicked, -1,-1);
} }
return false; return false;

View File

@ -52,7 +52,6 @@ namespace ewol {
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 OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]); virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
}; };
}; };

View File

@ -65,17 +65,15 @@ ewol::Entry::Entry(void)
Init(); Init();
m_data = ""; m_data = "";
UpdateTextPosition(); UpdateTextPosition();
MarkToReedraw();
} }
ewol::Entry::Entry(etk::String newData) ewol::Entry::Entry(etk::String newData)
{ {
Init(); Init();
SetValue(newData); SetValue(newData);
/*
m_data = newData;
m_displayCursorPos = m_data.Size();
UpdateTextPosition(); UpdateTextPosition();
*/ MarkToReedraw();
} }
@ -91,6 +89,7 @@ bool ewol::Entry::CalculateMinSize(void)
m_minSize.x = m_userSize; m_minSize.x = m_userSize;
m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize); m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize);
UpdateTextPosition(); UpdateTextPosition();
MarkToReedraw();
return true; return true;
} }
@ -166,7 +165,7 @@ bool ewol::Entry::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etk
// nothing to do ... // nothing to do ...
GenEventInputExternal(ewolEventEntryClick, x, y); GenEventInputExternal(ewolEventEntryClick, x, y);
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
ewol::KeyboardShow(KEYBOARD_MODE_CODE); MarkToReedraw();
return true; return true;
} }
} }
@ -227,11 +226,13 @@ void ewol::Entry::UpdateTextPosition(void)
void ewol::Entry::OnGetFocus(void) void ewol::Entry::OnGetFocus(void)
{ {
m_displayCursor = true; m_displayCursor = true;
ewol::KeyboardShow(ewol::KEYBOARD_MODE_CODE);
MarkToReedraw(); MarkToReedraw();
} }
void ewol::Entry::OnLostFocus(void) void ewol::Entry::OnLostFocus(void)
{ {
m_displayCursor = false; m_displayCursor = false;
ewol::KeyboardHide();
MarkToReedraw(); MarkToReedraw();
} }

View File

@ -62,7 +62,6 @@ namespace ewol {
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 OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]); virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
protected: protected:
virtual void OnGetFocus(void); virtual void OnGetFocus(void);

View File

@ -106,24 +106,13 @@ void ewol::Label::OnRegenerateDisplay(void)
tmpText->Text(tmpOriginX, tmpOriginY, m_label.c_str(), m_size.x - 2*paddingSize); tmpText->Text(tmpOriginX, tmpOriginY, m_label.c_str(), m_size.x - 2*paddingSize);
AddOObject(tmpText, "LabelText"); AddOObject(tmpText, "LabelText");
/*
// Regenerate the event Area:
EventAreaRemoveAll();
coord origin;
coord size;
origin.x = tmpOriginX;
origin.y = tmpOriginY;
size.x = m_minSize.x;
size.y = m_minSize.y;
AddEventArea(origin, size, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventLabelPressed);
*/
} }
} }
bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y) bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
{ {
EWOL_DEBUG("Event on Label ..."); //EWOL_DEBUG("Event on Label ...");
if (1 == IdInput) { if (1 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
// nothing to do ... // nothing to do ...
@ -135,16 +124,3 @@ bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etk
} }
/*
bool ewol::Label::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y)
{
bool eventIsOK = false;
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
if(ewolEventLabelPressed == generateEventId) {
EWOL_INFO("LBL pressed ... " << m_label);
//ewol::widgetManager::FocusKeep(this);
}
return eventIsOK;
}
*/

View File

@ -135,5 +135,9 @@ bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkF
int32_t rawID = (y - m_origin.y) / (minHeight + 2*m_paddingSizeY); int32_t rawID = (y - m_origin.y) / (minHeight + 2*m_paddingSizeY);
//EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");"); //EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");");
return OnItemEvent(IdInput, typeEvent, 0, rawID, x, y); bool isUsed = OnItemEvent(IdInput, typeEvent, 0, rawID, x, y);
if (true == isUsed) {
ewol::widgetManager::FocusKeep(this);
}
return isUsed;
} }

View File

@ -30,6 +30,7 @@
#include <ewol/widget/List.h> #include <ewol/widget/List.h>
#include <ewol/widget/Spacer.h> #include <ewol/widget/Spacer.h>
#include <ewol/widget/Label.h> #include <ewol/widget/Label.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/WidgetManager.h> #include <ewol/WidgetManager.h>
//#include <etk/Vector.h> //#include <etk/Vector.h>
#include <etk/VectorType.h> #include <etk/VectorType.h>
@ -314,6 +315,7 @@ class FileChooserFileList : public ewol::List
extern const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel"; extern const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel";
extern const char * const ewolEventFileChooserValidate = "ewol-event-file-chooser-validate"; extern const char * const ewolEventFileChooserValidate = "ewol-event-file-chooser-validate";
extern const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files";
ewol::FileChooser::FileChooser(void) ewol::FileChooser::FileChooser(void)
@ -325,8 +327,10 @@ ewol::FileChooser::FileChooser(void)
m_widgetValidateId = -1; m_widgetValidateId = -1;
m_widgetCancelId = -1; m_widgetCancelId = -1;
m_widgetCurrentFolderId = -1; m_widgetCurrentFolderId = -1;
m_widgetCurrentFileNameId = -1;
m_widgetListFolderId = -1; m_widgetListFolderId = -1;
m_widgetListFileId = -1; m_widgetListFileId = -1;
m_widgetCheckBoxId = -1;
m_hasSelectedFile = false; m_hasSelectedFile = false;
ewol::SizerVert * mySizerVert = NULL; ewol::SizerVert * mySizerVert = NULL;
@ -337,6 +341,7 @@ ewol::FileChooser::FileChooser(void)
FileChooserFileList * myListFile = NULL; FileChooserFileList * myListFile = NULL;
FileChooserFolderList * myListFolder = NULL; FileChooserFolderList * myListFolder = NULL;
ewol::Label * myLabel = NULL; ewol::Label * myLabel = NULL;
ewol::CheckBox * myCheckBox = NULL;
#ifdef __PLATFORM__Android #ifdef __PLATFORM__Android
m_folder = "/mnt/sdcard/"; m_folder = "/mnt/sdcard/";
SetDisplayRatio(0.90); SetDisplayRatio(0.90);
@ -344,6 +349,7 @@ ewol::FileChooser::FileChooser(void)
m_folder = "/home/"; m_folder = "/home/";
SetDisplayRatio(0.80); SetDisplayRatio(0.80);
#endif #endif
m_file = "";
mySizerVert = new ewol::SizerVert(); mySizerVert = new ewol::SizerVert();
mySizerVert->LockExpendContamination(true); mySizerVert->LockExpendContamination(true);
@ -354,12 +360,29 @@ ewol::FileChooser::FileChooser(void)
m_widgetTitleId = myLabel->GetWidgetId(); m_widgetTitleId = myLabel->GetWidgetId();
mySizerVert->SubWidgetAdd(myLabel); mySizerVert->SubWidgetAdd(myLabel);
myEntry = new ewol::Entry("~/"); mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
myLabel = new ewol::Label("Folder : ");
myLabel->SetFillY(true);
mySizerHori->SubWidgetAdd(myLabel);
myEntry = new ewol::Entry(m_folder);
m_widgetCurrentFolderId = myEntry->GetWidgetId(); m_widgetCurrentFolderId = myEntry->GetWidgetId();
myEntry->SetExpendX(true); myEntry->SetExpendX(true);
myEntry->SetFillX(true); myEntry->SetFillX(true);
myEntry->SetWidth(200); myEntry->SetWidth(200);
mySizerVert->SubWidgetAdd(myEntry); mySizerHori->SubWidgetAdd(myEntry);
mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
myLabel = new ewol::Label("File Name : ");
myLabel->SetFillY(true);
mySizerHori->SubWidgetAdd(myLabel);
myEntry = new ewol::Entry(m_file);
m_widgetCurrentFileNameId = myEntry->GetWidgetId();
myEntry->SetExpendX(true);
myEntry->SetFillX(true);
myEntry->SetWidth(200);
mySizerHori->SubWidgetAdd(myEntry);
mySizerHori = new ewol::SizerHori(); mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori); mySizerVert->SubWidgetAdd(mySizerHori);
@ -390,6 +413,11 @@ ewol::FileChooser::FileChooser(void)
mySizerHori = new ewol::SizerHori(); mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori); mySizerVert->SubWidgetAdd(mySizerHori);
myCheckBox = new ewol::CheckBox("Show hiden files");
m_widgetCheckBoxId = myCheckBox->GetWidgetId();
myCheckBox->ExternLinkOnEvent(ewolEventCheckBoxClicked, GetWidgetId(), ewolEventFileChooserHidenFileChange);
myCheckBox->SetValue(false);
mySizerHori->SubWidgetAdd(myCheckBox);
mySpacer = new ewol::Spacer(); mySpacer = new ewol::Spacer();
mySpacer->SetExpendX(true); mySpacer->SetExpendX(true);
mySizerHori->SubWidgetAdd(mySpacer); mySizerHori->SubWidgetAdd(mySpacer);
@ -446,6 +474,16 @@ void ewol::FileChooser::SetFolder(etk::String folder)
UpdateCurrentFolder(); UpdateCurrentFolder();
} }
void ewol::FileChooser::SetFileName(etk::String filename)
{
m_file = filename;
ewol::Entry * tmpWidget = (ewol::Entry*)ewol::widgetManager::Get(m_widgetCurrentFileNameId);
if (NULL == tmpWidget) {
return;
}
tmpWidget->SetValue(filename);
}
bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y) bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
@ -454,6 +492,10 @@ bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * gener
if (ewolEventFileChooserCancel == generateEventId) { if (ewolEventFileChooserCancel == generateEventId) {
//==> Auto remove ... //==> Auto remove ...
} else if (ewolEventFileChooserHidenFileChange == generateEventId) {
// regenerate the display ...
UpdateCurrentFolder();
return true;
} else if (ewolEventFileChooserSelectFolder == generateEventId) { } else if (ewolEventFileChooserSelectFolder == generateEventId) {
//==> this is an internal event ... //==> this is an internal event ...
FileChooserFolderList * myListFolder = (FileChooserFolderList *)ewol::widgetManager::Get(m_widgetListFolderId); FileChooserFolderList * myListFolder = (FileChooserFolderList *)ewol::widgetManager::Get(m_widgetListFolderId);
@ -472,17 +514,16 @@ bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * gener
if (m_folder != "/" ) { if (m_folder != "/" ) {
m_folder += "/"; m_folder += "/";
} }
SetFileName("");
UpdateCurrentFolder(); UpdateCurrentFolder();
m_hasSelectedFile = false; m_hasSelectedFile = false;
return true; return true;
} else if (ewolEventFileChooserSelectFile == generateEventId) { } else if (ewolEventFileChooserSelectFile == generateEventId) {
m_hasSelectedFile = true; m_hasSelectedFile = true;
FileChooserFileList * myListFile = (FileChooserFileList *)ewol::widgetManager::Get(m_widgetListFileId); FileChooserFileList * myListFile = (FileChooserFileList *)ewol::widgetManager::Get(m_widgetListFileId);
m_file = myListFile->GetSelectedLine(); etk::String file = myListFile->GetSelectedLine();
SetFileName(file);
} else if (ewolEventFileChooserValidateFile == generateEventId) { } else if (ewolEventFileChooserValidateFile == generateEventId) {
m_hasSelectedFile = true;
FileChooserFileList * myListFile = (FileChooserFileList *)ewol::widgetManager::Get(m_widgetListFileId);
m_file = myListFile->GetSelectedLine();
// select the File ==> generate a validate // select the File ==> generate a validate
return GenEventInputExternal(ewolEventFileChooserValidate, x, y);; return GenEventInputExternal(ewolEventFileChooserValidate, x, y);;
} else if (ewolEventFileChooserValidate == generateEventId && false == m_hasSelectedFile) { } else if (ewolEventFileChooserValidate == generateEventId && false == m_hasSelectedFile) {
@ -498,9 +539,17 @@ void ewol::FileChooser::UpdateCurrentFolder(void)
FileChooserFileList * myListFile = (FileChooserFileList *)ewol::widgetManager::Get(m_widgetListFileId); FileChooserFileList * myListFile = (FileChooserFileList *)ewol::widgetManager::Get(m_widgetListFileId);
FileChooserFolderList * myListFolder = (FileChooserFolderList *)ewol::widgetManager::Get(m_widgetListFolderId); FileChooserFolderList * myListFolder = (FileChooserFolderList *)ewol::widgetManager::Get(m_widgetListFolderId);
ewol::Entry * myEntry = (ewol::Entry *)ewol::widgetManager::Get(m_widgetCurrentFolderId); ewol::Entry * myEntry = (ewol::Entry *)ewol::widgetManager::Get(m_widgetCurrentFolderId);
ewol::CheckBox * myhidenFiles = (ewol::CheckBox *)ewol::widgetManager::Get(m_widgetCheckBoxId);
myListFile->ClearElements(); myListFile->ClearElements();
myListFolder->ClearElements(); myListFolder->ClearElements();
bool ShowHidenFile = true;
if (NULL != myhidenFiles) {
ShowHidenFile = myhidenFiles->GetValue();
} else {
EWOL_ERROR("Can not get the hiden property of the file choozer...");
}
myEntry->SetValue(m_folder); myEntry->SetValue(m_folder);
myListFolder->AddElement(etk::String(".")); myListFolder->AddElement(etk::String("."));
@ -513,17 +562,24 @@ void ewol::FileChooser::UpdateCurrentFolder(void)
while ((ent = readdir(dir)) != NULL) { while ((ent = readdir(dir)) != NULL) {
etk::String tmpString(ent->d_name); etk::String tmpString(ent->d_name);
if (DT_REG == ent->d_type) { if (DT_REG == ent->d_type) {
if (tmpString.c_str()[0] != '.' || true==ShowHidenFile)
{
myListFile->AddElement(tmpString); myListFile->AddElement(tmpString);
}
} else if (DT_DIR == ent->d_type) { } else if (DT_DIR == ent->d_type) {
if (tmpString != "." && tmpString != "..") { if (tmpString != "." && tmpString != "..") {
if (tmpString.c_str()[0] != '.' || true==ShowHidenFile)
{
myListFolder->AddElement(tmpString); myListFolder->AddElement(tmpString);
} }
} }
} }
}
closedir(dir); closedir(dir);
} else { } else {
EWOL_ERROR("could not open directory : \"" << m_folder << "\""); EWOL_ERROR("could not open directory : \"" << m_folder << "\"");
} }
MarkToReedraw();
} }

View File

@ -43,6 +43,7 @@ namespace ewol {
void SetValidateLabel(etk::String label); void SetValidateLabel(etk::String label);
void SetCancelLabel(etk::String label); void SetCancelLabel(etk::String label);
void SetFolder(etk::String folder); void SetFolder(etk::String folder);
void SetFileName(etk::String filename);
etk::String GetCompleateFileName(void); etk::String GetCompleateFileName(void);
void UpdateCurrentFolder(void); void UpdateCurrentFolder(void);
private: private:
@ -50,8 +51,10 @@ namespace ewol {
int32_t m_widgetValidateId; int32_t m_widgetValidateId;
int32_t m_widgetCancelId; int32_t m_widgetCancelId;
int32_t m_widgetCurrentFolderId; int32_t m_widgetCurrentFolderId;
int32_t m_widgetCurrentFileNameId;
int32_t m_widgetListFolderId; int32_t m_widgetListFolderId;
int32_t m_widgetListFileId; int32_t m_widgetListFileId;
int32_t m_widgetCheckBoxId;
bool m_hasSelectedFile; bool m_hasSelectedFile;
etk::String m_folder; etk::String m_folder;
etk::String m_file; etk::String m_file;

View File

@ -159,20 +159,26 @@ void ewol::Keyboard::SetMode(keyboardMode_te mode)
mySizerHori = new ewol::SizerHori(); mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori); mySizerVert->SubWidgetAdd(mySizerHori);
ADD_BUTTON(mySizerHori,myButton,"Hide",ewolEventKeyboardHide); ADD_BUTTON(mySizerHori,myButton,"Hide",ewolEventKeyboardHide);
myButton->SetExpendX(false);
ADD_BUTTON(mySizerHori,myButton,"Ctrl",ewolEventKeyEvent); ADD_BUTTON(mySizerHori,myButton,"Ctrl",ewolEventKeyEvent);
myButton->SetExpendX(false);
ADD_BUTTON(mySizerHori,myButton,"Pomme",ewolEventKeyEvent); ADD_BUTTON(mySizerHori,myButton,"Pomme",ewolEventKeyEvent);
myButton->SetExpendX(false);
ADD_BUTTON(mySizerHori,myButton,"Alt",ewolEventKeyEvent); ADD_BUTTON(mySizerHori,myButton,"Alt",ewolEventKeyEvent);
myButton->SetExpendX(false);
ADD_BUTTON(mySizerHori,myButton," ",ewolEventKeyEvent); ADD_BUTTON(mySizerHori,myButton," ",ewolEventKeyEvent);
ADD_BUTTON(mySizerHori,myButton,"AltGr",ewolEventKeyEvent); ADD_BUTTON(mySizerHori,myButton,"AltGr",ewolEventKeyEvent);
myButton->SetExpendX(false);
ADD_BUTTON(mySizerHori,myButton,"Ctrl",ewolEventKeyEvent); ADD_BUTTON(mySizerHori,myButton,"Ctrl",ewolEventKeyEvent);
myButton->SetExpendX(false);
} }
bool ewol::Keyboard::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y) bool ewol::Keyboard::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
{ {
EWOL_INFO("Receive Event from the Keyboard ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> internalEvent=\"" << eventExternId << "\"" ); EWOL_INFO("Receive Event from the Keyboard ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> internalEvent=\"" << data << "\"" );
if (ewolEventKeyEvent == eventExternId) { if (ewolEventKeyEvent == generateEventId) {
ewol::Button * bt = (ewol::Button *)ewol::widgetManager::Get(widgetID); ewol::Button * bt = (ewol::Button *)ewol::widgetManager::Get(widgetID);
EWOL_DEBUG("kbevent : \"" << bt->GetLabel() << "\""); EWOL_DEBUG("kbevent : \"" << bt->GetLabel() << "\"");
etk::String data = bt->GetLabel(); etk::String data = bt->GetLabel();
@ -189,7 +195,7 @@ bool ewol::Keyboard::OnEventAreaExternal(int32_t widgetID, const char * generate
guiAbstraction::SendKeyboardEvent(true, data); guiAbstraction::SendKeyboardEvent(true, data);
guiAbstraction::SendKeyboardEvent(false, data); guiAbstraction::SendKeyboardEvent(false, data);
return true; return true;
} else if (ewolEventKeyboardHide == eventExternId) { } else if (ewolEventKeyboardHide == generateEventId) {
Hide(); Hide();
ewol::ForceRedrawAll(); ewol::ForceRedrawAll();
} }