home *** CD-ROM | disk | FTP | other *** search
- /* ViewIt 2.2 Demonstration Program */
- /* ©FaceWare 1991-94. All Rights Reserved. */
-
- #include "string.h"
- #include "FaceStorMC.h"
- extern struct FaceRec fRec;
- pascal void OverProc(Ptr thePtr);
-
- short helpShown;
- struct {
- short myInteger;
- float myReal;
- char myString[100];
- long myFlags;
- } myRec;
- short myList;
- long oldTicks,newTicks,theProcPtr;
- float theReal,delta;
-
- #ifndef powerc
- pascal void fJumpIt(Ptr thePtr) = {0x2257,0x2051,0x4E90};
- #endif
-
- pascal void OverProc(Ptr thePtr) {
- if (fRec.uCommand == 264) /* a key down message? */
- if (fRec.uParam[0] == 32) /* SPACE key pressed? */
- fRec.uParam[0] = 95; /* convert to UNDERLINE */
- #ifdef powerc
- CallUniversalProc(*(UniversalProcPtr*)thePtr,192,thePtr);
- #else
- fJumpIt(thePtr); /* pass message to driver */
- #endif
- }
-
- void main()
- {
- myRec.myInteger = 0;
- myRec.myReal = 6.2;
- strcpy(myRec.myString,"Hello");
- myRec.myFlags = 10;
- myList = 2;
- oldTicks = 0;
- theReal = 6.0;
- #ifdef powerc
- theProcPtr = (long)NewRoutineDescriptor((ProcPtr)OverProc,192,1);
- #else
- theProcPtr = (long)OverProc;
- #endif
-
- /* Initialize FaceIt */
- strcpy(fRec.uName, "vDemo.Rsrc");
- FaceIt(0,DoInit,0,0,0,0);
-
- /* Open Modeless Window using FWND 1000 */
- FaceIt(0,NewWnd,1000,1,0,0);
-
- for (;;) {
- FaceIt(0,DoLoop,0,0,0,0);
- /* Standard "About" Menu Item Selection */
- if ((fRec.uMenuID == 101L) && (fRec.uMenuItem == 1L)) {
- strcpy(fRec.uString, "Demonstration of the use of ViewIt\rwindows in a FaceIt-based program.");
- FaceIt(0,ShoStr,3,12,(1 + (409 * 65536)),0);
- }
- /* Hit in Modeless Window's "Open Modal" Button */
- else if ((fRec.uMenuID == 1000L) && (fRec.wcHit == 2L)) {
- FaceIt(0,NewWnd,1001,0,0,0); /* Open Modal Window */
- for (;;) {
- FaceIt(0,MdlWnd,1001,0,0,0); /* Process Modal Events */
- if (fRec.wcHit == -1L) /* Hit in Close Box */
- break;
- else if (fRec.wcHit == 1L) { /* Hit in "Open Nested" Button */
- FaceIt(0,NewWnd,1002,0,0,(long)&myRec); /* Open Nested Modal */
- FaceIt(0,GetCtl,1002,0,3,3); /* Link Scrollable List */
- FaceIt(0,LnkCtl,(long)fRec.cControl,(long)&myList,2,0);
- FaceIt(0,GetCtl,1002,0,2,3); /* Set Override Proc */
- FaceIt(0,OvrCtl,(long)fRec.cControl,theProcPtr,0,0);
- FaceIt(0,SetVal,1002,0,0,0); /* Set Linked Values */
- helpShown = false;
- for (;;) {
- FaceIt(0,MdlWnd,1002,-2,0,0); /* Process Modal Events */
- if (fRec.uMenuID == 0L) { /* No Message */
- newTicks = TickCount();
- if (newTicks > oldTicks + 60) {
- oldTicks = newTicks;
- FaceIt(0,GetCtl,1002,0,2,8);
- SetCtlValue(fRec.cControl,(fRec.cValue % 4) + 1);
- }
- }
- else if (fRec.wvHit == 1L) { /* Hit in View #1 */
- if (fRec.wcHit == 1L) /* Hit in "OK" Button */
- break;
- else if (fRec.wcHit == 2L) { /* Hit in "Show/Hide" */
- if (helpShown == true) {
- FaceIt(0,ShoCtl,0,0,-3,2); /* Hide v3, Show v2 */
- helpShown = false;}
- else {
- FaceIt(0,ShoCtl,0,0,-2,3); /* Hide v2, Show v3 */
- helpShown = true;}
- }
- }
- else if (fRec.wvHit == 2L) /* Hit in View #2 */
- if ((fRec.wcHit == 6L)||(fRec.wcHit == 7L)) { /* Up/Down Arrow */
- FaceIt(0,GetCtl,1002,0,2,(long)fRec.wcHit);
- delta = 0.001 * (fRec.cMin - 2);
- myRec.myReal = myRec.myReal + delta;
- FaceIt(0,SetVal,1002,0,2,2);
- Delay(5,&fRec.uI4);
- }
- }
- FaceIt(0,GetVal,1002,0,0,0); /* Get Linked Values */
- FaceIt(0,EndWnd,1002,0,0,0); /* Close Nested Modal */
- }
- }
- FaceIt(0,EndWnd,1001,0,0,0); /* Close Modal Window */
- }
- /* Hit in Modeless Window's "Why ViewIt?" Button */
- else if ((fRec.uMenuID == 1000L) && (fRec.wcHit == 3L)) {
- FaceIt(0,NewWnd,1003,0,0,(long)&theReal);
- FaceIt(0,SetVal,1003,0,0,0);
- for (;;) {
- FaceIt(0,MdlWnd,1003,0,0,0);
- if (fRec.wcHit == 1L) break;}
- FaceIt(0,GetVal,1003,0,0,0);
- FaceIt(0,EndWnd,1003,0,0,0);
- }
- }
- }