1 namespace gui::controls;
7 #define MIN_INFO_WIDTH 300
9 public class StatusBar : Window
11 class_property(icon) = "<:ecere>controls/statusBar.png";
13 background = formColor;
16 anchor = Anchor { left = 0, right = 0, bottom = 0 };
19 void AddField(StatusField field)
23 field._statusBar = this;
25 width += field.width + (guiApp.textMode ? 0 : 6);
31 void RemoveField(StatusField field)
35 field._statusBar = null;
36 width -= field.width + (guiApp.textMode ? 0 : 6);
49 RemoveField(fields.first);
56 fields.offset = (uint)&((StatusField)0).prev;
68 for(field = fields.first; field; field = field.next)
69 width += field.width + (guiApp.textMode ? 0 : 6);
73 bool OnResizing(int * w, int * h)
80 void OnRedraw(Surface surface)
83 int position = Max(clientSize.w, MIN_INFO_WIDTH + width)-1-2;
84 Box clip { 2, 2, MIN_INFO_WIDTH, 17 };
85 Window parent = this.parent;
88 surface.ThinBevel(false, -1,0, clientSize.w+2, clientSize.h+1);
90 for(field = fields.first; field; field = field.next)
92 int x = position - field.width;
94 surface.SetBackground(white);
97 surface.ThinBevel(true, x - 2, 2, field.width + 4, 16);
98 surface.SetForeground(field.colorSet ? field.color : foreground);
102 if(parent.borderStyle == sizable && parent.state == normal)
103 surface.SetForeground(field.colorSet ? (field.color == black ? white : field.color) : (foreground == black ? white : foreground));
105 surface.SetForeground(field.colorSet ? field.color : foreground);
109 Box clip { x, 2, x + field.width - 1, 17 };
112 surface.TextExtent(field.text, strlen(field.text), &tw, null);
113 surface.WriteTextf(x + (field.width - tw) / 2, 2, field.text);
116 position -= field.width + (guiApp.textMode ? 0 : 6);
119 // TESTING THIS HERE!
120 clip.right = position;
122 if(guiApp.textMode && parent.borderStyle == sizable && parent.state == normal)
123 surface.SetForeground(white);
125 surface.SetForeground(foreground);
127 surface.WriteTextf(2, 2, text);
133 text = property::text;
142 public class StatusField
146 property StatusBar statusBar
153 _statusBar.RemoveField(this);
155 value.AddField(this);
169 _statusBar.Update(null);
182 int len = strlen(value);
183 text = renew text char[len + 1];
184 CopyBytes(text, value, len + 1);
189 _statusBar.Update(null);
202 _statusBar.width += value - width;
203 _statusBar.Update(null);
210 void SetTextf(char * format, ...)
217 char tempText[MAX_F_STRING];
219 va_start(args, format);
220 vsnprintf(tempText, sizeof(tempText), format, args);
221 tempText[sizeof(tempText)-1] = 0;
223 text = CopyString(tempText);
226 _statusBar.Update(null);
236 StatusField prev, next;
240 StatusBar _statusBar;