sdk: const correctness
[sdk] / ecere / src / gui / controls / CalendarControl.ec
index 0fd2a1b..ac0a649 100644 (file)
@@ -4,12 +4,18 @@ import "Window"
 
 #define ISLEAP(y) (!((y)%4) && (((y) % 100) || (!((y)% 400))))
 
+/*static */Array<const String> veryShortDaysNames
+{ [
+   $"Sunday"."S", $"Monday"."M", $"Tuesday"."T", $"Wednesday"."W",
+   $"Thursday"."T", $"Friday"."F", $"Saturday"."S"
+] };
+
 public class CalendarControl : CommonControl
 {
    class_property(icon) = "<:ecere>controls/calendar.png";
 
 public:
-   virtual void Window::NotifyChanged(bool close);      
+   virtual void Window::NotifyChanged(CalendarControl calendarControl, bool close);
    Date dateValue;
    Month shownMonth;
    int shownYear;
@@ -28,14 +34,14 @@ private:
          dateValue.day = now.day;
          dateValue.month = now.month;
          shownYear = dateValue.year = now.year;
-         shownMonth = dateValue.month;         
+         shownMonth = dateValue.month;
       }
       return true;
    }
-   
+
    RepButton leftArrow
    {
-      this, 
+      this,
       position = { 3, 8 };
       size = { 16, 16 };
       bevel = false;
@@ -46,12 +52,12 @@ private:
       offset = false;
       text = "«";
       hotKey = pageUp;
-      
+
       bool NotifyClicked(Button button, int x, int y, ecere::gui::Modifiers mods)
       {
          shownMonth--;
          if(shownMonth < january) { shownMonth = december; shownYear--; yearBox.Refresh(); }
-         monthBox.Refresh();         
+         monthBox.Refresh();
          Update(null);
          dateBox.Activate();
          return true;
@@ -59,7 +65,7 @@ private:
    };
    RepButton rightArrow
    {
-      this, 
+      this,
       anchor = { right = 8, top = 8 };
       size = { 16, 16 };
       bevel = false;
@@ -80,7 +86,7 @@ private:
          dateBox.Activate();
          return true;
       }
-   };   
+   };
 
    DataBox monthBox
    {
@@ -97,7 +103,7 @@ private:
          return true;
       }
 
-      bool NotifyChanged(bool closingDropDown)
+      bool NotifyChanged(DataBox dataBox, bool closingDropDown)
       {
          Update(null);
          if(closingDropDown)
@@ -120,7 +126,7 @@ private:
          }
          return true;
       }
-      
+
       bool OnPostCreate()
       {
          DataBox::OnPostCreate();
@@ -128,7 +134,7 @@ private:
          return true;
       }
 
-      bool NotifyChanged(bool closingDropDown)
+      bool NotifyChanged(DataBox dataBox, bool closingDropDown)
       {
          if(shownYear < 100)
          {
@@ -137,7 +143,7 @@ private:
             shownYear += (time.year / 100) * 100;
             if(Abs(shownYear - time.year) >= 50)
                shownYear -= 100;
-            yearBox.Refresh();           
+            yearBox.Refresh();
          }
          Update(null);
          dateBox.Activate();
@@ -179,7 +185,7 @@ private:
                monthBox.Refresh();
                yearBox.Refresh();
 
-               NotifyChanged(master, closeCalendar);
+               NotifyChanged(master, this, closeCalendar);
                return;
             }
             if(++day.day > monthLengths[ISLEAP(day.year)][day.month])
@@ -202,7 +208,7 @@ private:
       {
          if(mods.left && !mods.isSideEffect)
             ((CalendarControl)master).FindDate(x, y, false, false);
-         return true;         
+         return true;
       }
       bool OnLeftButtonDown(int x, int y, Modifiers mods)
       {
@@ -239,12 +245,14 @@ private:
 
          surface.SetForeground(black);
          for(d = sunday; d <= saturday; d++)
-            surface.CenterTextf(Width / 2 + d * Width, 0, "%c", toupper(daysNames[d][0]));
+         {
+            surface.CenterTextf(Width / 2 + d * Width, 0, "%s", veryShortDaysNames[d]);
+         }
 
          surface.SetBackground(Color { 238, 238, 238 } /*whiteSmoke*/);
          surface.Area(0, Height, Width, clientSize.h);
          surface.Area(6 * Width, Height, 7*Width, clientSize.h);
-         
+
          surface.SetForeground(lightGray);
          surface.DrawLine(0, Height, clientSize.w, Height);
          surface.DrawLine(0, Height, 0, clientSize.h);
@@ -282,7 +290,7 @@ private:
                   }
                }
             }
-         }      
+         }
       }
    };
 
@@ -326,7 +334,7 @@ private:
                }
                shownMonth = dateValue.month;
                shownYear = dateValue.year;
-               NotifyChanged(master, false);
+               NotifyChanged(master, this, false);
 
                monthBox.Refresh();
                yearBox.Refresh();