ecere/gui/StatusBar: Added option to set minimum info width
[sdk] / ecere / src / gui / controls / StatusBar.ec
index df1e651..8c78f55 100644 (file)
@@ -4,7 +4,7 @@ import "Window"
 
 #include <stdarg.h>
 
-#define MIN_INFO_WIDTH  300
+define defaultMinInfoWidth = 300;
 
 public class StatusBar : Window
 {
@@ -14,8 +14,15 @@ 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)
@@ -53,7 +60,7 @@ public:
 private:
    StatusBar()
    {
-      fields.offset = (uint)&((StatusField)0).prev;
+      fields.offset = (uint)(uintptr)&((StatusField)0).prev;
    }
 
    ~StatusBar()
@@ -82,8 +89,8 @@ private:
    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)
@@ -142,9 +149,10 @@ private:
       Update(null);
    };
 
-   char * text;
+   const char * text;
    OldList fields;
    int width;
+   int minInfoWidth;
 };
 
 public class StatusField
@@ -199,7 +207,7 @@ public:
       }
    }
 
-   property char * text
+   property const char * text
    {
       set
       {
@@ -235,7 +243,7 @@ public:
       }
    }
 
-   void SetTextf(char * format, ...)
+   void SetTextf(const char * format, ...)
    {
       if(this)
       {