pulsemenu.m
Upload User: loeagle
Upload Date: 2013-03-02
Package Size: 1236k
Code Size: 3k
Development Platform:

Matlab

  1. function rarg = pulsemenu (action);
  2. % menu for choice of pulse shape
  3. global name;
  4. global Buttons;
  5. global menuwinh;
  6. global buttonh;
  7. global MenuWinPos;
  8. Buttons = 4;
  9. ButtonText1 = 'NRZ Rectangular';
  10. ButtonText2 = 'Raised-Cosine';
  11. ButtonText3 = 'Root-RC';
  12. ButtonText4 = 'Main Menu';
  13. if nargin < 1                                           % no argument -> init 
  14.   action = 'init';
  15. end;
  16. % -----------------------------------------------------------------
  17. % init
  18. % initialize variables and open window
  19. if strcmp (action, 'init')
  20.   % constants and definitions
  21.    set(0,'Units','pixels');
  22.    scnsize = get(0,'ScreenSize');
  23.   MenuWinPos  = [10 (scnsize(4) - (Buttons*28+50)-40)];  % window position
  24.   pulsemenu ('openmenuwin');                                % open window
  25. end;
  26. % -----------------------------------------------------------------
  27. % openmenuwin
  28. % open window
  29. if strcmp (action, 'openmenuwin')
  30.  
  31.   menuwinh = figure ('Color', 'white', ...              % open window
  32.     'Position', [MenuWinPos 160 (Buttons*28+50)], ... 
  33.     'Name', 'Tutorial', ...
  34.     'NumberTitle', 'off', ...
  35.     'MenuBar', 'none', ...
  36.     'Resize', 'off', ...
  37.     'UserData', 'pulsemenu');
  38.   uicontrol (menuwinh, ...
  39.     'Style', 'text', ...
  40.     'Position', [5 (Buttons*28+5) 150 30], ...
  41.     'BackgroundColor', 'white', ...
  42.     'HorizontalAlignment', 'center', ...
  43.     'String', 'Pulse Shape');
  44.   for k = 1:Buttons
  45.     ypos = (Buttons- k) * 28 + 10;
  46.     ButtonTextString = eval (['ButtonText'  num2str(k)]);
  47.     CallBackFunction = ['Button' num2str(k)];
  48.     createbutton = ['buttonh(' num2str(k) ') = uicontrol (menuwinh, ' ...
  49.                         '''Position'', [5 ' num2str(ypos) ' 150 22], ' ...
  50.                          '''String'', ''' ButtonTextString ''', ' ...
  51.                          '''BackgroundColor'', ''white'', ' ...
  52.                          '''CallBack'', ''pulsemenu (''''' CallBackFunction ''''')'');'];
  53.    eval (createbutton);
  54.   end;
  55.   clear createbutton ypos ButtonTextStr CallBackFunction;
  56. end;
  57. % -----------------------------------------------------------------
  58. % Button1
  59. if strcmp (action, 'Button1')
  60.   delete(menuwinh);
  61.   name=[name,'nrz'];
  62.   filtmen;
  63. end;
  64. % -----------------------------------------------------------------
  65. % Button2
  66. if strcmp (action, 'Button2')
  67.   delete(menuwinh);
  68.   name=[name,'nyq'];
  69.   name=[name,'mf'];
  70.   backmen;
  71.   eval(name);
  72. end;
  73. % -----------------------------------------------------------------
  74. % Button3
  75. if strcmp (action, 'Button3')
  76.   delete(menuwinh);
  77.   name=[name,'wny'];
  78.   name=[name,'mf'];
  79.   backmen;
  80.   eval(name);
  81. end;
  82. % -----------------------------------------------------------------
  83. % Button4
  84. if strcmp (action, 'Button4')
  85.   delete(menuwinh);
  86.   DigModTutorial;
  87. end;