ecere/gui/DropBox: Added lastRow property
[sdk] / ecere / src / gui / controls / DropBox.ec
index 8a791ea..9f56dbf 100644 (file)
@@ -24,22 +24,11 @@ public class DropBox : CommonControl
 
    class_property(icon) = "<:ecere>controls/dropBox.png";
 
-   watch(foreground)
-   {
-      listBox.foreground = foreground;
-   };
-   watch(background)
-   {
-      listBox.background = background;
-   };
-   watch(selectionColor)
-   {
-      listBox.selectionColor = selectionColor;
-   };
-   watch(selectionText)
-   {
-      listBox.selectionText = selectionText;
-   };
+   watch(foreground)     { listBox.foreground = foreground;         if(editBox) editBox.foreground = foreground; };
+   watch(background)     { listBox.background = background;         if(editBox) editBox.background = background; };
+   watch(selectionColor) { listBox.selectionColor = selectionColor; if(editBox) editBox.selectionColor = selectionColor; };
+   watch(selectionText)  { listBox.selectionText = selectionText;   if(editBox) editBox.selectionText = selectionText; };
+   watch(opacity)        { listBox.opacity = opacity;               if(editBox) editBox.opacity = opacity; };
 
 public:
    property bool activeStipple
@@ -113,7 +102,7 @@ public:
             {
                char tempString[4096];
                if(currentRow)
-                  editBox.contents = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
+                  editBox.contents = ((const char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
                else
                   editBox.contents = "";
             }
@@ -132,7 +121,8 @@ public:
       get { return currentRow; }
    };
    property DataRow firstRow { get { return this ? listBox.firstRow : null; } };
-   property char * contents { property_category $"Data" set { if(editBox) editBox.contents = value; } get { return editBox ? editBox.contents : null; } };
+   property DataRow lastRow { get { return this ? listBox.lastRow : null; } };
+   property const char * contents { property_category $"Data" set { if(editBox) editBox.contents = value; } get { return editBox ? editBox.contents : null; } };
    property bool editText
    {
       property_category $"Behavior"
@@ -149,6 +139,10 @@ public:
                      this, textHorzScroll = true, borderStyle = 0;
                      anchor = Anchor { left = 0, top = 0, right = BTN_WIDTH, bottom = 0 };
                      // visible = false, modifyVirtualArea = false;
+                     foreground = foreground;
+                     background = background;
+                     selectionColor = selectionColor;
+                     selectionText = selectionText;
                   };
                   incref editBox;
                   editBox.Create();
@@ -224,7 +218,7 @@ public:
    virtual bool Window::NotifySelect(DropBox dropBox, DataRow row, Modifiers mods);
    virtual bool Window::NotifyClose(DropBox dropBox);
    virtual bool Window::NotifyHighlight(DropBox dropBox, DataRow row, Modifiers mods);
-   virtual bool Window::NotifyTextEntry(DropBox dropBox, char * string, bool confirmed);
+   virtual bool Window::NotifyTextEntry(DropBox dropBox, const char * string, bool confirmed);
 
    virtual Window OnDropDown()
    {
@@ -250,7 +244,7 @@ public:
    }
 
    // Methods
-   DataRow AddStringf(char * format, ...)
+   DataRow AddStringf(const char * format, ...)
    {
       if(this)
       {
@@ -271,7 +265,7 @@ public:
       return null;
    }
 
-   DataRow AddString(char * string)
+   DataRow AddString(const char * string)
    {
       if(this)
       {
@@ -311,12 +305,7 @@ public:
 
    any_object GetData(DataField field)
    {
-      if(this)
-      {
-         // TODO: Fix this shouldn't be required (memguard?)
-         return (void *)currentRow.GetData(field);
-      }
-      return null;
+      return this ? currentRow.GetData(field) : null;
    }
 
    void Sort(DataField field, int order)
@@ -413,7 +402,7 @@ public:
          {
             char tempString[4096];
             if(currentRow)
-               editBox.contents = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
+               editBox.contents = ((const char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
             else
                editBox.contents = "";
          }
@@ -589,7 +578,7 @@ private:
                {
                   char tempString[4096];
                   if(currentRow)
-                     editBox.contents = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
+                     editBox.contents = ((const char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
                   else
                      editBox.contents = "";
                }
@@ -886,7 +875,7 @@ private:
          {
             char tempString[4096];
             if(currentRow)
-               editBox.contents = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
+               editBox.contents = ((const char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, currentRow.GetData(null), tempString, null, null);
             else
                editBox.contents = "";
             if(active)