function axobj = axisobj(varargin)
%AXISOBJ/AXISOBJ Make axisobj object
%   This file is an internal helper function for plot annotation.

%   Copyright 1984-2004 The MathWorks, Inc. 
%   $Revision: 1.24.4.1 $  $Date: 2004/01/15 21:11:36 $

if nargin==0
   axobj.Class = 'axisobj';
   axobj.Notes = [];
   axobj.FigObj = [];
   axobj.ZoomScale = [];
   axobj = class(axobj,'axisobj',scribehgobj);
   return
end

if nargin==1
   if isa(varargin{1},'axisobj')
      axobj = varargin{1};
      set(axobj,varargin{2:end});
      return
   else
	  ax = varargin{1};
   end
else
   ax = varargin{1};
   if ishandle(ax) & strcmp(get(ax,'type'),'axes')
      set(ax,varargin{2:end});
   else
	  ax = axes;
	  set(ax,varargin{:});
   end
end

fig = get(ax,'Parent');
HGObj = scribehgobj(ax);
HGObj = set(HGObj,'Draggable',0);

LAddContextMenu(ax,fig);

axobj.Class = 'axisobj';
axobj.Notes = [];
axobj.FigObj = figobj(fig);
axobj.ZoomScale = 1;

axobj = class(axobj,'axisobj',HGObj);
scribehandle(axobj);


function u = LAddContextMenu(HG,fig)
u = findall(fig,'Tag','ScribeAxisObjContextMenu');

if ishandle(u)
   % set(HG,'UIContextMenu',u);
   setscribecontextmenu(HG, u);
else
   u = uicontextmenu(...
           'Parent',fig,...
           'Serializable','off', ...
           'HandleVisibility','off',...
           'Callback','domymenu update',...
           'Tag','ScribeAxisObjContextMenu');
   % set(HG,'UIContextMenu',u);
   setscribecontextmenu(HG, u);
   
   
   ucut = uimenu(...
           'Label','Cu&t',...
           'Callback', 'domymenu cut',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxisObjCutMenu');
   ucopy = uimenu(...
           'Label','&Copy',...
           'Callback', 'domymenu copy',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxisObjCopyMenu');
   upaste = uimenu(...
           'Label','&Paste',...
           'Callback', 'domymenu paste',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxisObjPasteMenu');
   uclear = uimenu(...
           'Label','Clea&r',...
           'Callback', 'domymenu clear',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxisObjClearMenu');
   
   u1 = uimenu(...
           'Label','Show Legend',...
           'Callback', 'domymenu showlegend',...
           'Separator','on',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxisObjShowLegendMenu');
   u2 = uimenu(...
           'Label','Lock Position',...
           'Callback', 'domymenu moveresize',...
           'Separator','on',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxisObjMoveResizeMenu');
   % u3 = uimenu(...
   %         'Label','New Axes',...
   %         'Callback', 'axes',...
   %         'Parent',u,...
   %         'HandleVisibility','off',...
   %         'Tag','ScribeAxisObjNewAxesMenu');

   u4 = uimenu(...
              'Label','Properties...',...
              'Callback', 'domymenu more',...
              'Separator','on',...
              'Parent',u,...
              'HandleVisibility','off',...
              'Tag','ScribeAxischildObjMoreMenu');
end



