ctkProject

        Class ctkProject models a project file as used in the clickTk
        session.

Syntax

        my $prj = ctkProject->new();
        $prj->open ;
        $prj->save;
        $prj->close;

Programming notes

Still under construction

Maintenance

        Author: marco
        date:   28.10.2006
        History
                        28.10.2006 MO03101 mam First draft
                        26.11.2007 version 1.02 refactoring
                        14.12.2007 version 1.03 refactoring
                        13.10.2008 version 1.04
                        28.10.2008 version 1.05
                        15.04.2009 version 1.06
                        23.04.2009 version 1.07
                        30.07.2010 version 1.08

Methods

Summary

                _extractVariables
                _init
                assignVariables
                conflicts
                descriptor
                destroy
                empty_file_opt
                existsFolder
                extractVariables
                fileName
                generate_unique_id
                getType
                getWidgetIdList
                id_to_path
                index_of
                init
                insertGlobal
                insertLocal
                isRef2Widget
                name
                new
                noname
                parseNonvisualConstructor
                parseTkCode
                path_to_id
                refreshVariables
                removeGlobal
                removeLocal
                saveDataToFile

index_of

        return the index of the given id in the
        class data member @tree
        TODO : raise an exception if id not found

getType

        Return the type (class name) of the given widget path
        (default is the selected widget).
        Exception
        id doesn't exist in the class data member %descriptor
        TODO : check existence of $id first, then access the hash

generate_unique_id

        Build the id of a new widget definition
        Argument
                widget class
        Return
                id
        Note : the class data member $objCount is
        used to make the id unique.

empty_file_opt

        Return the hash or ref to hash
        of the default file_opt structure.

existsFolder

        Return true if the project folder exists.

name

        Build the project name out of the given file name.

fileName

        Build the file name for the given project name.

getWidgetIdList

        Return the id of all currently defined widgets
        as array or ref to array.

isRef2Widget

        Check if the geiven widget's ids
        are in the list of the defined wigets.
        Return the number of name matches.

path_to_id

        Return the id of the given path
        Default id is getSelected()
        Exception 'Missing selected widget'

id_to_path

        Scan the class data member ctkProject::tree
        for the given id and reurn the found item.
        Argument
        id
        Exception : more thean one item found
        Return
                found item or
                UNDEF if none found

saveDataToFile

        - generate the code
        - set up an instance of type ctkFile
        - create a backup
        - write the generated code
        - return true if the close did well.
        Argument
        - file name

conflicts

        Scan the widgets definitions for existing conflicts
                conflict 1      remove option -label from Frame with sub-widgets using grid
                                        (endless loop in Perl)
                        for each frame widget
                        get all children id's
                        get those geometry
                        remove -label if at least one match 'grid'
        Arguments
                None
        Return
                array of conflicts description or
                number of conflicts

parseTkCode

        For each widget description line:
                1. get Id, Parent, Type, parameters, geometry
                2. check for Parent existence
                3. add line to tree descriptor
                4. add element to widget descriptor
                5. collect variables and callbacks
        Arguments
                - widget constructor code (string)
                - line number within input batch (int)
                - assigned order (string)
                - nonvisual flag
                -
        Return
                array of exceptions
        Global structures
                %ctkProject::descriptor (id->descriptor)
                @ctkProject::tree
                @ctkProject::user_auto_vars - user-defined variables to be pre-declared automatically
                use vars qw/$x/;
        Global widgets used:
                $tf - preview tree

parseNonvisualConstructor

        Parse the given constructore code and
        build up a descriptor for the given nonvisual entry.
        The constructor code looks like this
        $<id> = <type> -> new (<optionslist>);

_extractVariables

        - set up a parser instance
        - get descriptor
        - parse options string to options list
                message parseWidgetOptionsQuotate( return of message parseString)
        - scan options list
                - build option's pair (opt , value)
                  skip opt
                  - check value for
                                constant
                                variable's name beginning with %@$ (package name not yet supported)
                                ref to variable
                                element of array or hash
                                ref to list [ ]
                                closure (get not analyzed)
        - return the list of found variable's ident
          (depending on context array or ref to array)

extractVariables

        Extract valriables form the TK-commands and
        put them into data class members @user_local_vars
        and @user_auto_vars.
        Send message $self->_extractVariables to do the job,
        then save its return into the mentioned class data members.

Atomic methods for variable's handling

insertLocal
insertGlobal
removeLocal
removeGlobal

refreshVariables

        Reassign the extracted variables and inform the user
        about reassignments.
        See class data member ctkProject::DTmessage

assignVariables

        This method saves the given list of variables in the global
        arrays depending on the actual conditions.
Decision table
        see definition module ctkDT_variables.pl .
Notes
        - local variables are declared by means of my $variable .
        - global variables are declared with use vars qw/$variable/ .
        - same variable may exist in the local namespace and in the
          global one (warning).

Back to index