JG ROOT Tools libraries  version 5.0 - august 2014
RGItemSelectionBox Class Reference

#include <RGItemSelectionBox.hh>

Inheritance diagram for RGItemSelectionBox:

Public Member Functions

 RGItemSelectionBox (TGWindow *p, const char *txt_src=NULL, const char *txt_dest=NULL, const UInt_t opts=0, const UInt_t w_min=80, const UInt_t h_min=80)
 
virtual ~RGItemSelectionBox ()
 
virtual void MapSubwindows ()
 
virtual RGItemListBoxGetSrcItemListBox () const
 
virtual RGItemListBoxGetDestItemListBox () const
 
virtual TGVerticalFrame * GetCenterFrame () const
 
virtual TGButton * AddSrcButton (const char *text, const Int_t id, const char *tooltip=NULL)
 
virtual TGButton * AddSrcButton (TGButton *but, const Int_t id)
 
virtual TGButton * AddDestButton (const char *text, const Int_t id, const char *tooltip=NULL)
 
virtual TGButton * AddDestButton (TGButton *but, const Int_t id)
 
virtual TGButton * AddCenterButton (const char *text, const Int_t id, const char *tooltip=NULL)
 
virtual TGButton * AddCenterButton (TGButton *but, const Int_t id)
 
virtual TGFrame * AddSrcBottomFrame (TGFrame *f, TGLayoutHints *l=NULL)
 
virtual TGFrame * AddDestBottomFrame (TGFrame *f, TGLayoutHints *l=NULL)
 
virtual Int_t AddItem (const string &s, void *ptr=NULL, const Bool_t update=true)
 
virtual Int_t AddItem (const GItem &d, const Bool_t update=true)
 
virtual Int_t AddItem (GItem *d, const Bool_t update=true)
 
virtual void RemoveItem (const Int_t n, const Bool_t update=true)
 
virtual GItem * GetItem (Int_t id) const
 
virtual GSubItem * GetSrcItem (Int_t id) const
 
virtual GSubItem * GetDestItem (Int_t id) const
 
virtual void SrcSelectionRemove ()
 
virtual void DestSelectionRemove ()
 
virtual GItemListIter SrcBegin () const
 
virtual GItemListIter SrcEnd () const
 
virtual GItemListIter DestBegin () const
 
virtual GItemListIter DestEnd () const
 
virtual GItemListIter Begin () const
 
virtual GItemListIter End () const
 
virtual GItemListIter Null () const
 
virtual Int_t GetSize () const
 
virtual Int_t GetSrcSize () const
 
virtual Int_t GetDestSize () const
 
virtual void UpdateSelectionBox ()
 
virtual Int_t ItemToDest (const Int_t num, const Bool_t update=false)
 
virtual Int_t SrcItemToDest (const Int_t num, const Bool_t update=false)
 
virtual void SrcDoubleClicked (Int_t n)
 
virtual void DestDoubleClicked (Int_t n)
 
virtual void SrcSelectionToDest ()
 
virtual void DestSelectionToSrc ()
 
virtual void ItemRemoved (ULong_t ptr)
 
virtual void SrcItemRemoved (ULong_t ptr)
 
virtual void DestItemRemoved (ULong_t ptr)
 
virtual void CustomClicked (Int_t id)
 
virtual void SelectionChanged ()
 
virtual void SrcSelectionChanged ()
 
virtual void DestSelectionChanged ()
 
 ClassDef (RGItemSelectionBox, 0)
 

Protected Member Functions

 RGItemSelectionBox (const RGItemSelectionBox &original)
 
virtual void RemoveSelectedItem (const Bool_t update=true)
 
virtual void RemoveSubItems (GItem *supp, const Bool_t update=true, const Bool_t sub_signal=true)
 
virtual void SelectionRemove (RGItemListBox *ilb)
 

Protected Attributes

UInt_t list_w_min
 List widget minimum width.
 
UInt_t list_h_min
 List widget minimum height.
 
UInt_t options
 Widget options.
 
GItemList item_list
 Input list of elements (global list)
 
RGItemListBoxsrc_box
 Source selection box.
 
RGItemListBoxdest_box
 Destination selection box.
 
TGVerticalFrame * w_center_frame
 Central frame for buttons.
 
TGTextButton * w_add_button
 Add to selection button.
 
TGTextButton * w_remove_button
 Remove from selection button.
 

Private Member Functions

 GObject (RGItemSelectionBox)
 

Detailed Description

This class defines a widget with 2 lists for selection of elements. One list (on the left) is the source of objects, the other one (on the right), is the selection. Each list management is based on a RGItemListBox object.

The class RGItemSelectionBox only defines one list of objects as an input (the global list), and the elements of this global list are copied in the source and destination lists of RGItemListBox objects.

The elements of the source and destination lists have the same name than the elements from the global list, and the user data pointer is set to the global list GItem (and not to the user object itself). Thus, elements from the source or destination lists is uniquely associated to a element in the global list: if an element is removed in the global list is removed, all elements corresponding in the source and destination sub-lists are removed also. But if the global list element was present several times in the list, these elements are not removed.

The user data for source and destination lists can be modified compared to the global list, and can be different in source and destination sub-lists. This feature allows for example to set specific properties to the selected objects, and keep track of the information until the end of use of the selection widget. This requires to have specific signals when elements from the source or the destination sub-lists are removed (such signal is not emitted when the element is moved between source and destination sub-lists).

RGItemSelectionBox.gif

The options are in principle fixed at widget creation.

  • options for labels of source and destination lists
    • rgISBLabelsCenterAligned: labels centered (default)
    • rgISBLabelsLeftAligned: labels left aligned
    • rgISBLabelsRightAligned: labels right aligned
    • rgISBLabelsExternAligned: labels at external side
    • rgISBLabelsInternAligned: labels at internal side
    • rgISBLabelsAboveList: labels above lists (default)
    • rgISBLabelsBelowList: labels below lists
  • options for central and side buttons position
    • rgISBSideButtonsCenter: buttons vertically centered (default)
    • rgISBSideButtonsUp: buttons aligned top
    • rgICBSideButtonsDown: buttons aligned bottom
  • options for lists
    • rgISBMultipleSelection: same input can be selected several times for output
    • rgISBUniqueItem: source elements are unique (name and data pointer)
    • rgISBUniqueName: source elements have unique name (more restrictive than rgISBUniqueItem)
    • rgISBNoCaseSensitive: not case sensitive
    • rgISBDictSort: not case/accent sensitive for sorting
    • rgISBAlwaysSorted: list is always sorted
    • rgISBReverseSort: invert sorting order
    • rgISBAlwaysReverseSorted: list is always sorted in reverse order
  • options for source and destination sub-lists
    • rgISBMoveSrcButtons: move buttons for source elements
    • rgISBMoveDestButtons: move buttons for destination elements

Constructor & Destructor Documentation

RGItemSelectionBox::RGItemSelectionBox ( TGWindow *  p,
const char *  txt_src = NULL,
const char *  txt_dest = NULL,
const UInt_t  opts = 0,
const UInt_t  w_min = 80,
const UInt_t  h_min = 80 
)

Constructor.

Parameters
pparent widget
txt_srcsource list label
txt_destdestination list label
optsoptions
w_minminimum width of list widget
h_minminimum height of list widget

References dest_box, item_list, list_h_min, list_w_min, options, src_box, w_add_button, w_center_frame, and w_remove_button.

RGItemSelectionBox::RGItemSelectionBox ( const RGItemSelectionBox original)
protected

Copy constructor, not implemented.

Parameters
originalobject to copy

References dest_box, src_box, w_add_button, w_center_frame, and w_remove_button.

RGItemSelectionBox::~RGItemSelectionBox ( )
virtual

Destructor.

References item_list, and RemoveItem().

Member Function Documentation

RGItemSelectionBox::GObject ( RGItemSelectionBox  )
private

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
void RGItemSelectionBox::MapSubwindows ( )
virtual

Overload of TGFrame function.

Referenced by AddCenterButton(), AddDestButton(), and AddSrcButton().

RGItemListBox * RGItemSelectionBox::GetSrcItemListBox ( ) const
inlinevirtual

Get source list widget pointer.

References src_box.

RGItemListBox * RGItemSelectionBox::GetDestItemListBox ( ) const
inlinevirtual

Get destination list widget pointer.

References dest_box.

TGVerticalFrame * RGItemSelectionBox::GetCenterFrame ( ) const
inlinevirtual

Get central buttons frame pointer.

References w_center_frame.

TGButton * RGItemSelectionBox::AddSrcButton ( const char *  text,
const Int_t  id,
const char *  tooltip = NULL 
)
virtual

Add a button to source list side buttons. The button emits a signal CustomClicked(Int_t id).

Parameters
textbutton text
idbutton identification number
tooltipinformation message
TGButton * RGItemSelectionBox::AddSrcButton ( TGButton *  but,
const Int_t  id 
)
virtual

Add a button to source list side buttons. The button emits a signal CustomClicked(Int_t id).

Parameters
butbutton pointer
idbutton identification number

References RGItemListBox::GetSideFrame(), MapSubwindows(), and src_box.

TGButton * RGItemSelectionBox::AddDestButton ( const char *  text,
const Int_t  id,
const char *  tooltip = NULL 
)
virtual

Add a button to destination list side buttons. The button emits a signal CustomClicked(Int_t id).

Parameters
textbutton text
idbutton identification number
tooltipinformation message
TGButton * RGItemSelectionBox::AddDestButton ( TGButton *  but,
const Int_t  id 
)
virtual

Add a button to destination list side buttons. The button emits a signal CustomClicked(Int_t id).

Parameters
butbutton pointer
idbutton identification number

References dest_box, RGItemListBox::GetSideFrame(), and MapSubwindows().

TGButton * RGItemSelectionBox::AddCenterButton ( const char *  text,
const Int_t  id,
const char *  tooltip = NULL 
)
virtual

Add a button to the central buttons area. The button emits a signal CustomClicked(Int_t id).

Parameters
textbutton text
idbutton identification number
tooltipinformation message
TGButton * RGItemSelectionBox::AddCenterButton ( TGButton *  but,
const Int_t  id 
)
virtual

Add a button to the central buttons area. The button emits a signal CustomClicked(Int_t id).

Parameters
butbutton pointer
idbutton identification number

References MapSubwindows(), and w_center_frame.

TGFrame * RGItemSelectionBox::AddSrcBottomFrame ( TGFrame *  f,
TGLayoutHints *  l = NULL 
)
inlinevirtual

Add a bottom frame to source list widget.

Parameters
fframe pointer
llayout pointer

References RGItemListBox::AddBottomFrame(), and src_box.

TGFrame * RGItemSelectionBox::AddDestBottomFrame ( TGFrame *  f,
TGLayoutHints *  l = NULL 
)
inlinevirtual

Add a bottom frame to destination list widget.

Parameters
fframe pointer
llayout pointer

References RGItemListBox::AddBottomFrame(), and dest_box.

Int_t RGItemSelectionBox::AddItem ( const string &  s,
void *  ptr = NULL,
const Bool_t  update = true 
)
inlinevirtual

Add an item to the global list. If the element is accepted, a GSubItem is added to the source list, with same name and a pointer to the global list RGItem.

The function returns the index of the added element (in global list) and -1 in case of failure.

The list-box is updated, except if argument update is false. This should only be used in cases several elements will be added. In such case, only the objects list is updated (item_list), and not the list-box widgets.

Parameters
selement name
ptruser data pointer
updateflag for list-box update

Referenced by AddItem().

Int_t RGItemSelectionBox::AddItem ( const GItem &  item,
const Bool_t  update = true 
)
inlinevirtual

Add an item to the global list (the item is cloned). If the element is accepted, a GSubItem is added to the source list, with same name and a pointer to the global list RGItem.

The function returns the index of the added element (in global list) and -1 in case of failure.

The list-box is updated, except if argument update is false. This should only be used in cases several elements will be added. In such case, only the objects list is updated (item_list), and not the list-box widgets.

Parameters
itemelement to add (cloned)
updateflag for list-box update

References AddItem().

Int_t RGItemSelectionBox::AddItem ( GItem *  item,
const Bool_t  update = true 
)
virtual

Add an item to the global list (the item is adopted). If the element is accepted, a GSubItem is added to the source list, with same name and a pointer to the global list RGItem.

The function returns the index of the added element (in global list) and -1 in case of failure.

The list-box is updated, except if argument update is false. This should only be used in cases several elements will be added. In such case, only the objects list is updated (item_list), and not the list-box widgets.

Parameters
itempointer to the element to add (adopted)
updateflag for list-box update

References RGItemListBox::AddItem(), item_list, and src_box.

void RGItemSelectionBox::RemoveItem ( const Int_t  n,
const Bool_t  update = true 
)
virtual

Remove an element from the global list. Default behavior is that the list-box is updated from the list of elements, except if argument update is false. This should only be used in cases several elements will be removed. In such case, only the objects list is updated (item_list), and not the list-box widgets. All elements from the source and destination list corresponding to this item are removed.

Parameters
nindex of element to remove
updateflag for list-boxes update

References item_list, ItemRemoved(), and RemoveSubItems().

Referenced by ~RGItemSelectionBox().

GItem * RGItemSelectionBox::GetItem ( Int_t  id) const
inlinevirtual

Get the pointer to a element of the global list.

Parameters
idelement number

References item_list.

GSubItem * RGItemSelectionBox::GetSrcItem ( Int_t  id) const
inlinevirtual

Get the pointer to a element of the source list.

Parameters
idelement number

References RGItemListBox::GetItem(), and src_box.

GSubItem * RGItemSelectionBox::GetDestItem ( Int_t  id) const
inlinevirtual

Get the pointer to a element of the destination list.

Parameters
idelement number

References dest_box, and RGItemListBox::GetItem().

void RGItemSelectionBox::RemoveSelectedItem ( const Bool_t  update = true)
protectedvirtual

Remove all selected elements (from selction flag) from the global list. This function is used by the functions that remove selected elements in source or destination list.

Parameters
updateflag for list-boxes update

References item_list, ItemRemoved(), RemoveSubItems(), and UpdateSelectionBox().

Referenced by SelectionRemove().

void RGItemSelectionBox::RemoveSubItems ( GItem *  supp,
const Bool_t  update = true,
const Bool_t  sub_signal = true 
)
protectedvirtual

Remove elements in source and destination lists that correspond to the argument item pointer. This function is called by the functions removing elements in the global list.

Parameters
supppointer to item to be removed from global list
updateflag for list-box update
sub_signalindicate if signals for removal of source and destination (sub-) lists elements must be sent

References dest_box, DestItemRemoved(), RGItemListBox::GetItem(), RGItemListBox::GetItemNumber(), RGItemListBox::RemoveItem(), src_box, SrcItemRemoved(), and RGItemListBox::UpdateListBox().

Referenced by RemoveItem(), and RemoveSelectedItem().

void RGItemSelectionBox::SrcSelectionRemove ( )
inlinevirtual

Remove from global list the elements selected in the source list.

References SelectionRemove(), and src_box.

void RGItemSelectionBox::DestSelectionRemove ( )
inlinevirtual

Remove from global list the elements selected in the destination list.

References dest_box, and SelectionRemove().

void RGItemSelectionBox::SelectionRemove ( RGItemListBox ilb)
protectedvirtual

Remove from global list the selected elements in the argument list (that is either the source or the destination list).

Parameters
ilbpointer to RGItemListBox selection widget

References RGItemListBox::Begin(), dest_box, RGItemListBox::GetSelectedNumber(), item_list, RGItemListBox::Null(), RemoveSelectedItem(), and src_box.

Referenced by DestSelectionRemove(), and SrcSelectionRemove().

GItemListIter RGItemSelectionBox::SrcBegin ( ) const
inlinevirtual

Get the iterator on first element of source list.

References RGItemListBox::Begin(), and src_box.

Referenced by ItemToDest(), and SrcItemToDest().

GItemListIter RGItemSelectionBox::SrcEnd ( ) const
inlinevirtual

Get the iterator on last element of source list.

References RGItemListBox::End(), and src_box.

GItemListIter RGItemSelectionBox::DestBegin ( ) const
inlinevirtual

Get the iterator on first element of destination list.

References RGItemListBox::Begin(), and dest_box.

GItemListIter RGItemSelectionBox::DestEnd ( ) const
inlinevirtual

Get the iterator on last element of destination list.

References dest_box, and RGItemListBox::End().

GItemListIter RGItemSelectionBox::Begin ( ) const
inlinevirtual

Get the iterator on first element of global list.

References item_list.

Referenced by ItemToDest().

GItemListIter RGItemSelectionBox::End ( ) const
inlinevirtual

Get the iterator on last element of global list.

References item_list.

GItemListIter RGItemSelectionBox::Null ( ) const
inlinevirtual

Get the null iterator of list of elements.

References item_list.

Referenced by ItemToDest(), and SrcItemToDest().

Int_t RGItemSelectionBox::GetSize ( ) const
inlinevirtual

Get the global list number of elements (size).

References item_list.

Int_t RGItemSelectionBox::GetSrcSize ( ) const
inlinevirtual

Get the source list number of elements (size).

References RGItemListBox::GetSize(), and src_box.

Int_t RGItemSelectionBox::GetDestSize ( ) const
inlinevirtual

Get the destination list number of elements (size).

References dest_box, and RGItemListBox::GetSize().

void RGItemSelectionBox::UpdateSelectionBox ( )
inlinevirtual

Update display of the source and destination list-boexes.

References dest_box, src_box, and RGItemListBox::UpdateListBox().

Referenced by RemoveSelectedItem().

Int_t RGItemSelectionBox::ItemToDest ( const Int_t  num,
const Bool_t  update = false 
)
virtual

Set a element of global list in the destination list (final selection). The signal for selection change is sent. The function returns the destination list index (or -1 in case of problem).

Parameters
numelement number in global list
updateflag for list-boxex update

References Begin(), Null(), SrcBegin(), and SrcItemToDest().

Int_t RGItemSelectionBox::SrcItemToDest ( const Int_t  num,
const Bool_t  update = false 
)
virtual

Send a element of source list in the destination list (final selection). The signal for selection change is sent. The function returns the destination list index (or -1 in case of problem).

Parameters
numelement number in global list
updateflag for list-boxex update

References RGItemListBox::AddItem(), dest_box, Null(), options, RGItemListBox::RemoveItem(), SelectionChanged(), src_box, SrcBegin(), and RGItemListBox::UpdateListBox().

Referenced by ItemToDest().

void RGItemSelectionBox::SrcDoubleClicked ( Int_t  n)
virtual

Slot called when an element of source list is double-clicked: selected elements in the source list are sent to the destination list.

Parameters
nnumber of the double-clicked element (source list)

References SrcSelectionToDest().

void RGItemSelectionBox::DestDoubleClicked ( Int_t  n)
virtual

Slot called when an element of destination list is double-clicked: selected elements in the destination list are returned to the source list.

Parameters
nnumber of the double-clicked element (destination list)

References DestSelectionToSrc().

void RGItemSelectionBox::SrcSelectionToDest ( )
virtual

Slot called when sending an element from the source list to the destination list. If multiple instance selection is active, the objects are dupplicated in the destination list, but not removed from the source list. In any case, there is no emission of the remove signal, since elements are either copied, or moved, but not suppressed.

References RGItemListBox::AddItem(), RGItemListBox::Begin(), dest_box, DestSelectionChanged(), RGItemListBox::GetSelectedNumber(), RGItemListBox::Null(), options, RGItemListBox::Select(), SelectionChanged(), RGItemListBox::SelectionRemove(), src_box, SrcSelectionChanged(), and RGItemListBox::UpdateListBox().

Referenced by SrcDoubleClicked().

void RGItemSelectionBox::DestSelectionToSrc ( )
virtual

Slot called when returning an element from the destination list to the source list. If multiple instance selection is active, the objects are just removed from the destination list, else they are sent back to the source list. In case they are deleted, the signal for removal of detsination elements is sent.

References RGItemListBox::AddItem(), RGItemListBox::Begin(), dest_box, DestItemRemoved(), DestSelectionChanged(), RGItemListBox::GetItem(), RGItemListBox::GetItemNumber(), RGItemListBox::GetSelectedNumber(), RGItemListBox::Null(), options, RGItemListBox::RemoveItem(), RGItemListBox::Select(), SelectionChanged(), src_box, SrcSelectionChanged(), and RGItemListBox::UpdateListBox().

Referenced by DestDoubleClicked().

void RGItemSelectionBox::ItemRemoved ( ULong_t  ptr)
inlinevirtual

Signal sent when removing an element from the global list.

Parameters
ptrpointer (converted to ULong_t) on the user data of the element

Referenced by RemoveItem(), and RemoveSelectedItem().

void RGItemSelectionBox::SrcItemRemoved ( ULong_t  ptr)
inlinevirtual

Signal sent when an element is removed from the source list. The signal is not sent if the element is just moved to the destination list.

Parameters
ptrpointer (converted to ULong_t) on the user data of the element

Referenced by RemoveSubItems().

void RGItemSelectionBox::DestItemRemoved ( ULong_t  ptr)
inlinevirtual

Signal sent when an element is removed from the destination list. The signal is not sent if the element is just moved to the source list.

Parameters
ptrpointer (converted to ULong_t) on the user data of the element

Referenced by DestSelectionToSrc(), and RemoveSubItems().

void RGItemSelectionBox::CustomClicked ( Int_t  id)
inlinevirtual

Signal sent when a user button is clicked.

Parameters
ididentification number of the button
void RGItemSelectionBox::SelectionChanged ( )
inlinevirtual

Signal sent when selection list (destination) has been modified.

Referenced by DestSelectionToSrc(), SrcItemToDest(), and SrcSelectionToDest().

void RGItemSelectionBox::SrcSelectionChanged ( )
inlinevirtual

Signal sent when selection in source list has changed.

Referenced by DestSelectionToSrc(), and SrcSelectionToDest().

void RGItemSelectionBox::DestSelectionChanged ( )
inlinevirtual

Signal sent when selection in destination list has changed.

Referenced by DestSelectionToSrc(), and SrcSelectionToDest().

RGItemSelectionBox::ClassDef ( RGItemSelectionBox  ,
 
)

For ROOT dictionary.


The documentation for this class was generated from the following files: