Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / JuceDemo / Source / demos / CodeEditorDemo.cpp
blob99a5c5d3b6a0f7b03ab69495e80bc74b0a5d32ed
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-9 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 "../jucedemo_headers.h"
29 //==============================================================================
30 class CodeEditorDemo : public Component,
31 public FilenameComponentListener
33 public:
34 //==============================================================================
35 CodeEditorDemo()
36 : fileChooser ("File", File::nonexistent, true, false, false,
37 "*.cpp;*.h;*.hpp;*.c;*.mm;*.m", String::empty,
38 "Choose a C++ file to open it in the editor")
40 setName ("Code Editor");
41 setOpaque (true);
43 // Create the editor..
44 addAndMakeVisible (editor = new CodeEditorComponent (codeDocument, &cppTokeniser));
45 editor->loadContent ("\n\n/* Code editor demo! Please be gentle, this component is still an alpha version! */\n\n");
47 // Create a file chooser control to load files into it..
48 addAndMakeVisible (&fileChooser);
49 fileChooser.addListener (this);
52 ~CodeEditorDemo()
56 void filenameComponentChanged (FilenameComponent*)
58 editor->loadContent (fileChooser.getCurrentFile().loadFileAsString());
61 void paint (Graphics& g)
63 g.fillAll (Colours::lightgrey);
66 void resized()
68 editor->setBounds (10, 45, getWidth() - 20, getHeight() - 55);
69 fileChooser.setBounds (10, 10, getWidth() - 20, 25);
72 private:
73 // this is the document that the editor component is showing
74 CodeDocument codeDocument;
76 // this is a tokeniser to do the c++ syntax highlighting
77 CPlusPlusCodeTokeniser cppTokeniser;
79 // the editor component
80 ScopedPointer<CodeEditorComponent> editor;
82 FilenameComponent fileChooser;
84 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeEditorDemo);
88 //==============================================================================
89 Component* createCodeEditorDemo()
91 return new CodeEditorDemo();