Next Generation Containers.

From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Sun Apr 21 2002 - 10:55:01 EDT

  • Next message: Andrew Dunbar: "Re: commit: abi: UTF8String class"

    Hi Folks,
            Now is the time to start discussing the next generation layout
    code. The idea of course is to rewrite as little as possible of our
    current code. AbiWord 1.2 will support tables and footnotes but I thiunk
    we should design our next gen code to easily handle other advanced layout
    objects like text frames, positioned images and to allow text to flow
    around images and other embedded objects.

    Here is one suggestion on how to acheive that.

    To start with I'll recap how text is layed out on fp_Page.

      ===================================================================
      | |
      | Fixed size header |
      | |
      -------------------------------------------------------------------
      | |
      | ============================ ============================= |
      | | -------Line 1----------- | | ----------Line 1----------| |
      | | ------ Line 2 ---------- | | --------- Line 2 ---------| |
      | | ----Column 1 --------- | | ------- Column 2 ---------| |
      | | -------Line 4----------- | | ----------Line 4----------| |
      | | ------ Line 5 ---------- | | --------- Line 5 ---------| |
      | | -------Line 6----------- | | ----------Line 6 ---------| |
      | | ------ Line 7 ---------- | | --------- Line 7 ---------| |
      | ============================ ============================= |
      | ============================ ============================= |
      | | -------Line 1----------- | | ----------Line 1----------| |
      | | ------ Line 2 ---------- | | --------- Line 2 ---------| |
      | | ----Column 3 --------- | | ------- Column 4 ---------| |
      | | -------Line 4----------- | | ----------Line 4----------| |
      | | ------ Line 5 ---------- | | --------- Line 5 ---------| |
      | | -------Line 6----------- | | ----------Line 6 ---------| |
      | | ------ Line 7 ---------- | | --------- Line 7 ---------| |
      | ============================ ============================= |
      -------------------------------------------------------------------
      | |
      | Fixed size Footer |
      | |
      ===================================================================

    Images are embedded in lines. If an image is large it expands the height
    of a line.

    The lines are contained as a vector in the class fp_Column which derives
    from the base class fp_Container.

    Here is what we like to layout on a page.

      ===================================================================
      | |
      | Fixed size header |
      | |
      -------------------------------------------------------------------
      | |
      | ============================ ============================= |
      | | -------Line 1----------- | | ----------Line 1----------| |
      | | ---Column 1 ------------ | | ----------Line 2----------| |
      | | ======================= | | ------- Column 2 ---------| |
      | | | | | | ----------Line 4----------| |
      | | | embedded container | | | --------- Line 5 ---------| |
      | | | | | | ----------Line 6 ---------| |
      | | ======================| | | --------- Line 7 ---------| |
      | ============================ ============================= |
      | ============================================================= |
      | | | |
      | | Fill width column containing a table or frame | |
      | | | |
      | |===========================================================| |
      | ============================ ============================= |
      | | -------Line 1----------- | | ----------Line 1----------| |
      | | ------ Line 2 ---------- | | --------- Line 2 ---------| |
      | | ----Column 3 --------- | | ------- Column 4 ---------| |
      | | -------Line 4----------- | | ----------Line 4----------| |
      | ||========================|| | --------- Line 5 ---------| |
      | || Footnote container || |----------Line 6 --------- | |
      | ||========================|| |--------- Line 7 --------- | |
      | ============================ ============================= |
      -------------------------------------------------------------------
      | |
      | Fixed size Footer |
      | |
      ===================================================================

    OK so under the new scheme we continue to have a fp_Page class whose
    job it is to layout out fp_Columns on a page and place headers/footers in
    the margins.

    Now however fp_Columns can contain containers other than fp_Lines.
    fp_Columns can contain lines, other containers or footnote containers.

    In order to be able to continue to use a vector of void * pointers as the
    content of the column, this means that fp_line should become a subclass of
    a general container class. If we have getType() method in this class we
    can dynamically determine what sort of container is returned from a

    fp_ContainerObject * pCO = (fp_ContainerObject *) m_pLines.getNthItem(i);

    assignment.

    At present we have the following fp_* class heiracy.

    fp_Run --> lots of run subclasses.
    fp_Line --> no Line subclasses
    fp_Container ----|
                     |-----> fp_Column
                     |-----> fp_HdrFtrContainer
                     |-----> fp_ShadowContainer
                     |-----> fp_EndNoteContainer

    I propose this:

    fp_Run --> lots of run subclasses.
    fp_ContainerObject----|
                          |-----> fp_Line
                          |-----> fp_Container ----|
                                                   |---> fp_Column
                                                       |->fp_ShadowColumn
                                                       |->fp_PositionedColumn
                                                   |-----> fp_HdrFtrContainer
                                                   |-----> fp_EndNoteContainer
                                                   |-----> fp_FootnoteContainer
                                                   |-----> fp_TableContainer
                                                   |-----> fp_CellContainer
                                                   |-----> fp_RowContainer

    fp_RowContainer is a container that lays out containers horizonally not
    vertically.

    fp_TableContainer is a collection of row containers.

    The following methods would be available to all container classes:

    getContainerType(void)
    draw( drawArgs)
    clearScreen()
    getX(void)
    getY(void)
    getWidth(void)
    getHeight(void)
    getXLayoutUnits(void)
    getYLayoutUnits(void)
    getWidthLayoutUnits(void)
    getHeightUnits(void)
    getNext(void)
    getPrev(void)
    getSectionLayout(void)
    setX(UT_sint32 )
    setY(UT_sint32 )
    setWidth(UT_uint32)
    setHeight(UT_uint32 )
    setXLayoutUnits(UT_uint32 )
    setYLayoutUnits(UT_uint32 )
    setWidthLayoutUnits(UT_uint32)
    setHeightUnits(UT_uint32)
    setNext(fp_ContainerObject *)
    setPrev(fp_ContainerObject *)

    These would all be declared pure abstract in the fp_ContainerObject base
    class.

    All positions are relative to the container containing them, be it a
    column or a page.

    Of the containers, only columns get placed ona page. Other container types
    are placed in either other containers or in a column.

    Thus all containers not columns need:

    getColumn(void)
    getContainer(void) methods

    The getColumn would work by just recursively calling getColumn until a
    column was obtained.
    The getContainer() would just return the holding container.

    fp_Column classes have:

    getPage()
    getColumnLeader()
    getFollower()

    methods.

    The advantage of this aproach is that it makes it possible to nest
    containers inside each other while preserving the distinction of
    fp_Columns which get layed out right on a page.

    I believe it is straight forward to evolve our current layout classes to
    this more general method rather quickly.

    Opinions folks? I think that this can be implemented relatively quickly
    with little disruption to our current code base.

    If people agree to this scheme I will immediately move are current code
    base to this new version in the 1.2 tree. It should not take more than
    couple of days.

    I have other ideas on what is needed in the fl_Layout Classes and the
    piecetable classes in order to fill these physical classes but I'll save
    them for another email.

    Cheers

    Martin



    This archive was generated by hypermail 2.1.4 : Sun Apr 21 2002 - 10:56:05 EDT