Code covered by the BSD License  

Highlights from
HTML Indexer

image thumbnail

HTML Indexer

by

 

16 Aug 2004 (Updated )

automated multi-language html index, index for print, batch image scaling

IncearcaCeva.m
% IncearcaCeva
% 
% variabila CEVA e globala si se seteaza sus, dar sus de tot...
%
% mainly ca sa pot chema din quadra mai usor
% noua, 26.05.03
% v 0.4     02.11.2003, add support pt newnet (lista de fisiere)
% v.0.41    14.11.2003, add/del language
%           18.11.2003, bugfix in deplasare de fisiere 
%           (+-5, up top, dwn end, etc)
% v.0.42    25.11.2003, language controls revisited
%           (now in dlgList)
% v.0.45    13.12.2003
%           o sa update toate cimpurile multilang cu o functie
%           special amenajata, dlgUpdTxt
% v.0.46    20/29.04.2004, add h_rendersmart_callback
% v.0.46a   30.04.2004, add html author and font
%           add html colours : dlgList_in_textcolour* (* = text,bg,link,vlink,alink)
%           start checking directories in loaded projects
%           15.05.2004, curatenie in initializare, 
%           gestiunea de directoare/proiecte/etc
% v.0.5     18.05.2004, add 'h_prjnewcontact_callback'
%           09.07.2004, bug in textover update fixat
%           31.07.2004, bug in Nav.language_index update fixat
%                       added Render Sheet
%           14.08.2004, added contact sheet callbacks
%                       simplify load project
% v.0.51    05.01.2006, add filtering options at top (menu)
% v.0.53    05.07.2011, touch up some font sizes, callbacks for easier
%                       navig, nothing fundamental :-)

switch ceva

    % ----------------------------
    %   handles from menu
    % ----------------------------

    case 'h_prjnew_callback'
        FileList = uConstr('fileinfo'); FileList_buff = FileList; Options_buff = Options;
        ceva = 'h_prjsetdest_callback'; IncearcaCeva;
        set([h.Prj.Edit h.Prj.Save], 'Enable', 'on');
        ceva = 'h_prjedit_callback'; IncearcaCeva;

    case 'h_prjedit_callback'
        Nav.image_index = 1;
        FileList_buff = FileList; Options_buff = Options;
        prjDlgList;

        % --- load ---
    case 'h_load_callback'
        Dir=prjDir(Dir,'load');
        Dir.loadok = 0;
        if ~strcmp(Dir.PrjName, '$none')
            temp_catch = 'disp(''not a valid project file''); Dir.PrjName=''$none''; ';
            eval(['load ' Dir.PrjName ], temp_catch);
            if exist('FileList', 'var') && exist('Options', 'var')
                Dir.loadok = 1;
                if ~size(dir(Dir.lastopen),1), Dir.lastopen = 'c:\'; end;
                if ~size(dir(Dir.working),1), Dir.working = 'c:\'; end;
                % to add here check_dest, smartly...
                set([h.Prj.Edit h.Prj.Save], 'Enable', 'on');
                ceva = 'h_prjedit_callback'; IncearcaCeva;
            else eval(temp_catch)
            end;
        else
            disp('no project loaded');
        end;
        set(h.Info.Prj,'String', ['Prj : ' Dir.PrjName]);
        set(h.Info.Dest,'String', ['Dest : ' Dir.Dest]);
        clear temp_catch;

        % --- save ---
    case 'h_save_callback'
        save default.mat FileList Dir Options;
        Dir = prjDir(Dir,'save');
        eval(['save ' Dir.PrjName ' FileList Dir Options']);
        set([h.Info.Prj], 'String', ['Prj : ' Dir.PrjName]);

    case 'h_prjsetdest_callback'
        Dir = prjDir(Dir,'dest');
        set(h.Info.Dest,'String', ['Dest : ' Dir.Dest]);

        % --- render ---
        % --------------
    case 'h_rendersmart_callback'
        FileList = prjRenderSmart(FileList, Dir, Options);
    case 'h_renderth_callback'
        FileList = prjRender(FileList, Dir, Options);
    case 'h_rendergy_callback'
        FileList = prjRender(FileList, Dir, Options, 'gy');
    case 'h_rendercontact_callback'
        [sheet, placing_info] = prjRenderSheet(FileList, Options, Dir, 'th'); % thgyor 3-lemma
        %clear sheet placing_info
        % --- generate ---
    case 'h_generatehtml_callback'
        GenerateHtml(FileList, Dir, Options);

        % --- optiuni ---
        % ---------------
    case 'h_optsmart_callback'
        if Options.smartscale
            Options.smartscale = 0;
            set(h.Render.SmartToggle, 'Label', 'turn smart ''ON''');
            set(h.Render.Smart, 'Label', 'Render Exactly','Enable', 'on');
            %set([h.Render.Th h.Render.Gy], 'Enable', 'on');
        else
            Options.smartscale = 1;
            set(h.Render.SmartToggle, 'Label', 'turn smart ''OFF''');
            set(h.Render.Smart, 'Label', 'Render Smartly');
            %set([h.Render.Th h.Render.Gy], 'Enable', 'off');
        end;
        ceva = 'prjRefresh'; IncearcaCeva;

    case 'h_optfilt_callback'
        if Options.filtering
            Options.filtering = 0;
            set(h.Opt.Filt, 'Label', 'turn 2D filtering ''ON''');
        else
            Options.filtering = 1;
            set(h.Opt.Filt, 'Label', 'turn 2D filtering  ''OFF''');
        end;

    case 'h_optload_callback'
        FileList_buff = FileList; Dir_buff = Dir; Options_buff = Options;
        tmpDir=prjDir(Dir,'load');
        eval(['load ' tmpDir.PrjName ]);
        FileList = FileList_buff; Dir=Dir_buff;
        clear FileList_buff Dir_buff tmpDir

        % ----------------------------
        % handles de interceptie
        % ----------------------------
    case 'prjUpdate'
        FileList = prjUpdate(FileList, Dir, Options);
    case 'prjRefresh'
        FileList = prjRefresh(FileList, Options);
        % ceva = 'dlgList_disp_file'; IncearcaCeva;

        % ----------------------------
        %   handles din dlgList
        % ----------------------------

    case 'dlgList_in_legenda'
        FileList(Nav.image_index).Legenda = dlgUpdTxt(...
            FileList(Nav.image_index).Legenda, ...
            deblank(get(ctrl.legenda, 'string')), Nav.language_index);
    case 'dlgList_in_textover'
        FileList(Nav.image_index).TextOver  = dlgUpdTxt(...
            FileList(Nav.image_index).TextOver, ...
            deblank(get(ctrl.textover, 'string')), Nav.language_index);

    case 'dlgList_in_linkhome'
        Options.LinkHome = dlgUpdTxt(Options.LinkHome, deblank(get(ctrl.linkhome, 'string')), Nav.language_index );
    case 'dlgList_in_texthome'
        Options.TextHome = dlgUpdTxt(Options.TextHome, deblank(get(ctrl.texthome, 'string')), Nav.language_index );
    case 'dlgList_in_textlang'
        Options.TextLang = dlgUpdTxt(Options.TextLang, deblank(get(ctrl.textlang, 'string')), Nav.language_index );
    case 'dlgList_in_textjos'
        Options.TextJos = dlgUpdTxt(Options.TextJos, deblank(get(ctrl.textjos, 'string')), Nav.language_index );
    case 'dlgList_in_textsus'
        Options.TextSus = dlgUpdTxt(Options.TextSus, deblank(get(ctrl.textsus, 'string')), Nav.language_index );
    case 'dlgList_in_texttitlu'
        Options.Titlu = dlgUpdTxt(Options.Titlu, deblank(get(ctrl.texttitlu, 'string')), Nav.language_index );

    case 'dlgList_disp_text'
        set(ctrl.linkhome, 'string', deblank(Options.LinkHome(Nav.language_index,:)));
        set(ctrl.texthome, 'string', deblank(Options.TextHome(Nav.language_index,:)));
        set(ctrl.textlang, 'string', deblank(Options.TextLang(Nav.language_index,:)));
        set(ctrl.textjos, 'string', deblank(Options.TextJos(Nav.language_index,:)));
        set(ctrl.textsus, 'string', deblank(Options.TextSus(Nav.language_index,:)));
        set(ctrl.texttitlu, 'string', deblank(Options.Titlu(Nav.language_index,:)));

    case 'dlgList_in_textautor'
        Options.Autor = dlgUpdTxt(Options.Autor, deblank(get(ctrl.textautor, 'string')), Nav.language_index );
    case 'dlgList_in_textfontsize'
        Options.FontSize = min(max(fix(str2num(get(ctrl.textfontsize,'String'))),-8),10);
        set(ctrl.textfontsize, 'String', num2str(Options.FontSize));
    case 'dlgList_in_textfontface'
        Options.FontFace = deblank(get(ctrl.textfontface, 'string'));

        % ------------------------
        %  html colours
        % ------------------------
    case 'dlgList_in_textcolourtext'
        Options.Colour.text = get(ctrl.textcolourtext, 'String');
        [rgb, CorrectedColour] = uNet2Dec(Options.Colour.text); Options.Colour.text = CorrectedColour;
        set(ctrl.textcolourtext, 'backgroundcolor', rgb, 'String', Options.Colour.text);
    case 'dlgList_in_textcolourbg'
        Options.Colour.bg = get(ctrl.textcolourbg, 'String');
        [rgb, CorrectedColour] = uNet2Dec(Options.Colour.bg); Options.Colour.bg = CorrectedColour;
        set(ctrl.textcolourbg, 'backgroundcolor', rgb, 'String', Options.Colour.bg);
    case 'dlgList_in_textcolourlink'
        Options.Colour.link = get(ctrl.textcolourlink, 'String');
        [rgb, CorrectedColour] = uNet2Dec(Options.Colour.link); Options.Colour.link = CorrectedColour;
        set(ctrl.textcolourlink, 'backgroundcolor', rgb, 'String', Options.Colour.link);
    case 'dlgList_in_textcolourvlink'
        Options.Colour.vlink = get(ctrl.textcolourvlink, 'String');
        [rgb, CorrectedColour] = uNet2Dec(Options.Colour.vlink); Options.Colour.vlink = CorrectedColour;
        set(ctrl.textcolourvlink, 'backgroundcolor', rgb, 'String', Options.Colour.vlink);
    case 'dlgList_in_textcolouralink'
        Options.Colour.alink = get(ctrl.textcolouralink, 'String');
        [rgb, CorrectedColour] = uNet2Dec(Options.Colour.alink); Options.Colour.alink = CorrectedColour;
        set(ctrl.textcolouralink, 'backgroundcolor', rgb, 'String', Options.Colour.alink);

        % --------------------------------------
        % contact sheet
        % --------------------------------------
    case 'dlgList_in_contact_file_prefix'
        Options.contact.file_prefix = get(ctrl.contact_file_prefix, 'String');
    case 'dlgList_in_contact_sheet_w'
        Options.contact.sheet_width = str2num(get(ctrl.contact_sheet_w, 'String'));
        Options.contact.sheet_width = min(28800, max(600, Options.contact.sheet_width));
    case 'dlgList_in_contact_sheet_h'
        Options.contact.sheet_height = min(19200, max(400, str2num(get(ctrl.contact_sheet_h, 'String'))));
        % -------------------------------
        % show all Nav.fileindex details
        % -------------------------------
    case 'dlgList_disp_file'
        pref_nDigs = 3;
        if Nav.image_index && size(FileList,2)
            set(ctrl.legenda, 'string', deblank(FileList(Nav.image_index).Legenda(Nav.language_index,:)));
            set(ctrl.textover, 'string', deblank(FileList(Nav.image_index).TextOver(Nav.language_index,:)));
            set(ctrl.path, 'string', ['Path: ' FileList(Nav.image_index).path ]);
            set(ctrl.info, 'string', ...
                strvcat(['th   : [' num2str(FileList(Nav.image_index).th_width) ...
                ' -by- ' num2str(FileList(Nav.image_index).th_height) ']'], ...
                ['full : [' num2str(FileList(Nav.image_index).gy_width, pref_nDigs) ...
                ' -by- ' num2str(FileList(Nav.image_index).gy_height, pref_nDigs) ']'], ...
                ['orig: [' num2str(FileList(Nav.image_index).or_width, pref_nDigs) ...
                ' -by- ' num2str(FileList(Nav.image_index).or_height, pref_nDigs) ']'], ...
                ['scale: ' num2str(FileList(Nav.image_index).scalefactor_gy, pref_nDigs) ...
                ' / ' num2str(FileList(Nav.image_index).scalefactor_th, pref_nDigs)]) );
            % arata si thumbnailu > daca exista
            fn = fullfile(Dir.Dest, [FileList(Nav.image_index).base '_th.jpg']);
            fid_th = fopen(fn);
            if fid_th >= 1 % -> daca exista afiseaza-l
                fclose(fid_th);
                img_data = imread(fn, 'jpg');
                if size(img_data,3)==1 % o bucla sa prinda A/N, ca e un bug in image(alb-negru)
                    d3 = img_data; d3(:,:,2) = img_data; d3(:,:,3) = img_data;
                    img_data = d3; clear d3;
                end;
                xo = pz_pref.xo/pz_pref.main(3);
                yo = pz_pref.yo/pz_pref.main(4);
                dx = FileList(Nav.image_index).th_width* pz_pref.dmax/max(FileList(Nav.image_index).th_width, FileList(Nav.image_index).th_height)/pz_pref.main(3);
                dy = FileList(Nav.image_index).th_height* pz_pref.dmax/max(FileList(Nav.image_index).th_width, FileList(Nav.image_index).th_height)/pz_pref.main(4);

                image(img_data); grid off; axis off;
                set(get(h.DlgList,'currentaxes'),'position',[ xo yo dx dy ])
                clear img_data xo yo dx dy
            else % fa ceva frumos mai tirziu
                image(.5*ones(2,2,3)); grid off; axis off;

                set(get(h.DlgList,'currentaxes'),'position',[ pz_pref.xo/pz_pref.main(3) pz_pref.yo/pz_pref.main(4) .3 .2 ])
            end;
            clear fid_th fn
        else
            set([ctrl.legenda ctrl.textover ctrl.path ctrl.info], 'string', 'no file> cannot show details');
            image(.5*ones(2,2,3)); grid off; axis off;
        end;

        % +------------------------+
        % | file list manipulation |
        % +------------------------+

    case 'dlgList_switch_files'
        candidate_place = min(max(Nav.image_index+Nav.list_switch,1),size(FileList,2));
        buff=FileList(Nav.image_index);
        if candidate_place<Nav.image_index
            FileList(candidate_place+1:Nav.image_index) = FileList(candidate_place:Nav.image_index-1);
        else
            FileList(Nav.image_index:candidate_place-1) = FileList(Nav.image_index+1:candidate_place);
        end;
        FileList(candidate_place)=buff; clear buff;
        set(ctrl.lista, 'String', strvcat(FileList.name), 'Value', candidate_place);
        Nav.image_index = candidate_place;

        % +------------------+
        % | file/dir add/del |
        % +------------------+

    case 'dlgList_add_file'
        [FileList, Dir, Nav] = prjDlgAdd('file',FileList, Options, Dir, Nav);
        set(ctrl.lista, 'String', strvcat(FileList.name), 'Value', Nav.image_index);
        set(ctrl.lista, 'String', strvcat(FileList.name));
        ceva = 'dlgList_disp_file'; IncearcaCeva
    case 'dlgList_add_dir'
        [FileList, Dir] = prjDlgAdd('dir',FileList, Options, Dir, Nav);
        set(ctrl.lista, 'String', strvcat(FileList.name));
        set(ctrl.lista, 'String', strvcat(FileList.name), 'Value', Nav.image_index);
        ceva = 'dlgList_disp_file'; IncearcaCeva
    case 'dlgList_del_file'
        FileList = FileList([(1:Nav.image_index-1) (Nav.image_index+1:size(FileList,2))]);
        Nav.image_index = min(Nav.image_index,size(FileList,2));
        set(ctrl.lista, 'String', strvcat(FileList.name), 'Value', Nav.image_index);
        ceva = 'dlgList_disp_file'; IncearcaCeva
    case 'dlgList_OK'
        FileList_buff = FileList; Options_buff = Options;
        set([h.Prj.Edit h.Prj.Save], 'Enable', 'on');
    case 'dlgList_close'
        clear ctrl pz pz_pref pz_xcol pz_ytop candidate_place
        FileList = FileList_buff; clear FileList_buff;
        Options = Options_buff; clear Options_buff;

        close(h.DlgList); h=rmfield(h,'DlgList');

        % ------
        % limba
        % ------

    case 'dlgList_switch_lang'
        Nav.language_index = get(ctrl.langswitch, 'Value');
        ceva = 'dlgList_disp_file'; IncearcaCeva
        ceva = 'dlgList_disp_text'; IncearcaCeva

    case 'dlgList_add_lang'
        limba=dlgLimba; % aci ti-a-ntors un string
        Options.languages=deblank(strvcat(Options.languages, limba)); clear limba;
        % adauga cimpul noii limbi
        for i=1:size(FileList,2)
            FileList(i).TextOver = strvcat(FileList(i).TextOver, FileList(i).base);
            FileList(i).Legenda = strvcat(FileList(i).Legenda, FileList(i).base);
        end;
        Options.Titlu = strvcat(Options.Titlu, Options.Titlu(1,:));
        Options.TextSus = strvcat(Options.TextSus, Options.TextSus(1,:));
        Options.TextJos = strvcat(Options.TextJos, Options.TextJos(1,:));
        Options.TextLang = strvcat(Options.TextLang, Options.TextLang(1,:));
        Options.TextHome = strvcat(Options.TextHome, Options.TextHome(1,:));
        Options.LinkHome = strvcat(Options.LinkHome, Options.LinkHome(1,:));

        set(ctrl.langswitch, 'string' , Options.languages);
    case 'dlgList_del_lang'
        ix_lang = dlgLimba(Options.languages, 'delete');
        if ix_lang % altfel nu te atingi
            L = size(Options.languages,1);
            for i=1:size(FileList,2) % sterge cimpul limbii alese
                FileList(i).TextOver = strvcat(FileList(i).TextOver((1:ix_lang-1),:), FileList(i).TextOver((ix_lang+1:L),:));
                FileList(i).Legenda = strvcat(FileList(i).Legenda((1:ix_lang-1),:), FileList(i).Legenda((ix_lang+1:L),:));
            end;
            Nav.language_index = max(Nav.language_index - 1, 1);
            % sterge-o din optiuni
            Options.languages = deblank(strvcat(Options.languages((1:ix_lang-1),:), Options.languages((ix_lang+1:L),:)));
            set(ctrl.langswitch, 'string' , Options.languages);
            set(ctrl.langswitch, 'value', Nav.language_index);
            Options.Titlu = deblank(strvcat(Options.Titlu((1:ix_lang-1),:), Options.Titlu((ix_lang+1:L),:)));
            Options.TextSus = deblank(strvcat(Options.TextSus((1:ix_lang-1),:), Options.TextSus((ix_lang+1:L),:)));
            Options.TextJos = deblank(strvcat(Options.TextJos((1:ix_lang-1),:), Options.TextJos((ix_lang+1:L),:)));
            Options.TextLang = deblank(strvcat(Options.TextLang((1:ix_lang-1),:), Options.TextLang((ix_lang+1:L),:)));
            Options.TextHome = deblank(strvcat(Options.TextHome((1:ix_lang-1),:), Options.TextHome((ix_lang+1:L),:)));
            Options.LinkHome = deblank(strvcat(Options.LinkHome((1:ix_lang-1),:), Options.LinkHome((ix_lang+1:L),:)));

            clear ix_lang
        end
end

Contact us