ObjectSelection.c File Reference

#include "ObjectSelection.h"
#include "MALLOC.h"
#include "GetProperty.h"

Include dependency graph for ObjectSelection.c:

Go to the source code of this file.

Functions

int sciAddSelectedSon (sciPointObj *pParent, sciPointObj *pObj)
int sciAddUniqueSelectedSon (sciPointObj *pParent, sciPointObj *pObj)
void sciInitSelectedSons (sciPointObj *pObj)
sciPointObjsciGetFirstSelectedSon (sciPointObj *pObj)
sciPointObjsciGetFirstTypedSelectedSon (sciPointObj *pObj, sciEntityType objType)
DoublyLinkedListsciGetTypedSelectedSons (sciPointObj *pObj, sciEntityType objType)
int sciRemoveSelectedSon (sciPointObj *pParent, sciPointObj *pObj)
void sciUnselectSons (sciPointObj *pParent)
void sciUnselectTypedSons (sciPointObj *pParent, sciEntityType sonsType)
BOOL sciGetIsSelected (sciPointObj *pObj)
static BOOL hasSameType (void *typedSonsList1, void *typedSonsList2)
TypedSonsListsciGetTypedList (sciPointObj *pObj, sciEntityType objType)
TypedSonsListnewTypedSonList (sciEntityType type, DoublyLinkedList *typedSons)
void deleteTypedSonList (void *typedSonsList)


Function Documentation

void deleteTypedSonList ( void *  typedSonsList  ) 

Void * to be used directly by the list object

Definition at line 129 of file ObjectSelection.c.

References FREE, List_free(), and NULL.

Referenced by sciUnselectSons(), and sciUnselectTypedSons().

00130 {
00131   if ( ((TypedSonsList *)typedSonsList)->typedSons != NULL )
00132   {
00133     List_free( ((TypedSonsList *)typedSonsList)->typedSons ) ;
00134   }
00135   FREE(typedSonsList) ;
00136 }

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL hasSameType ( void *  typedSonsList1,
void *  typedSonsList2 
) [static]

Just check if the two typedSonsList has same type. To be used with List_find_full.

Definition at line 109 of file ObjectSelection.c.

Referenced by sciGetTypedList().

00110 {
00111   return ( ((TypedSonsList*)typedSonsList1)->sonType == ((TypedSonsList*)typedSonsList2)->sonType ) ;
00112 }

Here is the caller graph for this function:

TypedSonsList* newTypedSonList ( sciEntityType  type,
DoublyLinkedList typedSons 
)

Definition at line 120 of file ObjectSelection.c.

References MALLOC, TypedSonsList::sonType, and TypedSonsList::typedSons.

Referenced by sciAddSelectedSon().

00121 {
00122   TypedSonsList * newList = MALLOC(sizeof(TypedSonsList)) ;
00123   newList->sonType   = type ;
00124   newList->typedSons = typedSons ;
00125 
00126   return newList ;
00127 }

Here is the caller graph for this function:

int sciAddSelectedSon ( sciPointObj pParent,
sciPointObj pObj 
)

Add an object in the set of selected son of the parent. Be careful, pObj should be a son of pParent.

Definition at line 13 of file ObjectSelection.c.

References DoublyLinkedList_new, List_append(), newTypedSonList(), NULL, sciRelationShip::pSelectedSon, sciGetEntityType(), sciGetRelationship(), sciGetTypedList(), and TypedSonsList::typedSons.

Referenced by sciAddUniqueSelectedSon().

00014 {
00015   sciEntityType sonType = sciGetEntityType( pObj ) ;
00016   /* first search if there are already objects with the specified type */
00017   TypedSonsList * typedList = sciGetTypedList( pParent, sonType ) ;
00018 
00019   if ( typedList == NULL )
00020   {
00021     /* first item with this type to be inserted */
00022     DoublyLinkedList * newTypedList = NULL ;
00023     TypedSonsList    * newItem      = NULL ;
00024 
00025     /* first create the list of objects with the son type */
00026     newTypedList = DoublyLinkedList_new() ;
00027     newTypedList = List_append( newTypedList, pObj ) ;
00028 
00029     /* then create a new entry in the main list for this type */
00030     newItem = newTypedSonList( sonType, newTypedList ) ;
00031 
00032     /* add it to the main list */
00033     sciGetRelationship(pParent)->pSelectedSon = List_append( sciGetRelationship(pParent)->pSelectedSon, newItem ) ;
00034 
00035   }
00036   else
00037   {
00038     typedList->typedSons = List_append( typedList->typedSons, pObj ) ;
00039   }
00040   return 0 ;
00041 
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:

int sciAddUniqueSelectedSon ( sciPointObj pParent,
sciPointObj pObj 
)

Add an object in the set of selected son of the parent. If an other object with the same type is already inserted, it will be destroyed to let the place for this one.

Definition at line 44 of file ObjectSelection.c.

References sciAddSelectedSon(), sciGetEntityType(), and sciUnselectTypedSons().

Referenced by sciInitSelectedObject().

00045 {
00046   sciUnselectTypedSons( pParent, sciGetEntityType(pObj) ) ;
00047   return sciAddSelectedSon( pParent, pObj ) ;
00048 }

Here is the call graph for this function:

Here is the caller graph for this function:

sciPointObj* sciGetFirstSelectedSon ( sciPointObj pObj  ) 

Return the first son found in the set of selected sons.

Definition at line 55 of file ObjectSelection.c.

References List_data, and sciGetRelationship().

00056 {
00057   return (sciPointObj *) List_data(((TypedSonsList*)List_data(sciGetRelationship(pObj)->pSelectedSon))->typedSons ) ;
00058 }

Here is the call graph for this function:

sciPointObj* sciGetFirstTypedSelectedSon ( sciPointObj pObj,
sciEntityType  objType 
)

Return the first son with a certain type found in the set of selected sons

Definition at line 60 of file ObjectSelection.c.

References List_data, and sciGetTypedSelectedSons().

Referenced by callXstringL(), sciGetCurrentConsole(), sciGetCurrentSubWin(), sciGetCurrentWindow(), sciGetCurrentWindowFrame(), sciGetParentSubwin(), sciInitAutoScale(), sciInitdrawmode(), sciSetdrawmode(), xgetg(), and xsetg().

00061 {
00062   return (sciPointObj *) List_data( sciGetTypedSelectedSons( pObj, objType ) ) ;
00063 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL sciGetIsSelected ( sciPointObj pObj  ) 

To know if an object is selected

Definition at line 98 of file ObjectSelection.c.

References List_find(), NULL, sciGetEntityType(), sciGetParent(), and sciGetTypedSelectedSons().

Referenced by sci_delete(), sciRelocateObject(), sciSetSelectedObject(), and sciSetSelectedSubWin().

00099 {
00100   DoublyLinkedList * curList = sciGetTypedSelectedSons( sciGetParent(pObj), sciGetEntityType(pObj) ) ;
00101   return ( List_find( curList, pObj ) != NULL ) ;
00102 }

Here is the call graph for this function:

Here is the caller graph for this function:

TypedSonsList* sciGetTypedList ( sciPointObj pObj,
sciEntityType  objType 
)

Definition at line 114 of file ObjectSelection.c.

References hasSameType(), List_data, List_find_full(), NULL, and sciGetRelationship().

Referenced by sciAddSelectedSon(), sciGetTypedSelectedSons(), sciRemoveSelectedSon(), and sciUnselectTypedSons().

00115 {
00116   TypedSonsList refType = { objType, NULL } ; /* just for comparison with type */
00117   return (TypedSonsList *) List_data(List_find_full( sciGetRelationship(pObj)->pSelectedSon, &refType, hasSameType ) ) ;
00118 }

Here is the call graph for this function:

Here is the caller graph for this function:

DoublyLinkedList* sciGetTypedSelectedSons ( sciPointObj pObj,
sciEntityType  objType 
)

Get the list of selected sons with a certain type. This is a list of sciPointObj *. Be careful, the value is the direct pointer on the data.

Definition at line 65 of file ObjectSelection.c.

References sciGetTypedList(), and TypedSonsList::typedSons.

Referenced by sciGetFirstTypedSelectedSon(), and sciGetIsSelected().

00066 {
00067   return sciGetTypedList( pObj, objType )->typedSons ;
00068 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sciInitSelectedSons ( sciPointObj pObj  ) 

Initialize the set of sons

Definition at line 50 of file ObjectSelection.c.

References DoublyLinkedList_new, sciRelationShip::pSelectedSon, and sciGetRelationship().

Referenced by allocateText(), ConstructCompoundSeq(), ConstructLabel(), graphicsmodels(), initLabel(), and sciStandrardBuildOperations().

00051 {
00052   sciGetRelationship(pObj)->pSelectedSon = DoublyLinkedList_new() ;
00053 }

Here is the call graph for this function:

Here is the caller graph for this function:

int sciRemoveSelectedSon ( sciPointObj pParent,
sciPointObj pObj 
)

Remove a selected object from the set.

Definition at line 70 of file ObjectSelection.c.

References List_free_item(), sciGetEntityType(), sciGetTypedList(), and TypedSonsList::typedSons.

00071 {
00072   TypedSonsList * curList = sciGetTypedList( pParent, sciGetEntityType(pObj) ) ;
00073   curList->typedSons = List_free_item( curList->typedSons, pObj ) ;
00074   return 0 ;
00075 }

Here is the call graph for this function:

void sciUnselectSons ( sciPointObj pParent  ) 

Free the set of sons

Definition at line 77 of file ObjectSelection.c.

References deleteTypedSonList(), DoublyLinkedList_new, List_free_full(), sciRelationShip::pSelectedSon, and sciGetRelationship().

Referenced by DestroyLabel(), and sciStandardDestroyOperations().

00078 {
00079   List_free_full( sciGetRelationship(pParent)->pSelectedSon, deleteTypedSonList ) ;
00080   sciGetRelationship(pParent)->pSelectedSon = DoublyLinkedList_new() ;
00081 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sciUnselectTypedSons ( sciPointObj pParent,
sciEntityType  sonsType 
)

Remove all selected sons from a certain type

Definition at line 83 of file ObjectSelection.c.

References deleteTypedSonList(), List_free_item(), NULL, sciRelationShip::pSelectedSon, sciGetRelationship(), and sciGetTypedList().

Referenced by sciAddUniqueSelectedSon().

00084 {
00085   /* first search if there are already objects with the specified type */
00086   TypedSonsList * typedList = sciGetTypedList( pParent, sonsType ) ;
00087 
00088   if ( typedList == NULL ) { return ; } /* no item with this type */
00089 
00090   /* remove the input for this type in the main list */
00091   sciGetRelationship(pParent)->pSelectedSon = List_free_item( sciGetRelationship(pParent)->pSelectedSon, typedList ) ;
00092 
00093   /* free the input and the list of object with this type */
00094   deleteTypedSonList( typedList ) ;
00095 
00096 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Mar 4 15:49:12 2007 for Scilab [trunk] by  doxygen 1.5.1