Menu midget generation

This commit is contained in:
Edouard Dupin 2012-02-16 23:30:37 +01:00
parent b4dba28f15
commit 3ad5f9ff83
5 changed files with 183 additions and 9 deletions

View File

@ -0,0 +1,108 @@
/**
*******************************************************************************
* @file ewol/widget/Menu.cpp
* @brief ewol Menu widget system (Sources)
* @author Edouard DUPIN
* @date 16/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/widget/Menu.h>
#include <ewol/widget/Button.h>
#undef __class__
#define __class__ "ewol::Menu"
ewol::Menu::Menu(void)
{
m_staticId = 0;
}
ewol::Menu::~Menu(void)
{
Clear();
}
void ewol::Menu::SubWidgetRemoveAll(void)
{
EWOL_ERROR("Not availlable");
}
void ewol::Menu::SubWidgetAdd(ewol::Widget* newWidget)
{
EWOL_ERROR("Not availlable");
}
void ewol::Menu::SubWidgetRemove(ewol::Widget* newWidget)
{
EWOL_ERROR("Not availlable");
}
void ewol::Menu::SubWidgetUnLink(ewol::Widget* newWidget)
{
EWOL_ERROR("Not availlable");
}
void ewol::Menu::Clear(void)
{
for( int32_t iii=0; iii < m_listElement.Size(); iii++) {
if (m_listElement[iii] != NULL) {
delete(m_listElement[iii]);
m_listElement[iii] = NULL;
}
}
m_listElement.Clear();
}
int32_t ewol::Menu::AddTitle(etk::UString label, etk::UString image, const char * generateEvent, const etk::UString message)
{
return Add(-1, label, image, generateEvent, message);
}
int32_t ewol::Menu::Add(int32_t parent, etk::UString label, etk::UString image, const char * generateEvent, const etk::UString message)
{
ewol::MenuElement * tmpObject = new ewol::MenuElement();
if (NULL == tmpObject) {
EWOL_ERROR("Allocation problem");
return -1;
}
tmpObject->m_localId = m_staticId++;
tmpObject->m_parentId = parent;
tmpObject->m_label = label;
tmpObject->m_image = image;
tmpObject->m_generateEvent = generateEvent;
tmpObject->m_message = message;
m_listElement.PushBack(tmpObject);
if (-1 == tmpObject->m_parentId) {
ewol::Button * myButton = new ewol::Button(label);
ewol::SizerHori::SubWidgetAdd(myButton);
/*
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), "event ... ") ) {
EDN_CRITICAL("link with an entry event");
}
*/
}
return tmpObject->m_localId;
}
void ewol::Menu::AddSpacer(void)
{
EWOL_TODO("NOT now...");
}

View File

@ -0,0 +1,66 @@
/**
*******************************************************************************
* @file ewol/widget/Menu.h
* @brief ewol Menu widget system (header)
* @author Edouard DUPIN
* @date 16/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_MENU_H__
#define __EWOL_MENU_H__
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/Debug.h>
#include <ewol/Widget.h>
#include <ewol/widget/SizerHori.h>
namespace ewol {
class MenuElement {
public :
int32_t m_localId;
int32_t m_parentId;
etk::UString m_label;
etk::UString m_image;
const char * m_generateEvent;
etk::UString m_message;
};
class Menu :public ewol::SizerHori
{
public:
Menu(void);
virtual ~Menu(void);
private:
virtual void SubWidgetRemoveAll(void);
virtual void SubWidgetAdd(ewol::Widget* newWidget);
virtual void SubWidgetRemove(ewol::Widget* newWidget);
virtual void SubWidgetUnLink(ewol::Widget* newWidget);
private:
etk::VectorType<MenuElement*> m_listElement;
int32_t m_staticId;
public:
void Clear(void);
int32_t AddTitle(etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = "");
int32_t Add(int32_t parent, etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = "");
void AddSpacer(void);
};
};
#endif

View File

@ -48,15 +48,14 @@ namespace ewol {
bool m_lockExpendContamination;
etk::VectorType<ewol::Widget*> m_subWidget;
public:
void SubWidgetRemoveAll(void);
void SubWidgetAdd(ewol::Widget* newWidget);
void SubWidgetRemove(ewol::Widget* newWidget);
void SubWidgetUnLink(ewol::Widget* newWidget);
virtual void SubWidgetRemoveAll(void);
virtual void SubWidgetAdd(ewol::Widget* newWidget);
virtual void SubWidgetRemove(ewol::Widget* newWidget);
virtual void SubWidgetUnLink(ewol::Widget* newWidget);
protected:
virtual bool OnDraw(void);
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
};
};

View File

@ -48,10 +48,10 @@ namespace ewol {
bool m_lockExpendContamination;
etk::VectorType<ewol::Widget*> m_subWidget;
public:
void SubWidgetRemoveAll(void);
void SubWidgetAdd(ewol::Widget* newWidget);
void SubWidgetRemove(ewol::Widget* newWidget);
void SubWidgetUnLink(ewol::Widget* newWidget);
virtual void SubWidgetRemoveAll(void);
virtual void SubWidgetAdd(ewol::Widget* newWidget);
virtual void SubWidgetRemove(ewol::Widget* newWidget);
virtual void SubWidgetUnLink(ewol::Widget* newWidget);
protected:
virtual bool OnDraw(void);
public:

View File

@ -23,6 +23,7 @@ FILE_LIST = ewol/ewol.cpp \
ewol/widget/CheckBox.cpp \
ewol/widget/Entry.cpp \
ewol/widget/List.cpp \
ewol/widget/Menu.cpp \
ewol/widget/ContextMenu.cpp \
ewol/widget/PopUp.cpp \
ewol/widget/SizerHori.cpp \