void notify(dom::element& el, NMHL_HYPERLINK::type code)
    {
      // send notification
        NMHL_HYPERLINK nm;
        memset(&nm,0,sizeof(nm));

        HWND hwnd = el.get_element_hwnd(true);

        nm.hdr.code = HLN_HYPERLINK;
        nm.hdr.hwndFrom = hwnd;
        nm.hdr.idFrom = GetDlgCtrlID(hwnd);

        nm.action = code;
        nm.he = el;

        dom::element root = el.root();

        const wchar_t *pHREF = el.get_attribute("href");
        if(pHREF)
        {
          if(code == NMHL_HYPERLINK::CLICK && pHREF[0] == '#') // anchor name, this is a local hyperlink
          {
            if( pHREF+1 == 0 ) // href='#' case
              return;
            
            dom::element anchor_el = root.find_first("[id='%S'],[name='%S']",pHREF+1,pHREF+1);
              //find_element_by_name(el.root_element(hwnd), pHREF + 1);
            if(anchor_el.is_valid()) // found
            {
              anchor_el.scroll_to_view(true /* scroll it to top of the view */);
              return; // shall host be notified about this?
            }
          }
          wcsncpy(nm.szHREF,pHREF,MAX_URL_LENGTH);
          el.combine_url(nm.szHREF,MAX_URL_LENGTH);
        }
        const wchar_t *pszTarget = el.get_attribute("target");
        if(pszTarget)
        {
          if(code == NMHL_HYPERLINK::CLICK && try_to_load( root, nm.szHREF, pszTarget ))
            return;

          wcsncpy(nm.szTarget,pszTarget,MAX_URL_LENGTH);
        }

        ::SendMessage(hwnd,WM_BEHAVIOR_NOTIFY,HLN_HYPERLINK,LPARAM(&nm));

    }
Example #2
0
void FeTextureContainer::load_from_archive( const char *a, const char *n )
{
	std::string path, filename = clean_path( n );

	if ( filename.empty() )
	{
		clear();
		notify_texture_change();
		return;
	}

	if ( a && ( strlen( a ) > 0 ))
		path = clean_path( a );

	// If it is a relative path we assume it is in the
	// layout/screensaver/intro directory
	//
	else if ( is_relative_path( filename ) )
		path = FePresent::script_get_base_path();

	bool is_image=false;

	int i=0;
	while ( FE_ART_EXTENSIONS[i] )
	{
		if ( tail_compare( filename, FE_ART_EXTENSIONS[i] ) )
		{
			is_image=true;
			break;
		}
		i++;
	}

	try_to_load( path, filename, is_image );
	notify_texture_change();
}
Example #3
0
void FeTextureContainer::internal_update_selection( FeSettings *feSettings )
{
	int filter_index = feSettings->get_filter_index_from_offset( m_filter_offset );
	int rom_index = feSettings->get_rom_index( filter_index, m_index_offset );

	//
	// Optimization opportunity: We could already be showing the artwork for rom_index if the
	// layout uses the image swap() function... if we are, then there is no need to do anything...
	//
	if (( m_current_rom_index == rom_index )
				&& ( m_current_filter_index == filter_index ))
	{
#ifdef FE_DEBUG
		std::cout << "Optimization: " << m_file_name << " not loaded." << std::endl;
#endif
		return;
	}

	m_current_rom_index = rom_index;
	m_current_filter_index = filter_index;

	std::vector<std::string> vid_list;
	std::vector<std::string> image_list;
	std::string archive_name; // empty if no archive

	if ( m_type == IsArtwork )
	{
		FeRomInfo *rom	= feSettings->get_rom_absolute( filter_index, rom_index );
		if ( !rom )
			return;

		if ( !feSettings->get_best_artwork_file( *rom,
			m_art_name,
			vid_list,
			image_list,
			(m_video_flags & VF_DisableVideo) ) )
		{
			// check for layout fallback images/videos
			std::string layout_path;
			feSettings->get_path( FeSettings::Current,
				layout_path );

			if ( !layout_path.empty() )
			{
				const std::string &emu_name = rom->get_info(
					FeRomInfo::Emulator );

				if ( is_supported_archive( layout_path ) )
				{
					archive_name = layout_path;

					// check for "[emulator-[artlabel]" artworks first
					if ( !gather_artwork_filenames_from_archive(
							layout_path, emu_name + "-" + m_art_name,
							vid_list, image_list ) )
					{
						// then "[artlabel]"
						gather_artwork_filenames_from_archive( layout_path,
							m_art_name, vid_list, image_list );
					}
				}
				else
				{
					std::vector<std::string> layout_paths;
					layout_paths.push_back( layout_path );

					// check for "[emulator-[artlabel]" artworks first
					if ( !gather_artwork_filenames( layout_paths,
							emu_name + "-" + m_art_name,
							vid_list, image_list ) )
					{
						// then "[artlabel]"
						gather_artwork_filenames( layout_paths,
							m_art_name, vid_list, image_list );
					}
				}
			}
		}
	}
	else if ( m_type == IsDynamic )
	{
		std::string work = m_art_name;
		FePresent::script_process_magic_strings( work,
				m_filter_offset,
				m_index_offset );

		feSettings->get_best_dynamic_image_file( filter_index,
			rom_index,
			work,
			vid_list,
			image_list );
	}

	// Load any found videos/images now
	//
	bool loaded=false;
	std::vector<std::string>::iterator itr;

#ifndef NO_MOVIE
	if ( m_video_flags & VF_DisableVideo )
		vid_list.clear();

	for ( itr=vid_list.begin(); itr != vid_list.end(); ++itr )
	{
		std::string path = archive_name;
		std::string filename = *itr;

		if ( path.empty() )
		{
			// test for artwork in an archive
			// format of filename is "<archivename>|<filename>"
			size_t pos = (*itr).find( "|" );
			if ( pos != std::string::npos )
			{
				path = (*itr).substr( 0, pos );
				filename = (*itr).substr( pos+1 );
			}
		}

		if ( try_to_load( path, filename ) )
		{
			loaded = true;
			break;
		}
	}
#endif

	if ( !loaded )
	{
		if ( image_list.empty() )
			clear();
		else
		{
			for ( itr=image_list.begin();
				itr != image_list.end(); ++itr )
			{
				std::string path = archive_name;
				std::string filename = *itr;

				if ( path.empty() )
				{
					// test for artwork in an archive
					// format of filename is "<archivename>|<filename>"
					size_t pos = (*itr).find( "|" );
					if ( pos != std::string::npos )
					{
						path = (*itr).substr( 0, pos );
						filename = (*itr).substr( pos+1 );
					}
				}

				if ( try_to_load( path, filename, true ) )
				{
					loaded = true;
					break;
				}
			}
		}
	}

	//
	// Texture was replaced, so notify the attached images
	//
	notify_texture_change();
}