home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CLASS.ZIP / 2.CC < prev    next >
Text File  |  1993-02-21  |  29KB  |  800 lines

  1. #include "MenuPMProcess.h"
  2. #include "apfel.resource.h"
  3. #include "memory.h"
  4. #ifdef INCLUDESOURCE
  5. #include "pmprocess.cc"
  6. #endif
  7.  
  8.  
  9. Boolean calcThread::initPost(void)
  10. {
  11. #ifdef SHOWCALLS
  12.        fprintf(stderr, "Calling calcThread::initThread(%x)\n", this);
  13. #endif SHOWCALLS
  14.        pmThreadTree::initPost();
  15.        DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, -31, pTIB->tib_ptib2->tib2_ultid);
  16.        return TRUE;
  17. }
  18.  
  19.  
  20. calcThread::calcThread(menuPmThreadTree *pParentNew):pmThreadTree(pParentNew)
  21. {
  22. #ifdef SHOWCALLS
  23.        fprintf(stderr, "Calling calcThread(%x)\n", this);
  24. #endif SHOWCALLS
  25.       ((menuPmThreadTree*)pParent)->pCalcThread = this;
  26. }
  27.  
  28.  
  29. calcThread::~calcThread(void)
  30. {
  31. #ifdef SHOWCALLS
  32.        fprintf(stderr, "Calling ~calcThread(%x)\n", this);
  33. #endif SHOWCALLS
  34.       ((menuPmThreadTree*)pParent)->pCalcThread = (calcThread*)0;
  35. }
  36.  
  37.  
  38. #ifdef undefined
  39. fullScreen::fullScreen(menuPmThreadTree *pMsgThread)
  40.     :windowPaint(pMsgThread, 0, "")
  41. {
  42. #ifdef SHOWCALLS
  43.        fprintf(stderr, "Calling fullScreen::fullScreen()\n");
  44. #endif SHOWCALLS
  45.       ((menuPmThreadTree*)pMsgThread)->pFullScreen = this;
  46. }
  47. #endif undefined
  48.  
  49.  
  50. fullScreen::fullScreen(windowTree *pParent)
  51.     :windowPaint(pParent, 0, "")
  52. {
  53. #ifdef SHOWCALLS
  54.        fprintf(stderr, "Calling fullScreen::fullScreen(%x)\n", this);
  55. #endif SHOWCALLS
  56.       ((menuPmThreadTree*)pMsgThread)->pFullScreen = this;
  57. }
  58.  
  59.  
  60. Boolean fullScreen::initPre(void)
  61. {
  62. #ifdef SHOWCALLS
  63.         fprintf(stderr, "Calling fullScreen:initPre(%x)\n", this);
  64. #endif SHOWCALLS
  65.         if (!windowPaint::initPre())
  66.                 return FALSE;
  67.         frameFlags = FCF_NOMOVEWITHOWNER | FCF_SCREENALIGN | FCF_BORDER;
  68.         windowStyle = WS_MAXIMIZED | WS_VISIBLE | FS_NOMOVEWITHOWNER | FS_SCREENALIGN;
  69.         classStyle = 0;
  70.         pWindowClassName = "fullScreen";
  71.         return TRUE;
  72. }
  73.  
  74.  
  75. Boolean fullScreen::initPost(void)
  76. {
  77. #ifdef SHOWCALLS
  78.         fprintf(stderr, "Calling fullScreen:initPost(%x)\n", this);
  79. #endif SHOWCALLS
  80.         if (!windowPaint::initPost())
  81.                 return FALSE;
  82.         WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, ((menuPmThreadTree*)pMsgThread)->iSizeX,
  83.             ((menuPmThreadTree*)pMsgThread)->iSizeY,
  84.             SWP_ACTIVATE | SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW);
  85.         return TRUE;
  86. }
  87.  
  88.  
  89. MRESULT fullScreen::WMClose(MPARAM mp1, MPARAM mp2)
  90. {
  91. #ifdef SHOWCALLS
  92.        fprintf(stderr, "Calling fullScreen::WMClose(%x)\n", this);
  93. #endif SHOWCALLS
  94.       return FALSE;
  95. }
  96.  
  97.  
  98. fullScreen::~fullScreen(void)
  99. {
  100. #ifdef SHOWCALLS
  101.        fprintf(stderr, "Calling ~fullScreen(%x)\n", this);
  102. #endif SHOWCALLS
  103.       ((menuPmThreadTree*)pMsgThread)->pFullScreen = (fullScreen*)0;
  104. }
  105.  
  106.  
  107. #ifdef DEBUG
  108. void showFloatRegs(int n, int iLine)
  109.        {       double r[8];
  110.  
  111.                if (n >= 1)
  112.                        asm("FStPL %0" : "=m" (r[0]));
  113.                if (n >= 2)
  114.                        asm("FStPL %0" : "=m" (r[1]));
  115.                if (n >= 3)
  116.                        asm("FStPL %0" : "=m" (r[2]));
  117.                if (n >= 4)
  118.                        asm("FStPL %0" : "=m" (r[3]));
  119.                if (n >= 5)
  120.                        asm("FStPL %0" : "=m" (r[4]));
  121.                if (n >= 6)
  122.                        asm("FStPL %0" : "=m" (r[5]));
  123.                if (n >= 7)
  124.                        asm("FStPL %0" : "=m" (r[6]));
  125.                if (n >= 8)
  126.  
  127.                        asm("FStPL %0" : "=m" (r[7]));
  128.                
  129.                fprintf(stderr, "%u", iLine); \
  130.                if (n >= 1) \
  131.                        fprintf(stderr, " r0=%f", r[0]); \
  132.                if (n >= 2) \
  133.                        fprintf(stderr, " r1=%f", r[1]); \
  134.                if (n >= 3) \
  135.                        fprintf(stderr, " r2=%f", r[2]); \
  136.                if (n >= 4) \
  137.                        fprintf(stderr, " r3=%f", r[3]); \
  138.                if (n >= 5) \
  139.                        fprintf(stderr, " r4=%f", r[4]); \
  140.                if (n >= 6) \
  141.                        fprintf(stderr, " r5=%f", r[5]); \
  142.                if (n >= 7) \
  143.                        fprintf(stderr, " r6=%f", r[6]); \
  144.                if (n >= 8) \
  145.                        fprintf(stderr, " r7=%f", r[7]); \
  146.                fprintf(stderr, "\n"); \
  147.                if (n >= 8)
  148.                        asm("FLdL %0" : : "m" (r[7]));
  149.                if (n >= 7)
  150.                        asm("FLdL %0" : : "m" (r[6]));
  151.                if (n >= 6)
  152.                        asm("FLdL %0" : : "m" (r[5]));
  153.                if (n >= 5)
  154.                        asm("FLdL %0" : : "m" (r[4]));
  155.                if (n >= 4)
  156.                        asm("FLdL %0" : : "m" (r[3]));
  157.                if (n >= 3)
  158.                        asm("FLdL %0" : : "m" (r[2]));
  159.                if (n >= 2)
  160.                        asm("FLdL %0" : : "m" (r[1]));
  161.                if (n >= 1)
  162.                        asm("FLdL %0" : : "m" (r[0]));
  163. }
  164. #else DEBUG
  165. #define showFloatRegs(n, iLine) (void)1
  166. #endif !DEBUG
  167.  
  168.  
  169. void calcThread::doSomething(void)
  170. {      unsigned int xi, yi, it, iMaxColors_1;
  171.        menuPmThreadTree *pMsgThread = (menuPmThreadTree*)pParent;
  172.        double xl = pMsgThread->xa, yl = pMsgThread->ya, x, y;
  173. #ifdef undefined
  174.         const static double B1D16 = 0.0625,
  175.         B1D2  = 0.5,
  176.         B16   = 16.0,
  177.         B5    = 5.0,
  178.         B4    = 4.0;
  179. #endif
  180.        BITMAPINFO2 *pBitmapInfo;
  181.        unsigned char *pData;
  182.        unsigned char *pDataCompare;
  183.        unsigned int iBitmapSize;
  184. #ifdef SHOWCALLS
  185.        fprintf(stderr, "Calling calcThread::runThread(%x)\n", this);
  186. #endif
  187.        iMaxColors_1 = pMsgThread->iMaxColors - 1;
  188.        pData = alloca(iBitmapSize = pMsgThread->iSizeX * sizeof(*pData));
  189.        pDataCompare = alloca(iBitmapSize);
  190.        assert(!((unsigned long)pData & 3));
  191.        {       unsigned int iSize;
  192.  
  193.                pBitmapInfo = alloca(iSize = 256*sizeof(RGB2)
  194.                    + (unsigned int)((char*)&pBitmapInfo->ulCompression
  195.                   - (char*)&pBitmapInfo->cbFix));
  196.                memset(pBitmapInfo, 0, iSize);
  197.        }
  198.        printFileLine();
  199.        {       RGB2 *pScan;
  200.                unsigned short iColor;
  201.  
  202.                for (pScan = (RGB2*)&pBitmapInfo->ulCompression,
  203.                    iColor = 0;
  204.                    iColor < 256;
  205.                    pScan++, iColor++)
  206.                {       pScan->fcOptions = PC_EXPLICIT;
  207.                        (unsigned short)pScan->bBlue = iColor;
  208.                }
  209.        }
  210.        printFileLine();
  211.        pBitmapInfo->cbFix = (unsigned int)((char*)&pBitmapInfo->ulCompression
  212.            - (char*)&pBitmapInfo->cbFix);
  213.        assert(pBitmapInfo->cbFix > 0);
  214.        pBitmapInfo->cx = pMsgThread->iSizeX;
  215.        pBitmapInfo->cy = 1;
  216.        pBitmapInfo->cPlanes = 1;
  217.        pBitmapInfo->cBitCount = sizeof(*pData)*8;
  218.        /*
  219.        pBitmapInfo->ulCompression = BCA_UNCOMP;
  220.        pBitmapInfo->cbImage = 0;
  221.        pBitmapInfo->cxResolution = 0;
  222.        pBitmapInfo->cyResolution = 0;
  223.        pBitmapInfo->cclrUsed = 0;
  224.        pBitmapInfo->cclrImportant = 0;
  225.        pBitmapInfo->usUnits = 0;
  226.        pBitmapInfo->usReserved = 0;
  227.        pBitmapInfo->usRecording = BRA_BOTTOMUP;
  228.        pBitmapInfo->usRendering = BRH_NOTHALFTONED;
  229.        pBitmapInfo->ulColorEncoding = BCE_RGB;
  230.        */
  231.        printFileLine();
  232.        for (yi = 0, x = xl, y = yl;
  233.            yi < pMsgThread->iSizeY;
  234.            x = (xl += pMsgThread->xdy), y = (yl += pMsgThread->ydy),
  235.            GpiSetBitmapBits((void*)pMsgThread->hpsBitmap, (LONG)yi, (LONG)1,
  236.                (unsigned char*)pData, pBitmapInfo),
  237.            GpiQueryBitmapBits((void*)pMsgThread->hpsBitmap, (LONG)yi, (LONG)1,
  238.                (unsigned char*)pDataCompare, pBitmapInfo),
  239. #ifdef undefined
  240.            memcmp(pData, pDataCompare, iBitmapSize)
  241.            ? fprintf(stderr, "Daten stimmen nicht!\n") : (void)1,
  242. #endif undefined
  243.            (   {       RECTL rcl;
  244.  
  245.                        rcl.xLeft = 0;
  246.                        rcl.yTop = yi + 1;
  247.                        rcl.yBottom = yi;
  248.                        rcl.xRight = pMsgThread->iSizeX;
  249.                         if (pMsgThread->pFullScreen)
  250.                                 WinInvalidateRect(pMsgThread->pFullScreen->hwndClient,
  251.                                     &rcl, FALSE);
  252.                         WinInvalidateRect(pMsgThread->pWindow->hwndClient,
  253.                             &rcl, FALSE);
  254.                }
  255.            ),
  256.            yi++)
  257.                for (xi = 0,
  258.                    memset(pData, 0, iBitmapSize);
  259.                    xi < pMsgThread->iSizeX;
  260.                    xi++,
  261.                    y += pMsgThread->ydx, x += pMsgThread->xdx
  262.                    )
  263.                {       double y2 = y*y;
  264.                        double x_1_2 = x + 1.0;
  265.  
  266.                        x_1_2 *= x_1_2;
  267.                        if (y2 + x_1_2 > 1.0/16.0)
  268.                        {       double r = x*x + y2;
  269.                                double s = r - x*0.5 + 1.0/16.0;
  270.                                if ((r*16 - 5.0)*s + 4*x > 1)
  271.                                {       double xit = x, yit = y;
  272.  
  273.                                        for (it = 0;
  274.                                            it < pMsgThread->iMaxIterations;
  275.                                            it++)
  276.                                        {       double x2 = xit*xit;
  277.                                                double y2 = yit*yit;
  278.                                                double r = y2 + x2;
  279.                                                if (r > pMsgThread->Grenze)
  280.                                                {       //POINTL ptl;
  281.  
  282.                                                        pData[xi] = it % iMaxColors_1 + 1;
  283.                                                        //ptl.x = xi;
  284.                                                        //ptl.y = yi;
  285.                                                        //GpiSetColor(pMsgThread->hpsBitmap, pData[xi]);
  286.                                                        //GpiSetPel(pMsgThread->hpsBitmap, &ptl);
  287.                                                        break;
  288.                                                }
  289.                                                r = 2*xit*yit + y;
  290.                                                xit = x2 - y2 + x;
  291.                                                yit = r;
  292.                                        }
  293.                                }
  294.                        }
  295.                }
  296. }
  297. #ifdef undefined
  298. void calcThread::runThread(void)
  299. {      unsigned int xi, yi, it, iMaxColors_1;
  300.        menuWindowTree *pWindowTree = (menuWindowTree*)(((pmMsgThreadTree*)pParent)->pWindowTree);
  301.        double xl = pWindowTree->xa, yl = pWindowTree->ya, x, y;
  302.     static const volatile double B1D16 = 0.0625,
  303.         B1D2  = 0.5,
  304.         B16   = 16.0,
  305.         B5    = 5.0,
  306.         B4    = 4.0;
  307.        BITMAPINFO2 structBitmapInfo;
  308.        unsigned int *pData;
  309.  
  310. #ifdef SHOWCALLS
  311.        fprintf(stderr, "Calling calcThread::runThread()\n");
  312. #endif
  313.        pmThreadTree::runThread();
  314.        printFileLine();
  315.        iMaxColors_1 = pWindowTree->iMaxColors - 1;
  316.        memset(&structBitmapInfo, 0, sizeof structBitmapInfo);
  317.        structBitmapInfo.cbFix = sizeof structBitmapInfo;
  318.        structBitmapInfo.cx = pWindowTree->iSizeX;
  319.        structBitmapInfo.cy = 1;
  320.        structBitmapInfo.cPlanes = 32;
  321.        structBitmapInfo.cBitCount = 1;
  322.        structBitmapInfo.ulCompression = 0;
  323.        pData = alloca(structBitmapInfo.cbImage
  324.            = pWindowTree->iSizeX * sizeof(unsigned int));
  325.        for (yi = 0, x = xl, y = yl, 
  326.            (   {       asm("FldL %0" : : "m" (pWindowTree->Grenze));
  327.                        asm("FldL %0" : : "m" (x));
  328.                        asm("FldL %0" : : "m" (y));
  329.                }
  330.            );
  331.            yi < pWindowTree->iSizeY;
  332.            yi++, x = (xl += pWindowTree->xdy), y = (yl += pWindowTree->ydy),
  333.            GpiSetBitmapBits((void*)pWindowTree->hpsBitmap, (LONG)yi, (LONG)1,
  334.                (unsigned char*)pData, &structBitmapInfo),
  335.            (   {       RECTL rcl;
  336.                        rcl.xLeft = 0;
  337.                        rcl.yTop = rcl.yBottom = yi;
  338.                        rcl.xRight = pWindowTree->iSizeX - 1;
  339.                        WinInvalidateRect(pWindowTree->hwndClient, &rcl, FALSE);
  340.                }
  341.            ))
  342.                for (xi = 0,
  343.                    (   {       asm("FLdL %0" : : "m" (x));
  344.                                asm("FStPL %St(2)");
  345.                                asm("FLdL %0" : : "m" (y));
  346.                                asm("FStPL %St(1)");
  347.                        }),
  348.                    memset(pData, 0, structBitmapInfo.cbImage);
  349.                    xi < pWindowTree->iSizeX;
  350.                    xi++,
  351.                    (   {       asm("FAddL %0" : : "m" (pWindowTree->ydx));
  352.                                asm("FLdL %0" : : "m" (pWindowTree->xdx));
  353.                                asm("FAddPL %St(2)");
  354.                        }
  355.                    )
  356.                    )
  357.                {
  358.        printFileLine();
  359.        showFloatRegs(3, __LINE__);
  360.     asm("FLdL %St(1)");          /* -- -- -- -- G  xa ya x */
  361.     showFloatRegs(4, __LINE__);
  362.        asm("FLdL %St(1)");          /* -- -- -- G  xa ya x  y */
  363.     showFloatRegs(5, __LINE__);
  364.        asm("FLdL %St(0)");          /* -- -- G  xa ya x  y  y */
  365.     showFloatRegs(6, __LINE__);
  366.        asm("FMul %St, %St(0)");     /* -- -- G  xa ya x  y  y*y */
  367.     showFloatRegs(6, __LINE__);
  368.        asm("FLd %St(2)");          /* -- G  xa ya x  y  y*y x */
  369.     showFloatRegs(7, __LINE__);
  370.        asm("FLD1");               /* G  xa ya x  y  y*y x  1 */
  371.     showFloatRegs(8, __LINE__);
  372.        asm("FAddP %St(1), %St");    /* -- G  xa ya x  y  y*y x+1 */
  373.     showFloatRegs(7, __LINE__);
  374.        asm("FMul %St, %St(0)");     /* -- G  xa ya x  y y*y (x+1)*(x+1) */
  375.     showFloatRegs(7, __LINE__);
  376.        asm("FAdd %St, %St(1)");     /* -- G  xa ya x  y y*y (x+1)*(x+1)+y*y */
  377.     showFloatRegs(7, __LINE__);
  378.        asm("FComPL %0" : : "m" (B1D16));        /* -- -- G  xa ya x  y y*y */
  379.     asm("FSTSW %EAX");
  380.     asm("SAHF");
  381.     asm("JA Weiter1");
  382.        showFloatRegs(6, __LINE__);
  383.     asm("FStP %St(0)");            /* -- -- -- G  xa ya x  y */
  384.     showFloatRegs(5, __LINE__);
  385.        asm("Jmp Erhoehe");
  386.     asm("Weiter1:");         /* -- -- G  xa ya x  y y*y */
  387.     showFloatRegs(6, __LINE__);
  388.        asm("FLd %St(2)");        /* -- G  xa ya x  y y*y  x */
  389.     showFloatRegs(7, __LINE__);
  390.        asm("FMul %St, %St(0)");   /* -- G  xa ya x  y y*y  x*x */
  391.     showFloatRegs(7, __LINE__);
  392.        asm("FAddP %St(1), %St");  /* -- -- G  xa ya x  y r */
  393.     showFloatRegs(6, __LINE__);
  394.        asm("FLdL %St(2)");        /* -- G  xa ya x  y r x */
  395.     showFloatRegs(7, __LINE__);
  396.        asm("FMulL %0" : : "m" (B1D2));
  397.     showFloatRegs(7, __LINE__);
  398.        asm("FSubR %St(0), %St(1)");   /* -- G  xa ya x  y r r-x*0.5 */
  399.     showFloatRegs(7, __LINE__);
  400.        asm("FAddL %0" : : "m" (B1D16));         /* -- G  xa ya x  y r r-x*0.5+1/16 */
  401.     showFloatRegs(7, __LINE__);
  402.        asm("FSqrt");              /* -- G  xa ya x  y r s */
  403.     showFloatRegs(7, __LINE__);
  404.        asm("FLdL %0" : : "m" (B16));            /* G  xa ya x  y r s 16 */
  405.     showFloatRegs(8, __LINE__);
  406.        asm("FMulP %St(2), %St");  /* -- G  xa ya x  y r*16 s */
  407.     showFloatRegs(7, __LINE__);
  408.        asm("FLdL %0" : : "m" (B5));             /* G  xa ya x  y r*16 s 5 */
  409.     showFloatRegs(8, __LINE__);
  410.        asm("FSubP %St(2), %St");  /* -- G  xa ya x  y r*16-5 s */
  411.     showFloatRegs(7, __LINE__);
  412.        asm("FMulP %St(1), %St");  /* -- -- G  xa ya x  y (r*16-5)*s */
  413.     showFloatRegs(6, __LINE__);
  414.        asm("FLdL %0" : : "m" (B4));             /* -- G  xa ya x  y (r*16-5)*s 4 */
  415.     showFloatRegs(7, __LINE__);
  416.        asm("FMul %St, %St(3)");   /* -- G  xa ya x  y (r*16-5)*s 4*x */
  417.     showFloatRegs(7, __LINE__);
  418.        asm("FAddP %St(1), %St");  /* -- -- G  xa ya x  y (r*16-5)*s+4*x */
  419.     showFloatRegs(6, __LINE__);
  420.        asm("FLd1");               /* -- G  xa ya x  y (r*16-5)*s+4*x 1 */
  421.     showFloatRegs(7, __LINE__);
  422.        asm("FComP %St(1)");  /* -- -- G  xa ya x  y (r*16-5)*s+4*x */
  423.     asm("FSTSW %EAX");
  424.     asm("FStP %St(0)");
  425.     asm("SAHF");
  426.     asm("JA Erhoehe");
  427.        printFileLine();
  428.        showFloatRegs(5, __LINE__);
  429.                        for (it = 0; it < pWindowTree->iMaxIterations; it++)
  430.                        {       
  431.     asm("FLd %St(1)");          /* -- -- G  xa ya x  y  x */
  432.     asm("FMul %St, %St(0)");     /* -- -- G  xa ya x  y  x*x */
  433.     asm("FLd %St(1)");          /* -- G  xa ya x y x*x y */
  434.     asm("FMul %St, %St(0)");     /* -- G  xa ya x y x*x y*y */
  435.     asm("FLd %St(1)");          /* G  xa ya x y x*x y*y x*x */
  436.     asm("FAdd %St, %St(1)");     /* G xa ya x y x*x y*y x*x+y*y */
  437.     asm("FComP %St(7)");        /* -- G xa ya x y x*x y*y */
  438.     asm("FSTSW %EAX");
  439.     asm("SAHF");
  440.     asm("JA Erreicht");
  441.     asm("FSubP %St(1), %St");    /* -- -- G  xa ya x y x*x-y*y */
  442.     asm("FAdd %St, %St(4)");     /* -- -- G  xa ya x y x*x-y*y+xa */
  443.     asm("FLdL %St(2)");         /* -- G  xa ya x y x*x-y*y+xa x */
  444.     asm("FMul %St, %St(2)");     /* -- G  xa ya x y x*x-y*y+xa x*y */
  445.     asm("FAdd %St, %St(0)");     /* -- G  xa ya x y x*x-y*y+xa 2*x*y */
  446.     asm("FAdd %St, %St(4)");     /* -- G  xa ya x y x*x-y*y+xa 2*x*y+ya */
  447.     asm("FStP %St(2)");         /* -- -- G  xa ya x 2*x*y+ya x*x-y*y+xa */
  448.     asm("FStP %St(2)");         /* -- -- G  xa ya x*x-y*y+xa 2*x*y+ya */
  449.                        }
  450.        printFileLine();
  451.        showFloatRegs(5, __LINE__);
  452.     showFloatRegs(5, __LINE__);
  453.     asm("Jmp Erhoehe");
  454.        asm("Erreicht:");
  455. #ifdef DEBUG
  456.        fprintf(stderr, "xi= %u, yi = %u, it = %u\n", xi, yi, it);
  457. #endif
  458.        pData[xi] = it % iMaxColors_1 + 1;
  459.     asm("FStP %St");
  460.        asm("FStP %St");
  461.     asm("Erhoehe:");
  462.        asm("FStP %St");
  463.        asm("FStP %St");
  464.        }
  465.        asm("FStP %St");
  466.        asm("FStP %St");
  467.        asm("FStP %St");
  468. }
  469. #endif undefined
  470.  
  471.  
  472. MRESULT menuWindowTree::windowProc(ULONG msg, MPARAM mp1, MPARAM mp2)
  473. {
  474. #ifdef SHOWCALLS
  475.        fprintf(stderr, "Calling menuWindowTree::windowProc(%x)\n", this);
  476. #endif SHOWCALLS
  477.       switch (msg)
  478.        {       default:
  479.                        return windowPaint::windowProc(msg, mp1, mp2);
  480.                case WM_COMMAND:
  481.                        switch ((USHORT)mp1)
  482.                        {       case IDM_Calculate:
  483.                                        if (!((menuPmThreadTree*)pMsgThread)
  484.                                            ->pCalcThread)
  485.                                                (void)new calcThread(
  486.                                                    (menuPmThreadTree*)pMsgThread);
  487.                                        break;
  488.                                case IDM_BreakCalculation:
  489.                                        if (((menuPmThreadTree*)pMsgThread)
  490.                                            ->pCalcThread)
  491.                                                delete ((menuPmThreadTree*)pMsgThread)
  492.                                                    ->pCalcThread;
  493.                                        break;
  494.                                case IDM_FullScreen:
  495.                                         printFileLine();
  496.                                        if (!((menuPmThreadTree*)pMsgThread)
  497.                                            ->pFullScreen)
  498.                                        {       (void)new fullScreen(this);
  499.                                                 printFileLine();
  500.                                                if (!((menuPmThreadTree*)pMsgThread)
  501.                                                   ->pFullScreen->init())
  502.                                                        delete ((menuPmThreadTree*)
  503.                                                             pMsgThread)->pFullScreen;
  504.                                                 printFileLine();
  505.                                        }
  506.                                        break;
  507.                                case IDM_CloseFullScreen:
  508.                                        if (((menuPmThreadTree*)pMsgThread)
  509.                                            ->pFullScreen)
  510.                                                 WinDestroyWindow(
  511.                                                     ((menuPmThreadTree*)pMsgThread)
  512.                                                      ->pFullScreen->hwndFrame);
  513.                                        break;
  514.                        }
  515.                        return windowPaint::windowProc(msg, mp1, mp2);
  516.        }
  517. }
  518.  
  519.  
  520. Boolean menuWindowTree::initPost(void)
  521. {       
  522. #ifdef SHOWCALLS
  523.         fprintf(stderr, "Calling menuWindowTree::initPost(%x)\n", this);
  524. #endif
  525.         return windowPaint::initPost();
  526. }
  527.  
  528.  
  529. #ifdef undefined
  530. Boolean menuWindowTree::initPre(void)
  531. {
  532. #ifdef SHOWCALLS
  533.         fprintf(stderr, "Calling menuWindowTree::initPre(%x)\n", this);
  534. #endif
  535.         return windowPaint::initPre();
  536. }
  537. #endif
  538.  
  539.  
  540. windowPaint::windowPaint(pmMsgThreadTree *pMsgThreadNew, int idResource, char *pTitle)
  541.     :processWindow(pMsgThreadNew, idResource, pTitle)
  542. {
  543. #ifdef SHOWCALLS
  544.        fprintf(stderr, "Calling windowPaint::windowPaint(%x)\n", this);
  545. #endif SHOWCALLS
  546. }
  547.  
  548.  
  549. windowPaint::windowPaint(windowTree *pParent, int idResource, char *pTitle)
  550.     :processWindow(pParent, idResource, pTitle)
  551. {
  552. #ifdef SHOWCALLS
  553.        fprintf(stderr, "Calling windowPaint::windowPaint(%x)\n", this);
  554. #endif SHOWCALLS
  555. }
  556.  
  557.  
  558. void windowPaint::doPaint(HPS hps, RECTL *pStructRectl)
  559. {      POINTL aPoint[4];
  560.  
  561. #ifdef SHOWCALLS
  562.        fprintf(stderr, "Calling windowPaint::WMPaint(%x)\n", this);
  563. #endif SHOWCALLS
  564.        aPoint[0].x = pStructRectl->xLeft;
  565.        aPoint[0].y = pStructRectl->yBottom;
  566.        aPoint[1].x = pStructRectl->xRight;
  567.        aPoint[1].y = pStructRectl->yTop;
  568.        aPoint[2].x = pStructRectl->xLeft;
  569.        aPoint[2].y = pStructRectl->yBottom;
  570.        aPoint[3].x = pStructRectl->xRight;
  571.        aPoint[3].y = pStructRectl->yTop;
  572.        GpiBitBlt(hps, ((menuPmThreadTree*)pMsgThread)->hpsBitmap, 4, aPoint, 
  573.            ROP_SRCCOPY, BBO_OR);
  574. #ifdef SHOWCALLS
  575.        fprintf(stderr, "Calling menuWindowTree::WMPaint()\n");
  576.        fprintf(stderr, "invalidated rectangle : \n");
  577.        fprintf(stderr, "xLeft = %ld  yBottom = %ld \n", 
  578.                pStructRectl->xLeft, pStructRectl->yBottom);
  579.        fprintf(stderr, "xRight = %ld  yTop = %ld \n",
  580.                pStructRectl->xRight, pStructRectl->yTop);
  581. #endif SHOWCALLS
  582. }
  583.  
  584.  
  585. Boolean windowPaint::initPre(void)
  586. {       
  587. #ifdef SHOWCALLS
  588.         fprintf(stderr, "Calling windowPaint::initPre(%x)\n", this);
  589. #endif
  590.         return processWindow::initPre();
  591. }
  592.  
  593.  
  594. Boolean windowPaint::initPost(void)
  595. {
  596. #ifdef SHOWCALLS
  597.         fprintf(stderr, "Calling windowPaint::initPost(%x)\n", this);
  598. #endif
  599.        return processWindow::initPost();
  600. }
  601.  
  602.  
  603. Boolean menuWindowTree::initPre(void)
  604. {      
  605. #ifdef SHOWCALLS
  606.         fprintf(stderr, "Calling menuWindowTree:initPre(%x)\n", this);
  607. #endif SHOWCALLS
  608.         if (!windowPaint::initPre())
  609.                 return FALSE;
  610.         frameFlags |= FCF_MENU;
  611.         pWindowClassName = "menuWindowTree";
  612.         return TRUE;
  613. }
  614.  
  615.  
  616. menuWindowTree::menuWindowTree(pmMsgThreadTree *pMsgThreadNew, int idResource, 
  617.     char *pTitle):windowPaint(pMsgThreadNew, idResource, pTitle)
  618. {
  619. #ifdef SHOWCALLS
  620.        fprintf(stderr, "Calling menuWindowTree::menuWindowTree(%x)\n", this);
  621. #endif SHOWCALLS
  622.       ((menuPmThreadTree*)pMsgThreadNew)->pWindow = this;
  623. }
  624.  
  625.  
  626. menuWindowTree::~menuWindowTree(void)
  627. {
  628. #ifdef SHOWCALLS
  629.        fprintf(stderr, "Calling ~menuWindowTree(%x)\n", this);
  630. #endif SHOWCALLS
  631.  
  632. }
  633.  
  634.  
  635. #ifdef undefined
  636. Boolean dummyWindow::initPre(void)
  637. {       return fullScreen::initPre();
  638. }
  639.  
  640.  
  641. Boolean dummyWindow::initPost(void)
  642. {       return fullScreen::initPost();
  643. }
  644. #endif
  645.  
  646.  
  647. #ifdef DEBUG
  648. void menuPmThreadTree::run(void)
  649. {
  650. #ifdef SHOWCALLS
  651.        fprintf(stderr, "Calling menuPmThreadTree::run(%x)\n", this);
  652. #endif SHOWCALLS
  653. #ifdef DEBUG
  654.        fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
  655.            menuPmThreadTree::doSomething);
  656. #endif
  657.        pmMsgThreadTree::run();
  658. }
  659.  
  660.  
  661. void menuPmThreadTree::doSomething(void)
  662. {
  663. #ifdef SHOWCALLS
  664.        fprintf(stderr, "Calling menuPmThreadTree::doSomething(%x)\n", this);
  665. #endif SHOWCALLS
  666. #ifdef DEBUG
  667.        fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
  668.            menuPmThreadTree::doSomething);
  669. #endif
  670.        pmMsgThreadTree::doSomething();
  671. }
  672.  
  673.  
  674. Boolean menuPmThreadTree::init(void)
  675. {
  676. #ifdef SHOWCALLS
  677.        fprintf(stderr, "Calling menuPmThreadTree::init(%x)\n", this);
  678. #endif SHOWCALLS
  679. #ifdef DEBUG
  680.        fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
  681.            menuPmThreadTree::doSomething);
  682. #endif
  683.        return pmMsgThreadTree::init();
  684. }
  685.  
  686.  
  687. Boolean menuPmThreadTree::initPre(void)
  688. {
  689. #ifdef SHOWCALLS
  690.        fprintf(stderr, "Calling menuPmThreadTree::initPre(%x)\n", this);
  691. #endif SHOWCALLS
  692. #ifdef DEBUG
  693.        fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
  694.            menuPmThreadTree::doSomething);
  695. #endif
  696.        return pmMsgThreadTree::initPre();
  697. }
  698. #endif DEBUG
  699.  
  700.  
  701. Boolean menuPmThreadTree::create(void)
  702. {      
  703. #ifdef SHOWCALLS
  704.        fprintf(stderr, "Calling menuPmThreadTree::create(%x)\n", this);
  705. #endif SHOWCALLS
  706. #ifdef DEBUG
  707.        fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
  708.            menuPmThreadTree::doSomething);
  709. #endif
  710.        if (!(pWindowTree
  711.            = new menuWindowTree((pmMsgThreadTree*)this, ID_Resource,
  712.            "Apfel")))
  713.                return FALSE;
  714. #ifdef SHOWCALLS
  715.        fprintf(stderr, "Leaving menuPmThreadTree::create()\n");
  716. #endif SHOWCALLS
  717. #ifdef DEBUG
  718.        fprintf(stderr, "doSomething() = %x\n", &this->doSomething);
  719. #endif
  720.        return TRUE;
  721. }
  722.  
  723.  
  724. Boolean menuPmThreadTree::initPost(void)
  725. {
  726. #ifdef SHOWCALLS
  727.        fprintf(stderr, "Calling menuPmThreadTree::initPost(%x)\n", this);
  728. #endif SHOWCALLS
  729. #ifdef DEBUG
  730.        fprintf(stderr, "doSomething() = %x\n", &this->doSomething);
  731. #endif
  732.        pmMsgThreadTree::initPost();
  733.        hdcBitmap = DevOpenDC(hab, OD_MEMORY, (unsigned char*)"*", 0, 0, 0);
  734.        {       SIZEL size;
  735.  
  736.                size.cx = size.cy = 0;
  737.                hpsBitmap = GpiCreatePS(hab, hdcBitmap, &size,
  738.                    PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);
  739.        }
  740.        iSizeX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  741.        iSizeY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  742.        {       long alBmpFormats[2];
  743.                BITMAPINFOHEADER2 structBmpInfoHeader;
  744.  
  745.                GpiQueryDeviceBitmapFormats(hpsBitmap, 2, alBmpFormats);
  746.                memset(&structBmpInfoHeader, 0, sizeof(structBmpInfoHeader));
  747.                structBmpInfoHeader.cbFix = sizeof(structBmpInfoHeader);
  748.                structBmpInfoHeader.cx = iSizeX;
  749.                structBmpInfoHeader.cy = iSizeY;
  750.                structBmpInfoHeader.cPlanes = (USHORT)alBmpFormats[0];
  751.                structBmpInfoHeader.cBitCount = (USHORT)alBmpFormats[1];
  752.                hbm = GpiCreateBitmap(hpsBitmap, &structBmpInfoHeader, 0, (BYTE*)0,
  753.                    (BITMAPINFO2*)0);
  754.        }
  755.        GpiSetBitmap(hpsBitmap, hbm);
  756.        {       POINTL aPoint[4];
  757.  
  758.                aPoint[0].x = 0;
  759.                aPoint[0].y = iSizeY;
  760.                aPoint[1].x = iSizeX;
  761.                aPoint[1].y = 0;
  762.                aPoint[2].x = 0;
  763.                aPoint[2].y = iSizeY;
  764.                aPoint[3].x = iSizeX;
  765.                aPoint[3].y = 0;
  766.                GpiBitBlt(hpsBitmap, hpsBitmap, 4, aPoint, ROP_ZERO, BBO_OR);
  767.        }
  768.        xa = -2.0;
  769.        xdx = 3.0 / iSizeX;
  770.        xdy = 0.0;
  771.        ya = xdx*iSizeY*0.5;
  772.        ydy = -xdx;
  773.        ydx = 0.0;
  774.        iMaxIterations = 255;
  775.        Grenze = 100.0;
  776.        {       HDC hdc;
  777.  
  778.                hdc = WinOpenWindowDC(HWND_DESKTOP);
  779.                DevQueryCaps((HDC)hdc, (LONG)CAPS_COLORS, (LONG)1, (LONG*)&iMaxColors);
  780.        }
  781. #ifdef SHOWCALLS
  782.        fprintf(stderr, "Leaving menuPmThreadTree::initPost(%x)\n", this);
  783. #endif SHOWCALLS
  784. #ifdef DEBUG
  785.        fprintf(stderr, "doSomething() = %x\n", &this->doSomething);
  786. #endif
  787.        return TRUE;
  788. }
  789.  
  790.  
  791. Boolean menuPmProcess::create(void)
  792. {
  793. #ifdef SHOWCALLS
  794.        fprintf(stderr, "Calling menuPmProcess::create(%x)\n", this);
  795. #endif SHOWCALLS
  796.        if (!(pThreadTree = new menuPmThreadTree(this)))
  797.                return FALSE;
  798.        return TRUE;
  799. }
  800.