cleaned all trailing white space from source files.
[sdk] / ecere / src / gui / controls / ScrollBar.ec
index 5981972..4c897b0 100644 (file)
@@ -63,7 +63,7 @@ public:
             // SNAPDOWN(position, lineStep);
 
          if(position < 0) position = 0;
-         if(position >= range) 
+         if(position >= range)
             position = range - 1;
 
          if(thumb)
@@ -79,12 +79,12 @@ public:
 
    virtual void Window::NotifyScrolling(ScrollBar scrollBar, ScrollBarAction action, int position, Key key);
 
-   property ScrollDirection direction { property_category "Appearance" set { sbStyle.vertical = value == vertical; } get { return sbStyle.vertical ? vertical : horizontal; } };
+   property ScrollDirection direction { property_category $"Appearance" set { sbStyle.vertical = value == vertical; } get { return sbStyle.vertical ? vertical : horizontal; } };
    property bool windowOwned { set { sbStyle.window = value; } /* get { return sbStyle.window; } */ };
-   property bool snap { property_category "Behavior" set { sbStyle.snap = value; } get { return sbStyle.snap; } };
+   property bool snap { property_category $"Behavior" set { sbStyle.snap = value; } get { return sbStyle.snap; } };
    property int range
    {
-      property_category "Behavior" 
+      property_category $"Behavior"
       set
       {
          total = value + seen - 1;
@@ -95,7 +95,7 @@ public:
    // Improve this, needs to be done in 2 so updates commented out for seen
    property int seen
    {
-      property_category "Behavior" 
+      property_category $"Behavior"
       set
       {
          if(this)
@@ -111,7 +111,7 @@ public:
    };
    property int total
    {
-      property_category "Behavior" 
+      property_category $"Behavior"
       set
       {
          if(this)
@@ -124,9 +124,9 @@ public:
       get { return total; }
    };
 
-   property int lineStep { property_category "Behavior" set { if(this) lineStep = value; } get { return lineStep; } };
-   property int pageStep { property_category "Behavior" set { if(this) pageStep = value; } get { return pageStep; } };
-   property int thumbPosition { property_category "Behavior" set { Action(setPosition, value, 0); } get { return position; } };
+   property int lineStep { property_category $"Behavior" set { if(this) lineStep = value; } get { return lineStep; } };
+   property int pageStep { property_category $"Behavior" set { if(this) pageStep = value; } get { return pageStep; } };
+   property int thumbPosition { property_category $"Behavior" set { Action(setPosition, value, 0); } get { return position; } };
 
 private:
    ScrollBar()
@@ -174,7 +174,7 @@ private:
       bool NotifyPushed(Button button, int x, int y, Modifiers mods)
       {
          action = down;
-         Action(action, 0, (Key)mods);
+         Action(action, 0, Key { modifiers = mods });
          timer.Start();
          return true;
       }
@@ -186,8 +186,8 @@ private:
 
       bool NotifyPushed(Button button, int x, int y, Modifiers mods)
       {
-         action = up; 
-         Action(action, 0, (Key)mods);
+         action = up;
+         Action(action, 0, Key { modifiers = mods });
          timer.Start();
          return true;
       }
@@ -220,7 +220,7 @@ private:
                }
                position = y - thumbClick.y + thumb.position.y;
                if(height)
-                  position = (position - SB_HEIGHT) * (range - 1) / height;
+                  position = (int)((int64)(position - SB_HEIGHT) * (range - 1) / height);
                if(guiApp.textMode)
                {
                   SNAPUP(position, textCellH);
@@ -235,7 +235,7 @@ private:
                }
                position = x - thumbClick.x + thumb.position.x;
                if(height)
-                  position = (position - upBtn.size.w) * (range - 1) / height;
+                  position = (int)((int64)(position - upBtn.size.w) * (range - 1) / height);
                if(guiApp.textMode)
                {
                   SNAPUP(position, textCellW);
@@ -247,9 +247,9 @@ private:
                if(sbStyle.snap)
                   SNAPDOWN(position, lineStep);
                if(position == 0)
-                  Action(setPosition, position, (Key)mods);
+                  Action(setPosition, position, Key { modifiers = mods });
                else
-                  Action(setPosition, position, (Key)mods);
+                  Action(setPosition, position, Key { modifiers = mods });
             }
          }
          return true;
@@ -303,7 +303,7 @@ private:
    bool draggingThumb;
    Point pos, thumbClick;
    bool inside;
-   
+
    void OnRedraw(Surface surface)
    {
       int sbWidth = SB_WIDTH;
@@ -378,7 +378,7 @@ private:
             {
                SNAPUP(height, textCellH);
             }
-            thumbPos = upBtn.size.h + position * height / (range - 1);
+            thumbPos = upBtn.size.h + (int)((int64)position * height / (range - 1));
             if(guiApp.textMode)
             {
                SNAPUP(thumbPos, textCellH);
@@ -393,7 +393,7 @@ private:
             {
                SNAPUP(width, textCellW);
             }
-            thumbPos = upBtn.size.w + position * width / (range - 1);
+            thumbPos = upBtn.size.w + (int)((int64)position * width / (range - 1));
             if(guiApp.textMode)
             {
                SNAPUP(thumbPos, textCellW);
@@ -418,9 +418,9 @@ private:
       else
       {
          // What to do here?
-         upBtn.background = activeBorder;
-         downBtn.background = activeBorder;
-         thumb.background = activeBorder;
+         upBtn.background = formColor;
+         downBtn.background = formColor;
+         thumb.background = formColor;
          background = Color { 224, 224, 224 };
       }
       if(sbStyle.vertical)
@@ -480,7 +480,7 @@ private:
             thumbSize = seen * size / total;
          }
          else
-            thumbSize = 0;      
+            thumbSize = 0;
 
          if(sbStyle.vertical)
          {
@@ -525,7 +525,7 @@ private:
       else
          action = pageDown;
 
-      Action(action, 0, (Key)mods);
+      Action(action, 0, Key { modifiers = mods });
       timer.Start();
 
       Update(null);
@@ -577,9 +577,9 @@ private:
       {
          case left:
          case up:     Action(up, 0, key); break;
-         case right: 
-         case down:   
-            Action(down, 0, key); 
+         case right:
+         case down:
+            Action(down, 0, key);
             break;
          case pageUp:   Action(pageUp, 0, key); break;
          case pageDown:  Action(pageDown, 0, key); break;
@@ -592,3 +592,19 @@ private:
       thumb.visible = !disabled;
    };
 };
+
+void SBSetSeen(ScrollBar sb, int value)
+{
+   value = Max(1,value);
+   if(sb.sbStyle.snap)
+      SNAPDOWN(value, *&sb.lineStep);
+   *&sb.seen = value;
+   sb.range = Max(sb.total - sb.seen + 1, 1);
+}
+
+void SBSetTotal(ScrollBar sb, int value)
+{
+   if(!value) value = *&sb.seen;
+   *&sb.total = value;
+   sb.range = Max(sb.total - sb.seen + 1, 1);
+}