home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: minimal.cc
- * Purpose: Minimal wxWindows app
- *
- * 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"
-
- // 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);
- };
-
- // ID for the menu quit command
- #define MINIMAL_QUIT 1
-
- // This statement initializes the whole application and calls OnInit
- MyApp myApp;
-
- // `Main program' equivalent, creating windows and returning main app frame
- wxFrame *MyApp::OnInit(void)
- {
- // Create the main frame window
- MyFrame *frame = new MyFrame(NULL, "Minimal wxWindows App", 50, 50, 400, 300);
-
- // Give it an icon
- frame->SetIcon(new wxIcon("aiai_icn"));
-
- // Make a menubar
- wxMenu *file_menu = new wxMenu;
- file_menu->Append(MINIMAL_QUIT, "Quit");
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, "File");
- 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 minimal wxWindows program!", 0, 0);
-
- // Show the frame
- 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 MINIMAL_QUIT:
- delete this;
- break;
- }
- }
-
-