* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Drawing / System.Drawing / gdipStructs.cs
1 //
2 // System.Drawing.gdipStructs.cs
3 //
4 // Author: 
5 // Alexandre Pigolkine (pigolkine@gmx.de)
6 // Jordi Mas (jordi@ximian.com)
7 //
8
9 //
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using System;
33 using System.Runtime.InteropServices;
34 using System.Text;
35 using System.Drawing.Imaging;
36 using System.Drawing;
37
38 namespace System.Drawing 
39 {
40         [StructLayout(LayoutKind.Sequential)]
41         internal struct GdiplusStartupInput
42         {
43                 uint            GdiplusVersion;
44                 IntPtr          DebugEventCallback;
45                 int             SuppressBackgroundThread;
46                 int             SuppressExternalCodecs;
47     
48                 internal static GdiplusStartupInput MakeGdiplusStartupInput ()
49                 {
50                         GdiplusStartupInput result = new GdiplusStartupInput ();
51                         result.GdiplusVersion = 1;
52                         result.DebugEventCallback = IntPtr.Zero;
53                         result.SuppressBackgroundThread = 0;
54                         result.SuppressExternalCodecs = 0;
55                         return result;
56                 }       
57         }
58     
59         [StructLayout(LayoutKind.Sequential)]
60         internal struct GdiplusStartupOutput
61         {
62                 internal IntPtr         NotificationHook;
63                 internal IntPtr         NotificationUnhook;
64                 
65                 internal static GdiplusStartupOutput MakeGdiplusStartupOutput ()
66                 {
67                         GdiplusStartupOutput result = new GdiplusStartupOutput ();
68                         result.NotificationHook = result.NotificationUnhook = IntPtr.Zero;
69                         return result;
70                 }
71         }
72         
73                 
74         [StructLayout(LayoutKind.Sequential)]
75         internal struct GdiColorPalette
76         {
77                 internal int Flags;             // Palette flags
78                 internal int Count;             // Number of color entries                              
79         }
80         
81         [StructLayout(LayoutKind.Sequential)]
82         internal struct  GdiColorMap 
83         {
84                 internal int from;
85                 internal int to;
86         }
87
88         [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
89         internal struct LOGFONT
90         {
91                 internal int    lfHeight;
92                 internal uint   lfWidth;
93                 internal uint   lfEscapement;
94                 internal uint   lfOrientation;
95                 internal uint   lfWeight;
96                 internal byte   lfItalic;
97                 internal byte   lfUnderline;
98                 internal byte   lfStrikeOut;
99                 internal byte   lfCharSet;
100                 internal byte   lfOutPrecision;
101                 internal byte   lfClipPrecision;
102                 internal byte   lfQuality;
103                 internal byte   lfPitchAndFamily;
104                 [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
105                 internal string lfFaceName;
106         }  
107         
108         [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
109         internal struct GdipImageCodecInfo      /*Size 76 bytes*/
110         {
111                 internal Guid Clsid;                    
112                 internal Guid  FormatID;                
113                 internal IntPtr CodecName;
114                 internal IntPtr DllName;
115                 internal IntPtr FormatDescription;
116                 internal IntPtr FilenameExtension;
117                 internal IntPtr MimeType;
118                 internal ImageCodecFlags Flags;
119                 internal int Version;
120                 internal int SigCount;
121                 internal int SigSize;
122                 IntPtr SigPattern;
123                 IntPtr SigMask;
124                 
125                 internal static void MarshalTo (GdipImageCodecInfo gdipcodec, ImageCodecInfo codec)
126                 {       
127                         codec.CodecName = Marshal.PtrToStringUni (gdipcodec.CodecName);                                                 
128                         codec.DllName = Marshal.PtrToStringUni (gdipcodec.DllName);
129                         codec.FormatDescription = Marshal.PtrToStringUni (gdipcodec.FormatDescription);
130                         codec.FilenameExtension = Marshal.PtrToStringUni (gdipcodec.FilenameExtension);
131                         codec.MimeType = Marshal.PtrToStringUni (gdipcodec.MimeType);
132                         codec.Clsid = gdipcodec.Clsid;
133                         codec.FormatID = gdipcodec.FormatID;                    
134                         codec.Flags = gdipcodec.Flags;
135                         codec.Version  = gdipcodec.Version;                                     
136                 }
137         }
138
139         [StructLayout(LayoutKind.Sequential)]
140         internal struct GdipEncoderParameter {
141                 internal Guid guid;
142                 internal uint numberOfValues;
143                 internal EncoderParameterValueType type;
144                 internal IntPtr value;
145         }
146
147         [StructLayout(LayoutKind.Sequential)]
148         internal struct GdipPropertyItem
149         {
150                 internal int id;
151                 internal int len;
152                 internal short type;
153                 internal IntPtr value;
154
155                 internal static void MarshalTo (GdipPropertyItem gdipProp, PropertyItem prop)
156                 {       
157                         prop.Id = gdipProp.id;
158                         prop.Len = gdipProp.len;
159                         prop.Type = gdipProp.type;
160                         prop.Value = new byte [gdipProp.len];                   
161                         Marshal.Copy (gdipProp.value, prop.Value, 0, gdipProp.len);
162                 }
163         }
164
165         [StructLayout(LayoutKind.Sequential)]
166         internal struct IconInfo
167         {
168                 int fIcon;
169                 public int xHotspot;
170                 public int yHotspot;
171                 IntPtr hbmMask;
172                 IntPtr hbmColor;
173
174                 public bool IsIcon {
175                         get {
176                                 return fIcon == 1;
177                         }
178                 }
179         }
180
181         [StructLayout(LayoutKind.Sequential)]
182         internal struct XColor
183         {
184                 public int              pixel;
185                 public ushort           red, green, blue;
186                 public sbyte            flags;
187                 public sbyte            pad;    
188         }
189
190         [StructLayout(LayoutKind.Sequential)]
191         internal struct XVisualInfo
192         {
193                 internal IntPtr visual;
194                 internal int visualid;
195                 internal int screen;
196                 internal uint depth;
197                 internal int klass;
198                 internal uint red_mask;
199                 internal uint green_mask;
200                 internal uint blue_mask;
201                 internal int colormap_size;
202                 internal int bits_per_rgb;              
203         }
204         
205 }
206