Annotation of pmsdk/samples/petzold/chap05/starfill.c, revision 1.1.1.1

1.1       root        1: /*-------------------------------------------
                      2:    STARFILL.C -- Alternate and Winding Modes
                      3:  --------------------------------------------*/
                      4: 
                      5: #define INCL_GPI
                      6: #include <os2.h>
                      7: 
                      8: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
                      9: 
                     10: int main (void)
                     11:      {
                     12:      static CHAR  szClientClass [] = "StarFill" ;
                     13:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
                     14:                                  FCF_SIZEBORDER    | FCF_MINMAX  |
                     15:                                  FCF_SHELLPOSITION | FCF_TASKLIST ;
                     16:      HAB          hab ;
                     17:      HMQ          hmq ;
                     18:      HWND         hwndFrame, hwndClient ;
                     19:      QMSG         qmsg ;
                     20: 
                     21:      hab = WinInitialize (0) ;
                     22:      hmq = WinCreateMsgQueue (hab, 0) ;
                     23: 
                     24:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
                     25: 
                     26:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
                     27:                                      &flFrameFlags, szClientClass,
                     28:                                      " - Alternate and Winding",
                     29:                                      0L, NULL, 0, &hwndClient) ;
                     30: 
                     31:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     32:           WinDispatchMsg (hab, &qmsg) ;
                     33: 
                     34:      WinDestroyWindow (hwndFrame) ;
                     35:      WinDestroyMsgQueue (hmq) ;
                     36:      WinTerminate (hab) ;
                     37:      return 0 ;
                     38:      }
                     39: 
                     40: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     41:      {
                     42:      static POINTL aptlStar[5] = {-59,-81, 0,100, 59,-81, -95,31, 95,31 } ;
                     43:      static SHORT  cxClient, cyClient ;
                     44:      HPS           hps ;
                     45:      POINTL        aptl[5] ;
                     46:      SHORT         sIndex ;
                     47: 
                     48:      switch (msg)
                     49:          {
                     50:           case WM_SIZE:
                     51:                cxClient = SHORT1FROMMP (mp2) ;
                     52:                cyClient = SHORT2FROMMP (mp2) ;
                     53:                return 0 ;
                     54: 
                     55:           case WM_PAINT:
                     56:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     57:                GpiErase (hps) ;
                     58:                GpiSetPattern (hps, PATSYM_HALFTONE) ;
                     59: 
                     60:                          /*---------------------
                     61:                             Alternate Fill Mode
                     62:                            ---------------------*/
                     63: 
                     64:                for (sIndex = 0 ; sIndex < 5 ; sIndex++)
                     65:                     {
                     66:                     aptl[sIndex].x = cxClient / 4 + cxClient *
                     67:                                           aptlStar[sIndex].x / 400 ;
                     68:                     aptl[sIndex].y = cyClient / 2 + cyClient *
                     69:                                           aptlStar[sIndex].y / 200 ;
                     70:                     }
                     71: 
                     72:                GpiBeginArea (hps, BA_NOBOUNDARY | BA_ALTERNATE) ;
                     73:                GpiMove (hps, aptl) ;
                     74:                GpiPolyLine (hps, 4L, aptl + 1) ;
                     75:                GpiEndArea (hps) ;
                     76: 
                     77:                          /*-------------------
                     78:                             Winding Fill Mode
                     79:                            -------------------*/
                     80: 
                     81:                for (sIndex = 0 ; sIndex < 5 ; sIndex++)
                     82:                     aptl[sIndex].x += cxClient / 2 ;
                     83: 
                     84:                GpiBeginArea (hps, BA_NOBOUNDARY | BA_WINDING) ;
                     85:                GpiMove (hps, aptl) ;
                     86:                GpiPolyLine (hps, 4L, aptl + 1) ;
                     87:                GpiEndArea (hps) ;
                     88: 
                     89:                WinEndPaint (hps) ;
                     90:                return 0 ;
                     91:           }
                     92:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     93:      }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.