2001-05-02 16:59:28 -04:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
2001-05-03 13:33:55 -04:00
|
|
|
* wxWindows HTML Applet Package
|
2001-05-02 16:59:28 -04:00
|
|
|
*
|
2001-06-12 14:52:03 -04:00
|
|
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2001-05-02 16:59:28 -04:00
|
|
|
* ========================================================================
|
|
|
|
*
|
2001-06-12 14:52:03 -04:00
|
|
|
* The contents of this file are subject to the wxWindows License
|
|
|
|
* Version 3.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.wxwindows.org/licence3.txt
|
2001-05-02 16:59:28 -04:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2001-05-03 13:33:55 -04:00
|
|
|
* Language: ANSI C++
|
|
|
|
* Environment: Any
|
2001-05-02 16:59:28 -04:00
|
|
|
*
|
|
|
|
* Description: Main wxApplet sample program
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
2001-10-30 08:33:34 -05:00
|
|
|
#include "wx/wxprec.h"
|
2001-05-02 16:59:28 -04:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
2001-05-06 13:41:54 -04:00
|
|
|
|
|
|
|
#include "wx/wx.h"
|
2001-05-02 16:59:28 -04:00
|
|
|
#include "wx/applet/window.h"
|
|
|
|
#include "applet.h"
|
|
|
|
|
|
|
|
/*---------------------------- Global variables ---------------------------*/
|
|
|
|
|
|
|
|
// Define the event tables for handling application frame events
|
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
2001-05-03 13:33:55 -04:00
|
|
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
|
|
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
|
|
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
|
|
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
2001-05-02 16:59:28 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// Create a new application object: this macro will allow wxWindows to create
|
|
|
|
// the application object during program execution (it's better than using a
|
|
|
|
// static object for many reasons) and also declares the accessor function
|
|
|
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
|
|
|
// not wxApp)
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
|
|
|
|
/*------------------------- Implementation --------------------------------*/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
PARAMETERS:
|
2001-05-03 13:33:55 -04:00
|
|
|
title - Title for the frame window
|
|
|
|
pos - Position to place to frame window
|
|
|
|
size - Size of the frame window
|
2001-05-02 16:59:28 -04:00
|
|
|
|
|
|
|
REMARKS:
|
|
|
|
Application frame window constructor
|
|
|
|
****************************************************************************/
|
|
|
|
MyFrame::MyFrame(
|
2001-05-03 13:33:55 -04:00
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size)
|
|
|
|
: wxFrame(NULL, -1, title, pos, size)
|
2001-05-02 16:59:28 -04:00
|
|
|
{
|
2001-05-03 13:33:55 -04:00
|
|
|
// Create a menu bar
|
|
|
|
wxMenu *menuFile = new wxMenu;
|
|
|
|
wxMenu *menuNav = new wxMenu;
|
|
|
|
menuFile->Append(Minimal_Quit, "E&xit");
|
|
|
|
menuNav->Append(Minimal_Back, "Go &back");
|
|
|
|
menuNav->Append(Minimal_Forward, "Go &forward");
|
2001-06-12 14:52:03 -04:00
|
|
|
|
2001-05-03 13:33:55 -04:00
|
|
|
// Now append the freshly created menu to the menu bar...
|
|
|
|
wxMenuBar *menuBar = new wxMenuBar;
|
|
|
|
menuBar->Append(menuFile, "&File");
|
|
|
|
menuBar->Append(menuNav, "&Navigate");
|
2001-06-12 14:52:03 -04:00
|
|
|
|
2001-05-03 13:33:55 -04:00
|
|
|
// ... and attach this menu bar to the frame
|
|
|
|
SetMenuBar(menuBar);
|
|
|
|
CreateStatusBar(2);
|
|
|
|
|
2001-06-12 14:52:03 -04:00
|
|
|
// Create the HTML window
|
2001-05-03 13:33:55 -04:00
|
|
|
html = new wxHtmlAppletWindow(this);
|
|
|
|
html->SetRelatedFrame(this, "wxApplet Demo: '%s'");
|
|
|
|
html->SetRelatedStatusBar(1);
|
|
|
|
html->LoadPage("index.html");
|
2001-05-02 16:59:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
REMARKS:
|
|
|
|
Event handler for the 'Exit' menu item
|
|
|
|
****************************************************************************/
|
|
|
|
void MyFrame::OnQuit(
|
2001-05-03 13:33:55 -04:00
|
|
|
wxCommandEvent&)
|
2001-05-02 16:59:28 -04:00
|
|
|
{
|
2001-05-03 13:33:55 -04:00
|
|
|
// TRUE is to force the frame to close
|
|
|
|
Close(TRUE);
|
2001-05-02 16:59:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
REMARKS:
|
|
|
|
Event handler for the 'About' menu item
|
|
|
|
****************************************************************************/
|
|
|
|
void MyFrame::OnAbout(
|
2001-05-03 13:33:55 -04:00
|
|
|
wxCommandEvent&)
|
2001-05-02 16:59:28 -04:00
|
|
|
{
|
2001-05-03 13:33:55 -04:00
|
|
|
// TODO: Bring up and about html page!
|
2001-05-02 16:59:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
REMARKS:
|
|
|
|
Event handler for the 'Go back' menu item
|
|
|
|
****************************************************************************/
|
|
|
|
void MyFrame::OnBack(
|
2001-05-03 13:33:55 -04:00
|
|
|
wxCommandEvent&)
|
2001-05-02 16:59:28 -04:00
|
|
|
{
|
2001-05-03 13:33:55 -04:00
|
|
|
if (!html -> HistoryBack())
|
|
|
|
wxMessageBox("You reached prehistory era!");
|
2001-05-02 16:59:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
REMARKS:
|
|
|
|
Event handler for the 'Go forward' menu item
|
|
|
|
****************************************************************************/
|
|
|
|
void MyFrame::OnForward(
|
2001-05-03 13:33:55 -04:00
|
|
|
wxCommandEvent&)
|
2001-05-02 16:59:28 -04:00
|
|
|
{
|
2001-05-03 13:33:55 -04:00
|
|
|
if (!html -> HistoryForward())
|
|
|
|
wxMessageBox("No more items in history!");
|
2001-05-02 16:59:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
REMARKS:
|
|
|
|
`Main program' equivalent: the program execution "starts" here
|
|
|
|
****************************************************************************/
|
|
|
|
bool MyApp::OnInit()
|
|
|
|
{
|
2001-05-03 13:33:55 -04:00
|
|
|
// Create the main application window
|
|
|
|
MyFrame *frame = new MyFrame("wxApplet testing application",
|
|
|
|
wxPoint(50, 50), wxSize(640, 480));
|
2001-05-02 16:59:28 -04:00
|
|
|
|
2001-05-03 13:33:55 -04:00
|
|
|
// Show it and tell the application that it's our main window
|
|
|
|
frame->Show(TRUE);
|
|
|
|
SetTopWindow(frame);
|
2001-05-02 16:59:28 -04:00
|
|
|
|
2001-05-03 13:33:55 -04:00
|
|
|
// Success: wxApp::OnRun() will be called to run the application
|
|
|
|
return TRUE;
|
2001-05-02 16:59:28 -04:00
|
|
|
}
|
|
|
|
|