Commits

Morel Bérenger  committed d2040ab

MenuEngine library enhancements and some gui adds

Added a wxMenuConverter class to encapsulate wxWidgets dumb stuff
Created a splash screen
Menus read themselves from a directory tree

  • Participants
  • Parent commits a5fc959

Comments (0)

Files changed (21)

File autorealm.workspace

 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 <CodeBlocks_workspace_file>
 	<Workspace title="Workspace">
-		<Project filename="src/autorealm.cbp" active="1">
+		<Project filename="src/autorealm.cbp">
 			<Depends filename="src/pluginEngine.cbp" />
 			<Depends filename="src/renderEngine.cbp" />
 			<Depends filename="src/plugins/core/PolyLine.cbp" />
 			<Depends filename="src/plugins/core/Line.cbp" />
+			<Depends filename="src/menuEngine.cbp" />
 		</Project>
 		<Project filename="src/pluginEngine.cbp" />
-		<Project filename="src/renderEngine.cbp" />
+		<Project filename="src/renderEngine.cbp" active="1" />
 		<Project filename="src/plugins/core/PolyLine.cbp">
 			<Depends filename="src/pluginEngine.cbp" />
 		</Project>

File src/autorealm.cbp

 				<Linker>
 					<Add option="-pg" />
 					<Add library="renderEngine-d" />
+					<Add library="menuEngine-d" />
 					<Add library="pluginEngine-d" />
 					<Add directory="../bin/debug" />
 				</Linker>
 					<Add option="-s" />
 					<Add library="renderEngine" />
 					<Add library="pluginEngine" />
+					<Add library="menuEngine" />
 					<Add directory="../bin/release" />
 				</Linker>
 			</Target>

File src/gui/MainFrame.cpp

 #include <functional>
 #include <algorithm>
 
+#include <boost/filesystem.hpp>
+
 #include "RenderWindow.h"
-#include <pluginEngine/container.h>
+//#include <pluginEngine/container.h>
 
 const long MainFrame::ID_NOTEBOOK = wxNewId();
 const long MainFrame::ID_MENUQUIT = wxNewId();
 
 MainFrame::~MainFrame(void)
 {
-	for(auto &i:m_items)//!\todo find a way to let unique_ptr<> do the delete job when destroyed by vector's destruction
-		i.reset();
+//	for(auto &i:m_items)//!\todo find a way to let unique_ptr<> do the delete job when destroyed by vector's destruction
+//		i.reset();
 
 	m_auiManager.UnInit();
 }
 
 MainFrame::MainFrame(wxWindow *parent,wxWindowID id,std::string const &title)
-:wxFrame(parent,id,title)
+:wxFrame(parent,id,title),m(boost::filesystem::path(AppConfig::buildPath(AppConfig::INFO::PLUGINS)),this)
 {
     wxMenu* MenuFile;
     wxMenuItem* MenuItemExit;
     m_auiManager.AddPane(m_auiNotebookWorkspace, wxAuiPaneInfo().Name(_T("Workspace")).Caption(_("Workspace")).CaptionVisible(false).CloseButton(false).Center());
     m_auiManager.Update();
 
-//add menu entry File->Exit
-    m_MenuBar = new wxMenuBar();
-	SetMenuBar(m_MenuBar);
-
-    MenuFile = new wxMenu();
-    m_MenuBar->Append(MenuFile, _("&File"));
-    MenuItemExit = new wxMenuItem(MenuFile, ID_MENUQUIT, _("&Exit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
-    MenuFile->Append(MenuItemExit);
-	Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::onQuit, this, ID_MENUQUIT);
-
-//add all plug-ins entries
-	m_actionPlugIn.acceptProviderType<ItemProvider>();
-	m_actionPlugIn.loadFromFolder("plugin");
-	m_actionPlugIn.getProviders(m_actionProviders);
-
-	m_items.reserve(m_actionProviders.size());
-	std::transform(m_actionProviders.begin(),m_actionProviders.end(),std::inserter(m_items,m_items.begin()),
-					[](ItemProvider *ita)
-					{return std::unique_ptr<Item>(ita->create());});
-
-	//!\todo use algorithms (for_each and transform) instead of for loops
-	for(auto &i:m_items)
-		registerItem(i);
-
-	for(auto p:m_containers)
-		m_auiManager.AddPane(p.second.first,p.second.second);
+////add menu entry File->Exit
+//    m_MenuBar = new wxMenuBar();
+//	SetMenuBar(m_MenuBar);
+//
+//    MenuFile = new wxMenu();
+//    m_MenuBar->Append(MenuFile, _("&File"));
+//    MenuItemExit = new wxMenuItem(MenuFile, ID_MENUQUIT, _("&Exit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
+//    MenuFile->Append(MenuItemExit);
+//	Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::onQuit, this, ID_MENUQUIT);
+//
+////add all plug-ins entries
+//	m_actionPlugIn.acceptProviderType<ItemProvider>();
+//	m_actionPlugIn.loadFromFolder("plugin");
+//	m_actionPlugIn.getProviders(m_actionProviders);
+//
+//	m_items.reserve(m_actionProviders.size());
+//	std::transform(m_actionProviders.begin(),m_actionProviders.end(),std::inserter(m_items,m_items.begin()),
+//					[](ItemProvider *ita)
+//					{return std::unique_ptr<Item>(ita->create());});
+//
+//	//!\todo use algorithms (for_each and transform) instead of for loops
+//	for(auto &i:m_items)
+//		registerItem(i);
+//
+//	for(auto p:m_containers)
+//		m_auiManager.AddPane(p.second.first,p.second.second);
 
 	m_auiManager.Update();
 }
 
-void MainFrame::registerItem(std::unique_ptr<Item> &item)
-{
-	auto id=item->m_id;
-	item->readConfig();
-	wxMenu *lastMenu=item->createMenu(this);
-//TODO make this function doing something
-	std::string name=item->m_path.back().getName();
-
-	if(m_containers.find(name)==m_containers.end())
-		m_containers[name].createToolbar(name,this);
-
-	m_containers[name].createItem(item->m_toolbarItem,id);
-	static_cast<MenuData>(item->m_toolbarItem).addTo(lastMenu, id);
-
-	Bind(wxEVT_COMMAND_MENU_SELECTED,&MainFrame::changeLeftAction,this,id,id);
-}
+//void MainFrame::registerItem(std::unique_ptr<Item> &item)
+//{
+//	auto id=item->m_id;
+//	item->readConfig();
+//	wxMenu *lastMenu=item->createMenu(this);
+////TODO make this function doing something
+//	std::string name=item->m_path.back().getName();
+//
+//	if(m_containers.find(name)==m_containers.end())
+//		m_containers[name].createToolbar(name,this);
+//
+//	m_containers[name].createItem(item->m_toolbarItem,id);
+//	static_cast<MenuData>(item->m_toolbarItem).addTo(lastMenu, id);
+//
+//	Bind(wxEVT_COMMAND_MENU_SELECTED,&MainFrame::changeLeftAction,this,id,id);
+//}
 
 void MainFrame::onQuit(wxCommandEvent& event)
 {
     Close();
 }
 
-void MainFrame::changeLeftAction(wxCommandEvent& ev)
-{
-	static ITEM_CALLBACK s_actualCallback=0;
-	static Item *s_actualItem=0;
-
-	if(s_actualCallback)
-		(*m_active)->Unbind(wxEVT_LEFT_DOWN, s_actualCallback, s_actualItem);
-
-//!\todo replace that with find_if
-	auto it=m_items.begin();
-	for(;it!=m_items.end();++it)
-		if((*it)->m_id==ev.GetId())
-			break;
-
-//	auto it=std::find_if(m_items.begin(),m_items.end(),
-//						std::bind2nd(std::mem_fun_ref<bool,Item,wxEvent&>(&Item::test),ev)
-//						);
-
-	if(it==m_items.end())
-		throw std::runtime_error("item not found");
-	s_actualItem=&(**it);
-	s_actualCallback=s_actualItem->m_callback;
-	(*m_active)->Bind(wxEVT_LEFT_DOWN, s_actualCallback, s_actualItem);
-}
+//void MainFrame::changeLeftAction(wxCommandEvent& ev)
+//{
+//	static ITEM_CALLBACK s_actualCallback=0;
+//	static Item *s_actualItem=0;
+//
+//	if(s_actualCallback)
+//		(*m_active)->Unbind(wxEVT_LEFT_DOWN, s_actualCallback, s_actualItem);
+//
+////!\todo replace that with find_if
+//	auto it=m_items.begin();
+//	for(;it!=m_items.end();++it)
+//		if((*it)->m_id==ev.GetId())
+//			break;
+//
+////	auto it=std::find_if(m_items.begin(),m_items.end(),
+////						std::bind2nd(std::mem_fun_ref<bool,Item,wxEvent&>(&Item::test),ev)
+////						);
+//
+//	if(it==m_items.end())
+//		throw std::runtime_error("item not found");
+//	s_actualItem=&(**it);
+//	s_actualCallback=s_actualItem->m_callback;
+//	(*m_active)->Bind(wxEVT_LEFT_DOWN, s_actualCallback, s_actualItem);
+//}

File src/gui/MainFrame.h

 #include <wx/wx.h>
 #include <wx/aui/aui.h>
 
-#include "../pluginEngine/item.h"
+//#include <pluginEngine/item.h>
 #include "appconfig.h"
+#include <menuEngine/menubar.h>
 
 class RenderWindow;
-class ToolbarItem;
-class ToolBar;
+//class ToolbarItem;
+//class ToolBar;
 
 class MainFrame : public wxFrame
 {
     static const long ID_NOTEBOOK;
     static const long ID_MENUQUIT;
 
-	std::vector<ItemProvider * > m_actionProviders;
-	std::vector<std::unique_ptr<Item>> m_items;
-    std::vector<std::unique_ptr<Item>>::iterator m_selected;
-	pluma::Pluma m_actionPlugIn;
-	std::map<std::string,Container > m_containers;
+//	std::vector<ItemProvider * > m_actionProviders;
+//	std::vector<std::unique_ptr<Item>> m_items;
+//    std::vector<std::unique_ptr<Item>>::iterator m_selected;
+//	pluma::Pluma m_actionPlugIn;
+//	std::map<std::string,Container > m_containers;
 
 public:
     /** \brief build the window and load plug-ins
     ~MainFrame(void);
 
 protected:
-	void registerItem(std::unique_ptr<Item> &item);
+//	void registerItem(std::unique_ptr<Item> &item);
 private:
     /** \brief Exit the application
      * \param event wxCommandEvent&
      */
     void onQuit(wxCommandEvent& event);
+    MenuBar m;
 };
 #endif

File src/gui/splash.cpp

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #include "splash.h"
 
 #include <wx/sizer.h>

File src/gui/splash.h

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #ifndef SPLASH_H
 #define SPLASH_H
 

File src/menuEngine.cbp

 		<Option virtualFolders="source/;header/;" />
 		<Build>
 			<Target title="Debug">
-				<Option output="../bin/debug/menuEngine" prefix_auto="1" extension_auto="1" />
+				<Option output="../bin/debug/menuEngine-d" prefix_auto="1" extension_auto="1" />
 				<Option object_output="../obj/debug/menuEngine" />
 				<Option type="3" />
 				<Option compiler="gcc" />
 		</Build>
 		<Compiler>
 			<Add option="-Wall" />
+			<Add option="`wx-config --cppflags`" />
 			<Add option="-fPIC" />
+			<Add directory="../src" />
 		</Compiler>
 		<Linker>
+			<Add option="`wx-config -libs aui core`" />
 			<Add library="boost_filesystem" />
 			<Add library="boost_system" />
 		</Linker>
 		<Unit filename="menuEngine/menu.h">
 			<Option virtualFolder="header/" />
 		</Unit>
-		<Unit filename="menuEngine/menubar.cpp">
+		<Unit filename="menuEngine/menuitem.cpp">
 			<Option virtualFolder="source/" />
 		</Unit>
-		<Unit filename="menuEngine/menubar.h">
+		<Unit filename="menuEngine/menuitem.h">
 			<Option virtualFolder="header/" />
 		</Unit>
-		<Unit filename="menuEngine/menuitem.cpp">
+		<Unit filename="menuEngine/wxmenuconverter.cpp">
 			<Option virtualFolder="source/" />
 		</Unit>
-		<Unit filename="menuEngine/menuitem.h">
+		<Unit filename="menuEngine/wxmenuconverter.h">
 			<Option virtualFolder="header/" />
 		</Unit>
 		<Extensions>
 			<envvars />
 			<code_completion />
 			<debugger />
+			<DoxyBlocks>
+				<comment_style block="0" line="0" />
+				<doxyfile_project />
+				<doxyfile_build />
+				<doxyfile_warnings />
+				<doxyfile_output />
+				<doxyfile_dot />
+				<general />
+			</DoxyBlocks>
 		</Extensions>
 	</Project>
 </CodeBlocks_project_file>

File src/menuEngine/item.cpp

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #include "item.h"
 
-Item::Item(boost::filesystem::path const &location)
-:MenuItem(), m_plugin()
+#include "menu.h"
+//#include <pluginEngine/plugin.h>
+
+Item::Item(boost::filesystem::path const &location, Menu *parent)
+//: m_plugin()
 {
+	init(location,parent);
 }
 
 Item::~Item()
 	//dtor
 }
 
-void Item::associate(std::unique_ptr<Plugin> target)
-{
-	m_plugin.reset(target);
-}
+//void Item::associate(std::unique_ptr<Plugin> &target)
+//{
+////	m_plugin.reset(std::move(target));
+//	m_plugin=std::move(target);
+//}

File src/menuEngine/item.h

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #ifndef ITEM_H
 #define ITEM_H
 
 
 #include "menuitem.h"
 
-class Plugin;
+//class Plugin;
+class Menu;
 
 class Item : public MenuItem
 {
 friend class Menu;
 public:
 	virtual ~Item();
-	void associate(std::unique_ptr<Plugin> target);
+//	void associate(std::unique_ptr<Plugin> &target);
 protected:
-	Item(boost::filesystem::path const &location);
+	Item(boost::filesystem::path const &location, Menu *parent);
 private:
 
 public:
 protected:
-	std::unique_ptr<Plugin> m_plugin;
+//	std::unique_ptr<Plugin> m_plugin;
 private:
 };
 

File src/menuEngine/menu.cpp

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #include "menu.h"
 
+#include <assert.h>
 #include "item.h"
 
 Menu::Menu(boost::filesystem::path const &location)
-:MenuItem()
+:Menu(location,nullptr)
 {
+}
+
+Menu::Menu(boost::filesystem::path const &location, MenuItem* parent)
+{
+	//!\pre location must exists
+	if(!boost::filesystem::exists(location))
+		throw std::runtime_error("Given location does not exists");
+	//!\pre location is a directory
+	if(!boost::filesystem::is_directory(location))
+		throw std::runtime_error("Given location is not a directory");
+
+	bool confFileFound=false;
+	boost::filesystem::path ownedFile;
 	for(auto content=boost::filesystem::directory_iterator(location);content!=boost::filesystem::directory_iterator();++content)
 	{
 		if(boost::filesystem::is_regular_file(content->path()))
 		{
 			// do the file have the same name as it's directory?
 			if(0==location.filename().string().compare(content->path().filename().string()))
-				MenuItem::init(*content);
+			{
+				ownedFile=*content;
+				confFileFound=true;
+			}
 			else
-				m_leaves.push_back(std::unique_ptr<MenuItem>(new Item(content->path())));
+				m_leaves.push_back(std::unique_ptr<MenuItem>(new Item(content->path(),this)));
 		}
 		else
-			m_leaves.push_back(std::unique_ptr<MenuItem>(new Menu(content->path())));
+			m_leaves.push_back(std::unique_ptr<MenuItem>(new Menu(content->path(),this)));
 	}
+	if(!confFileFound)
+		throw std::runtime_error("configuration file is missing");
+	init(ownedFile,parent);
 }
 
 Menu::~Menu()

File src/menuEngine/menu.h

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #ifndef MENU_H
 #define MENU_H
 
 class Menu : public MenuItem
 {
 public:
+	Menu(boost::filesystem::path const &location);
 	virtual ~Menu();
 protected:
-	Menu(boost::filesystem::path const &location);
+	Menu(boost::filesystem::path const &location, MenuItem* parent);
 private:
 public:
 protected:
-private:
 	std::vector<std::unique_ptr<MenuItem>> m_leaves;
+private:
 };
 
 #endif // MENU_H

File src/menuEngine/menubar.cpp

-#include "menubar.h"
-
-MenuBar::MenuBar(boost::filesystem::path const &location)
-:Menu(location)
-{
-}
-
-MenuBar::~MenuBar()
-{
-	//dtor
-}

File src/menuEngine/menubar.h

-#ifndef MENUBAR_H
-#define MENUBAR_H
-
-#include "menu.h"
-
-
-class MenuBar : public Menu
-{
-	public:
-		MenuBar(boost::filesystem::path const &location);
-		virtual ~MenuBar();
-	protected:
-	private:
-};
-
-#endif // MENUBAR_H

File src/menuEngine/menuitem.cpp

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #include "menuitem.h"
 
-MenuItem::MenuItem()
+#include <assert.h>
+void MenuItem::init(boost::filesystem::path const &file,MenuItem *parent)
 {
-	//ctor
+	//!\pre file must be a regular file
+	assert(boost::filesystem::is_regular_file(file));
+	m_name=file.filename().string();
+	//!\todo read name of the entry from the file
+	//!\todo read help text from the file
+	//!\todo read kind of entry from the file
+	MenuConverter::init(parent);
 }
 
 MenuItem::~MenuItem()
 {
 	//dtor
 }
-
-void MenuItem::init(boost::filesystem::path const &file)
-{
-	m_name=file.filename().string();
-}

File src/menuEngine/menuitem.h

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #ifndef MENUITEM_H
 #define MENUITEM_H
 
 #include <string>
-
 #include <boost/filesystem.hpp>
 
-class MenuItem
+#include "wxmenuconverter.h"
+
+class MenuItem: public MenuConverter
 {
 	public:
 		virtual ~MenuItem();
+		std::string getName(void)const{return m_name;}
+		std::string getHelp(void)const{return m_help;}
 	protected:
-		MenuItem(void);
-		void init(boost::filesystem::path const &file);
+		void init(boost::filesystem::path const &file, MenuItem *parent);
 	private:
 		std::string m_name;
+		std::string m_help;
 };
 
 #endif // MENUITEM_H

File src/menuEngine/wxmenuconverter.cpp

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
+#include "wxmenuconverter.h"
+
+#include <wx/menu.h>
+#include <wx/menuitem.h>
+
+#include "item.h"
+#include "menubar.h"
+#include "menu.h"
+#include "menuitem.h"
+
+#include <assert.h>
+
+void MenuConverter::init(MenuConverter *parent)
+{
+	//!\todo find a way to check at compilation that (*this) is of the good type.
+	//!\pre type of *this is Menu or Item
+	assert(typeid(*this)==typeid(Menu) || typeid(*this)==typeid(Item));//, "(*this)'s type can only be Menu or Item");
+	//!\pre parent must be a Menu
+	assert(typeid(*parent)==typeid(Menu));//, "(*parent)'s type can only be Menu");
+	//!\pre Item can not be added to a menubar
+	assert(typeid(*this)==typeid(Menu) || (parent!=nullptr && false==parent->m_isMenuBar));//, "Item can not be added to a root Menu (aka: menubar. WxWidget's limitation)");
+
+	if(nullptr==parent)
+	{
+		m_content.menubar=new wxMenuBar();
+		m_isMenuBar=true;
+	}
+	else
+	{
+		//create Menu or Item
+		if(typeid(*this)==typeid(Menu))
+			m_content.menu=new wxMenu(getName()); //!\todo implement style
+		else
+			m_content.menuitem=new wxMenuItem(parent->m_content.menu, wxNewId(),getName(),getHelp(),wxITEM_NORMAL);
+
+		if(parent->m_isMenuBar)
+			parent->m_content.menubar->Append(m_content.menu, getName());// it is only possible to add menu to menubars
+		else
+		{
+			if(typeid(*this)==typeid(Menu))
+				parent->m_content.menu->AppendSubMenu(m_content.menu,getName(),getHelp());
+			else
+				parent->m_content.menu->Append(m_content.menuitem);
+		}
+
+	}
+}
+
+MenuConverter::~MenuConverter()
+{
+	//dtor
+}
+
+MenuConverter::operator wxMenuBar*(void)const
+{
+	assert(m_isMenuBar);
+	return m_content.menubar;
+}
+
+MenuConverter::operator wxMenu*(void)const
+{
+	return m_content.menu;
+}
+
+MenuConverter::operator wxMenuItem*(void)const
+{
+	return m_content.menuitem;
+}

File src/menuEngine/wxmenuconverter.h

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
+#ifndef WXMENUCONVERTER_H
+#define WXMENUCONVERTER_H
+
+#include <string>
+
+class wxMenu;
+class wxMenuBar;
+class wxMenuItem;
+
+class MenuConverter
+{
+public:
+	virtual ~MenuConverter();
+	operator wxMenuBar*(void)const;
+protected:
+	operator wxMenu*(void)const;
+	operator wxMenuItem*(void)const;
+	void init(MenuConverter *parent);
+	virtual std::string getName(void)const=0;
+	virtual std::string getHelp(void)const=0;
+private:
+private:
+	union WWxContent
+	{
+		wxMenu* menu=nullptr;
+		wxMenuBar* menubar;
+		wxMenuItem* menuitem;
+	}m_content;
+	bool m_isMenuBar=false;
+};
+
+#endif // WXMENUCONVERTER_H

File src/pluginEngine/item.cpp

 {
 }
 
-//void Item::registerIn(wxFrame *parent,std::map<std::string,Container>&containers)
-//{
-//	/**\todo move this method in MainFrame: it only use m_path, m_toolbarItem and m_id.
-//	But m_path will be moved in MainFrame
-//	MainFrame should generate m_id, because it is generated by wxWidgets and so augment dependencies of Item
-//	m_toolbarItem can be accessed with an accessor
-//	*/
-//	readConfig();
-//	wxMenu *lastMenu=createMenu(parent);
-////TODO make this function doing something
-//	std::string name=m_path.back().getName();
-//
-//	if(containers.find(name)==containers.end())
-//		containers[name].createToolbar(name,parent);
-//
-//	containers[name].createItem(m_toolbarItem,m_id);
-//	static_cast<MenuData>(m_toolbarItem).addTo(lastMenu, m_id);
-//}
+void Item::registerIn(wxFrame *parent,std::map<std::string,Container>&containers)
+{
+	/**\todo move this method in MainFrame: it only use m_path, m_toolbarItem and m_id.
+	But m_path will be moved in MainFrame
+	MainFrame should generate m_id, because it is generated by wxWidgets and so augment dependencies of Item
+	m_toolbarItem can be accessed with an accessor
+	*/
+	readConfig();
+	wxMenu *lastMenu=createMenu(parent);
+//TODO make this function doing something
+	std::string name=m_path.back().getName();
+
+	if(containers.find(name)==containers.end())
+		containers[name].createToolbar(name,parent);
+
+	containers[name].createItem(m_toolbarItem,m_id);
+	static_cast<MenuData>(m_toolbarItem).addTo(lastMenu, m_id);
+}
 
 wxMenu* Item::createMenu(wxFrame *parent)const
 {

File src/pluginEngine/item.h

 	Item(std::string const &);
 	virtual ~Item(void);
 
-//    /** \brief create controls to use a plug-in and bind it's action
-//     * The plug-in add it's controls to it's parent's lists.
-//     * The location of several things will be given by the AppConfig object
-//     *
-//     * \param parent wxFrame* container which will own the plug-in controls
-//     * \param containers std::map<std::string,Container>& list of parent's plug-in
-//     * \param appConfig AppConfig const& configuration of the application
-//     * \return void
-//     *
-//     */
-//	void registerIn(wxFrame *parent,std::map<std::string,Container>&);
+    /** \brief create controls to use a plug-in and bind it's action
+     * The plug-in add it's controls to it's parent's lists.
+     * The location of several things will be given by the AppConfig object
+     *
+     * \param parent wxFrame* container which will own the plug-in controls
+     * \param containers std::map<std::string,Container>& list of parent's plug-in
+     * \param appConfig AppConfig const& configuration of the application
+     * \return void
+     *
+     */
+	void registerIn(wxFrame *parent,std::map<std::string,Container>&);
 
     /** \brief read the plug-in's configuration
 	 *	\note the plug-in should read it's specific data before asking to Item to read common data
 	wxMenu* createMenuPath(wxMenu *parent,std::vector<MenuData>::const_iterator &it)const;
 private:
 
+
 public:
 //protected:
 	const std::string m_configFileName; //!< name of the configuration file

File src/utils/textfile.cpp

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #include "textfile.h"
 
 TextFile::TextFile(boost::filesystem::path const &file, bool create)

File src/utils/textfile.h

+/**********************************************************************************
+ *autorealm - A vectorized graphic editor to create maps, mostly for RPG games    *
+ *Copyright (C) 2012 Morel Bérenger                                               *
+ *                                                                                *
+ *This file is part of autorealm.                                                 *
+ *                                                                                *
+ *    autorealm is free software: you can redistribute it and/or modify           *
+ *    it under the terms of the GNU General Public License as published by        *
+ *    the Free Software Foundation, either version 3 of the License, or           *
+ *    (at your option) any later version.                                         *
+ *                                                                                *
+ *    autorealm is distributed in the hope that it will be useful,                *
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
+ *    GNU General Public License for more details.                                *
+ *                                                                                *
+ *    You should have received a copy of the GNU General Public License           *
+ *    along with autorealm.  If not, see <http://www.gnu.org/licenses/>.          *
+ **********************************************************************************/
+
 #ifndef TEXTFILE_H
 #define TEXTFILE_H