MCPcopy Create free account
hub / github.com/audacity/audacity / WriteOneImageMap

Method WriteOneImageMap

libraries/lib-theme/Theme.cpp:737–786  ·  view source on GitHub ↗

Writes an html file with an image map of the ImageCache Very handy for seeing what each part is for.

Source from the content-addressed store, hash-verified

735/// Writes an html file with an image map of the ImageCache
736/// Very handy for seeing what each part is for.
737void ThemeBase::WriteOneImageMap( teThemeType id )
738{
739 SwitchTheme( id );
740 auto &resources = *mpSet;
741
742 FlowPacker context{ ImageCacheWidth };
743
744 auto dir = ThemeSubdir(GetFilePath(), id);
745 auto FileName = wxFileName{ dir, ImageMapFileName }.GetFullPath();
746 wxFFile File( FileName, wxT("wb") );// I'll put in NEW lines explicitly.
747 if( !File.IsOpened() )
748 return;
749
750 File.Write( wxT("<html>\r\n"));
751 File.Write( wxT("<body bgcolor=\"303030\">\r\n"));
752 wxString Temp = wxString::Format( wxT("<img src=\"ImageCache.png\" width=\"%i\" usemap=\"#map1\">\r\n" ), ImageCacheWidth );
753 File.Write( Temp );
754 File.Write( wxT("<map name=\"map1\">\r\n") );
755
756 for (size_t i = 0; i < resources.mImages.size(); ++i)
757 {
758 wxImage &SrcImage = resources.mImages[i];
759 context.mFlags = mBitmapFlags[i];
760 if( !(mBitmapFlags[i] & resFlagInternal) )
761 {
762 context.GetNextPosition( SrcImage.GetWidth(), SrcImage.GetHeight());
763 // No href in html. Uses title not alt.
764 wxRect R( context.RectInner() );
765 File.Write( wxString::Format(
766 wxT("<area title=\"Bitmap:%s\" shape=rect coords=\"%i,%i,%i,%i\">\r\n"),
767 mBitmapNames[i],
768 R.GetLeft(), R.GetTop(), R.GetRight(), R.GetBottom()) );
769 }
770 }
771 // Now save the colours.
772 context.SetColourGroup();
773 for (size_t i = 0; i < resources.mColours.size(); ++i)
774 {
775 context.GetNextPosition( iColSize, iColSize );
776 // No href in html. Uses title not alt.
777 wxRect R( context.RectInner() );
778 File.Write( wxString::Format( wxT("<area title=\"Colour:%s\" shape=rect coords=\"%i,%i,%i,%i\">\r\n"),
779 mColourNames[i],
780 R.GetLeft(), R.GetTop(), R.GetRight(), R.GetBottom()) );
781 }
782 File.Write( wxT("</map>\r\n") );
783 File.Write( wxT("</body>\r\n"));
784 File.Write( wxT("</html>\r\n"));
785 // File will be closed automatically.
786}
787
788/// Writes a series of Macro definitions that can be used in the include file.
789void ThemeBase::WriteImageDefs( )

Callers

nothing calls this directly

Calls 10

ThemeSubdirFunction · 0.85
IsOpenedMethod · 0.80
GetNextPositionMethod · 0.80
GetHeightMethod · 0.80
RectInnerMethod · 0.80
GetRightMethod · 0.80
SetColourGroupMethod · 0.80
WriteMethod · 0.45
sizeMethod · 0.45
GetWidthMethod · 0.45

Tested by

no test coverage detected