]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/applet/applet.cpp
1 /****************************************************************************
3 * wxWindows HTML Applet Package
5 * Copyright (C) 1991-2001 SciTech Software, Inc.
8 * ========================================================================
10 * The contents of this file are subject to the wxWindows License
11 * Version 3.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.wxwindows.org/licence3.txt
15 * Software distributed under the License is distributed on an
16 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * ========================================================================
25 * Description: Main wxApplet sample program
27 ****************************************************************************/
29 // For compilers that support precompilation, includes "wx/wx.h".
30 #include "wx/wxprec.h"
36 #include "wx/applet/window.h"
39 /*---------------------------- Global variables ---------------------------*/
41 // Define the event tables for handling application frame events
42 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
43 EVT_MENU(Minimal_Quit
, MyFrame::OnQuit
)
44 EVT_MENU(Minimal_About
, MyFrame::OnAbout
)
45 EVT_MENU(Minimal_Back
, MyFrame::OnBack
)
46 EVT_MENU(Minimal_Forward
, MyFrame::OnForward
)
49 // Create a new application object: this macro will allow wxWindows to create
50 // the application object during program execution (it's better than using a
51 // static object for many reasons) and also declares the accessor function
52 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
56 /*------------------------- Implementation --------------------------------*/
58 /****************************************************************************
60 title - Title for the frame window
61 pos - Position to place to frame window
62 size - Size of the frame window
65 Application frame window constructor
66 ****************************************************************************/
68 const wxString
& title
,
71 : wxFrame(NULL
, -1, title
, pos
, size
)
74 wxMenu
*menuFile
= new wxMenu
;
75 wxMenu
*menuNav
= new wxMenu
;
76 menuFile
->Append(Minimal_Quit
, "E&xit");
77 menuNav
->Append(Minimal_Back
, "Go &back");
78 menuNav
->Append(Minimal_Forward
, "Go &forward");
80 // Now append the freshly created menu to the menu bar...
81 wxMenuBar
*menuBar
= new wxMenuBar
;
82 menuBar
->Append(menuFile
, "&File");
83 menuBar
->Append(menuNav
, "&Navigate");
85 // ... and attach this menu bar to the frame
89 // Create the HTML window
90 html
= new wxHtmlAppletWindow(this);
91 html
->SetRelatedFrame(this, "wxApplet Demo: '%s'");
92 html
->SetRelatedStatusBar(1);
93 html
->LoadPage("index.html");
96 /****************************************************************************
98 Event handler for the 'Exit' menu item
99 ****************************************************************************/
100 void MyFrame::OnQuit(
103 // TRUE is to force the frame to close
107 /****************************************************************************
109 Event handler for the 'About' menu item
110 ****************************************************************************/
111 void MyFrame::OnAbout(
114 // TODO: Bring up and about html page!
117 /****************************************************************************
119 Event handler for the 'Go back' menu item
120 ****************************************************************************/
121 void MyFrame::OnBack(
124 if (!html
-> HistoryBack())
125 wxMessageBox("You reached prehistory era!");
128 /****************************************************************************
130 Event handler for the 'Go forward' menu item
131 ****************************************************************************/
132 void MyFrame::OnForward(
135 if (!html
-> HistoryForward())
136 wxMessageBox("No more items in history!");
139 /****************************************************************************
141 `Main program' equivalent: the program execution "starts" here
142 ****************************************************************************/
145 // Create the main application window
146 MyFrame
*frame
= new MyFrame("wxApplet testing application",
147 wxPoint(50, 50), wxSize(640, 480));
149 // Show it and tell the application that it's our main window
153 // Success: wxApp::OnRun() will be called to run the application