Annotation of pmsdk/samples/vectfont/vectfont.c, revision 1.1

1.1     ! root        1: /*----------------------------------------
        !             2:    VECTFONT.C -- Vector Font Demo Program
        !             3:   ----------------------------------------*/
        !             4: 
        !             5: #define INCL_WIN
        !             6: #define INCL_GPI
        !             7: #include <os2.h>
        !             8: #include "vectfont.h"
        !             9: 
        !            10: MRESULT CALLBACK ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
        !            11: 
        !            12: HAB hab ;
        !            13: 
        !            14: int main (void)
        !            15:      {
        !            16:      static CHAR  szClientClass [] = "VectFont" ;
        !            17:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU  |
        !            18:                                  FCF_SIZEBORDER    | FCF_MINMAX   |
        !            19:                                  FCF_SHELLPOSITION | FCF_TASKLIST |
        !            20:                                  FCF_MENU ;
        !            21:      HMQ          hmq ;
        !            22:      HWND         hwndFrame, hwndClient ;
        !            23:      QMSG         qmsg ;
        !            24: 
        !            25:      hab = WinInitialize (0) ;
        !            26:      hmq = WinCreateMsgQueue (hab, 0) ;
        !            27: 
        !            28:      WinRegisterClass (hab, szClientClass, ClientWndProc,
        !            29:                             CS_SIZEREDRAW, 0) ;
        !            30: 
        !            31:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
        !            32:                                      &flFrameFlags, szClientClass,
        !            33:                                      " - Vector Font Demo", 0L,
        !            34:                                      NULL, ID_RESOURCE, &hwndClient) ;
        !            35: 
        !            36:      WinSendMsg (hwndFrame, WM_SETICON,
        !            37:                  WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
        !            38:                  NULL) ;
        !            39: 
        !            40:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            41:           WinDispatchMsg (hab, &qmsg) ;
        !            42: 
        !            43:      WinDestroyWindow (hwndFrame) ;
        !            44:      WinDestroyMsgQueue (hmq) ;
        !            45:      WinTerminate (hab) ;
        !            46:      return 0 ;
        !            47:      }
        !            48: 
        !            49: MRESULT CALLBACK ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1,
        !            50:                                                        MPARAM mp2)
        !            51:      {
        !            52:      static struct {
        !            53:                    SHORT idCmd ;
        !            54:                    VOID (*fn) (HPS, LONG, LONG) ;
        !            55:                    }
        !            56:                    vectfont [] = {
        !            57:                                  IDM_NOTHING,     NULL,
        !            58:                                  IDM_24POINT,     Display_24Point,
        !            59:                                  IDM_MIRROR,      Display_Mirror,
        !            60:                                  IDM_STRETCH,     Display_Stretch,
        !            61:                                  IDM_CHARANGLE,   Display_CharAngle,
        !            62:                                  IDM_ROTATE,      Display_Rotate,
        !            63:                                  IDM_CHARSHEAR,   Display_CharShear,
        !            64:                                  IDM_SHADOW,      Display_Shadow,
        !            65:                                  IDM_HOLLOW,      Display_Hollow,
        !            66:                                  IDM_DROPSHADOW,  Display_DropShadow,
        !            67:                                  IDM_BLOCK,       Display_Block,
        !            68:                                  IDM_NEON,        Display_Neon,
        !            69:                                  IDM_FADE,        Display_Fade,
        !            70:                                  IDM_SPOKES,      Display_Spokes,
        !            71:                                  IDM_WAVY,        Display_Wavy,
        !            72:                                  IDM_MODSPOKES,   Display_ModSpokes
        !            73:                                  } ;
        !            74:      static HDC    hdc ;
        !            75:      static HPS    hps ;
        !            76:      static HWND   hwndMenu ;
        !            77:      static POINTL ptlClient ;
        !            78:      static SHORT  sNumRoutines = sizeof vectfont / sizeof vectfont[0],
        !            79:                    sDisplay = IDM_NOTHING ;
        !            80:      INT           i ;
        !            81:      RECTL         rcl ;
        !            82:      SIZEL         sizl ;
        !            83: 
        !            84:      switch (msg)
        !            85:           {
        !            86:           case WM_CREATE:
        !            87:                hdc = WinOpenWindowDC (hwnd) ;
        !            88: 
        !            89:                                    // Create PS use Twips page units
        !            90:                sizl.cx = 0 ;
        !            91:                sizl.cy = 0 ;
        !            92:                hps = GpiCreatePS (hab, hdc, &sizl,
        !            93:                                        PU_TWIPS     | GPIF_DEFAULT |
        !            94:                                        GPIT_MICRO   | GPIA_ASSOC) ;
        !            95: 
        !            96:                                    // Adjust Page Viewport for points
        !            97: 
        !            98:                GpiQueryPageViewport (hps, &rcl) ;
        !            99:                rcl.xRight *= 20 ;
        !           100:                rcl.yTop   *= 20 ;
        !           101:                GpiSetPageViewport (hps, &rcl) ;
        !           102: 
        !           103:                hwndMenu = WinWindowFromID (
        !           104:                                WinQueryWindow (hwnd, QW_PARENT, FALSE),
        !           105:                                FID_MENU) ;
        !           106:                return 0 ;
        !           107: 
        !           108:           case WM_SIZE:
        !           109:                ptlClient.x = SHORT1FROMMP (mp2) ;      // client width
        !           110:                ptlClient.y = SHORT2FROMMP (mp2) ;      // client height
        !           111: 
        !           112:                GpiConvert (hps, CVTC_DEVICE, CVTC_PAGE, 1L, &ptlClient);
        !           113:                return 0 ;
        !           114: 
        !           115:           case WM_COMMAND:
        !           116:                for (i = 0 ; i < sNumRoutines ; i++)
        !           117:                     if (COMMANDMSG(&msg)->cmd == vectfont[i].idCmd)
        !           118:                          {
        !           119:                          if (sDisplay == COMMANDMSG(&msg)->cmd)
        !           120:                               return 0 ;
        !           121: 
        !           122:                          WinSendMsg (hwndMenu, MM_SETITEMATTR,
        !           123:                                      MPFROM2SHORT (sDisplay, TRUE),
        !           124:                                      MPFROM2SHORT (MIA_CHECKED, 0)) ;
        !           125: 
        !           126:                          sDisplay = COMMANDMSG(&msg)->cmd ;
        !           127: 
        !           128:                          WinSendMsg (hwndMenu, MM_SETITEMATTR,
        !           129:                                      MPFROM2SHORT (sDisplay, TRUE),
        !           130:                                      MPFROM2SHORT (MIA_CHECKED,
        !           131:                                                    MIA_CHECKED)) ;
        !           132: 
        !           133:                          WinInvalidateRect (hwnd, NULL, FALSE) ;
        !           134:                          return 0 ;
        !           135:                          }
        !           136:                break ;
        !           137: 
        !           138:           case WM_PAINT:
        !           139:                WinBeginPaint (hwnd, hps, NULL) ;
        !           140:                GpiErase (hps) ;
        !           141:                                    // Display hourglass pointer
        !           142: 
        !           143:                WinSetPointer (HWND_DESKTOP,
        !           144:                     WinQuerySysPointer (HWND_DESKTOP,SPTR_WAIT,FALSE));
        !           145: 
        !           146:                if (!WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT))
        !           147:                     WinShowPointer (HWND_DESKTOP, TRUE) ;
        !           148: 
        !           149:                                    // Execute font routine
        !           150: 
        !           151:                for (i = 0 ; i < sNumRoutines ; i++)
        !           152:                     if (sDisplay == vectfont[i].idCmd)
        !           153:                          {
        !           154:                          if (vectfont[i].fn != NULL)
        !           155:                               {
        !           156:                               GpiSavePS (hps) ;
        !           157:                               vectfont[i].fn (hps, ptlClient.x,
        !           158:                                                    ptlClient.y) ;
        !           159:                               GpiRestorePS (hps, -1L) ;
        !           160:                               }
        !           161:                          break ;
        !           162:                          }
        !           163:                                         // Display arrow pointer
        !           164: 
        !           165:                if (!WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT))
        !           166:                     WinShowPointer (HWND_DESKTOP, FALSE) ;
        !           167: 
        !           168:                WinSetPointer (HWND_DESKTOP,
        !           169:                     WinQuerySysPointer (HWND_DESKTOP,SPTR_ARROW,FALSE));
        !           170: 
        !           171:                WinEndPaint (hps) ;
        !           172:                return 0 ;
        !           173: 
        !           174:           case WM_DESTROY:
        !           175:                GpiDestroyPS (hps) ;
        !           176:                return 0 ;
        !           177:           }
        !           178:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !           179:      }

unix.superglobalmegacorp.com

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