Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / Introjucer / Source / Application / jucer_FilePreviewComponent.cpp
blob847d36db8e277109c027c1f058764e0ad6e91645
1 /*
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_)
32 : file (file_)
34 tryToLoadImage();
37 void ItemPreviewComponent::tryToLoadImage()
39 facts.clear();
40 facts.add (file.getFullPathName());
41 image = Image();
43 ScopedPointer <InputStream> input (file.createInputStream());
45 if (input != nullptr)
47 const int64 totalSize = input->getTotalLength();
48 ImageFileFormat* format = ImageFileFormat::findImageFormatForStream (*input);
49 input = nullptr;
51 String formatName;
52 if (format != nullptr)
53 formatName = " " + format->getFormatName();
55 image = ImageCache::getFromFile (file);
57 if (image.isValid())
58 facts.add (String (image.getWidth()) + " x " + String (image.getHeight()) + formatName);
60 if (totalSize > 0)
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,
71 false);
73 g.setFont (15.0f, Font::bold);
74 g.setColour (Colours::white);
75 g.drawMultiLineText (facts.joinIntoString ("\n"),
76 10, 15, getWidth() - 16);