5 public class FontResource : Resource
8 property const char * faceName { set { delete faceName; faceName = CopyString(value); } get { return this ? faceName : null; } };
9 property float size { set { size = value; } get { return this ? size : 0; } };
10 property bool bold { set { flags.bold = value; } get { return this ? flags.bold : false; } };
11 property bool italic { set { flags.italic = value; } get { return this ? flags.italic : false; } };
12 property bool underline { set { flags.underline = value; } get { return this ? flags.underline : false; } };
13 property Font font { get { return this ? font : null; } };
14 property Window window { set { if(value) { value.RemoveResource(this); value.AddResource(this); } } };
15 property float outlineSize { set { outlineSize = value; } get { return this ? outlineSize : 0; } };
16 property float outlineFade { set { outlineFade = value; } get { return this ? outlineFade : 0; } };
23 DisplaySystem displaySystem;
24 float outlineSize, outlineFade;
26 void Load(FontResource copy, DisplaySystem displaySystem)
29 faceName = *&CopyString(copy.faceName);
31 *&flags = *©.flags;
32 *&outlineSize = *©.outlineSize;
33 *&outlineFade = *©.outlineFade;
34 if(faceName && displaySystem)
36 this.displaySystem = displaySystem;
37 font = displaySystem.LoadOutlineFont(faceName, size, flags, outlineSize, outlineFade);
41 void Reference(FontResource reference)
43 font = reference.font;
53 if(font && displaySystem)
54 displaySystem.UnloadFont(font);
59 Window OnEdit(Window window, Window master, int x, int y, int w, int h, void * userData)
61 Window editData = class::OnEdit(window, master, x + 24,y,w - 48,h, userData);
64 window, master = editData, inactive = true, text = "...", hotKey = F2,
65 position = { Max(x + 24, x + w - 24), y }, size = { 24, h }
71 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags flags)
73 char * string = this ? faceName : null;
74 Font font = this ? font : null;
75 if(!string) string = "(none)";
76 surface.WriteTextDots(alignment, x + 24, y + 1, width - 24, string, strlen(string));
77 surface.SetBackground(White);
78 surface.Area(x - 4, y, x + 20, y + 15);
80 surface.SetForeground(Black);
81 surface.Rectangle(x-1, y + 1, x + 18, y + 14);
84 int OnCompare(FontResource font2)
89 char * string1 = faceName;
90 char * string2 = font2.faceName;
91 if(string1 && string2)
92 result = strcmpi(string1, string2);
97 const char * OnGetString(char * string, void * fieldDat, bool * needClass)
101 char * fileName = faceName;
103 strcpy(string, fileName);
111 bool OnGetDataFromString(const char * string)
113 this = (string && string[0]) ? FontResource { } : null;