function txtobj = axistext(x,y,str,varargin)
%AXISTEXT/AXISTEXT

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.19 $  $Date: 2000/08/01 22:09:31 $
%   B.A. Jones & J.H. Roh 4-25-97.

if nargin==0
   txtobj.Class = 'axistext';
   txtobj.Notes = [];
   txtobj = class(txtobj,'axistext',axischild);
   return
end

if nargin == 1
   HG = x;
   if ishandle(getobj(HG))
      return
   end
else
   HG = text(x,y,str);
   set(HG,varargin{:});
end

axischildObj = axischild(HG);
% enable dragging for text objects
axischildObj = set(axischildObj,'DragConstraint','');
set(HG,'CreateFcn','');
setappdata(HG,'ScribeButtonDownFcn','doclick');

txtobj.Class = 'axistext';
txtobj.Notes = [];

txtobj = class(txtobj,'axistext',axischildObj);

fig = get(get(HG,'Parent'),'Parent');
u = findall(fig,'Tag','ScribeAxistextObjContextMenu');

if ishandle(u)
   if length(u)>1, warning('redundant context menus...'), end
   % set(HG,'UIContextMenu',u(1));
   setscribecontextmenu(HG,u(1));
else
   u = uicontextmenu(...
           'Parent',fig,...
           'Serializable','off', ...
           'HandleVisibility','off',...
           'Callback','domymenu update',...
           'Tag','ScribeAxistextObjContextMenu');

   % set(HG,'UIContextMenu',u);
   setscribecontextmenu(HG,u);
   
   ucut = uimenu(...
           'Label','Cu&t',...
           'Callback', 'domymenu cut',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjCutMenu');
   ucopy = uimenu(...
           'Label','&Copy',...
           'Callback', 'domymenu copy',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjCopyMenu');
   upaste = uimenu(...
           'Label','&Paste',...
           'Callback', 'domymenu paste',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjPasteMenu');
   uclear = uimenu(...
           'Label','Clea&r',...
           'Callback', 'domymenu clear',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjClearMenu');

   u0 = uimenu(...
           'Label','&String...',...
           'Callback', 'domymenu string',...
           'Separator', 'on',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjStringMenu');
   u1 = uimenu(...
           'Label','&Font Size',...
           'Callback', 'domymenu size',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjSizeMenu');
   u2 = uimenu(...
           'Label','Font St&yle',...
           'Callback', 'domymenu style',...        
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjStyleMenu');
   u3 = uimenu(...
           'Label','Co&lor...',...
           'Callback', 'domymenu color',...        
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjColorMenu');
   u4 = uimenu(...
           'Label','&Properties...',...
           'Callback', 'domymenu font',...
           'Enable','on',...
           'Separator','on',...
           'Parent',u,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjMoreMenu');

   sizes = [4 6 8 9 10 11 12 14 18 24 32];
   for i = 1:length(sizes)
      val = num2str(sizes(i));
      uimenu(...
           'Label',val,...
           'Callback', ['domymenu size ' val],...        
           'Parent',u1,...
           'HandleVisibility','off',...
           'Tag',['ScribeEditlineObjSizeMenu' val]);
   end
   u1more = uimenu(...
           'Label', 'more...',...
           'Callback', 'domymenu font',...
           'Enable','on',...
           'Parent',u1,...
           'HandleVisibility','off',...
           'Tag','ScribeEditlineObjSizeMenuMore');
   
   u21 =  uimenu(...
           'Label','&Normal',...
           'Callback', 'domymenu style normal',...        
           'Parent',u2,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjStyleMenuNormal');
   u22 =  uimenu(...
           'Label','&Italic',...
           'Callback', 'domymenu style italic',...
           'Parent',u2,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextdObjStyleMenuItalic');
   u23 =  uimenu(...
           'Label','&Bold',...
           'Callback', 'domymenu style bold',...        
           'Parent',u2,...
           'HandleVisibility','off',...
           'Tag','ScribeAxistextObjStyleMenuBold');

end

