File: protoapp.cpp

package info (click to toggle)
v1 1.17-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,812 kB
  • ctags: 6,780
  • sloc: cpp: 43,604; ansic: 5,003; makefile: 955; sh: 30
file content (147 lines) | stat: -rw-r--r-- 5,310 bytes parent folder | download
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
//=======================================================================
//  protoapp.xx:     Source file for minimal prototype V application
//  Copyright (C) 1995  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:
//      protoapp.h      Header for the min app
//      protoapp.cxx:   Source code for min app
//	mycmdwin.h:	Header code for sample command window
//	mycmdwin.cxx:	Source code for sample command window
//      mydialog.h:     Header for sample modeless dialog
//      mydialog.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 "protoapp.h"	// our header

    static char newName[] = "[A] Example Subwindow";

//=========================>>> myApp::NewAppWin <<<==========================
  vWindow* myApp::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,"myApp::NewAppWin(%s)\n",myname);

    if (!thisWin)			// need to new a window
      {
	thisWin = new myCmdWindow(myname, w, h);
      }

    // The real app will no doubt have its own AppWinInfo class.

    if (!awinfo)
	awinfo = new vAppWinInfo(myname);

    if (!*name)
      {
	newName[1]++;		// Cheap way to generate unique name
      }
    return vApp::NewAppWin(thisWin, myname, w, h, awinfo);
  }

//========================>>> myApp::Exit <<<======================
  void myApp::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 myApp::CloseAppWin

    UserDebug(Build,"myApp::Exit()\n");

    vApp::Exit();	// easy default behavior
  }

//=======================>>> myApp::CloseAppWin <<<===========================
  void myApp::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,"myApp::CloseAppWin()\n");

    vApp::CloseAppWin(win);
  }

//========================>>> myApp::AppCommand <<<==============================
  void myApp::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,"myApp::AppCmd(ID: %d)\n",id);
    vApp::AppCommand(win, id, val, cType);
  }

//=========================>>> myApp::KeyIn <<<==============================
  void myApp::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 myApp my_App("ProtoApp");	// 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", 450, 200);

    return 0;
  }