sdk: const correctness
[sdk] / ecere / src / gui / controls / PathBox.ec
index 73a0883..d724db2 100644 (file)
@@ -3,7 +3,7 @@ import "Window"
 import "Array"
 
 default extern int __ecereVMethodID_class_OnGetDataFromString;
-default static void _workAround()
+default __attribute__((unused)) static void _workAround()
 {
    int a;
    a.OnGetDataFromString(0);
@@ -109,22 +109,15 @@ public class PathBox : CommonControl
    borderStyle = deep;
    clientSize = { 64, 18 };
 
-   watch(background) { editBox.background = background; };
-   watch(foreground) { editBox.foreground = foreground; };
-   watch(opacity)    { editBox.opacity    = opacity; };
-
-#if defined(__WIN32__)
-   PathBox()
-   {
-      path[0] = '\0';
-   }
-#endif
+   watch(background)     { editBox.background = background; };
+   watch(foreground)     { editBox.foreground = foreground; };
+   watch(selectionColor) { editBox.selectionColor = selectionColor; };
+   watch(selectionText)  { editBox.selectionText = selectionText; };
+   watch(opacity)        { editBox.opacity = opacity; };
 
    PathTypeExpected typeExpected;
    FileDialog browseDialog;
-#if defined(__WIN32__)
    char path[MAX_LOCATION];
-#endif
 
    BitmapResource file { "<:ecere>mimeTypes/file.png", transparent = true, alphaBlend = true };
    BitmapResource brokenFile { "<:ecere>mimeTypes/brokenFile.png", transparent = true, alphaBlend = true };
@@ -186,21 +179,24 @@ public class PathBox : CommonControl
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
+         if(modifiedDocument)
+            NotifyModified(master, this);
+
          if(browseDialog)
          {
             char browsePath[MAX_LOCATION];
-            char * baseBrowsePath = null;
             PathBox pathBox = this;
             DataBox dataBox = pathBoxDataBox;
             ListBox listBox;
             DirectoriesBox dirsBox = pathBoxDirsBox;
-            char * ebContents = editBox.contents;
+            const char * ebContents = editBox.contents;
             String backFilePath = CopyString(browseDialog.filePath);
+            char * baseBrowsePath = dirsBox ? dirsBox.baseBrowsePath : null;
 
             browsePath[0] = '\0';
             strncpy(browsePath, browseDialog.filePath, MAX_LOCATION); browsePath[MAX_LOCATION-1] = '\0';
-            if(dirsBox && dirsBox.baseBrowsePath && dirsBox.baseBrowsePath[0] && ((ebContents && ebContents[0]) || !backFilePath || !backFilePath[0]))
-               PathCat(browsePath, dirsBox.baseBrowsePath);
+            if(baseBrowsePath && baseBrowsePath[0] && ((ebContents && ebContents[0]) || !backFilePath || !backFilePath[0]))
+               PathCat(browsePath, baseBrowsePath);
             PathCat(browsePath, ebContents);
             browseDialog.filePath = (ebContents && ebContents[0]) ? browsePath : "";
             if(pathBox.typeExpected == directory && browsePath[0] && FileExists(browsePath).isDirectory && backFilePath && backFilePath[0])
@@ -341,7 +337,7 @@ public:
    void SelectAll() { editBox.SelectAll(); }
    void Deselect() { editBox.Deselect(); }
 
-   property String path
+   property const String path
    {
       set
       {
@@ -382,8 +378,11 @@ public:
    virtual bool OnPrepareBrowseDir(char ** directory);
    virtual bool OnBrowsedDir(char ** directory);
 
-   watch(foreground) { list.foreground = foreground; };
-   watch(background) { list.background = background; };
+   watch(foreground)     { list.foreground = foreground; };
+   watch(background)     { list.background = background; };
+   //watch(selectionColor) { list.selectionColor = selectionColor; };
+   //watch(selectionText)  { list.selectionText = selectionText; };
+   watch(opacity)        { list.opacity = opacity; };
 
    property Array<String> strings
    {
@@ -408,7 +407,7 @@ public:
          DataRow row;
          for(row = list.firstRow; row; row = row.next)
          {
-            String string = row.string;
+            const String string = row.string;
             if(string && string[0])
                array.Add(CopyUnixPath(string));
          }
@@ -572,11 +571,7 @@ public:
                listBox.SetData(null, dir);
                listBox.modifiedDocument = true;
                if(listBox.currentRow == listBox.lastRow && listBox.lastRow.string)
-               {
-                  DataRow r = listBox.lastRow;
-                  char * s = r.string;
                   listBox.currentRow = listBox.AddString("");
-               }
             }
             delete dir;
          }