Example #1
0
        public LBItem ItemOf(string S)
        {
            LBItem result = null;

            int num = fList.Count;

            for (int i = 0; i < num; i++)
            {
                LBItem item = (LBItem)fList[i];

                if (item.Text.CompareTo(S) == 0)
                {
                    result = item;
                }
                else
                {
                    result = item.SubItems.ItemOf(S);
                }

                if (result != null)
                {
                    break;
                }
            }

            return(result);
        }
Example #2
0
        public LBItem Add(string S, object aData)
        {
            Changing();

            int lev;

            if (fParentItem == null)
            {
                lev = 0;
            }
            else
            {
                lev = fParentItem.Level + 1;
            }

            LBItem Result = new LBItem(fOwner, lev);

            Result.Text       = S;
            Result.Data       = aData;
            Result.List       = this;
            Result.ImageIndex = -1;
            fList.Add(Result);
            if (Sorted)
            {
                Sort();
            }
            fOwner.Reset(true);
            Changed();
            return(Result);
        }
Example #3
0
 public LBItemList(ListBox owner, LBItem parentItem)
 {
     fList       = new ExtList <LBItem>();
     fOwner      = owner;
     fParentItem = parentItem;
     fSorted     = false;
 }
Example #4
0
        public LBItem GetItem(int index)
        {
            LBItem result = null;

            if (index >= 0 && index < fList.Count)
            {
                result = ((LBItem)fList[index]);
            }
            return(result);
        }
Example #5
0
 public LBItem(ListBox owner, int level)
 {
     Color     = Colors.Gold;
     Checked   = false;
     Data      = null;
     fLevel    = (int)level;
     fOwner    = owner;
     fParent   = null;
     fSubItems = new LBItemList(fOwner, this);
     Text      = "";
 }
Example #6
0
        protected virtual void DoPaintSubItem(BaseScreen screen, LBItem item, int itemIndex, int subIndex, ExtRect subRect)
        {
            if (fSelIndex == itemIndex)
            {
                screen.DrawRectangle(subRect, SelColor, SelBorderColor);
            }
            int tx = subRect.Left + 3;
            int ty = subRect.Top + (subRect.Bottom - subRect.Top - Font.Height) / 2;

            screen.DrawText(tx, ty, item.SubItems.GetItem(subIndex).Text, 0);
        }
Example #7
0
        public void Delete(int Index)
        {
            Changing();
            LBItem item = GetItem(Index);

            if (item != null)
            {
                item.Dispose();
            }
            fList.Delete(Index);
            Changed();
        }
Example #8
0
        private void ReindexList(LBItemList aList, ref int aIndex)
        {
            int num = aList.Count;

            for (int i = 0; i < num; i++)
            {
                aIndex++;
                LBItem item = aList.GetItem(i);
                item.AbsoluteIndex = aIndex;
                item.VisibleIndex  = aIndex;
                fColumnSize++;
            }
        }
Example #9
0
        public int IndexOf(LBItem item)
        {
            int num = fList.Count;

            for (int i = 0; i < num; i++)
            {
                if (fList[i].Equals(item))
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #10
0
        public int IndexOf(string S)
        {
            int num = fList.Count;

            for (int i = 0; i < num; i++)
            {
                LBItem item = (LBItem)fList[i];
                if (item.Text.CompareTo(S) == 0)
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #11
0
        public LBItem GetAbsoluteItem(int index)
        {
            LBItem result = fItems.GetItem(index);

            return(result);
        }
Example #12
0
 protected virtual void DoSelectItem(object Sender, MouseButton Button, int aX, int aY, LBItem Item, ExtRect aRect)
 {
     if (Options.Contains(LBOptions.lboChecks))
     {
         int     d         = (aRect.Bottom - aRect.Top - CheckHeight) / 2;
         ExtRect checkRect = aRect;
         checkRect.Right = checkRect.Left + CheckWidth + (d << 1);
         if (checkRect.Contains(aX, aY) || Options.Contains(LBOptions.lboRadioChecks))
         {
             DoCheck(fSelIndex);
         }
     }
     if (OnItemSelect != null)
     {
         OnItemSelect.Invoke(this, Button, Item);
     }
 }
Example #13
0
        protected override void DoPaintEvent(BaseScreen screen)
        {
            ExtRect crt = ClientRect;

            if ((ControlStyle.Contains(ControlStyles.сsOpaque)))
            {
                screen.FillRect(crt, Colors.Black);
            }
            screen.SetTextColor(Colors.Gold, true);
            CtlCommon.DrawCtlBorder(screen, crt);

            switch (fMode)
            {
            case MODE_LIST:
            case MODE_ICONS:
            {
                for (int col = 0; col < fColumns; col++)
                {
                    int lb = fTopIndex + col * fColumnSize;
                    int hb = lb + (fVisibleItems - 1);
                    if (hb >= fItems.Count)
                    {
                        hb = fItems.Count - 1;
                    }
                    int defColor = screen.GetTextColor(true);

                    for (int i = lb; i <= hb; i++)
                    {
                        LBItem item = fItems.GetItem(i);
                        DoPaintItem(screen, item, i, GetItemRect(i, -1));
                    }
                    screen.SetTextColor(defColor, true);
                }
            }
            break;

            case MODE_REPORT:
            {
                int lb = fTopIndex;
                int hb = lb + (fVisibleItems - 1);
                if (hb >= fItems.Count)
                {
                    hb = fItems.Count - 1;
                }

                for (int i = lb; i <= hb; i++)
                {
                    LBItem item = fItems.GetItem(i);

                    int defColor = screen.GetTextColor(true);
                    DoPaintItem(screen, item, i, GetItemRect(i, -1));
                    screen.SetTextColor(defColor, true);

                    int num2 = item.SubItems.Count;
                    for (int j = 0; j < num2; j++)
                    {
                        defColor = screen.GetTextColor(true);
                        DoPaintSubItem(screen, item, i, j, GetItemRect(i, j));
                        screen.SetTextColor(defColor, true);
                    }
                }
            }
            break;
            }
        }
Example #14
0
        protected virtual void DoPaintItem(BaseScreen screen, LBItem item, int itemIndex, ExtRect itemRect)
        {
            if (fSelIndex == itemIndex)
            {
                screen.DrawRectangle(itemRect, SelColor, SelBorderColor);
            }

            int ih = ItemHeight;
            int tx = itemRect.Left + 2;
            int ty;

            if (Options.Contains(LBOptions.lboTextTop))
            {
                ty = itemRect.Top + 1;
            }
            else
            {
                ty = itemRect.Top + (ih - Font.Height) / 2;
            }

            if (Options.Contains(LBOptions.lboChecks))
            {
                int cd = (ih - CheckHeight) / 2;
                int cx = itemRect.Left + cd;
                int cy = itemRect.Top + cd;
                if (item.Checked)
                {
                    screen.DrawImage(cx, cy, 0, 16, 16, 17, CheckImage, 255);
                }
                else
                {
                    screen.DrawImage(cx, cy, 0, 0, 16, 17, CheckImage, 255);
                }
                tx = itemRect.Left + CheckWidth + (cd << 1);
            }

            if (Options.Contains(LBOptions.lboIcons))
            {
                if (ImagesList != null && item.ImageIndex > -1)
                {
                    ImagesList.DrawImage(screen, tx, itemRect.Top + (ItemHeight - fIconHeight) / 2, item.ImageIndex, 255);
                }
                tx = tx + fIconWidth + 2;
            }

            if (fMode != MODE_ICONS)
            {
                Font.Color = item.Color;
                if (Options.Contains(LBOptions.lboDoubleItem))
                {
                    StringList lst = new StringList();
                    lst.Text = item.Text;
                    screen.DrawText(tx, ty, lst[0], 0);
                    if (lst.Count > 1)
                    {
                        screen.DrawText(tx, ty + CtlCommon.SmFont.Height, lst[1], 0);
                    }
                    lst.Dispose();
                }
                else
                {
                    screen.DrawText(tx, ty, item.Text, 0);
                }
            }

            if (OnItemDraw != null)
            {
                OnItemDraw.Invoke(this, screen, itemIndex, itemRect);
            }
        }