close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#945 closed enhancement (fixed)

Dynamic icon for instance depending on the instance state

Reported by: Jorge Owned by: Jorge
Priority: high Milestone: TOL Packages
Component: Interface Version: 2.0.1
Severity: major Keywords: GUI, icons
Cc: Pedro Gea

Description

In order to improve the flexibility when specifying icons for instances of the classes it is require that besides specifying a name of an image being able to provide a code that could determine the name of the image depending on the state of the instance. A possible prototype could be:

Text GetImageForIcon( NameBlock instance );

The prototype for ImageManager::setIconForClass should be now

Real ImageManager::setIconForClass( Text className, Anything imageName )

where imageName could be of type Text or Code.

Change History (5)

comment:1 Changed 15 years ago by Jorge

Status: newaccepted

getIconForClass will change to:

  Anything getIconForClass( Text className )

and a new method getIconForInstance will be implemented

Text getIconForInstance( NameBlock instance )

comment:2 Changed 15 years ago by Jorge

(In [2400]) refs #945, ticket done & test updated, the example follows

NameBlock Test0004 =
[[
  Class @TestA {
    Real value = 1.0
  };

  Class @Variable {
    Set _value = Copy( Empty );

    Text getSubType( Real void )
    {
      Grammar( _value[1] )
    };
    
    Static @Variable newSerie( Real void )
      {
        @Variable aux = [[ Set _value = [[ Serie Gaussian( 0, 1 ) ]] ]];
        aux
      };
    
    Static @Variable newMatrix( Real row, Real column )
      {
        @Variable aux = [[ Set _value = [[ Matrix Gaussian( row, column, 0, 1 ) ]] ]];
        aux
      }
  };

  Text getIconForVariable( @Variable instance )
  {
    // en este caso podemos retorna el subtipo de la @Variable, en
    // otro caso se puede hacer la casuistica tan compleja como se
    // quiera
    Text instance::getSubType(?)
  }
]];

Real GuiTools::ImageManager::defineImageFromData
( "checkedBox",
  "R0lGODdhCwALAJEAAH9/f////wAAAP///ywAAAAACwALAAACLISPRvEPAE8oAMUXCYAgJSEiAYRIQkSCAgTJjgiAoEgSEQGEJIRiA9wdwUcrADs=" );

Real GuiTools::ImageManager::defineImageFromFile( "Matrix", "Matrix.gif" );

Real GuiTools::ImageManager::defineImageFromFile( "Serie", "Serie.gif" );

Real GuiTools::ImageManager::setIconForClass( "Test0004::@TestA", "checkedBox" );
  
Real GuiTools::ImageManager::setIconForClass( "Test0004::@Variable",
                                              Test0004::getIconForVariable );

Test0004::@TestA inst1 = [[ Real value = 1.0 ]];

Test0004::@Variable instSerie = Test0004::@Variable::newSerie(?);
Test0004::@Variable instMatrix = Test0004::@Variable::newMatrix(10,10);

comment:3 Changed 15 years ago by Jorge

Resolution: fixed
Status: acceptedclosed

(In [2401]) fixes #945, ticket done & test updated, see also commit [2400], updating new functions in tclIndex

comment:4 Changed 15 years ago by Jorge

(In [2402]) refs #945, removing forgotten trace.

comment:5 Changed 15 years ago by Jorge

(In [2406]) refs #945, fixed a bug raised when GuiTools is not loaded

Note: See TracTickets for help on using tickets.