VisibleList Class Reference

Allows a user to edit a list of items. More...

#include <uielem.h>

Inheritance diagram for VisibleList:

UserInterface Notifier VisibleListWithEditableEntries AvailablePropertiesList UsedPropertiesList List of all members.

Public Member Functions

 VisibleList ()
virtual ~VisibleList ()
 Virtual destructor clears its lists.
virtual BOOL Display (DialogOp &Dialog)
 Hmm.. haven't quite decided what these should do. How about: Display - show disabled Interact - show enabled Hide - remove from sight.
virtual BOOL Interact (DialogOp &Dialog)
virtual void Hide ()
virtual BOOL Display (ListControl &Control)
virtual BOOL Interact (ListControl &Control)
virtual BOOL InsertEntry (VisibleListItem &EntryToInsert)
 Inserts an entry into a visible list.
virtual BOOL DeleteSelectedEntries ()
 Deletes the selected entries in this list.
virtual BOOL DeleteAllEntries ()
 Deletes all the entries in this list.
virtual UINT32 GetNumberOfEntries () const
 Determines how much space you would need for the whole list were you building an array.
virtual UINT32 GetNumberOfSelectedEntries () const
 Determines if there's a selection.
virtual VisibleListItemGetFirstSelectedEntry () const
 Gets the VisibleListItem that's selected in this list.
virtual void RemoveSelection ()
 Deselects any entries in this list.
virtual VisibleListIterator Begin ()
 Returns an iterator so you can run through all the entries in this list.
virtual const VisibleListIteratorEnd () const
 So you know when to stop iterating use this 'cos it marks the end of this list.
virtual VisibleListIterator BeginOfEnd ()
 Returns an iterator so you can back through all the entries in this list.
virtual VisibleListIterator SelectionBegin ()
 Returns an iterator so you can run through the selected entries in this list.

Protected Member Functions

virtual VisibleListItemGetEntryAt (UINT32 Index)
 Support function to get the Index'th entry in the list.
virtual BOOL DeleteEntryAtIndex (UINT32 Index)
 Deletes the Index'th entry in this list.
ListGetContainer ()
 Support function to exposeget the VisibleList's innards.

Private Member Functions

 CC_DECLARE_MEMDUMP (VisibleList)

Private Attributes

ListControlm_pUIElement
List m_Container

Detailed Description

Allows a user to edit a list of items.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/10/96

Definition at line 208 of file uielem.h.


Constructor & Destructor Documentation

VisibleList::VisibleList  )  [inline]
 

Definition at line 213 of file uielem.h.

00213 : m_pUIElement(NULL)    {}

VisibleList::~VisibleList  )  [virtual]
 

Virtual destructor clears its lists.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 369 of file uielem.cpp.

00370 {
00371     DeleteAllEntries();
00372 }


Member Function Documentation

VisibleListIterator VisibleList::Begin  )  [virtual]
 

Returns an iterator so you can run through all the entries in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 765 of file uielem.cpp.

VisibleListIterator VisibleList::BeginOfEnd  )  [virtual]
 

Returns an iterator so you can back through all the entries in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 781 of file uielem.cpp.

VisibleList::CC_DECLARE_MEMDUMP VisibleList   )  [private]
 

BOOL VisibleList::DeleteAllEntries  )  [virtual]
 

Deletes all the entries in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
FALSE if it fails

Reimplemented in VisibleListWithEditableEntries, and UsedPropertiesList.

Definition at line 605 of file uielem.cpp.

00606 {
00607     BOOL DeletedAllEntries = TRUE;
00608 
00609     m_Container.DeleteAll();
00610 
00611     if (m_pUIElement != NULL)
00612     {
00613         DeletedAllEntries = m_pUIElement->DeleteAllItems();
00614     }
00615 
00616     return DeletedAllEntries;
00617 }

BOOL VisibleList::DeleteEntryAtIndex UINT32  Index  )  [protected, virtual]
 

Deletes the Index'th entry in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
FALSE if it fails

Reimplemented in UsedPropertiesList.

Definition at line 557 of file uielem.cpp.

00558 {
00559     BOOL Success = TRUE;        // return this
00560 
00561 //#ifdef _DEBUG 
00562 //  String_256 ListText = m_pUIElement->GetText(pText)  _R(IDC_TMLPTDLG_USED), &Success, 
00563 //                                                          Index);
00564 //  VisibleListItem* pItem = pEntryToDelete->GetEntry();
00565 
00566 //      ASSERT(ListText == pEntryToDelete->GetText());
00567 
00568     VisibleListItemPtr* pEntryToDelete = (VisibleListItemPtr*)m_Container.FindItem(LISTPOS(Index));
00569     Success = (pEntryToDelete != NULL);
00570 
00571     if (Success)
00572     {
00573         Success = (m_Container.RemoveItem(pEntryToDelete) != NULL);
00574     }
00575 
00576     if (Success)
00577     {
00578         delete pEntryToDelete;
00579         pEntryToDelete = NULL;
00580     }
00581 
00582     // Remove the entry from the display if it's there
00583     if (Success && m_pUIElement != NULL)
00584     {
00585         Success = m_pUIElement->DeleteItemAtIndex(Index);
00586     }
00587 
00588 
00589     return Success;
00590 }

BOOL VisibleList::DeleteSelectedEntries  )  [virtual]
 

Deletes the selected entries in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
FALSE if it fails

Reimplemented in VisibleListWithEditableEntries.

Definition at line 632 of file uielem.cpp.

00633 {
00634     ENSURE_NOT_NULL(m_pUIElement);
00635 
00636     // Delete the selected argument from the used list and copy it to the available list
00637     INT32* pIndexes = NULL;
00638     BOOL Success = m_pUIElement->GetSelectedIndexes(&pIndexes);
00639 
00640     UINT32 ArrayIndex = 0;
00641     UINT32 EntriesDeleted = 0;
00642     while (Success && pIndexes[ArrayIndex] != -1)
00643     {
00644         const UINT32 IndexOfEntryToDelete = pIndexes[ArrayIndex] - EntriesDeleted;
00645         Success = DeleteEntryAtIndex(IndexOfEntryToDelete);
00646 
00647         ++EntriesDeleted;
00648         ++ArrayIndex;
00649     }
00650 
00651     if (pIndexes != NULL)
00652     {
00653         delete pIndexes;
00654         pIndexes = NULL;
00655     }
00656 
00657     return Success;
00658 }

BOOL VisibleList::Display ListControl Control  )  [virtual]
 

Definition at line 407 of file uielem.cpp.

00408 {
00409     m_pUIElement = &Control;
00410     Control.Disable();
00411     // should display the entries we have and InsertEntry, etc. only update if we've
00412     // got a UIElement, but for now we'll insist on a display before InsertEntry, etc.
00413     return TRUE;
00414 }

BOOL VisibleList::Display DialogOp Dialog  )  [virtual]
 

Hmm.. haven't quite decided what these should do. How about: Display - show disabled Interact - show enabled Hide - remove from sight.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Implements UserInterface.

Definition at line 391 of file uielem.cpp.

00392 {
00393     return TRUE;
00394 }

const VisibleListIterator & VisibleList::End  )  const [virtual]
 

So you know when to stop iterating use this 'cos it marks the end of this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 798 of file uielem.cpp.

00799 {
00800     // doesn't matter about which list it's in
00801     List                list;
00802     static const VisibleListIterator TheEnd( list, NULL );  
00803 
00804     return TheEnd;
00805 }

List & VisibleList::GetContainer  )  [protected]
 

Support function to exposeget the VisibleList's innards.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 435 of file uielem.cpp.

00436 {
00437     return m_Container;
00438 }

VisibleListItem & VisibleList::GetEntryAt UINT32  Index  )  [protected, virtual]
 

Support function to get the Index'th entry in the list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
The VisibleListItem at the given Index

Definition at line 533 of file uielem.cpp.

00534 {
00535     VisibleListItemPtr* const pEntry = (VisibleListItemPtr*)GetContainer().FindItem(LISTPOS(Index));
00536     if (pEntry == NULL)
00537     {
00538         ERROR2RAW("NULL member");
00539     }
00540 
00541     return pEntry->GetEntry();
00542 }

VisibleListItem * VisibleList::GetFirstSelectedEntry  )  const [virtual]
 

Gets the VisibleListItem that's selected in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
NULL if there isn't one (or the list isn't visible)

Definition at line 717 of file uielem.cpp.

00718 {
00719     VisibleListItem* pSelectedEntry = NULL;     // return this
00720 
00721     INT32 SelectedIndex = 0;
00722 
00723     if (m_pUIElement != NULL && m_pUIElement->GetFirstSelectedIndex(&SelectedIndex))
00724     {
00725         VisibleListItemPtr* pEntryPtr = (VisibleListItemPtr*)m_Container.FindItem(LISTPOS(SelectedIndex));
00726         if (pEntryPtr != NULL)
00727         {
00728             pSelectedEntry = &pEntryPtr->GetEntry();
00729         }
00730     }
00731 
00732     return pSelectedEntry;
00733 }

UINT32 VisibleList::GetNumberOfEntries  )  const [virtual]
 

Determines how much space you would need for the whole list were you building an array.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
The Number of Entries

Definition at line 674 of file uielem.cpp.

00675 {
00676     return UINT32(m_Container.GetCount());
00677 }

UINT32 VisibleList::GetNumberOfSelectedEntries  )  const [virtual]
 

Determines if there's a selection.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
The Number of Entries Selected

Definition at line 692 of file uielem.cpp.

00693 {
00694     UINT32 NumberOfSelectedEntries = 0;
00695 
00696     if (m_pUIElement != NULL)
00697     {
00698         NumberOfSelectedEntries = m_pUIElement->GetNumberOfSelectedItems();
00699     }
00700 
00701     return NumberOfSelectedEntries;
00702 }

void VisibleList::Hide  )  [virtual]
 

Implements UserInterface.

Definition at line 402 of file uielem.cpp.

00403 {
00404 }

BOOL VisibleList::InsertEntry VisibleListItem EntryToInsert  )  [virtual]
 

Inserts an entry into a visible list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
FALSE if it fails

Reimplemented in UsedPropertiesList.

Definition at line 451 of file uielem.cpp.

00452 {
00453     BOOL Success = TRUE;        // return this
00454 
00455     // Find the entry to insert after & its index
00456     BOOL Found = FALSE;
00457     INT32 Index = 0;
00458     VisibleListItemPtr* pItemToInsertBefore = NULL;
00459 
00460     VisibleListItemPtr* pCurrentItem = (VisibleListItemPtr*)m_Container.GetHead();
00461     while (pCurrentItem != NULL && !Found)
00462     {
00463         if (!(EntryToInsert > pCurrentItem->GetEntry()))
00464         {
00465             pItemToInsertBefore = pCurrentItem;
00466             Found = TRUE;
00467         }
00468         else
00469         {
00470             ++Index;
00471             pCurrentItem = (VisibleListItemPtr*)m_Container.GetNext(pCurrentItem);
00472         }
00473     }
00474 
00475     // Create a new pointer to the given entry and put it in the container
00476     VisibleListItemPtr* pNewItem = NULL;
00477     if (Success)
00478     {
00479         pNewItem = new VisibleListItemPtr(EntryToInsert);
00480         Success = (pNewItem != NULL);
00481     }
00482 
00483     if (Success)
00484     {
00485         if (!Found)
00486         {
00487             m_Container.AddTail(pNewItem);
00488         }
00489         else
00490         {
00491             Success = (m_Container.InsertBefore(pItemToInsertBefore, pNewItem) != NULL);
00492         }
00493     }
00494 
00495     // Add a text entry for the VisibleListItem in the UI Element (if it's there)
00496     if (Success && m_pUIElement != NULL)
00497     {
00498         String_64 ListText;
00499         EntryToInsert.GetText(ListText);
00500         if (!Found)
00501         {
00502             Success = m_pUIElement->AddItem(ListText);
00503         }
00504         else
00505         {
00506             Success = m_pUIElement->InsertItem(ListText, Index);
00507         }
00508     }
00509 
00510     // tidy up any mess if it goes wrong
00511     if (!Success)
00512     {
00513         delete pNewItem;
00514         pNewItem = NULL;
00515     }
00516 
00517     return Success;
00518 }

BOOL VisibleList::Interact ListControl Control  )  [virtual]
 

Definition at line 417 of file uielem.cpp.

00418 {
00419     BOOL Ok = Display(Control);
00420     Control.Enable();
00421     return Ok;
00422 }

BOOL VisibleList::Interact DialogOp Dialog  )  [virtual]
 

Implements UserInterface.

Definition at line 397 of file uielem.cpp.

00398 {
00399     return TRUE;
00400 }

void VisibleList::RemoveSelection  )  [virtual]
 

Deselects any entries in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Reimplemented in VisibleListWithEditableEntries.

Definition at line 747 of file uielem.cpp.

00748 {
00749     VOID_ENSURE_NOT_NULL(m_pUIElement);
00750 
00751     m_pUIElement->DeselectAll();
00752 }

VisibleListIterator VisibleList::SelectionBegin  )  [virtual]
 

Returns an iterator so you can run through the selected entries in this list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 819 of file uielem.cpp.

00820 {
00821     ERROR2IF(m_pUIElement == NULL, End(), "NULL Member");
00822 
00823     INT32* pIndexes = NULL;
00824     if (m_pUIElement->GetSelectedIndexes(&pIndexes))
00825     {
00826         return VisibleListIterator(m_Container, (VisibleListItemPtr*)m_Container.GetHead(), pIndexes);
00827     }
00828     else
00829     {
00830         return End();
00831     }
00832 }


Member Data Documentation

List VisibleList::m_Container [private]
 

Definition at line 249 of file uielem.h.

ListControl* VisibleList::m_pUIElement [private]
 

Definition at line 248 of file uielem.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:03:02 2007 for Camelot by  doxygen 1.4.4