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
34 //==============================================================================
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");
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);
56 void filenameComponentChanged (FilenameComponent
*)
58 editor
->loadContent (fileChooser
.getCurrentFile().loadFileAsString());
61 void paint (Graphics
& g
)
63 g
.fillAll (Colours::lightgrey
);
68 editor
->setBounds (10, 45, getWidth() - 20, getHeight() - 55);
69 fileChooser
.setBounds (10, 10, getWidth() - 20, 25);
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();