No BSD License  

Highlights from
Sudoku! (v3.4)

image thumbnail
from Sudoku! (v3.4) by Alan Tan
Sudoku! is the ultimate GUI for Sudoku fans. No messy scribbles, simply click away to the solution.

sudoku_gui
function fig = sudoku_gui

% Read configuration file.
u1 = textread('sudoku_config.txt','%q');

% Set constants.
m1 = [		0            0       0.5625
            0            0        0.625
            0            0       0.6875
            0            0         0.75
            0            0       0.8125
            0            0        0.875
            0            0       0.9375
            0            0            1
            0       0.0625            1
            0        0.125            1
            0       0.1875            1
            0         0.25            1
            0       0.3125            1
            0        0.375            1
            0       0.4375            1
            0          0.5            1
            0       0.5625            1
            0        0.625            1
            0       0.6875            1
            0         0.75            1
            0       0.8125            1
            0        0.875            1
            0       0.9375            1
            0            1            1
       0.0625            1            1
        0.125            1       0.9375
       0.1875            1        0.875
         0.25            1       0.8125
       0.3125            1         0.75
        0.375            1       0.6875
       0.4375            1        0.625
          0.5            1       0.5625
       0.5625            1          0.5
        0.625            1       0.4375
       0.6875            1        0.375
         0.75            1       0.3125
       0.8125            1         0.25
        0.875            1       0.1875
       0.9375            1        0.125
            1            1       0.0625
            1            1            0
            1       0.9375            0
            1        0.875            0
            1       0.8125            0
            1         0.75            0
            1       0.6875            0
            1        0.625            0
            1       0.5625            0
            1          0.5            0
            1       0.4375            0
            1        0.375            0
            1       0.3125            0
            1         0.25            0
            1       0.1875            0
            1        0.125            0
            1       0.0625            0
            1            0            0
       0.9375            0            0
        0.875            0            0
       0.8125            0            0
         0.75            0            0
       0.6875            0            0
        0.625            0            0
       0.5625            0            0];
m2 = [236 233 216]/255;

% Set figure.
h0 = figure('Color',m2, ...
   'Colormap',m1, ...
   'Name','Sudoku!, mb@', ...
   'Units','points', ...
   'Position',[100 100 560 400], ...
	'ToolBar','none');

% Set axes.
hndl.axes = axes('Parent',h0, ...
   'Units','points', ...
   'Position',[0 0 400 400], ...
   'XLim',[0 10], ...
   'YLim',[0 10], ...
   'Visible','off');
for k1 = 1:9, for k2 = 1:9, rectangle('Position',[k1-0.5,9.5-k2,1,1]); end, end
for k1 = [1 4 7], for k2 = [1 4 7], rectangle('Position',[k1-0.5,7.5-k2,3,3],'LineWidth',3); end, end

% Set frames and static-texts.
uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',m2, ...
   'ForegroundColor',0.75*m2, ...
	'Position',[395 293 150 81], ...
   'Style','frame');
uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',m2, ...
	'Position',[400 368 22 12], ...
	'String','Map', ...
	'Style','text');
uicontrol('Parent',h0, ...
	'Units','points', ...
   'BackgroundColor',m2, ...
   'HorizontalAlignment','left', ...
	'Position',[405 347 50 12], ...
	'String','File :', ...
	'Style','text');
uicontrol('Parent',h0, ...
	'Units','points', ...
   'BackgroundColor',m2, ...
   'HorizontalAlignment','left', ...
	'Position',[405 326 50 12], ...
	'String','Map :', ...
	'Style','text');
uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',m2, ...
   'ForegroundColor',0.75*m2, ...
	'Position',[395 234 150 37], ...
   'Style','frame');
uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',m2, ...
	'Position',[400 265 35 12], ...
	'String','Analysis', ...
   'Style','text');
uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',m2, ...
   'ForegroundColor',0.75*m2, ...
	'Position',[395 133 125 79], ...
   'Style','frame');
uicontrol('Parent',h0, ...
   'Units','points', ...
   'BackgroundColor',m2, ...
	'Position',[400 206 45 12], ...
	'String','Commands', ...
   'Style','text');

% Set editable-texts and popupmenus.
hndl.text_map = uicontrol('Parent',h0, ...
	'Units','points', ...
   'BackgroundColor',[1 1 1], ...
   'Enable','off', ...
	'HorizontalAlignment','left', ...
	'Position',[460 345 75 16], ...
	'Style','edit');
hndl.pm_map = uicontrol('Parent',h0, ...
	'Units','points', ...
   'BackgroundColor',m2, ...
	'Position',[460 324 75 16], ...
	'String',' ', ...
	'Style','popupmenu');
hndl.pm_analysis = uicontrol('Parent',h0, ...
	'Units','points', ...
   'BackgroundColor',m2, ...
	'Position',[405 244 75 16], ...
	'String',u1, ...
	'Style','popupmenu', ...
   'Value',1);

% Set buttons.
uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
	'Callback','sudoku_guicb(''button_load'',get(gcbf,''UserData''));', ...
	'Position',[430 303 50 16], ...
   'String','Load...');
uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
	'Callback','sudoku_guicb(''button_make'',get(gcbf,''UserData''));', ...
	'Position',[485 303 50 16], ...
	'String','Make Map');
uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
	'Callback','sudoku_guicb(''button_run'',get(gcbf,''UserData''));', ...
	'Position',[485 244 50 16], ...
	'String','Run');
hndl.button_record = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
	'Callback','sudoku_guicb(''button_record'',get(gcbf,''UserData''));', ...
	'Position',[405 185 50 16], ...
	'String','Record');
hndl.button_recall = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
   'Callback','sudoku_guicb(''button_recall'',get(gcbf,''UserData''));', ...
   'Enable','off', ...
	'Position',[460 185 50 16], ...
	'String','Recall');
hndl.button_undo = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
   'Callback','sudoku_guicb(''button_undo'',get(gcbf,''UserData''));', ...
   'Enable','off', ...
	'Position',[405 164 50 16], ...
	'String','Undo');
uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
	'Callback','sudoku_guicb(''button_save'',get(gcbf,''UserData''));', ...
	'Position',[460 164 50 16], ...
	'String','Save...');
uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',0.9*m2, ...
	'Callback','close(gcbf);', ...
	'Position',[460 143 50 16], ...
	'String','Exit');

% Set menus.
h1 = uimenu('Parent',h0, ...
   'Label','&Options');
uimenu('Parent',h1, ...
   'Callback','sudoku_guicb(''menu_print'',get(gcbf,''UserData''));', ...
   'Label','&Print with Hints');
uimenu('Parent',h1, ...
   'Callback','sudoku_guicb(''menu_print'',get(gcbf,''UserData''));', ...
   'Label','Print with&out Hints');

% Set aboutdialog.
msg.title  = 'About Sudoku!';
msg.header = {'Version 3.4','7 June 2006','Alan Tan (weechiat@gmail.com)','http://www.mathworks.com/matlabcentral/fileexchange/'};
msg.body   = {'Record & Recall','Print options','Right-click','Analysis tools','Undo'};
msg.box    = [290 50];
uimenu('Parent',h0, ...
   'Callback','sudoku_guicb(''aboutme'',get(gcbo,''UserData''));', ...
   'Label','&About', ...
   'UserData',msg);

% Save to hObject.
hObject.hndl = hndl;
hObject.exe  = u1;
set(h0,'UserData',hObject);

if nargout > 0, fig = h0; end

Contact us at files@mathworks.com