ctkWidgetLib

        Class ctkWidgetLib models a widget class library in the ctk environment.
        It controls all widgets which may be generated by ctk,
        in order to keep them ready to be used (accessed) while
        ctk sessions.
        That means it registers, loads and saves the widget definitions,
        whereby
        'register' a widget means make it known to ctk,
        'save' means make the widget definitions persistent into a dedicated folder of ctk,
        'load' means make the saved widget accessable while a ctk session for use.
        Standard TK-widget are automatically registered.
        Derived or composite widget should be individually and explicitely registered.

Widget class properties

        classname the name of the widget class: valid class name,
                  optional, default file name whithout extension
        filename  the file name of the widget definition: valid file name,
                  optional, default classname.'.pl'
        defaultwidgetoptions list of the default widget options,
                             optional, no default.
        geom       the widget needs the geometry manager, mandatory,
                   0 | 1
        defaultgeometrymanager name of the geometry manager to be be proposed,
                               default 'pack' .
        defaultgeometryoptions list of the default options, optional.
        use        package name to be given in the use statement, optional,
                   default 'Tk::'.classname,
                   '  ' suppress tne generation of the use statement for the widget.
        balloon    set up an hint to the widget, mandatory,
                   0 | 1
        icon       name of the image file to be used as icon
                   (may be any file supported by widget Photo),
                   default (missing.gif)
        attr       supported widget's attribute list.

Syntax

        $widgetClassLib = ctkWidgetLib->new(widgetlib => <widget library folder>, widgets => <ref to widget list>);
        $widgetClassLib->create(<classname>);
        $widgetClassLib->createNonVisualClass(<classname>);
        $widgetClassLib->loadAll();
        $widgetList = $widgetClassLib->widgets;
        $pathToWidgetLib = $widgetClassLib->widgetlib;
        $widgetClassLib->register(<ref to parent widget>[,<classname>]);
        $widgetClassDef = $widgetClassLib->load(<classname>);
        $widgetClassLib->saveAll();
        $widgetClassLib->save(<widgetClass>)
        $widgetClassLib->dlg_widgetRegistrationsParam(<ref to parent widget>,<classname>);
        $widgetClassLib->registerWidgetClassDefinition();
        $widgetClassLib->editWidgetOptions(<ref to dialog widget>,<classname>,<useFileName>,<attr>);
        $widgetClassLib->deleteWidgetClass(<widgetClass>);
        $widgetClassLib->validateUseName(<use>,<askuser>);

Programming notes

Actually the individual class definitions are ref to HASH.
Run time environment
        Almost all methods need the active run time env of ctk_w.
                - cwd must be the clickTk folder
                - widget library
                - widget class definition list

Maintenance

        Author: mam
        date:   01.01.2005
        History
                01.01.2005 MO000xx mam First draft
                25.10.2005 MO00704 version 1.02
                28.10.2005 MO00705 version 1.03
                15.09.2006 version 1.04
                        02.10.2006 version 1.05
                        05.10.2006 version 1.06
                        20.11.2007 version 1.07
                        14.03.2008 version 1.09
                        27.05.2008 version 1.10
                        28.10.2008 version 1.11
                        23.11.2009 version 1,12 (pathName)

Methods

Summary

        new
        destroy
        _backup
        _init
        create
        createNonVisualClass
        deleteWidgetClass
        dlg_widgetRegistrationsParam
        editNonVisualClassOptions
        editWidgetOptions
        fileName
        load
        loadAll
        register
        registerWidgetClassDefinition
        save
        saveAll
        validateUseName

Properties

        widgetlib
        widgets
        class
        use
        optionsTyp

new

        Construct the instance
        - save the argument list
        - set up class name
        - send message new to SUPER class (arguments)
        - bless the instance returned from SUPER
        - initialize the instance by mean of message $self->_init

destroy

        Destruct the instance.

_init

        Intialize the instance
        -set up properties

fileName

        Build the standard file name of a widget class definition.
        It returns the file name corresponding to the given widget class
        Note : this method doesn't check whether the file exists.

_backup

        move the widget definition file to a backup image.
        That is done unlinking the actually existing backup and
        renaming the existing file to <fileName>.bak .
        It returns true if the rename worked fine.

register

        - Register a single widget class to ctk_w .
        - send message registerWidgetClassDefinition to do the job.

create

        This method returns a ref to HASH which contains all data members
        of a widgetLib intance. All memeber but classname are initialized
        to their default values.
        Classname is given the value passed to as argument.
                geom        = 1,
                nonVisual   = 0,
                balloon     = 1,
                use         = '',
                file        = '',
                classname   = $classname,
                defaultgeometrymanager = 'pack',
                defaultgeometryoptions = '',
                defaultwidgetoptions   = '',
                icon        = 'default',
                pathName    => ''
                attr        = {}
Arguments
        class name (mandatory)
Returns
        ref to HASH.
Notes
        None.

createNonVisualClass

        Same as create but specialized for nonvisual classes.

loadAll

        Load all widget into memory.
        This method returns ref to hash containing all actually registered widgets.
        It creates the widget list and always saves a ref to that list into
        the property 'widgets'.
        Additionally it returns that ref to the issuer.
        Note: this method scans the widgets folder for file names ending with '.pl'
              which are assumed to be class definitions.
              Once loaded the definition are stored using the value of the item 'classname'
              If this item doesn't exists then the file name without extension is used as class name instead.

load

        Load a definition into memory.
        This method returns a ref to an instance of type ctkWidgetLib
        if the job has been well done, undef otherwise.
        Arguments
                self
                file name of the def
        Return
        ref to the definition or
        UNDEF in case of errors.

save

        The method saves the currently active widget class definition
        into the persistent widget definition's library.
        To do that task it accesses the widget class list applying the given classname and uses Data::Dumper->Dump and returns
        the file name.

saveAll

        Save all widgets persistently to disk.
        Method saveAll returns true if the job has been well done
        undef otherwise.

dlg_widgetRegistrationsParam

        This method sets up modal dialog to enter options.
        It returns a ref to HASH containing all definition's options,
        or undef if the user dismissed the action.

validateUseName

        Method validateUseName validates the existence of the given widget class.
        It returns true if the widget class can be used or required
        false otherwise.
        Arguments
                - name to be used for use or require statement (mandatory)
                - ask user for decision on error (optional)
                  1 ask user to decide
                  0 don't ask the user (default)
        Notes
                - use names prefixed by 'Tk::' are used
                - other names are first suffixed with '.pm' and
                  then required.

registerWidgetClassDefinition

        This method executes an registration process.
        First it sends dlg_widgetRegistrationsParam to
        accept options and than depending on the user's action
        saves the definition.
        It returns true if the definition has been save , false otherwise.

editWidgetOptions

        This method edits the options of a widget class definition:
                - setup a local toplevel
                - use the requested widget
                - instantiate a widget
                - get the option's list
                - set up the edit dialog arguments
                - show the edit dialog
                - get rid of the options marked as 'default'
                - return a ref to the edited option's hash
        Arguments
                - className
                - useFileName
                - attr
                - pathName
        Returns
                - ref to hash with changed attributes
        Notes

editNonVisualClassOptions

        This method edits the options of a non-visual widget definition.
        Arguments
                - className
                - useFileName
                - attr
                -pathName
        Returns
                - ref to hash with changed attributes
        Notes

deleteWidgetClass

        This method deletes a widget class definition from the
        registration's library.
        The definition is deleted from the library actually in memory
        and the persistent instance is simply turned to a backup copy.
        This method always returns true.
        Note: this message can be issued only while a ctk_w session!
        Arguments
                - className
        Returns
                - True if the deletion including the backup did fine,
                  undef otherwise.
        Notes

Back to index