summaryrefslogtreecommitdiff
path: root/src/corelib/gdi
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-29 11:54:28 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-29 11:54:28 +0200
commit206f0498c7b78638535af6536c9468a8a63d6b30 (patch)
tree380731c57348c4bdcd79e997c1606bba7fb942b9 /src/corelib/gdi
parent94a597e80e106ee15e1b924068c8caaeaa9a9fa5 (diff)
downloadfpGUI-206f0498c7b78638535af6536c9468a8a63d6b30.tar.xz
Slight improvement to the WindowsClipboardLookup method.
* Introduced a new parameter to know if we translated the mime type to a known Windows CF_ clipboard type. * Fixed the spelling mistake in the function name
Diffstat (limited to 'src/corelib/gdi')
-rw-r--r--src/corelib/gdi/fpg_gdi.pas3
-rw-r--r--src/corelib/gdi/fpg_oledragdrop.pas25
2 files changed, 21 insertions, 7 deletions
diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas
index 14422af3..bda2be25 100644
--- a/src/corelib/gdi/fpg_gdi.pas
+++ b/src/corelib/gdi/fpg_gdi.pas
@@ -1443,6 +1443,7 @@ var
data: pchar;
wg: TfpgWidget;
CF: DWORD;
+ lIsTranslated: Boolean;
begin
if not FUserAcceptDrag then
exit;
@@ -1453,7 +1454,7 @@ begin
wg := self as TfpgWidget;
{ construct a FORMATETC object }
- CF := WindowsClipboardLoopup(FUserMimeSelection);
+ CF := WindowsClipboardLookup(FUserMimeSelection, lIsTranslated);
FE := GetFormatEtc(CF);
if DataObj.QueryGetData(FE) = S_OK then
diff --git a/src/corelib/gdi/fpg_oledragdrop.pas b/src/corelib/gdi/fpg_oledragdrop.pas
index 2a3cefa9..6c7dc4e9 100644
--- a/src/corelib/gdi/fpg_oledragdrop.pas
+++ b/src/corelib/gdi/fpg_oledragdrop.pas
@@ -191,7 +191,7 @@ type
function WindowsMimeLookup(const CFFormat: string): string;
-function WindowsClipboardLoopup(const AMime: string): DWORD;
+function WindowsClipboardLookup(const AMime: string; var IsTranslated: Boolean): DWORD;
function EnumDataToStringList(DataObj: IDataObject): TStringList;
function GetFormatEtc(const CFFormat: DWORD): FORMATETC;
@@ -223,13 +223,26 @@ begin
Result := CFFormat;
end;
-function WindowsClipboardLoopup(const AMime: string): DWORD;
+function WindowsClipboardLookup(const AMime: string; var IsTranslated: Boolean): DWORD;
begin
- { TODO: We need to implement this correctly }
- if AMime = 'text/plain' then
- Result := CF_TEXT
- else
+ { TODO: We need to improve this implementation }
+ if AMime = 'text/html' then
+ begin
+ { We don't want duplicate CF_TEXT in DataObject, so register some of our
+ known convenience types (from TfpgMimeData) as-is }
+ IsTranslated := False;
+ Result := RegisterClipboardFormat('text/html');
+ end
+ else if Pos('text/', AMime) = 1 then
+ begin
+ IsTranslated := True;
Result := CF_TEXT; // fallback result
+ end
+ else
+ begin
+ IsTranslated := False;
+ Result := RegisterClipboardFormat(PChar(AMime));
+ end;
end;
function WindowsClipboardFormatToString(const CFFormat: integer): string;