summaryrefslogtreecommitdiff
path: root/Runtime/Export/GUIStyleBindings.txt
blob: 76ac5500bb80583d3df0742f02c0f5b88afda72c (plain)
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
C++RAW

#include "UnityPrefix.h"
#include "Runtime/IMGUI/GUIStyle.h"
#include "Runtime/IMGUI/GUIContent.h"
#include "Runtime/IMGUI/GUIState.h"
#include "Runtime/IMGUI/GUIManager.h"
#include "Runtime/Mono/MonoBehaviour.h"
#include "Runtime/Filters/Misc/Font.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "Runtime/Scripting/Scripting.h"
#include "Runtime/Scripting/ScriptingObjectWithIntPtrField.h"

#if UNITY_EDITOR
//#include "Editor/Src/EditorHelper.h"
//#include "Editor/Mono/MonoEditorUtility.h"
//#include "Editor/Src/OptimizedGUIBlock.h"
//#include "Editor/Src/AssetPipeline/AssetDatabase.h"

//#include "Editor/Src/EditorResources.h"
#endif

using namespace Unity;
using namespace std;

CSRAW
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Collections;
using UnityEngineInternal;

namespace UnityEngine
{



// Specialized values for the given states used by [[GUIStyle]] objects.
CSRAW #if !UNITY_WINRT
CSRAW [StructLayout (LayoutKind.Sequential)]
CSRAW #endif
CSRAW [System.Serializable]
CLASS GUIStyleState
	// Pointer to the GUIStyleState INSIDE a GUIStyle.
	CSRAW [System.NonSerialized] [NotRenamed]
	CSRAW internal IntPtr m_Ptr;
	
	// Pointer to the source GUIStyle so it doesn't get garbage collected.
	// If NULL, it means we own m_Ptr and need to delete it when this gets displosed
	CSRAW GUIStyle m_SourceStyle;

	// Pointer to the texture that is referenced from the GUIStyleState.
	// Necessary for the Asset Garbage Collector to find the texture reference
CSRAW #pragma warning disable 414
	[System.NonSerialized]
	CSRAW private Texture2D m_Background;
CSRAW #pragma warning restore 414
	
	public GUIStyleState ()
	{
		Init ();
	}
	
	internal GUIStyleState (GUIStyle sourceStyle, IntPtr source)
	{
		m_SourceStyle = sourceStyle;
		m_Ptr = source;
		RefreshAssetReference();
	}
	
	internal void RefreshAssetReference ()
	{
		m_Background = GetBackgroundInternal();
	}
	
	~GUIStyleState () 
	{
		if (m_SourceStyle == null)
			Cleanup ();
	}

	THREAD_SAFE
	CUSTOM private void Init () {
		self.SetPtr(new GUIStyleState());
		
	}
	
	THREAD_SAFE
	CUSTOM private void Cleanup () {
		delete self.GetPtr();
	}
	
	// The background image used by GUI elements in this given state.
	CUSTOM private void SetBackgroundInternal (Texture2D value) {
		self->background = (Texture2D*) (value);
	}

	CUSTOM private Texture2D GetBackgroundInternal () {
		return Scripting::ScriptingWrapperFor (self->background);
	}

	CSRAW public Texture2D background { 
		get { return GetBackgroundInternal(); }
		set { SetBackgroundInternal (value); m_Background = value; }
	}

	// The text color used by GUI elements in this state.
	CUSTOM_PROP Color textColor  { return self->textColor; }  { self->textColor = value; }	
END


// Offsets for rectangles, borders, etc.
CSRAW #if !UNITY_WINRT
CSRAW [StructLayout (LayoutKind.Sequential)]
CSRAW #endif
CSRAW [System.Serializable]
CLASS RectOffset
	
	// Pointer to the RectOffset INSIDE a GUIStyle.
	CSRAW [System.NonSerialized] [NotRenamed]
	CSRAW internal IntPtr m_Ptr;
	
	// Pointer to the source GUIStyle so it doesn't get garbage collected.
	// If NULL, it means we own m_Ptr and need to delete it when this gets displosed
	CSRAW GUIStyle m_SourceStyle;

	/// *listonly* 
	CSRAW public RectOffset () {
		Init ();
	}

	internal RectOffset (GUIStyle sourceStyle, IntPtr source)
	{
		m_SourceStyle = sourceStyle;
		m_Ptr = source;
	}
	
	~RectOffset () 
	{
		if (m_SourceStyle == null)
			Cleanup ();
	}

	THREAD_SAFE
	CUSTOM private void Init () {
		self.SetPtr(new RectOffset());
	}
	
	THREAD_SAFE
	CUSTOM private void Cleanup () {
		delete self.GetPtr();
	}

	
	// Creates a new rectangle with offsets.
	CSRAW public RectOffset (int left, int right, int top, int bottom) {
		Init ();
		this.left = left;
		this.right = right;
		this.top = top;
		this.bottom = bottom;
	} 

	// Left edge size.
	CUSTOM_PROP int left { return self->left; }  { self->left = value; }
	// Right edge size.
	CUSTOM_PROP int right { return self->right; }  { self->right = value; }
	// Top edge size.
	CUSTOM_PROP int top { return self->top; }  { self->top = value; }
	// Bottom edge size.
	CUSTOM_PROP int bottom { return self->bottom; }  { self->bottom = value; }
	// shortcut for left + right (RO)
	CUSTOM_PROP int horizontal { return self->left + self->right; } 
	// shortcut for top + bottom (RO)
	CUSTOM_PROP public int vertical { return self->top + self->bottom; } 
	// Add the border offsets to a /rect/.
	CUSTOM public Rect Add (Rect rect)	
		{ return Rectf (rect.x - self->left, rect.y - self->top, rect.width + self->left + self->right, rect.height + self->top + self->bottom); }
	// Remove the border offsets from a /rect/.
	CUSTOM public Rect Remove (Rect rect) 
		{ return Rectf (rect.x + self->left, rect.y + self->top, rect.width - self->left - self->right, rect.height - self->top - self->bottom); }
	
	CSRAW public override string ToString () {
		return UnityString.Format ("RectOffset (l:{0} r:{1} t:{2} b:{3})", left, right, top, bottom);
	}	

END

// Font Style applied to GUI Texts, Text Meshes or GUIStyles.
ENUM FontStyle
	// No special style is applied.
	Normal = 0,

	// Bold style applied to your texts.
	Bold = 1,

	// Italic style applied to your texts.
	Italic = 2,

	// Bold and Italic styles applied to your texts.
	BoldAndItalic = 3,
END

C++RAW

// Simple struct that contains all the arguments needed by Internal_Draw.
STRUCT internal Internal_DrawArguments
	CSRAW public IntPtr target;
	CSRAW public Rect position;
	CSRAW public int isHover;
	CSRAW public int isActive;
	CSRAW public int on;
	CSRAW public int hasKeyboardFocus;
END

C++RAW

struct MonoInternal_DrawArguments {
	void* target;
	const Rectf position;
	int isHover;
	int isActive;
	int on;
	int hasKeyboardFocus;
};

// Simple struct that contains all the arguments needed by Internal_DrawWithTextSelection.
STRUCT internal Internal_DrawWithTextSelectionArguments
	CSRAW public IntPtr target;
	CSRAW public Rect position;
	CSRAW public int firstPos;
	CSRAW public int lastPos;
	CSRAW public Color cursorColor;
	CSRAW public Color selectionColor;
	CSRAW public int isHover;
	CSRAW public int isActive;
	CSRAW public int on;
	CSRAW public int hasKeyboardFocus;
	CSRAW public int drawSelectionAsComposition;

END

C++RAW

struct MonoInternal_DrawWithTextSelectionArguments {
	void* target;
	Rectf position;
	int firstPos;
	int lastPos;
	const ColorRGBAf cursorColor;
	const ColorRGBAf selectionColor;
	int isHover;
	int isActive;
	int on;
	int hasKeyboardFocus;
	int drawSelectionAsComposition;
};

// How image and text is placed inside [[GUIStyle]].
ENUM ImagePosition
	// Image is to the left of the text.
	ImageLeft = 0,
	// Image is above the text.
	ImageAbove = 1,
	// Only the image is displayed.
	ImageOnly = 2,
	// Only the text is displayed.
	TextOnly = 3
END


BEGIN DOC
Style settings for a GUI element.
This class contains all information for how a gui element should be rendered. It contains information for font, icon placement, background images, and spacing. 
It does /not/ contain information for what it contains - just defines how any text rendered with this style should be displayed. 
It does /not/ define what interactions can occur with the element, but defines the display settings commonly used in by the interactions.

The settings of a [[GUIStyle]]. It is modelled after a CSS Style. It contains settings for the following items:
<dl>
<dt>Background images</dt>
<dd>	These are rendered behind the contents. Different images can be assigned for normal display, when the user hovers the mouse over the element, 
		when the user presses it down - as well as alternatives for when the element has been turned on - like toggle butons do. Below, these are referred to as style /states/.
		SA: ::ref::normal, ::ref::hover, ::ref::active, ::ref::onNormal, ::ref::onHover, ::ref::onActive - these contain the background image & text color properties for each state.</dd>
<dt>Text rendering</dt>
<dd>	The style can define a font for text rendering, as well as alignment, wordwrap and clipping settings. It also defines colors for the text in the various states of the style element
		SA: ::ref::font, ::ref::alignment, ::ref::wordWrap, ::ref::normal, ::ref::hover, ::ref::active, ::ref::onHover, ::ref::onActive</dd>
<dt>Icon Placement</dt>
<dd>	GUIStyles can be rendered with either text, and icon or both. The GUIStyle defines where these two are rendered in relation to each other (or can force it to only display one of them).
		SA: ::ref::imagePosition</dd>
<dt>Sizing and Spacing Options</dd>
<dd>	GUIStyles contain padding, margins and borders. These corresponds loosely to the similar named CSS properties. A GUIStyle can optionally define a fixed width and height.
		SA: ::ref::margin, ::ref::padding, ::ref::border, ::ref::fixedWidth, ::ref::fixedHeight</dd>
</dl>


END DOC

C++RAW
 static void CleanupGUIStyle(void* guiStyle){ delete ((GUIStyle*)guiStyle); }
CSRAW #if !UNITY_WINRT
CSRAW [StructLayout (LayoutKind.Sequential)]
CSRAW #endif
CSRAW [System.Serializable]
CLASS GUIStyle
	
CSRAW
	// Constructor for empty GUIStyle.
	public GUIStyle () {
		Init ();
	}
	
	// Constructs GUIStyle identical to given other GUIStyle.
	public GUIStyle (GUIStyle other) {
		InitCopy (other);
	}
	
	~GUIStyle () {
		Cleanup ();
	}

	internal void CreateObjectReferences () {
		m_FontInternal = GetFontInternal();
		normal.RefreshAssetReference ();
		hover.RefreshAssetReference ();
		active.RefreshAssetReference ();
		focused.RefreshAssetReference ();
		onNormal.RefreshAssetReference ();
		onHover.RefreshAssetReference ();
		onActive.RefreshAssetReference ();
		onFocused.RefreshAssetReference ();
	}

	[System.NonSerialized] [NotRenamed]
	internal IntPtr m_Ptr;
	
	[System.NonSerialized]
	GUIStyleState m_Normal, m_Hover, m_Active, m_Focused, m_OnNormal, m_OnHover, m_OnActive, m_OnFocused;
	
	[System.NonSerialized]
	RectOffset m_Border, m_Padding, m_Margin, m_Overflow;
	
CSRAW #pragma warning disable 414
	[System.NonSerialized]
	private Font m_FontInternal;
CSRAW #pragma warning restore 414

	THREAD_SAFE
	CUSTOM private void Init () {
		self.SetPtr(new GUIStyle(), CleanupGUIStyle);
	}

	THREAD_SAFE
	CUSTOM private void InitCopy (GUIStyle other) {
		self.SetPtr(new GUIStyle (*other), CleanupGUIStyle);
	}
	
	THREAD_SAFE
	CUSTOM private void Cleanup () {
		CleanupGUIStyle(self.GetPtr());
	}

	// The name of this GUIStyle. Used for getting them based on name.... 
	CUSTOM_PROP string name 
		{ 
			return scripting_string_new(self->m_Name); 
		}
		{ self->m_Name = value.AsUTF8(); }

	// Rendering settings for when the component is displayed normally.
	CSRAW public GUIStyleState normal { get { 
			if (m_Normal == null) 
				m_Normal = new GUIStyleState (this, GetStyleStatePtr (0));
			return m_Normal;
		}
		set { AssignStyleState (0, value.m_Ptr); } 
	}

	// Rendering settings for when the mouse is hovering over the control
	CSRAW public GUIStyleState hover { get { 
			if (m_Hover == null) 
				m_Hover = new GUIStyleState (this, GetStyleStatePtr (1));
			return m_Hover;
		}
		set { AssignStyleState (1, value.m_Ptr); } 
	}

	// Rendering settings for when the control is pressed down.
	CSRAW public GUIStyleState active { get { 
			if (m_Active == null) 
				m_Active = new GUIStyleState (this, GetStyleStatePtr (2));
			return m_Active;
		}
		set { AssignStyleState (2, value.m_Ptr); } 
	}
	
	// Rendering settings for when the control is turned on.
	CSRAW public GUIStyleState onNormal { get { 
			if (m_OnNormal == null) 
				m_OnNormal = new GUIStyleState (this, GetStyleStatePtr (4));
			return m_OnNormal;
		}
		set { AssignStyleState (4, value.m_Ptr); } 
	}
	
	// Rendering settings for when the control is turned on and the mouse is hovering it.
	CSRAW public GUIStyleState onHover { get { 
			if (m_OnHover == null) 
				m_OnHover = new GUIStyleState (this, GetStyleStatePtr (5));
			return m_OnHover;
		}
		set { AssignStyleState (5, value.m_Ptr); } 
	}
	
	// Rendering settings for when the element is turned on and pressed down.
	CSRAW public GUIStyleState onActive { get { 
			if (m_OnActive == null) 
				m_OnActive = new GUIStyleState (this, GetStyleStatePtr (6));
			return m_OnActive;
		}
		set { AssignStyleState (6, value.m_Ptr); } 
	}
	
	// Rendering settings for when the element has keyboard focus.
	CSRAW public GUIStyleState focused { get { 
			if (m_Focused == null) 
				m_Focused = new GUIStyleState (this, GetStyleStatePtr (3));
			return m_Focused;
		}
		set { AssignStyleState (3, value.m_Ptr); } 
	}
	
	// Rendering settings for when the element has keyboard and is turned on.
	CSRAW public GUIStyleState onFocused { get { 
			if (m_OnFocused == null) 
				m_OnFocused = new GUIStyleState (this, GetStyleStatePtr (7));
			return m_OnFocused;
		}
		set { AssignStyleState (7, value.m_Ptr); } 
	}
	
	CUSTOM private IntPtr GetStyleStatePtr (int idx)
	{
		GUIStyleState* gss = &(self->m_Normal);
		return gss+idx;
	}
	
	CUSTOM private void AssignStyleState (int idx, IntPtr srcStyleState)
	{ 
		GUIStyleState* gss = &(self->m_Normal);
		gss += idx;
		*gss = *((GUIStyleState*)srcStyleState);
	}


	// RECT OFFSETS
	// ================================================================================================================================================


	// The borders of all background images.
	CSRAW public RectOffset border { get { 
			if (m_Border == null) 
				m_Border = new RectOffset (this, GetRectOffsetPtr (0));
			return m_Border;
		}
		set { AssignRectOffset (0, value.m_Ptr); } 
	}

	// The margins between elements rendered in this style and any other GUI elements
	CSRAW public RectOffset margin { get { 
			if (m_Margin == null) 
				m_Margin = new RectOffset (this, GetRectOffsetPtr (1));
			return m_Margin;
		}
		set { AssignRectOffset (1, value.m_Ptr); } 
	}
	
	// Space from the edge of [[GUIStyle]] to the start of the contents.
	CSRAW public RectOffset padding { get { 
			if (m_Padding == null) 
				m_Padding = new RectOffset (this, GetRectOffsetPtr (2));
			return m_Padding;
		}
		set { AssignRectOffset (2, value.m_Ptr); } 
	}
	
	// Extra space to be added to the background image.
	CSRAW public RectOffset overflow { get { 
			if (m_Overflow == null) 
				m_Overflow = new RectOffset (this, GetRectOffsetPtr (3));
			return m_Overflow;
		}
		set { AssignRectOffset (3, value.m_Ptr); } 
	}

	CUSTOM private IntPtr GetRectOffsetPtr (int idx)
	{
		RectOffset* ro = &(self->m_Border);
		return ro+idx;
	}
	
	CUSTOM private void AssignRectOffset (int idx, IntPtr srcRectOffset)
	{ 
		RectOffset* ro = &(self->m_Border);
		ro += idx;
		*ro = *((RectOffset*)srcRectOffset);
	}


	// How image and text of the [[GUIContent]] is combined.
	CUSTOM_PROP ImagePosition imagePosition
		{ return self->m_ImagePosition; }
		{ self->m_ImagePosition = value; }

	// Text alignment.
	CUSTOM_PROP TextAnchor alignment 
		{ return self->m_Alignment; }
		{ self->m_Alignment = value; }

	// Word wrap the text?
	CUSTOM_PROP bool wordWrap { return self->m_WordWrap; }  { self->m_WordWrap = value; }

	// What to do when the contents to be rendered is too large to fit within the area given.
	CUSTOM_PROP TextClipping clipping { return self->m_Clipping; }  { self->m_Clipping = value; }

	// Pixel offset to apply to the content of this GUIstyle
	CUSTOM_PROP Vector2 contentOffset { return self->m_ContentOffset; }  { self->m_ContentOffset = value; }
	
	// *undocumented* Clip offset to apply to the content of this GUIstyle
	OBSOLETE warning Don't use clipOffset - put things inside begingroup instead. This functionality will be removed in a later version.
	CSRAW public Vector2 clipOffset { get { return Internal_clipOffset; }   set {Internal_clipOffset = value; } }
	
	CUSTOM_PROP internal Vector2 Internal_clipOffset  { return self->m_ClipOffset; }  { self->m_ClipOffset = value; }

	// If non-0, any GUI elements rendered with this style will have the width specified here.
	CUSTOM_PROP float fixedWidth { return self->m_FixedWidth; } { self->m_FixedWidth = value; }

	// If non-0, any GUI elements rendered with this style will have the height specified here.
	CUSTOM_PROP float fixedHeight { return self->m_FixedHeight; } { self->m_FixedHeight = value; }

	// Can GUI elements of this style be stretched horizontally for better layouting?
	CUSTOM_PROP bool stretchWidth { return self->m_StretchWidth; } { self->m_StretchWidth = value; }

	// Can GUI elements of this style be stretched vertically for better layouting?
	CUSTOM_PROP bool stretchHeight { return self->m_StretchHeight; } { self->m_StretchHeight = value; }

	CUSTOM private static float Internal_GetLineHeight (IntPtr target) {
		GUIStyle *cache = reinterpret_cast<GUIStyle*> (target);
		return cache->GetLineHeight ();
	}

	CUSTOM private void SetFontInternal (Font value) {
		self->m_Font = (Font*) (value);
	}

	CUSTOM private Font GetFontInternal () {
		return Scripting::ScriptingWrapperFor (self->m_Font);
	}

	// The font to use for rendering. If null, the default font for the current [[GUISkin]] is used instead.
	CSRAW public Font font { 
		get { return GetFontInternal(); }
		set { SetFontInternal(value); m_FontInternal = value; }
	}

	// The font size to use (for dynamic fonts)
	CUSTOM_PROP int fontSize { return self->m_FontSize; } { self->m_FontSize = value; }

	// The font style to use (for dynamic fonts)
	CUSTOM_PROP FontStyle fontStyle { return self->m_FontStyle; } { self->m_FontStyle = value; }

	// Enable HTML-style tags for Text Formatting Markup. 
	CUSTOM_PROP bool richText { return self->m_RichText; } { self->m_RichText = value; }
	
	// The height of one line of text with this style, measured in pixels. (RO)
	CSRAW public float lineHeight { get { return Mathf.Round (Internal_GetLineHeight (m_Ptr)); } }

					
	// Draw this GUIStyle on to the screen.
	CSRAW private static void Internal_Draw (IntPtr target, Rect position, GUIContent content, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) {
		Internal_DrawArguments arguments = new Internal_DrawArguments ();
		arguments.target = target;
		arguments.position = position;
		arguments.isHover = isHover ? 1 : 0;
		arguments.isActive = isActive ? 1 : 0;
		arguments.on = on ? 1 : 0;
		arguments.hasKeyboardFocus = hasKeyboardFocus ? 1 : 0;
		Internal_Draw (content, ref arguments);
	}

	// Draw this GUIStyle on to the screen, internal version
	CUSTOM private static void Internal_Draw (GUIContent content, ref Internal_DrawArguments arguments) {
		reinterpret_cast<GUIStyle*> (arguments.target)->Draw (GetGUIState(), arguments.position, MonoGUIContentToTempNative(content), arguments.isHover, arguments.isActive, arguments.on, arguments.hasKeyboardFocus);
	}

	// Draw plain GUIStyle without text nor image.
	CSRAW public void Draw (Rect position, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) { 
		#if UNITY_EDITOR
		if (Event.current.type != EventType.Repaint)
		{
			Debug.LogError("Style.Draw may not be called if it is not a repaint event");
			return;
		}
		#endif
		
		Internal_Draw (m_Ptr, position, GUIContent.none, isHover, isActive, on, hasKeyboardFocus); 
	}
	// Draw the GUIStyle with a text string inside.
	CSRAW public void Draw (Rect position, string text, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) { 
		#if UNITY_EDITOR
		if (Event.current.type != EventType.Repaint)
		{
			Debug.LogError("Style.Draw may not be called if it is not a repaint event");
			return;
		}
		#endif
		
		Internal_Draw (m_Ptr, position, GUIContent.Temp(text), isHover, isActive, on, hasKeyboardFocus); 
	}
	// Draw the GUIStyle with an image inside. If the image is too large to fit within the content area of the style it is scaled down.
	CSRAW public void Draw (Rect position, Texture image, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) { 
		#if UNITY_EDITOR
		if (Event.current.type != EventType.Repaint)
		{
			Debug.LogError("Style.Draw may not be called if it is not a repaint event");
			return;
		}
		#endif
		
		Internal_Draw (m_Ptr, position, GUIContent.Temp(image), isHover, isActive, on, hasKeyboardFocus); 
	}
	// Draw the GUIStyle with text and an image inside. If the image is too large to fit within the content area of the style it is scaled down.
	CSRAW public void Draw (Rect position, GUIContent content, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) {
		#if UNITY_EDITOR
		if (Event.current.type != EventType.Repaint)
		{
			Debug.LogError("Style.Draw may not be called if it is not a repaint event");
			return;
		}
		#endif
		
		Internal_Draw (m_Ptr, position, content, isHover, isActive, on, hasKeyboardFocus); 
		
		#if UNITY_GUI_SUPPORT_TOOLTIP
		if (content.tooltip != null && content.tooltip != "") {
			if (isHover || isActive)
			{
				GUI.s_EditorTooltip = GUI.s_MouseTooltip = content.tooltip;
				Vector2 v = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y));
				GUI.s_ToolTipRect = new Rect (v.x, v.y, position.width, position.height);
			}
			if (hasKeyboardFocus)
				GUI.s_KeyTooltip = content.tooltip;
			
		}
		#endif
	}
	
	CSRAW public void Draw (Rect position, GUIContent content, int controlID, bool on = false)
	{
		#if UNITY_EDITOR
		if (Event.current.type != EventType.Repaint)
		{
			Debug.LogError("Style.Draw may not be called if it is not a repaint event.");
			return;
		}
		#endif
		
		if (content != null)
			Internal_Draw2 (m_Ptr, position, content, controlID, on);
		else
			Debug.LogError("Style.Draw may not be called with GUIContent that is null.");
	}
	
	CUSTOM private static void Internal_Draw2 (IntPtr style, Rect position, GUIContent content, int controlID, bool on)
	{
		GUIStyle *_style = reinterpret_cast<GUIStyle*>(style);
		_style->Draw (GetGUIState(), position, MonoGUIContentToTempNative (content), controlID, on);
	}
	
#if UNITY_EDITOR
	// PrefixLabel has to be drawn with an alternative draw mathod.
	// The normal draw methods use MonoGUIContentToTempNative which means they all share the same temp GUIContent on the native side.
	// A native IMGUI control such as GUIButton is already using this temp GUIContent when it calls GetControlID, which,
	// because of the delayed feature in PrefixLabel, can end up calling a style draw function again to draw the PrefixLabel.
	// This draw call cannot use the same temp GUIContent that is already needed for the GUIButton control itself,
	// so it has to use this alternative code path that uses a different GUIContent to store the content in.
	// We can all agree this workaround is not nice at all. But nobody seemed to be able to come up with something better.
	CSRAW internal void DrawPrefixLabel (Rect position, GUIContent content, int controlID)
	{
		if (content != null)
			Internal_DrawPrefixLabel (m_Ptr, position, content, controlID, false);
		else
			Debug.LogError("Style.DrawPrefixLabel may not be called with GUIContent that is null.");
	}
	
	C++RAW static GUIContent s_TempPrefixLabelGUIContent;
	
	CUSTOM private static void Internal_DrawPrefixLabel (IntPtr style, Rect position, GUIContent content, int controlID, bool on)
	{
		GUIStyle *_style = reinterpret_cast<GUIStyle*>(style);
		MonoGUIContentToNative (content, s_TempPrefixLabelGUIContent);
		_style->Draw (GetGUIState(), position, s_TempPrefixLabelGUIContent, controlID, on);
	}
#endif
	
	
	// Does the ID-based Draw function show keyboard focus? Disabled by windows when they don't have keyboard focus
	CSRAW internal static bool showKeyboardFocus = true;

	CUSTOM private static float Internal_GetCursorFlashOffset () {
		return GUIManager::GetCursorFlashTime ();
	}
	
	CUSTOM private static void Internal_DrawCursor (IntPtr target, Rect position, GUIContent content, int pos, Color cursorColor) 
		{ reinterpret_cast<GUIStyle*> (target)->DrawCursor (GetGUIState(), position, MonoGUIContentToTempNative (content), pos, cursorColor); }

	// Draw this GUIStyle with selected content.
	CSRAW public void DrawCursor (Rect position, GUIContent content, int controlID, int Character) {
		Event e = Event.current;
		if (e.type == EventType.Repaint) {

			// Figure out the cursor color...
			Color cursorColor = new Color (0,0,0,0);
			float cursorFlashSpeed = GUI.skin.settings.cursorFlashSpeed;
			float cursorFlashRel = ((Time.realtimeSinceStartup - GUIStyle.Internal_GetCursorFlashOffset()) % cursorFlashSpeed) / cursorFlashSpeed;
			if (cursorFlashSpeed == 0 || cursorFlashRel < .5f) {
				cursorColor = GUI.skin.settings.cursorColor;
			}

			Internal_DrawCursor (
				m_Ptr, position, content, 
				Character, cursorColor);
		}
	}
	
	
	CUSTOM private static void Internal_DrawWithTextSelection (GUIContent content, ref Internal_DrawWithTextSelectionArguments arguments) 
	{ 
		reinterpret_cast<GUIStyle*> (arguments.target)->DrawWithTextSelection (
			GetGUIState (), 
			arguments.position, 
			MonoGUIContentToTempNative(content), 
			arguments.isHover, 
			arguments.isActive, 
			arguments.on, 
			arguments.hasKeyboardFocus, 
			arguments.drawSelectionAsComposition, 
			arguments.firstPos, 
			arguments.lastPos, 
			arguments.cursorColor, 
			arguments.selectionColor
		); 
	}

	CSRAW internal void DrawWithTextSelection (Rect position, GUIContent content, int controlID, int firstSelectedCharacter, int lastSelectedCharacter, bool drawSelectionAsComposition) {

		#if UNITY_EDITOR
		if (Event.current.type != EventType.Repaint)
		{
			Debug.LogError("Style.Draw may not be called if it is not a repaint event");
			return;
		}
		#endif
		
		Event e = Event.current;

		// Figure out the cursor color...
		Color cursorColor = new Color (0,0,0,0);
		float cursorFlashSpeed = GUI.skin.settings.cursorFlashSpeed;
		float cursorFlashRel = ((Time.realtimeSinceStartup - GUIStyle.Internal_GetCursorFlashOffset()) % cursorFlashSpeed) / cursorFlashSpeed;
		if (cursorFlashSpeed == 0 || cursorFlashRel < .5f)
			cursorColor = GUI.skin.settings.cursorColor;
		

		Internal_DrawWithTextSelectionArguments arguments = new Internal_DrawWithTextSelectionArguments ();
		arguments.target = m_Ptr;
		arguments.position = position;
		arguments.firstPos = firstSelectedCharacter;
		arguments.lastPos = lastSelectedCharacter;
		arguments.cursorColor = cursorColor;
		arguments.selectionColor = GUI.skin.settings.selectionColor;
		arguments.isHover = position.Contains (e.mousePosition) ? 1 : 0;
		arguments.isActive = controlID == GUIUtility.hotControl ? 1 : 0;
		arguments.on = 0;
		arguments.hasKeyboardFocus = controlID == GUIUtility.keyboardControl && showKeyboardFocus ? 1 : 0;
		arguments.drawSelectionAsComposition = drawSelectionAsComposition ? 1 : 0;

		Internal_DrawWithTextSelection (content, ref arguments);
	}

	// Draw this GUIStyle with selected content.
	CSRAW public void DrawWithTextSelection (Rect position, GUIContent content, int controlID, int firstSelectedCharacter, int lastSelectedCharacter) {
		DrawWithTextSelection (position, content, controlID, firstSelectedCharacter, lastSelectedCharacter, false);
		
	}
	
	// Set the default font used if null is used.
	CUSTOM static internal void SetDefaultFont (Font font) 
		{ GUIStyle::SetDefaultFont (font); }

	// Get a named GUI style from the current skin.
	CSRAW public static implicit operator GUIStyle(string str) 
	{
		if (GUISkin.current == null) 
		{
			Debug.LogError ("Unable to use a named GUIStyle without a current skin. Most likely you need to move your GUIStyle initialization code to OnGUI");
			return GUISkin.error;
		}
		return GUISkin.current.GetStyle (str);
	}
	
	// Shortcut for an empty GUIStyle.
	CSRAW public static GUIStyle none { get { if(s_None == null) s_None = new GUIStyle(); return s_None; } }
	static GUIStyle s_None;

	// Get the pixel position of a given string index.
	CSRAW public Vector2 GetCursorPixelPosition (Rect position, GUIContent content, int cursorStringIndex) 
		{  Vector2 temp; Internal_GetCursorPixelPosition(m_Ptr, position, content, cursorStringIndex, out temp); return temp; }
	
	// *undoc*
	CUSTOM internal static void Internal_GetCursorPixelPosition (IntPtr target, Rect position, GUIContent content, int cursorStringIndex, out Vector2 ret)
		{
			*ret = reinterpret_cast<GUIStyle*> (target)->GetCursorPixelPosition (position, MonoGUIContentToTempNative (content), cursorStringIndex);
		}
	
	// Get the cursor position (indexing into contents.text) when the user clicked at cursorPixelPosition
	CSRAW public int GetCursorStringIndex (Rect position, GUIContent content, Vector2 cursorPixelPosition) 
		{ return Internal_GetCursorStringIndex (m_Ptr, position, content, cursorPixelPosition); }

	// *undoc*
	CUSTOM internal static int Internal_GetCursorStringIndex (IntPtr target, Rect position, GUIContent content, Vector2 cursorPixelPosition)
		{
			return reinterpret_cast<GUIStyle*> (target)->GetCursorStringIndex (position, MonoGUIContentToTempNative (content), cursorPixelPosition);
		}


	// Returns number of characters that can fit within width, returns -1 if fails due to missing font
	CSRAW internal int GetNumCharactersThatFitWithinWidth (string text, float width)
	{ 
		return Internal_GetNumCharactersThatFitWithinWidth (m_Ptr, text, width);
	}

	// *undoc*
	CUSTOM internal static int Internal_GetNumCharactersThatFitWithinWidth (IntPtr target, string text, float width)
	{
#if UNITY_FLASH
		return 5;
#else	
		return reinterpret_cast<GUIStyle*> (target)->GetNumCharactersThatFitWithinWidth (UTF16String (text.AsUTF8().c_str()), width);
#endif		
	}

	// Calculate the size of a some content if it is rendered with this style. 
	CSRAW public Vector2 CalcSize (GUIContent content)
	{ 
		Vector2 temp; Internal_CalcSize(m_Ptr, content, out temp);
		return temp;
	}

	// *undoc*
	CUSTOM internal static void Internal_CalcSize (IntPtr target, GUIContent content, out Vector2 ret)
		{
			*ret = reinterpret_cast<GUIStyle*> (target)->CalcSize (MonoGUIContentToTempNative (content));
		}

	// Calculate the size of an element formatted with this style, and a given space to content.
	CSRAW public Vector2 CalcScreenSize (Vector2 contentSize) {
		return new Vector2 (
			(fixedWidth != 0.0f ? fixedWidth : Mathf.Ceil (contentSize.x + padding.left + padding.right)),
			(fixedHeight != 0.0f ? fixedHeight : Mathf.Ceil (contentSize.y + padding.top + padding.bottom))
		);
	}
	
	// How tall this element will be when rendered with /content/ and a specific /width/.
	CSRAW public float CalcHeight (GUIContent content, float width) {
		return Internal_CalcHeight (m_Ptr, content, width);
	}

	CUSTOM private static float Internal_CalcHeight (IntPtr target, GUIContent content, float width) {
		return reinterpret_cast<GUIStyle*> (target)->CalcHeight (MonoGUIContentToTempNative (content), width);
	}

	// *undocumented*
	CSRAW public bool isHeightDependantOnWidth { get {
		return fixedHeight == 0 && (wordWrap == true && imagePosition != ImagePosition.ImageOnly);
	} }

	// Calculate the minimum and maximum widths for this style rendered with /content/.
	CSRAW public void CalcMinMaxWidth (GUIContent content, out float minWidth, out float maxWidth)
	{
		Internal_CalcMinMaxWidth(m_Ptr, content, out minWidth, out maxWidth);
	}
	// *undoc*
	CUSTOM private static void Internal_CalcMinMaxWidth (IntPtr target, GUIContent content, out float minWidth, out float maxWidth)
		{
			reinterpret_cast<GUIStyle*> (target)->CalcMinMaxWidth (MonoGUIContentToTempNative (content), minWidth, maxWidth);
		}

	// *undocumented
	CSRAW public override string ToString () {
		return UnityString.Format ("GUIStyle '{0}'", name);
	}

	C++RAW
 #undef GET
END


// Different methods for how the GUI system handles text being too large to fit the rectangle allocated.
ENUM TextClipping 
	// Text flows freely outside the element.
	Overflow = 0,
	// Text gets clipped to be inside the element.
	Clip = 1,
	
	// Text gets truncated with dots to show it is too long
	//	Truncate = 2
END


CSRAW
}