Update Java profile with recent changes
[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 // Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System.Drawing.Imaging;
31 using System.Runtime.InteropServices;
32
33 namespace System.Drawing 
34 {
35         [StructLayout(LayoutKind.Sequential)]
36         internal struct GdiplusStartupInput
37         {
38                         // internalted to silent compiler
39                         internal uint           GdiplusVersion;
40                         internal IntPtr                 DebugEventCallback;
41                         internal int             SuppressBackgroundThread;
42                         internal int            SuppressExternalCodecs;
43     
44                 internal static GdiplusStartupInput MakeGdiplusStartupInput ()
45                 {
46                         GdiplusStartupInput result = new GdiplusStartupInput ();
47                         result.GdiplusVersion = 1;
48                         result.DebugEventCallback = IntPtr.Zero;
49                         result.SuppressBackgroundThread = 0;
50                         result.SuppressExternalCodecs = 0;
51                         return result;
52                 }       
53         }
54     
55         [StructLayout(LayoutKind.Sequential)]
56         internal struct GdiplusStartupOutput
57         {
58                 internal IntPtr         NotificationHook;
59                 internal IntPtr         NotificationUnhook;
60                 
61                 internal static GdiplusStartupOutput MakeGdiplusStartupOutput ()
62                 {
63                         GdiplusStartupOutput result = new GdiplusStartupOutput ();
64                         result.NotificationHook = result.NotificationUnhook = IntPtr.Zero;
65                         return result;
66                 }
67         }
68         
69                 
70         [StructLayout(LayoutKind.Sequential)]
71         internal struct GdiColorPalette
72         {
73                 internal int Flags;             // Palette flags
74                 internal int Count;             // Number of color entries                              
75         }
76         
77         [StructLayout(LayoutKind.Sequential)]
78         internal struct  GdiColorMap 
79         {
80                 internal int from;
81                 internal int to;
82         }
83
84         [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
85         internal struct LOGFONT
86         {
87                 internal int    lfHeight;
88                 internal uint   lfWidth;
89                 internal uint   lfEscapement;
90                 internal uint   lfOrientation;
91                 internal uint   lfWeight;
92                 internal byte   lfItalic;
93                 internal byte   lfUnderline;
94                 internal byte   lfStrikeOut;
95                 internal byte   lfCharSet;
96                 internal byte   lfOutPrecision;
97                 internal byte   lfClipPrecision;
98                 internal byte   lfQuality;
99                 internal byte   lfPitchAndFamily;
100                 [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
101                 internal string lfFaceName;
102         }  
103         
104         [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
105         internal struct GdipImageCodecInfo      /*Size 76 bytes*/
106         {
107                 internal Guid Clsid;                    
108                 internal Guid  FormatID;                
109                 internal IntPtr CodecName;
110                 internal IntPtr DllName;
111                 internal IntPtr FormatDescription;
112                 internal IntPtr FilenameExtension;
113                 internal IntPtr MimeType;
114                 internal ImageCodecFlags Flags;
115                 internal int Version;
116                 internal int SigCount;
117                 internal int SigSize;
118                 IntPtr SigPattern;
119                 IntPtr SigMask;
120                 
121                 internal static void MarshalTo (GdipImageCodecInfo gdipcodec, ImageCodecInfo codec)
122                 {       
123                         codec.CodecName = Marshal.PtrToStringUni (gdipcodec.CodecName);                                                 
124                         codec.DllName = Marshal.PtrToStringUni (gdipcodec.DllName);
125                         codec.FormatDescription = Marshal.PtrToStringUni (gdipcodec.FormatDescription);
126                         codec.FilenameExtension = Marshal.PtrToStringUni (gdipcodec.FilenameExtension);
127                         codec.MimeType = Marshal.PtrToStringUni (gdipcodec.MimeType);
128                         codec.Clsid = gdipcodec.Clsid;
129                         codec.FormatID = gdipcodec.FormatID;                    
130                         codec.Flags = gdipcodec.Flags;
131                         codec.Version = gdipcodec.Version;
132                         codec.SignatureMasks = new byte [gdipcodec.SigCount][];
133                         codec.SignaturePatterns = new byte [gdipcodec.SigCount][];
134                         IntPtr p = gdipcodec.SigPattern;
135                         IntPtr m = gdipcodec.SigMask;
136                         for (int i=0; i < gdipcodec.SigCount; i++) {
137                                 codec.SignatureMasks[i] = new byte [gdipcodec.SigSize];
138                                 Marshal.Copy (m, codec.SignatureMasks[i], 0, gdipcodec.SigSize);
139                                 m = new IntPtr (m.ToInt64 () + gdipcodec.SigSize);
140                                 codec.SignaturePatterns[i] = new byte [gdipcodec.SigSize];
141                                 Marshal.Copy (p, codec.SignaturePatterns[i], 0, gdipcodec.SigSize);
142                                 p = new IntPtr (p.ToInt64 () + gdipcodec.SigSize);
143                         }
144                 }
145         }
146
147         [StructLayout(LayoutKind.Sequential)]
148         internal struct GdipEncoderParameter {
149                 internal Guid guid;
150                 internal uint numberOfValues;
151                 internal EncoderParameterValueType type;
152                 internal IntPtr value;
153         }
154
155         [StructLayout(LayoutKind.Sequential)]
156         internal struct GdipPropertyItem
157         {
158                 internal int id;
159                 internal int len;
160                 internal short type;
161                 internal IntPtr value;
162
163                 internal static void MarshalTo (GdipPropertyItem gdipProp, PropertyItem prop)
164                 {       
165                         prop.Id = gdipProp.id;
166                         prop.Len = gdipProp.len;
167                         prop.Type = gdipProp.type;
168                         prop.Value = new byte [gdipProp.len];                   
169                         Marshal.Copy (gdipProp.value, prop.Value, 0, gdipProp.len);
170                 }
171         }
172
173         [StructLayout(LayoutKind.Sequential)]
174         internal struct IconInfo
175         {
176                 int fIcon;
177                 public int xHotspot;
178                 public int yHotspot;
179                 public IntPtr hbmMask;
180                 public IntPtr hbmColor;
181
182                 public bool IsIcon {
183                         get { return (fIcon == 1); }
184                         set { fIcon = (value) ? 1 : 0; }
185                 }
186         }
187
188         [StructLayout(LayoutKind.Sequential)]
189         internal struct XColor
190         {
191                 public int              pixel;
192                 public ushort           red, green, blue;
193                 public sbyte            flags;
194                 public sbyte            pad;    
195         }
196
197         [StructLayout(LayoutKind.Sequential)]
198         internal struct XVisualInfo
199         {
200                 internal IntPtr visual;
201                 internal int visualid;
202                 internal int screen;
203                 internal uint depth;
204                 internal int klass;
205                 internal uint red_mask;
206                 internal uint green_mask;
207                 internal uint blue_mask;
208                 internal int colormap_size;
209                 internal int bits_per_rgb;              
210         }
211         
212         internal enum GetSysColorIndex {
213                 COLOR_SCROLLBAR                 = 0,
214                 COLOR_BACKGROUND                = 1,
215                 COLOR_ACTIVECAPTION             = 2,
216                 COLOR_INACTIVECAPTION           = 3,
217                 COLOR_MENU                      = 4,
218                 COLOR_WINDOW                    = 5,
219                 COLOR_WINDOWFRAME               = 6,
220                 COLOR_MENUTEXT                  = 7,
221                 COLOR_WINDOWTEXT                = 8,
222                 COLOR_CAPTIONTEXT               = 9,
223                 COLOR_ACTIVEBORDER              = 10,
224                 COLOR_INACTIVEBORDER            = 11,
225                 COLOR_APPWORKSPACE              = 12,
226                 COLOR_HIGHLIGHT                 = 13,
227                 COLOR_HIGHLIGHTTEXT             = 14,
228                 COLOR_BTNFACE                   = 15,
229                 COLOR_BTNSHADOW                 = 16,
230                 COLOR_GRAYTEXT                  = 17,
231                 COLOR_BTNTEXT                   = 18,
232                 COLOR_INACTIVECAPTIONTEXT       = 19,
233                 COLOR_BTNHIGHLIGHT              = 20,
234                 COLOR_3DDKSHADOW                = 21,
235                 COLOR_3DLIGHT                   = 22,
236                 COLOR_INFOTEXT                  = 23,
237                 COLOR_INFOBK                    = 24,
238                         
239                 COLOR_HOTLIGHT                  = 26,
240                 COLOR_GRADIENTACTIVECAPTION     = 27,
241                 COLOR_GRADIENTINACTIVECAPTION   = 28,
242                 COLOR_MENUHIGHLIGHT             = 29,
243                 COLOR_MENUBAR                   = 30,
244
245                 COLOR_DESKTOP                   = 1,
246                 COLOR_3DFACE                    = 16,
247                 COLOR_3DSHADOW                  = 16,
248                 COLOR_3DHIGHLIGHT               = 20,
249                 COLOR_3DHILIGHT                 = 20,
250                 COLOR_BTNHILIGHT                = 20,
251
252                 COLOR_MAXVALUE                  = 30,/* Maximum value */
253         }       
254 }
255