cleaned all trailing white space from source files.
[sdk] / ecere / src / gui / controls / Label.ec
index 04b6147..a2c744f 100644 (file)
@@ -14,7 +14,7 @@ public class Label : CommonControl
 public:
    property Window labeledWindow
    {
-      property_category "Behavior" 
+      property_category $"Behavior"
       set
       {
          Size size;
@@ -42,13 +42,13 @@ public:
    };
 
    property bool isGroupBox
-   { 
-      property_category "Appearance" 
+   {
+      property_category $"Appearance"
       set
       {
          isGroupBox = value;
          inactive = !value;
-      } 
+      }
       get { return isGroupBox; }
    };
 
@@ -61,6 +61,7 @@ private:
          stopwatching(window, text);
          delete window;
       }
+      CommonControl::OnDestroy();
    }
 
    ~Label()
@@ -82,11 +83,15 @@ private:
          int width = 0, height = 0;
 
          display.FontExtent(fontObject, string, strlen(string), &width, &height);
-         if(labeledWindow && labeledWindow.text)
-            *w = Max(width, *w);
-         else
-            *w = Max(width, 80);
-         *h = Max(height, *h);
+         if(!*w)
+         {
+            if(labeledWindow && labeledWindow.text)
+               *w = Max(width, *w);
+            else
+               *w = Max(width, 80);
+         }
+         if(!*h)
+            *h = Max(height, *h);
       }
       return true;
    }
@@ -98,6 +103,34 @@ private:
       return isGroupBox;
    }
 
+   static void Surface::GroupBevel(bool inner, int x, int y, int w, int h, int tw)
+   {
+      ColorAlpha foreground = this.foreground;
+
+      SetForeground(inner ? Color { 128,128,128 } : formColor);
+
+      HLine(x,   x+8 - 2, y);       // Top
+      HLine(x+8+tw,   x+w - 2, y);    // Top part 2
+
+      VLine(y+1, y+h - 2, x);
+
+      SetForeground(inner ? Color { 64,64,64 } : white);
+
+      HLine(x+1, x+8-3, y+1);       // Top
+      HLine(x+8+tw+1, x+w-3, y+1);    // Top part 2
+      VLine(y+2, y+h-3, x+1);
+
+      SetForeground(inner ? formColor : Color { 128,128,128 } );
+      HLine(x+1, x+w-2, y + h -2);
+      VLine(y+1, y+h-3, x + w - 2);
+
+      SetForeground(inner ? white : Color { 64,64,64 });
+      HLine(x, x+w-1, y + h - 1);
+      VLine(y, y+h-2, x + w - 1);
+
+      SetForeground(foreground);
+   }
+
    void OnRedraw(Surface surface)
    {
       Window labeledWindow = text ? this : window;
@@ -105,13 +138,25 @@ private:
 
       if(isGroupBox)
       {
-         surface.Bevel(true,  1,7, clientSize.w - 2, clientSize.h - 8);
-         surface.Bevel(false, 0,6, clientSize.w, clientSize.h - 6);
-         if(parent.background)
+         if(labeledWindow)
+         {
+            int tw = 0;
+            char * caption = labeledWindow.caption;
+            if(caption)
+               surface.TextExtent(caption, strlen(caption), &tw, null);
+            GroupBevel(surface, true,  1,7, clientSize.w - 2, clientSize.h - 8, tw);
+            GroupBevel(surface, false, 0,6, clientSize.w, clientSize.h - 6, tw);
+         }
+         else
+         {
+            surface.Bevel(true,  1,7, clientSize.w - 2, clientSize.h - 8);
+            surface.Bevel(false, 0,6, clientSize.w, clientSize.h - 6);
+         }
+         /*if(parent.background)
          {
             surface.TextOpacity(true);
             surface.SetBackground(parent.background);
-         }
+         }*/
          offset = 8;
       }
       if(labeledWindow)
@@ -119,7 +164,7 @@ private:
    }
 
    watch(font) { SetInitSize(initSize); };
-   watch(text) { SetInitSize(initSize); };
+   watch(caption) { SetInitSize(initSize); };
 
    Window window;
    bool isGroupBox;