672
665
case {VirtualCol, VirtualRow} of
673
666
{undefined, undefined} ->
674
667
update_marked_cells(CellId, CellId, false);
675
{AnyCol, undefined} ->
668
{_AnyCol, undefined} ->
676
669
NofColsShown = length(ColsShown),
677
670
unmark_col(VirtualCol, FirstColShown, FirstColShown + NofColsShown - 1,
679
{undefined, AnyRow} ->
672
{undefined, _AnyRow} ->
680
673
unmark_row(VirtualRow, FirstRowShown, FirstRowShown + NofRowsShown - 1,
725
718
col_ids = ColIds,
726
719
row_ids = RowIds} = GridP,
728
#mark_params{cell_id = CellId,
729
virtual_col = VirtualCol,
721
#mark_params{virtual_col = VirtualCol,
730
722
virtual_row = VirtualRow} = MarkP,
733
NewMarkP = case {VirtualCol, VirtualRow} of
734
{undefined, undefined} ->
735
NofColsShown = length(ColsShown),
736
move_marked_cell(FirstCol, FirstRow, NofColsShown,
737
NofRowsShown, RowIds, MarkP);
738
{AnyCol, undefined} ->
739
NofColsShown = length(ColsShown),
740
OldLastCol = OldFirstCol + NofColsShown - 1,
741
LastCol = FirstCol + NofColsShown - 1,
742
move_marked_col(VirtualCol, OldFirstCol, OldLastCol,
743
FirstCol, LastCol, ColIds, MarkP);
744
{undefined, AnyRow} ->
745
OldLastRow = OldFirstRow + NofRowsShown - 1,
746
LastRow = FirstRow + NofRowsShown - 1,
747
move_marked_row(VirtualRow, OldFirstRow, OldLastRow,
748
FirstRow, LastRow, RowIds, MarkP);
749
{CellCol, CellRow} ->
750
NofColsShown = length(ColsShown),
751
move_marked_cell(FirstCol, FirstRow, NofColsShown,
752
NofRowsShown, RowIds, MarkP)
725
case {VirtualCol, VirtualRow} of
726
{undefined, undefined} ->
727
NofColsShown = length(ColsShown),
728
move_marked_cell(FirstCol, FirstRow, NofColsShown,
729
NofRowsShown, RowIds, MarkP);
730
{_AnyCol, undefined} ->
731
NofColsShown = length(ColsShown),
732
OldLastCol = OldFirstCol + NofColsShown - 1,
733
LastCol = FirstCol + NofColsShown - 1,
734
move_marked_col(VirtualCol, OldFirstCol, OldLastCol,
735
FirstCol, LastCol, ColIds, MarkP);
736
{undefined, _AnyRow} ->
737
OldLastRow = OldFirstRow + NofRowsShown - 1,
738
LastRow = FirstRow + NofRowsShown - 1,
739
move_marked_row(VirtualRow, OldFirstRow, OldLastRow,
740
FirstRow, LastRow, RowIds, MarkP);
741
{_CellCol, _CellRow} ->
742
NofColsShown = length(ColsShown),
743
move_marked_cell(FirstCol, FirstRow, NofColsShown,
744
NofRowsShown, RowIds, MarkP)
789
780
NofColsShown = length(ColsShown),
790
781
move_marked_cell(FirstCol, FirstRow, NofColsShown, NofRowsShown,
792
{AnyCol, undefined} ->
783
{_AnyCol, undefined} ->
793
784
NofColsShown = length(ColsShown),
794
785
LastCol = FirstCol + NofColsShown - 1,
795
786
mark_col(VirtualCol, FirstCol, LastCol, ColIds, ?GRID_MARK_COLOR);
796
{undefined, AnyRow} ->
787
{undefined, _AnyRow} ->
797
788
LastRow = FirstRow + NofRowsShown - 1,
798
789
mark_row(VirtualRow, FirstRow, LastRow, RowIds, ?GRID_MARK_COLOR);
799
{CellCol, CellRow} ->
790
{_CellCol, _CellRow} ->
800
791
NofColsShown = length(ColsShown),
801
792
move_marked_cell(FirstCol, FirstRow, NofColsShown, NofRowsShown,
844
835
%%======================================================================
847
mark_col(VirtualCol, FirstCol, LastCol, ColIds, Color) when VirtualCol < FirstCol ->
849
mark_col(VirtualCol, FirstCol, LastCol, ColIds, Color) when VirtualCol > LastCol ->
851
mark_col(VirtualCol, FirstCol, LastCol, ColIds, Color) ->
838
mark_col(VirtualCol, FirstCol, _LastCol, _ColIds, _Color) when VirtualCol < FirstCol ->
840
mark_col(VirtualCol, _FirstCol, LastCol, _ColIds, _Color) when VirtualCol > LastCol ->
842
mark_col(VirtualCol, FirstCol, _LastCol, ColIds, Color) ->
852
843
RealCol = VirtualCol - FirstCol + 1,
853
844
MarkedColIds = lists:nth(RealCol, ColIds),
854
845
mark_all_cells(MarkedColIds, Color).
916
907
%%======================================================================
919
mark_row(VirtualRow, FirstRow, LastRow, RowIds, Color) when VirtualRow < FirstRow ->
921
mark_row(VirtualRow, FirstRow, LastRow, RowIds, Color) when VirtualRow > LastRow ->
923
mark_row(VirtualRow, FirstRow, LastRow, RowIds, Color) ->
910
mark_row(VirtualRow, FirstRow, _LastRow, _RowIds, _Color) when VirtualRow < FirstRow ->
912
mark_row(VirtualRow, _FirstRow, LastRow, _RowIds, _Color) when VirtualRow > LastRow ->
914
mark_row(VirtualRow, FirstRow, _LastRow, RowIds, Color) ->
924
915
RealRow = VirtualRow - FirstRow + 1,
925
916
MarkedRowIds = lists:nth(RealRow, RowIds),
926
917
mark_all_cells(MarkedRowIds, Color).
1036
1027
%%======================================================================
1039
check_if_new_mark_visible(Col, Row, NofCols, NofRows) when Col > NofCols ->
1041
check_if_new_mark_visible(Col, Row, NofCols, NofRows) when Col =< 0 ->
1043
check_if_new_mark_visible(Col, Row, NofCols, NofRows) when Row > NofRows ->
1045
check_if_new_mark_visible(Col, Row, NofCols, NofRows) when Row =< 0 ->
1047
check_if_new_mark_visible(Col, Row, NofCols, NofRows) ->
1030
check_if_new_mark_visible(Col, _Row, NofCols, _NofRows) when Col > NofCols ->
1032
check_if_new_mark_visible(Col, _Row, _NofCols, _NofRows) when Col =< 0 ->
1034
check_if_new_mark_visible(_Col, Row, _NofCols, NofRows) when Row > NofRows ->
1036
check_if_new_mark_visible(_Col, Row, _NofCols, _NofRows) when Row =< 0 ->
1038
check_if_new_mark_visible(_Col, _Row, _NofCols, _NofRows) ->
1068
1059
%%======================================================================
1071
update_marked_cells(CellId, OldCellId, MarkedCell) when CellId == OldCellId ->
1062
update_marked_cells(CellId, OldCellId, _MarkedCell) when CellId == OldCellId ->
1072
1063
gs:config(CellId, [{bg, ?DEFAULT_GRID_BGCOLOR}]);
1073
update_marked_cells(CellId, undefined, false) ->
1064
update_marked_cells(_CellId, undefined, false) ->
1075
1066
update_marked_cells(CellId, undefined, true) ->
1076
1067
gs:config(CellId, [{bg, ?GRID_MARK_COLOR}]);
1077
1068
update_marked_cells(CellId, OldCellId, true) ->
1078
1069
gs:config(OldCellId, [{bg, ?DEFAULT_GRID_BGCOLOR}]),
1079
1070
gs:config(CellId, [{bg, ?GRID_MARK_COLOR}]);
1080
update_marked_cells(CellId, OldCellId, false) ->
1071
update_marked_cells(_CellId, OldCellId, false) ->
1081
1072
gs:config(OldCellId, [{bg, ?DEFAULT_GRID_BGCOLOR}]).
1138
1129
refresh_visible_rows([], _FirstColShown, _NofColsShown, _DataList, _ListAsStr) ->
1140
refresh_visible_rows(RowIds, FirstColShown, NofColsShown, [], ListAsStr) ->
1131
refresh_visible_rows(RowIds, _FirstColShown, _NofColsShown, [], _ListAsStr) ->
1141
1132
clear_cols_or_rows(RowIds);
1142
1133
refresh_visible_rows([OneRowIds | RemRowIds], FirstColShown, NofColsShown,
1143
1134
[DataItemList | RemDataItemLists], ListAsStr) ->
1167
1158
update_visible_rows([], _FirstColShown, _NofColsShown, _DataList, _ListAsStr) ->
1169
update_visible_rows(RowIds, FirstColShown, NofColsShown, [], _ListAsStr) ->
1160
update_visible_rows(RowIds, _FirstColShown, _NofColsShown, [], _ListAsStr) ->
1170
1161
clear_cols_or_rows(RowIds);
1171
1162
update_visible_rows([OneRowIds | RemRowIds], FirstColShown, NofColsShown,
1172
1163
[DataItem | RemData], ListAsStr) ->
1244
1235
make_row_data_list(N, NofRows, []) ->
1245
1236
% If NofRows == N, we get the empty list here!
1246
1237
lists:duplicate(NofRows- N, notext);
1247
make_row_data_list(N, NofRows, [DataItem | RemData]) when N > NofRows ->
1238
make_row_data_list(N, NofRows, [_DataItem | _RemData]) when N > NofRows ->
1249
1240
make_row_data_list(N, NofRows, [DataItem | RemData]) ->
1250
1241
% We convert the received item to a list! This way we know that
1492
1483
%%======================================================================
1495
check_nof_cols(ColsShown, NofNewCols, ColFrameIds, ColIds, RowIds,
1496
NofRows, RowHeight, FgColor, BgColor) when NofNewCols =< 0 ->
1486
check_nof_cols(_ColsShown, NofNewCols, ColFrameIds, ColIds, RowIds,
1487
_NofRows, _RowHeight, _FgColor, _BgColor) when NofNewCols =< 0 ->
1497
1488
{length(ColFrameIds), ColFrameIds, ColIds, RowIds};
1498
1489
check_nof_cols(ColsShown, NofNewCols, ColFrameIds, ColIds,
1499
1490
RowIds, NofRows, RowHeight, FgColor, BgColor) ->
1505
1496
% values on these important parameters, then he can only blame himself.
1506
1497
ParentId = lists:nth((NewColNo - 1), ColFrameIds),
1507
1498
ParentColWidth = lists:nth((NewColNo - 1), ColsShown),
1508
NewColWidth = lists:nth(NewColNo, ColsShown),
1509
1499
Xpos = ParentColWidth + 1,
1511
1501
{ColFrameId, LabelIds} = add_one_col_frame(ParentId, NewColNo, Xpos, FgColor,
1671
1661
%%======================================================================
1674
compute_cols_shown(FirstColShown, ColWidths, GridWidth, NofCols, DefaultColWidth) ->
1664
compute_cols_shown(FirstColShown, ColWidths, GridWidth, _NofCols, DefaultColWidth) ->
1675
1665
ColWidthsLength = length(ColWidths),
1676
1666
% Normally ColWidths shall be long enough, but just to make sure...
1677
1667
% (We could have chosen to update ColWidths here to, but right now
1755
1745
%%======================================================================
1758
create_col_frames(0, NofRows, RowHeight, ParentId, GridP, ColFrameAcc, LabelAcc) ->
1748
create_col_frames(0, _NofRows, _RowHeight, _ParentId, _GridP, ColFrameAcc, LabelAcc) ->
1759
1749
{lists:reverse(ColFrameAcc), lists:reverse(LabelAcc)};
1760
1750
create_col_frames(N, NofRows, RowHeight, ParentId, GridP, ColFrameAcc, LabelAcc) ->
1761
1751
% Yes, it *IS* inefficient to copy GridP for each loop.
1851
1841
%%======================================================================
1854
create_rows_on_frame(FrameId, RowNo, NofRows, H, Y, Fg, Bg, ColNo, Acc) when RowNo > NofRows ->
1844
create_rows_on_frame(_FrameId, RowNo, NofRows, _H, _Y, _Fg, _Bg, _ColNo, Acc) when RowNo > NofRows ->
1855
1845
lists:reverse(Acc);
1856
1846
create_rows_on_frame(FrameId, RowNo, NofRows, H, Y, Fg, Bg, ColNo, RAcc) ->