home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: test.cc
- * Purpose: Test wxWindows app to demonstrate use of wxHelp API
- *
- * wxWindows 1.40
- * Copyright (c) 1993 Artificial Intelligence Applications Institute,
- * The University of Edinburgh
- *
- * Author: Julian Smart
- * Date: 18-4-93
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose is hereby granted without fee, provided
- * that the above copyright notice, author statement and this permission
- * notice appear in all copies of this software and related documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
- * IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
- * UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
- * DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
- * THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
- #include <windows.h> // Included only for benefit of MSC7 precompiled headers
- #include "wx.h"
- #include "wx_help.h"
-
- // Define a new application type
- class MyApp: public wxApp
- { public:
- wxFrame *OnInit(void);
- };
-
- // Define a new frame type
- class MyFrame: public wxFrame
- { public:
- MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
- void OnMenuCommand(int id);
- Bool OnClose(void);
- };
-
- // ID for the menu quit command
- #define TEST_QUIT 1
- #define TEST_HELP_ON_HELP 2
- #define TEST_HELP_ON_EDITING 3
- #define TEST_KEYWORD 4
-
- // This statement initializes the whole application and calls OnInit
- MyApp myApp;
-
- // Help instance
- wxHelpInstance *HelpInstance = NULL;
-
- // `Main program' equivalent, creating windows and returning main app frame
- wxFrame *MyApp::OnInit(void)
- {
- // Create the main frame window
- MyFrame *frame = new MyFrame(NULL, "Test wxWindows App", 0, 0, 400, 300);
-
- // Give it an icon
- frame->SetIcon(new wxIcon("aiai_icn"));
-
- // Make a menubar
- wxMenu *file_menu = new wxMenu;
- file_menu->Append(TEST_QUIT, "Quit");
-
- wxMenu *help_menu = new wxMenu;
- help_menu->Append(TEST_HELP_ON_HELP, "Help on wxHelp");
- help_menu->Append(TEST_HELP_ON_EDITING, "Help on wxHelp Editing");
- help_menu->Append(TEST_KEYWORD, "Keyword search");
-
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, "File");
- menu_bar->Append(help_menu, "Help");
- frame->SetMenuBar(menu_bar);
-
- // Make a panel with a message
- wxPanel *panel = new wxPanel(frame, 0, 0, 400, 300);
- (void)new wxMessage(panel, "Hello, this is a test wxWindows program!");
-
- HelpInstance = new wxHelpInstance;
- HelpInstance->Initialize("help.xlp");
-
- frame->Show(TRUE);
-
- // Return the main frame window
- return frame;
- }
-
- // My frame constructor
- MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
- wxFrame(frame, title, x, y, w, h)
- {}
-
- // Intercept menu commands
- void MyFrame::OnMenuCommand(int id)
- {
- switch (id) {
- case TEST_QUIT:
- OnClose();
- delete this;
- break;
- case TEST_HELP_ON_HELP:
- {
- HelpInstance->LoadFile();
- HelpInstance->DisplayContents();
- break;
- }
- case TEST_HELP_ON_EDITING:
- {
- HelpInstance->LoadFile();
- HelpInstance->DisplaySection(9);
- break;
- }
- case TEST_KEYWORD:
- {
- char *s = wxGetTextFromUser("Enter keyword");
- if (s)
- {
- HelpInstance->LoadFile();
- HelpInstance->KeywordSearch(s);
- }
- break;
- }
- }
- }
-
- Bool MyFrame::OnClose(void)
- {
- HelpInstance->Quit();
- return TRUE;
- }
-
-