1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
//=======================================================================
// testapp.xx: Source file for test prototype V application
// Copyright (C) 1995,1996, 1997, 1998 Bruce E. Wampler
//
// This program is part of the V C++ GUI Framework example programs.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// (see COPYING) along with this program; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=======================================================================
//
//
// Files required for minimal application:
// testapp.h Header for the test app
// testoapp.cxx: Source code for min app
// vtcmdwin.h: Header code for sample command window
// vtcmdwin.cxx: Source code for sample command window
// vtdialog.h: Header for sample modeless dialog
// vtdialog.cxx: Source for sample modeless dialog
// mymodal.h: Header for sample modal dialog
// mymodal.cxx Soruce for sample modal dialog
//
// While these files were generated by hand, they are intended to
// serve as an example of files that could have been generated by
// the V interface generator (Vigr)
//
#include <v/vnotice.h> // so we can use notice
#include "testapp.h" // our header
static char newName[] = "[A] Example Subwindow";
static vWindow* firstWindow = 0;
//=========================>>> testApp::testapp <<<=========================
testApp::testApp(char* name, int simSDI) : vApp(name,simSDI)
{
_defWin = 0;
_defAppWinInfo = 0;
}
//=========================>>> testApp::~testapp <<<=========================
testApp::~testApp()
{
}
//=========================>>> myApp::NewAppWin <<<==========================
vWindow* testApp::NewAppWin(vWindow* win, char* name, int w, int h,
vAppWinInfo* winInfo)
{
// This version of NewAppWin is provided with the information
// required to name and size a window.
// Typically, these would get a file name or other information
// that will setup the AppWinInfo class for information
// specific to the application. Thus, each open window
// usually represents a view of a file or data object.
vWindow* thisWin = win; // local copy to use
vAppWinInfo* awinfo = winInfo;
char *myname = name;
if (!*name)
{
myname = newName; // make up a name
}
UserDebug1(Build,"testApp::NewAppWin(%s)\n",myname);
if (!thisWin) // need to new a window
{
thisWin = new testCmdWindow(myname, w, h);
_defWin = firstWindow = thisWin;
}
// The real app will no doubt have its own AppWinInfo class.
if (!awinfo)
{
awinfo = new vAppWinInfo(myname);
if (!_defAppWinInfo)
_defAppWinInfo = awinfo;
}
if (!*name)
{
newName[1]++; // Cheap way to generate unique name
}
return vApp::NewAppWin(thisWin, myname, w, h, awinfo);
}
//===========================>>> testApp::Exit <<<=============================
void testApp::Exit(void)
{
// This is called to close all windows. If the app needs to
// do something special, it can. Otherwise, it can call the
// general vApp::Exit method, which will generate
// appropriate calls the the specialized testApp::CloseAppWin
UserDebug(Build,"testApp::Exit()\n");
vApp::Exit(); // easy default behavior
}
//=======================>>> testApp::CloseAppWin <<<===========================
void testApp::CloseAppWin(vWindow* win)
{
// This will be called BEFORE a window has been unregistered or
// closed. The app can do whatever it needs to to close down
// the data associated with this window. Then it can call the
// general vApp::CloseAppWin to unregister and close this window.
// Note that the win gives a handle that can be used with
// vApp::getAppWinInfo to retrieve the AppWinInfo class.
// Code to handle close of window (such as saving/closing a file)
// would go here...
// Now unregister and close the window.
UserDebug(Build,"testApp::CloseAppWin()\n");
vApp::CloseAppWin(win);
}
//========================>>> testApp::AppCommand <<<===========================
void testApp::AppCommand(vWindow* win, ItemVal id, ItemVal val, CmdType cType)
{
// Any commands not processed by the window will be passed
// along to here for default treatment.
UserDebug1(Build,"testApp::AppCmd(ID: %d)\n",id);
if (id == 901)
{
vNoticeDialog note(this);
note.Notice("This is generated from testApp, not a dialog.");
return;
}
else if (id == 902)
{
if (firstWindow)
firstWindow->RaiseWindow();
}
else if (id == 903) // Shift first window
{
if (firstWindow)
{
int l,t,r,b;
firstWindow->GetPosition(l,t,r,b);
firstWindow->SetPosition(l+30,t+30);
}
}
vApp::AppCommand(win, id, val, cType);
}
//=========================>>> testApp::KeyIn <<<==============================
void testApp::KeyIn(vWindow* win, vKey key, unsigned int shift)
{
// Any key strokes not processed by the window will be passed
// along to here for default treatment.
vApp::KeyIn(win, key, shift);
}
//###########################################################################
// EVERY V application needs the equivalent of the following line
static testApp* tApp = new testApp("Vtest",0); // The instance of the app
//============================>>> AppMain <<<==============================
int AppMain(int argc, char** argv)
{
// Use AppMain to create the main window
(void) theApp->NewAppWin(0, "Prototype V Example", 600, 250, 0);
return 0;
}
|