home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / ctenari / Krutak / univiewi_ilib.exe / plugins / IL_SDK / iconlib.c next >
Encoding:
C/C++ Source or Header  |  2002-04-06  |  3.8 KB  |  94 lines

  1. /*
  2.     You have to recompile this file if you wan't to create your own icon library for UniView
  3.     ...or you can use some kind of resource hacker to replace icons in current iconlib.uvp
  4.        file => It is LEGAL, because ...
  5.  
  6.     This file is distributed under following license:
  7.     * Files contained in this distribution are copyrighted by Andrej Krutak
  8.     * It is allowed to alter all files contained in this package (including icons)
  9.         as long, as you mention me as original author in some place and as long
  10.         as you don't give me responsibility for damages caused by this s/w.
  11.  
  12.     (C) 2002 Andrej Krutak
  13.  
  14.  
  15. DESCRIPTION OF ICON LIBRARY INTERFACE:
  16.     
  17.     Icon library for UniView isn't a simple DLL with icons. Because each library
  18.     should handle all following versions of UniView (and their file types), it has
  19.     to use some special interface...
  20.       
  21.     The first thing that each icon library (IL) should pass is the standard plugin interface
  22.     support. This means, each plugin must contain function 'uvplugin_main' and must
  23.     response to messages UVMSG_INITPLUGIN and others - like the function in this file.
  24.  
  25.     2nd important thing that IL has to have is the 'uv_associate_getIconID' function.
  26.     This function must be __stdcall and must be exported as '_uv_associate_getIconID'.
  27.     Let's check some example to understand the function:
  28.  
  29.     When a file, that is using IL icon, is being associated, this function is called.
  30.  
  31.     We have, for example, a TXT extension, which is going to get IL icon. UniView makes
  32.     all the associations and finds out, that it requires icon from IL. So it calls our
  33.     function (uv_associate_getIconID) with extension as parameter (in form '.txt').
  34.     The 'objective' of our function is to return index of image in UVP file. The best
  35.     way to get this index is to explicitly create a table (like ext_uv_18), which contains
  36.     extensions... I think, this algorithm can you 'resolve' by your self...
  37.  
  38.     So we return 1 based index (or 0 if this extension isn't included in current version of
  39.     IL). That's all - there's nothing more to do with our plugin...
  40.  
  41.     In general, you'll never have to completely rewrite this sources, because the basic idea
  42.     of this procedure will stay for a long time :-) For every new version of UniView there
  43.     will be also a new version of this plugin (w/sources) available on my homesite...
  44.  
  45.     Best regards!
  46.  
  47.     Andrej Krutak, krutak@gymrk.sk, http://www.gymrk.sk/andrek/
  48. */
  49.  
  50. #include <windows.h>
  51. #include <stdio.h>
  52. #include "plugin.h"
  53.  
  54. int __stdcall uvplugin_main(HINSTANCE plgI, DWORD message, DWORD wParam, DWORD lParam)
  55. {
  56.     switch (message) {
  57.     case UVMSG_INITPLUGIN:
  58.         {
  59.             up_initdata* updata=(up_initdata*)wParam;
  60.             
  61.             updata->items_count=0;
  62.             strcpy(updata->plugin_name, "UniView icon library (*)");
  63.             updata->version_1=1;
  64.             updata->version_2=8;
  65.         }
  66.         return 0;
  67.     case UVMSG_EXIT:
  68.         return 0;
  69.     case UVMSG_STOPEXIT:
  70.         return 0;
  71.     }
  72.     return 0;
  73. }
  74.  
  75. char *ext_uv_18[] = {
  76.     ".aa", ".aif", ".aifc", ".aiff", ".atk", ".au", ".avi", ".bie", ".bmp", ".cmu", ".dat", ".dib", ".dic", ".diz", 
  77.     ".doo", ".exc", ".fac", ".face", ".fit", ".fits", ".fts", ".g3", ".gif", ".icl", ".ico", ".icon", ".iff", ".img", ".ini", 
  78.     ".jpe", ".jpeg", ".jpg", ".lbm", ".leaf", ".m1v", ".mac", ".macp", ".mda", ".mdp", ".mgr", ".mid", ".mov", ".mp2", ".mpa", ".mpe", 
  79.     ".mpeg", ".mpg", ".mpnt", ".mpv2", ".ngg", ".nol", ".npm", ".paint", ".pbm", ".pcx", ".pdb", ".pgm", ".pi1", ".pi3", ".png", 
  80.     ".pnm", ".pntg", ".ppm", ".qrt", ".ras", ".rast", ".raw", ".rgb", ".rle", ".rmi", ".rtf", ".scp", ".scr", ".sgi", ".sir", ".snd", 
  81.     ".sr", ".tga", ".tif", ".tiff", ".txt", ".urt", ".wav", ".wbmp", ".wfa", ".wri", ".xbm", ".xim", ".xpm", ".ybm", ".yuv", ".ecw", ".mtv"
  82. };
  83.  
  84. int __stdcall uv_associate_getIconID(char *extension)
  85. {
  86.     int i;
  87.  
  88.     for (i=0; i<sizeof(ext_uv_18)/sizeof(char*); i++) {
  89.         if (!strcmpi(ext_uv_18[i], extension))
  90.             return i+1;
  91.     }
  92.     return 0;
  93. }
  94.