File: UXTheme.cs

package info (click to toggle)
mono 5.18.0.240%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,253,216 kB
  • sloc: cs: 10,925,936; xml: 2,804,987; ansic: 643,970; cpp: 120,384; perl: 59,272; asm: 21,383; sh: 20,162; makefile: 18,157; python: 4,715; pascal: 924; sql: 859; sed: 16; php: 1
file content (215 lines) | stat: -rw-r--r-- 11,160 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//
// UXTheme.cs
// - Internal class for P/Invokes to uxtheme.dll
//
// 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) 2006 Novell, Inc.
//
// Authors:
//	Jonathan Pobst (monkey@jpobst.com)
//

using System.Runtime.InteropServices;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace System.Windows.Forms.VisualStyles
{
	internal class UXTheme
	{
		#region DllImports
		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 CloseThemeData (IntPtr hTheme);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeBackground (IntPtr hTheme, IntPtr hdc, int iPartId,
		   int iStateId, ref XplatUIWin32.RECT pRect, ref XplatUIWin32.RECT pClipRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeBackground (IntPtr hTheme, IntPtr hdc, int iPartId,
		   int iStateId, ref XplatUIWin32.RECT pRect, IntPtr pClipRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeEdge (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pDestRect, uint egde, uint flags, out XplatUIWin32.RECT pRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeEdge (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pDestRect, uint edge, uint flags, int pRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeIcon (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pRect, IntPtr himl, int iImageIndex);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeParentBackground (IntPtr hWnd, IntPtr hdc, ref XplatUIWin32.RECT pRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeParentBackground (IntPtr hWnd, IntPtr hdc, int pRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 DrawThemeText (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, UInt32 textFlags, UInt32 textFlags2, ref XplatUIWin32.RECT pRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 EnableTheming (int fEnable);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public static extern IntPtr OpenThemeData (IntPtr hWnd, String classList);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeBackgroundContentRect (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pBoundingRect, out XplatUIWin32.RECT pContentRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeBackgroundExtent (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pRect, ref XplatUIWin32.RECT pClipRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeBackgroundRegion (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pRect, out IntPtr pRegion);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeBool (IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int pfVal);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeColor (IntPtr hTheme, int iPartId, int iStateId, int iPropId, out Int32 pColor);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeEnumValue (IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeFilename (IntPtr hTheme, int iPartId, int iStateId, int iPropId, [MarshalAs (UnmanagedType.LPWStr)] Text.StringBuilder themeFileName, int themeFileNameLength);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeFont (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, [MarshalAs (UnmanagedType.LPStruct)] out LOGFONT lf);

		[DllImport ("gdi32", CharSet = CharSet.Auto)]
		public static extern IntPtr CreateFontIndirect ([In, MarshalAs (UnmanagedType.LPStruct)] LOGFONT lplf);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeInt (IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeMargins (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, out XplatUIWin32.RECT prc, out MARGINS pMargins);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemePartSize (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref XplatUIWin32.RECT pRect, int eSize, out SIZE size);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemePartSize (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, IntPtr pRect, int eSize, out SIZE size);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemePosition (IntPtr hTheme, int iPartId, int iStateId, int iPropId, out POINT pPoint);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeString (IntPtr hTheme, int iPartId, int iStateId, int iPropId, [MarshalAs (UnmanagedType.LPWStr)] Text.StringBuilder themeString, int themeStringLength);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeTextExtent (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, int textFlags, ref XplatUIWin32.RECT boundingRect, out XplatUIWin32.RECT extentRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeTextExtent (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, int textFlags, int boundingRect, out XplatUIWin32.RECT extentRect);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeTextMetrics (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, out XplatUIWin32.TEXTMETRIC textMetric);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 HitTestThemeBackground (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, UInt32 dwOptions, ref XplatUIWin32.RECT pRect, IntPtr hrgn, POINT ptTest, out HitTestCode code);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static int IsThemeBackgroundPartiallyTransparent (IntPtr hTheme, int iPartId, int iStateId);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static bool IsThemePartDefined (IntPtr hTheme, int iPartId, int iStateId);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static bool IsThemeActive ();

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static bool IsAppThemed ();

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 HitTestThemeBackground (IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, UInt32 dwOptions, ref XplatUIWin32.RECT pRect, IntPtr hrgn, POINT ptTest, out int code);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeDocumentationProperty (String stringThemeName, String stringPropertyName, StringBuilder stringValue, int lengthValue);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetCurrentThemeName (StringBuilder stringThemeName, int lengthThemeName, StringBuilder stringColorName, int lengthColorName, StringBuilder stringSizeName, int lengthSizeName);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static UInt32 GetThemeSysColor (IntPtr hTheme, int iColorId);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static Int32 GetThemeSysInt (IntPtr hTheme, int iIntId, out int piVal);

		[DllImport ("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
		public extern static int GetThemeSysBool (IntPtr hTheme, int iBoolId);
		#endregion

		#region LOGFONT Type
		[StructLayout (LayoutKind.Sequential, CharSet = CharSet.Auto)]
		public class LOGFONT
		{
			public int lfHeight = 0;
			public int lfWidth = 0;
			public int lfEscapement = 0;
			public int lfOrientation = 0;
			public int lfWeight = 0;
			public byte lfItalic = 0;
			public byte lfUnderline = 0;
			public byte lfStrikeOut = 0;
			public byte lfCharSet = 0;
			public byte lfOutPrecision = 0;
			public byte lfClipPrecision = 0;
			public byte lfQuality = 0;
			public byte lfPitchAndFamily = 0;
			[MarshalAs (UnmanagedType.ByValTStr, SizeConst = 32)]
			public string lfFaceName = string.Empty;
		}
		#endregion

		#region MARGINS Type
		[StructLayout (LayoutKind.Sequential)]
		public struct MARGINS
		{
			public int leftWidth;
			public int rightWidth;
			public int topHeight;
			public int bottomHeight;

			public Padding ToPadding ()
			{
				return new Padding (leftWidth, topHeight, rightWidth, bottomHeight);
			}
		}
		#endregion
		
		#region SIZE Type
		[StructLayout (LayoutKind.Sequential)]
		public struct SIZE
		{
			public int cx;
			public int cy;

			public Size ToSize ()
			{
				return new Size (cx, cy);
			}
		}
		#endregion
	}
}