extras; samples: Fixed some warnings
authorJerome St-Louis <jerome@ecere.com>
Sun, 22 Jun 2014 06:58:14 +0000 (02:58 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sun, 22 Jun 2014 06:58:14 +0000 (02:58 -0400)
18 files changed:
extras/fli.ec
extras/fliPlay.ec
samples/guiAndGfx/LinkLabel/linkLabel.ec
samples/guiAndGfx/disablingMovingControls/form2.ec
samples/guiAndGfx/eNotepad/eNotepad.ec
samples/guiAndGfx/fractals/fractals.ec
samples/guiAndGfx/fractals/fractals.epj
samples/guiAndGfx/openrider/form1.ec
samples/guiAndGfx/openrider/game.ec
samples/guiAndGfx/openrider/math.ec
samples/guiAndGfx/openrider/openrider.epj
samples/guiAndGfx/reminder/Reminder.ec
samples/guiAndGfx/replace/replace.ec
samples/guiAndGfx/skinning/MySkin.ec
samples/guiAndGfx/slideShow/eShow.ec
samples/guiAndGfx/snow/snow.ec
samples/guiAndGfx/textScroller/textScroller.ec
samples/guiAndGfx/treeView/explorer.ec

index e71b0b6..a2109ce 100644 (file)
@@ -21,7 +21,7 @@ struct FLIheader
    uint16 speed           __attribute__((packed));
    uint next              __attribute__((packed));
    uint frit              __attribute__((packed));
-   byte expand[102]       __attribute__((packed));
+   byte expand[102];
 };
 
 struct FLIFrame
@@ -29,7 +29,7 @@ struct FLIFrame
    uint size              __attribute__((packed));
    uint16 magic           __attribute__((packed));
    uint16 chunknum        __attribute__((packed));
-   byte nothing[8]        __attribute__((packed));
+   byte nothing[8];
 };
 
 struct FLIchunk
@@ -69,9 +69,9 @@ class Fli
       {
          byte ch;
 
-         f.Getc(&ch);
+         f.Getc((char *)&ch);
          skip+=ch;
-         f.Getc(&ch);
+         f.Getc((char *)&ch);
          put=ch;
 
          if(!put)
@@ -103,13 +103,13 @@ class Fli
       {
          byte ch;
          offset=skipline*bitmap.width;
-         f.Getc(&ch);
+         f.Getc((char *)&ch);
          num = ch;
          for(; num>0; num--)
          {
-            f.Getc(&ch);
+            f.Getc((char *)&ch);
             offset += ch;
-            f.Getc(&ch);
+            f.Getc((char *)&ch);
             put = ch;
             if(put>0)
             {
@@ -118,7 +118,7 @@ class Fli
             }
             else if(put<0)
             {
-               f.Getc(&value);
+               f.Getc((char *)&value);
                FillBytes(bitmap.picture+offset,value,-put);
                offset-=put;
             }
@@ -148,9 +148,9 @@ class Fli
             offset=y*bitmap.width;
             for(; num>0; num--)
             {
-               f.Getc(&ch);
+               f.Getc((char *)&ch);
                offset += ch;
-               f.Getc(&ch);
+               f.Getc((char *)&ch);
                put = ch;
 
                if(put>0)
@@ -177,19 +177,19 @@ class Fli
    {
       uint offset;
       int y;
-      short num;
+      //short num;
       signed char put;
       byte value;
       for(y=0; y<bitmap.height; y++)
       {
          byte ch;
          int x = 0;
-         f.Getc(&ch);
-         num = ch;
+         f.Getc((char *)&ch);
+         //num = ch;
          /*if(!num)
          {
-            f.Getc(&ch);
-            f.Getc(&ch);
+            f.Getc((char *)&ch);
+            f.Getc((char *)&ch);
             FillBytes(bitmap.picture,ch,bitmap.size);
             return;
          }*/
@@ -197,7 +197,7 @@ class Fli
          // for(; num>0 && x < bitmap.width; num--)
          for(; x < bitmap.width; )
          {
-            f.Getc(&ch);
+            f.Getc((char *)&ch);
             put = ch;
             if(put<0)
             {
@@ -207,7 +207,7 @@ class Fli
             }
             else if(put>0)
             {
-               f.Getc(&value);
+               f.Getc((char *)&value);
                if(offset > bitmap.width * bitmap.height)
                   printf("bug");
                FillBytes(bitmap.picture+offset,value,put);
@@ -234,7 +234,7 @@ class Fli
    property int frame { get { return frame; } set { frame = value; } }
    property bool palUpdate { get { return palUpdate; } set { palUpdate = value; }}
 
-   bool Load(char *fileName)
+   bool Load(const char *fileName)
    {
       bool result = false;
       //f=FileOpen(fileName, read);
index dca721f..0ebf97a 100644 (file)
@@ -33,7 +33,7 @@ class FliPlay : Window
       }
    };
 
-   property char * animation
+   property const char * animation
    {
       set
       {
index a9c3f4f..b9a93a2 100644 (file)
@@ -3,7 +3,7 @@ import "ecere"
 class LinkLabel : Label
 {
    char * url;
-   public property char * url
+   public property const char * url
    {
       set { delete url; url = CopyString(value); }
       get { return url; }
@@ -22,14 +22,14 @@ class LinkLabel : Label
 
 class About : Window
 {
-   text = "Link Demo";
+   caption = "Link Demo";
    hasClose = true;
    size = { 200, 80 };
 
    LinkLabel
    {
       this, position = { 10,  10 };
-      text = "www.ecere.com";
+      caption = "www.ecere.com";
       url = "http://www.ecere.com/";
    };
 }
index e437b31..a36ec48 100644 (file)
@@ -50,9 +50,9 @@ public:
       for (;d--;i++) {
          i->x += i->dx;
          i->y += i->dy;
-         if (i->x<0 && i->dx<0 || (i->x+i->w >= holder.clientSize.w && i->dx>0))
+         if ((i->x<0 && i->dx<0) || (i->x+i->w >= holder.clientSize.w && i->dx>0))
             i->dx = -i->dx;
-         if (i->y<0 && i->dy<0 || (i->y+i->h >= holder.clientSize.h && i->dy>0))
+         if ((i->y<0 && i->dy<0) || (i->y+i->h >= holder.clientSize.h && i->dy>0))
             i->dy = -i->dy;
       }
    }
index 9928e11..a3a718d 100644 (file)
@@ -42,6 +42,7 @@ class eNodepadWindow : Window
                delete(f);
             }
          }
+         return true;
       }
    };
    MenuDivider { fileMenu };
@@ -62,7 +63,7 @@ class eNodepadWindow : Window
    };
    saveDialog = fileSaveDialog;
 
-   bool OnSaveFile(char * fileName)
+   bool OnSaveFile(const char * fileName)
    {
       File f = FileOpen(fileName, write);
       if(f)
@@ -78,7 +79,7 @@ class eNodepadWindow : Window
    {
       this, font = { "Lucida Console", 10 }, anchor = { left = 0.0, top = 0.0, right = 0.0, bottom = 0.0 }, hasHorzScroll = true, hasVertScroll = true, multiLine = true;
 
-      bool OnFileModified(FileChange fileChange, char * param)
+      bool OnFileModified(FileChange fileChange, const char * param)
       {
 
          return true;
@@ -112,7 +113,7 @@ class eNodepadWindow : Window
       return false;
    }
 
-   bool OnFileModified(FileChange fileChange, char * param)
+   bool OnFileModified(FileChange fileChange, const char * param)
    {
 
       return true;
index f0baa2a..cec59fa 100644 (file)
@@ -623,7 +623,7 @@ class Fractal : Window
          exportDialog.SetText("Export %s image", text);
          if(exportDialog.Modal())
          {
-            char * ext = exportDialog.types[exportDialog.fileType].typeExtension;
+            const char * ext = exportDialog.types[exportDialog.fileType].typeExtension;
             if(!ext)
             {
                char extension[MAX_EXTENSION];
@@ -631,7 +631,7 @@ class Fractal : Window
                if(!extension[0])
                {
                   ext = "jpg";
-                  ChangeExtension(exportDialog.filePath, ext, exportDialog.filePath);
+                  ChangeExtension(exportDialog.filePath, ext, (char *)exportDialog.filePath);
                }
             }
             image.Save(exportDialog.filePath, ext, (void *) bool::true);
@@ -651,7 +651,7 @@ class Fractal : Window
          exportDialog.SetText("Export %s image", text);
          if(exportDialog.Modal())
          {
-            char * ext = exportDialog.types[exportDialog.fileType].typeExtension;
+            const char * ext = exportDialog.types[exportDialog.fileType].typeExtension;
             Bitmap filtered { };
             if(!ext)
             {
@@ -660,7 +660,7 @@ class Fractal : Window
                if(!extension[0])
                {
                   ext = "jpg";
-                  ChangeExtension(exportDialog.filePath, ext, exportDialog.filePath);
+                  ChangeExtension(exportDialog.filePath, ext, (char *)exportDialog.filePath);
                }
             }
             if(filtered.Allocate(null, image.width/2, image.height/2, 0, pixelFormat888, false))
@@ -1076,7 +1076,7 @@ class FractalsDesigner : Window
          UpdateDisplay();
       }
    };
-   bool LoadFractals(char * fileName)
+   bool LoadFractals(const char * fileName)
    {
       File f = FileOpen(fileName, read);
       if(f)
@@ -1370,7 +1370,7 @@ class FractalsDesigner : Window
 
    saveDialog = mySaveDialog;
 
-   bool OnSaveFile(char * fileName)
+   bool OnSaveFile(const char * fileName)
    {
       File f = FileOpen(fileName, write);
       if(f)
index 2a56ec3..3791603 100644 (file)
       "Console" : false,
       "Compress" : false
    },
+   "Platforms" : [
+      {
+         "Name" : "linux",
+         "Options" : {
+            "Libraries" : [
+               "m"
+            ]
+         }
+      },
+      {
+         "Name" : "apple",
+         "Options" : {
+            "Libraries" : [
+               "m"
+            ]
+         }
+      }
+   ],
    "Configurations" : [
       {
          "Name" : "Debug",
@@ -35,4 +53,4 @@
    "Resources" : [
 
    ]
-}
\ No newline at end of file
+}
index 1f607f3..82efb82 100644 (file)
@@ -390,7 +390,7 @@ class Form1 : Window
       return true;
    }
 
-   bool OnSaveFile(char * fileName)
+   bool OnSaveFile(const char * fileName)
    {
       File f = FileOpen(fileName, write);
       unsigned short mv = (unsigned short)game.version_code;
@@ -409,7 +409,7 @@ class Form1 : Window
       return true;
    }
 
-   void OnLoadFile(char * fileName) {
+   void OnLoadFile(const char * fileName) {
       File f = FileOpen(fileName, read);
       unsigned short mv;
       char prefix[PREFIX_SIZE];
index 47a6093..c5794f1 100644 (file)
@@ -43,18 +43,15 @@ class GameVehicle {
 
    void OnUnserialize(IOChannel channel)
    {
-      if(!this)
+      GameVehicleType vtype;
+      channel.Get(vtype);
+      if(vtype == ball)
       {
-         GameVehicleType vtype;
-         channel.Get(vtype);
-         if(vtype == ball)
-         {
-            GameBall::OnUnserialize(class(GameBall), this, channel);
-            return;
-         }
-         else
-            this = GameVehicle { };
+         GameBall::OnUnserialize(class(GameBall), this, channel);
+         return;
       }
+      else
+         this = GameVehicle { };
 
       if(!type)
          channel.Get(type);
@@ -83,7 +80,8 @@ class GameBall : GameVehicle {
 
    void OnUnserialize(IOChannel channel)
    {
-      this = GameBall { };
+      GameBall gb { };
+      this = gb;
       GameVehicle::OnUnserialize(channel);
       channel.Get(radius);
       channel.Get(elasticity);
@@ -94,7 +92,6 @@ class GameBall : GameVehicle {
    //support backtracing if ball is within box for line
    void Update(Game game) {
       //TODO:  check for collision with other balls
-      uint count;
       double time_left=1.0;
       BallLineReturn soonest = {INF,{0,0}};
       GameLine *soonest_line;
index cff5b0a..1b54765 100644 (file)
@@ -7,11 +7,11 @@ struct Vector2D {
       x = sx;
       y = sy;
    }
-   void Add(Vector2D a, Vector2D b) {
+   void Add(const Vector2D a, const Vector2D b) {
       x = a.x+b.x;
       y = a.y+b.y;
    }
-   void Sub(Vector2D end, Vector2D start) {
+   void Sub(const Vector2D end, const Vector2D start) {
       x = end.x-start.x;
       y = end.y-start.y;
    }
@@ -28,7 +28,7 @@ struct Vector2D {
 
 struct Coord2D : Vector2D {};
 
-double DotProduct(Vector2D a, Vector2D b) {
+double DotProduct(const Vector2D a, const Vector2D b) {
    return a.x*b.x+a.y*b.y;
 }
 
index 4b47a1f..8a74fd0 100644 (file)
@@ -9,6 +9,24 @@
          "ecere"
       ]
    },
+   "Platforms" : [
+      {
+         "Name" : "linux",
+         "Options" : {
+            "Libraries" : [
+               "m"
+            ]
+         }
+      },
+      {
+         "Name" : "apple",
+         "Options" : {
+            "Libraries" : [
+               "m"
+            ]
+         }
+      }
+   ],
    "Configurations" : [
       {
          "Name" : "Debug",
index 7f39130..11c6e7c 100644 (file)
@@ -110,7 +110,7 @@ class ReminderApp : GuiApplication
 
 define app = ((ReminderApp)__thisModule);
 
-static void struscpy(char * d, char * s)
+static void struscpy(char * d, const char * s)
 {
    int j, k;
    j = k = 0;
index f967499..25811a8 100644 (file)
@@ -73,8 +73,8 @@ class Replace : Window
       this, noCaret = true, multiLine = true, autoEmpty = true, textHorzScroll = true, hasVertScroll = true, anchor = Anchor { left = 420, top = 30, right = 10, bottom = 10 }
    };
 
-   int ReplaceInDirectory(char * directory, char * findWhat, char * replaceWith,
-                            bool matchCase, bool wholeWord, bool recurse, EditBox edit, EditBox log)
+   int ReplaceInDirectory(const char * directory, const char * findWhat, const char * replaceWith,
+                          bool matchCase, bool wholeWord, bool recurse, EditBox edit, EditBox log)
    {
       FileListing listing { directory, "htm, html, css, ec" };
       int total = 0;
index ed745d9..615e4d4 100644 (file)
@@ -51,7 +51,7 @@ static ColorKey gradientInactive[] =
 #define GRADIENT_DIRECTION horizontal
 #define TEXT_COLOR         white
 #define TEXT_INACTIVE      darkGray // Color { 212,208,200 }
-
+/*
 static ColorKey gradient[] =
 {
    { ColorAlpha { 255, Color {  10,   36, 106 } }, 0.00f },
@@ -62,8 +62,7 @@ static ColorKey gradientInactive[] =
    { ColorAlpha { 255, Color { 128, 128, 128 } }, 0.00f },
    { ColorAlpha { 255, Color { 192, 192, 192 } }, 1.00f }
 };
-
-
+*/
 
 BitmapResource bmpUpMiddle { ":upMiddle.png", alphaBlend = true };
 BitmapResource bmpUpLeft { ":upLeft.png", alphaBlend = true };
@@ -100,21 +99,21 @@ extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResizing;
 extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnPostCreate;
 private:
 
-static void Dummy()
+static __attribute__((unused)) void Dummy()
 {
-   Window w;
+   Window w = 0;
    w.OnPostCreate();
    w.OnRedraw(null);
    w.OnResizing(null, null);
 }
 
-static void Button::ThumbOnRedraw(Surface surface)
+/*static void Button::ThumbOnRedraw(Surface surface)
 {
-   int offset = (buttonState == down) ? this.offset : 0;
+   //int offset = (buttonState == down) ? this.offset : 0;
    BitmapResource left = bmpThumbUp;
    BitmapResource right = bmpThumbDown;
    BitmapResource middle = bmpThumbVert;
-   int sizeW = size.w;
+   //int sizeW = size.w;
    int x = 1; //-40 * sizeH / 96;
    int y = -6; //-7 * sizeH / 96;
    int w = 14;// * sizeW / 14;
@@ -125,11 +124,9 @@ static void Button::ThumbOnRedraw(Surface surface)
    surface.HTile(middle.bitmap, x, y + sideH, w, middleH);
    surface.Stretch(right.bitmap, x, y + sideH + middleH, 0,0, w, sideH, right.bitmap.width, right.bitmap.height);
 
-   /*
-   surface.Filter(left.bitmap, x, y, 0,0, w, sideH, left.bitmap.width, left.bitmap.height);
-   surface.FilterVTile(middle.bitmap, x, y + sideH, w, middleH);
-   surface.Filter(right.bitmap, x, y + sideH + middleH, 0,0, w, sideH, right.bitmap.width, right.bitmap.height);
-   */
+   //surface.Filter(left.bitmap, x, y, 0,0, w, sideH, left.bitmap.width, left.bitmap.height);
+   //surface.FilterVTile(middle.bitmap, x, y + sideH, w, middleH);
+   //surface.Filter(right.bitmap, x, y + sideH + middleH, 0,0, w, sideH, right.bitmap.width, right.bitmap.height);
 }
 
 static bool Button::ThumbIsInside(int x, int y)
@@ -144,7 +141,7 @@ static void Button::ThumbSetBox(Box box)
    box.right -= 1;
    box.bottom += 6;
 }
-
+*/
 public class MySkin_ScrollBar : ScrollBar
 {
    void OnApplyGraphics()
@@ -197,7 +194,7 @@ public class MySkin_ScrollBar : ScrollBar
       {
 
       }
-      return true;
+      return result;
    }
 
    void OnRedraw(Surface surface)
@@ -318,7 +315,7 @@ public class MySkin_Button : Button
 }
 
 
-char * cursorsBitmaps[] =
+const char * cursorsBitmaps[] =
 {
    "<:ecere>cursors/arrow.png",
    "<:ecere>cursors/iBeam.png",
@@ -343,7 +340,7 @@ static Point cursorsHotSpots[] =
    { 5, 0 }
 };
 
-static char * skinBitmaps[SkinBitmap] =
+static const char * skinBitmaps[SkinBitmap] =
 {
    "<:ecere>elements/areaMinimize.png",
    "<:ecere>elements/areaMaximize.png",
@@ -366,7 +363,7 @@ public class MySkin : Skin
       return FontResource { faceName = "Tahoma", size = 10.0f, bold = true };
    }
 
-   char * ::CursorsBitmaps(uint id, int * hotSpotX, int *hotSpotY, byte ** paletteShades)
+   const char * ::CursorsBitmaps(uint id, int * hotSpotX, int *hotSpotY, byte ** paletteShades)
    {
       *hotSpotX = cursorsHotSpots[id].x;
       *hotSpotY = cursorsHotSpots[id].y;
@@ -517,7 +514,7 @@ public class MySkin_Window : Window
       *ch = Max(*ch, 0);
    }
 
-   void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
+   void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving)
    {
       if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
       {
@@ -539,7 +536,7 @@ public class MySkin_Window : Window
       }
    }
 
-   void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
+   void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving)
    {
       bool isNormal = (state == normal);
       int top = 0, border = 0, bottom = 0;
index ab23b2a..6f6923b 100644 (file)
@@ -76,7 +76,7 @@ class SlideShow : Window
          return strcmp(a.name, b.name);
    }
 
-   void AddDirectory(OldList files, char * directory)
+   void AddDirectory(OldList files, const char * directory)
    {
       FileListing listing { directory, "pcx, jpg, bmp, png" };
       OldList list { };
@@ -122,10 +122,10 @@ class SlideShow : Window
    {
       if(bitmap && bitmap.width)
       {
+#ifndef __linux__
          float scale = Min((float)clientSize.w / (float)bitmap.width, (float)clientSize.h / (float)bitmap.height);
          int w = (int)(bitmap.width * scale);
          int h = (int)(bitmap.height * scale);
-#ifndef __linux__
          surface.Filter(bitmap, (clientSize.w - w) / 2,(clientSize.h - h) / 2, 0,0, w, h, bitmap.width, bitmap.height);
 #else
          // Until Filter / Stretch works with X
index 0f1b12d..76672a4 100644 (file)
@@ -1,7 +1,12 @@
+#ifndef __WIN32__
+void XSync();
+void * IS_XGetDisplay();
+#endif
+
 import "ecere"
 
 define NUMFLAKES = 60;
-char * textString = "Let it snow!";
+const char * textString = "Let it snow!";
 define backgroundColor = Color { 10, 0, 60 };
 
 class Snowing : Window
@@ -115,14 +120,14 @@ class Snowing : Window
                   if(GetRandom(0, 4) == 0)
                   {
                      if(GetRandom(0, 1))
-                        (!atLeft && SnowTo(offset, stride-1)) || (!atRight && SnowTo(offset, stride+1));
+                        (void)((!atLeft && SnowTo(offset, stride-1)) || (!atRight && SnowTo(offset, stride+1)));
                      else
-                        (!atRight && SnowTo(offset, stride+1)) || (!atLeft && SnowTo(offset, stride-1));
+                        (void)((!atRight && SnowTo(offset, stride+1)) || (!atLeft && SnowTo(offset, stride-1)));
                   }
                }
                break;
-            case 1: (!atLeft && SnowTo(offset, stride-1)) || (GetRandom(0, 4) == 0 && SnowTo(offset, stride)) || (!atRight && SnowTo(offset, stride+1)); break;
-            case 2: (!atRight && SnowTo(offset, stride+1)) || (GetRandom(0, 4) == 0 && SnowTo(offset, stride)) || (!atLeft && SnowTo(offset, stride-1)); break;
+            case 1: (void)((!atLeft && SnowTo(offset, stride-1)) || (GetRandom(0, 4) == 0 && SnowTo(offset, stride)) || (!atRight && SnowTo(offset, stride+1))); break;
+            case 2: (void)((!atRight && SnowTo(offset, stride+1)) || (GetRandom(0, 4) == 0 && SnowTo(offset, stride)) || (!atLeft && SnowTo(offset, stride-1))); break;
          }
       }
    }
index 67df865..1b330f1 100644 (file)
@@ -54,7 +54,7 @@ public class TextScroller : Window
       delete contents;
    }
 
-   property String contents
+   property const String contents
    {
       set
       {
@@ -80,8 +80,9 @@ public class TextScroller : Window
          display.FontExtent(fontObject, lines[c], strlen(lines[c]), &w, null);
          if(w > maxW) maxW = w;
       }
-      snapVertScroll = lh; // Snap to line height vertically
-      snapHorzScroll = 1;
+      SetScrollLineStep(1, Max(1, lh));
+      snapVertScroll = true ;//lh; // Snap to line height vertically
+      //snapHorzScroll = 1;
       scrollArea = { maxW, lh * (linesCount-1) };
       return true;
    }
@@ -93,7 +94,6 @@ public class TextScroller : Window
       int ch = clientSize.h;
       for(c = 0; c < linesCount; c++, y += lh)
       {
-         int w;
          if(y > -lh && y < ch)
             surface.WriteText(x, y, lines[c], strlen(lines[c]));
       }
index 0bdf35d..0c42d20 100644 (file)
@@ -12,7 +12,7 @@ class Form1 : Window
 
    ListBox listBox1 { fullRowSelect = false, collapseControl = true, treeBranches = true, rootCollapseButton = true, parent = this, text = "listBox1", size = Size { 306, 432 }, anchor = Anchor { left = 10, top = 10, right = 0.5, bottom = 10 } };
 
-   void ListDirectory(DataRow addTo, char *path)
+   void ListDirectory(DataRow addTo, const char *path)
    {
       static int maxDepth = 0;
       FileListing listing { path };
@@ -29,7 +29,7 @@ class Form1 : Window
 
    bool OnCreate()
    {
-      String rootDir = (GetRuntimePlatform() == win32) ? "c:" : getenv("HOME");
+      const String rootDir = (GetRuntimePlatform() == win32) ? "c:" : getenv("HOME");
       DataRow row = listBox1.AddString(rootDir);
       ListDirectory(row, rootDir);
       return true;