Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / JuceDemo / Source / demos / WebBrowserDemo.cpp
blob423ee90cf6747791a5f745fb50ccf01180924ec6
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"
28 #if JUCE_WEB_BROWSER
30 //==============================================================================
31 /** We'll use a subclass of WebBrowserComponent to demonstrate how to get callbacks
32 when the browser changes URL. You don't need to do this, you can just also
33 just use the WebBrowserComponent class directly.
35 class DemoBrowserComponent : public WebBrowserComponent
37 public:
38 //==============================================================================
39 DemoBrowserComponent (TextEditor& addressTextBox_)
40 : addressTextBox (addressTextBox_)
44 // This method gets called when the browser is about to go to a new URL..
45 bool pageAboutToLoad (const String& newURL)
47 // We'll just update our address box to reflect the new location..
48 addressTextBox.setText (newURL, false);
50 // we could return false here to tell the browser not to go ahead with
51 // loading the page.
52 return true;
55 private:
56 TextEditor& addressTextBox;
58 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DemoBrowserComponent);
62 //==============================================================================
63 class WebBrowserDemo : public Component,
64 public TextEditor::Listener,
65 public ButtonListener
67 public:
68 //==============================================================================
69 WebBrowserDemo()
70 : goButton ("Go", "Go to URL"),
71 backButton ("<<", "Back"),
72 forwardButton (">>", "Forward")
74 setName ("Web Browser");
76 // Create an address box..
77 addAndMakeVisible (&addressTextBox);
78 addressTextBox.setTextToShowWhenEmpty ("Enter a web address, e.g. http://www.rawmaterialsoftware.com", Colours::grey);
79 addressTextBox.addListener (this);
81 // create the actual browser component
82 addAndMakeVisible (webView = new DemoBrowserComponent (addressTextBox));
84 // add some buttons..
85 addAndMakeVisible (&goButton);
86 goButton.addListener (this);
87 addAndMakeVisible (&backButton);
88 backButton.addListener (this);
89 addAndMakeVisible (&forwardButton);
90 forwardButton.addListener (this);
92 // send the browser to a start page..
93 webView->goToURL ("http://www.google.com");
96 ~WebBrowserDemo()
100 void resized()
102 webView->setBounds (10, 45, getWidth() - 20, getHeight() - 55);
103 goButton.setBounds (getWidth() - 45, 10, 35, 25);
104 addressTextBox.setBounds (100, 10, getWidth() - 155, 25);
105 backButton.setBounds (10, 10, 35, 25);
106 forwardButton.setBounds (55, 10, 35, 25);
109 void textEditorTextChanged (TextEditor&) {}
110 void textEditorEscapeKeyPressed (TextEditor&) {}
111 void textEditorFocusLost (TextEditor&) {}
113 void textEditorReturnKeyPressed (TextEditor&)
115 webView->goToURL (addressTextBox.getText());
118 void buttonClicked (Button* b)
120 if (b == &backButton)
121 webView->goBack();
122 else if (b == &forwardButton)
123 webView->goForward();
124 else if (b == &goButton)
125 webView->goToURL (addressTextBox.getText());
128 private:
129 ScopedPointer<DemoBrowserComponent> webView;
131 TextEditor addressTextBox;
132 TextButton goButton, backButton, forwardButton;
134 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebBrowserDemo);
138 //==============================================================================
139 Component* createWebBrowserDemo()
141 return new WebBrowserDemo();
144 #endif