Преглед изворни кода

Added methods for dealing with clipboard

Marko Pintera пре 12 година
родитељ
комит
ac2ce32f5b

+ 0 - 1
BansheeEngine.sln

@@ -41,7 +41,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
 		CSharpWrap.txt = CSharpWrap.txt
 		Dependencies.txt = Dependencies.txt
 		DrawHelper.txt = DrawHelper.txt
-		DropDown.txt = DropDown.txt
 		EditorWindowDock.txt = EditorWindowDock.txt
 		Notes.txt = Notes.txt
 		RenderOperation.txt = RenderOperation.txt

+ 14 - 0
CamelotCore/Include/Win32/CmPlatformImpl.h

@@ -157,6 +157,20 @@ namespace CamelotFramework
 		 */
 		static void resetNonClientAreas(const RenderWindow& window);
 
+		/**
+		 * @brief	Adds a string to the clipboard.
+		 */
+		static void copyToClipboard(const WString& string);
+
+		/**
+		 * @brief	Reads a string from the clipboard and returns it. If there is no
+		 * 			string in the clipboard it returns an empty string.
+		 * 			
+		 * @note	Both wide and normal strings will be read, but normal strings will be converted to
+		 * 			a wide string before returning.
+		 */
+		static WString copyFromClipboard();
+
 		/**
 		 * @brief	Message pump. Processes OS messages and returns when it's free.
 		 * 			

+ 47 - 0
CamelotCore/Source/Win32/CmPlatformImpl.cpp

@@ -275,6 +275,53 @@ namespace CamelotFramework
 			mNonClientAreas.erase(iterFind);
 	}
 
+	void Platform::copyToClipboard(const WString& string)
+	{
+		HANDLE hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (string.size() + 1) * sizeof(WString::value_type));
+		WString::value_type* buffer = (WString::value_type*)GlobalLock(hData);
+
+		string.copy(buffer, string.size());
+		buffer[string.size()] = '\0';
+
+		GlobalUnlock(hData);
+
+		if(OpenClipboard(NULL))
+		{
+			EmptyClipboard();
+			SetClipboardData(CF_UNICODETEXT, hData);
+			CloseClipboard();
+		}
+		else
+		{
+			GlobalFree(hData);
+		}
+	}
+
+	WString Platform::copyFromClipboard()
+	{
+		if(OpenClipboard(NULL))
+		{
+			HANDLE hData = GetClipboardData(CF_UNICODETEXT);
+
+			if(hData != NULL)
+			{
+				WString::value_type* buffer = (WString::value_type*)GlobalLock(hData);
+				WString string(buffer);
+				GlobalUnlock(hData);
+
+				CloseClipboard();
+				return string;
+			}
+			else
+			{
+				CloseClipboard();
+				return L"";
+			}			
+		}
+
+		return L"";
+	}
+
 	void Platform::messagePump()
 	{
 		MSG  msg;

+ 4 - 0
Notes.txt

@@ -31,6 +31,10 @@ Reminders:
 	    it could be replaced with a variable parameter version of addComponent.
   - Profiling: Create an easy to browse list of all loaded Resources (similar to Hierarchy in Unity, just for loaded resources)
     - Possibly also for all core objects
+  - Attempt to get rid of selective input click callback in GUIManager. It's too specific.
+    - Instead of using selective input I might be able to block all input using event filter (by adding return values to them)
+    - Some kind of GUISelectiveInput class? I think it makes sense to move it out of GUIManager
+  - GUI ignores image in GUIContent for most elements
 
 Potential optimizations:
  - bulkPixelConversion is EXTREMELY poorly unoptimized. Each pixel it calls a separate method that does redudant operations every pixel.