Пример #1
0
void ResFileCtrl::InitCtrlIter(PDUI_LISTCONTAINERELEM ctrl, LPCTSTR file_name)
{
  ctrl->SetMaxHeight(90);
  ctrl->SetMaxWidth(100);
  ctrl->SetMinHeight(90);
  ctrl->SetMinWidth(100);
  ctrl->FindSubControl(_T("file_name"))->SetText(file_name);
  ctrl->FindSubControl(_T("file_view"))->SetBkImage(GetProperIcon(file_name));
  ctrl->SetToolTip(file_name);
}
Пример #2
0
// Get icon for an object
void backdrop_get_icon(BackdropInfo *info,BackdropObject *object,short flags)
{
	short x,y,border_x=0,border_y=0;
	BOOL new_icon=1;

	// Keeping icon?
	if (flags&GETICON_KEEP) new_icon=0;

	// Not AppIcon?
	if (object->type!=BDO_APP_ICON && !(flags&GETICON_POS_ONLY))
	{
		BPTR lock=0,old=0;

		// Already got icon?
		if (object->icon && !(flags&GETICON_KEEP))
		{
			// Free icon remapping
			RemapIcon(object->icon,(info->window)?info->window->WScreen:0,1);

			// Free icon
			FreeCachedDiskObject(object->icon);
			object->icon=0;

			// We'll be getting a new one
			new_icon=1;
		}

		// Bad disk?
		if (object->type==BDO_BAD_DISK)
		{
			// Get default disk
			if (!object->icon && !(object->icon=GetCachedDefDiskObject(WBKICK)))
				object->icon=GetCachedDefDiskObject(WBDISK);
		}

		// Default directory icon?
		else
		if (flags&GETICON_DEFDIR)
		{
			// Get default drawer icon
			if (!object->icon) object->icon=GetCachedDefDiskObject(WBDRAWER);
		}

		// Get lock on directory
		else
		if (!(flags&GETICON_CD) || (lock=backdrop_icon_lock(object)))
		{
			// Go to icon directory
			if (lock) old=CurrentDir(lock);

			// Disk?
			if (object->type==BDO_DISK)
			{
				// No icon already?
				if (!object->icon)
				{
					BOOL ok=1;
					Cfg_Filetype *type=0;
					char name[256],*ptr;

					// Find a filetype-defined icon
					if (object->device_name &&
						(type=filetype_identify(object->device_name,FTTYPE_ICON,0,0)))
					{
						// Copy icon path, strip .info
						strcpy(name,type->icon_path);
						if (ptr=isicon(name)) *ptr=0;

						// Over-ride flag set in filetype?
						if (type->type.flags&FILETYPEF_OVERRIDE)
						{
							// Try for filetype icon first
							object->icon=GetCachedDiskObject(name,0);
						}
					}

					// Don't have icon yet?
					if (!object->icon)
					{
						// Is this a MSDOS disk?
						if (object->misc_data==ID_MSDOS_DISK)
						{
							// See if icon actually exists
							if (type && !(SetProtection("Disk.info",FIBF_ARCHIVE)) &&
								IoErr()==ERROR_OBJECT_NOT_FOUND)
							{
								// We'll use default icon
								ok=0;
							}
						}
						
						// Get disk icon
						if (ok)
							object->icon=GetCachedDiskObject("Disk",0);
					}

					// Got icon?
					if (object->icon)
					{
						// If it's a drawer icon, turn it into a disk
						if (object->icon->do_Type==WBDRAWER)
							object->icon->do_Type=WBDISK;

						// Check it is for a disk
						if (object->icon->do_Type!=WBDISK)
						{
							// It's not, free it and use default
							FreeCachedDiskObject(object->icon);
							object->icon=0;
						}
					}

					// Still no icon? Get default
					if (!object->icon && !(flags&GETICON_FAIL))
					{
						// Got type-defined?
						if (type)
						{
							// Try for filetype icon
							object->icon=GetCachedDiskObject(name,0);
						}

						// Still none? Get default
						if (!object->icon)
							object->icon=GetCachedDefDiskObject(WBDISK);

						// Set fake flag
						if (object->icon)
							object->flags|=BDOF_FAKE_ICON;
					}
				}
			}

			// Left out or group
			else
			if (object->type==BDO_LEFT_OUT || object->type==BDO_GROUP)
			{
				// Try for icon
				if (!object->icon)
				{
					short fake=0;

					// Want real icon?
					if (flags&GETICON_FAIL) object->icon=GetCachedDiskObject(object->name,0);

					// Get default icon if fails
					else object->icon=GetProperIcon(object->name,&fake,0);

					// Ended up fake?
					if (fake)
					{
						// Set flag
						object->flags|=BDOF_FAKE_ICON;
					}
				}

				// Got group icon?
				if (object->icon && object->type==BDO_GROUP)
				{
					// Auto-open group?
					if (FindToolType(object->icon->do_ToolTypes,"OPEN"))
						object->flags|=BDOF_AUTO_OPEN;
				}
			}

			// Had a lock?
			if (lock)
			{
				// Got icon?
				if (object->icon)
				{
					// Clear custom position flag
					object->flags&=~BDOF_CUSTOM_POS;

#ifdef DISTINCT_OK
					// Main desktop, distinct positions?
					if (info->flags&BDIF_MAIN_DESKTOP &&
						environment->env->desktop_flags&DESKTOPF_DISTINCT)
					{
						char path[256];

						// Get icon path
						if (desktop_icon_path(object,path,256,lock))
						{
							// See if position is available
							if (desktop_find_icon(path,&object->custom_pos))
							{
								// Set "custom position" flag
								object->flags|=BDOF_CUSTOM_POS;
							}
						}
					}
#endif
				}

				// Restore current dir
				CurrentDir(old);

				// Unlock object lock
				UnLock(lock);
			}
		}

		// Failed to even get a lock; get default icon if a disk
		else
		if (object->type==BDO_DISK)
		{
			// Get default icon
			if (!object->icon && (object->icon=GetCachedDefDiskObject(WBDISK)))
				object->flags|=BDOF_FAKE_ICON;
		}
	}

	// Got an icon?
	if (object->icon)
	{
		// Ended up fake?
		if (object->flags&BDOF_FAKE_ICON)
		{
			// Make sure default icon has no position
			if (object->icon)
			{
				// Clear 'position ok' flag, set invalid position
				SetIconFlags(object->icon,GetIconFlags(object->icon)&~ICONF_POSITION_OK);
				SetIconPosition(object->icon,-1,-1);
				object->icon->do_CurrentX=NO_ICON_POSITION;
				object->icon->do_CurrentY=NO_ICON_POSITION;
			}
		}

		// If this is a group, make sure icon is a drawer
		if (object->type==BDO_GROUP)
			object->icon->do_Type=WBDRAWER;

		// Is it a new icon?
		if (new_icon)
		{
			// Window open?
			if (info->window)
			{
				// Remap the icon
				RemapIcon(object->icon,info->window->WScreen,0);

				// Set flag
				object->flags|=BDOF_REMAPPED;
			}
		}

		// Transparent icon?
		if (!backdrop_icon_border(object))
		{
			border_x=0;
			border_y=0;
		}
		else
		{
			border_x=ICON_BORDER_X;
			border_y=ICON_BORDER_Y;
		}

		// No label?
		if ((GetIconFlags(object->icon)&ICONF_NO_LABEL) && !(environment->env->desktop_flags&DESKTOPF_NO_NOLABELS))
			object->flags|=BDOF_NO_LABEL;
		else
			object->flags&=~BDOF_NO_LABEL;
	}

	// No icon, or no size stuff?
	if (!object->icon || flags&GETICON_NO_POS) return;

	// Get masks
	if (!(flags&GETICON_KEEP)) backdrop_get_masks(object);

	// Get object size
	object->pos.Width=object->icon->do_Gadget.Width;
	object->pos.Height=object->icon->do_Gadget.Height;

	// (Re)position?
	if (!(flags&GETICON_SAVE_POS))
	{
		// No position initially
		object->flags|=BDOF_NO_POSITION;

		// Auto position?
		if (object->flags&BDOF_AUTO_POSITION)
		{
			return;
		}

		// Custom position?
		else
		if (object->flags&(BDOF_CUSTOM_POS|BDOF_LEFTOUT_POS))
		{
			// Get custom position
			x=(object->custom_pos>>16)&0xffff;
			y=object->custom_pos&0xffff;
		}