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"
23 stopwatching(window, text);
30 SetInitSize(initSize);
35 text { 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, text);
64 CommonControl::OnDestroy();
71 stopwatching(window, text);
76 bool OnResizing(int *w, int *h)
80 Window labeledWindow = text ? this : window;
81 char * string = (labeledWindow && labeledWindow.text) ? labeledWindow.text : " ";
83 int width = 0, height = 0;
85 display.FontExtent(fontObject, string, strlen(string), &width, &height);
88 if(labeledWindow && labeledWindow.text)
99 bool OnLeftButtonDown(int x, int y, Modifiers mods)
101 if(window && window.visible && window.created)
106 static void Surface::GroupBevel(bool inner, int x, int y, int w, int h, int tw)
108 ColorAlpha foreground = this.foreground;
110 SetForeground(inner ? Color { 128,128,128 } : formColor);
112 HLine(x, x+8 - 2, y); // Top
113 HLine(x+8+tw, x+w - 2, y); // Top part 2
115 VLine(y+1, y+h - 2, x);
117 SetForeground(inner ? Color { 64,64,64 } : white);
119 HLine(x+1, x+8-3, y+1); // Top
120 HLine(x+8+tw+1, x+w-3, y+1); // Top part 2
121 VLine(y+2, y+h-3, x+1);
123 SetForeground(inner ? formColor : Color { 128,128,128 } );
124 HLine(x+1, x+w-2, y + h -2);
125 VLine(y+1, y+h-3, x + w - 2);
127 SetForeground(inner ? white : Color { 64,64,64 });
128 HLine(x, x+w-1, y + h - 1);
129 VLine(y, y+h-2, x + w - 1);
131 SetForeground(foreground);
134 void OnRedraw(Surface surface)
136 Window labeledWindow = text ? this : window;
144 char * caption = labeledWindow.caption;
146 surface.TextExtent(caption, strlen(caption), &tw, null);
147 GroupBevel(surface, true, 1,7, clientSize.w - 2, clientSize.h - 8, tw);
148 GroupBevel(surface, false, 0,6, clientSize.w, clientSize.h - 6, tw);
152 surface.Bevel(true, 1,7, clientSize.w - 2, clientSize.h - 8);
153 surface.Bevel(false, 0,6, clientSize.w, clientSize.h - 6);
155 /*if(parent.background)
157 surface.TextOpacity(true);
158 surface.SetBackground(parent.background);
163 labeledWindow.WriteCaption(surface, offset, 0);
166 watch(font) { SetInitSize(initSize); };
167 watch(caption) { SetInitSize(initSize); };