Ejemplo n.º 1
0
        // It seems if using own TreeViewSearchEqualFunc one cannot use default function anymore.
        // Function getter returns null and null is not allowed.
        // Workaround: define own functions for all needed column types.

        // FALSE if the row does MATCH, otherwise true !!!
        bool TreeViewSearchFunc(TreeModel model, int column, string key, TreeIter iter)
        {
            object content = model.GetValue(iter, column);

            GLib.GType gt = model.GetColumnType(column);
            if (gt == GLib.GType.Float)
            {
                return(EqualFuncFloat(key, (float)content));
            }
            else if (gt == GLib.GType.String)
            {
                return(EqualFuncString(key, (string)content));
            }

            // type int needs further info!
            switch ((ColumnNr2D)column)
            {
            case ColumnNr2D.Location:
            case ColumnNr2D.XPos:
            case ColumnNr2D.YPos:
                return(EqualFuncHex(key, (int)content));

            case ColumnNr2D.Type:
                return(EqualFuncTableType(key, (Tables.TableType)content));

            case ColumnNr2D.CountX:
                return(EqualFuncInt(key, (int)content));

            default:
                // cannot search on icon column, must signal true = no match.
                return(true);
            }
        }
Ejemplo n.º 2
0
        // It seems if using own TreeViewSearchEqualFunc one cannot use default function anymore.
        // Function getter returns null and null is not allowed.
        // Workaround: define own functions for all needed column types.
        // FALSE if the row does MATCH, otherwise true !!!
        bool TreeViewSearchFunc(TreeModel model, int column, string key, TreeIter iter)
        {
            object content = model.GetValue (iter, column);

            GLib.GType gt = model.GetColumnType (column);
            if (gt == GLib.GType.Float)
                return EqualFuncFloat (key, (float)content);
            else if (gt == GLib.GType.String)
                return EqualFuncString (key, (string)content);

            // type int needs further info!
            switch ((ColumnNr2D)column) {
            case ColumnNr2D.Location:
            case ColumnNr2D.XPos:
            case ColumnNr2D.YPos:
                return EqualFuncHex (key, (int)content);
            case ColumnNr2D.Type:
                return EqualFuncTableType (key, (Tables.TableType)content);
            case ColumnNr2D.CountX:
                return EqualFuncInt (key, (int)content);
            default:
                // cannot search on icon column, must signal true = no match.
                return true;
            }
        }