For fpspreadsheet I would like to implement the feature of Excel or Libre/OpenOffice that multiple cell ranges can be selected. The grid component in this package, TsSpreadsheetGrid, currently can select only a single range (if goRangeSelect is in the grid's Options) due to its inheritance from TCustomGrid.

My idea is to add a new "goMultiSelect" option to TCustomGrid directly since this might be an interesting feature for other applications as well, and then to write additional code to store multiple range rectangles. It shouldn't be too difficult, but I am failing already at the very first step: adding the new option to the type TGridOption. This is the new declaration:

type
  TGridOption = (
    goFixedVertLine,      // Ya
    goFixedHorzLine,      // Ya
    goVertLine,           // Ya
    goHorzLine,           // Ya
    goRangeSelect,        // Ya
    goDrawFocusSelected,  // Ya
    goRowSizing,          // Ya
    goColSizing,          // Ya
    goRowMoving,          // Ya
    goColMoving,          // Ya
    goEditing,            // Ya
    goAutoAddRows,        // JuMa
    goTabs,               // Ya
    goRowSelect,          // Ya
    goAlwaysShowEditor,   // Ya
    goThumbTracking,      // ya
    // Additional Options
    goColSpanning,        // Enable cellextent calcs
    goRelaxedRowSelect,   // User can see focused cell on goRowSelect
goDblClickAutoSize, // dblclicking columns borders (on hdrs) resize col. goSmoothScroll, // Switch scrolling mode (pixel scroll is by default)
    goFixedRowNumbering,  // Ya
    goScrollKeepVisible,  // keeps focused cell visible while scrolling
goHeaderHotTracking, // Header cells change look when mouse is over them
    goHeaderPushedLook,   // Header cells looks pushed when clicked
    goSelectionActive,    // Setting grid.Selection moves also cell cursor
    goFixedColSizing,     // Allow to resize fixed columns
goDontScrollPartCell, // clicking partially visible cells will not scroll
    goCellHints,          // show individual cell hints
    goTruncCellHints,     // show cell hints if cell text is too long
    goCellEllipsis,       // show "..." if cell text is too long
goAutoAddRowsSkipContentCheck,//BB Also add a row (if AutoAddRows in Options) if last row is empty
    goRowHighlight,       // Highlight the current Row
    goMultiSelect         // Enable selection of multiple ranges <<<< NEW
  );
  TGridOptions = set of TGridOption;

Recompiling the package LCLBase fails with the error: "Property can't have a default value". I think this message is misleading and confusing because the true issue seems to me that the set of TGridOptions now contains 33 elements. In my understanding, the elements of a set correspond to the bits of an integer. In a 32-bit OS, therefore, a set can only contain 32 elements - there is one too many now...

Is this interpretation correct?

OK, here I could circumvent this issue by introducing a new boolean property "MultiSelect" which is evaluated when goRangeSelect is active. Maybe this is even better than the goMultiSelect option because it bypasses the conflict with goRangeSelect.

But what if I would not have this possibility? Is there a way to extend the set to more than 32 elements? If not, split the Options into groups of options like VirtualTreeView does? I fear the options of the grid components will require a major redsign soon.

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to