2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-10 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_FilePreviewComponent.h"
30 //==============================================================================
31 ItemPreviewComponent::ItemPreviewComponent (const File
& file_
)
37 void ItemPreviewComponent::tryToLoadImage()
40 facts
.add (file
.getFullPathName());
43 ScopedPointer
<InputStream
> input (file
.createInputStream());
47 const int64 totalSize
= input
->getTotalLength();
48 ImageFileFormat
* format
= ImageFileFormat::findImageFormatForStream (*input
);
52 if (format
!= nullptr)
53 formatName
= " " + format
->getFormatName();
55 image
= ImageCache::getFromFile (file
);
58 facts
.add (String (image
.getWidth()) + " x " + String (image
.getHeight()) + formatName
);
61 facts
.add (File::descriptionOfSizeInBytes (totalSize
));
64 facts
.removeEmptyStrings (true);
67 void ItemPreviewComponent::paint (Graphics
& g
)
69 g
.drawImageWithin (image
, 2, 22, getWidth() - 4, getHeight() - 24,
70 RectanglePlacement::centred
| RectanglePlacement::onlyReduceInSize
,
73 g
.setFont (15.0f
, Font::bold
);
74 g
.setColour (Colours::white
);
75 g
.drawMultiLineText (facts
.joinIntoString ("\n"),
76 10, 15, getWidth() - 16);