Files
mono/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataObject.cs
T
Chris Toshok 9279f78f95 [ after removing all warning suppressions, this cleans up over 100 warnings. ]
* Win32DnD.cs: comment out some unused fields.

	* XplatUIWin32.cs: comment out some unused pinvokes, and remove
	some unused properties/methods.

	* XplatUIX11.cs: fix MousePosition so we override the base class's
	property instead of conflicting with it.

	* PictureBox.cs: comment out some unused fields

	* OSXStructs.cs: make some struct fields public.

	* XplatUIOSX.cs: comment out some unused pinvokes, and fix
	MousePosition so we override the base class's property instead of
	conflicting with it.

	* X11Dnd.cs: comment out some unused fields

	* X11DesktopColors.cs: fix some struct field visibility to quiet
	the compiler.

	* X11Dnd.cs: remove some debug code.

	* ThemeClearlooks.cs: comment out unused field.

	* ThemeNice.cs: mark some methods as overriding ThemeWin32Classic as needed.

	* ThemeGtk.cs: comment out some unused pinvokes.

	* Timer.cs: remove some unused fields.

	* ThemeClearlooks.cs: comment out unused field.

	* UpDownBase.cs: comment out unused field.

	* DataObject.cs: comment out unused field.

	* DataGridBoolColumn.cs: reomve unused field.

	* DataGrid.cs: remove unused field.

	* Cursor.cs: remove old ToBitmap code.

	* ControlPaint.cs: remove unused method.

	* ScrollBar.cs: remove unused fields.

	* ComboBox.cs: remove unused field, and chain up to
	AccessibleObject ctor.

	* ListBox.cs: remove unused field.

	* ButtonBase.cs: wrap a couple fields in NET_2_0.

	* GridEntry.cs: remove unused fields.

	* Binding.cs: remove unused fields.

	* AxHost.cs: remove unused method.

	* ContainerControl.cs: remove unused field.

	* ScrollableControl.cs: remove unused fields.

2006-12-01  Chris Toshok  <[email protected]>


svn path=/trunk/mcs/; revision=68867
2006-12-01 22:50:43 +00:00

289 lines
6.8 KiB
C#

// 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.
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Peter Bartok ([email protected])
//
//
// COMPLETE
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Windows.Forms {
[ClassInterface(ClassInterfaceType.None)]
public class DataObject : IDataObject {
#region DataObject.Entry Class
private class Entry {
#region Local Variables
private string type;
private object data;
//private bool autoconvert;
internal Entry next;
#endregion // Local Variables
#region Constructors
internal Entry(string type, object data, bool autoconvert) {
this.type = type;
this.data = data;
//this.autoconvert = autoconvert;
}
#endregion // Constructors
#region Properties
public object Data {
get {
return data;
}
set {
data = value;
}
}
#endregion // Properties
#region Methods
public static int Count(Entry entries) {
int result;
result = 0;
while (entries != null) {
result++;
entries = entries.next;
}
return result;
}
public static Entry Find(Entry entries, string type) {
while (entries != null) {
if (entries.type.Equals(type)) {
return entries;
}
entries = entries.next;
}
return null;
}
public static Entry FindConvertible(Entry entries, string type) {
Entry e;
e = Find(entries, type);
if (e != null) {
return e;
}
e = entries;
while (e != null) {
if (type == DataFormats.Text) {
if (e.type == DataFormats.UnicodeText) {
return e;
}
} else if (type == DataFormats.UnicodeText) {
if (e.type == DataFormats.Text) {
return e;
}
} else if (type == DataFormats.StringFormat) {
if (e.type == DataFormats.Text) {
return e;
} else if (e.type == DataFormats.UnicodeText) {
return e;
}
}
e = e.next;
}
return null;
}
public static string[] Entries(Entry entries, bool convertible) {
Entry e;
ArrayList list;
string[] result;
// Initially store into something that we can grow easily
list = new ArrayList(Entry.Count(entries));
e = entries;
while (e != null) {
list.Add(e.type);
e = e.next;
}
if (convertible) {
// Add the convertibles
if ((Entry.Find(entries, DataFormats.Text) != null) && (Entry.Find(entries, DataFormats.UnicodeText) == null)) {
list.Add(DataFormats.UnicodeText);
}
if ((Entry.Find(entries, DataFormats.Text) == null) && (Entry.Find(entries, DataFormats.UnicodeText) != null)) {
list.Add(DataFormats.Text);
}
if (((Entry.Find(entries, DataFormats.Text) != null) || (Entry.Find(entries, DataFormats.UnicodeText) != null)) && (Entry.Find(entries, DataFormats.StringFormat) == null)) {
list.Add(DataFormats.StringFormat);
}
}
// Copy the results into a string array
result = new string[list.Count];
for (int i = 0; i < list.Count; i++) {
result[i] = (string)list[i];
}
return result;
}
#endregion // Methods
}
#endregion // DataObject.Entry class
#region Local Variables
private Entry entries;
#endregion // Local Variables
#region Public Constructors
public DataObject() {
entries = null;
}
public DataObject(object data) {
SetData(data);
}
public DataObject(string format, object data) {
SetData(format, data);
}
#endregion // Public Constructors
#region Public Instance Properties
public virtual object GetData(string format) {
return GetData(format, true);
}
public virtual object GetData(string format, bool autoConvert) {
Entry e;
if (autoConvert) {
e = Entry.FindConvertible(entries, format);
} else {
e = Entry.Find(entries, format);
}
if (e == null)
return null;
return e.Data;
}
public virtual object GetData(Type format) {
return GetData(format.FullName, true);
}
public virtual bool GetDataPresent(string format) {
return GetDataPresent(format, true);
}
public virtual bool GetDataPresent(string format, bool autoConvert) {
if (autoConvert) {
return Entry.FindConvertible(entries, format) != null;
} else {
return Entry.Find(entries, format) != null;
}
}
public virtual bool GetDataPresent(Type format) {
return GetDataPresent(format.FullName, true);
}
public virtual string[] GetFormats() {
return GetFormats(true);
}
public virtual string[] GetFormats(bool autoConvert) {
return Entry.Entries(entries, autoConvert);
}
public virtual void SetData(object data) {
SetData(data.GetType(), data);
}
public virtual void SetData(string format, bool autoConvert, object data) {
Entry entry;
Entry e;
entry = Entry.Find(entries, format);
if (entry == null) {
entry = new DataObject.Entry(format, data, autoConvert);
} else {
entry.Data = data;
return;
}
lock (this) {
if (entries == null) {
entries = entry;
} else {
// Insert into the list of known/defined formats
e = entries;
while (e.next != null) {
e = e.next;
}
e.next = entry;
}
}
}
public virtual void SetData(string format, object data) {
SetData(format, true, data);
}
public virtual void SetData(Type format, object data) {
SetData(EnsureFormat(format), true, data);
}
#endregion // Public Instance Properties
#region Public Instance Methods
#endregion // Public Instance Methods
#region Private Methods
internal string EnsureFormat(string name) {
DataFormats.Format f;
f = DataFormats.Format.Find(name);
if (f == null) {
// Register the format
f = DataFormats.Format.Add(name);
}
return f.Name;
}
internal string EnsureFormat(Type type) {
return EnsureFormat(type.FullName);
}
#endregion // Private Methods
}
}