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 146 of file ObjectSelection.c.

References FREE, List_free(), and NULL.

Referenced by sciUnselectSons(), and sciUnselectTypedSons().

00147 {
00148   if ( ((TypedSonsList *)typedSonsList)->typedSons != NULL )
00149   {
00150     List_free( ((TypedSonsList *)typedSonsList)->typedSons ) ;
00151   }
00152   FREE(typedSonsList) ;
00153 }

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 124 of file ObjectSelection.c.

Referenced by sciGetTypedList().

00125 {
00126   return ( ((TypedSonsList*)typedSonsList1)->sonType == ((TypedSonsList*)typedSonsList2)->sonType ) ;
00127 }

Here is the caller graph for this function:

TypedSonsList* newTypedSonList ( sciEntityType  type,
DoublyLinkedList typedSons 
)

Definition at line 137 of file ObjectSelection.c.

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

Referenced by sciAddSelectedSon().

00138 {
00139   TypedSonsList * newList = MALLOC(sizeof(TypedSonsList)) ;
00140   newList->sonType   = type ;
00141   newList->typedSons = typedSons ;
00142 
00143   return newList ;
00144 }

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 23 of file ObjectSelection.c.

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

Referenced by sciAddUniqueSelectedSon().

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

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 54 of file ObjectSelection.c.

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

Referenced by sciInitSelectedObject().

00055 {
00056   sciUnselectTypedSons( pParent, sciGetEntityType(pObj) ) ;
00057   return sciAddSelectedSon( pParent, pObj ) ;
00058 }

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 65 of file ObjectSelection.c.

References List_data, and sciGetRelationship().

00066 {
00067   return (sciPointObj *) List_data(((TypedSonsList*)List_data(sciGetRelationship(pObj)->pSelectedSon))->typedSons ) ;
00068 }

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 70 of file ObjectSelection.c.

References List_data, and sciGetTypedSelectedSons().

Referenced by getAffichTextObject(), sci_xclick(), sci_xgetmouse(), sciGetCurrentConsole(), sciGetCurrentSubWin(), sciGetCurrentWindow(), sciGetCurrentWindowFrame(), sciGetParentSubwin(), sciInitAutoScale(), sciInitdrawmode(), sciSetdrawmode(), and scoInitOfWindow().

00071 {
00072   return (sciPointObj *) List_data( sciGetTypedSelectedSons( pObj, objType ) ) ;
00073 }

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 113 of file ObjectSelection.c.

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

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

00114 {
00115   DoublyLinkedList * curList = sciGetTypedSelectedSons( sciGetParent(pObj), sciGetEntityType(pObj) ) ;
00116   return ( curList != NULL && List_find( curList, pObj ) != NULL ) ;
00117 }

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 129 of file ObjectSelection.c.

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

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

00130 {
00131   TypedSonsList refType = { objType, NULL } ; /* just for comparison with type */
00132   DoublyLinkedList * foundList = List_find_full( sciGetRelationship(pObj)->pSelectedSon, &refType, hasSameType ) ;
00133   if ( foundList == NULL ) { return NULL ; }
00134   return (TypedSonsList *) List_data( foundList ) ;
00135 }

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 75 of file ObjectSelection.c.

References NULL, sciGetTypedList(), and TypedSonsList::typedSons.

Referenced by sciGetFirstTypedSelectedSon(), and sciGetIsSelected().

00076 {
00077   TypedSonsList * curList = sciGetTypedList( pObj, objType ) ;
00078   if ( curList == NULL )
00079   {
00080     return NULL ;
00081   }
00082   return curList->typedSons ;
00083 }

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 60 of file ObjectSelection.c.

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

Referenced by allocatePolyline(), allocateText(), ConstructCompoundSeq(), ConstructFigure(), CreateUIContextMenu(), CreateUimenu(), graphicsmodels(), initLabel(), and sciStandardBuildOperations().

00061 {
00062   sciGetRelationship(pObj)->pSelectedSon = DoublyLinkedList_new() ;
00063 }

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