function val = get(A, varargin)
%SCRIBEHGOBJ/GET

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.12 $  $Date: 1998/07/02 19:09:14 $
%   J.H. Roh & B.A. Jones 4-25-97.


narg = size(varargin);
if narg == 1
   val = getone(A,varargin{1});
else
   subs = varargin{1}{1};
   for idx = 1:length(subs)
      val{idx} = getone(A(subs(idx)),varargin{2:end});
   end
end


function val = getone(A,property)

switch property
case 'UIContextMenu'
   val = getappdata(A.HGHandle,'ScribeUIContextMenu');
   return
case 'IsSelected'
   val = A.ObjSelected;
   return
case 'Draggable'
   val = A.Draggable;
case 'DragConstraint'
   val = A.DragConstraint;
case 'SavedState'
   val = A.SavedState;
case 'MyHandle'
   try
      ud = getappdata(A.HGHandle,'ScribeObjectData');
      val = ud.HandleStore;
   catch
      val = [];
      warning('Object is nonexistent or corrupted...');
   end
   return
case 'MyHGHandle'
   val = A.HGHandle;
case 'MyBin'
   val = A.ObjBin;
   if ~isempty(val) & iscell(val)
      val = val{:};
   end
   return
case 'NextItem'
   val = LGetItemI(A,+1);
case 'PrevItem'
   val = LGetItemI(A,-1);
case 'AllItems'
   myhandle = get(A,'myhandle');
   val = A.ObjBin;
   if ~isempty(val) & iscell(val)
      val = val{:};
      if isa(val,'hgbin')
         val = get(val,'items');
      else
         val = myhandle;
      end
   end
case 'OtherItems'
   val = A.ObjBin;
   if ~isempty(val) & iscell(val)
      val = val{:};
      if isa(val,'hgbin')
         siblings = get(val,'items');
         myhandle = get(A,'myhandle');
         val = siblings(find(siblings~=myhandle));
      else
         val = {};
      end
   end
otherwise
   val = get(A.HGHandle, property);
end


function val = LGetItemI(A, offset)

val = A.ObjBin;
if ~isempty(val) & iscell(val)
   val = val{:};
   if isa(val,'hgbin')
      siblings = get(val,'Items');
      myhandle = get(A,'MyHandle');
      iNextItem = find(siblings==myhandle) + offset;
      iNextItem = iNextItem(1);
      if iNextItem >= 1 & iNextItem <= length(siblings)
	 val = siblings(iNextItem);
      else
	 val = {};
      end
   else
      val = {};
   end
end
