1 namespace gui::controls;
5 public class Label : CommonControl
7 class_property(icon) = "<:ecere>controls/label.png";
15 property Window labeledWindow
17 property_category $"Behavior"
22 stopwatching(window, caption);
23 stopwatching(window, disabled);
30 SetInitSize(initSize);
35 caption { SetInitSize(initSize); }
36 disabled { Update(null); }
41 get { return window; }
44 property bool isGroupBox
46 property_category $"Appearance"
52 get { return isGroupBox; }
59 if(window && (window == master || window == parent))
61 stopwatching(window, caption);
62 stopwatching(window, disabled);
65 CommonControl::OnDestroy();
72 stopwatching(window, caption);
73 stopwatching(window, disabled);
78 bool OnResizing(int *w, int *h)
82 Window labeledWindow = text ? this : window;
83 char * string = (labeledWindow && labeledWindow.text) ? labeledWindow.text : " ";
85 int width = 0, height = 0;
87 display.FontExtent(fontObject, string, strlen(string), &width, &height);
90 if(labeledWindow && labeledWindow.text)
101 bool OnLeftButtonDown(int x, int y, Modifiers mods)
103 if(window && window.visible && window.created && !window.disabled)
108 static void Surface::GroupBevel(bool inner, int x, int y, int w, int h, int tw)
110 ColorAlpha foreground = this.foreground;
112 SetForeground(inner ? Color { 128,128,128 } : formColor);
114 HLine(x, x+8 - 2, y); // Top
115 HLine(x+8+tw, x+w - 2, y); // Top part 2
117 VLine(y+1, y+h - 2, x);
119 SetForeground(inner ? Color { 64,64,64 } : white);
121 HLine(x+1, x+8-3, y+1); // Top
122 HLine(x+8+tw+1, x+w-3, y+1); // Top part 2
123 VLine(y+2, y+h-3, x+1);
125 SetForeground(inner ? formColor : Color { 128,128,128 } );
126 HLine(x+1, x+w-2, y + h -2);
127 VLine(y+1, y+h-3, x + w - 2);
129 SetForeground(inner ? white : Color { 64,64,64 });
130 HLine(x, x+w-1, y + h - 1);
131 VLine(y, y+h-2, x + w - 1);
133 SetForeground(foreground);
136 void OnRedraw(Surface surface)
138 Window labeledWindow = text ? this : window;
146 char * caption = labeledWindow.caption;
148 surface.TextExtent(caption, strlen(caption), &tw, null);
149 GroupBevel(surface, true, 1,7, clientSize.w - 2, clientSize.h - 8, tw);
150 GroupBevel(surface, false, 0,6, clientSize.w, clientSize.h - 6, tw);
154 surface.Bevel(true, 1,7, clientSize.w - 2, clientSize.h - 8);
155 surface.Bevel(false, 0,6, clientSize.w, clientSize.h - 6);
157 /*if(parent.background)
159 surface.TextOpacity(true);
160 surface.SetBackground(parent.background);
165 labeledWindow.WriteCaption(surface, offset, 0);
168 watch(font) { SetInitSize(initSize); };
169 watch(caption) { SetInitSize(initSize); };