Exemple #1
0
/** Load an icon from a file. */
IconNode *LoadNamedIcon(const char *name, char save, char preserveAspect)
{

   IconNode *icon;
   IconPathNode *ip;

   Assert(name);

   /* If no icon is specified, return an empty icon. */
   if(name[0] == 0) {
      return &emptyIcon;
   }

   /* See if this icon has already been loaded. */
   icon = FindIcon(name);
   if(icon) {
      return icon;
   }

   /* Check for an absolute file name. */
   if(name[0] == '/') {
      ImageNode *image = LoadImage(name, 0, 0, 1);
      if(image) {
         icon = CreateIcon(image);
         icon->preserveAspect = preserveAspect;
         icon->name = CopyString(name);
         if(save) {
            InsertIcon(icon);
         }
         DestroyImage(image);
         return icon;
      } else {
         return &emptyIcon;
      }
   }

   /* Try icon paths. */
   for(ip = iconPaths; ip; ip = ip->next) {
      icon = LoadNamedIconHelper(name, ip->path, save, preserveAspect);
      if(icon) {
         return icon;
      }
   }

   /* The default icon. */
   return NULL;
}
Exemple #2
0
/** Load an icon from a file. */
IconNode *LoadNamedIcon(const char *name, char save, char preserveAspect)
{

   IconPathNode *ip;
   IconNode *icon;

   Assert(name);

   if(name[0] == '/') {
      return CreateIconFromFile(name, save, preserveAspect);
   } else {
      for(ip = iconPaths; ip; ip = ip->next) {
         icon = LoadNamedIconHelper(name, ip->path, save, preserveAspect);
         if(icon) {
            return icon;
         }
      }
      return NULL;
   }

}