Browse Source

Merge branch 'master' into android-port

mikymod 13 years ago
parent
commit
66bc902837
69 changed files with 0 additions and 9481 deletions
  1. 0 5
      CMakeLists.txt
  2. 0 120
      samples/editor/CRWObjectModel.cpp
  3. 0 89
      samples/editor/CRWObjectModel.h
  4. 0 390
      samples/editor/Editor.cpp
  5. BIN
      samples/editor/res/arialbd.ttf
  6. BIN
      samples/editor/res/boom.bmp
  7. BIN
      samples/editor/res/closebutton_x.bmp
  8. BIN
      samples/editor/res/terrain.bmp
  9. 0 1
      samples/editor/res/testfile.txt
  10. BIN
      samples/windowing/res/arialbd.ttf
  11. BIN
      samples/windowing/res/boom.bmp
  12. BIN
      samples/windowing/res/closebutton_x.bmp
  13. 0 172
      samples/windowing/windowing.cpp
  14. 0 220
      samples/xwmlreader/XWMLReader.cpp
  15. 0 5
      src/CMakeLists.txt
  16. 0 3
      src/Crown.h
  17. 0 62
      src/core/CoreEventArgs.h
  18. 0 488
      src/core/Delegate.h
  19. 0 99
      src/core/SignalSlot.h
  20. 0 136
      src/core/WithProperties.h
  21. 0 192
      src/windowing/Bind.cpp
  22. 0 88
      src/windowing/Bind.h
  23. 0 109
      src/windowing/Button.cpp
  24. 0 63
      src/windowing/Button.h
  25. 0 76
      src/windowing/DragArea.cpp
  26. 0 60
      src/windowing/DragArea.h
  27. 0 97
      src/windowing/ImageWidget.cpp
  28. 0 56
      src/windowing/ImageWidget.h
  29. 0 98
      src/windowing/ItemsSelector.cpp
  30. 0 65
      src/windowing/ItemsSelector.h
  31. 0 61
      src/windowing/ItemsWidget.cpp
  32. 0 78
      src/windowing/ItemsWidget.h
  33. 0 141
      src/windowing/Label.cpp
  34. 0 81
      src/windowing/Label.h
  35. 0 194
      src/windowing/ListView.cpp
  36. 0 91
      src/windowing/ListView.h
  37. 0 61
      src/windowing/Property.cpp
  38. 0 121
      src/windowing/Property.h
  39. 0 83
      src/windowing/ScrollArea.cpp
  40. 0 57
      src/windowing/ScrollArea.h
  41. 0 359
      src/windowing/SpecificProperties.cpp
  42. 0 278
      src/windowing/SpecificProperties.h
  43. 0 277
      src/windowing/TextBox.cpp
  44. 0 86
      src/windowing/TextBox.h
  45. 0 68
      src/windowing/ThemeSpriteWidget.h
  46. 0 77
      src/windowing/Themes.cpp
  47. 0 78
      src/windowing/Themes.h
  48. 0 344
      src/windowing/TreeView.cpp
  49. 0 128
      src/windowing/TreeView.h
  50. 0 1072
      src/windowing/Widget.cpp
  51. 0 389
      src/windowing/Widget.h
  52. 0 178
      src/windowing/Window.cpp
  53. 0 92
      src/windowing/Window.h
  54. 0 114
      src/windowing/WindowContext.cpp
  55. 0 72
      src/windowing/WindowContext.h
  56. 0 204
      src/windowing/WindowingEventArgs.h
  57. 0 574
      src/windowing/WindowsManager.cpp
  58. 0 117
      src/windowing/WindowsManager.h
  59. 0 64
      src/windowing/layouts/CanvasLayout.cpp
  60. 0 46
      src/windowing/layouts/CanvasLayout.h
  61. 0 455
      src/windowing/layouts/StackLayout.cpp
  62. 0 61
      src/windowing/layouts/StackLayout.h
  63. 0 43
      src/windowing/templates/ITemplate.h
  64. 0 288
      src/windowing/themes/LunaTheme.cpp
  65. 0 59
      src/windowing/themes/LunaTheme.h
  66. 0 99
      src/windowing/toolbox/MessageWindow.cpp
  67. 0 63
      src/windowing/toolbox/MessageWindow.h
  68. 0 78
      src/windowing/toolbox/TextInputWindow.cpp
  69. 0 56
      src/windowing/toolbox/TextInputWindow.h

+ 0 - 5
CMakeLists.txt

@@ -25,11 +25,6 @@ set (INCLUDES
 	${CMAKE_SOURCE_DIR}/src/renderers
 	${CMAKE_SOURCE_DIR}/src/renderers
 	${CMAKE_SOURCE_DIR}/src/renderers/gl
 	${CMAKE_SOURCE_DIR}/src/renderers/gl
 	${CMAKE_SOURCE_DIR}/src/renderers/gles
 	${CMAKE_SOURCE_DIR}/src/renderers/gles
-	${CMAKE_SOURCE_DIR}/src/windowing
-	${CMAKE_SOURCE_DIR}/src/windowing/toolbox
-	${CMAKE_SOURCE_DIR}/src/windowing/themes
-	${CMAKE_SOURCE_DIR}/src/windowing/layouts
-	${CMAKE_SOURCE_DIR}/src/windowing/templates
 	${CMAKE_SOURCE_DIR}/src/network
 	${CMAKE_SOURCE_DIR}/src/network
 )
 )
 
 

+ 0 - 120
samples/editor/CRWObjectModel.cpp

@@ -1,120 +0,0 @@
-#include "CRWObjectModel.h"
-
-CRWDescriptor::CRWDescriptor(CRWObjectModel* crwObjectModel, CRWDescriptor* parent, const Crown::Descriptor& descriptor, Crown::uint offset):
-	mCRWObjectModel(crwObjectModel), mParent(parent), mChildren(NULL), mDescriptorOffset(offset)
-{
-	AddProperty(new UIntProperty("ID", &mID));
-	AddProperty(new UShortProperty("Type", &mType));
-	AddProperty(new StrProperty("Name", &mName));
-	AddProperty(new UIntProperty("ContentOffset", &mContentOffset));
-	AddProperty(new UIntProperty("ContentSize", &mContentSize));
-	AddProperty(new UShortProperty("Flags", &mFlags));
-	AddProperty(new UIntProperty("DescriptorOffset", &mDescriptorOffset));
-
-	AddProperty(new GenericListProperty("Children", &mChildrenGenericWrapper));
-
-	mID = descriptor.ID;
-	mType = descriptor.type;
-	mName = descriptor.name;
-	mContentOffset = descriptor.contentOffset;
-	mContentSize = descriptor.contentSize;
-	mDescriptorOffset = offset;
-}
-
-CRWDescriptor::~CRWDescriptor()
-{
-	delete mChildren;
-}
-
-Crown::Str CRWDescriptor::ToStr() const
-{
-	return "CRWDescriptor\"" + mName + "\"";
-}
-
-void CRWDescriptor::OnGetProperty(const Crown::Str& name)
-{
-	if (name == "Children")
-	{
-		if (mChildren == NULL)
-		{
-			GetChildren();
-			mChildrenGenericWrapper = new Crown::ListGenericWrapper<CRWDescriptor*>(mChildren);
-		}
-	}
-}
-
-Generic CRWDescriptor::GetPropertyValue(const Str& name) const
-{
-	return WithProperties::GetPropertyValue(name);
-}
-
-Crown::Str CRWDescriptor::GetFullName()
-{
-	Crown::Str name;
-	name = mName;
-	
-	if (!mParent)
-		return "/" + name;
-	else
-		return mParent->GetFullName() + "/" + name;
-}
-
-CRWObjectModel* CRWDescriptor::GetCRWObjectModel()
-{
-	return mCRWObjectModel;
-}
-
-Crown::List<CRWDescriptor*>* CRWObjectModel::LoadChildren(CRWDescriptor* crwDescriptor)
-{
-	Crown::Str path = "/";
-	if (crwDescriptor)
-	{
-		path = crwDescriptor->GetFullName();
-	}
-
-	Crown::List<CRWDescriptor*>* list = new Crown::List<CRWDescriptor*>();
-	//If seek fails, the path is not a directory and therefore there's no children
-	if (!mDecoder->Seek(path))
-		return list;
-
-	while (mDecoder->NextDescriptor())
-	{
-		const Crown::Descriptor& descriptor = mDecoder->GetDescriptor();
-		Crown::uint offset = mDecoder->GetDescriptorOffset();
-		list->Append(new CRWDescriptor(this, crwDescriptor, descriptor, offset));
-	}
-
-	return list;
-}
-
-CRWObjectModel::CRWObjectModel(Crown::CRWDecoder* decoder):
-	mDecoder(decoder), mRoot(NULL)
-{
-	GetRoot();
-}
-
-CRWObjectModel::~CRWObjectModel()
-{
-}
-
-Str CRWObjectModel::GetCRWLibraryPath()
-{
-	return mDecoder->GetLibraryPath();
-}
-
-Generic CRWObjectModel::GetPropertyValue(const Str& name) const
-{
-	if (name == "Root")
-	{
-		//This does not generate leaks because Generic stores the pointer in a Shared<>
-		return new ListGenericWrapper<CRWDescriptor*>(mRoot.GetPointer());
-	}
-	return Generic();
-}
-
-void CRWObjectModel::SetPropertyValue(const Str& name, const Generic& value)
-{
-
-}
-
-

+ 0 - 89
samples/editor/CRWObjectModel.h

@@ -1,89 +0,0 @@
-#ifndef __CRWOBJECTMODEL_H__
-#define	__CRWOBJECTMODEL_H__
-
-#include "Crown.h"
-
-using namespace Crown;
-
-class CRWObjectModel;
-
-class CRWDescriptor: public WithProperties
-{
-public:
-	CRWDescriptor(CRWObjectModel* crwObjectModel, CRWDescriptor* parent, const Descriptor& descriptor, uint offset);
-	virtual ~CRWDescriptor();
-
-	const List<CRWDescriptor*>& GetChildren();
-
-	Str GetFullName();
-	CRWObjectModel* GetCRWObjectModel();
-	inline ushort GetType()
-	 { return mType; }
-
-	Str ToStr() const;
-
-	virtual void OnGetProperty(const Str& name);
-
-	virtual Generic GetPropertyValue(const Str& name) const;
-
-
-private:
-	CRWObjectModel* mCRWObjectModel;
-	CRWDescriptor* mParent;
-	List<CRWDescriptor*>* mChildren;
-	Shared<IList<Generic> > mChildrenGenericWrapper;
-
-	//Descriptor Properties
-	uint mID;
-	ushort mType;
-	Str mName;
-	uint mContentOffset;
-	uint mContentSize;
-	//TODO: Use uchar
-	ushort mFlags;
-	uint mDescriptorOffset;
-
-	friend class CRWObjectModel;
-};
-
-class CRWObjectModel: public IWithProperties
-{
-public:
-	CRWObjectModel(CRWDecoder* decoder);
-	virtual ~CRWObjectModel();
-
-	inline const IList<CRWDescriptor*>* GetRoot()
-	{
-		if (mRoot.IsNull())
-			mRoot = LoadChildren(NULL);
-		return mRoot.GetPointer();
-	}
-
-	Str GetCRWLibraryPath();
-
-	virtual Generic GetPropertyValue(const Str& name) const;
-	virtual void SetPropertyValue(const Str& name, const Generic& value);
-
-	virtual Str ToStr() const
-	{
-		return "CRWObjectModel";
-	}
-
-private:
-	CRWDecoder* mDecoder;
-	Shared<IList<CRWDescriptor*> > mRoot;
-
-	List<CRWDescriptor*>* LoadChildren(CRWDescriptor* descriptor);
-
-	friend class CRWDescriptor;
-};
-
-inline const List<CRWDescriptor*>& CRWDescriptor::GetChildren()
-{
-	if (!mChildren)
-		mChildren = mCRWObjectModel->LoadChildren(this);
-	return *mChildren;
-}
-
-#endif	/* __CRWOBJECTMODEL_H__ */
-

+ 0 - 390
samples/editor/Editor.cpp

@@ -1,390 +0,0 @@
-#include "Crown.h"
-#include "CRWObjectModel.h"
-#include <cstdlib>
-#include <iostream>
-
-using namespace Crown;
-
-class WndCtrl: public KeyboardListener
-{
-public:
-
-	WndCtrl()
-	{
-		GetDevice()->GetInputManager()->RegisterKeyboardListener(this);
-	}
-
-	virtual void KeyReleased(const KeyboardEvent& event)
-	{
-		if (event.key == KC_ESCAPE)
-		{
-			GetDevice()->StopRunning();
-		}
-	}
-};
-
-void LoadXWMLAndLogResponse(WindowsManager* windowsManager, Str xwmlFile, WindowContext* context)
-{
-	XWMLReader xwml;
-	Window* window;
-
-	Filesystem* fs = GetFilesystem();
-	FilesystemEntry info;
-	if (!fs->GetInfo(xwmlFile, info))
-	{
-		MessageWindow* mw = new MessageWindow(windowsManager, "Load XWML", "Could not find file '" + xwmlFile + "'", MWR_OK, NULL);
-		windowsManager->DoModalWindow(mw);
-		return;
-	}
-
-	window = xwml.LoadFile(xwmlFile, windowsManager, context);
-
-	if (window == NULL)
-		Log::E("Could not load XWML file '" + info.osPath + "'");
-	else
-		Log::I("Successfully loaded XWML file '" + info.osPath + "'");
-}
-
-class CRWUtils
-{
-	public:
-		static void CreateExampleCRW(Str crwFilePath)
-		{
-			CRWDecoder mDecoder;
-
-			Stream* testimage = GetFilesystem()->OpenStream("res/terrain.bmp", SOM_READ);
-			//FileStream* testfile = new FileStream("../../res/testfile.txt", SOM_READ);
-			Stream* testfile = GetFilesystem()->OpenStream("res/testfile.txt", SOM_READ);
-
-			mDecoder.New(crwFilePath);
-
-			mDecoder.AddRawData("/", "file 1.txt", testfile, RF_NORMAL);
-			testfile->Seek(0, SM_SeekFromBegin);
-
-			mDecoder.AddDirectory("/", "docs");
-
-			mDecoder.AddRawData("/docs", "file 2.txt", testfile, RF_NORMAL);
-			testfile->Seek(0, SM_SeekFromBegin);
-
-			mDecoder.AddDirectory("/docs", "images");
-			mDecoder.AddRawData("/docs/images", "terrain.bmp", testimage, RF_NORMAL);
-			mDecoder.AddDirectory("/docs", "todo");
-			mDecoder.AddDirectory("/docs/todo", "asd1");
-			mDecoder.AddDirectory("/docs/todo", "asd2");
-			mDecoder.AddDirectory("/docs/images", "lll");
-			mDecoder.AddDirectory("/docs/todo", "asd3");
-			mDecoder.AddDirectory("/docs/todo", "asd4");
-			mDecoder.AddDirectory("/docs/todo", "asd5");
-			mDecoder.AddDirectory("/docs/todo", "asd6");
-
-			for (int i=0; i<5; i++)
-			{
-				Str s = "info" + Str(i) + ".txt";
-				mDecoder.AddRawData("/", s.c_str(), testfile, RF_NORMAL);
-				testfile->Seek(0, SM_SeekFromBegin);
-			}
-
-			GetFilesystem()->Close(testimage);
-			GetFilesystem()->Close(testfile);
-
-			mDecoder.Close();
-		}
-};
-
-//----------------------------------
-//            Windows
-//----------------------------------
-
-class EditorWindow: public Window
-{
-  public:
-    EditorWindow(WindowsManager* wm, int x, int y, int width, int height, const Str& crwFilePath):
-      Window(wm, x, y, width, height, "Editor: " + crwFilePath)
-    {
-			mDecoder.Load(crwFilePath);
-			mObjModel = new CRWObjectModel(&mDecoder);
-
-			TreeView* tw = new TreeView(GetContentWidget());
-
-			//The CRW Object Model exposes the CRW content through a hierarchy of IWithProperties objects
-			//that is suitable to be viewed in a TreeView
-			//Create a ListGenericWrapper to expose the list as a Generic List
-			ListGenericWrapper<CRWDescriptor*>* wrapper = new ListGenericWrapper<CRWDescriptor*>(mObjModel->GetRoot());
-			tw->SetItems(wrapper);
-    }
-
-		virtual ~EditorWindow()
-		{
-			delete mObjModel;
-		}
-
-  private:
-		CRWDecoder mDecoder;
-		CRWObjectModel* mObjModel;
-};
-
-class UpperCaseConverter: public Converter
-{
-public:
-	virtual Generic Convert(Generic source)
-	{
-		Str str = source.asStr();
-		str.MakeUpper();
-		return str;
-	}
-};
-
-class CrwIconConverter: public Converter
-{
-public:
-	virtual Generic Convert(Generic source)
-	{
-		//source is a CRWDescriptor, return the correct icon ImageSource (a path, probably)
-		ushort type;
-		if (!source.asUShort(type))
-		{
-			return "<Unknown>";
-		}
-		if (type == RT_Directory)
-		{
-			return "res/crw_dir_icon.bmp";
-		}
-		if (type == RT_RawData)
-		{
-			return "res/crw_file_icon.bmp";
-		}
-		return "res/crw_unknown.bmp";
-	}
-};
-
-class CrwDescriptorToFullPathConverter: public Converter
-{
-public:
-	virtual Generic Convert(Generic source)
-	{
-		//source is a CRWDescriptor, return the correct icon ImageSource (a path, probably)
-		CRWDescriptor* descr;
-		if (!source.asType(&descr))
-		{
-			return "";
-		}
-		return descr->GetCRWObjectModel()->GetCRWLibraryPath() + descr->GetFullName();
-	}
-};
-
-class EditorWindowContext: public WindowContext
-{
-public:
-  EditorWindowContext(WindowsManager* windowsManager, const Str& crwFilePath):
-		WindowContext(windowsManager), twCrwLibrary(NULL)
-  {
-		mDecoder.Load(crwFilePath);
-		mObjModel = new CRWObjectModel(&mDecoder);
-
-		AddProperty(new IWithPropertiesProperty("CrwObjectModel", (IWithProperties**)&mObjModel));
-
-		RegisterAction("UpdateCrwFilePreview", CreateDelegate(this, &EditorWindowContext::UpdateCrwFilePreview));
-		RegisterConverter("UpperCaseConverter", new UpperCaseConverter);
-		RegisterConverter("CrwIconConverter", new CrwIconConverter);
-		RegisterConverter("CrwDescriptorToFullPathConverter", new CrwDescriptorToFullPathConverter);
-  }
-
-	virtual ~EditorWindowContext()
-	{
-		delete mObjModel;
-	}
-
-	void OnLoad()
-	{
-		twCrwLibrary = (TreeView*)FindWidgetByName("twCrwLibrary");
-		NotifyChangeEventArgs args("twCrwLibrary");
-		NotifyChange(&args);
-	}
-
-	virtual Generic GetPropertyValue(const Str& name) const
-	{
-		if (name == "twCrwLibrary")
-		{
-			return twCrwLibrary;
-		}
-		else
-		{
-			return WindowContext::GetPropertyValue(name);
-		}
-	}
-
-	
-	void UpdateCrwFilePreview(Widget* src, List<Str>* /*args*/)
-	{
-		//if (twCrwLibrary->GetSelectedIndex() != 2)
-		//{
-		//	twCrwLibrary->SetSelectedIndex(2);
-		//}
-		//twCrwLibrary->PrintLoop(0);
-	}
-
-	virtual Str ToStr() const
-	{
-		return "EditorWindowContext";
-	}
-
-private:
-	TreeView* twCrwLibrary;
-	CRWDecoder mDecoder;
-	CRWObjectModel* mObjModel;
-};
-
-class MainWindowContext: public WindowContext
-{
-  public:
-    MainWindowContext(WindowsManager* windowsManager):
-		  WindowContext(windowsManager)
-    {
-			RegisterAction("NewLibrary", CreateDelegate(this, &MainWindowContext::NewLibraryAction));
-			RegisterAction("OpenLibrary", CreateDelegate(this, &MainWindowContext::OpenLibraryAction));
-    }
-
-		void OnLoad()
-		{
-			btnClose = (Button*)FindWidgetByName("btnClose");
-			btnNewLibrary = (Button*)FindWidgetByName("btnNewLibrary");
-			btnOpenLibrary = (Button*)FindWidgetByName("btnOpenLibrary");
-		}
-
-		void NewLibraryAction(Widget* src, List<Str>* /*args*/)
-		{
-			Window* wnd = new TextInputWindow(
-				GetWindowsManager(),
-				"New CRW", "Please insert the new CRW name:",
-				"library",
-				new Delegate2<MainWindowContext, void, bool, Str>(this, &MainWindowContext::NewLibraryCallback, false, Str(""))
-				);
-			GetWindowsManager()->DoModalWindow(wnd);
-		}
-
-		void OpenLibraryAction(Widget* src, List<Str>* /*args*/)
-		{
-			Window* wnd = new TextInputWindow(
-				GetWindowsManager(),
-				"Open CRW", "Please insert the CRW name to open:",
-				"library",
-				new Delegate2<MainWindowContext, void, bool, Str>(this, &MainWindowContext::OpenCrwCallback, false, Str(""))
-				);
-			GetWindowsManager()->DoModalWindow(wnd);
-		}
-
-		void NewLibraryCallback(bool cancelled, Str name)
-		{
-			if (!cancelled)
-			{
-				Log::I("Creating new CRW: " + name + ".crw");
-
-				Str crwFilePath = "res/" + name + ".crw";
-
-				CRWUtils::CreateExampleCRW(crwFilePath);
-				new EditorWindow(GetWindowsManager(), 100, 15, 250, 200, crwFilePath);
-			}
-			else
-				Log::I("New CRW creation cancelled.");
-		}
-
-		void OpenCrwCallback(bool cancelled, Str name)
-		{
-			if (!cancelled)
-			{
-				Log::I("Opening CRW: " + name + ".crw");
-
-				Str crwFilePath = "res/" + name + ".crw";
-
-				//Verify the existence of crwFilePath
-				if (!GetFilesystem()->Exists(crwFilePath))
-				{
-					Log::I("CRW file specified does not exist");
-				}
-				else
-				{
-					//new EditorWindow(GetWindowsManager(), 100, 15, 250, 200, crwFilePath);
-					WindowsManager* windowsManager = GetWindowsManager();
-					LoadXWMLAndLogResponse(windowsManager, "res/editor_editorwindow.xml", new EditorWindowContext(windowsManager, crwFilePath));
-				}
-			}
-			else
-				Log::I("Opening CRW cancelled.");
-		}
-
-	private:
-		Button* btnClose;
-		Button* btnNewLibrary;
-		Button* btnOpenLibrary;
-};
-
-class MainScene: public Scene
-{
-public:
-	MainScene(Crown::uint windowWidth, Crown::uint windowHeight)
-	{
-	}
-
-	virtual ~MainScene()
-	{
-	}
-
-	virtual void OnLoad()
-	{
-		Renderer* renderer = GetDevice()->GetRenderer();
-		renderer->SetClearColor(Color4(0.6f, 0.6f, 0.6f, 1.0f));
-
-		//Mat4 matrix(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f);
-		//renderer->SetMatrix(MT_MODEL, matrix);
-
-		//Mat4 matrix1;
-		//glGetFloatv(GL_MODELVIEW_MATRIX, matrix1.ToFloatPtr());
-
-		mWindowsManager = new WindowsManager(this);
-
-		LoadXWMLAndLogResponse(mWindowsManager, "res/editor_mainwindow.xml", new MainWindowContext(mWindowsManager));
-	}
-
-	virtual void RenderScene()
-	{
-		Scene::RenderScene();
-	}
-
-private:
-	WindowsManager* mWindowsManager;
-}; 
-
-int main(int argc, char** argv)
-{
-	int wndW = 1024;
-	int wndH = 768;
-
-	if (argc == 3)
-	{
-		wndW = atoi(argv[1]);
-		wndH = atoi(argv[2]);
-	}
-
-	Device* mDevice = GetDevice();
-
-	if (!mDevice->Init(wndW, wndH, 32, false))
-	{
-		return 0;
-	}
-
-	WndCtrl ctrl;
-
-	MainScene* mainScene = new MainScene(wndW, wndH);
-	GetDevice()->GetSceneManager()->SelectNextScene(mainScene);
-
-	mDevice->GetMainWindow()->SetTitle("Crown Engine v0.1 - Editor Test");
-
-	mDevice->Run();
-
-	mDevice->Shutdown();
-
-	return 0;
-}
-
-
-

BIN
samples/editor/res/arialbd.ttf


BIN
samples/editor/res/boom.bmp


BIN
samples/editor/res/closebutton_x.bmp


BIN
samples/editor/res/terrain.bmp


+ 0 - 1
samples/editor/res/testfile.txt

@@ -1 +0,0 @@
-<text file content, prova 123 lol asd> 

BIN
samples/windowing/res/arialbd.ttf


BIN
samples/windowing/res/boom.bmp


BIN
samples/windowing/res/closebutton_x.bmp


+ 0 - 172
samples/windowing/windowing.cpp

@@ -1,172 +0,0 @@
-#include "Crown.h"
-#include <cstdlib>
-#include <iostream>
-#include <GL/glew.h>
-
-//----------------------------------
-//            Windows
-//----------------------------------
-
-class MainWindow: public Crown::Window
-{
-  public:
-    MainWindow(Crown::WindowsManager* wm, float x, float y, float width, float height):
-      Crown::Window(wm, x, y, width, height, "Crown")
-    {
-			Crown::StackLayout* sl = new Crown::StackLayout(GetContentWidget());
-
-			btnClose = new Crown::Button(sl);
-			btnClose->SetDesiredSize(-1, -1);
-
-			/*Crown::ThemeSpriteWidget* tsw =*/ new Crown::ThemeSpriteWidget(btnClose, Crown::TS_BOOM, 0);
-
-			btnClose->OnClickEvent += CreateDelegate(this, &MainWindow::btnClose_OnClick);
-    }
-
-		void btnClose_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/)
-		{
-			Crown::GetDevice()->StopRunning();
-		}
-
-  private:
-		Crown::Button* btnClose;
-};
-
-class MyWindow: public Crown::Window
-{
-  public:
-    MyWindow(Crown::WindowsManager* wm, float x, float y, float width, float height):
-      Crown::Window(wm, x, y, width, height, "Test Window")
-    {
-			Crown::StackLayout* sl = new Crown::StackLayout(GetContentWidget());
-			Crown::StackLayout* sl_left = new Crown::StackLayout(sl);
-			Crown::StackLayout* sl_right = new Crown::StackLayout(sl);
-			sl->SetOrientationVertical(false);
-
-      /*Crown::Button* btn1 =*/ new Crown::Button(sl_left);
-			Crown::Button* btn2 = new Crown::Button(sl_left);
-			/*Crown::Button* btn3 =*/ new Crown::Button(sl_left);
-			Crown::Button* btn4 = new Crown::Button(sl_left);
-
-			Crown::Button* btn5 = new Crown::Button(sl_right);
-			/*Crown::Button* btn6 =*/ new Crown::Button(sl_right);
-			Crown::Button* btn7 = new Crown::Button(sl_right);
-			/*Crown::Button* btn8 =*/ new Crown::Button(sl_right);
-
-			btn2->SetDesiredSize(-1, -1);
-			btn4->SetDesiredSize(-1, -1);
-			btn5->SetDesiredSize(-1, -1);
-			btn7->SetDesiredSize(-1, -1);
-    }
-
-  private:
-};
-
-class ListWindow: public Crown::Window
-{
-  public:
-    ListWindow(Crown::WindowsManager* wm, float x, float y, float width, float height):
-      Crown::Window(wm, x, y, width, height, "ListView Window")
-    {
-			Crown::StackLayout* sl = new Crown::StackLayout(GetContentWidget());
-			sl->SetOrientationVertical(false);
-
-			Crown::ListView* lw = new Crown::ListView(sl);
-
-//			Crown::GenericList gl;
-//      
-//      for(int i = 0; i < 15; i++)
-//        gl.Append(i*3);
-
-//			lw->SetItems(gl);
-
-
-			Crown::StackLayout* slRight = new Crown::StackLayout(sl);
-
-			Crown::TreeView* treeview = new Crown::TreeView(slRight);
-    }
-
-  private:
-};
-
-class MainScene: public Crown::Scene
-{
-	public:
-		MainScene() {}
-		virtual ~MainScene()
-		{
-			if (tr)
-				delete tr;
-		}
-
-		virtual void OnLoad()
-		{
-			Crown::Renderer* renderer = Crown::GetDevice()->GetRenderer();
-			renderer->SetClearColor(Crown::Color(0.6f, 0.6f, 0.6f, 1.0f));
-
-			Crown::WindowsManager* wm = new Crown::WindowsManager(this);
-			/*Crown::Window* w1 =*/ new MainWindow(wm, 10.0f, 15.0f, 80.0f, 80.0f);
-			/*Crown::Window* w2 =*/ new MyWindow(wm, 150.0f, 150.0f, 100.0f, 100.0f);
-			/*Crown::Window* w3 =*/ new ListWindow(wm, 350.0f, 150.0f, 300.0f, 200.0f);
-
-			/*
-			mFont.SetTrueTypeSize(8);
-			mImg = mFont.LoadFont("../../res/times.ttf");
-			
-			Crown::Frame* f = new Crown::Frame();
-			f->Set(renderer->CreateTexture(mImg), 0, 0, mImg->GetWidth(), mImg->GetHeight());
-			mSprite.AddFrame(f);
-
-			Crown::BMPImageLoader bmp;
-			bmp.SaveFile(mImg, "../../res/out.bmp");
-			*/
-		}
-
-		virtual void RenderScene()
-		{
-			glDisable(GL_LIGHTING);
-			glColor3f(1, 1, 1);
-
-			// Uncomment to gain a huge performance boost
-			glDisable(GL_DEPTH_TEST);
-			glDepthMask(GL_FALSE);
-
-			Scene::RenderScene();
-
-			//glTranslatef(0.0f, 100.0f, 0.0f);
-			//mSprite.draw(0);
-		}
-
-		//Crown::Image* mImg;
-		//Crown::Sprite mSprite;
-};
-
-int main(int argc, char** argv) {
-
-	int wndW, wndH;
-	wndW = 800;
-	wndH = 600;
-
-	if (argc == 3) {
-		wndW = atoi(argv[1]);
-		wndH = atoi(argv[2]);
-	}
-
-	Crown::Device* device = Crown::GetDevice();
-
-	if (!device->Init(wndW, wndH, 32, false)) {
-
-		return 0;
-	}
-
-	device->GetMainWindow()->SetTitle("Crown Engine v0.1");
-
-	MainScene* mainScene = new MainScene();
-	device->GetSceneManager()->SelectNextScene(mainScene);
-	
-	device->Run();
-	device->Shutdown();
-
-	return 0;
-
-}

+ 0 - 220
samples/xwmlreader/XWMLReader.cpp

@@ -1,220 +0,0 @@
-#include "Crown.h"
-#include <cstdlib>
-#include <iostream>
-#include <GL/glew.h>
-
-using namespace Crown;
-
-class WndCtrl: public KeyboardListener
-{
-public:
-
-	WndCtrl()
-	{
-		GetDevice()->GetInputManager()->RegisterKeyboardListener(this);
-	}
-
-	virtual void KeyReleased(const KeyboardEvent& event)
-	{
-		if (event.key == KC_ESCAPE)
-		{
-			GetDevice()->StopRunning();
-		}
-	}
-};
-
-class FruitInfo: public WithProperties
-{
-public:
-	FruitInfo(Str name, float price):
-		mName(name), mPrice(price)
-	{
-		AddProperty(new StrProperty("fruitName", &mName));
-		AddProperty(new FloatProperty("fruitPrice", &mPrice));
-	}
-
-	virtual ~FruitInfo()
-	{
-
-	}
-
-	Str ToStr() const
-	{
-		return mName;
-	}
-
-public:
-	Str mName;
-	float mPrice;
-};
-
-class AllWindowsContext: public WindowContext
-{
-public:
-	AllWindowsContext(WindowsManager* windowsManager):
-	  WindowContext(windowsManager)
-  {
-		mFruitsList = new List<Generic>();
-		mFruitsList->Append(new FruitInfo("Pear", 1.38f));
-		mFruitsList->Append(new FruitInfo("Apple", 2.41f));
-		mFruitsList->Append(new FruitInfo("Peach", 1.89f));
-		mFruitsList->Append(new FruitInfo("Tomato???", 0.87f));
-		mFruitsList->Append(new FruitInfo("Orange", 1.40f));
-		mFruitsList->Append(new FruitInfo("Pineapple", 2.15f));
-
-		//AddProperty(new GenericListProperty("FruitsList", &mFruitsList));
-
-		RegisterAction("IncreaseFruitPrice", CreateDelegate(this, &AllWindowsContext::IncreaseFruitPrice));
-		RegisterAction("DecreaseFruitPrice", CreateDelegate(this, &AllWindowsContext::DecreaseFruitPrice));
-  }
-
-	virtual ~AllWindowsContext()
-	{
-		for(int i=0; i<mFruitsList->GetSize(); i++)
-		{
-			FruitInfo* fruitInfo = mFruitsList->GetElement(i).asType<FruitInfo>();
-			delete fruitInfo;
-		}
-	}
-
-	void OnLoad()
-	{
-		lwFruits = (ListView*)(GetAssociatedWindow()->FindChildByName("lwFruits"));
-	}
-
-	void IncreaseFruitPrice(Widget* src, List<Str>* /*args*/)
-	{
-		FruitPriceApplyDeltaToSelected(+1.0f);
-	}
-
-	void DecreaseFruitPrice(Widget* src, List<Str>* /*args*/)
-	{
-		FruitPriceApplyDeltaToSelected(-1.0f);
-	}
-
-	void FruitPriceApplyDeltaToSelected(float delta)
-	{
-		int selectedIndex = lwFruits->GetSelectedIndex();
-		if (selectedIndex != -1)
-		{
-			FruitInfo* fruitInfo;
-			mFruitsList->GetElement(selectedIndex).asType(&fruitInfo);
-			fruitInfo->SetPropertyValue("fruitPrice", fruitInfo->mPrice + delta);
-		}
-	}
-
-private:
-	ListView* lwFruits;
-	List<Generic>* mFruitsList;
-};
-
-class MainScene: public Scene, public WeakReferenced
-{
-public:
-	MainScene(Crown::uint windowWidth, Crown::uint windowHeight)
-	{
-
-	}
-	virtual ~MainScene()
-	{
-
-	}
-
-	void LoadXWMLAndLogResponse(Str xwmlFile)
-	{
-		XWMLReader xwml;
-		Window* window;
-
-		Filesystem* fs = GetFilesystem();
-		FilesystemEntry info;
-//		if (!fs->GetInfo(xwmlFile, info))
-//		{
-//			MessageWindow* mw = new MessageWindow(mWindowsManager, "Load XWML", "Could not find file '" + xwmlFile + "'", MWR_OK, NULL);
-//			mWindowsManager->DoModalWindow(mw);
-//			return;
-//		}
-
-		window = xwml.LoadFile(xwmlFile, mWindowsManager, new AllWindowsContext(mWindowsManager));
-
-		if (window == NULL)
-			Log::E("Could not load XWML file '" + info.osPath + "'");
-		else
-			Log::I("Successfully loaded XWML file '" + info.osPath + "'");
-	}
-
-	virtual void OnLoad()
-	{
-		Scene::OnLoad();
-
-		Renderer* renderer = GetDevice()->GetRenderer();
-		renderer->SetClearColor(Color4(0.6f, 0.6f, 0.6f, 1.0f));
-
-		mWindowsManager = new WindowsManager(this);
-		mWindowsManager->RegisterAction("LoadXWMLFromFilepath", CreateDelegate(this, &MainScene::LoadXWMLFromFilepath));
-
-		//LoadXWMLAndLogResponse("res/window.xml", wm);
-		//LoadXWMLAndLogResponse("res/window_listview.xml", wm);
-		LoadXWMLAndLogResponse("res/window_loader.xml");
-	}
-
-	void LoadXWMLFromFilepath(Widget* src, List<Str>* /*args*/)
-	{
-		Window* window = src->GetWindow();
-		TextBox* tbXWMLFilepath = (TextBox*)window->FindChildByName("tbXWMLFilepath");
-		if (tbXWMLFilepath == NULL)
-		{
-			Log::E("LoadXWMLFromFilepath action: Could not find TextBox 'tbXWMLFilepath'");
-			return;
-		}
-
-		LoadXWMLAndLogResponse(tbXWMLFilepath->GetText());
-	}
-
-	virtual void RenderScene()
-	{
-		GetDevice()->GetRenderer()->_SetBackfaceCulling(false);
-
-		mWindowsManager->Render();
-
-		GetDevice()->GetRenderer()->_SetBackfaceCulling(true);
-	}
-
-private:
-	WindowsManager* mWindowsManager;
-}; 
-
-int main(int argc, char** argv)
-{
-	int wndW = 1024;
-	int wndH = 768;
-
-	if (argc == 3)
-	{
-		wndW = atoi(argv[1]);
-		wndH = atoi(argv[2]);
-	}
-
-	Device* mDevice = GetDevice();
-
-	if (!mDevice->Init(wndW, wndH, 32, false))
-	{
-		return 0;
-	}
-
-	WndCtrl ctrl;
-
-	MainScene* mainScene = new MainScene(wndW, wndH);
-	GetDevice()->GetSceneManager()->SelectNextScene(mainScene);
-
-	mDevice->GetMainWindow()->SetTitle("Crown Engine v0.1 - XWMLReader Test");
-
-	while (mDevice->IsRunning())
-	{
-		mDevice->Frame();
-	}
-
-	mDevice->Shutdown();
-
-	return 0;
-}
-

+ 0 - 5
src/CMakeLists.txt

@@ -65,13 +65,8 @@ set (CORE_SRC
 )
 )
 
 
 set (CORE_HEADERS
 set (CORE_HEADERS
-	core/CoreEventArgs.h
-	core/Delegate.h
-	core/Exceptions.h
-	core/SignalSlot.h
 	core/Types.h
 	core/Types.h
 	core/VertexData.h
 	core/VertexData.h
-	core/WithProperties.h
 )
 )
 
 
 set (BV_SRC
 set (BV_SRC

+ 0 - 3
src/Crown.h

@@ -27,10 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 
 // Core
 // Core
 #include "Exceptions.h"
 #include "Exceptions.h"
-#include "SignalSlot.h"
 #include "Types.h"
 #include "Types.h"
-#include "CoreEventArgs.h"
-//#include "WithProperties.h"
 
 
 // Core/Math
 // Core/Math
 #include "Color4.h"
 #include "Color4.h"

+ 0 - 62
src/core/CoreEventArgs.h

@@ -1,62 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Str.h"
-
-namespace crown
-{
-
-class EventArgs
-{
-public:
-	EventArgs() { }
-	virtual ~EventArgs() { }
-};
-
-class NotifyChangeEventArgs
-{
-public:
-	NotifyChangeEventArgs(const Str& name):
-		mPropertyName(name)
-	{
-	}
-
-	virtual ~NotifyChangeEventArgs()
-	{
-	}
-
-	inline const Str& GetPropertyName() const
-	{
-		return mPropertyName;
-	}
-
-private:
-	Str mPropertyName;
-};
-
-}

+ 0 - 488
src/core/Delegate.h

@@ -1,488 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-namespace crown
-{
-
-/* Delegate with 0 arguments */
-
-template<typename TResult>
-class IDelegate
-{
-public:
-	virtual TResult Invoke() = 0;
-	virtual IDelegate<TResult>* Duplicate() = 0;
-	virtual void SetCalledObject(void* object) = 0;
-};
-
-template<typename TClass, typename TResult>
-class Delegate : public IDelegate<TResult>
-{
-public:
-	Delegate(TClass* object):
-		mObject(object)
-	{ }
-
-	~Delegate()
-	{ }
-
-	void SetCalledObject(void* object)
-	 { mObject = static_cast<TClass*>(object); }
-
-	IDelegate<TResult>* Duplicate()
-	 { return new Delegate(mObject.GetPoint32_ter()); }
-
-protected:
-	TClass* mObject;
-};
-
-/* Delegate with 1 argument */
-
-template<typename TResult, typename TArg0>
-class IDelegate1: public IDelegate<TResult>
-{
-public:
-	virtual TResult Invoke(TArg0 arg0) = 0;
-};
-
-template<typename TClass, typename TResult, typename TArg0>
-class Delegate1: public IDelegate1<TResult, TArg0>
-{
-public:
-	typedef TResult (TClass::*MethodType)(TArg0 arg0);
-
-	Delegate1(TClass* object, MethodType method):
-	 mObject(object), mMethod(method), mDefaultArg0(TArg0())
-	{ }
-
-	Delegate1(TClass* object, MethodType method, TArg0 defaultArg0):
-	 mObject(object), mMethod(method), mDefaultArg0(defaultArg0)
-	{ }
-	
-	~Delegate1()
-	{ }
-
-	void SetCalledObject(void* object)
-	 { mObject = static_cast<TClass*>(object); }
-
-	TResult Invoke();
-	TResult Invoke(TArg0 arg0);
-
-	virtual IDelegate<TResult>* Duplicate()
-	{
-		return new Delegate1(mObject.GetPoint32_ter(), mMethod, mDefaultArg0);
-	}
-
-	TArg0 GetDefaultArg0() const;
-
-protected:
-	TClass* mObject;
-	MethodType mMethod;
-	TArg0 mDefaultArg0;
-};
-
-template<typename TClass, typename TResult, typename TArg0>
-TResult Delegate1<TClass, TResult, TArg0>::Invoke()
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(mDefaultArg0);
-}
-
-template<typename TClass, typename TResult, typename TArg0>
-TResult Delegate1<TClass, TResult, TArg0>::Invoke(TArg0 arg0)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0);
-}
-
-template<typename TClass, typename TResult, typename TArg0>
-TArg0 Delegate1<TClass, TResult, TArg0>::GetDefaultArg0() const
-{
-	return mDefaultArg0;
-}
-
-
-
-/* Delegate with 2 arguments */
-
-template<typename TResult, typename TArg0, typename TArg1>
-class IDelegate2: public IDelegate1<TResult, TArg0>
-{
-public:
-	virtual TResult Invoke(TArg0 arg0, TArg1 arg1) = 0;
-};
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1>
-class Delegate2: public IDelegate2<TResult, TArg0, TArg1>
-{
-public:
-	typedef TResult (TClass::*MethodType)(TArg0 arg0, TArg1 arg1);
-
-	Delegate2(TClass* object, MethodType method):
-	 mObject(object), mMethod(method), mDefaultArg0(TArg0()), mDefaultArg1(TArg1())
-	{ }
-
-	Delegate2(TClass* object, MethodType method, TArg0 defaultArg0, TArg1 defaultArg1):
-	 mObject(object), mMethod(method), mDefaultArg0(defaultArg0), mDefaultArg1(defaultArg1)
-	{ }
-
-	~Delegate2()
-	{ }
-
-	void SetCalledObject(void* object)
-	 { mObject = static_cast<TClass*>(object); }
-
-	TResult Invoke();
-	TResult Invoke(TArg0 arg0);
-	TResult Invoke(TArg0 arg0, TArg1 arg1);
-
-	virtual IDelegate<TResult>* Duplicate()
-	{
-		return new Delegate2(mObject.GetPoint32_ter(), mMethod, mDefaultArg0, mDefaultArg1);
-	}
-
-	TArg0 GetDefaultArg0() const;
-	TArg1 GetDefaultArg1() const;
-
-protected:
-	TClass* mObject;
-	MethodType mMethod;
-	TArg0 mDefaultArg0;
-	TArg1 mDefaultArg1;
-};
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1>
-TResult Delegate2<TClass, TResult, TArg0, TArg1>::Invoke()
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(mDefaultArg0, mDefaultArg1);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1>
-TResult Delegate2<TClass, TResult, TArg0, TArg1>::Invoke(TArg0 arg0)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, mDefaultArg1);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1>
-TResult Delegate2<TClass, TResult, TArg0, TArg1>::Invoke(TArg0 arg0, TArg1 arg1)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, arg1);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1>
-TArg0 Delegate2<TClass, TResult, TArg0, TArg1>::GetDefaultArg0() const
-{
-	return mDefaultArg0;
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1>
-TArg1 Delegate2<TClass, TResult, TArg0, TArg1>::GetDefaultArg1() const
-{
-	return mDefaultArg1;
-}
-
-/* Delegate with 3 arguments */
-
-template<typename TResult, typename TArg0, typename TArg1, typename TArg2>
-class IDelegate3: public IDelegate2<TResult, TArg0, TArg1>
-{
-public:
-	virtual TResult Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2) = 0;
-};
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-class Delegate3: public IDelegate3<TResult, TArg0, TArg1, TArg2>
-{
-public:
-	typedef TResult (TClass::*MethodType)(TArg0 arg0, TArg1 arg1, TArg2 arg2);
-
-	Delegate3(TClass* object, MethodType method):
-	 mObject(object), mMethod(method), mDefaultArg0(TArg0()), mDefaultArg1(TArg1()), mDefaultArg2(TArg2())
-	{ }
-
-	Delegate3(TClass* object, MethodType method, TArg0 defaultArg0, TArg1 defaultArg1, TArg2 defaultArg2):
-	 mObject(object), mMethod(method), mDefaultArg0(defaultArg0), mDefaultArg1(defaultArg1), mDefaultArg2(defaultArg2)
-	{ }
-
-	~Delegate3()
-	{ }
-
-	void SetCalledObject(void* object)
-	 { mObject = static_cast<TClass*>(object); }
-
-	TResult Invoke();
-	TResult Invoke(TArg0 arg0);
-	TResult Invoke(TArg0 arg0, TArg1 arg1);
-	TResult Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2);
-
-	virtual IDelegate<TResult>* Duplicate()
-	{
-		return new Delegate3(mObject.GetPoint32_ter(), mMethod, mDefaultArg0, mDefaultArg1, mDefaultArg2);
-	}
-
-	TArg0 GetDefaultArg0() const;
-	TArg1 GetDefaultArg1() const;
-	TArg2 GetDefaultArg2() const;
-
-protected:
-	TClass* mObject;
-	MethodType mMethod;
-	TArg0 mDefaultArg0;
-	TArg1 mDefaultArg1;
-	TArg2 mDefaultArg2;
-};
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TResult Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::Invoke()
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(mDefaultArg0, mDefaultArg1, mDefaultArg2);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TResult Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::Invoke(TArg0 arg0)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, mDefaultArg1, mDefaultArg2);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TResult Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::Invoke(TArg0 arg0, TArg1 arg1)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, arg1, mDefaultArg2);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TResult Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, arg1, arg2);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TArg0 Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::GetDefaultArg0() const
-{
-	return mDefaultArg0;
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TArg1 Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::GetDefaultArg1() const
-{
-	return mDefaultArg1;
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-TArg2 Delegate3<TClass, TResult, TArg0, TArg1, TArg2>::GetDefaultArg2() const
-{
-	return mDefaultArg2;
-}
-
-/* Delegate with 4 arguments */
-
-template<typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-class IDelegate4: public IDelegate3<TResult, TArg0, TArg1, TArg2>
-{
-public:
-	virtual TResult Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3) = 0;
-};
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-class Delegate4: public IDelegate4<TResult, TArg0, TArg1, TArg2, TArg3>
-{
-public:
-	typedef TResult (TClass::*MethodType)(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3);
-
-	Delegate4(TClass* object, MethodType method):
-	 mObject(object), mMethod(method), mDefaultArg0(TArg0()), mDefaultArg1(TArg1()), mDefaultArg2(TArg2()), mDefaultArg3(TArg3())
-	{ }
-
-	Delegate4(TClass* object, MethodType method, TArg0 defaultArg0, TArg1 defaultArg1, TArg2 defaultArg2, TArg3 defaultArg3):
-	 mObject(object), mMethod(method), mDefaultArg0(defaultArg0), mDefaultArg1(defaultArg1), mDefaultArg2(defaultArg2), mDefaultArg3(defaultArg3)
-	{ }
-
-	~Delegate4()
-	{ }
-
-	void SetCalledObject(void* object)
-	 { mObject = static_cast<TClass*>(object); }
-
-	TResult Invoke();
-	TResult Invoke(TArg0 arg0);
-	TResult Invoke(TArg0 arg0, TArg1 arg1);
-	TResult Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2);
-	TResult Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3);
-
-	virtual IDelegate<TResult>* Duplicate()
-	{
-		return new Delegate4(mObject.GetPoint32_ter(), mMethod, mDefaultArg0, mDefaultArg1, mDefaultArg2, mDefaultArg3);
-	}
-
-	TArg0 GetDefaultArg0() const;
-	TArg1 GetDefaultArg1() const;
-	TArg2 GetDefaultArg2() const;
-	TArg3 GetDefaultArg3() const;
-
-protected:
-	TClass* mObject;
-	MethodType mMethod;
-	TArg0 mDefaultArg0;
-	TArg1 mDefaultArg1;
-	TArg2 mDefaultArg2;
-	TArg3 mDefaultArg3;
-};
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TResult Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::Invoke()
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(mDefaultArg0, mDefaultArg1, mDefaultArg2, mDefaultArg3);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TResult Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::Invoke(TArg0 arg0)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, mDefaultArg1, mDefaultArg2, mDefaultArg3);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TResult Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::Invoke(TArg0 arg0, TArg1 arg1)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, arg1, mDefaultArg2, mDefaultArg3);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TResult Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, arg1, arg2, mDefaultArg3);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TResult Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::Invoke(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3)
-{
-	if (mObject.IsNull() || mMethod == NULL)
-		return TResult();
-	return (mObject.GetPoint32_ter()->*mMethod)(arg0, arg1, arg2, arg3);
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TArg0 Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::GetDefaultArg0() const
-{
-	return mDefaultArg0;
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TArg1 Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::GetDefaultArg1() const
-{
-	return mDefaultArg1;
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TArg2 Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::GetDefaultArg2() const
-{
-	return mDefaultArg2;
-}
-
-template<typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-TArg3 Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>::GetDefaultArg3() const
-{
-	return mDefaultArg3;
-}
-
-/* 
- * Delegate Helper functions
- */
-
-template <typename TClass, typename TResult, typename TArg0>
-static IDelegate1<TResult, TArg0>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0))
-{
-	return new Delegate1<TClass, TResult, TArg0>(obj, method);
-}
-
-template <typename TClass, typename TResult, typename TArg0>
-static IDelegate1<TResult, TArg0>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0), TArg0 arg0)
-{
-	return new Delegate1<TClass, TResult, TArg0>(obj, method, arg0);
-}
-
-template <typename TClass, typename TResult, typename TArg0, typename TArg1>
-static IDelegate2<TResult, TArg0, TArg1>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0, TArg1))
-{
-	return new Delegate2<TClass, TResult, TArg0, TArg1>(obj, method);
-}
-
-template <typename TClass, typename TResult, typename TArg0, typename TArg1>
-static IDelegate2<TResult, TArg0, TArg1>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0, TArg1), TArg0 arg0, TArg1 arg1)
-{
-	return new Delegate2<TClass, TResult, TArg0, TArg1>(obj, method, arg0, arg1);
-}
-
-template <typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-static IDelegate3<TResult, TArg0, TArg1, TArg2>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0, TArg1, TArg2))
-{
-	return new Delegate3<TClass, TResult, TArg0, TArg1, TArg2>(obj, method);
-}
-
-template <typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2>
-static IDelegate3<TResult, TArg0, TArg1, TArg2>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0, TArg1, TArg2), TArg0 arg0, TArg1 arg1, TArg2 arg2)
-{
-	return new Delegate3<TClass, TResult, TArg0, TArg1, TArg2>(obj, method, arg0, arg1, arg2);
-}
-
-template <typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-static IDelegate4<TResult, TArg0, TArg1, TArg2, TArg3>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0, TArg1, TArg2, TArg3))
-{
-	return new Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>(obj, method);
-}
-
-template <typename TClass, typename TResult, typename TArg0, typename TArg1, typename TArg2, typename TArg3>
-static IDelegate4<TResult, TArg0, TArg1, TArg2, TArg3>* CreateDelegate(TClass* obj, TResult (TClass::*method)(TArg0, TArg1, TArg2, TArg3), TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3)
-{
-	return new Delegate4<TClass, TResult, TArg0, TArg1, TArg2, TArg3>(obj, method, arg0, arg1, arg2, arg3);
-}
-
-
-} //namespace crown

+ 0 - 99
src/core/SignalSlot.h

@@ -1,99 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "List.h"
-#include "Delegate.h"
-
-namespace crown
-{
-
-/*
- * The MulticastMulticastEvent class represents an MulticastEvent. When it fires, it calls the handlers that have been added to it, passing some information arguments
- * Handlers must have the same signature of the MulticastEvent, and can be added to the MulticastEvent through the += operator
- */
-
-template <typename TSource, typename TArg1>
-class MulticastEvent
-{
-public:
-	MulticastEvent();
-	~MulticastEvent();
-
-	typedef IDelegate2<void, TSource*, TArg1> HandlerType;
-
-	void Fire(TSource* source, TArg1 arg1);
-
-	//! Register handler delegate to be called when the event fires. This operation transfers ownership
-	void operator+=(HandlerType* handler);
-
-	//! Construct and register handler delegate to be called when the event fires.
-	template <typename THandlerClass>
-	void AddHandler(THandlerClass* obj, void (THandlerClass::*handlerMethod)(TSource*, TArg1))
-	{
-		HandlerType* handler = new Delegate2<THandlerClass, void, TSource*, TArg1>(obj, handlerMethod);
-		*this += handler;
-	}
-
-private:
-	List<HandlerType*> mHandlers;
-};
-
-/* -- MulticastEvent -- */
-
-template <typename TSource, typename TArg1>
-MulticastEvent<TSource, TArg1>::MulticastEvent()
-{
-}
-
-template <typename TSource, typename TArg1>
-MulticastEvent<TSource, TArg1>::~MulticastEvent()
-{
-	for (int32_t i=0; i<mHandlers.GetSize(); i++)
-	{
-		delete mHandlers[i];
-	}
-}
-
-template <typename TSource, typename TArg1>
-void MulticastEvent<TSource, TArg1>::Fire(TSource* source, TArg1 arg1)
-{
-	for (int32_t i=0; i<mHandlers.GetSize(); i++)
-	{
-		HandlerType* handler = mHandlers[i];
-		handler->Invoke(source, arg1);
-	}
-}
-
-template <typename TSource, typename TArg1>
-void MulticastEvent<TSource, TArg1>::operator+=(HandlerType* handler)
-{
-	if (mHandlers.Find(handler) == -1)
-		mHandlers.Append(handler);
-}
-
-} //namespace crown

+ 0 - 136
src/core/WithProperties.h

@@ -1,136 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Generic.h"
-#include "Str.h"
-#include "Dictionary.h"
-#include "Observable.h"
-#include "Property.h"
-#include "Log.h"
-#include "Weak.h"
-
-namespace crown
-{
-
-class StrSerializable
-{
-public:
-	virtual bool DeserializeFromStr(Str& input) = 0;
-	virtual Str SerializeToStr() const = 0;
-};
-
-class IWithProperties: public WeakReferenced
-{
-public:
-	virtual Generic		GetPropertyValue(const Str& name) const = 0;
-	virtual void		SetPropertyValue(const Str& name, const Generic& value) = 0;
-};
-
-class WithProperties: public Observable, public IWithProperties
-{
-public:
-	WithProperties()
-	{
-
-	}
-	
-	virtual ~WithProperties()
-	{
-		for (int32_t i=0; i<mProperties.GetSize(); i++)
-		{
-			delete mProperties[i];
-		}
-	}
-
-	//typedef Dictionary<Str, Generic> PropertiesDictionary;
-
-	virtual Generic GetPropertyValue(const Str& name) const
-	{
-		// TODO: Due to Object deletion
-//		if (name == "ToStr")
-//		{
-//			return ToStr();
-//		}
-		for(int32_t i = 0; i < mProperties.GetSize(); i++)
-		{
-			if (mProperties[i]->GetName() == name)
-			{
-				const_cast<WithProperties*>(this)->OnGetProperty(name);
-				return mProperties[i]->GetValue();
-			}
-		}
-
-		return Generic();
-	}
-
-	virtual void SetPropertyValue(const Str& name, const Generic& value)
-	{
-		for(int32_t i = 0; i < mProperties.GetSize(); i++)
-		{
-			if (mProperties[i]->GetName() == name)
-			{
-				mProperties[i]->SetValue(value);
-				OnSetProperty(name);
-				NotifyChangeEventArgs args(name);
-				NotifyChange(&args);
-				return;
-			}
-		}
-		Log::I("Property '" + name + "' not found for this object");
-	}
-
-	virtual void OnSetProperty(const Str& /*name*/)
-	{
-	}
-
-	virtual void OnGetProperty(const Str& /*name*/)
-	{
-	}
-
-	void AddProperty(Property* prop)
-	{
-		mProperties.Append(prop);
-	}
-
-	Property* GetProperty(const Str& name)
-	{
-		for(int32_t i = 0; i < mProperties.GetSize(); i++)
-		{
-			if (mProperties[i]->GetName() == name)
-			{
-				return mProperties[i];
-			}
-		}
-		return NULL;
-	}
-
-private:
-	List<Property*> mProperties;
-};
-
-}
-

+ 0 - 192
src/windowing/Bind.cpp

@@ -1,192 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Bind.h"
-#include "Window.h"
-
-namespace Crown
-{
-
-Converter::Converter()
-{
-
-}
-
-Converter::~Converter()
-{
-
-}
-
-Generic Converter::Convert(Generic source)
-{
-	return source;
-}
-
-Bind::Bind(IWithProperties* source, IWithProperties* destination, Str sourceProperty, Str destinationProperty, Converter* converter):
-	mSource(NULL), mDestination(destination), mSourceProperty(sourceProperty), mDestinationProperty(destinationProperty),
-	mConverter(converter), mFlags(BF_NORMAL | BF_DIRTY)
-{
-	SetSource(source);
-}
-
-Bind::Bind(Widget* widget, Str sourceProperty, Str destinationProperty, Converter* converter):
-	mSource(NULL), mDestination(widget), mSourceProperty(sourceProperty), mDestinationProperty(destinationProperty),
-	mConverter(converter), mFlags(BF_USE_BINDING_CONTEXT | BF_DIRTY)
-{
-	SetSource(widget->GetBindingContext());
-}
-
-Bind::Bind(const Str& sourceName, Widget* destination, Str sourceProperty, Str destinationProperty, Converter* converter):
-  mSource(NULL), mSourceName(sourceName), mDestination(destination), mSourceProperty(sourceProperty), mDestinationProperty(destinationProperty),
-	mConverter(converter), mFlags(BF_NAMED_WIDGET | BF_DIRTY)
-{
-	//Source will be set the on the first Apply
-}
-
-Bind::~Bind()
-{
-
-}
-
-void Bind::Apply()
-{
-	if (!IsEnabled() || !Math::TestBitmask(mFlags, BF_DIRTY))
-	{
-		return;
-	}
-
-	if (Math::TestBitmask(mFlags, BF_NAMED_WIDGET))
-	{
-		if (mSource.IsNull())
-		{
-			Window* w = ((Widget*)mDestination.GetPoint32_ter())->GetWindow();
-			SetSource(w->FindChildByName(mSourceName));
-		}
-	}
-
-	if (mSource.IsNull())
-	{
-		Log::E("No binding source set for this binding");
-		return;
-	}
-
-	//if (mSourceProperty == "twCrwLibrary")
-	//{
-	//	int32_t a = 5;
-	//}
-
-	//Log::I("Bind::Apply: " + mSource->ToStr() + "." + mSourceProperty + " -> " + mDestination->ToStr() + "." + mDestinationProperty);
-
-	//SB NOTE: Disable this Bind when Applying the value, to prevent Apply loops
-	SetEnabled(false);
-	if (mConverter)
-	{
-		mDestination->SetPropertyValue(mDestinationProperty, mConverter->Convert(mSource->GetPropertyValue(mSourceProperty)));
-	}
-	else
-	{
-		mDestination->SetPropertyValue(mDestinationProperty, mSource->GetPropertyValue(mSourceProperty));
-	}
-	SetEnabled(true);
-
-	mFlags = Math::UnsetBitmask(mFlags, BF_DIRTY);
-}
-
-void Bind::SetSource(IWithProperties* source)
-{
-	//Log::I("Bind::SetSource: " + mSourceProperty + " -> " + mDestinationProperty);
-	//if (mSourceProperty == "twCrwLibrary")
-	//{
-	//	int32_t a = 5;
-	//}
-
-	if (!IsEnabled())
-	{
-		return;
-	}
-
-	Observable* sourceAsObservable;
-	if (mSource.IsValid())
-	{
-		//Remove the old observing connection if present
-		sourceAsObservable = dynamic_cast<Observable*>(mSource.GetPoint32_ter());
-		if (sourceAsObservable != NULL)
-		{
-			sourceAsObservable->RemoveObserver(this);
-		}
-	}
-
-	//Try casting to Observable to see if we can bind to it
-	mSource = source;
-
-	sourceAsObservable = dynamic_cast<Observable*>(source);
-	if (sourceAsObservable != NULL)
-	{
-		sourceAsObservable->AddObserver(this);
-	}
-
-	mFlags = Math::SetBitmask(mFlags, BF_DIRTY);
-}
-
-void Bind::SetSourceIfUsingBindingContext(IWithProperties* source)
-{
-	if (Math::TestBitmask(mFlags, BF_USE_BINDING_CONTEXT))
-	{
-		SetSource(source);
-	}
-}
-
-void Bind::OnNotifyChange(Observable* obj, NotifyChangeEventArgs* args)
-{
-	//if (mSourceProperty == "twCrwLibrary")
-	//{
-	//	int32_t a = 5;
-	//}
-
-	if (args->GetPropertyName() == mSourceProperty)
-	{
-		//Apply();
-		mFlags = Math::SetBitmask(mFlags, BF_DIRTY);
-	}
-}
-
-bool Bind::IsEnabled() const
-{
-	return !Math::TestBitmask(mFlags, BF_DISABLED);
-}
-
-void Bind::SetEnabled(bool value)
-{
-	if (value)
-	{
-		mFlags = (uint16_t)Math::UnsetBitmask(mFlags, BF_DISABLED);
-	}
-	else
-	{
-		mFlags = (uint16_t)Math::SetBitmask(mFlags, BF_DISABLED);
-	}
-}
-
-}

+ 0 - 88
src/windowing/Bind.h

@@ -1,88 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Widget.h"
-
-namespace Crown
-{
-
-class Converter
-{
-public:
-	Converter();
-	virtual ~Converter();
-
-	virtual Generic Convert(Generic source);
-};
-
-enum BindFlags
-{
-	BF_NORMAL = 0,
-	BF_DISABLED = 1,
-	BF_USE_BINDING_CONTEXT = 2,
-	BF_NAMED_WIDGET = 4,
-	BF_DIRTY = 8
-};
-
-class Bind: public IObserver
-{
-public:
-	Bind(IWithProperties* source, IWithProperties* destination, Str sourceProperty, Str destinationProperty, Converter* converter);
-	//! Initialize the Bind with a Widget that acts as destination. The widget's BindingContext becomes the source
-	Bind(Widget* widget, Str sourceProperty, Str destinationProperty, Converter* converter);
-	//! Initializes the Bind with a named source to be searched in the destination widget's window descendants
-	Bind(const Str& sourceName, Widget* destination, Str sourceProperty, Str destinationProperty, Converter* converter);
-	~Bind();
-
-	void Apply();
-
-	void OnNotifyChange(Observable* obj, NotifyChangeEventArgs* args);
-
-	void SetSource(IWithProperties* source);
-	void SetSourceIfUsingBindingContext(IWithProperties* source);
-	inline IWithProperties* GetSource()
-	 { return mSource.GetPoint32_ter(); }
-
-	inline void SetDestination(IWithProperties* destination)
-	 { mDestination = destination; }
-	inline IWithProperties* GetDestination()
-	 { return mDestination.GetPoint32_ter(); }
-
-	bool IsEnabled() const;
-	void SetEnabled(bool value);
-
-private:
-	Weak<IWithProperties> mSource;
-	Str mSourceName;
-	Weak<IWithProperties> mDestination;
-	Str mSourceProperty;
-	Str mDestinationProperty;
-	Converter* mConverter;
-	uint16_t mFlags;
-};
-
-}

+ 0 - 109
src/windowing/Button.cpp

@@ -1,109 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Button.h"
-#include <GL/glew.h> // FIXME
-#include "Types.h"
-#include "Themes.h"
-#include "Label.h"
-#include "Window.h"
-#include "WindowsManager.h"
-#include "WindowContext.h"
-#include "Auto.h"
-#include "XWMLReader.h"
-#include "SpecificProperties.h"
-
-namespace Crown
-{
-
-Button::Button(Widget* parent):
-	Widget(parent), mIsMouseDown(false)
-{
-	AddProperty(new ActionProperty<Button, EventArgs*>("OnClick", &OnClickEvent, this));
-}
-
-Button::Button(Widget* parent, const Str& caption):
-	Widget(parent), mIsMouseDown(false)
-{
-	SetDesiredSize(-1, 20);
-	Label* lbl = new Crown::Label(this);
-	lbl->SetText(caption);
-	lbl->SetHorizontalAlign(LHA_CENTER);
-}
-
-Button::~Button()
-{
-}
-
-void Button::OnMouseDown(MouseButtonEventArgs* /*args*/)
-{
-	MouseCapture();
-	mIsMouseDown = true;
-}
-
-void Button::OnMouseUp(MouseButtonEventArgs* args)
-{
-	MouseRelease();
-	mIsMouseDown = false;
-
-	if (args->IsClick())
-	{
-		OnClickEvent.Fire(this, NULL);
-	}
-}
-
-void Button::OnDraw(DrawingClipInfo& clipInfo)
-{
-	if (mIsMouseDown && IsMouseOver())
-	{
-		Themes::Draw(TF_BUTTON_PRESSED, GetSize());
-	}
-	else
-	{
-		if (IsMouseOver())
-		{
-			Themes::Draw(TF_BUTTON_HIGHLIGHTED, GetSize());
-		}
-		else
-		{
-			Themes::Draw(TF_BUTTON_NORMAL, GetSize());
-		}
-	}
-
-	//TODO: Use Widget::OnDraw() to draw children, and set a translation to achieve the pressed effect
-	if (mDrawDebugBorder)
-	{
-		DebugDrawBorder();
-	}
-
-	if (mIsMouseDown && IsMouseOver())
-	{
-		glTranslatef(-1.0f, -1.0f, 0.0f);
-	}
-
-	DrawChildren(clipInfo);
-}
-
-} //namespace Crown

+ 0 - 63
src/windowing/Button.h

@@ -1,63 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "List.h"
-#include "WindowingEventArgs.h"
-
-namespace Crown
-{
-
-class Button : public Widget
-{
-
-public:
-
-	Button(Widget* parent);
-	Button(Widget* parent, const Str& caption);
-	virtual ~Button();
-
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-
-	//Events
-	MulticastEvent<Button, EventArgs*> OnClickEvent;
-
-	virtual Str ToStr() const
-	 { return "Button"; }
-
-protected:
-
-	virtual void OnMouseUp(MouseButtonEventArgs* args);
-	virtual void OnMouseDown(MouseButtonEventArgs* args);
-
-private:
-
-	bool mIsMouseDown;
-};
-
-} //namespace Crown

+ 0 - 76
src/windowing/DragArea.cpp

@@ -1,76 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "DragArea.h"
-#include "Log.h"
-#include "Types.h"
-
-namespace Crown
-{
-
-DragArea::DragArea(Widget* parent):
-	Widget(parent), mWidgetToDrag(NULL), mIsDragging(false)
-{
-}
-
-DragArea::~DragArea()
-{
-}
-
-void DragArea::SetWidgetToDrag(Widget* w)
-{
-	if (IsChildOf(w))
-	{
-		mWidgetToDrag = w;
-	}
-}
-
-void DragArea::OnMouseMove(MouseMoveEventArgs* args)
-{
-	if (mIsDragging && mWidgetToDrag != NULL)
-	{
-		mWidgetToDrag->SetDesiredPosition(mWidgetToDrag->GetDesiredPosition() + args->GetDelta());
-	}
-}
-
-void DragArea::OnMouseDown(MouseButtonEventArgs* /*args*/)
-{
-	if (MouseCapture())
-	{
-		//mPrevMousePos =
-		mIsDragging = true;
-	}
-}
-
-void DragArea::OnMouseUp(MouseButtonEventArgs* /*args*/)
-{
-	if (mIsDragging)
-	{
-		MouseRelease();
-		mIsDragging = false;
-	}
-}
-
-} //namespace Crown

+ 0 - 60
src/windowing/DragArea.h

@@ -1,60 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-
-namespace Crown
-{
-
-class DragArea : public Widget
-{
-
-public:
-
-	DragArea(Widget* parent);
-	virtual ~DragArea();
-
-	void SetWidgetToDrag(Widget* w);
-
-	virtual Str ToStr() const
-	 { return "DragArea"; }
-
-protected:
-
-	void OnMouseMove(MouseMoveEventArgs* args);
-	void OnMouseDown(MouseButtonEventArgs* args);
-	void OnMouseUp(MouseButtonEventArgs* args);
-
-private:
-
-	Widget* mWidgetToDrag;
-	bool mIsDragging;
-	Vec2 mPrevMousePos;
-};
-
-} //namespace Crown

+ 0 - 97
src/windowing/ImageWidget.cpp

@@ -1,97 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "ImageWidget.h"
-#include "TextureManager.h"
-#include "SpecificProperties.h"
-#include "BMPImageLoader.h"
-#include "Renderer.h"
-
-namespace Crown
-{
-
-ImageWidget::ImageWidget(Widget* parent):
-	Widget(parent)
-{
-	AddProperty(new StrProperty("ImageSource", &mImageSource));
-}
-
-ImageWidget::ImageWidget(Widget* parent, const Str& imageSource):
-	Widget(parent), mImageSource(imageSource)
-{
-	AddProperty(new StrProperty("ImageSource", &mImageSource));
-	ReloadFromImageSource();
-}
-
-ImageWidget::~ImageWidget()
-{
-}
-
-void ImageWidget::OnSetProperty(const Str& name)
-{
-	if (name == "ImageSource")
-	{
-		ReloadFromImageSource();
-	}
-}
-
-void ImageWidget::ReloadFromImageSource()
-{
-	mSprite.Clear();
-
-	Texture* tex;
-	bool created;
-	tex = GetTextureManager()->Create(mImageSource.c_str(), created);
-	if (created)
-	{
-		BMPImageLoader loader;
-		Image* img;
-
-		img = loader.LoadFile(mImageSource);
-		if (img == NULL)
-		{
-			return;
-		}
-		img->ApplyColorKeying(Color4(255, 0, 255));
-
-		tex->LoadFromImage(img);
-		delete img;
-	}
-
-	Frame* frame = new Frame();
-	frame->Set(tex);
-	mSprite.AddFrame(frame);
-}
-
-void ImageWidget::OnDraw(DrawingClipInfo& clipInfo)
-{
-	if (mSprite.GetFrameCount() > 0)
-	{
-		mSprite.draw(0);
-	}
-	Widget::OnDraw(clipInfo);
-}
-
-} //namespace Crown

+ 0 - 56
src/windowing/ImageWidget.h

@@ -1,56 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "Sprite.h"
-
-namespace Crown
-{
-
-class ImageWidget : public Widget
-{
-public:
-	ImageWidget(Widget* parent);
-	ImageWidget(Widget* parent, const Str& imageSource);
-	virtual ~ImageWidget();
-
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-
-	virtual void OnSetProperty(const Str& /*name*/);
-
-	void ReloadFromImageSource();
-
-	virtual Str ToStr() const
-	 { return "ImageWidget"; }
-
-private:
-	Str mImageSource;
-	Sprite mSprite;
-};
-
-} //namespace Crown

+ 0 - 98
src/windowing/ItemsSelector.cpp

@@ -1,98 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "ItemsSelector.h"
-#include "SpecificProperties.h"
-
-namespace Crown
-{
-
-ItemsSelector::ItemsSelector(Widget* parent): 
-	ItemsWidget(parent), mSelectedIndex(-1)
-{
-	AddProperty(new ActionProperty<ItemsSelector, SelectionChangedEventArgs*>("OnSelectionChanged", &OnSelectionChangedEvent, this));
-}
-
-ItemsSelector::~ItemsSelector()
-{
-	
-}
-
-Generic ItemsSelector::GetSelectedItem() const
-{
-	if (mSelectedIndex < 0)
-	{
-		return Generic();
-	}
-	else
-	{
-		return GetItems()->GetElement(mSelectedIndex);
-	}
-}
-
-Generic ItemsSelector::GetPropertyValue(const Str& name) const
-{
-	if (name == "SelectedItem")
-	{
-		return GetSelectedItem();
-	}
-	else
-	{
-		return ItemsWidget::GetPropertyValue(name);
-	}
-}
-
-void ItemsSelector::SetPropertyValue(const Str& name, const Generic& value)
-{
-	if (name == "SelectedItem")
-	{
-		Log::E("Property SelectedItem is read-only");
-	}
-	else
-	{
-		ItemsWidget::SetPropertyValue(name, value);
-	}
-}
-
-void ItemsSelector::SetSelectedIndex(int32_t value)
-{
-	if (mSelectedIndex != value)
-	{
-		int32_t prevSelectedIndex = mSelectedIndex;
-		mSelectedIndex = value;
-		InternalSelectionChanged();
-
-		SelectionChangedEventArgs args(this, prevSelectedIndex, mSelectedIndex);
-		OnSelectionChangedEvent.Fire(this, &args);
-
-		NotifyChangeEventArgs args1("SelectedIndex");
-		NotifyChange(&args1);
-
-		NotifyChangeEventArgs args2("SelectedItem");
-		NotifyChange(&args2);
-	}
-}
-
-}

+ 0 - 65
src/windowing/ItemsSelector.h

@@ -1,65 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "ItemsWidget.h"
-#include "WindowingEventArgs.h"
-#include "SignalSlot.h"
-
-namespace Crown
-{
-
-class ItemsSelector : public ItemsWidget
-{
-public:
-	ItemsSelector(Widget* parent);
-	virtual ~ItemsSelector();
-
-	virtual Generic GetSelectedItem() const;
-
-	inline int32_t GetSelectedIndex() const
-	{
-		return mSelectedIndex;
-	}
-	virtual void SetSelectedIndex(int32_t value);
-
-	virtual Generic GetPropertyValue(const Str& name) const;
-	virtual void SetPropertyValue(const Str& name, const Generic& value);
-
-	MulticastEvent<ItemsSelector, SelectionChangedEventArgs*> OnSelectionChangedEvent;
-
-	virtual Str ToStr() const
-	 { return "ItemsSelector"; }
-
-protected:
-	virtual void InternalSelectionChanged() = 0;
-
-private:
-	int32_t mSelectedIndex;
-};
-
-}

+ 0 - 61
src/windowing/ItemsWidget.cpp

@@ -1,61 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "ItemsWidget.h"
-#include "SpecificProperties.h"
-#include "XMLReader.h"
-
-namespace Crown
-{
-
-ItemsWidget::ItemsWidget(Widget* parent):
-	Widget(parent), mItemTemplate(NULL)
-{
-	//AddProperty(new GenericListProperty("Items", &mItems));
-	AddProperty(new TemplateProperty("ItemTemplate", &mItemTemplate));
-}
-
-ItemsWidget::~ItemsWidget()
-{
-	delete mItemTemplate;
-}
-
-void ItemsWidget::OnSetProperty(const Str& name)
-{
-	if (name == "Items")
-	{
-		InternalItemsChanged();
-	}
-	else if (name == "ItemTemplate")
-	{
-		OnItemTemplateChanged();
-	}
-	else
-	{
-		Widget::OnSetProperty(name);
-	}
-}
-
-}

+ 0 - 78
src/windowing/ItemsWidget.h

@@ -1,78 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "Generic.h"
-
-namespace Crown
-{
-
-class XMLNode;
-
-//! A base class for all widgets that display a list of items
-class ItemsWidget: public Widget
-{
-public:
-	ItemsWidget(Widget* parent);
-
-	virtual ~ItemsWidget();
-
-	//! Returns the inner items list, if present.
-	inline const List<Generic>* GetItems() const
-	{
-		return mItems;
-	}
-
-	//! Sets the items list to be used. Releases the previous one.
-	//! The int32_ternal point32_ter is of Shared type: if callers need to
-	//! reference the list, they must keep a reference counted point32_ter
-	//! as well or delegate to the ItemsWidget instance
-	inline void SetItems(List<Generic>* value)
-	{
-		mItems = value;
-		InternalItemsChanged();
-	}
-
-	virtual void OnSetProperty(const Str& name);
-
-	inline XMLNode* GetItemTemplate() const
-	 { return mItemTemplate; }
-
-	virtual Str ToStr() const
-	 { return "ItemsWidget"; }
-
-protected:
-	virtual void InternalItemsChanged() = 0;
-	virtual void OnItemTemplateChanged() = 0;
-
-private:
-	List<Generic>* mItems;
-	XMLNode* mItemTemplate;
-};
-
-}

+ 0 - 141
src/windowing/Label.cpp

@@ -1,141 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Label.h"
-#include "Themes.h"
-#include "Types.h"
-#include "Device.h"
-#include "TextRenderer.h"
-#include "FontManager.h"
-#include "SpecificProperties.h"
-#include "Renderer.h"
-
-namespace Crown
-{
-
-Label::Label(Widget* parent, Str text):
-	Widget(parent), mHorizontalAlign(LHA_LEFT), mVerticalAlign(LVA_CENTER)
-{
-	EnumProperty* prop = new EnumProperty("HorizontalTextAlign", (int32_t*)&mHorizontalAlign);
-	prop->AddValueMapping("Left", LHA_LEFT);
-	prop->AddValueMapping("Center", LHA_CENTER);
-	prop->AddValueMapping("Right", LHA_RIGHT);
-	AddProperty(prop);
-
-	prop = new EnumProperty("VerticalTextAlign", (int32_t*)&mVerticalAlign);
-	prop->AddValueMapping("Top", LVA_TOP);
-	prop->AddValueMapping("Center", LVA_CENTER);
-	prop->AddValueMapping("Bottom", LVA_BOTTOM);
-	AddProperty(prop);
-
-	AddProperty(new StrProperty("Text", &mText));
-
-	SetDesiredSize(-1, -1);
-	mFont = GetFontManager()->LoadDefault();
-	SetText(text);
-}
-
-Label::~Label()
-{
-
-}
-
-void Label::OnSetProperty(const Str& name)
-{
-	if (name == "Text")
-	{
-		CalculateTextDimensions();
-	}
-	else
-	{
-		Widget::OnSetProperty(name);
-	}
-}
-
-void Label::SetText(Str value)
-{
-	mText = value;
-	CalculateTextDimensions();
-}
-
-void Label::CalculateTextDimensions()
-{
-	int32_t dimX, dimY;
-
-	TextRenderer* textRenderer = GetDevice()->GetRenderer()->GetTextRenderer();
-	textRenderer->SetFont(mFont);
-	textRenderer->GetStrDimensions(mText, 0, dimX, dimY);
-
-	dimY = textRenderer->GetMaxTextHeight();
-
-	mTextSize.x = dimX;
-	mTextSize.y = dimY;
-
-	SetMinimumSize(dimX + 2, dimY + 2);
-}
-
-void Label::OnDraw(DrawingClipInfo& clipInfo)
-{
-	int32_t yy;
-	int32_t xx;
-
-	TextRenderer* textRenderer = GetDevice()->GetRenderer()->GetTextRenderer();
-	textRenderer->SetFont(mFont);
-
-	//mTextSize.y is the rendered text height, depending on mVerticalAlign place the yy
-	switch(mVerticalAlign)
-	{
-		case LVA_TOP:
-			yy = 0;
-		break;
-		case LVA_CENTER:
-			yy = (GetSize().y - mTextSize.y) / 2;
-		break;
-		case LVA_BOTTOM:
-			yy = GetSize().y - mTextSize.y;
-		break;
-	}
-
-	//mTextSize.x is the rendered text width, depending on mHorizontalAlign place the xx
-	switch(mHorizontalAlign)
-	{
-		case LHA_LEFT:
-			xx = 0;
-		break;
-		case LHA_CENTER:
-			xx = (GetSize().x - mTextSize.x) / 2;
-		break;
-		case LHA_RIGHT:
-			xx = GetSize().x - mTextSize.x;
-		break;
-	}
-	
-	textRenderer->SetColor(Color4(86, 134, 255));
-	textRenderer->Draw(mText, xx, yy);
-
-	Widget::OnDraw(clipInfo);
-}
-
-} //namespace Crown

+ 0 - 81
src/windowing/Label.h

@@ -1,81 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "Str.h"
-#include "Font.h"
-
-namespace Crown
-{
-
-enum LabelHorizontalAlign
-{
-	LHA_LEFT,
-	LHA_CENTER,
-	LHA_RIGHT
-};
-
-enum LabelVerticalAlign
-{
-	LVA_TOP,
-	LVA_CENTER,
-	LVA_BOTTOM
-};
-
-
-class Label: public Widget
-{
-public:
-	Label(Widget* parent, Str text = "");
-	virtual ~Label();
-
-	void SetText(Str value);
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-
-	inline void SetHorizontalAlign(LabelHorizontalAlign value)
-	 { mHorizontalAlign = value; }
-
-	inline void SetVerticalAlign(LabelVerticalAlign value)
-	 { mVerticalAlign = value; }
-
-	virtual void OnSetProperty(const Str& name);
-
-	virtual Str ToStr() const
-	 { return "Label"; }
-
-private:
-	Str mText;
-	Point32_t2 mTextSize;
-	Font* mFont;
-	LabelHorizontalAlign mHorizontalAlign;
-	LabelVerticalAlign mVerticalAlign;
-
-	void CalculateTextDimensions();
-};
-
-} //namespace Crown

+ 0 - 194
src/windowing/ListView.cpp

@@ -1,194 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "ListView.h"
-#include "Window.h"
-#include "Types.h"
-#include "Label.h"
-#include "Themes.h"
-#include "Device.h"
-#include "ScrollArea.h"
-#include "Auto.h"
-#include "XWMLReader.h"
-#include "Renderer.h"
-
-namespace Crown
-{
-
-bool DeserializeFromStr(List<Generic>& out, Str& input);
-
-ListViewItem::ListViewItem(Widget* parent):
-	Widget(parent), mInsideChild(false)
-{
-	SetFitToChildren(FTC_VERTICALLY);
-}
-
-ListViewItem::~ListViewItem()
-{
-
-}
-
-void ListViewItem::OnPreviewMouseIn(MouseEventArgs* /*args*/)
-{
-	mInsideChild = true;
-}
-
-void ListViewItem::OnPreviewMouseOut(MouseEventArgs* /*args*/)
-{
-	mInsideChild = false;
-}
-
-void ListViewItem::OnMouseUp(MouseButtonEventArgs* /*args*/)
-{
-	mListView->SetSelectedIndex(mItemIndex);
-}
-
-void ListViewItem::OnDraw(DrawingClipInfo& clipInfo)
-{
-	Widget::DrawInit(clipInfo);
-	Renderer* r = GetDevice()->GetRenderer();
-	int32_t mode = DM_NO_DRAW;
-	if (mListView->GetSelectedIndex() == mItemIndex)
-		mode |= DM_FILL;
-
-	if (mInsideChild)
-		mode |= DM_BORDER;
-
-	r->DrawRectangle(Point32_t2::ZERO, GetSize(), mode, Color4(0.2f, 0.4f, 1.0f), Color4(185, 213, 255));
-	
-	Widget::DrawChildren(clipInfo);
-}
-
-ListViewItem* ListViewDefaultTemplate::GenerateItem(const Generic& element)
-{
-	ListViewItem* lwi = new ListViewItem(NULL);
-
-	Label* label = new Label(lwi->GetContentWidget());
-	label->SetText(element.asStr());
-	label->SetMargins(2, 2, 2, 2);
-	
-	return lwi;
-}
-
-ListView::ListView(Widget* parent):
-	ItemsSelector(parent)
-{
-  ScrollArea* scroll = new ScrollArea(GetContentWidget());
-	mListViewItemsLayout = new StackLayout(scroll->GetContentWidget());
-	mListViewItemsLayout->SetMargins(1, 1, 0, 1);
-  
-	mItemTemplate = new ListViewDefaultTemplate();
-}
-
-ListView::~ListView()
-{
-	delete mItemTemplate;
-}
-
-void ListView::OnDraw(DrawingClipInfo& clipInfo)
-{
-	Widget::DrawInit(clipInfo);
-	Themes::Draw(TF_LISTVIEW, GetSize());
-
-	Widget::DrawChildren(clipInfo);
-}
-
-void ListView::RegenerateItemsWidgets()
-{
-	for (int32_t i=0; i<mListViewItems.GetSize(); i++)
-	{
-		mListViewItems[i]->Destroy();
-	}
-
-	mListViewItems.Clear();
-
-	if (GetItems() != NULL)
-	{
-		for (int32_t i=0; i<GetItems()->GetSize(); i++)
-		{
-			ListViewItem* lwi = NULL;
-		
-			if (GetItemTemplate() != NULL)
-			{
-				IWithProperties* withProperties;
-				if (GetItems()->GetElement(i).asType(&withProperties))
-				{
-					//It is an item that has properties, if a template is available use it!
-					lwi = new ListViewItem(mListViewItemsLayout);
-					lwi->SetLogicalParent(this);
-					lwi->ApplyTemplate(GetItemTemplate());
-					lwi->SetBindingContext(withProperties);
-				}
-			}
-
-			if (lwi == NULL)
-			{
-				//Not using template, generate default
-				lwi = mItemTemplate->GenerateItem(GetItems()->GetElement(i));
-				lwi->AttachToParent(mListViewItemsLayout);
-			}
-
-			//lwi->AttachToParent(mListViewItemsLayout);
-			lwi->mListView = this;
-			lwi->mItemIndex = i;
-
-			mListViewItems.Append(lwi);
-		}
-	}
-
-	NotifyNeedsLayout();
-}
-
-void ListView::InternalSelectionChanged()
-{
-}
-
-void ListView::InternalItemsChanged()
-{
-	RegenerateItemsWidgets();
-}
-
-void ListView::OnItemTemplateChanged()
-{
-	RegenerateItemsWidgets();
-}
-
-bool DeserializeFromStr(List<Generic>& out, Str& input)
-{
-	List<Str> items;
-
-	if (input[0] != '[' || input[input.GetLength() - 1] != ']')
-		return false;
-
-	input = input.GetSubstring(1, input.GetLength() - 1);
-	input.Split(',', items);
-
-	for(int32_t i=0; i<items.GetSize(); i++)
-		out.Append(items[i]);
-	
-	return true;
-}
-
-}

+ 0 - 91
src/windowing/ListView.h

@@ -1,91 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "ItemsSelector.h"
-#include "StackLayout.h"
-#include "ITemplate.h"
-
-namespace Crown
-{
-
-class ListView;
-class XMLNode;
-
-class ListViewItem: public Widget
-{
-public:
-	ListViewItem(Widget* parent);
-	virtual ~ListViewItem();
-
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-
-	virtual Str ToStr() const
-	 { return "ListViewItem"; }
-
-private:
-	bool mInsideChild;
-	ListView* mListView;
-	int32_t mItemIndex;
-
-	virtual void OnPreviewMouseIn(MouseEventArgs* args);
-	virtual void OnPreviewMouseOut(MouseEventArgs* args);
-	virtual void OnMouseUp(MouseButtonEventArgs* args);
-
-	friend class ListView;
-};
-
-class ListViewDefaultTemplate: public ITemplate<ListViewItem>
-{
-public:
-	ListViewItem* GenerateItem(const Generic& element);
-};
-
-class ListView: public ItemsSelector
-{
-public:
-	ListView(Widget* parent);
-	virtual ~ListView();
-
-	void OnDraw(DrawingClipInfo& clipInfo);
-
-	virtual Str ToStr() const
-	 { return "ListView"; }
-
-private:
-	StackLayout* mListViewItemsLayout;
-	List<Widget*> mListViewItems;
-	ITemplate<ListViewItem>* mItemTemplate;
-
-	virtual void InternalSelectionChanged();
-	virtual void InternalItemsChanged();
-	virtual void OnItemTemplateChanged();
-
-	void RegenerateItemsWidgets();
-};
-
-}

+ 0 - 61
src/windowing/Property.cpp

@@ -1,61 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Property.h"
-
-namespace Crown
-{
-
-Property::Property(const Str& name):
-	mName(name)
-{
-
-}
-
-PropertyPipe::PropertyPipe(const Str& name, Property* prop):
-	Property(name), mProperty(prop)
-{
-	if (prop == NULL)
-	{
-		throw ArgumentException("PropertyPipe must bind to a valid property, NULL is not allowed");
-	}
-}
-
-PropertyType PropertyPipe::GetType() const
-{
-	return mProperty->GetType();
-}
-
-Generic PropertyPipe::GetValue() const
-{
-	return mProperty->GetValue();
-}
-
-void PropertyPipe::SetValue(const Generic& value)
-{
-	mProperty->SetValue(value);
-}
-
-}

+ 0 - 121
src/windowing/Property.h

@@ -1,121 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Generic.h"
-#include "Str.h"
-#include "Delegate.h"
-
-namespace Crown
-{
-
-class Point32_t2;
-template <typename T>
-class List;
-class Widget;
-template <typename TKey, typename TValue>
-class Dictionary;
-//TODO: Move this declaration to somewhere more appropriate, It just doesn't seem right to declare this here
-typedef Dictionary<Str, IDelegate2<void, Widget*, List<Str>*>*> ActionDictionary;
-typedef IDelegate2<void, Widget*, List<Str>*> ActionDelegate;
-
-enum PropertyType
-{
-	PT_Undefined = 0,
-	/* -- Basic types -- */
-	PT_Int,
-	PT_UInt,
-	PT_UShort,
-	PT_Float,
-	PT_Bool,
-
-	/* -- Composite Types -- */
-	PT_Point32_t2,
-	PT_Str,
-	PT_Margins,
-	PT_Template,
-	PT_Action,
-	PT_GenericList
-};
-
-class Property
-{
-public:
-	Property(const Str& name);
-	virtual ~Property() {}
-
-	inline const Str& GetName()
-	  { return mName; }
-
-	virtual PropertyType GetType() const = 0;
-	virtual Generic GetValue() const = 0;
-	virtual void SetValue(const Generic& value) = 0;
-
-private:
-	Str mName;
-};
-
-class PropertyPipe: public Property
-{
-public:
-	PropertyPipe(const Str& name, Property* prop);
-
-	virtual PropertyType GetType() const;
-	virtual Generic GetValue() const;
-	virtual void SetValue(const Generic& value);
-private:
-	Property* mProperty;
-};
-
-struct Margins
-{
-	Margins(int32_t l, int32_t t, int32_t r, int32_t b)
-	{
-		left = l;
-		top = t;
-		right = r;
-		bottom = b;
-	}
-
-	int32_t left;
-	int32_t top;
-	int32_t right;
-	int32_t bottom;
-
-	//! Calculate the fixed margins in the x direction.
-	int32_t GetFixedMarginsX() const
-	{
-		return (left > 0 ? left : 0) + (right > 0 ? right : 0);
-	}
-
-	//! Calculate the fixed margins in the y direction.
-	int32_t GetFixedMarginsY() const
-	{
-		return (top > 0 ? top : 0) + (bottom > 0 ? bottom : 0);
-	}
-};
-
-}

+ 0 - 83
src/windowing/ScrollArea.cpp

@@ -1,83 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "ScrollArea.h"
-#include "StackLayout.h"
-#include "Button.h"
-#include "CanvasLayout.h"
-
-namespace Crown
-{
-
-ScrollArea::ScrollArea(Widget* parent):
-	Widget(parent), mScrollX(false), mScrollY(true)
-{
-	StackLayout* sl = new StackLayout(this);
-	sl->SetOrientation(SO_HORIZONTAL);
-
-	mContainer = new Widget(sl);
-	mChildrenContainer = new Widget(mContainer);
-	mChildrenContainer->SetMargins(0, 0, -1, -1);
-	mChildrenContainer->SetFitToChildren((FitToChildrenEnum)((mScrollX ? FTC_HORIZONTALLY : FTC_NONE) | 
-																													 (mScrollY ? FTC_VERTICALLY : FTC_NONE)));
-
-	StackLayout* verticalBarSL = new StackLayout(sl);
-	verticalBarSL->SetDesiredSize(16, -1);
-
-	Button* btnScrollUp = new Button(verticalBarSL, "^");
-	Button* btnScrollDown = new Button(verticalBarSL, "v");
-	btnScrollUp->SetDesiredSize(-1, -1);
-	btnScrollDown->SetDesiredSize(-1, -1);
-
-	btnScrollUp->OnClickEvent += CreateDelegate(this, &ScrollArea::btnScrollUp_OnClick);
-	btnScrollDown->OnClickEvent += CreateDelegate(this, &ScrollArea::btnScrollDown_OnClick);
-}
-
-ScrollArea::~ScrollArea()
-{
-
-}
-
-Widget* ScrollArea::GetContentWidget()
-{
-  return mChildrenContainer;
-}
-
-void ScrollArea::btnScrollUp_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/)
-{
-	Point32_t2 pos = mChildrenContainer->GetTranslation();
-	if (pos.y < 0)
-		mChildrenContainer->SetTranslation(pos.x, Math::Min(0, pos.y + 10));
-}
-
-void ScrollArea::btnScrollDown_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/)
-{
-	Point32_t2 pos = mChildrenContainer->GetTranslation();
-	int32_t yval = -mChildrenContainer->GetSize().y + mContainer->GetSize().y;
-	if (pos.y > yval)
-		mChildrenContainer->SetTranslation(pos.x, Math::Max(yval, pos.y - 10));
-}
-
-}

+ 0 - 57
src/windowing/ScrollArea.h

@@ -1,57 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "SignalSlot.h"
-
-namespace Crown
-{
-
-class Button;
-
-class ScrollArea: public Widget
-{
-public:
-	ScrollArea(Widget* parent);
-	virtual ~ScrollArea();
-  
-  virtual Widget* GetContentWidget();
-
-	virtual Str ToStr() const
-	 { return "ScrollArea"; }
-
-private:
-	Widget* mContainer;
-	Widget* mChildrenContainer;
-	bool mScrollX, mScrollY;
-
-	void btnScrollUp_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/);
-	void btnScrollDown_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/);
-};
-
-} //namespace Crown

+ 0 - 359
src/windowing/SpecificProperties.cpp

@@ -1,359 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "SpecificProperties.h"
-#include "Log.h"
-#include "Point32_t2.h"
-#include "XMLReader.h"
-
-namespace Crown
-{
-
-inline Str SerializeToStr(const Margins& in)
-{
-	return Str(in.left) + ", " + Str(in.top) + ", " + Str(in.right) + ", " + Str(in.bottom);
-}
-
-bool DeserializeFromStr(Margins& out, Str& input)
-{
-	List<Str> coords;
-	input.Split(',', coords);
-
-	if (coords.GetSize() != 4)
-		return false;
-
-	if (!coords[0].ParseInt(&out.left))
-		return false;
-	if (!coords[1].ParseInt(&out.top))
-		return false;
-	if (!coords[2].ParseInt(&out.right))
-		return false;
-	if (!coords[3].ParseInt(&out.bottom))
-		return false;
-	
-	return true;
-}
-
-IntProperty::IntProperty(const Str& name, int32_t* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType IntProperty::GetType() const
-{
-	return PT_Int;
-}
-
-Generic IntProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void IntProperty::SetValue(const Generic& value)
-{
-	if (!value.asInt(*mValuePtr))
-	{
-		Log::E("Value not valid for Int property '" + GetName() + "'");
-	}
-}
-
-UIntProperty::UIntProperty(const Str& name, uint32_t* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType UIntProperty::GetType() const
-{
-	return PT_UInt;
-}
-
-Generic UIntProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void UIntProperty::SetValue(const Generic& value)
-{
-	if (!value.asUInt(*mValuePtr))
-	{
-		Log::E("Value not valid for UInt property '" + GetName() + "'");
-	}
-}
-
-UShortProperty::UShortProperty(const Str& name, uint16_t* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType UShortProperty::GetType() const
-{
-	return PT_UShort;
-}
-
-Generic UShortProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void UShortProperty::SetValue(const Generic& value)
-{
-	if (!value.asUShort(*mValuePtr))
-	{
-		Log::E("Value not valid for UShort property '" + GetName() + "'");
-	}
-}
-
-FloatProperty::FloatProperty(const Str& name, float* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType FloatProperty::GetType() const
-{
-	return PT_Float;
-}
-
-Generic FloatProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void FloatProperty::SetValue(const Generic& value)
-{
-	if (!value.asFloat(*mValuePtr))
-	{
-		Log::E("Value not valid for Float property '" + GetName() + "'");
-	}
-}
-
-Point32_t2Property::Point32_t2Property(const Str& name, Point32_t2* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType Point32_t2Property::GetType() const
-{
-	return PT_Point32_t2;
-}
-
-Generic Point32_t2Property::GetValue() const
-{
-	return Generic(SerializeToStr(*mValuePtr));
-}
-
-void Point32_t2Property::SetValue(const Generic& value)
-{
-	Str val = value.asStr();
-	if (!DeserializeFromStr(*mValuePtr, (Str&)val))
-	{
-		Log::E("Value not valid for Point32_t2 property '" + GetName() + "'");
-	}
-}
-
-StrProperty::StrProperty(const Str& name, Str* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType StrProperty::GetType() const
-{
-	return PT_Str;
-}
-
-Generic StrProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void StrProperty::SetValue(const Generic& value)
-{
-	if (!value.asStr(*mValuePtr))
-	{
-		Log::E("Value not valid for Str property '" + GetName() + "'");
-	}
-}
-
-MarginsProperty::MarginsProperty(const Str& name, Margins* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType MarginsProperty::GetType() const
-{
-	return PT_Margins;
-}
-
-Generic MarginsProperty::GetValue() const
-{
-	return Generic(SerializeToStr(*mValuePtr));
-}
-
-void MarginsProperty::SetValue(const Generic& value)
-{
-	Str val = value.asStr();
-	if (!DeserializeFromStr(*mValuePtr, (Str&)val))
-	{
-		Log::E("Value not valid for Margins property '" + GetName() + "'");
-	}
-}
-
-TemplateProperty::TemplateProperty(const Str& name, XMLNode** valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType TemplateProperty::GetType() const
-{
-	return PT_Template;
-}
-
-Generic TemplateProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void TemplateProperty::SetValue(const Generic& value)
-{
-	XMLNode* node = NULL;
-	if (!value.asType<XMLNode*>(&node))
-	{
-		Log::E("The TemplateProperty wants an XMLNode representing the template informations");
-		return;		
-	}
-
-	if (*mValuePtr != NULL)
-	{
-		delete *mValuePtr;
-	}
-	*mValuePtr = node->Clone();
-}
-
-IWithPropertiesProperty::IWithPropertiesProperty(const Str& name, IWithProperties** valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType IWithPropertiesProperty::GetType() const
-{
-	return PT_Template;
-}
-
-Generic IWithPropertiesProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void IWithPropertiesProperty::SetValue(const Generic& value)
-{
-	IWithProperties* castedValue = NULL;
-	if (!value.asType<IWithProperties*>(&castedValue))
-	{
-		Log::E("The IWithPropertiesProperty wants an object implementing the int32_terface IWithProperties");
-		return;		
-	}
-
-	*mValuePtr = castedValue;
-}
-
-//GenericListProperty::GenericListProperty(const Str& name, Shared<IList<Generic> >* valuePtr):
-//	Property(name), mValuePtr(valuePtr)
-//{
-
-//}
-
-//PropertyType GenericListProperty::GetType() const
-//{
-//	return PT_GenericList;
-//}
-
-//Generic GenericListProperty::GetValue() const
-//{
-//	return Generic(mValuePtr->GetPoint32_ter());
-//}
-
-//void GenericListProperty::SetValue(const Generic& value)
-//{
-//	if (value.GetType() == Generic::GT_List)
-//	{
-//		if (value.asList(*mValuePtr))
-//		{
-//			return;
-//		}
-//	}
-
-
-//	//if (!DeserializeFromStr(*mValuePtr, value.asStr()))
-//	//{
-//	//	Log::E("Value not valid for Margins property '" + GetName() + "'");
-//	//}
-//}
-
-
-EnumProperty::EnumProperty(const Str& name, int32_t* valuePtr):
-	Property(name), mValuePtr(valuePtr)
-{
-
-}
-
-PropertyType EnumProperty::GetType() const
-{
-	return PT_Int;
-}
-
-Generic EnumProperty::GetValue() const
-{
-	return Generic(*mValuePtr);
-}
-
-void EnumProperty::AddValueMapping(const Str& valueName, int32_t enumValue)
-{
-	EnumPropertyPair pair = {valueName, enumValue};
-	mValuesMapping.Append(pair);
-}
-
-void EnumProperty::SetValue(const Generic& value)
-{
-	const Str& strValue = value.asStr();
-	for(int32_t i = 0; i < mValuesMapping.GetSize(); i++)
-	{
-		if (strValue == mValuesMapping[i].valueName)
-		{
-			*mValuePtr = mValuesMapping[i].enumValue;
-			return;
-		}
-	}
-	Log::E("Value '" + strValue + "' not valid for Enum property '" + GetName() + "'");
-}
-
-}

+ 0 - 278
src/windowing/SpecificProperties.h

@@ -1,278 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Property.h"
-#include "WindowsManager.h"
-#include "Auto.h"
-#include "XWMLReader.h"
-#include "WindowContext.h"
-
-namespace Crown
-{
-
-class XMLNode;
-
-class IntProperty: public Property
-{
-public:
-	IntProperty(const Str& name, int32_t* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	int32_t* mValuePtr;
-};
-
-class UIntProperty: public Property
-{
-public:
-	UIntProperty(const Str& name, uint32_t* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	uint32_t* mValuePtr;
-};
-
-class UShortProperty: public Property
-{
-public:
-	UShortProperty(const Str& name, uint16_t* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	uint16_t* mValuePtr;
-};
-
-class FloatProperty: public Property
-{
-public:
-	FloatProperty(const Str& name, float* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	float* mValuePtr;
-};
-
-class Point32_t2Property: public Property
-{
-public:
-	Point32_t2Property(const Str& name, Point32_t2* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	Point32_t2* mValuePtr;
-};
-
-class StrProperty: public Property
-{
-public:
-	StrProperty(const Str& name, Str* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	Str* mValuePtr;
-};
-
-class MarginsProperty: public Property
-{
-public:
-	MarginsProperty(const Str& name, Margins* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	Margins* mValuePtr;
-};
-
-class TemplateProperty: public Property
-{
-public:
-	TemplateProperty(const Str& name, XMLNode** valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	XMLNode** mValuePtr;
-};
-
-class IWithPropertiesProperty: public Property
-{
-public:
-	IWithPropertiesProperty(const Str& name, IWithProperties** valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-private:
-	IWithProperties** mValuePtr;
-};
-
-//class GenericListProperty: public Property
-//{
-//public:
-//	GenericListProperty(const Str& name, Shared<IList<Generic> >* valuePtr);
-
-//	PropertyType GetType() const;
-//	Generic GetValue() const;
-//	void SetValue(const Generic& value);
-
-//private:
-//	Shared<IList<Generic> >* mValuePtr;
-//};
-
-class EnumProperty: public Property
-{
-public:
-	EnumProperty(const Str& name, int32_t* valuePtr);
-
-	PropertyType GetType() const;
-	Generic GetValue() const;
-	void SetValue(const Generic& value);
-
-	void AddValueMapping(const Str& valueName, int32_t enumValue);
-
-private:
-	struct EnumPropertyPair
-	{
-		Str valueName;
-		int32_t enumValue;
-
-		bool operator==(const EnumPropertyPair& other)
-		{
-			return (valueName == other.valueName && enumValue == other.enumValue);
-		}
-	};
-
-	int32_t* mValuePtr;
-	List<EnumPropertyPair> mValuesMapping;
-};
-
-template <typename TSource, typename TArg1>
-class ActionProperty: public Property, public WeakReferenced
-{
-private:
-	//! Finds the specified action and register it to be executed when the given event fires
-	bool FindActionAndAddToEvent(const Str& actionStr, MulticastEvent<TSource, TArg1>& multicastEvent);
-	void GenericActionInvoker(TSource* button, TArg1 e, ActionDelegate* action, List<Str>* args);
-
-public:
-	ActionProperty(const Str& name, MulticastEvent<TSource, TArg1>* valuePtr, Widget* widget):
-		Property(name), mValuePtr(valuePtr), mWidget(widget)
-	{
-
-	}
-
-	PropertyType GetType() const
-	{
-		return PT_Action;
-	}
-
-	Generic GetValue() const
-	{
-		return mActionStr;
-	}
-
-	void SetValue(const Generic& value)
-	{
-		mActionStr = value.asStr();
-		FindActionAndAddToEvent(mActionStr, *mValuePtr);
-	}
-
-private:
-	MulticastEvent<TSource, TArg1>* mValuePtr;
-	Widget* mWidget;
-	Str mActionStr;
-};
-
-template <typename TSource, typename TArg1>
-bool ActionProperty<TSource, TArg1>::FindActionAndAddToEvent(const Str& actionStr, MulticastEvent<TSource, TArg1>& multicastEvent)
-{
-	Window* wnd = mWidget->GetWindow();
-	if (!wnd)
-	{
-		Log::E("Unable to find an Action in a widget not connected to a WindowsManager");
-		return false;
-	}
-
-	Auto<List<Str> > args = new List<Str>();
-	Str actionName;
-	if (!XWMLReader::ParseAction(actionStr, actionName, args.GetPoint32_ter()))
-	{
-		Log::E("Action '" + actionStr + "' is in an invalid format");
-		return false;
-	}
-
-	WindowContext* context = wnd->GetWindowContext();
-	ActionDelegate* action = NULL;
-	if (context != NULL)
-	{
-		action = context->GetRegisteredAction(actionName);
-	}
-	if (action == NULL)
-	{
-		action = wnd->GetWindowsManager()->GetRegisteredAction(actionName);
-	}
-
-	if (action == NULL)
-	{
-		Log::E("Action '" + actionName + "' is not registered in the current WindowContext or in the WindowsManager");
-		return false;
-	}
-
-	multicastEvent += CreateDelegate(this, &ActionProperty::GenericActionInvoker, (TSource*)NULL, (TArg1)NULL, action, args.GetPoint32_ter(true));
-	return true;
-}
-
-template <typename TSource, typename TArg1>
-void ActionProperty<TSource, TArg1>::GenericActionInvoker(TSource* sourceWidget, TArg1 e, ActionDelegate* action, List<Str>* args)
-{
-	action->Invoke(sourceWidget, args);
-}
-
-}

+ 0 - 277
src/windowing/TextBox.cpp

@@ -1,277 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "TextBox.h"
-#include "Themes.h"
-#include "Types.h"
-#include "Device.h"
-#include "GLTextRenderer.h"
-#include "FontManager.h"
-#include "SpecificProperties.h"
-#include "Renderer.h"
-#include "InputManager.h"
-
-namespace Crown
-{
-
-TextBox::TextBox(Widget* parent, const Str& text):
-	Widget(parent), mDisplayedTextIndex(0), mDisplayedTextX(0),
-	mDisplayedTextOffset(0), mCaretIndex(0)
-{
-	AddProperty(new StrProperty("Text", &mText));
-
-	mFont = GetFontManager()->LoadDefault();
-	mTextRenderer = GetDevice()->GetRenderer()->GetTextRenderer();
-	mTextRenderer->SetFont(mFont);
-
-	SetText(text);
-
-	SetDesiredSize(-1, 20);
-}
-
-TextBox::~TextBox()
-{
-}
-
-void TextBox::SetText(const Str& value)
-{
-	mText = value;
-	AfterTextSet();
-}
-
-void TextBox::OnSetProperty(const Str& name)
-{
-	if (name == "Text")
-	{
-		AfterTextSet();
-	}
-	else
-	{
-		Widget::OnSetProperty(name);
-	}
-}
-
-void TextBox::AfterTextSet()
-{
-	if (mCaretIndex > mText.GetLength())
-	{
-		mCaretIndex = mText.GetLength();	
-	}
-
-	if (mDisplayedTextIndex > mText.GetLength())
-	{
-		mDisplayedTextIndex = mText.GetLength();
-	}
-	
-	UpdateCaretScreenPosition();
-	UpdateDisplayedText();
-	ScrollCaretIntoView();
-}
-
-void TextBox::ScrollCaretIntoView()
-{
-	mTextRenderer->SetFont(mFont);
-	if (mCaretCharPosition.x > mDisplayedTextX + mDisplayedTextOffset + Math::Max(0, GetSize().x - 6))
-	{
-		//scroll right
-		mDisplayedTextX = mCaretCharPosition.x - Math::Max(0, (int32_t)GetSize().x - 6);
-		Point32_t2 dummy;
-		mDisplayedTextIndex = mTextRenderer->GetStrIndexFromDimensions(mText, 0, Point32_t2(mDisplayedTextX - 10, 0), dummy);
-		mDisplayedTextOffset = mDisplayedTextX - dummy.x;
-		mDisplayedTextX = dummy.x;
-
-		UpdateDisplayedText();
-	}
-	if (mCaretCharPosition.x < mDisplayedTextX + mDisplayedTextOffset)
-	{
-		//scroll left
-		mDisplayedTextX = mCaretCharPosition.x;
-		Point32_t2 dummy;
-		mDisplayedTextIndex = mTextRenderer->GetStrIndexFromDimensions(mText, 0, Point32_t2(mDisplayedTextX - 10, 0), dummy);
-		mDisplayedTextOffset = mDisplayedTextX - dummy.x;
-		mDisplayedTextX = dummy.x;
-
-		UpdateDisplayedText();
-	}
-}
-
-void TextBox::UpdateDisplayedText()
-{
-	mTextRenderer->SetFont(mFont);
-	uint32_t mEndIndex;
-
-	mEndIndex = mTextRenderer->GetStrIndexFromDimensions(mText, mDisplayedTextIndex, Point32_t2((int32_t)GetSize().x, (int32_t)GetSize().y) + Point32_t2(mDisplayedTextOffset, 0), mDisplayedTextDimensions);
-	if (mEndIndex < mText.GetLength())
-		mEndIndex++;
-	mDisplayedText = mText.GetSubstring(mDisplayedTextIndex, mEndIndex);
-}
-
-void TextBox::UpdateCaretScreenPosition()
-{
-	mTextRenderer->SetFont(mFont);
-	mTextRenderer->GetStrDimensions(mText, 0, mCaretIndex, mCaretCharPosition.x, mCaretCharPosition.y);
-	mCaretCharPosition.y = 0;
-}
-
-void TextBox::MoveCaretLeft()
-{
-	if (mCaretIndex == 0)
-		return;
-
-	mTextRenderer->SetFont(mFont);
-
-	Point32_t2 charSize;
-	mTextRenderer->GetStrDimensions(mText, mCaretIndex-1, mCaretIndex, charSize.x, charSize.y);
-	mCaretCharPosition.x -= charSize.x;
-	mCaretIndex--;
-	ScrollCaretIntoView();
-}
-
-void TextBox::MoveCaretRight()
-{
-	if (mCaretIndex == mText.GetLength())
-		return;
-
-	mTextRenderer->SetFont(mFont);
-
-	Point32_t2 charSize;
-	mTextRenderer->GetStrDimensions(mText, mCaretIndex, mCaretIndex+1, charSize.x, charSize.y);
-	
-	mCaretCharPosition.x += charSize.x;
-	mCaretIndex++;
-	ScrollCaretIntoView();
-}
-
-void TextBox::OnTextInput(TextInputEventArgs* args)
-{
-	args->StopPropagation(true);
-	
-	if (args->GetText() == "\b")
-		return;
-
-	Str before, after;
-	if (mCaretIndex > 0)
-		before = mText.GetSubstring(0, mCaretIndex);
-	if (mCaretIndex < mText.GetLength())
-		after = mText.GetSubstring(mCaretIndex, mText.GetLength());
-
-	mText = before + args->GetText() + after;
-	mCaretIndex += args->GetText().GetLength();
-
-	UpdateDisplayedText();
-	UpdateCaretScreenPosition();
-	ScrollCaretIntoView();
-}
-
-void TextBox::OnMouseUp(MouseButtonEventArgs* args)
-{
-	Widget::OnMouseUp(args);
-	if (args->IsClick())
-	{
-		args->StopPropagation(true);
-		GetFocus();
-
-		mTextRenderer->SetFont(mFont);
-		
-		//Find the caret position
-		Point32_t2 mousePosition = GetDevice()->GetInputManager()->GetMouse()->GetCursorXY() - GetScreenPosition();
-		mousePosition += Point32_t2(-2 + mDisplayedTextOffset, -2);
-		mCaretIndex = mTextRenderer->GetStrIndexFromDimensions(mText, mDisplayedTextIndex, mousePosition, mCaretCharPosition);
-		mCaretCharPosition.x += mDisplayedTextX;
-		ScrollCaretIntoView();
-	}
-}
-
-void TextBox::OnKeyDown(KeyboardEventArgs* args)
-{
-	Widget::OnKeyDown(args);
-	args->StopPropagation(true);
-	switch (args->GetKey())
-	{
-		case KC_LEFT:
-			MoveCaretLeft();
-			break;
-
-		case KC_RIGHT:
-			MoveCaretRight();
-			break;
-
-		case KC_BACKSPACE:
-			if (mCaretIndex > 0)
-			{
-				mCaretIndex--;
-				SetText(mText.GetSubstring(0, mCaretIndex) + mText.GetSubstring(mCaretIndex+1, mText.GetLength()));
-			}
-			break;
-			
-		default:
-			break;
-	}
-}
-
-void TextBox::OnSizeChanged(WindowingEventArgs* /*args*/)
-{
-	UpdateDisplayedText();
-}
-
-void TextBox::OnDraw(DrawingClipInfo& clipInfo)
-{
-	Widget::DrawInit(clipInfo);
-	Themes::Draw(TF_LISTVIEW, GetSize());
-
-	Renderer* r = GetDevice()->GetRenderer();
-
-	mTextRenderer->SetFont(mFont);
-
-	Point32_t2 sPos = GetScreenPosition();
-	//r->_SetScissorParams(sPos.x+1, 600 - (sPos.y + GetSize().y-2), GetSize().x-2, GetSize().y-4);
-	r->SetScissorBox(clipInfo.sx + 1, clipInfo.sy + 1, clipInfo.sw - 2, clipInfo.sh - 2);
-
-	int32_t yy;
-	yy = (int32_t)((GetSize().y - 4 - mTextRenderer->GetMaxTextHeight()) / 2.0f);
-
-	bool hasFocus = HasTextInputFocus();
-
-	if (hasFocus)
-	{
-		mTextRenderer->SetColor(Color4(255 / 255.0f, 134 / 255.0f, 86 / 255.0f));
-	}
-	else
-	{
-		mTextRenderer->SetColor(Color4(86 / 255.0f, 134 / 255.0f, 255 / 255.0f));
-	}
-
-	mTextRenderer->Draw(mDisplayedText, 3 - mDisplayedTextOffset, 2 + yy);
-
-	if (hasFocus)
-	{
-		r->DrawRectangle(mCaretCharPosition + Point32_t2(3 - mDisplayedTextX - mDisplayedTextOffset, 2 + yy - 1),
-		                 Point32_t2(1, mTextRenderer->GetMaxTextHeight() + 2), DM_BORDER);
-	}
-
-	Widget::DrawChildren(clipInfo);
-}
-
-} //namespace Crown

+ 0 - 86
src/windowing/TextBox.h

@@ -1,86 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "Str.h"
-#include "TextRenderer.h"
-#include "Font.h"
-
-namespace Crown
-{
-
-class TextBox: public Widget
-{
-public:
-	TextBox(Widget* parent, const Str& text = "");
-	virtual ~TextBox();
-
-	void SetText(const Str& value);
-	inline const Str& GetText() const
-	{
-		return mText;
-	}
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-
-	virtual void OnSetProperty(const Str& name);
-
-	virtual Str ToStr() const
-	 { return "TextBox"; }
-
-protected:
-	virtual void OnTextInput(TextInputEventArgs* args);
-	virtual void OnMouseUp(MouseButtonEventArgs* args);
-	virtual void OnKeyDown(KeyboardEventArgs* args);
-	virtual void OnSizeChanged(WindowingEventArgs* args);
-
-private:
-	Str mText;
-	Str mDisplayedText;
-	uint32_t mDisplayedTextIndex; //< Index in mText of the first character of the displayed text
-
-	int32_t mDisplayedTextX;
-	Point32_t2 mDisplayedTextDimensions;
-	int32_t mDisplayedTextOffset;
-
-	
-	uint32_t mCaretIndex;
-	Point32_t2 mCaretCharPosition;
-
-	TextRenderer* mTextRenderer;
-	Font* mFont;
-
-	void AfterTextSet();
-
-	void ScrollCaretIntoView();
-	void UpdateDisplayedText();
-	void UpdateCaretScreenPosition();
-	void MoveCaretLeft();
-	void MoveCaretRight();
-};
-
-} //namespace Crown

+ 0 - 68
src/windowing/ThemeSpriteWidget.h

@@ -1,68 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "Themes.h"
-
-namespace Crown
-{
-
-class ThemeSpriteWidget: public Widget
-{
-public:
-	ThemeSpriteWidget(Widget* p, ThemesSprites spriteId, uint32_t frameNumber):
-		Widget(p), mSpriteId(spriteId), mFrameNumber(frameNumber)
-	{
-		Sprite* spr = Themes::GetSprite(spriteId);
-
-		if (spr)
-		{
-			Frame* fr = spr->GetFrame(frameNumber);
-			SetDesiredSize((int32_t)fr->GetSize().x, (int32_t)fr->GetSize().y);
-		}
-
-		SetMouseSensible(false);
-	}
-
-	virtual ~ThemeSpriteWidget()
-	{
-	}
-
-	void OnDraw(DrawingClipInfo& clipInfo)
-	{
-		Themes::Draw(mSpriteId, mFrameNumber);
-
-		Widget::OnDraw(clipInfo);
-	}
-
-private:
-	ThemesSprites mSpriteId;
-	uint32_t mFrameNumber;
-};
-
-} //namespace Crown

+ 0 - 77
src/windowing/Themes.cpp

@@ -1,77 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Themes.h"
-#include "Types.h"
-
-namespace Crown
-{
-
-ITheme* Themes::mCurrentTheme;
-
-Themes::Themes()
-{
-}
-
-Themes::~Themes()
-{
-}
-
-void Themes::LoadTheme(ITheme* theme)
-{
-	if (mCurrentTheme != NULL)
-	{
-		delete mCurrentTheme;
-	}
-
-	mCurrentTheme = theme;
-}
-
-void Themes::Draw(ThemesFunctions functionId, const Point32_t2& size)
-{
-	ThemeFunction func = mCurrentTheme->GetFunction(functionId);
-
-	if (func)
-	{
-		func(size);
-	}
-}
-
-void Themes::Draw(ThemesSprites spriteId, uint32_t frameNumber)
-{
-	Sprite* spr = mCurrentTheme->GetSprite(spriteId);
-
-	if (spr)
-	{
-		spr->draw(frameNumber);
-	}
-}
-
-Sprite* Themes::GetSprite(ThemesSprites spriteId)
-{
-	return mCurrentTheme->GetSprite(spriteId);
-}
-
-} //namespace Crown

+ 0 - 78
src/windowing/Themes.h

@@ -1,78 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Point32_t2.h"
-#include "Sprite.h"
-
-namespace Crown
-{
-
-enum ThemesFunctions
-{
-	TF_BUTTON_NORMAL = 0,
-	TF_BUTTON_HIGHLIGHTED,
-	TF_BUTTON_PRESSED,
-	TF_WINDOW,
-	TF_LISTVIEW
-};
-
-enum ThemesSprites
-{
-	TS_CLOSEBUTTON_X = 0,
-	TS_BOOM
-};
-
-typedef void (*ThemeFunction)(const Point32_t2& size);
-
-class ITheme
-{
-public:
-
-	virtual ~ITheme() {}
-
-	virtual ThemeFunction GetFunction(ThemesFunctions functionId) = 0;
-	virtual Sprite* GetSprite(ThemesSprites spriteId) = 0;
-};
-
-class Themes
-{
-public:
-	~Themes();
-
-	static void LoadTheme(ITheme* theme);
-	static void Draw(ThemesFunctions functionId, const Point32_t2& size);
-	static void Draw(ThemesSprites spriteId, uint32_t frameNumber);
-	static Sprite* GetSprite(ThemesSprites spriteId);
-
-private:
-	Themes();
-
-	static ITheme* mCurrentTheme;
-};
-
-} //namespace Crown

+ 0 - 344
src/windowing/TreeView.cpp

@@ -1,344 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "TreeView.h"
-#include "Window.h"
-#include "Types.h"
-#include "Label.h"
-#include "Themes.h"
-#include "Device.h"
-#include "ScrollArea.h"
-#include "WithProperties.h"
-#include "XWMLReader.h"
-#include "Renderer.h"
-
-namespace Crown
-{
-
-TreeViewItem::TreeViewItem(Widget* parent, TreeView* tree):
-	ItemsSelector(parent), mInsideChild(false), mTreeView(tree), mIsExpanded(false), mExpandButton(NULL),
-	mContentWidget(NULL)
-{
-	SetFitToChildren(FTC_VERTICALLY);
-
-	StackLayout* sl = new StackLayout(this);
-
-	StackLayout* sl1 = new StackLayout(sl);
-	sl1->SetOrientation(SO_HORIZONTAL);
-
-	mExpandButton = new Button(sl1);
-	mExpandButton->SetDesiredSize(8, 8);
-	mExpandButton->SetMargins(2, -1, 2, -1);
-
-	mContentWidget = new Widget(sl1);
-
-	mTreeViewItemsLayout = new StackLayout(sl);
-	mTreeViewItemsLayout->SetVisibility(WV_COLLAPSED);
-  
-	mItemTemplate = new TreeViewDefaultTemplate(mTreeView);
-
-	mExpandButton->OnClickEvent += CreateDelegate(this, &TreeViewItem::ExpendedButton_OnClick);
-}
-
-TreeViewItem::~TreeViewItem()
-{
-
-}
-
-Widget* TreeViewItem::GetContentWidget()
-{
-	if (mContentWidget)
-		return mContentWidget;
-	return this;
-}
-
-void TreeViewItem::OnMouseIn(MouseEventArgs* args)
-{
-	mInsideChild = true;
-	args->StopPropagation(true);
-}
-
-void TreeViewItem::OnMouseOut(MouseEventArgs* args)
-{
-	mInsideChild = false;
-	args->StopPropagation(true);
-}
-
-void TreeViewItem::OnMouseUp(MouseButtonEventArgs* args)
-{
-	//mItemsSelector->SetSelectedIndex(mItemIndex);
-	mTreeView->SelectItem(mItemsSelector, mItemIndex);
-	args->StopPropagation(true);
-}
-
-void TreeViewItem::OnDraw(DrawingClipInfo& clipInfo)
-{
-	Widget::DrawInit(clipInfo);
-	Renderer* r = GetDevice()->GetRenderer();
-	//TODO: All this should be moved to state effects/styles in XWML files.
-	int32_t mode = DM_NO_DRAW;
-	if (mTreeView->mSelectorWithSelection == mItemsSelector && mTreeView->mSelectedIndex == mItemIndex)
-		mode |= DM_FILL;
-
-	if (mInsideChild)
-		mode |= DM_BORDER;
-
-	r->DrawRectangle(mContentWidget->GetRelativePosition(this), mContentWidget->GetSize(), mode, Color4(0.2f, 0.4f, 1.0f), Color4(185, 213, 255));
-	
-	Widget::DrawChildren(clipInfo);
-}
-
-void TreeViewItem::ExpendedButton_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/)
-{
-	if (mIsExpanded)
-		Collapse();
-	else
-		Expand();
-
-	mIsExpanded = !mIsExpanded;
-}
-
-void TreeViewItem::Expand()
-{
-	if (mIsExpanded)
-		return;
-
-	mTreeViewItemsLayout->SetVisibility(WV_VISIBLE);
-}
-
-void TreeViewItem::Collapse()
-{
-	if (!mIsExpanded)
-		return;
-
-	mTreeViewItemsLayout->SetVisibility(WV_COLLAPSED);
-}
-
-void TreeViewItem::InternalSelectionChanged()
-{
-
-}
-
-void TreeViewItem::InternalItemsChanged()
-{
-	RegenerateItemsWidgets();
-}
-
-void TreeViewItem::OnItemTemplateChanged()
-{
-	RegenerateItemsWidgets();
-}
-
-void TreeViewItem::RegenerateItemsWidgets()
-{
-	for (int32_t i=0; i<mTreeViewItems.GetSize(); i++)
-	{
-		mTreeViewItems[i]->Destroy();
-	}
-
-	mTreeViewItems.Clear();
-
-	if (GetItems() == NULL)
-	{
-		mExpandButton->SetVisibility(WV_HIDDEN);
-	}
-	else
-	{
-		if (GetItems()->GetSize() > 0)
-			mExpandButton->SetVisibility(WV_VISIBLE);
-		else
-			mExpandButton->SetVisibility(WV_HIDDEN);
-
-		for (int32_t i=0; i<GetItems()->GetSize(); i++)
-		{
-			TreeViewItem* lwi = NULL;
-		
-			if (GetItemTemplate() != NULL)
-			{
-				IWithProperties* withProperties;
-				if (GetItems()->GetElement(i).asType(&withProperties))
-				{
-					//It is an item that has properties, if a template is available use it!
-					lwi = new TreeViewItem(mTreeViewItemsLayout, mTreeView);
-					lwi->SetLogicalParent(this);
-					lwi->ApplyTemplate(GetItemTemplate());
-					lwi->SetBindingContext(withProperties);
-				}
-			}
-
-			if (lwi == NULL)
-			{
-				//Not using template, generate default
-				lwi = mItemTemplate->GenerateItem(GetItems()->GetElement(i));
-				lwi->AttachToParent(mTreeViewItemsLayout);
-			}
-
-			//lwi->AttachToParent(mTreeViewItemsLayout);
-			lwi->mItemsSelector = this;
-			lwi->mItemIndex = i;
-			lwi->SetMargins(10, 0, 0, 0);
-
-			mTreeViewItems.Append(lwi);
-		}
-	}
-
-	NotifyNeedsLayout();
-}
-
-TreeViewItem* TreeViewDefaultTemplate::GenerateItem(const Generic& element)
-{
-	TreeViewItem* lwi = new TreeViewItem(NULL, mTreeView);
-
-	Label* label = new Label(lwi->GetContentWidget());
-	Str str;
-	element.asStr(str);
-	label->SetText(str);
-	label->SetMargins(2, 4, 0, 4);
-	
-	return lwi;
-}
-
-TreeView::TreeView(Widget* parent):
-	ItemsSelector(parent), mSelectorWithSelection(NULL), mSelectedIndex(-1)
-{
-  
-  ScrollArea* scroll = new ScrollArea(GetContentWidget());
-	mTreeViewItemsLayout = new StackLayout(scroll->GetContentWidget());
-	mTreeViewItemsLayout->SetMargins(1, 1, 0, 1);
-  
-	mItemTemplate = new TreeViewDefaultTemplate(this);
-}
-
-TreeView::~TreeView()
-{
-	delete mItemTemplate;
-}
-
-Generic TreeView::GetSelectedItem() const
-{
-	if (mSelectorWithSelection)
-	{
-		if (mSelectorWithSelection == this)
-		{
-			return ItemsSelector::GetSelectedItem();
-		}
-		else
-		{
-			return mSelectorWithSelection->GetSelectedItem();
-		}
-	}
-	else
-	{
-		return Generic();
-	}
-}
-
-void TreeView::SelectItem(ItemsSelector* selector, int32_t index)
-{
-	if (mSelectorWithSelection)
-		mSelectorWithSelection->SetSelectedIndex(-1);
-
-	mSelectorWithSelection = selector;
-	mSelectedIndex = index;
-	selector->SetSelectedIndex(index);
-	if (mSelectorWithSelection != this)
-	{
-		//If mSelectorWithSelection is not the TreeView, the NotifyChange of SelectedItem must be raised
-		//if it is, SetSelectedIndex does the job
-		NotifyChangeEventArgs args("SelectedItem");
-		NotifyChange(&args);
-	}
-}
-
-void TreeView::OnDraw(DrawingClipInfo& clipInfo)
-{
-	Widget::DrawInit(clipInfo);
-	Themes::Draw(TF_LISTVIEW, GetSize());
-
-	Widget::DrawChildren(clipInfo);
-}
-
-void TreeView::InternalSelectionChanged()
-{
-}
-
-void TreeView::InternalItemsChanged()
-{
-	RegenerateItemsWidgets();
-}
-
-void TreeView::OnItemTemplateChanged()
-{
-	RegenerateItemsWidgets();
-}
-
-void TreeView::RegenerateItemsWidgets()
-{
-	Log::I("TreeView Regenerate");
-	for (int32_t i=0; i<mTreeViewItems.GetSize(); i++)
-	{
-		mTreeViewItems[i]->Destroy();
-	}
-
-	mTreeViewItems.Clear();
-
-	if (GetItems() != NULL)
-	{
-		for (int32_t i=0; i<GetItems()->GetSize(); i++)
-		{
-			TreeViewItem* lwi = NULL;
-		
-			if (GetItemTemplate() != NULL)
-			{
-				IWithProperties* withProperties;
-				if (GetItems()->GetElement(i).asType(&withProperties))
-				{
-					//It is an item that has properties, if a template is available use it!
-					lwi = new TreeViewItem(mTreeViewItemsLayout, this);
-					lwi->SetLogicalParent(this);
-					lwi->ApplyTemplate(GetItemTemplate());
-					lwi->SetBindingContext(withProperties);
-				}
-			}
-
-			if (lwi == NULL)
-			{
-				//Not using template, generate default
-				lwi = mItemTemplate->GenerateItem(GetItems()->GetElement(i));
-				lwi->AttachToParent(mTreeViewItemsLayout);
-			}
-
-			//lwi->AttachToParent(mTreeViewItemsLayout);
-			lwi->mItemsSelector = this;
-			lwi->mItemIndex = i;
-
-			mTreeViewItems.Append(lwi);
-		}
-	}
-
-	NotifyNeedsLayout();
-}
-
-}

+ 0 - 128
src/windowing/TreeView.h

@@ -1,128 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "ItemsSelector.h"
-#include "StackLayout.h"
-#include "ITemplate.h"
-#include "Button.h"
-
-namespace Crown
-{
-
-class TreeView;
-
-class TreeViewItem: public ItemsSelector
-{
-public:
-	TreeViewItem(Widget* parent, TreeView* tree);
-	virtual ~TreeViewItem();
-
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-	virtual Widget* GetContentWidget();
-
-	virtual Str ToStr() const
-	 { return "TreeViewItem"; }
-
-private:
-	bool mInsideChild;
-	ItemsSelector* mItemsSelector;
-	TreeView* mTreeView;
-	int32_t mItemIndex;
-	bool mIsExpanded;
-	Button* mExpandButton;
-	Widget* mContentWidget;
-	
-	StackLayout* mTreeViewItemsLayout;
-	List<Widget*> mTreeViewItems;
-	ITemplate<TreeViewItem>* mItemTemplate;
-
-	virtual void OnMouseIn(MouseEventArgs* args);
-	virtual void OnMouseOut(MouseEventArgs* args);
-	virtual void OnMouseUp(MouseButtonEventArgs* args);
-
-	void ExpendedButton_OnClick(Button* /*obj*/, Crown::EventArgs* /*args*/);
-
-	void Expand();
-	void Collapse();
-
-	virtual void InternalSelectionChanged();
-	virtual void InternalItemsChanged();
-	virtual void OnItemTemplateChanged();
-
-	void RegenerateItemsWidgets();
-
-	friend class TreeView;
-};
-
-class TreeViewDefaultTemplate: public ITemplate<TreeViewItem>
-{
-public:
-	TreeViewDefaultTemplate(TreeView* tw):
-		mTreeView(tw)
-	{
-
-	}
-
-	TreeViewItem* GenerateItem(const Generic& element);
-
-private:
-	TreeView* mTreeView;
-};
-
-class TreeView: public ItemsSelector
-{
-public:
-	TreeView(Widget* parent);
-	virtual ~TreeView();
-
-	virtual Generic GetSelectedItem() const;
-
-	void OnDraw(DrawingClipInfo& clipInfo);
-
-	virtual Str ToStr() const
-	 { return "TreeView"; }
-
-private:
-	StackLayout* mTreeViewItemsLayout;
-	List<Widget*> mTreeViewItems;
-	ITemplate<TreeViewItem>* mItemTemplate;
-	ItemsSelector* mSelectorWithSelection;
-	int32_t mSelectedIndex;
-
-	void SelectItem(ItemsSelector* selector, int32_t index);
-
-	virtual void InternalSelectionChanged();
-	virtual void InternalItemsChanged();
-	virtual void OnItemTemplateChanged();
-
-	void RegenerateItemsWidgets();
-
-	friend class TreeViewItem;
-};
-
-}

+ 0 - 1072
src/windowing/Widget.cpp

@@ -1,1072 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Widget.h"
-#include <GL/glew.h>
-#include <stdio.h>
-#include "Types.h"
-#include "WindowsManager.h"
-#include "Device.h"
-#include <limits>
-#include "Bind.h"
-#include "SpecificProperties.h"
-#include "XWMLReader.h"
-#include "Renderer.h"
-
-using namespace std;
-
-namespace Crown
-{
-
-bool Widget::mDrawDebugBorder = false;
-
-Widget::Widget(Widget* parent):
-	mDesiredPosition(0, 0), mDesiredSize(-1, -1),
-	mMaximumSize(numeric_limits<int32_t>::max(), numeric_limits<int32_t>::max()),	mMinimumSize(0, 0),
-	mPosition(0, 0), mSize(0, 0), mMargins(-1, -1, -1, -1), mParent(parent), mLogicalParent(parent), mVisibility(WV_VISIBLE),
-	mBindingContext(NULL), mIsMouseOver(false), mIsMouseSensible(true), mFitToChildren(FTC_NONE)
-{
-	if (mParent)
-	{
-		mParent->AddChild(this);
-	}
-
-	//By using specific properties such as IntProperty, we define how the Generic value should be int32_terpreted for each property
-	//TODO: Use converters where necessary
-	AddProperty(new IntProperty("Width", &mDesiredSize.x));
-	AddProperty(new IntProperty("Height", &mDesiredSize.y));
-	AddProperty(new IntProperty("MinimumWidth", &mMinimumSize.x));
-	AddProperty(new IntProperty("MinimumHeight", &mMinimumSize.y));
-	AddProperty(new IntProperty("MaximumWidth", &mMaximumSize.x));
-	AddProperty(new IntProperty("MaximumHeight", &mMaximumSize.y));
-	AddProperty(new Point32_t2Property("DesiredSize", &mDesiredSize));
-	AddProperty(new Point32_t2Property("MinimumSize", &mMinimumSize));
-	AddProperty(new Point32_t2Property("MaximumSize", &mMaximumSize));
-	AddProperty(new StrProperty("Name", &mName));
-	AddProperty(new MarginsProperty("Margins", &mMargins));
-
-	EnumProperty* prop = new EnumProperty("FitToChildren", (int32_t*)&mFitToChildren);
-	prop->AddValueMapping("None", FTC_NONE);
-	prop->AddValueMapping("Horizontally", FTC_HORIZONTALLY);
-	prop->AddValueMapping("Vertically", FTC_VERTICALLY);
-	prop->AddValueMapping("Both", FTC_BOTH);
-	AddProperty(prop);
-}
-
-Widget::~Widget()
-{
-	for (int32_t i=0; i<mChildren.GetSize(); i++)
-	{
-		delete mChildren[i];
-	}
-
-	for (int32_t i=0; i<mBinds.GetSize(); i++)
-	{
-		delete mBinds[i];
-	}
-}
-
-void Widget::Print32_tLoop(int32_t depth)
-{
-	Log::I(Str(depth, ' ') + ToStr());
-	for (int32_t i=0; i<mChildren.GetSize(); i++)
-	{
-		mChildren[i]->Print32_tLoop(depth + 1);
-	}
-}
-
-void Widget::AddChild(Widget* child)
-{
-	if (child != NULL)
-	{
-		mChildren.Append(child);
-		NotifyNeedsLayout();
-	}
-}
-
-Widget* Widget::FindChildByName(const Str& name)
-{
-	for(int32_t i = 0; i < mChildren.GetSize(); i++)
-	{
-		if (mChildren[i]->mName == name)
-			return mChildren[i];
-	}
-
-	for(int32_t i = 0; i < mChildren.GetSize(); i++)
-	{
-		Widget* w = mChildren[i]->FindChildByName(name);
-		if (w != NULL)
-			return w;
-	}
-	
-	return NULL;
-}
-
-IWithProperties* Widget::GetBindingContext() const
-{
-	if (mBindingContext == NULL && mParent != NULL)
-	{
-		return mParent->GetBindingContext();
-	}
-	return const_cast<IWithProperties*>(mBindingContext.GetPoint32_ter());
-}
-
-void Widget::SetBindingContext(IWithProperties* newContext)
-{
-	mBindingContext = newContext;
-
-	UpdateBindsToNewBindingContext(newContext);
-	
-	//ApplyBinds();
-}
-
-void Widget::UpdateBindsToNewBindingContext(IWithProperties* newContext)
-{
-	for (int32_t i=0; i<mBinds.GetSize(); i++)
-	{
-		Bind* bind = mBinds[i];
-		bind->SetSourceIfUsingBindingContext(newContext);
-	}
-
-	NotifyChangeEventArgs args("BindingContext");
-	NotifyChange(&args);
-
-	for (int32_t i=0; i<mChildren.GetSize(); i++)
-	{
-		mChildren[i]->UpdateBindsToNewBindingContext(newContext);
-	}
-}
-
-void Widget::AddBind(Bind* bind)
-{
-	mBinds.Append(bind);
-}
-
-void Widget::ApplyBinds()
-{
-	for (int32_t i=0; i<mBinds.GetSize(); i++)
-	{
-		mBinds[i]->Apply();
-	}
-
-	Log::IndentIn();
-	for (int32_t i=0; i<mChildren.GetSize(); i++)
-	{
-		mChildren[i]->ApplyBinds();
-	}
-	Log::IndentOut();
-}
-
-void Widget::ApplyTemplate(XMLNode* templateNode)
-{
-	DestroyContent();
-	XWMLReader::LoadWidgetPropertiesAndChildren(templateNode, this);
-}
-
-void Widget::DestroyContent()
-{
-	GetContentWidget()->DestroyChildren();
-}
-
-void Widget::DestroyChildren()
-{
-	int32_t size = mChildren.GetSize();
-	while (mChildren.GetSize() > 0)
-	{
-		mChildren[0]->Destroy();
-		if (size != mChildren.GetSize() + 1)
-		{
-			throw InvalidOperationException("Infinite loop detected, mChildren should decrease in length");
-		}
-		size--;
-	}
-}
-
-Generic Widget::GetPropertyValue(const Str& name) const
-{
-	if (name == "BindingContext")
-	{
-		return Generic(GetBindingContext());
-	}
-	else if (name == "Children")
-	{
-		// FIXME
-		//return Generic(new ListGenericWrapper<Widget*>(&mChildren));
-		return Generic();
-	}
-	else
-	{
-		return WithProperties::GetPropertyValue(name);
-	}
-}
-
-void Widget::SetPropertyValue(const Str& name, const Generic& value)
-{
-	if (name == "BindingContext")
-	{
-		IWithProperties* newBindingContext;
-		if (value.asType(&newBindingContext))
-		{
-			SetBindingContext(newBindingContext);
-		}
-		else
-		{
-			Log::E("Value not valid for property 'BindingContext'");
-		}
-	}
-	else
-	{
-		WithProperties::SetPropertyValue(name, value);
-	}
-}
-
-Point32_t2 Widget::GetScreenPosition()
-{
-	Widget* widget = this;
-	Point32_t2 position = mPosition + mTranslation;
-
-	while (widget->mParent != NULL)
-	{
-		widget = widget->mParent;
-		position += widget->mPosition + widget->mTranslation;
-	}
-
-	return position;
-}
-
-Point32_t2 Widget::GetRelativePosition(Widget* w)
-{
-	Widget* widget = this;
-	Point32_t2 position = mPosition + mTranslation;
-
-	while (widget->mParent != NULL && widget->mParent != w)
-	{
-		widget = widget->mParent;
-		position += widget->mPosition + widget->mTranslation;
-	}
-
-	return position;
-}
-
-Window* Widget::GetWindow()
-{
-	Widget* p = this;
-
-	while (p->mParent != NULL)
-	{
-		p = p->mParent;
-	}
-
-	return dynamic_cast<Window*>(p);
-}
-
-void Widget::NotifyNeedsLayout()
-{
-	Window* w = GetWindow();
-		if (w)
-			w->NotifyNeedsLayout();
-}
-
-void Widget::AttachToParent(Widget* value)
-{
-	if (!mParent && value)
-	{
-		mParent = value;
-		mParent->mChildren.Append(this);
-		NotifyNeedsLayout();
-	}
-}
-
-bool Widget::IsChildOf(const Widget* parent)
-{
-	Widget* w = this;
-
-	while (w)
-	{
-		if (parent == w)
-		{
-			return true;
-		}
-
-		w = w->mParent;
-	}
-
-	return false;
-}
-
-void Widget::Resize(int32_t width, int32_t height)
-{
-	bool changed = false;
-	if (width != mSize.x || height != mSize.y)
-		changed = true;
-	mSize = Point32_t2(width, height);
-	if (changed)
-	{
-		Window* w = GetWindow();
-		if (w)
-			w->GetWindowsManager()->SizeChangedHelper(this);
-	}
-}
-
-void Widget::Move(int32_t x, int32_t y)
-{
-	mPosition = Point32_t2(x, y);
-}
-
-void Widget::SetDesiredPosition(int32_t x, int32_t y)
-{
-	mDesiredPosition = Point32_t2(x, y);
-	NotifyNeedsLayout();
-}
-
-void Widget::SetDesiredSize(int32_t x, int32_t y)
-{
-	mDesiredSize = Point32_t2(x, y);
-	NotifyNeedsLayout();
-}
-
-void Widget::SetMinimumSize(int32_t x, int32_t y)
-{
-	mMinimumSize = Point32_t2(x, y);
-	NotifyNeedsLayout();
-}
-
-void Widget::SetMaximumSize(int32_t x, int32_t y)
-{
-	mMaximumSize = Point32_t2(x, y);
-	NotifyNeedsLayout();
-}
-
-void Widget::SetMargins(int32_t left, int32_t top, int32_t right, int32_t bottom)
-{
-	mMargins.left = left;
-	mMargins.top = top;
-	mMargins.right = right;
-	mMargins.bottom = bottom;
-	NotifyNeedsLayout();
-}
-
-bool Widget::HasTextInputFocus()
-{
-	Window* w = GetWindow();
-	if (w)
-	{
-		WindowsManager* windowsManager = w->GetWindowsManager();
-		return windowsManager->GetTextInputFocusWidget() == this;
-	}
-	return false;
-}
-
-bool Widget::MouseCapture()
-{
-	Window* root = GetWindow();
-
-	if (root == NULL)
-	{
-		return false;
-	}
-
-	return root->GetWindowsManager()->MouseCapture(this);
-}
-
-void Widget::MouseRelease()
-{
-	Window* root = GetWindow();
-
-	if (root == NULL)
-	{
-		return;
-	}
-
-	return root->GetWindowsManager()->MouseRelease();
-}
-
-void Widget::GetFocus()
-{
-	if (HasTextInputFocus())
-		return;
-	Window* w = GetWindow();
-	if (w == NULL)
-		return;
-	w->GetWindowsManager()->_SetTextInputFocusWidget(this);
-}
-
-void Widget::Destroy()
-{
-	Window* w = GetWindow();
-	if (w)
-	{
-		WindowsManager* windowsManager = w->GetWindowsManager();
-		windowsManager->ReleaseWidget(this);
-	}
-	if (mParent)
-	{
-		int32_t indexOnParent = mParent->mChildren.Find(this);
-		mParent->mChildren.Remove(indexOnParent);
-		mParent = NULL;
-	}
-	Trash();
-}
-
-Widget* Widget::GetContentWidget()
-{
-	return this;
-}
-
-void Widget::OnPreviewMouseIn(MouseEventArgs* /*args*/)
-{
-	mIsMouseOver = true;
-}
-
-void Widget::OnPreviewMouseOut(MouseEventArgs* /*args*/)
-{
-	mIsMouseOver = false;
-}
-
-void Widget::OnPreviewMouseMove(MouseMoveEventArgs* /*args*/)
-{
-}
-
-void Widget::OnPreviewMouseDown(MouseButtonEventArgs* /*args*/)
-{
-}
-
-void Widget::OnPreviewMouseUp(MouseButtonEventArgs* /*args*/)
-{
-}
-
-void Widget::OnPreviewKeyDown(KeyboardEventArgs* /*args*/)
-{
-}
-
-void Widget::OnPreviewKeyUp(KeyboardEventArgs* /*args*/)
-{
-}
-
-void Widget::OnPreviewTextInput(TextInputEventArgs* /*args*/)
-{
-}
-
-void Widget::OnMouseIn(MouseEventArgs* /*args*/)
-{	
-}
-
-void Widget::OnMouseOut(MouseEventArgs* /*args*/)
-{
-}
-
-void Widget::OnMouseMove(MouseMoveEventArgs* /*args*/)
-{
-}
-
-void Widget::OnMouseDown(MouseButtonEventArgs* /*args*/)
-{
-}
-
-void Widget::OnMouseUp(MouseButtonEventArgs* /*args*/)
-{
-}
-
-void Widget::OnKeyDown(KeyboardEventArgs* /*args*/)
-{
-}
-
-void Widget::OnKeyUp(KeyboardEventArgs* /*args*/)
-{
-}
-
-void Widget::OnTextInput(TextInputEventArgs* /*args*/)
-{
-}
-
-void Widget::OnGotFocus(WindowingEventArgs* /*args*/)
-{
-}
-
-void Widget::OnLostFocus(WindowingEventArgs* /*args*/)
-{
-}
-
-void Widget::OnSizeChanged(WindowingEventArgs* /*args*/)
-{
-}
-
-void Widget::OnMouseInHelper(bool doPreview, MouseEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewMouseIn(args);
-	else
-		OnMouseIn(args);
-}
-
-void Widget::OnMouseOutHelper(bool doPreview, MouseEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewMouseOut(args);
-	else
-		OnMouseOut(args);
-}
-
-void Widget::OnMouseMoveHelper(bool doPreview, MouseMoveEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewMouseMove(args);
-	else
-		OnMouseMove(args);
-}
-
-void Widget::OnMouseDownHelper(bool doPreview, MouseButtonEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewMouseDown(args);
-	else
-		OnMouseDown(args);
-}
-
-void Widget::OnMouseUpHelper(bool doPreview, MouseButtonEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewMouseUp(args);
-	else
-		OnMouseUp(args);
-}
-
-void Widget::OnKeyDownHelper(bool doPreview, KeyboardEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewKeyDown(args);
-	else
-		OnKeyDown(args);
-}
-
-void Widget::OnKeyUpHelper(bool doPreview, KeyboardEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewKeyUp(args);
-	else
-		OnKeyUp(args);
-}
-
-void Widget::OnTextInputHelper(bool doPreview, TextInputEventArgs* args)
-{
-	if (doPreview)
-		OnPreviewTextInput(args);
-	else
-		OnTextInput(args);
-}
-
-void Widget::OnGotFocusHelper(bool doPreview, WindowingEventArgs* args)
-{
-	if (doPreview)
-		;
-	else
-		OnGotFocus(args);
-}
-
-void Widget::OnLostFocusHelper(bool doPreview, WindowingEventArgs* args)
-{
-	if (doPreview)
-		;
-	else
-		OnLostFocus(args);
-}
-
-void Widget::OnSizeChangedHelper(bool doPreview, WindowingEventArgs* args)
-{
-	if (doPreview)
-		;
-	else
-		OnSizeChanged(args);
-}
-
-void Widget::DrawChildren(const DrawingClipInfo& clipInfo)
-{
-	Renderer* r = GetDevice()->GetRenderer();
-
-	for (int32_t i=0; i<mChildren.GetSize(); i++)
-	{
-	  if (mChildren[i]->mVisibility != WV_VISIBLE)
-			continue;
-
-		const Point32_t2& childPos = mChildren[i]->GetPosition();
-		const Point32_t2& childTrans = mChildren[i]->GetTranslation();
-		const Point32_t2& childSize = mChildren[i]->GetSize();
-
-		DrawingClipInfo childClipInfo;
-		childClipInfo.screenX = clipInfo.screenX + childPos.x + childTrans.x;
-		childClipInfo.screenY = clipInfo.screenY + childPos.y + childTrans.y;
-
-		childClipInfo.sx = childClipInfo.screenX;
-		childClipInfo.sy = childClipInfo.screenY;
-		childClipInfo.sw = childSize.x;
-		childClipInfo.sh = childSize.y;
-
-		if (childClipInfo.sx < clipInfo.sx)
-		{
-			childClipInfo.sw = Math::Max<int32_t>(0, childClipInfo.sx + childClipInfo.sw - clipInfo.sx);
-			childClipInfo.sx = clipInfo.sx;
-		}
-
-		if (childClipInfo.sy < clipInfo.sy)
-		{
-			childClipInfo.sh = Math::Max<int32_t>(0, childClipInfo.sy + childClipInfo.sh - clipInfo.sy);
-			childClipInfo.sy = clipInfo.sy;
-		}
-
-		if (childClipInfo.sx + childClipInfo.sw > clipInfo.sx + clipInfo.sw)
-			childClipInfo.sw = Math::Max<int32_t>(0, clipInfo.sx + clipInfo.sw - childClipInfo.sx);
-
-		if (childClipInfo.sy + childClipInfo.sh > clipInfo.sy + clipInfo.sh)
-			childClipInfo.sh = Math::Max<int32_t>(0, clipInfo.sy + clipInfo.sh - childClipInfo.sy);
-
-		if (childClipInfo.sw == 0 || childClipInfo.sh == 0)
-			continue;
-
-		r->SetScissorBox(childClipInfo.sx, childClipInfo.sy, childClipInfo.sw, childClipInfo.sh);
-
-		//Log::I("screenX: " + Str(childClipInfo.screenX) + ", screenY: " + Str(childClipInfo.screenY) + ", sx" + Str(childClipInfo.sx) + ", sy" + Str(childClipInfo.sy) + ", sw" + Str(childClipInfo.sw) + ", sh" + Str(childClipInfo.sh));
-
-		r->PushMatrix();
-		glTranslatef((float)(childPos.x + childTrans.x), (float)(childPos.y + childTrans.y), 0.0f);
-		mChildren[i]->OnDraw(childClipInfo); 
-		r->PopMatrix();
-	}
-
-	//Upon exit, set the scissorbox to the whole widget, because when drawing children it was altered
-	r->SetScissorBox(clipInfo.sx, clipInfo.sy, clipInfo.sw, clipInfo.sh);
-}
-
-void Widget::DebugDrawBorder()
-{
-	glDisable(GL_SCISSOR_TEST);
-	glEnable(GL_LINE_STIPPLE);
-	glLineStipple(2, 0x5555);
-	glBegin(GL_LINE_LOOP);
-
-	if (mIsMouseOver)
-	{
-		glColor3i(1, 1, 0);
-	}
-	else
-	{
-		glColor3i(1, 0, 1);
-	}
-
-	glVertex3i(-1     , -1     , 0);
-	glVertex3i(mSize.x, -1     , 0);
-	glVertex3i(mSize.x, mSize.y, 0);
-	glVertex3i(-1     , mSize.y, 0);
-	glEnd();
-	glDisable(GL_LINE_STIPPLE);
-	glEnable(GL_SCISSOR_TEST);
-}
-
-void Widget::DrawInit(DrawingClipInfo& /*clipInfo*/)
-{
-	//glTranslatef(mTranslation.x, mTranslation.y, 0.0f);
-	//clipInfo.screenX += mTranslation.x;
-	//clipInfo.screenY += mTranslation.y;
-}
-
-void Widget::OnDraw(DrawingClipInfo& clipInfo)
-{
-	DrawInit(clipInfo);
-	if (mDrawDebugBorder)
-	{
-		DebugDrawBorder();
-	}
-	DrawChildren(clipInfo);
-}
-
-/*
- * The goal of this function is to determine whether the widget has
- * dimensions set by hand, by children if fitting to children, or
- * is decided by the layout
- */
-void Widget::OnMeasure(bool fitChildrenX, bool fitChildrenY)
-{
-	if (mVisibility == WV_COLLAPSED)
-	{
-		mMeasuredSize.x = 0;
-		mMeasuredSize.y = 0;
-		return;
-	}
-
-	fitChildrenX |= Math::TestBitmask(mFitToChildren, FTC_HORIZONTALLY);
-	fitChildrenY |= Math::TestBitmask(mFitToChildren, FTC_VERTICALLY);
-
-	if (fitChildrenX && mDesiredSize.x >= 0)
-	{
-		fitChildrenX = false;
-	}
-
-	if (fitChildrenY && mDesiredSize.y >= 0)
-	{
-		fitChildrenY = false;
-	}
-
-	for (int32_t i = 0; i < mChildren.GetSize(); i++)
-	{
-		mChildren[i]->OnMeasure(fitChildrenX, fitChildrenY);
-	}
-
-	if (fitChildrenX)
-		OnMeasureFitX();
-	else
-		mMeasuredSize.x = mDesiredSize.x;
-	
-	if (mMeasuredSize.x >= 0)
-		mMeasuredSize.x = Math::Min(Math::Max(mMeasuredSize.x, mMinimumSize.x), mMaximumSize.x);
-
-	if (fitChildrenY)
-		OnMeasureFitY();
-	else
-		mMeasuredSize.y = mDesiredSize.y;
-
-	if (mMeasuredSize.y >= 0)
-		mMeasuredSize.y = Math::Min(Math::Max(mMeasuredSize.y, mMinimumSize.y), mMaximumSize.y);
-}
-
-/*
- * Computes the X MeasuredSize component based on child dimensions, which are all computed recursively
- * before the call.
- * It must be overriden by custom layouts to determine the layout size based on children sizes when
- * doing a FitToChildren.
- */
-void Widget::OnMeasureFitX()
-{
-	mMeasuredSize.x = Math::Max(0, mDesiredSize.x);
-
-	for (int32_t i = 0; i < mChildren.GetSize(); i++)
-	{
-		Widget* child = mChildren[i];
-
-		int32_t w = child->mMeasuredSize.x;
-		if (child->mMargins.left > 0)
-			w += child->mMargins.left;
-		if (child->mMargins.right > 0)
-			w += child->mMargins.right;
-		
-		mMeasuredSize.x = Math::Max(mMeasuredSize.x, w);
-	}
-}
-
-void Widget::OnMeasureFitY()
-{
-	mMeasuredSize.y = Math::Max(0, mDesiredSize.y);
-
-	for (int32_t i = 0; i < mChildren.GetSize(); i++)
-	{
-		Widget* child = mChildren[i];
-
-		int32_t h = child->mMeasuredSize.y;
-		if (child->mMargins.top > 0)
-			h += child->mMargins.top;
-		if (child->mMargins.bottom > 0)
-			h += child->mMargins.bottom;
-		
-		mMeasuredSize.y = Math::Max(mMeasuredSize.y, h);
-	}
-}
-
-void Widget::OnArrange(Point32_t2 position, Point32_t2 size)
-{
-	Move(position);
-	if (mVisibility == WV_COLLAPSED)
-	{
-		Resize(Point32_t2::ZERO);
-		return;
-	}
-	Resize(size);
-
-	for (int32_t i=0; i<mChildren.GetSize(); i++)
-	{
-		Point32_t2 childPosition = mChildren[i]->GetDesiredPosition();
-		Point32_t2 childSize = mChildren[i]->GetMeasuredSize();
-    
-    Point32_t2 vv;
-    vv.x = 0;
-    vv.y = 0;
-    childSize = size;
-    
-    mChildren[i]->FitMeasuredSizeX(vv, childSize);
-    mChildren[i]->FitMeasuredSizeY(vv, childSize);
-
-//		if (childSize.x < 0.0f)
-//		{
-//			childSize.x = size.x - childPosition.x;
-//			mChildren[i]->ErodeMarginsX(childPosition, childSize);
-//		}
-//		else
-//			mChildren[i]->EnlargeMarginsX(childPosition, childSize);
-//
-//		if (childSize.y < 0.0f)
-//		{
-//			childSize.y = size.y - childPosition.y;
-//			mChildren[i]->ErodeMarginsY(childPosition, childSize);
-//		}
-//		else
-//			mChildren[i]->EnlargeMarginsY(childPosition, childSize);
-		
-		mChildren[i]->OnArrange(vv, childSize);
-	}
-}
-
-int32_t Widget::EnlargeMarginsX(Point32_t2& position, Point32_t2& size)
-{
-	int32_t v = size.x;
-	if (mMargins.left > 0)
-	{
-		position.x += mMargins.left;
-		v += mMargins.left;
-	}
-	if (mMargins.right > 0)
-	{
-		v += mMargins.right;
-	}
-	return v;
-}
-
-int32_t Widget::EnlargeMarginsY(Point32_t2& position, Point32_t2& size)
-{
-	int32_t v = size.y;
-	if (mMargins.top > 0)
-	{
-		position.y += mMargins.top;
-		v += mMargins.top;
-	}
-	if (mMargins.bottom > 0)
-	{
-		v += mMargins.bottom;
-	}
-	return v;
-}
-
-void Widget::ErodeMarginsX(Point32_t2& position, Point32_t2& size)
-{
-	if (mMargins.left > 0)
-	{
-		position.x += mMargins.left;
-		size.x -= mMargins.left;
-	}
-
-	if (mMargins.right > 0)
-	{
-		size.x -= mMargins.right;
-	}
-}
-
-void Widget::ErodeMarginsY(Point32_t2& position, Point32_t2& size)
-{
-	if (mMargins.top > 0)
-	{
-		position.y += mMargins.top;
-		size.y -= mMargins.top;
-	}
-
-	if (mMargins.bottom > 0)
-	{
-		size.y -= mMargins.bottom;
-	}
-}
-
-void Widget::FitMeasuredSizeX(Point32_t2& position, Point32_t2& size)
-{
-	Point32_t2 origSize = size;
-	Point32_t2 origPosition = position;
-
-	if (mMeasuredSize.x < 0)
-	{
-		//Se i margini sono entrambi settati, utilizza quelli
-		if (mMargins.left >= 0)
-		{
-			position.x += mMargins.left;
-			size.x -= mMargins.left;
-		}
-		if (mMargins.right >= 0)
-		{
-			size.x -= mMargins.right;
-		}
-	}
-	else
-	{
-		if (mMargins.left >= 0)
-		{
-			if (mMargins.right < 0)
-			{
-				position.x += mMargins.left;
-			}
-			else if (mMargins.left + mMargins.right + mMeasuredSize.x < size.x)
-			{
-				//I margini non sono sufficienti a coprire la dimensione data, posizionati nel mezzo
-				//TODO: Inserire qui le politiche di allineamento
-				position.x += (size.x - mMeasuredSize.x) / 2;
-			}
-			else
-			{
-				position.x += mMargins.left;
-			}
-		}
-		else
-		{
-			if (mMargins.right < 0)
-			{
-				position.x += (size.x - mMeasuredSize.x) / 2;
-			}
-			else
-			{
-				position.x += size.x - mMeasuredSize.x - mMargins.right;
-			}
-		}
-
-		size.x = mMeasuredSize.x;
-	}
-
-	if (size.x < mMinimumSize.x)
-	{
-		mMeasuredSize.x = mMinimumSize.x;
-		position = origPosition;
-		size = origSize;
-		FitMeasuredSizeX(position, size);
-	}
-	if (size.x > mMaximumSize.x)
-	{
-		mMeasuredSize.x = mMaximumSize.x;
-		position = origPosition;
-		size = origSize;
-		FitMeasuredSizeX(position, size);
-	}
-}
-
-void Widget::FitMeasuredSizeY(Point32_t2& position, Point32_t2& size)
-{
-	Point32_t2 origSize = size;
-	Point32_t2 origPosition = position;
-
-	if (mMeasuredSize.y < 0)
-	{
-		//Se i margini sono entrambi settati, utilizza quelli
-		if (mMargins.top >= 0)
-		{
-			position.y += mMargins.top;
-			size.y -= mMargins.top;
-		}
-		if (mMargins.bottom >= 0)
-		{
-			size.y -= mMargins.bottom;
-		}
-	}
-	else
-	{
-		if (mMargins.top >= 0)
-		{
-			if (mMargins.bottom < 0)
-			{
-				position.y += mMargins.top;
-			}
-			else if (mMargins.top + mMargins.bottom + mMeasuredSize.y < size.y)
-			{
-				//I margini non sono sufficienti a coprire la dimensione data, posizionati nel mezzo
-				//TODO: Inserire qui le politiche di allineamento
-				position.y += (size.y - mMeasuredSize.y) / 2;
-			}
-			else
-			{
-				position.y += mMargins.top;
-			}
-		}
-		else
-		{
-			if (mMargins.bottom < 0)
-			{
-				position.y += (size.y - mMeasuredSize.y) / 2;
-			}
-			else
-			{
-				position.y += size.y - mMeasuredSize.y - mMargins.bottom;
-			}
-		}
-		size.y = mMeasuredSize.y;
-	}
-
-	if (size.y < mMinimumSize.y)
-	{
-		mMeasuredSize.y = mMinimumSize.y;
-		position = origPosition;
-		size = origSize;
-		FitMeasuredSizeX(position, size);
-	}
-	if (size.y > mMaximumSize.y)
-	{
-		mMeasuredSize.y = mMaximumSize.y;
-		position = origPosition;
-		size = origSize;
-		FitMeasuredSizeX(position, size);
-	}
-}
-
-WidgetSizeAcceptedEnum Widget::GetSizeAcceptedX(int32_t sizeX)
-{
-	if (mMeasuredSize.x >= 0)	//A desired size is set, use that one regardless of the available space
-		return WSA_FIXED;
-
-	int32_t w = sizeX;
-
-	//Apply margins if they are not 'auto'
-	//'auto' margins have effect only if the desired size is set, so just ignore them here
-	if (mMargins.left >= 0)
-		w -= mMargins.left;
-	if (mMargins.right >= 0)
-		w -= mMargins.right;
-	
-	if (w < mMinimumSize.x)
-		return WSA_MIN_SIZE;
-	if (w > mMaximumSize.x)
-		return WSA_MAX_SIZE;
-	return WSA_ACCEPTED;
-}
-
-WidgetSizeAcceptedEnum Widget::GetSizeAcceptedY(int32_t sizeY)
-{
-	if (mMeasuredSize.y >= 0)	//A desired size is set, use that one regardless of the available space
-		return WSA_FIXED;
-
-	int32_t h = sizeY;
-
-	//Apply margins if they are not 'auto'
-	//'auto' margins have effect only if the desired size is set, so just ignore them here
-	if (mMargins.top >= 0)
-		h -= mMargins.top;
-	if (mMargins.bottom >= 0)
-		h -= mMargins.bottom;
-
-	if (h < mMinimumSize.y)
-		return WSA_MIN_SIZE;
-	if (h > mMaximumSize.y)
-		return WSA_MAX_SIZE;
-	return WSA_ACCEPTED;
-}
-
-} //namespace Crown

+ 0 - 389
src/windowing/Widget.h

@@ -1,389 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Rect.h"
-#include "List.h"
-#include "GarbageBin.h"
-#include "WindowingEventArgs.h"
-#include "WithProperties.h"
-#include "Point32_t2.h"
-#include "SignalSlot.h"
-#include "Property.h"
-
-namespace Crown
-{
-
-class Window;
-class Bind;
-class XMLNode;
-
-enum WidgetSizeAcceptedEnum
-{
-	WSA_ACCEPTED,		//< The size is allowed
-	WSA_MIN_SIZE,		//< The size is too small, min size would be used
-	WSA_MAX_SIZE,		//< The size is too big, max size would be used
-	WSA_FIXED				//< The size can't be accepted because a preferred size is set
-};
-
-enum WidgetVisibilityEnum
-{
-	WV_VISIBLE,		//Normal visibility
-	WV_HIDDEN,		//The widget is hidden but occupies the space
-	WV_COLLAPSED	//The widget is collapsed to a point32_t
-};
-
-enum FitToChildrenEnum
-{
-	FTC_NONE = 0,						//! Don't fit to children, occupy available space
-	FTC_VERTICALLY = 1,			//! Fit to children vertically
-	FTC_HORIZONTALLY = 2,		//! Fit to children horizontally
-	FTC_BOTH = 3						//! Fit to children in both directions
-};
-
-struct DrawingClipInfo
-{
-	int32_t screenX, screenY;	//Save the screen coordinates of the current widget
-	int32_t sx, sy, sw, sh;		//Scissor box
-};
-
-class Widget: public WithProperties, public IGarbageable
-{
-public:
-	Widget(Widget* parent);
-	virtual ~Widget();
-
-	//Desired size and position
-	inline const Point32_t2& GetDesiredPosition() const
-	{
-		return mDesiredPosition;
-	}
-	inline const Point32_t2& GetDesiredSize() const
-	{
-		return mDesiredSize;
-	}
-	inline const Margins& GetMargins() const
-	{
-		return mMargins;
-	}
-
-	void SetDesiredPosition(int32_t x, int32_t y);
-	inline void SetDesiredPosition(const Point32_t2& value)
-	{
-		SetDesiredPosition(value.x, value.y);
-	}
-	void SetDesiredSize(int32_t x, int32_t y);
-	inline void SetDesiredSize(const Point32_t2& value)
-	{
-		SetDesiredSize(value.x, value.y);
-	}
-	void SetMinimumSize(int32_t x, int32_t y);
-	inline void SetMinimumSize(const Point32_t2& value)
-	{
-		SetMinimumSize(value.x, value.y);
-	}
-	void SetMaximumSize(int32_t x, int32_t y);
-	inline void SetMaximumSize(const Point32_t2& value)
-	{
-		SetMaximumSize(value.x, value.y);
-	}
-	inline const Point32_t2& GetMinimumSize() const
-	{
-		return mMinimumSize;
-	}
-	inline const Point32_t2& GetMaximumSize() const
-	{
-		return mMaximumSize;
-	}
-	
-	inline void SetMeasuredSize(int32_t x, int32_t y)
-	{
-		mMeasuredSize.x = x;
-		mMeasuredSize.y = y;
-	}
-	inline const Point32_t2& GetMeasuredSize() const
-	{
-		return mMeasuredSize;
-	}
-
-	inline void SetTranslation(int32_t x, int32_t y)
-	{
-		mTranslation.x = x;
-		mTranslation.y = y;
-	}
-	inline const Point32_t2& GetTranslation() const
-	{
-		return mTranslation;
-	}
-
-	inline void SetName(const Str& name)
-	{
-		mName = name;
-	}
-	inline const Str& GetName() const
-	{
-		return mName;
-	}
-
-	void SetMargins(int32_t left, int32_t top, int32_t right, int32_t bottom);
-
-	inline Point32_t2 GetPosition()
-	{
-		return mPosition;
-	}
-	Point32_t2 GetScreenPosition();
-	Point32_t2 GetRelativePosition(Widget* w);
-	inline Point32_t2 GetSize()
-	{
-		return mSize;
-	}
-	inline Rect GetBounds()
-	{
-		//TODO: Use a Rect with Point32_t2 coordinates
-		return Rect((mPosition + mTranslation).ToVec2(), (mPosition + mTranslation + mSize).ToVec2());
-	}
-	Window* GetWindow();
-
-	inline Widget* GetParent()
-	{
-		return mParent;
-	}
-	inline Widget* GetLogicalParent()
-	{
-		return mLogicalParent;
-	}
-
-	void AttachToParent(Widget* value);
-	void SetLogicalParent(Widget* value)
-	{
-		mLogicalParent = value;
-	}
-
-	inline bool IsPoint32_tInside(const Point32_t2& point32_t)
-	{
-		//TODO: Use a Rect with Point32_t2 coordinates
-		return GetBounds().ContainsPoint32_t(point32_t.ToVec2());
-	}
-	inline bool IsMouseOver() const
-	{
-		return mIsMouseOver;
-	}
-	bool HasTextInputFocus();
-	inline bool IsMouseSensible()
-	{
-		return mIsMouseSensible && mVisibility == WV_VISIBLE;
-	}
-	inline void SetMouseSensible(bool value)
-	{
-		mIsMouseSensible = value;
-	}
-	inline void SetFitToChildren(FitToChildrenEnum value)
-	{
-		if (value != mFitToChildren)
-		{
-			mFitToChildren = value;
-			NotifyNeedsLayout();
-		}
-	}
-	bool IsChildOf(const Widget* parent);
-	virtual Widget* GetContentWidget();
-
-	inline WidgetVisibilityEnum GetVisibility() const
-	{
-		return mVisibility;
-	}
-	inline void SetVisibility(WidgetVisibilityEnum visibility)
-	{
-	  bool needsLayout = (mVisibility == WV_COLLAPSED) || (visibility == WV_COLLAPSED);
-		mVisibility = visibility;
-		if (needsLayout)
-			NotifyNeedsLayout();
-	}
-
-	IWithProperties* GetBindingContext() const;
-	void SetBindingContext(IWithProperties* bindingContext);
-
-	virtual Generic GetPropertyValue(const Str& name) const;
-	virtual void SetPropertyValue(const Str& name, const Generic& value);
-
-	void AddBind(Bind* bind);
-	void ApplyBinds();
-
-	void ApplyTemplate(XMLNode* templateNode);
-
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-	virtual void OnMeasure(bool fitChildrenX, bool fitChildrenY);
-	virtual void OnMeasureFitX();
-	virtual void OnMeasureFitY();
-	virtual void OnArrange(Point32_t2 position, Point32_t2 size);
-
-	bool MouseCapture();
-	void MouseRelease();
-	void GetFocus();
-	void Destroy();
-
-	void NotifyNeedsLayout();
-
-	WidgetSizeAcceptedEnum GetSizeAcceptedX(int32_t sizeX);
-	WidgetSizeAcceptedEnum GetSizeAcceptedY(int32_t sizeY);
-
-	void ErodeMarginsX(Point32_t2& position, Point32_t2& size);
-	void ErodeMarginsY(Point32_t2& position, Point32_t2& size);
-
-	int32_t EnlargeMarginsX(Point32_t2& position, Point32_t2& size);
-	int32_t EnlargeMarginsY(Point32_t2& position, Point32_t2& size);
-
-	void FitMeasuredSizeX(Point32_t2& position, Point32_t2& size);
-	void FitMeasuredSizeY(Point32_t2& position, Point32_t2& size);
-
-	Widget* FindChildByName(const Str& name);
-	void DestroyContent();
-
-	//! Set the flag to draw a debug border on widgets
-	inline static void SetDrawDebugBorder(bool value)
-	 { mDrawDebugBorder = value; }
-
-	virtual Str ToStr() const
-	 { return "Widget"; }
-
-	void Print32_tLoop(int32_t depth);
-
-protected:
-	Point32_t2 mDesiredPosition;
-	Point32_t2 mDesiredSize;
-	Point32_t2 mMeasuredSize;
-	Point32_t2 mMaximumSize;
-	Point32_t2 mMinimumSize;
-	Point32_t2 mTranslation;
-
-	static bool mDrawDebugBorder;
-
-	//Preview events
-	virtual void OnPreviewMouseIn(MouseEventArgs* args);
-	virtual void OnPreviewMouseOut(MouseEventArgs* args);
-	virtual void OnPreviewMouseMove(MouseMoveEventArgs* args);
-	virtual void OnPreviewMouseDown(MouseButtonEventArgs* args);
-	virtual void OnPreviewMouseUp(MouseButtonEventArgs* args);
-	virtual void OnPreviewKeyDown(KeyboardEventArgs* args);
-	virtual void OnPreviewKeyUp(KeyboardEventArgs* args);
-	virtual void OnPreviewTextInput(TextInputEventArgs* args);
-
-	//Bubble events
-	virtual void OnMouseIn(MouseEventArgs* args);
-	virtual void OnMouseOut(MouseEventArgs* args);
-	virtual void OnMouseMove(MouseMoveEventArgs* args);
-	virtual void OnMouseDown(MouseButtonEventArgs* args);
-	virtual void OnMouseUp(MouseButtonEventArgs* args);
-	virtual void OnKeyDown(KeyboardEventArgs* args);
-	virtual void OnKeyUp(KeyboardEventArgs* args);
-	virtual void OnTextInput(TextInputEventArgs* args);
-	virtual void OnGotFocus(WindowingEventArgs* args);
-	virtual void OnLostFocus(WindowingEventArgs* args);
-	virtual void OnSizeChanged(WindowingEventArgs* args);
-
-	//OnEvent helpers
-	void OnMouseInHelper(bool doPreview, MouseEventArgs* args);
-	void OnMouseOutHelper(bool doPreview, MouseEventArgs* args);
-	void OnMouseMoveHelper(bool doPreview, MouseMoveEventArgs* args);
-	void OnMouseDownHelper(bool doPreview, MouseButtonEventArgs* args);
-	void OnMouseUpHelper(bool doPreview, MouseButtonEventArgs* args);
-	void OnKeyDownHelper(bool doPreview, KeyboardEventArgs* args);
-	void OnKeyUpHelper(bool doPreview, KeyboardEventArgs* args);
-	void OnTextInputHelper(bool doPreview, TextInputEventArgs* args);
-	void OnGotFocusHelper(bool doPreview, WindowingEventArgs* args);
-	void OnLostFocusHelper(bool doPreview, WindowingEventArgs* args);
-	void OnSizeChangedHelper(bool doPreview, WindowingEventArgs* args);
-	/*
-	 * MouseIn
-	 * MouseOut
-	 * MouseUp
-	 * MouseDown
-	 * MouseMove
-	 * MouseWheel
-	 * KeyUp
-	 * KeyDown
-	 * TextInput
-	 * GotFocus
-	 * LostFocus
-	 * Loaded
-	 * Unloaded
-	 * SizeChanged
-	 *
-	 */
-
-	friend class WindowsManager;
-
-	void DrawInit(DrawingClipInfo& clipInfo);
-	void DrawChildren(const DrawingClipInfo& clipInfo);
-	void DebugDrawBorder();
-
-	virtual void AddChild(Widget* child);
-	inline const List<Widget*>& GetChildren() const
-	{
-		return mChildren;
-	}
-	virtual void Resize(int32_t width, int32_t height);
-	inline void Resize(Point32_t2 size)
-	{
-		Resize(size.x, size.y);
-	}
-	virtual void Move(int32_t x, int32_t y);
-	inline void Move(Point32_t2 pos)
-	{
-		Move(pos.x, pos.y);
-	}
-
-	inline FitToChildrenEnum GetFitToChildren()
-	{
-	  return mFitToChildren;
-	}
-
-	void DestroyChildren();
-
-	//void ApplyMargins(Point32_t2& position, Point32_t2& size);
-
-private:
-	Point32_t2 mPosition;
-	Point32_t2 mSize;
-	Margins mMargins;
-	Widget* mParent;
-	Widget* mLogicalParent;
-	List<Widget*> mChildren;
-	Str mName;
-	WidgetVisibilityEnum mVisibility;
-	Weak<IWithProperties> mBindingContext;
-	List<Bind*> mBinds;
-
-	bool mIsMouseOver;
-	bool mIsMouseSensible;
-	FitToChildrenEnum mFitToChildren;
-
-	//! Updates all the descending Binds bound to the BindingContext to use the new one
-	void UpdateBindsToNewBindingContext(IWithProperties* newContext);
-};
-
-} //namespace Crown

+ 0 - 178
src/windowing/Window.cpp

@@ -1,178 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "WindowsManager.h"
-#include "Themes.h"
-#include "Types.h"
-#include "ThemeSpriteWidget.h"
-#include "StackLayout.h"
-#include "WindowContext.h"
-#include "Property.h"
-#include "Renderer.h"
-
-namespace Crown
-{
-
-Point32_t2 Window::mDefaultPosition(30, 30);
-
-Window::Window(WindowsManager* wm, int32_t x, int32_t y, int32_t width, int32_t height, Str title):
-	Widget(NULL),
-	mWindowsManager(wm), mModalParent(NULL),
-	mClientArea(0), mCloseButton(0), mNeedsLayout(true),
-	mIsDoingModal(false), mWindowContext(NULL)
-{
-	InitWindow(x, y, width, height, title);
-}
-
-Window::Window(WindowsManager* wm, int32_t width, int32_t height, Str title):
-	Widget(NULL),
-	mWindowsManager(wm), mModalParent(NULL),
-	mClientArea(0), mCloseButton(0), mNeedsLayout(true),
-	mIsDoingModal(false), mWindowContext(NULL)
-{
-	InitWindow(mDefaultPosition.x, mDefaultPosition.y, width, height, title);
-	//Compute the new default position
-	mDefaultPosition.x += 20;
-	mDefaultPosition.y += 20;
-}
-
-Window::~Window()
-{
-	delete mWindowContext;
-}
-
-void Window::InitWindow(int32_t x, int32_t y, int32_t width, int32_t height, Str title)
-{
-	mWindowsManager->mWindows.Append(this);
-	SetDesiredPosition(x - 1, y - 11);
-	SetDesiredSize(width + 2, height + 15);
-
-	StackLayout* layout = new StackLayout(this);
-
-	mDragArea = new DragArea(layout);
-	mDragArea->SetDesiredSize(-1, 14);
-	mDragArea->SetWidgetToDrag(this);
-
-	StackLayout* titleLayout = new StackLayout(mDragArea);
-	titleLayout->SetOrientation(SO_HORIZONTAL);
-
-	mTitle = new Label(titleLayout, title);
-	mTitle->SetMargins(1, -1, -1, -1);
-	//mTitle->SetDesiredSize(-1, -1);
-
-	mCloseButton = new Button(titleLayout);
-	mCloseButton->SetDesiredSize(8, 8);
-  mCloseButton->SetMargins(2, -1, 2, -1);
-	ThemeSpriteWidget* tsw = new ThemeSpriteWidget(mCloseButton, TS_CLOSEBUTTON_X, 0);
-  tsw->SetMargins(3, 3, -1, -1);
-
-	mClientArea = new Widget(layout);
-	mClientArea->SetMargins(1, 1, 1, 1);
-
-	mCloseButton->OnClickEvent += CreateDelegate(this, &Window::CloseButton_OnClick);
-
-	AddProperty(new PropertyPipe("Title", mTitle->GetProperty("Text")));
-}
-
-Widget* Window::GetContentWidget()
-{
-	if (mClientArea)
-		return mClientArea;
-	return this;
-}
-
-void Window::CloseButton_OnClick(Button* /*widget*/, EventArgs* /*args*/)
-{
-	Close();
-}
-
-void Window::_PerformLayout()
-{
-	if (mNeedsLayout)
-	{
-		mNeedsLayout = false;
-		bool fitX = Math::TestBitmask(GetFitToChildren(), FTC_HORIZONTALLY);
-		bool fitY = Math::TestBitmask(GetFitToChildren(), FTC_VERTICALLY);
-		OnMeasure(fitX, fitY);
-		OnArrange(GetDesiredPosition(), GetDesiredSize());
-	}
-}
-
-void Window::OnDraw(DrawingClipInfo& clipInfo)
-{
-	Widget::DrawInit(clipInfo);
-	Themes::Draw(TF_WINDOW, GetSize());
-	Renderer* r = GetDevice()->GetRenderer();
-	Widget::DrawChildren(clipInfo);
-	
-	if (mIsDoingModal)
-	{
-		Color4 c(0.0f, 0.0f, 0.0f, 0.1f);
-		r->DrawRectangle(Point32_t2::ZERO, GetSize(), DM_FILL, c, c);
-	}
-}
-
-void Window::NotifyNeedsLayout()
-{
-	mNeedsLayout = true;
-}
-
-void Window::DoModal(Window* childWindow)
-{
-	if (!childWindow->mModalParent)
-	{
-		childWindow->mModalParent = this;
-		mIsDoingModal = true;
-		SetMouseSensible(false);
-	}
-}
-
-void Window::Close()
-{
-	WindowCloseEventArgs ea(this);
-	OnCloseEvent.Fire(this, &ea);
-
-	if (ea.cancel)
-	{
-		return;
-	}
-
-	if (mModalParent)
-	{
-		//If a modal parent has been set, reactivate it
-		mModalParent->SetMouseSensible(true);
-		mModalParent->mIsDoingModal = false;
-	}
-	else
-	{
-		//Call EndModal on the windows manager, if this window was a global modal window, it will reactivate the int32_teractions
-		mWindowsManager->EndModal(this);
-	}
-
-	mWindowsManager->mWindows.Remove(mWindowsManager->mWindows.Find(this));
-	Destroy();
-}
-
-} //namespace Crown

+ 0 - 92
src/windowing/Window.h

@@ -1,92 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-#include "SignalSlot.h"
-#include "Button.h"
-#include "Label.h"
-#include "DragArea.h"
-#include "Str.h"
-
-namespace Crown
-{
-
-class WindowsManager;
-class WindowContext;
-
-class Window : public Widget
-{
-public:
-	Window(WindowsManager* wm, int32_t width, int32_t height, Str title);
-	Window(WindowsManager* wm, int32_t x, int32_t y, int32_t width, int32_t height, Str title);
-	virtual ~Window();
-
-	inline WindowsManager* GetWindowsManager()
-	{
-		return mWindowsManager;
-	}
-	virtual Widget* GetContentWidget();
-	inline WindowContext* GetWindowContext() const
-	 { return mWindowContext; }
-
-	virtual void OnDraw(DrawingClipInfo& clipInfo);
-
-	void NotifyNeedsLayout();
-	void Close();
-	void DoModal(Window* childWindow);
-
-	void _PerformLayout();
-
-	MulticastEvent<Window, WindowCloseEventArgs*> OnCloseEvent;
-
-	virtual Str ToStr() const
-	 { return "Window"; }
-
-protected:
-	void CloseButton_OnClick(Button* widget, EventArgs* args);
-
-private:
-	WindowsManager* mWindowsManager;
-	Window* mModalParent;
-	Widget* mClientArea;
-	Button* mCloseButton;
-	Label* mTitle;
-	DragArea* mDragArea;
-	bool mNeedsLayout;
-	bool mIsDoingModal;
-	WindowContext* mWindowContext;
-
-	static Point32_t2 mDefaultPosition;
-
-	void InitWindow(int32_t x, int32_t y, int32_t width, int32_t height, Str title);
-
-	friend class WindowsManager;
-	friend class WindowContext;
-};
-
-} //namespace Crown

+ 0 - 114
src/windowing/WindowContext.cpp

@@ -1,114 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "WindowContext.h"
-#include "Window.h"
-#include "Bind.h"
-
-namespace Crown
-{
-
-WindowContext::WindowContext(WindowsManager* windowsManager):
-	mWindowsManager(windowsManager), mAssociatedWindow(NULL)
-{
-	assert(mWindowsManager);
-}
-
-WindowContext::~WindowContext()
-{
-	//TODO: Verify, should Actions be deleted too? Memory Leak!
-	ConverterDictionary::Enumerator e = mRegisteredConverters.getBegin();
-	while (e.next())
-	{
-		delete e.current().value;
-	}
-}
-
-Widget* WindowContext::FindWidgetByName(const Str& name) const
-{
-	assert(mAssociatedWindow);
-	return mAssociatedWindow->FindChildByName(name);
-}
-
-void WindowContext::SetAssociatedWindow(Window* associatedWindow)
-{
-	if (mAssociatedWindow != NULL)
-	{
-		Log::E("WindowContext can only be associated to a Window once and for all");
-	}
-	else
-	{
-		mAssociatedWindow = associatedWindow;
-		mAssociatedWindow->mWindowContext = this;
-		//Made the Binding Context default to the WindowContext of the window
-		mAssociatedWindow->SetBindingContext(this);
-	}
-}
-
-void WindowContext::RegisterAction(const Str& name, ActionDelegate* slot)
-{
-	if (mRegisteredActions.Contains(name))
-	{
-		Log::E("WindowContext already has an Action registered with name '" + name + "'");
-	}
-	else
-	{
-		mRegisteredActions[name] = slot;
-	}
-}
-
-ActionDelegate* WindowContext::GetRegisteredAction(const Str& name)
-{
-	if (mRegisteredActions.Contains(name))
-	{
-		//Return a duplicate because the caller will usually pass the delegate to an event, which transfers ownership
-		//TODO: Verify memory leak. Maybe Duplicate could be avoided
-		return (ActionDelegate*)mRegisteredActions[name]->Duplicate();		
-	}
-	return NULL;
-}
-
-void WindowContext::RegisterConverter(const Str& name, Converter* converter)
-{
-	if (mRegisteredConverters.Contains(name))
-	{
-		Log::E("WindowContext already has a Converter registered with name '" + name + "'");
-	}
-	else
-	{
-		mRegisteredConverters[name] = converter;
-	}
-}
-
-Converter* WindowContext::GetRegisteredConverter(const Str& name)
-{
-	if (mRegisteredConverters.Contains(name))
-	{
-		return mRegisteredConverters[name];
-	}
-	return NULL;
-}
-
-}

+ 0 - 72
src/windowing/WindowContext.h

@@ -1,72 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "WithProperties.h"
-#include "WindowsManager.h"
-
-namespace Crown
-{
-
-class Converter;
-
-typedef Dictionary<Str, Converter*> ConverterDictionary;
-
-//! A class that serves as a base-class to define a context for windows, where actions are registered and take place
-class WindowContext: public WithProperties
-{
-public:
-	WindowContext(WindowsManager* windowsManager);
-	virtual ~WindowContext();
-
-	inline Window* GetAssociatedWindow() const
-	 { return mAssociatedWindow; }
-
-	inline WindowsManager* GetWindowsManager() const
-	{ return mWindowsManager; }
-
-	Widget* FindWidgetByName(const Str& name) const;
-
-	virtual void OnLoad() = 0;
-
-	void RegisterAction(const Str& name, ActionDelegate* slot);
-	ActionDelegate* GetRegisteredAction(const Str& name);
-
-	void RegisterConverter(const Str& name, Converter* converter);
-	Converter* GetRegisteredConverter(const Str& name);
-
-private:
-	WindowsManager* mWindowsManager;
-	Window* mAssociatedWindow;
-	ActionDictionary mRegisteredActions;
-	ConverterDictionary mRegisteredConverters;
-
-	void SetAssociatedWindow(Window* associatedWindow);
-
-	friend class XWMLReader;
-};
-
-}

+ 0 - 204
src/windowing/WindowingEventArgs.h

@@ -1,204 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "CoreEventArgs.h"
-#include "Device.h"
-#include "Mouse.h"
-#include "KeyCode.h"
-
-namespace Crown
-{
-
-class Widget;
-
-class WindowingEventArgs: public EventArgs
-{
-public:
-	WindowingEventArgs(Widget* source):
-		mSource(source), mPropagationStopped(false)
-	{
-	}
-	virtual ~WindowingEventArgs() { }
-
-	inline Widget* GetSource() const
-	{
-		return mSource;
-	}
-	inline bool IsPropagationStopped() const
-	{
-		return mPropagationStopped;
-	}
-
-	inline void StopPropagation(bool value)
-	{
-		mPropagationStopped = value;
-	}
-
-private:
-	Widget* mSource;
-	bool mPropagationStopped;
-};
-
-class MouseEventArgs: public WindowingEventArgs
-{
-public:
-	MouseEventArgs(Widget* source):
-		WindowingEventArgs(source)
-	{
-	}
-	virtual ~MouseEventArgs() { }
-
-	const Vec2& GetMousePosition();
-	const Vec2& GetMousePosition(Widget* w);
-};
-
-class MouseMoveEventArgs: public MouseEventArgs
-{
-public:
-	MouseMoveEventArgs(Widget* source, const Point32_t2& delta):
-		MouseEventArgs(source), mDelta(delta)
-	{
-	}
-
-	virtual ~MouseMoveEventArgs()
-	{
-	}
-
-	inline const Point32_t2& GetDelta()
-	{
-		return mDelta;
-	}
-
-private:
-	Point32_t2 mDelta;
-};
-
-class MouseButtonEventArgs: public MouseEventArgs
-{
-public:
-	MouseButtonEventArgs(Widget* source, MouseButton button, bool isclick):
-		MouseEventArgs(source), mButton(button), mIsClick(isclick)
-	{
-	}
-
-	virtual ~MouseButtonEventArgs()
-	{
-	}
-
-	inline MouseButton GetButton()
-	{
-		return mButton;
-	}
-
-	inline bool IsClick()
-	{
-		return mIsClick;
-	}
-
-private:
-	MouseButton mButton;
-	bool mIsClick;
-};
-
-class KeyboardEventArgs: public WindowingEventArgs
-{
-public:
-	KeyboardEventArgs(Widget* source, Key key):
-		WindowingEventArgs(source), mKey(key)
-	{
-	}
-
-	virtual ~KeyboardEventArgs()
-	{
-	}
-
-	inline Key GetKey()
-	{
-		return mKey;
-	}
-
-private:
-	Key mKey;
-};
-
-class TextInputEventArgs: public WindowingEventArgs
-{
-public:
-	TextInputEventArgs(Widget* source, Str text):
-		WindowingEventArgs(source), mText(text)
-	{
-	}
-
-	virtual ~TextInputEventArgs()
-	{
-	}
-
-	inline const Str& GetText() const
-	{
-		return mText;
-	}
-
-private:
-	Str mText;
-};
-
-class WindowCloseEventArgs: public WindowingEventArgs
-{
-public:
-	WindowCloseEventArgs(Widget* source):
-		WindowingEventArgs(source), cancel(false)
-	{
-	}
-	virtual ~WindowCloseEventArgs() { }
-
-	bool cancel;
-};
-
-class SelectionChangedEventArgs: public WindowingEventArgs
-{
-public:
-	SelectionChangedEventArgs(Widget* source, int32_t oldIndex, int32_t newIndex):
-		WindowingEventArgs(source), mOldIndex(oldIndex), mNewIndex(newIndex)
-	{
-	}
-	virtual ~SelectionChangedEventArgs() { }
-
-	inline int32_t GetOldIndex()
-	{
-		return mOldIndex;
-	}
-	inline int32_t GetNewIndex()
-	{
-		return mNewIndex;
-	}
-
-private:
-	int32_t mOldIndex;
-	int32_t mNewIndex;
-};
-
-} //namespace Crown

+ 0 - 574
src/windowing/WindowsManager.cpp

@@ -1,574 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "WindowsManager.h"
-#include "Device.h"
-#include <GL/glew.h> // FIXME
-#include "Types.h"
-#include "Themes.h"
-#include "LunaTheme.h"
-#include "Log.h"
-#include "Scene.h"
-#include "Renderer.h"
-#include "RenderWindow.h"
-#include "InputManager.h"
-
-namespace Crown
-{
-
-WindowsManager::WindowsManager(Scene* creator):
-	SceneNode(creator, 0, Vec3(0, 0, 0), Angles(0, 0, 0), true),
-	mMouseCapturedWidget(NULL), mWidgetUnderMouse(NULL), mWidgetMouseDown(NULL),
-	mInputFocusWidget(NULL), mModalWindow(NULL), mMousePosition(-10000, -10000)
-{
-	Device* mDevice = GetDevice();
-	mDevice->GetInputManager()->RegisterMouseListener(this);
-	mDevice->GetInputManager()->RegisterKeyboardListener(this);
-
-	Themes::LoadTheme(new LunaTheme());
-
-	//Register the default actions
-	RegisterAction("QuitApplication", CreateDelegate(this, &WindowsManager::QuitApplicationAction));
-	RegisterAction("CopyProperty", CreateDelegate(this, &WindowsManager::CopyProperty));
-
-	if (creator)
-		creator->GetRootSceneNode()->AddChild(this);
-}
-
-WindowsManager::~WindowsManager()
-{
-	for (int32_t i=0; i<mWindows.GetSize(); i++)
-	{
-		delete mWindows[i];
-	}
-
-	ActionDictionary::Enumerator e = mRegisteredActions.getBegin();
-	while (e.next())
-	{
-		delete e.current().value;
-	}
-}
-
-bool WindowsManager::DoModalWindow(Window* window)
-{
-	if (mModalWindow != NULL)
-		return false;
-
-	mModalWindow = window;
-
-	//Perform a layout of the window to obtain actual size and place it at the center of the screen
-	RenderWindow* renderWindow = GetDevice()->GetMainWindow();
-	window->_PerformLayout();
-
-	uint32_t rwWidth, rwHeight;
-	renderWindow->GetMetrics(rwWidth, rwHeight);
-	window->SetDesiredPosition((int32_t)Math::Floor(((float)rwWidth  - window->GetSize().x)/2.0f),
-														 (int32_t)Math::Floor(((float)rwHeight - window->GetSize().y)/2.0f));
-
-	return true;
-}
-
-void WindowsManager::EndModal(Window* window)
-{
-	if (mModalWindow == window)
-	{
-		mModalWindow = NULL;
-	}
-}
-
-void WindowsManager::RegisterAction(const Str& name, ActionDelegate* slot)
-{
-	if (mRegisteredActions.Contains(name))
-	{
-		Log::E("WindowsManager already has an Action registered with name '" + name + "'");
-	}
-	else
-	{
-		mRegisteredActions[name] = slot;
-	}
-}
-
-ActionDelegate* WindowsManager::GetRegisteredAction(const Str& name)
-{
-	if (mRegisteredActions.Contains(name))
-	{
-		//Return a duplicate because the caller will usually pass the delegate to an event, which transfers ownership
-		return (ActionDelegate*)mRegisteredActions[name]->Duplicate();		
-	}
-	return NULL;
-}
-
-void WindowsManager::ButtonPressed(const MouseEvent& event)
-{
-	if (mWidgetUnderMouse != NULL)
-	{
-		mWidgetMouseDown = mWidgetUnderMouse;
-		BringWindowToFront(mWidgetMouseDown->GetWindow());
-		MouseDownHelper(mWidgetMouseDown);
-	}
-	else if (mMouseCapturedWidget != NULL)
-	{
-		BringWindowToFront(mMouseCapturedWidget->GetWindow());
-		MouseDownHelper(mMouseCapturedWidget);
-	}
-}
-
-void WindowsManager::ButtonReleased(const MouseEvent& event)
-{
-	if (mWidgetUnderMouse != NULL)
-	{
-		bool isClick = mWidgetUnderMouse == mWidgetMouseDown || (mMouseCapturedWidget != NULL && mWidgetUnderMouse->IsChildOf(mMouseCapturedWidget));
-		
-		MouseUpHelper(mWidgetUnderMouse, isClick);
-		mWidgetMouseDown = NULL;
-	}
-	else if (mMouseCapturedWidget != NULL)
-	{
-		MouseUpHelper(mMouseCapturedWidget, false);
-	}
-}
-
-void WindowsManager::CursorMoved(const MouseEvent& event)
-{
-	Point32_t2 newMousePosition(event.x, event.y);
-
-	if (mMousePosition.x == -10000)
-	{
-		mMousePosition = newMousePosition;
-	}
-
-	//Check for the widget under mouse.
-	Point32_t2 point32_t(newMousePosition);
-	Widget* wdg = NULL;
-	Widget* wdgToMove = NULL;
-
-	if (mMouseCapturedWidget != NULL)
-	{
-		wdgToMove = mMouseCapturedWidget;
-		Widget* parent = mMouseCapturedWidget->GetParent();
-
-		if (parent != NULL)
-		{
-			point32_t -= parent->GetScreenPosition();
-		}
-
-		if (mMouseCapturedWidget->IsPoint32_tInside(point32_t))
-		{
-			wdg = mMouseCapturedWidget;
-		}
-	}
-	else
-	{
-		for (int32_t i=mWindows.GetSize()-1; i>=0; i--)
-		{
-			Window* w = mWindows[i];
-
-			if (w->IsMouseSensible() && w->IsPoint32_tInside(point32_t))
-			{
-				point32_t -= w->GetPosition() + w->GetTranslation();
-				wdg = FindWidgetAt(w, point32_t);
-				break;
-			}
-		}
-
-		if (mModalWindow != NULL && wdg != NULL && wdg->GetWindow() != mModalWindow)
-		{
-			return;
-		}
-	}
-
-	if (wdg == NULL)
-	{
-		//Mouse is not inside any window
-		if (mWidgetUnderMouse != NULL)
-		{
-			MouseOutHelper(mWidgetUnderMouse);
-			mWidgetUnderMouse = NULL;
-		}
-
-		mWidgetMouseDown = NULL;
-	}
-	else if (mWidgetUnderMouse != wdg)
-	{
-		if (mWidgetUnderMouse != NULL)
-		{
-			MouseOutHelper(mWidgetUnderMouse);
-		}
-
-		mWidgetUnderMouse = wdg;
-		MouseInHelper(mWidgetUnderMouse);
-		wdgToMove = wdg;
-	}
-
-	if (wdgToMove)
-	{
-		point32_t -= wdgToMove->GetPosition();
-		MouseMoveHelper(wdgToMove, newMousePosition - mMousePosition);
-	}
-
-	mMousePosition = newMousePosition;
-}
-
-void WindowsManager::KeyPressed(const KeyboardEvent& event)
-{
-	if (event.key == KC_F1)
-	{
-		Widget::SetDrawDebugBorder(true);
-	}
-
-	if (mInputFocusWidget != NULL)
-	{
-		KeyDownHelper(mInputFocusWidget, event.key);
-	}
-}
-
-void WindowsManager::KeyReleased(const KeyboardEvent& event)
-{
-	if (event.key == KC_F1)
-	{
-		Widget::SetDrawDebugBorder(false);
-	}
-
-	if (mInputFocusWidget != NULL)
-	{
-		KeyUpHelper(mInputFocusWidget, event.key);
-	}
-}
-
-void WindowsManager::TextInput(const KeyboardEvent& event)
-{
-	if (mInputFocusWidget != NULL)
-	{
-		TextInputHelper(mInputFocusWidget, event.text);
-	}
-}
-
-Widget* WindowsManager::FindWidgetAt(Widget* parent, Point32_t2& point32_t) const
-{
-	Widget* widgetInside = parent;
-
-	for (int32_t i=parent->mChildren.GetSize()-1; i>=0; i--)
-	{
-		Widget* w = parent->mChildren[i];
-
-		if (w->IsPoint32_tInside(point32_t))
-		{
-			point32_t -= w->GetPosition() + w->GetTranslation();
-			widgetInside = FindWidgetAt(w, point32_t);
-			break;
-		}
-	}
-
-	if (!widgetInside->IsMouseSensible())
-	{
-		return parent;
-	}
-
-	return widgetInside;
-}
-
-
-//Propagate the event in the widgets hierarchy. delegate contains the point32_ter to function and the
-//parameters that need to be passed to it.
-void WindowsManager::LaunchEvent(Widget* targetWidget, IDelegate1<void, bool>* onEventHelper, WindowingEventArgs* args)
-{
-	if (!onEventHelper || !targetWidget || !args)
-		return;
-
-	List<Widget*> ancestors;
-	Widget* w = targetWidget;
-	while (w != NULL)
-	{
-		ancestors.Append(w);
-		w = w->GetParent();
-	}
-
-	//Tunneling
-	args->StopPropagation(false);
-	for(int32_t i = ancestors.GetSize()-1; i >= 0; i--)
-	{
-		onEventHelper->SetCalledObject(ancestors[i]);
-		onEventHelper->Invoke(true);
-		if (args->IsPropagationStopped())
-			break;
-	}
-
-	//Bubbling
-	args->StopPropagation(false);
-	for(int32_t i = 0; i < ancestors.GetSize(); i++)
-	{
-		onEventHelper->SetCalledObject(ancestors[i]);
-		onEventHelper->Invoke(false);
-		if (args->IsPropagationStopped())
-			break;
-	}
-}
-
-/*
- *	Widget event helpers
- */
-
-void WindowsManager::MouseInHelper(Widget* targetWidget)
-{
-	MouseEventArgs args(targetWidget);
-	Delegate2<Widget, void, bool, MouseEventArgs*> d(NULL, &Widget::OnMouseInHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::MouseOutHelper(Widget* targetWidget)
-{
-	MouseEventArgs args(targetWidget);
-	Delegate2<Widget, void, bool, MouseEventArgs*> d(NULL, &Widget::OnMouseOutHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::MouseMoveHelper(Widget* targetWidget, const Point32_t2& delta)
-{
-	MouseMoveEventArgs args(targetWidget, delta);
-	Delegate2<Widget, void, bool, MouseMoveEventArgs*> d(NULL, &Widget::OnMouseMoveHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::MouseUpHelper(Widget* targetWidget, bool isClick)
-{
-	MouseButtonEventArgs args(targetWidget, MB_LEFT, isClick);
-	Delegate2<Widget, void, bool, MouseButtonEventArgs*> d(NULL, &Widget::OnMouseUpHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::MouseDownHelper(Widget* targetWidget)
-{
-	MouseButtonEventArgs args(targetWidget, MB_LEFT, false);
-	Delegate2<Widget, void, bool, MouseButtonEventArgs*> d(NULL, &Widget::OnMouseDownHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::TextInputHelper(Widget* targetWidget, const Str& text)
-{
-	TextInputEventArgs args(targetWidget, text);
-	Delegate2<Widget, void, bool, TextInputEventArgs*> d(NULL, &Widget::OnTextInputHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::GotFocusHelper(Widget* targetWidget)
-{
-	WindowingEventArgs args(targetWidget);
-	Delegate2<Widget, void, bool, WindowingEventArgs*> d(NULL, &Widget::OnGotFocusHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::LostFocusHelper(Widget* targetWidget)
-{
-	WindowingEventArgs args(targetWidget);
-	Delegate2<Widget, void, bool, WindowingEventArgs*> d(NULL, &Widget::OnLostFocusHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::KeyDownHelper(Widget* targetWidget, Key key)
-{
-	KeyboardEventArgs args(targetWidget, key);
-	Delegate2<Widget, void, bool, KeyboardEventArgs*> d(NULL, &Widget::OnKeyDownHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::KeyUpHelper(Widget* targetWidget, Key key)
-{
-	KeyboardEventArgs args(targetWidget, key);
-	Delegate2<Widget, void, bool, KeyboardEventArgs*> d(NULL, &Widget::OnKeyUpHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-void WindowsManager::SizeChangedHelper(Widget* targetWidget)
-{
-	WindowingEventArgs args(targetWidget);
-	Delegate2<Widget, void, bool, WindowingEventArgs*> d(NULL, &Widget::OnSizeChangedHelper, true, &args);
-	LaunchEvent(targetWidget, &d, &args);
-}
-
-bool WindowsManager::MouseCapture(Widget* w)
-{
-	if (mMouseCapturedWidget != NULL || w == NULL)
-	{
-		return false;
-	}
-
-	if (!w->IsMouseSensible())
-	{
-		return false;
-	}
-
-	mMouseCapturedWidget = w;
-	return true;
-}
-
-void WindowsManager::MouseRelease()
-{
-	mMouseCapturedWidget = NULL;
-}
-
-void WindowsManager::_SetTextInputFocusWidget(Widget* widget)
-{
-	if (mInputFocusWidget != NULL)
-	{
-		LostFocusHelper(mInputFocusWidget);
-	}
-	mInputFocusWidget = widget;
-	GotFocusHelper(mInputFocusWidget);
-}
-
-void WindowsManager::ReleaseWidget(Widget* w)
-{
-	if (mMouseCapturedWidget != NULL && mMouseCapturedWidget->IsChildOf(w))
-	{
-		MouseRelease();
-	}
-
-	if (mWidgetUnderMouse != NULL && mWidgetUnderMouse->IsChildOf(w))
-	{
-		mWidgetUnderMouse = NULL;
-	}
-
-	if (mWidgetMouseDown != NULL && mWidgetMouseDown->IsChildOf(w))
-	{
-		mWidgetMouseDown = NULL;
-	}
-
-	if (mInputFocusWidget != NULL && mInputFocusWidget->IsChildOf(w))
-	{
-		mInputFocusWidget = NULL;
-	}
-}
-
-void WindowsManager::BringWindowToFront(Window* window)
-{
-	if (mWindows[mWindows.GetSize() - 1] != window)
-	{
-		mWindows.Remove(mWindows.Find(window));
-		mWindows.Append(window);
-	}
-}
-
-void WindowsManager::OnRegisterForRendering()
-{
-	if (mCreator)
-		mCreator->RegisterNodeForRendering(this, RP_GUI);
-}
-
-void WindowsManager::Render()
-{
-	Renderer* renderer = GetDevice()->GetRenderer();
-	Mat4 ortho;
-	RenderWindow* rWindow = GetDevice()->GetMainWindow();
-	uint32_t rwWidth, rwHeight;
-	rWindow->GetMetrics(rwWidth, rwHeight);
-	ortho.BuildProjectionOrtho2dRH((float)rwWidth, (float)rwHeight, -1.0f, 1.0f);
-	renderer->SetMatrix(MT_PROJECTION, ortho);
-	renderer->SetMatrix(MT_VIEW, Mat4::IDENTITY);
-	renderer->SelectMatrix(MT_MODEL);
-	renderer->_SetScissor(true);
-	renderer->_SetBlending(true);
-	renderer->_SetBlendingParams(BE_FUNC_ADD, BF_SRC_ALPHA, BF_ONE_MINUS_SRC_ALPHA, Color4::BLACK);
-	renderer->_SetLighting(false);
-
-	for (int32_t i=0; i<mWindows.GetSize(); i++)
-	{
-		renderer->PushMatrix();
-		Window* wnd = mWindows[i];
-		wnd->_PerformLayout();
-
-		if (wnd == mModalWindow)
-		{
-			RenderWindow* renderWindow = GetDevice()->GetMainWindow();
-			//Draw a dark-gray overlay before drawing the modal window
-			//TODO: Adjust this behaviour by int32_troducing windows z-ordering and foremost windows
-			Color4 fillColor(0.0f, 0.0f, 0.0f, 0.3f);
-			renderer->_SetScissor(false);
-			renderer->DrawRectangle(Point32_t2::ZERO, Point32_t2(rwWidth, rwHeight), DM_FILL, fillColor, fillColor);
-			renderer->_SetScissor(true);
-		}
-
-		Point32_t2 pos = wnd->GetPosition();
-		Point32_t2 size = wnd->GetSize();
-		glTranslatef((float)pos.x, (float)pos.y, 0.0f);
-
-		DrawingClipInfo clipInfo;
-		clipInfo.screenX = pos.x;
-		clipInfo.screenY = pos.y;
-		clipInfo.sx = pos.x;
-		clipInfo.sy = pos.y;
-		clipInfo.sw = size.x;
-		clipInfo.sh = size.y;
-
-		renderer->SetScissorBox(pos.x, pos.y, size.x, size.y);
-		wnd->ApplyBinds();
-		wnd->OnDraw(clipInfo);
-		renderer->PopMatrix();
-	}
-
-	renderer->_SetScissor(false);
-}
-
-/*
- *	Predefined Actions
- */
-
-void WindowsManager::QuitApplicationAction(Widget* /*src*/, List<Str>* /*args*/)
-{
-	GetDevice()->StopRunning();
-}
-
-void WindowsManager::CopyProperty(Widget* src, List<Str>* args)
-{
-	//Input parameters:
-	//args[0]: Source of the copy
-	//args[1]: Destination of the copy
-	//TODO: Parse the source and destination to locate the properties to copy
-
-	List<Str> srcField;
-	List<Str> dstField;
-
-	(*args)[0].Split('.', srcField);
-	(*args)[1].Split('.', dstField);
-
-	Window* window = src->GetWindow();
-	Widget* srcWidget = window->FindChildByName(srcField[0]);
-	Widget* dstWidget = window->FindChildByName(dstField[0]);
-
-	if (srcWidget == NULL)
-	{
-		Log::E("CopyProperty action: Source widget '" + srcField[0] + "' could not be found");
-		return;
-	}
-
-	if (dstWidget == NULL)
-	{
-		Log::E("CopyProperty action: Destination widget '" + dstField[0] + "' could not be found");
-		return;
-	}
-
-	dstWidget->SetPropertyValue(dstField[1], srcWidget->GetPropertyValue(srcField[1]));
-}
-
-} //namespace Crown

+ 0 - 117
src/windowing/WindowsManager.h

@@ -1,117 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Window.h"
-#include "SceneNode.h"
-#include "Delegate.h"
-#include "KeyCode.h"
-#include "Keyboard.h"
-#include "Mouse.h"
-
-namespace Crown
-{
-
-class Scene;
-
-class WindowsManager: public SceneNode, public WeakReferenced, public MouseListener, public KeyboardListener
-{
-public:
-	WindowsManager(Scene* creator);
-	virtual ~WindowsManager();
-
-	virtual void KeyPressed(const KeyboardEvent& event);
-	virtual void KeyReleased(const KeyboardEvent& event);
-	virtual void TextInput(const KeyboardEvent& event);
-
-	virtual void ButtonPressed(const MouseEvent& event);
-	virtual void ButtonReleased(const MouseEvent& event);
-	virtual void CursorMoved(const MouseEvent& event);
-
-	virtual void OnRegisterForRendering();
-
-	virtual void Render();
-
-	inline Widget* GetTextInputFocusWidget() const
-	{
-		return mInputFocusWidget;
-	}
-
-	void RegisterAction(const Str& name, ActionDelegate* slot);
-	ActionDelegate* GetRegisteredAction(const Str& name);
-
-	void _SetTextInputFocusWidget(Widget* widget);
-
-	bool DoModalWindow(Window* window);
-
-protected:
-
-	bool MouseCapture(Widget* w);
-	void MouseRelease();
-
-	void ReleaseWidget(Widget* window);
-	void BringWindowToFront(Window* window);
-
-	friend class Widget;
-
-private:
-	List<Window*> mWindows;
-	Widget* mMouseCapturedWidget;
-	Widget* mWidgetUnderMouse;
-	Widget* mWidgetMouseDown;     //The widget on which the mouse was pressed (if any)
-	Widget* mInputFocusWidget;
-	Window* mModalWindow;
-	Point32_t2 mMousePosition;
-	ActionDictionary mRegisteredActions;
-
-	//Default action handlers
-	void QuitApplicationAction(Widget* src, List<Str>* args);
-	void CopyProperty(Widget* src, List<Str>* args);
-
-	Widget* FindWidgetAt(Widget* parent, Point32_t2& point32_t) const;
-	void LaunchEvent(Widget* targetWidget, IDelegate1<void, bool>* onEventHelper, WindowingEventArgs* args);
-
-	//Helpers
-	void MouseInHelper(Widget* targetWidget);
-	void MouseOutHelper(Widget* targetWidget);
-	void MouseMoveHelper(Widget* targetWidget, const Point32_t2& delta);
-	void MouseUpHelper(Widget* targetWidget, bool);
-	void MouseDownHelper(Widget* targetWidget);
-	void TextInputHelper(Widget* targetWidget, const Str& text);
-	void GotFocusHelper(Widget* targetWidget);
-	void LostFocusHelper(Widget* targetWidget);
-	void KeyDownHelper(Widget* targetWidget, Key key);
-	void KeyUpHelper(Widget* targetWidget, Key key);
-	void SizeChangedHelper(Widget* targetWidget);
-
-	//Called from Window::Close() to end modal
-	void EndModal(Window* window);
-
-	friend class Window;
-};
-
-} //namespace Crown

+ 0 - 64
src/windowing/layouts/CanvasLayout.cpp

@@ -1,64 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "CanvasLayout.h"
-#include "Types.h"
-
-namespace Crown
-{
-
-CanvasLayout::CanvasLayout(Widget* parent):
-	Widget(parent)
-{
-	SetMouseSensible(false);
-}
-
-CanvasLayout::~CanvasLayout()
-{
-}
-
-void CanvasLayout::OnArrange(Point32_t2 position, Point32_t2 size)
-{
-	Move(position);
-	Resize(size);
-	const List<Widget*>& children = GetChildren();
-
-	for (int32_t i=0; i<children.GetSize(); i++)
-	{
-    Point32_t2 childPosition = children[i]->GetDesiredPosition();
-		Point32_t2 childSize = children[i]->GetMeasuredSize();
-    
-    if (childSize.x < 0)
-      childSize.x = children[i]->GetMinimumSize().x;
-    if (childSize.y < 0)
-      childSize.y = children[i]->GetMinimumSize().y;
-
-		children[i]->OnArrange(childPosition, childSize);
-	}
-}
-
-
-}
-

+ 0 - 46
src/windowing/layouts/CanvasLayout.h

@@ -1,46 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-
-namespace Crown
-{
-
-class CanvasLayout: public Widget
-{
-public:
-	CanvasLayout(Widget* parent);
-	virtual ~CanvasLayout();
-
-	virtual void OnArrange(Point32_t2 position, Point32_t2 size);
-
-	virtual Str ToStr() const
-	 { return "CanvasLayout"; }
-};
-
-} //namespace Crown

+ 0 - 455
src/windowing/layouts/StackLayout.cpp

@@ -1,455 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "StackLayout.h"
-#include "Types.h"
-#include "SpecificProperties.h"
-
-namespace Crown
-{
-
-StackLayout::StackLayout(Widget* parent):
-	Widget(parent), mOrientation(SO_VERTICAL)
-{
-	SetMouseSensible(false);
-
-	EnumProperty* prop = new EnumProperty("Orientation", (int32_t*)&mOrientation);
-	prop->AddValueMapping("Horizontal", SO_HORIZONTAL);
-	prop->AddValueMapping("Vertical", SO_VERTICAL);
-	AddProperty(prop);
-}
-
-StackLayout::~StackLayout()
-{
-}
-
-void StackLayout::SetOrientation(StackOrientation value)
-{
-	mOrientation = value;
-	NotifyNeedsLayout();
-}
-
-void StackLayout::OnSetProperty(const Str& name)
-{
-	if (name == "Orientation")
-	{
-		NotifyNeedsLayout();
-	}
-	else
-	{
-		Widget::OnSetProperty(name);
-	}
-}
-
-void StackLayout::OnArrange(Point32_t2 position, Point32_t2 size)
-{
-	Move(position);
-	Resize(size);
-
-	//La misurazione è stata fatta, ogni widget figlio sa le dimensioni che desidera o se sono arbitrarie
-
-	if (mOrientation == SO_VERTICAL)
-	{
-		//Calculate the remaining space, given that some widgets have an height set
-
-		//Obiettivo: assegnare la dimensione desiderata ai widget che la hanno, 
-		//					 individuare lo spazio rimanente e finchè ad almeno un widget non va bene
-		//					 riprovare a calcolarlo
-		List<WidgetSizeAcceptedEnum> acceptedStatus;
-		const List<Widget*>& children = GetChildren();
-
-		int32_t fixedHeight = 0;
-		int32_t fixedHeightCount = 0;
-		
-
-		for (int32_t i = 0; i < children.GetSize(); i++)
-		{
-			Widget* child = children[i];
-			int32_t measuredY = child->GetMeasuredSize().y;
-
-			if (measuredY >= 0)
-			{
-				acceptedStatus.Append(WSA_FIXED);
-				fixedHeightCount ++;
-				//Take margins int32_to account
-				fixedHeight += measuredY + child->GetMargins().GetFixedMarginsY();
-			}
-			else
-				acceptedStatus.Append(WSA_ACCEPTED);
-		}
-
-		float suggestedHeight = ((float)size.y - fixedHeight) / (children.GetSize() - fixedHeightCount);
-		float roundupRemainder = suggestedHeight - (int32_t)(suggestedHeight);
-		float accumulator = 0.0f;
-		suggestedHeight = (float)((int32_t)suggestedHeight);
-
-		if (suggestedHeight < 0.0f)
-		{
-			//No free space to assign, go over to actual assignment phase
-			suggestedHeight = 0.0f;
-		}
-		else
-		{
-			for (int32_t i = 0; i < children.GetSize(); i++)
-			{
-				Widget* child = children[i];
-
-				WidgetSizeAcceptedEnum accepted = acceptedStatus[i];
-
-				if (accepted != WSA_ACCEPTED)
-					continue;
-				else
-				{
-					//Try to propose the calculated height and see if the response changes
-					//If so, restart the scan with a new suggestedHeight
-					int32_t height = (int32_t)suggestedHeight;
-					accumulator += roundupRemainder;
-					if (accumulator >= 0.9999f)
-					{
-						accumulator -= 1.0f;
-						height++;
-					}
-
-					WidgetSizeAcceptedEnum acceptedNew = child->GetSizeAcceptedY(height);
-					if (acceptedNew != accepted)
-					{
-						//Based on acceptedNew, which is now either WSA_MIN_SIZE or WSA_MAX_SIZE, add the min or max size to the fixedHeight and start over
-						switch (acceptedNew)
-						{
-							case WSA_MIN_SIZE:
-								fixedHeight += child->GetMinimumSize().y;
-							break;
-							case WSA_MAX_SIZE:
-								fixedHeight += child->GetMaximumSize().y;
-							break;
-						}
-						//Consider the fixed margins as well
-						fixedHeight += child->GetMargins().GetFixedMarginsY();
-						fixedHeightCount += 1;
-
-						if (children.GetSize() == fixedHeightCount)
-						{
-							//No more variable sized widgets to calculate, exit the acceptation for loop
-							break;
-						}
-
-						suggestedHeight = ((float)size.y - fixedHeight) / (children.GetSize() - fixedHeightCount);
-						roundupRemainder = suggestedHeight - (int32_t)(suggestedHeight);
-						accumulator = 0.0f;
-						suggestedHeight = (float)((int32_t)suggestedHeight);
-						//Replace the acceptedStatus and start over
-						acceptedStatus[i] = acceptedNew;
-						i = -1;
-					}
-				}
-			}
-		}
-
-		accumulator = 0.0f;
-
-		position = Point32_t2::ZERO;
-		int32_t xSpace = size.x;
-		size.y = 0;
-
-		for (int32_t i = 0; i < children.GetSize(); i++)
-		{
-			Widget* child = children[i];
-			Point32_t2 pos = position;
-			int32_t occupiedSpace = 0;
-			bool applyMargins = false;
-
-			switch (acceptedStatus[i])
-			{
-				case WSA_ACCEPTED:
-				{
-					//Use the suggested height
-					int32_t height = (int32_t)suggestedHeight;
-					accumulator += roundupRemainder;
-					if (accumulator >= 0.9999f)
-					{
-						accumulator -= 1.0f;
-						height++;
-					}
-
-					occupiedSpace = height;
-					size.y = height;
-					child->ErodeMarginsY(pos, size);
-				}break;
-
-				case WSA_MIN_SIZE:
-				{
-					//Pass in the min size plus the margins
-					size.y = child->GetMinimumSize().y;
-					applyMargins = true;
-				}break;
-
-				case WSA_MAX_SIZE:
-				{
-					//Pass in the min size plus the margins
-					size.y = child->GetMaximumSize().y;
-					applyMargins = true;
-				}break;
-
-				case WSA_FIXED:
-				{
-					//Pass in the min size plus the margins
-					size.y = child->GetMeasuredSize().y;
-					applyMargins = true;
-				}break;
-			}
-
-			if (applyMargins)
-			{
-				occupiedSpace = size.y + child->GetMargins().GetFixedMarginsY();
-				if (child->GetMargins().top > 0)
-				{
-					pos.y += child->GetMargins().top;
-				}
-			}
-
-			size.x = xSpace;
-			child->FitMeasuredSizeX(pos, size);
-			child->OnArrange(pos, size);
-			position.y += occupiedSpace;
-		}
-	}
-	else
-	{
-		//Calculate the remaining space, given that some widgets have an height set
-
-		//Obiettivo: assegnare la dimensione desiderata ai widget che la hanno, 
-		//					 individuare lo spazio rimanente e finchè ad almeno un widget non va bene
-		//					 riprovare a calcolarlo
-		List<WidgetSizeAcceptedEnum> acceptedStatus;
-		const List<Widget*>& children = GetChildren();
-
-		int32_t fixedHeight = 0;
-		int32_t fixedHeightCount = 0;
-		
-
-		for (int32_t i = 0; i < children.GetSize(); i++)
-		{
-			Widget* child = children[i];
-			int32_t measuredX = child->GetMeasuredSize().x;
-
-			if (measuredX >= 0)
-			{
-				acceptedStatus.Append(WSA_FIXED);
-				fixedHeightCount ++;
-				//Take margins int32_to account
-				fixedHeight += measuredX + child->GetMargins().GetFixedMarginsX();
-			}
-			else
-				acceptedStatus.Append(WSA_ACCEPTED);
-		}
-
-		float suggestedHeight = ((float)size.x - fixedHeight) / (children.GetSize() - fixedHeightCount);
-		float roundupRemainder = suggestedHeight - (int32_t)(suggestedHeight);
-		float accumulator = 0.0f;
-		suggestedHeight = (float)((int32_t)suggestedHeight);
-
-		if (suggestedHeight < 0.0f)
-		{
-			//No free space to assign, go over to actual assignment phase
-			suggestedHeight = 0.0f;
-		}
-		else
-		{
-			for (int32_t i = 0; i < children.GetSize(); i++)
-			{
-				Widget* child = children[i];
-
-				WidgetSizeAcceptedEnum accepted = acceptedStatus[i];
-
-				if (accepted != WSA_ACCEPTED)
-					continue;
-				else
-				{
-					//Try to propose the calculated height and see if the response changes
-					//If so, restart the scan with a new suggestedHeight
-					int32_t width = (int32_t)suggestedHeight;
-					accumulator += roundupRemainder;
-					if (accumulator >= 0.9999f)
-					{
-						accumulator -= 1.0f;
-						width++;
-					}
-
-					WidgetSizeAcceptedEnum acceptedNew = child->GetSizeAcceptedX(width);
-					if (acceptedNew != accepted)
-					{
-						//Based on acceptedNew, which is now either WSA_MIN_SIZE or WSA_MAX_SIZE, add the min or max size to the fixedHeight and start over
-						switch (acceptedNew)
-						{
-							case WSA_MIN_SIZE:
-								fixedHeight += child->GetMinimumSize().x;
-							break;
-							case WSA_MAX_SIZE:
-								fixedHeight += child->GetMaximumSize().x;
-							break;
-						}
-						//Consider the fixed margins as well
-						fixedHeight += child->GetMargins().GetFixedMarginsX();
-						fixedHeightCount += 1;
-
-						if (children.GetSize() == fixedHeightCount)
-						{
-							//No more variable sized widgets to calculate, exit the acceptation for loop
-							break;
-						}
-
-						suggestedHeight = ((float)size.x - fixedHeight) / (children.GetSize() - fixedHeightCount);
-						roundupRemainder = suggestedHeight - (int32_t)(suggestedHeight);
-						accumulator = 0.0f;
-						suggestedHeight = (float)((int32_t)suggestedHeight);
-						//Replace the acceptedStatus and start over
-						acceptedStatus[i] = acceptedNew;
-						i = -1;
-					}
-				}
-			}
-		}
-
-		accumulator = 0.0f;
-
-		position = Point32_t2::ZERO;
-		int32_t ySpace = size.y;
-		size.x = 0;
-
-		for (int32_t i = 0; i < children.GetSize(); i++)
-		{
-			Widget* child = children[i];
-			Point32_t2 pos = position;
-			int32_t occupiedSpace = 0;
-			bool applyMargins = false;
-
-			switch (acceptedStatus[i])
-			{
-				case WSA_ACCEPTED:
-				{
-					//Use the suggested height
-					int32_t height = (int32_t)suggestedHeight;
-					accumulator += roundupRemainder;
-					if (accumulator >= 0.9999f)
-					{
-						accumulator -= 1.0f;
-						height++;
-					}
-
-					occupiedSpace = height;
-					size.x = height;
-					child->ErodeMarginsX(pos, size);
-				}break;
-
-				case WSA_MIN_SIZE:
-				{
-					//Pass in the min size plus the margins
-					size.x = child->GetMinimumSize().x;
-					applyMargins = true;
-				}break;
-
-				case WSA_MAX_SIZE:
-				{
-					//Pass in the min size plus the margins
-					size.x = child->GetMaximumSize().x;
-					applyMargins = true;
-				}break;
-
-				case WSA_FIXED:
-				{
-					//Pass in the min size plus the margins
-					size.x = child->GetMeasuredSize().x;
-					applyMargins = true;
-				}break;
-			}
-
-			if (applyMargins)
-			{
-				occupiedSpace = size.x + child->GetMargins().GetFixedMarginsX();
-				if (child->GetMargins().left > 0)
-				{
-					pos.x += child->GetMargins().left;
-				}
-			}
-
-			size.y = ySpace;
-			child->FitMeasuredSizeY(pos, size);
-			child->OnArrange(pos, size);
-			position.x += occupiedSpace;
-		}
-	}
-}
-
-void StackLayout::OnMeasureFitX()
-{
-	int32_t msx = 0;
-
-	const List<Widget*> children = GetChildren();
-
-	for (int32_t i = 0; i < children.GetSize(); i++)
-	{
-		Widget* child = children[i];
-
-		int32_t w = child->GetMeasuredSize().x;
-		if (child->GetMargins().left > 0)
-			w += child->GetMargins().left;
-		if (child->GetMargins().right > 0)
-			w += child->GetMargins().right;
-		
-		if (mOrientation == SO_VERTICAL)
-			msx = Math::Max(msx, w);
-		else
-			msx += w;
-	}
-
-	mMeasuredSize.x = msx;
-}
-
-void StackLayout::OnMeasureFitY()
-{
-	int32_t msy = 0;
-
-	const List<Widget*> children = GetChildren();
-
-	for (int32_t i = 0; i < children.GetSize(); i++)
-	{
-		Widget* child = children[i];
-
-		int32_t h = child->GetMeasuredSize().y;
-		if (child->GetMargins().top > 0)
-			h += child->GetMargins().top;
-		if (child->GetMargins().bottom > 0)
-			h += child->GetMargins().bottom;
-		
-		if (mOrientation == SO_HORIZONTAL)
-			msy = Math::Max(msy, h);
-		else
-			msy += h;
-	}
-
-	mMeasuredSize.y = msy;
-}
-
-}

+ 0 - 61
src/windowing/layouts/StackLayout.h

@@ -1,61 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Widget.h"
-
-namespace Crown
-{
-
-enum StackOrientation
-{
-	SO_HORIZONTAL = 0,
-	SO_VERTICAL
-};
-
-class StackLayout: public Widget
-{
-public:
-	StackLayout(Widget* parent);
-	virtual ~StackLayout();
-
-	virtual void OnArrange(Point32_t2 position, Point32_t2 size);
-	virtual void OnMeasureFitX();
-	virtual void OnMeasureFitY();
-
-	void SetOrientation(StackOrientation value);
-
-	virtual void OnSetProperty(const Str& name);
-
-	virtual Str ToStr() const
-	 { return "StackLayout"; }
-
-private:
-	StackOrientation mOrientation;
-};
-
-} //namespace Crown

+ 0 - 43
src/windowing/templates/ITemplate.h

@@ -1,43 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Generic.h"
-
-namespace Crown
-{
-
-template<typename TItem>
-class ITemplate
-{
-public:
-
-	virtual ~ITemplate() {}
-	virtual TItem* GenerateItem(const Generic& element) = 0;
-};
-
-}
-

+ 0 - 288
src/windowing/themes/LunaTheme.cpp

@@ -1,288 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "LunaTheme.h"
-#include "Themes.h"
-#include <GL/glew.h> // FIXME
-#include "Types.h"
-#include "Color4.h"
-#include "BMPImageLoader.h"
-#include "Device.h"
-#include "Image.h"
-#include "TextureManager.h"
-#include "Renderer.h"
-
-namespace Crown
-{
-
-LunaTheme::LunaTheme()
-{
-	mFunctions[TF_BUTTON_NORMAL] = &LunaTheme::DrawButtonNormal;
-	mFunctions[TF_BUTTON_HIGHLIGHTED] = &LunaTheme::DrawButtonHighlighted;
-	mFunctions[TF_BUTTON_PRESSED] = &LunaTheme::DrawButtonPressed;
-	mFunctions[TF_WINDOW] = &LunaTheme::DrawWindow;
-	mFunctions[TF_LISTVIEW] = &LunaTheme::DrawListView;
-
-	BMPImageLoader loader;
-	Image* img;
-	Frame* f;
-	Sprite* sprite;
-	img = loader.LoadFile("res/closebutton_x.bmp");
-	img->ApplyColorKeying(Color4(255, 0, 255));
-	f = new Frame();
-
-	bool created;
-	Texture* tex1;
-	tex1 = GetTextureManager()->Create("closebutton", created);
-	tex1->LoadFromImage(img);
-	f->Set(tex1, 0, img->GetHeight()-3, 3, img->GetHeight());
-
-	sprite = new Sprite();
-	sprite->AddFrame(f);
-	mSprites[TS_CLOSEBUTTON_X] = sprite;
-	delete img;
-
-	img = loader.LoadFile("res/boom.bmp");
-	img->ApplyColorKeying(Color4(255, 255, 255));
-	f = new Frame();
-
-	Texture* tex2;
-	tex2 = GetTextureManager()->Create("boom", created);
-	tex2->LoadFromImage(img);
-	f->Set(tex2, 0, 0, img->GetWidth(), img->GetHeight());
-
-	sprite = new Sprite();
-	sprite->AddFrame(f);
-	mSprites[TS_BOOM] = sprite;
-	delete img;
-}
-
-LunaTheme::~LunaTheme()
-{
-	SpritesDictionary::Enumerator e = mSprites.getBegin();
-
-	while (e.next())
-	{
-		delete e.current().value;
-	}
-}
-
-ThemeFunction LunaTheme::GetFunction(ThemesFunctions functionId)
-{
-	return mFunctions[functionId];
-}
-
-Sprite* LunaTheme::GetSprite(ThemesSprites spriteId)
-{
-	return mSprites[spriteId];
-}
-
-void LunaTheme::DrawButtonNormal(const Point32_t2& size)
-{
-	glPushMatrix();
-	int32_t fWidth = size.x;
-	int32_t fHeight = size.y;
-	glBegin(GL_QUAD_STRIP);
-	glColor3ub(245, 245, 245);
-	glVertex2i(fWidth-1, 1);
-	glVertex2i(1       , 1);
-	glColor3ub(220, 220, 220);
-	glVertex2i(fWidth-1, int32_t((fHeight-1)*0.55));
-	glVertex2i(1       , int32_t((fHeight-1)*0.55));
-	glColor3ub(200, 200, 200);
-	glVertex2i(fWidth-1, int32_t((fHeight-1)*0.8));
-	glVertex2i(1       , int32_t((fHeight-1)*0.8));
-	glColor3ub(210, 210, 210);
-	glVertex2i(fWidth-1, fHeight-1);
-	glVertex2i(1       , fHeight-1);
-	glEnd();
-	glBegin(GL_LINES);
-	glColor3f(0.85f, 0.85f, 0.85f);
-	glVertex2i(1       , 0);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(fWidth-1, 0);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(1       , fHeight-1);
-	glColor3f(0.5f, 0.5f, 0.5f);
-	glVertex2i(fWidth-1, fHeight-1);
-	glColor3f(0.85f, 0.85f, 0.85f);
-	glVertex2i(0       , 1);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(0       , fHeight-1);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(fWidth-1, 1);
-	glColor3f(0.5f, 0.5f, 0.5f);
-	glVertex2i(fWidth-1, fHeight-1);
-	glEnd();
-	glPopMatrix();
-}
-
-void LunaTheme::DrawButtonHighlighted(const Point32_t2& size)
-{
-	glPushMatrix();
-	int32_t fWidth = size.x;
-	int32_t fHeight = size.y;
-	glBegin(GL_QUAD_STRIP);
-	glColor3ub(250, 250, 250);
-	glVertex2i(fWidth-1, 1);
-	glVertex2i(1       , 1);
-	glColor3ub(225, 225, 225);
-	glVertex2i(fWidth-1, int32_t((fHeight-1)*0.55));
-	glVertex2i(1       , int32_t((fHeight-1)*0.55));
-	glColor3ub(205, 205, 205);
-	glVertex2i(fWidth-1, int32_t((fHeight-1)*0.8));
-	glVertex2i(1       , int32_t((fHeight-1)*0.8));
-	glColor3ub(215, 215, 215);
-	glVertex2i(fWidth-1, fHeight-1);
-	glVertex2i(1       , fHeight-1);
-	glEnd();
-	glBegin(GL_LINES);
-	glColor3f(0.90f, 0.90f, 0.90f);
-	glVertex2i(1       , 0);
-	glColor3f(0.80f, 0.80f, 0.80f);
-	glVertex2i(fWidth-1, 0);
-	glColor3f(0.80f, 0.80f, 0.80f);
-	glVertex2i(1       , fHeight-1);
-	glColor3f(0.55f, 0.55f, 0.55f);
-	glVertex2i(fWidth-1, fHeight-1);
-	glColor3f(0.90f, 0.90f, 0.90f);
-	glVertex2i(0       , 1);
-	glColor3f(0.80f, 0.80f, 0.80f);
-	glVertex2i(0       , fHeight-1);
-	glColor3f(0.80f, 0.80f, 0.80f);
-	glVertex2i(fWidth-1, 1);
-	glColor3f(0.55f, 0.55f, 0.55f);
-	glVertex2i(fWidth-1, fHeight-1);
-	glEnd();
-	glPopMatrix();
-}
-
-void LunaTheme::DrawButtonPressed(const Point32_t2& size)
-{
-	glPushMatrix();
-	int32_t fWidth = size.x;
-	int32_t fHeight = size.y;
-	glBegin(GL_QUAD_STRIP);
-	glColor3ub(210, 210, 210);
-	glVertex2i(fWidth-1, 1);
-	glVertex2i(1       , 1);
-	glColor3ub(200, 200, 200);
-	glVertex2i(fWidth-1, int32_t((fHeight-1)*0.2));
-	glVertex2i(1       , int32_t((fHeight-1)*0.2));
-	glColor3ub(220, 220, 220);
-	glVertex2i(fWidth-1, int32_t((fHeight-1)*0.45));
-	glVertex2i(1       , int32_t((fHeight-1)*0.45));
-	glColor3ub(245, 245, 245);
-	glVertex2i(fWidth-1, fHeight-1);
-	glVertex2i(1       , fHeight-1);
-	glEnd();
-	glBegin(GL_LINES);
-	glColor3f(0.5f, 0.5f, 0.5f);
-	glVertex2i(1       , 0);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(fWidth-1, 0);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(1       , fHeight-1);
-	glColor3f(0.85f, 0.85f, 0.85f);
-	glVertex2i(fWidth-1, fHeight-1);
-	glColor3f(0.5f, 0.5f, 0.5f);
-	glVertex2i(0       , 1);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(0       , fHeight-1);
-	glColor3f(0.75f, 0.75f, 0.75f);
-	glVertex2i(fWidth-1, 1);
-	glColor3f(0.85f, 0.85f, 0.85f);
-	glVertex2i(fWidth-1, fHeight-1);
-	glEnd();
-	glPopMatrix();
-}
-
-void LunaTheme::DrawWindow(const Point32_t2& size)
-{
-	glPushMatrix();
-	int32_t fWidth = size.x;
-	int32_t fHeight = size.y;
-	glColor3ub(235, 235, 235);
-	glBegin(GL_QUAD_STRIP);
-	glVertex2i(fWidth-1, 1);
-	glVertex2i(1       , 1);
-	glColor3ub(220, 220, 220);
-	glVertex2i(fWidth-1, fHeight-1);
-	glVertex2i(1       , fHeight-1);
-	glEnd();
-	const float alphaVal = 1.0f;
-	glBegin(GL_LINES);
-	glColor4f(0.8f, 0.8f, 0.8f, alphaVal);
-	//glColor4f(1.0f, 1.0f, 1.0f, alphaVal);
-	glVertex2i(1       , 0);
-	//glColor4f(0.8f, 0.8f, 0.8f, alphaVal);
-	glVertex2i(fWidth-1, 0);
-	//glColor4f(0.8f, 0.8f, 0.8f, alphaVal);
-	glVertex2i(1       , fHeight-1);
-	//glColor4f(0.6f, 0.6f, 0.6f, alphaVal);
-	glVertex2i(fWidth-1, fHeight-1);
-	//glColor4f(1.0f, 1.0f, 1.0f, alphaVal);
-	glVertex2i(0       , 1);
-	//glColor4f(0.8f, 0.8f, 0.8f, alphaVal);
-	glVertex2i(0       , fHeight-1);
-	//glColor4f(0.8f, 0.8f, 0.8f, alphaVal);
-	glVertex2i(fWidth-1, 1);
-	//glColor4f(0.6f, 0.6f, 0.6f, alphaVal);
-	glVertex2i(fWidth-1, fHeight-1);
-	glEnd();
-	glPopMatrix();
-}
-
-void LunaTheme::DrawListView(const Point32_t2& size)
-{
-	glPushMatrix();
-	int32_t fWidth = size.x;
-	int32_t fHeight = size.y;
-	glColor3ub(245, 245, 255);
-	glBegin(GL_QUAD_STRIP);
-	glVertex2i(fWidth-1, 1);
-	glVertex2i(1       , 1);
-	glColor3ub(230, 230, 240);
-	glVertex2i(fWidth-1, fHeight-1);
-	glVertex2i(1       , fHeight-1);
-	glEnd();
-	glPopMatrix();
-
-//	const float alphaVal = 1.0f;
-//	glBegin(GL_LINES);
-//	glColor4f(0.75f, 0.75f, 1.0f, alphaVal);
-//	glVertex2i(1       , 0);
-//	glVertex2i(fWidth-1, 0);
-//	glVertex2i(1       , fHeight-1);
-//	glVertex2i(fWidth-1, fHeight-1);
-//	glVertex2i(0       , 1);
-//	glVertex2i(0       , fHeight-1);
-//	glVertex2i(fWidth-1, 1);
-//	glVertex2i(fWidth-1, fHeight-1);
-//	glEnd();
-//	glPopMatrix();
-}
-
-} //namespace Crown

+ 0 - 59
src/windowing/themes/LunaTheme.h

@@ -1,59 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-#include "Dictionary.h"
-#include "Themes.h"
-
-namespace Crown
-{
-
-class LunaTheme: public ITheme
-{
-public:
-	LunaTheme();
-	~LunaTheme();
-
-	typedef Dictionary<ThemesSprites, Sprite*> SpritesDictionary;
-	typedef Dictionary<ThemesFunctions, ThemeFunction> FunctionsDictionary;
-
-	ThemeFunction GetFunction(ThemesFunctions functionId);
-	Sprite* GetSprite(ThemesSprites spriteId);
-
-private:
-	FunctionsDictionary mFunctions;
-	SpritesDictionary mSprites;
-
-	static void DrawButtonNormal(const Point32_t2& size);
-	static void DrawButtonHighlighted(const Point32_t2& size);
-	static void DrawButtonPressed(const Point32_t2& size);
-	static void DrawWindow(const Point32_t2& size);
-	static void DrawListView(const Point32_t2& size);
-
-};
-
-} //namespace Crown

+ 0 - 99
src/windowing/toolbox/MessageWindow.cpp

@@ -1,99 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "MessageWindow.h"
-#include "StackLayout.h"
-
-namespace Crown
-{
-
-MessageWindow::MessageWindow(WindowsManager* wm, const Str& title, const Str& message, int32_t buttonsFlags, MessageResultDelegate* callback):
-	Window(wm, 300, 300, 250, 70, title), mCallback(callback)
-{
-
-
-	StackLayout* layout = new StackLayout(GetContentWidget());
-	layout->SetMargins(2, 10, 2, 2);
-
-	Label* lbl;
-	lbl = new Label(layout, message);
-
-	StackLayout* buttonLayout = new StackLayout(layout);
-	buttonLayout->SetMargins(0, 2, 0, 0);
-	buttonLayout->SetOrientation(SO_HORIZONTAL);
-
-	//If no valid flag has been specified, use MWR_OK
-	if ((buttonsFlags & (MWR_OK | MWR_CANCEL | MWR_YES | MWR_NO)) == 0)
-		buttonsFlags = MWR_OK;
-
-	//Note: do not use the same instance of delegate for all the events, because the += operation transfers the ownership
-	if (buttonsFlags & MWR_OK)
-	{
-		mOkButton = new Button(buttonLayout, "Ok");
-		mOkButton->SetMargins(2, 0, 2, 0);
-		mOkButton->OnClickEvent += CreateDelegate(this, &MessageWindow::mButton_OnClick);
-	}
-	if (buttonsFlags & MWR_CANCEL)
-	{
-		mCancelButton = new Button(buttonLayout, "Cancel");
-		mCancelButton->SetMargins(2, 0, 2, 0);
-		mCancelButton->OnClickEvent += CreateDelegate(this, &MessageWindow::mButton_OnClick);
-	}
-	if (buttonsFlags & MWR_YES)
-	{
-		mYesButton = new Button(buttonLayout, "Yes");
-		mYesButton->SetMargins(2, 0, 2, 0);
-		mYesButton->OnClickEvent += CreateDelegate(this, &MessageWindow::mButton_OnClick);
-	}
-	if (buttonsFlags & MWR_NO)
-	{
-		mNoButton = new Button(buttonLayout, "No");
-		mNoButton->SetMargins(2, 0, 2, 0);
-		mNoButton->OnClickEvent += CreateDelegate(this, &MessageWindow::mButton_OnClick);
-	}
-}
-
-void MessageWindow::mButton_OnClick(Button* button, EventArgs* /*args*/)
-{
-	if (mCallback)
-	{
-		int32_t resultFlags = 0;
-
-		if (button == mOkButton)
-			resultFlags |= MWR_OK;
-		if (button == mCancelButton)
-			resultFlags |= MWR_CANCEL;
-		if (button == mYesButton)
-			resultFlags |= MWR_YES;
-		if (button == mNoButton)
-			resultFlags |= MWR_NO;
-
-		mCallback->Invoke(resultFlags);
-		mCallback->Trash();
-	}
-	Close();
-}
-
-}

+ 0 - 63
src/windowing/toolbox/MessageWindow.h

@@ -1,63 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Window.h"
-#include "TextBox.h"
-
-namespace Crown
-{
-
-enum MessageWindowResult
-{
-	MWR_OK = 1,
-	MWR_CANCEL = 2,
-	MWR_YES = 4,
-	MWR_NO = 8
-};
-
-class MessageWindow: public Window
-{
-  public:
-		typedef IDelegate1<void, int32_t> MessageResultDelegate;
-
-    MessageWindow(WindowsManager* wm, const Str& title, const Str& message, int32_t buttonsFlags, MessageResultDelegate* callback);
-
-		void mButton_OnClick(Button* obj, EventArgs* args);
-
-	virtual Str ToStr() const
-	 { return "MessageWindow"; }
-
-  private:
-		Button* mOkButton;
-		Button* mCancelButton;
-		Button* mYesButton;
-		Button* mNoButton;
-		MessageResultDelegate* mCallback;
-};
-
-}
-

+ 0 - 78
src/windowing/toolbox/TextInputWindow.cpp

@@ -1,78 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "TextInputWindow.h"
-#include "StackLayout.h"
-
-namespace Crown
-{
-
-TextInputWindow::TextInputWindow(WindowsManager* wm, const Str& title, const Str& message, const Str& defaultText, IDelegate2<void, bool, Str>* callback):
-	Window(wm, 300, 300, 250, 70, title), mCallback(callback)
-{
-	StackLayout* layout = new StackLayout(GetContentWidget());
-	layout->SetMargins(2, 2, 2, 2);
-
-	Label* lbl;
-
-	lbl = new Label(layout, message);
-
-	mTextBox = new TextBox(layout, defaultText);
-
-	StackLayout* buttonLayout = new StackLayout(layout);
-	buttonLayout->SetMargins(0, 2, 0, 0);
-	buttonLayout->SetOrientation(SO_HORIZONTAL);
-
-	mOkButton = new Button(buttonLayout, "Ok");
-
-	mCancelButton = new Button(buttonLayout, "Cancel");
-	mCancelButton->SetMargins(2, 0, 0, 0);
-
-	mOkButton->OnClickEvent += CreateDelegate(this, &TextInputWindow::mOkButton_OnClick);
-	mCancelButton->OnClickEvent += CreateDelegate(this, &TextInputWindow::mCancelButton_OnClick);
-}
-
-void TextInputWindow::mOkButton_OnClick(Button* /*obj*/, EventArgs* /*args*/)
-{
-	if (mCallback)
-	{
-		Str text = mTextBox->GetText();
-		mCallback->Invoke(false, text);
-		mCallback->Trash();
-	}
-	Close();
-}
-
-void TextInputWindow::mCancelButton_OnClick(Button* /*obj*/, EventArgs* /*args*/)
-{
-	if (mCallback)
-	{
-		mCallback->Invoke(true, "");
-		mCallback->Trash();
-	}
-	Close();
-}
-
-}

+ 0 - 56
src/windowing/toolbox/TextInputWindow.h

@@ -1,56 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Window.h"
-#include "TextBox.h"
-
-namespace Crown
-{
-
-class TextInputWindow: public Window
-{
-  public:
-		typedef IDelegate2<void, bool, Str> TextInputDelegate;
-
-    TextInputWindow(WindowsManager* wm, const Str& title, const Str& message, const Str& defaultText, IDelegate2<void, bool, Str>* callback);
-
-		void mOkButton_OnClick(Button* obj, EventArgs* args);
-
-		void mCancelButton_OnClick(Button* obj, EventArgs* args);
-
-	virtual Str ToStr() const
-	 { return "TextInputWindow"; }
-
-  private:
-		TextBox* mTextBox;
-		Button* mOkButton;
-		Button* mCancelButton;
-		IDelegate2<void, bool, Str>* mCallback;
-};
-
-}
-