-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinsertSnippetAboutDlg.m
104 lines (91 loc) · 2.91 KB
/
insertSnippetAboutDlg.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function insertSnippetAboutDlg(versionStr)
figSize = [ 400 300 ];
screenSize = get(0, 'ScreenSize');
hFig = figure( ...
'WindowStyle', 'modal', ...
'Position', [ 0.5*screenSize(3:4)-0.5*figSize figSize ], ...
'DockControls', 'off', ...
'MenuBar', 'none', ...
'NumberTitle', 'off', ...
'Name', 'About', ...
'KeyPressFcn', @figureKeyPressFcn ...
);
hPanel = uipanel(hFig, ...
'Title','', ...
'Units','pixels',...
'Position',[10 figSize(2)-78 380 68] );
axes(hPanel,'Units','pixels','Position',[10 10 48 48]);
[img,map] = imread('insertSnippet_48.png');
map(double(img(1,1))+1,:) = hFig.Color;
imshow(img,map);
labelStr = ['<html><body>'...
'<b>MATLAB Snippets</b><br>' ...
'Pavel Trnka (pavel@trnka.name)<br>' ...
'Version: ' versionStr '</body></html>'];
jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
% ---
oldWarn = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
warning('off','MATLAB:ui:javacomponent:FunctionToBeRemoved');
javacomponent(jLabel,[78,10,380-78-10,48],hPanel);
warning(oldWarn);
% ---
uicontrol(...
'style', 'edit', ...
'Position', [10 60 380 80+68], ...
'BackgroundColor', 0.9*hFig.Color, ...
'HorizontalAlignment','left', ...
...'Enable', 'inactive', ...
'Max',2, ...
'String', {
'INSPIRED BY:'
'============'
'"Insert a piece of code (a snippet) in the Matlab editor"'
'https://www.mathworks.com/matlabcentral/fileexchange/41704-insert-a-piece-of-code-a-snippet-in-the-matlab-editor'
''
'"MATLAB for Visual Studio Code"'
'https://marketplace.visualstudio.com/items?itemName=Gimly81.matlab'
''
'USES:'
'====='
'"JSONlab: a toolbox to encode/decode JSON files"'
'https://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab-a-toolbox-to-encode-decode-json-files'
''
'"findjobj - find java handles of Matlab graphic objects"'
'https://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects'
''
} ...
);
uicontrol(...
'style', 'pushbutton', ...
'Position', [90+20 15 130 30], ...
'String', 'Matlab File Exchange', ...
'Callback', @fileExchangeCallback ...
);
uicontrol(...
'style', 'pushbutton', ...
'Position', [240+20 15 130 30], ...
'String', 'GitHub', ...
'Callback', @gitHubBtnCallback ...
);
uicontrol( ...
'Style', 'text', ...
'String', 'Visit project page:', ...
'Position', [10 17 90 20], ...
'HorizontalAlignment','left' ...
);
end
function gitHubBtnCallback(~,~)
url = 'https://github.com/trnkap/matlab-snippets';
web(url,'-browser')
end
function fileExchangeCallback(~,~)
url = 'https://www.mathworks.com/matlabcentral/fileexchange/70524-matlab-snippets';
web(url,'-browser')
end
function figureKeyPressFcn(src,keyData)
switch keyData.Key
case 'escape'
close(src);
return
end
end