0001 function [varargout]=logindlg(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 if nargin == 2
0024 Login = varargin{1};
0025 password = varargin{2};
0026 else
0027 Login = '';
0028 password = '';
0029 end
0030
0031
0032 Color = 'w';
0033
0034 set(0,'Units','normalized')
0035 Screen = get(0,'screensize');
0036 Position = [Screen(3)/2 Screen(4)/2 0.2 0.2];
0037 set(0,'Units','pixels')
0038
0039
0040
0041 gui.main = figure('HandleVisibility','on',...
0042 'IntegerHandle','off',...
0043 'Menubar','none',...
0044 'Name','LTPDA Repository Login',...
0045 'NumberTitle','off',...
0046 'Tag','logindlg',...
0047 'Color',Color,...
0048 'Units','normalized',...
0049 'Userdata','logindlg',...
0050 'Position',Position);
0051
0052 set(gui.main,'Closerequestfcn',{@Cancel,gui.main},'Keypressfcn',{@Escape,gui.main})
0053
0054 fsize = getappdata(0, 'ltpda_passwd_win_fontsize');
0055
0056
0057 gui.login_text = uicontrol(gui.main,'Style','text',...
0058 'FontSize',fsize,...
0059 'HorizontalAlign','center',...
0060 'Units','normalized',...
0061 'BackgroundColor','w',...
0062 'String','Login',...
0063 'Position',[0 .7 1 .2]);
0064 gui.password_text = uicontrol(gui.main,'Style','text',...
0065 'FontSize',fsize,...
0066 'HorizontalAlign','center',...
0067 'BackgroundColor','w',...
0068 'Units','normalized',...
0069 'String','Password',...
0070 'Position',[0 .35 1 .2]);
0071
0072
0073 gui.edit1 = uicontrol(gui.main,'Style','edit',...
0074 'FontSize',fsize,...
0075 'HorizontalAlign','left',...
0076 'BackgroundColor','w',...
0077 'Units','normalized',...
0078 'String',Login,...
0079 'Position',[0.05 .6 0.9 .15]);
0080
0081 gui.edit2 = jcontrol(gui.main, 'javax.swing.JPasswordField',...
0082 'BackgroundColor','w',...
0083 'Units','normalized',...
0084 'Position',[0.05 0.3 0.9 0.15]);
0085
0086
0087 gui.OK = uicontrol(gui.main,'Style','push',...
0088 'FontSize',fsize,...
0089 'Units','normalized',...
0090 'String','OK',...
0091 'Position',[0.1 0.05 0.3 0.2],...
0092 'Callback',{@OK,gui.main});
0093
0094 gui.Cancel = uicontrol(gui.main,'Style','push',...
0095 'FontSize',fsize,...
0096 'Units','normalized',...
0097 'String','Cancel',...
0098 'Position',[0.6 0.05 0.3 0.2],...
0099 'Callback',{@Cancel,gui.main});
0100
0101 setappdata(0,'logindlg',gui)
0102 setappdata(gui.main,'Check',0)
0103
0104 uicontrol(gui.edit1)
0105
0106
0107 uiwait(gui.main)
0108
0109 Check = getappdata(gui.main,'Check');
0110
0111
0112 if Check == 1
0113 Login = get(gui.edit1,'String');
0114 Password = get(get(gui.edit2, 'hgcontrol'), 'Text');
0115
0116 varargout(1) = {Login};
0117 varargout(2) = {Password};
0118 else
0119 varargout(1) = {[]};
0120 varargout(2) = {[]};
0121 end
0122
0123 delete(gui.main)
0124 setappdata(0,'logindlg',[])
0125
0126
0127
0128 function Cancel(h,eventdata,fig)
0129 uiresume(fig)
0130 end
0131
0132
0133 function OK(h,eventdata,fig)
0134
0135 setappdata(fig,'Check',1)
0136 uiresume(fig)
0137 end
0138
0139
0140 function Escape(h,eventdata,fig)
0141
0142
0143 key = get(fig,'currentkey');
0144
0145 if isempty(strfind(key,'escape')) == 0 && h == fig
0146 Cancel([],[],fig)
0147 end
0148 end
0149
0150 end