%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % DEMO M FILE FOR EDITNUM, EDITLIST, EDITTEXT, % % UIRADIO, UISWITCH AND UICPUSH FUNCTIONS. % % % % Claudio 10.7.96 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Make the figure figure('position', [300 300 700 600], 'color', [0.55 .55 .55],... 'NumberTitle', 'off', 'name', 'claudio@alice.uoregon.edu'); %Title text Tit=uicontrol(gcf, 'style', 'text',... 'background', 'k',... 'fore', 'g',... 'string', 'EDITNUM, EDITLIST, EDITTEXT, UIRADIO, UISWITCH AND UICPUSH DEMO',... 'units', 'norm',... 'pos', [0 0.95 1 0.05]); %------ NUMBERS WITH BUTTONS TOOLS ----- uicontrol(gcf, 'style', 'text',... 'string', 'Edit Numbers',... 'units', 'norm',... 'pos', [0.03 0.90 0.24 0.04],... 'backgr', [0.55 .55 .55],... 'fore', 'b'); %Upper left cbk='set(Tit, ''background'', [0 0 get(gco, ''value'')])'; h=editnum(gcf, 0, 1, 0.1, 'FLOAT_BT_RR',... 'units','norm',... 'pos', [.03 .85 0.1 0.04],... 'callback', cbk); %Second left h=editnum(gcf, -10, 10, 2, 'INT_BT_LL',... 'units','norm',... 'pos', [.03 .75 0.1 0.04],... 'Horiz', 'left'); %Third left h=editnum(gcf, 0, 1, 0.01, 'FLOAT_BT_LR',... 'units','norm',... 'pos', [.03 .65 0.1 0.04],... 'style', 'text'); %Fourth left h=editnum(gcf, 0, 1000, 25, 'INT_BT_BB',... 'units','norm',... 'pos', [.03 .55 0.1 0.06],... 'Horiz', 'right',... 'string', '200'); set(h, 'background', 'k', 'foreground', 'y'); %------ NUMBERS WITH SCROLLBAR TOOLS ------ %Upper middle cbk='set(Tit, ''foreground'', [get(gco, ''value'') 1-get(gco, ''value'') 0])'; h=editnum(gcf, 0, 1, 0.1, 'FLOAT_SL_B',... 'units','norm',... 'pos', [.17 .85 0.1 0.05],... 'callback', cbk); %Second middle h=editnum(gcf, -10, 10, 2, 'INT_SL_T',... 'units','norm',... 'pos', [.17 .75 0.1 0.05],... 'Horiz', 'left',... 'string', '5'); %Third middle h=editnum(gcf, 0, 1, 0.01, 'FLOAT_SL_L',... 'units','norm',... 'pos', [.17 .65 0.1 0.04],... 'style', 'text'); %Fourth middle h=editnum(gcf, 0, 1000, 25, 'INT_SL_R',... 'units','norm',... 'pos', [.17 .55 0.1 0.04],... 'Horiz', 'right',... 'string', '200'); set(h, 'background', 'k', 'foreground', 'y'); %------- EDITLIST ------ uicontrol(gcf, 'style', 'text',... 'string', 'Edit lists',... 'units', 'norm',... 'pos', [0.3 0.90 0.15 0.04],... 'backgr', [0.55 .55 .55],... 'fore', 'b'); editlist(gcf, 'BT_RR',... 'units','norm',... 'pos', [.3 .85 0.15 0.04],... 'string', 'Item 1|Item 2|Item 3|Item 4|Item 5|Item 6|Item 7|Item 8|Item 9'); editlist(gcf, 'SL_B',... 'units','norm',... 'pos', [.3 .75 0.15 0.06],... 'string', 'Zoff|Gentile|Cabrini|Scirea|Tardelli|Benetti|Conti|Antonioni|Altobelli|Rossi|Graziani'); %------- UIRADIOBUTTONS ------ %All the five radio buttons in the figure hr=uiradio(gcf, 'string', 'radio 1|radio 2|radio 3|radio 4|radio 5',... 'value', 3,... 'units', 'norm',... 'pos', [.5 .75 .45 .15],... 'user', [1 0 1;0 1 0;1 0 1],... 'min', 5,... 'max', 5,... 'horiz', 'left'); %Text to display selected radio ht=uicontrol(gcf, 'style', 'text',... 'units', 'norm',... 'pos', [0.67 0.9 0.1 0.04],... 'backgr', [0 .55 .55],... 'fore', 'y'); %Pushbutton to display selected radio uicontrol(gcf, 'style', 'push',... 'units', 'norm',... 'pos', [0.5 0.9 0.15 0.04],... 'string', 'Who is on?',... 'call', 'set(ht, ''string'', int2str(get(hr, ''value'')))'); %------ UI SWITCHES ------ uicontrol(gcf, 'style', 'text',... 'string', 'Ui Switches',... 'units', 'norm',... 'pos', [0.42 0.68 0.2 0.04],... 'backgr', [0.55 .55 .55],... 'fore', 'b'); uiswitch(gcf, 'units', 'norm',... 'pos', [0.37 0.55 0.05 0.12],... 'fore', 'r', 'value', 1,... 'userdata', 'LIGHT_VT'); uiswitch(gcf, 'units', 'norm',... 'pos', [0.44 0.55 0.05 0.12],... 'fore', 'r', 'value', 1,... 'userdata', 'TEXT_VT'); uiswitch(gcf, 'units', 'norm',... 'pos', [0.52 0.62 0.15 0.05],... 'fore', 'y', 'value', 1,... 'string', '<>',... 'userdata', 'LIGHT_HZ'); uiswitch(gcf, 'units', 'norm',... 'pos', [0.52 0.55 0.15 0.05],... 'fore', 'y', 'value', 1,... 'string', '1|0|X',... 'userdata', 'TEXT_HZ'); %------ CYCLIC BUTTONS (UICPUSH) ------ uicontrol(gcf, 'style', 'text',... 'string', 'Cyclic Buttons',... 'units', 'norm',... 'pos', [0.77 0.68 0.2 0.04],... 'backgr', [0.55 .55 .55],... 'fore', 'b'); cbt1=uicontrol(gcf, 'style', 'text',... 'units', 'norm',... 'pos', [0.72 0.62 0.07 0.05],... 'string', '',... 'backgr', [0 .55 .55],... 'fore', 'y'); cbt2=uicontrol(gcf, 'style', 'text',... 'units', 'norm',... 'pos', [0.72 0.55 0.07 0.05],... 'string', '',... 'backgr', [0 .55 .55],... 'fore', 'y'); uicpush(gcf, 'units', 'norm',... 'pos', [0.80 0.62 0.15 0.05],... 'string', 'I am|a cyclic|button|and I can|cycle in|different|ways',... 'max', 1,... 'callback', 'set(cbt1, ''string'', int2str(get(gco, ''value'')))'); uicpush(gcf, 'units', 'norm',... 'pos', [0.80 0.55 0.15 0.05],... 'string', 'I am|a cyclic|button|and I can|cycle in|different|ways',... 'max', 2,... 'callback', 'set(cbt2, ''string'', int2str(get(gco, ''value'')))'); %Simple text uicontrol(gcf, 'style', 'text',... 'units', 'norm',... 'pos', [0.025 0.48 0.28 0.04],... 'string', 'Edit text READ_ONLY',... 'backgr', [0.55 .55 .55],... 'fore', 'b'); %Simple text uicontrol(gcf, 'style', 'text',... 'units', 'norm',... 'pos', [0.525 0.48 0.28 0.04],... 'string', 'Edit text READ_WRITE',... 'backgr', [0.55 .55 .55],... 'fore', 'b'); %Print pushbutton uicontrol(gcf, 'style', 'push',... 'units', 'norm',... 'pos', [0.3 0.48 0.16 0.04],... 'string', 'Print',... 'Call', 'disp(edittext(eh1, ''GETTEXT''))'); %Print pushbutton uicontrol(gcf, 'style', 'push',... 'units', 'norm',... 'pos', [0.8 0.48 0.16 0.04],... 'string', 'Print',... 'Call', 'disp(edittext(eh2, ''GETTEXT''))'); %------ TEXT EDITORS ------ %Text editor read_only eh1=edittext(0, 'INIT', 'VTRHZB',... 'units', 'norm',... 'pos', [0.025 0.025 0.45 0.45],... 'value', 0); %Text editor read_write eh2=edittext(0, 'INIT', 'VTLHZT',... 'units', 'norm',... 'pos', [0.525 0.025 0.45 0.45],... 'value', 1); %Load text sample from README file txt=readtext('README'); %Display the text in the two editors edittext(eh1, 'SETTEXT', txt); edittext(eh2, 'SETTEXT', txt); %That's all folk!