#include <stdarg.h>
-#define MIN_INFO_WIDTH 300
+define defaultMinInfoWidth = 300;
public class StatusBar : Window
{
nonClient = true;
inactive = true;
anchor = Anchor { left = 0, right = 0, bottom = 0 };
+ minInfoWidth = defaultMinInfoWidth;
public:
+ property int minInfoWidth
+ {
+ set { minInfoWidth = value; }
+ get { return minInfoWidth; }
+ }
+
void AddField(StatusField field)
{
if(this && field)
{
if(this && field)
{
- field._statusBar = null;
+ field._statusBar = null;
width -= field.width + (guiApp.textMode ? 0 : 6);
fields.Remove(field);
delete field;
private:
StatusBar()
{
- fields.offset = (uint)&((StatusField)0).prev;
+ fields.offset = (uint)(uintptr)&((StatusField)0).prev;
}
~StatusBar()
Clear();
}
+ FontResource boldFont { font.faceName, font.size, true, window = this };
+
bool OnLoadGraphics()
{
StatusField field;
void OnRedraw(Surface surface)
{
StatusField field;
- int position = Max(clientSize.w, MIN_INFO_WIDTH + width)-1-2;
- Box clip { 2, 2, MIN_INFO_WIDTH, statusBarHeight-1 };
+ int position = Max(clientSize.w, minInfoWidth + width)-1-2;
+ Box clip { 2, 2, minInfoWidth, statusBarHeight-1 };
Window parent = this.parent;
if(!guiApp.textMode)
surface.ThinBevel(false, -1,0, clientSize.w+2, clientSize.h+1);
-
+
for(field = fields.first; field; field = field.next)
{
int x = position - field.width;
}
if(field.text)
{
- Box clip { x, 2, x + field.width - 1, statusBarHeight-1 };
+ Box clip { x, 2, x + field.width - 1, statusBarHeight-3 };
int tw;
surface.Clip(clip);
+ if(field.backColor)
+ {
+ surface.SetBackground(field.backColor);
+ surface.Clear(colorBuffer);
+ }
+ surface.font = field.bold ? boldFont.font : fontObject;
surface.TextExtent(field.text, strlen(field.text), &tw, null);
surface.WriteTextf(x + (field.width - tw) / 2, 2, field.text);
- surface.Clip(null);
+ surface.Clip(null);
}
position -= field.width + (guiApp.textMode ? 0 : 6);
}
surface.SetForeground(white);
else
surface.SetForeground(foreground);
-
+
surface.WriteTextf(2, 2, text);
surface.Clip(null);
}
Update(null);
};
- char * text;
+ const char * text;
OldList fields;
int width;
+ int minInfoWidth;
};
public class StatusField
}
property Color color
{
- set
+ set
{
if(this)
{
}
}
}
+ property ColorAlpha backColor
+ {
+ set
+ {
+ if(this)
+ {
+ backColor = value;
+ colorSet = true;
+ if(_statusBar)
+ _statusBar.Update(null);
+ }
+ }
+ }
+ property bool bold
+ {
+ set
+ {
+ if(this) this.bold = value;
+ }
+ }
- property char * text
+ property const char * text
{
set
{
}
}
- void SetTextf(char * format, ...)
+ void SetTextf(const char * format, ...)
{
if(this)
{
char * text;
int width;
Color color;
+ ColorAlpha backColor;
StatusBar _statusBar;
bool colorSet;
+ bool bold;
};