This commit is contained in:
Edouard Dupin 2012-01-08 22:07:39 +01:00
parent ac54987af9
commit c55dd4b4d9
11 changed files with 131 additions and 50 deletions

View File

@ -42,6 +42,7 @@
const char * ewolEventWindowsClose = "ewol Windows close";
const char * ewolEventWindowsMinimize = "ewol Windows minimize";
const char * ewolEventWindowsExpend = "ewol Windows expend/unExpend";
const char * ewolEventWindowsHideKeyboard = "ewol Windows hideKeyboard";
ewol::Windows::Windows(void)
@ -52,6 +53,8 @@ ewol::Windows::Windows(void)
SetCanHaveFocus(true);
m_subWidget = NULL;
m_popUpWidget = NULL;
m_keyBoardwidget = NULL;
m_keyboardShow = false;
// enable specific drawing system ...
SpecificDrawEnable();
@ -85,6 +88,7 @@ ewol::Windows::Windows(void)
myOObjectText->Text(62, 2, "My Title ...", m_size.x-2);
AddOObject(myOObjectText, "Title");
}
KeyboardShow(KEYBOARD_MODE_CODE);
}
ewol::Windows::~Windows(void)
@ -97,21 +101,33 @@ ewol::Windows::~Windows(void)
delete(m_popUpWidget);
m_popUpWidget=NULL;
}
if (NULL != m_keyBoardwidget) {
delete(m_keyBoardwidget);
m_keyBoardwidget=NULL;
}
}
bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
{
m_size.x = availlableX;
m_size.y = availlableY;
int32_t keyboardHigh = 0;
if (NULL != m_keyBoardwidget && true == m_keyboardShow ) {
m_keyBoardwidget->CalculateMinSize();
coord tmpSize = m_keyBoardwidget->GetMinSize();
keyboardHigh = (int32_t)tmpSize.y;
m_keyBoardwidget->SetOrigin(0, m_size.y - keyboardHigh);
m_keyBoardwidget->CalculateSize(m_size.x, keyboardHigh);
}
if (NULL != m_subWidget) {
m_subWidget->CalculateMinSize();
// TODO : Check if min Size is possible ...
// TODO : Herited from MinSize .. and expand ???
m_subWidget->CalculateSize(m_size.x, m_size.y);
m_subWidget->CalculateSize(m_size.x, m_size.y - keyboardHigh);
}
if (NULL != m_popUpWidget) {
m_popUpWidget->CalculateMinSize();
m_popUpWidget->CalculateSize(m_size.x, m_size.y);
m_popUpWidget->CalculateSize(m_size.x, m_size.y - keyboardHigh);
}
// regenerate all the display ...
OnRegenerateDisplay();
@ -137,6 +153,13 @@ bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, e
}
}
}
if (NULL != m_keyBoardwidget && true == m_keyboardShow ) {
coord tmpSize = m_keyBoardwidget->GetMinSize();
if (y > m_size.y - tmpSize.y) {
m_keyBoardwidget->GenEventInput(IdInput, typeEvent, x, y);
return true;
}
}
// event go directly on the pop-up
if (NULL != m_popUpWidget) {
m_popUpWidget->GenEventInput(IdInput, typeEvent, x, y);
@ -193,6 +216,9 @@ void ewol::Windows::OnRegenerateDisplay(void)
if (NULL != m_popUpWidget) {
m_popUpWidget->OnRegenerateDisplay();
}
if (NULL != m_keyBoardwidget && true == m_keyboardShow ) {
m_keyBoardwidget->OnRegenerateDisplay();
}
}
@ -208,9 +234,14 @@ bool ewol::Windows::OnDraw(void)
m_popUpWidget->GenDraw();
//EWOL_DEBUG("Draw Pop-up");
}
if (NULL != m_keyBoardwidget && true == m_keyboardShow ) {
m_keyBoardwidget->GenDraw();
//EWOL_DEBUG("Draw Pop-up");
}
return true;
}
bool ewol::Windows::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y)
{
bool eventIsOK = false;
@ -266,3 +297,35 @@ void ewol::Windows::PopUpWidgetPop(void)
m_popUpWidget = NULL;
}
}
bool ewol::Windows::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y)
{
EWOL_DEBUG("kjhlkjhlkjhlkjhlkhlkjhlkjhlkjhlkjhlkjhlkjh");
if(ewolEventWindowsHideKeyboard == generateEventId) {
EWOL_INFO("Request Hide keyboard");
KeyboardHide();
}
return true;
}
void ewol::Windows::KeyboardShow(ewol::keyboardMode_te mode)
{
m_keyboardShow = true;
if (NULL == m_keyBoardwidget) {
// Create the keyboard ...
m_keyBoardwidget = new ewol::Keyboard(GetWidgetId());
m_keyBoardwidget->ExternLinkOnEvent("ewol event Keyboard request hide", GetWidgetId(), ewolEventWindowsHideKeyboard );
}
CalculateSize(m_size.x, m_size.y);
OnRegenerateDisplay();
}
void ewol::Windows::KeyboardHide(void)
{
m_keyboardShow = false;
EWOL_INFO("Request Hide keyboard");
CalculateSize(m_size.x, m_size.y);
OnRegenerateDisplay();
}

View File

@ -30,8 +30,10 @@
#include <etk/VectorType.h>
#include <etk/Singleton.h>
#include <ewol/Widget.h>
#include <ewol/widgetMeta/Keyboard.h>
namespace ewol {
class Windows :public ewol::Widget
{
public:
@ -56,6 +58,7 @@ namespace ewol {
// Widget overwrite function
public:
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);
private:
bool m_hasDecoration;
public:
@ -69,8 +72,10 @@ namespace ewol {
m_hasDecoration = true;
}
private:
ewol::Widget * m_subWidget;
ewol::Widget * m_popUpWidget;
ewol::Widget* m_subWidget;
ewol::Widget* m_popUpWidget;
ewol::Keyboard* m_keyBoardwidget;
bool m_keyboardShow;
public:
void SetSubWidget(ewol::Widget * widget);
void PopUpWidgetPush(ewol::Widget * widget);
@ -79,6 +84,9 @@ namespace ewol {
virtual bool OnDraw(void);
public:
virtual void OnRegenerateDisplay(void);
public:
void KeyboardShow(ewol::keyboardMode_te mode);
void KeyboardHide(void);
};
};

View File

@ -27,7 +27,9 @@
#define __GUI_ABSTRACTION_H__
#include <etk/Types.h>
#include <etk/String.h>
#include <ewol/Windows.h>
#include <ewol/ewolInterne.h>
namespace guiAbstraction
{
@ -43,6 +45,7 @@ namespace guiAbstraction
void StartMoveSystem(void);
bool IsPressedInput(int32_t inputID);
void ForceRedrawAll(void);
void SendKeyboardEvent(bool isDown, etk::String &keyInput);
};
//!< must be define in CPP by the application ...

View File

@ -274,6 +274,7 @@ void EWOL_NativeApplicationInit(void)
{
EWOL_WARNING("Event : Init Application");
if (false == isAlreadyInit) {
guiAbstraction::Init(0, NULL);
ewol::Init(0, NULL);
APP_Init(0, NULL);
isAlreadyInit = true;
@ -287,6 +288,8 @@ void EWOL_NativeApplicationUnInit(void)
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// basic abstraction un-init
guiAbstraction::UnInit();
// uninit Ewol
ewol::UnInit();
}
@ -555,6 +558,22 @@ void guiAbstraction::ForceRedrawAll(void)
}
}
void guiAbstraction::SendKeyboardEvent(bool isDown, etk::String &keyInput)
{
// Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (NULL != tmpWidget) {
if(true == isDown) {
EWOL_DEBUG("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size());
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str());
} else {
EWOL_DEBUG("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size());
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str());
}
}
}
// never had main in android ...
/*
int main(int argc, char *argv[])

View File

@ -672,18 +672,11 @@ namespace guiAbstraction {
XComposeStatus status;
int count = XLookupString(&event.xkey, buf, 10, &keysym, &status);
buf[count] = '\0';
// Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (NULL != tmpWidget) {
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);
}
etk::String tmpData = buf;
if(event.type == KeyPress) {
SendKeyboardEvent(true, tmpData);
} else {
SendKeyboardEvent(true, tmpData);
}
break;
}
@ -911,6 +904,22 @@ void guiAbstraction::ForceRedrawAll(void)
}
}
void guiAbstraction::SendKeyboardEvent(bool isDown, etk::String &keyInput)
{
// Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (NULL != tmpWidget) {
if(true == isDown) {
EWOL_DEBUG("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size());
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str());
} else {
EWOL_DEBUG("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size());
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str());
}
}
}
#include <ewol/ewol.h>
@ -919,16 +928,19 @@ void guiAbstraction::ForceRedrawAll(void)
int main(int argc, char *argv[])
{
guiAbstraction::Init(argc, argv);
// init Ewol
ewol::Init(argc, argv);
// Init Application ...
APP_Init(argc, argv);
// Start Ewol diwplay while
ewol::Run();
guiAbstraction::Run();
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// basic abstraction un-init
guiAbstraction::UnInit();
// uninit Ewol
ewol::UnInit();

View File

@ -24,39 +24,13 @@
#include <ewol/ewol.h>
#include <ewol/Font.h>
#include <ewol/WidgetManager.h>
#include <ewol/themeManager.h>
#include <ewol/base/gui.h>
#undef __class__
#define __class__ "ewol"
void ewol::Init(int argc, char *argv[])
{
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
EWOL_INFO("Build Date: " VERSION_BUILD_TIME);
guiAbstraction::Init(argc, argv);
ewol::theme::Init();
ewol::widgetManager::Init();
ewol::InitFont();
}
void ewol::Run(void)
{
guiAbstraction::Run();
}
void ewol::UnInit(void)
{
guiAbstraction::UnInit();
ewol::UnInitFont();
ewol::widgetManager::UnInit();
ewol::theme::UnInit();
}
void ewol::DisplayWindows(ewol::Windows * windows)
{
// Remove current Focus :
@ -116,3 +90,4 @@ void ewol::ForceRedrawAll(void)
guiAbstraction::ForceRedrawAll();
}

View File

@ -31,11 +31,10 @@
#include <ewol/Widget.h>
#include <ewol/Windows.h>
namespace ewol {
void Init(int32_t argc, char *argv[]);
void Run(void);
void Stop(void);
void UnInit(void);
void DisplayWindows(ewol::Windows * windows);
void ChangeSize(int32_t w, int32_t h);
void ChangePos(int32_t x, int32_t y);

View File

@ -39,6 +39,7 @@ namespace ewol {
virtual ~Button(void);
virtual bool CalculateMinSize(void);
void SetLabel(etk::String newLabel);
etk::String GetLabel(void) {return m_label;};
// TODO :
//void SetSize(int32_t size);
//void SetFont(etk::String fontName);

View File

@ -1,7 +1,7 @@
/**
*******************************************************************************
* @file ewol/widgetMeta/FileChooser.cpp
* @brief ewol File chooser complex widget system (Sources)
* @brief ewol File chooser meta widget system (Sources)
* @author Edouard DUPIN
* @date 29/12/2011
* @par Project

View File

@ -1,7 +1,7 @@
/**
*******************************************************************************
* @file ewol/widgetMeta/FileChooser.h
* @brief ewol File chooser complex widget system (header)
* @brief ewol File chooser meta widget system (header)
* @author Edouard DUPIN
* @date 29/12/2011
* @par Project

View File

@ -1,7 +1,7 @@
FILE_LIST = \
ewol/ewol.cpp \
FILE_LIST = ewol/ewol.cpp \
ewol/ewolInterne.cpp \
ewol/Debug.cpp \
ewol/OObject.cpp \
ewol/OObject/2DText.cpp \
@ -24,6 +24,7 @@ FILE_LIST = \
ewol/widget/Spacer.cpp \
ewol/widget/Test.cpp \
ewol/widgetMeta/FileChooser.cpp \
ewol/widgetMeta/Keyboard.cpp \
ewol/themeManager.cpp \
ewol/theme/Theme.cpp \
ewol/theme/EolElement.cpp \