What design should be used so that a class can request one of its ancestors?

I am creating a hierarchy of objects representing a table drawn on a control. My hierarchy is as follows:

Table has multiple pages
Page has multiple lines
Line has multiple cells
Cell has multiple glyph

I want to have a parameter (parameter) in a table to filter the displayed column (s). The client code might do something like this:

myTable.ShowColumns(8,12) // Will display columns 8 to 12

Displaying and placing cells in a control is the responsibility of Lines. How to pass information about which cells should be displayed from the Table object to the Line object?

Should I give each row a link to a table object? Should I try to pass information to each row in the hierarchy every time it is called Table.ShowColumns()?

Should there be an elegant way?

+3
2

, . ( ) , ?

+2

, , , , , tree. , .

ShowColumns, , Lines ( ) Lines.

// something like this..
Table.ShowCollumns -> Table.m_lines.SetVisibleColumns -> (modify visible columns)

, SetVisibleColumns Lines, : Table.FindPageWithColumns(...), .

+1

Source: https://habr.com/ru/post/1724391/


All Articles