Annotation of pmsdk/samples/line/line.c, revision 1.1.1.1

1.1       root        1: /****************************************************************************
                      2: 
                      3:     PROGRAM: line.c                    Created by Microsoft Corp., 1988
                      4: 
                      5:     PURPOSE: Demonstrate the color, line, arc, and retained
                      6:             drawing capabilities of the MS OS/2 Presentation Manager.
                      7: 
                      8:     FUNCTIONS:
                      9:              GENERICWNDPROC
                     10:              ABOUT
                     11:              ARCPDLGPROC
                     12:              FIL_S_DLGPROC
                     13: 
                     14: 
                     15:     COMMENTS:
                     16:        This code demonstrates some of the features of GPI, the Graphics
                     17:        Programming Interface for MS OS/2. The user interface consists of
                     18:        menus, dialogs, and message boxes.
                     19: 
                     20:        You can use menu selections to:
                     21: 
                     22:            o   Erase the current screen contents
                     23:            o   Open a segment for retained drawing
                     24:            o   Save a segments contents
                     25:            o   Display a series of segments
                     26:            o   Select line widths ranging from 2 to 50 pels
                     27:            o   Select a line color from one of the 16 default colors
                     28:            o   Select a line-end style
                     29:            o   Select a line-join style
                     30:            o   Select a foreground line mix mode
                     31:            o   Plot an x- and y-axis for arc and ellipse drawing
                     32:            o   Draw 3 types of arcs
                     33:            o   Collect points for fillet and spline drawings
                     34:            o   Draw fillets and splines
                     35: 
                     36:        You can draw lines by pressing the left-most mouse button and
                     37:        dragging the mouse.
                     38: 
                     39:        You can collect points for fillets and splines by clicking the
                     40:        leftmost button when the mouse cursor is at the appropriate
                     41:        position in the window's client area.
                     42: 
                     43: 
                     44: 
                     45: 
                     46: ****************************************************************************/
                     47: #include "line.h"
                     48: 
                     49: HAB hab;                                   /* handle to the anchor block  */
                     50: HMQ hmq;                                  /* handle to the message queue */
                     51: HPS hps;                                  /* handle to the presentation space */
                     52: SIZEL page;                               /* ps pagesize */
                     53: HDC hdc;                                  /* device context handle */
                     54: LONG width = 2;                               /* wide-line width */
                     55: POINTL point1, point2;                     /* pel points */
                     56: POINTL cur_pos, prev_pos, point;              /* points used in tracking mouse */
                     57: LONG larray[4];                        /* array of fillet sharpness values */
                     58: POINTL farray[20];                     /* array fillet & spline params */
                     59: LONG m;                                /* full arc multiplier */
                     60: BOOL draw_full_arc, draw_geom_line, collect_points, geom_line_flag = 1;
                     61: LONG seg_num=0;                         /* unique segment identifier */
                     62: LONG i,j, point_count;                               /* loop counter */
                     63: POINTL parray[4] = { 10,10, 50,50, 200,10, 10,10 };
                     64: LONG bflWinStyle;                           /* window style */
                     65: CHAR   str[80];                        /* char string from sprintf */
                     66: LINEBUNDLE pbundle;                       /* attribute bundle pointer */
                     67: SHORT lP, lQ, lR, lS;                  /* temporary arc parameters */
                     68: ARCPARAMS arcparams;                   /* arc parameters */
                     69: POINTL arc_array[2] = {450, 150, 550, 100}; /* params for point arc */
                     70: 
                     71: 
                     72: CHAR szClassName[] = "Line";           /* window class name           */
                     73: HWND hwndClient;                           /* handle to the client        */
                     74: HWND hwndFrame;                            /* handle to the frame window  */
                     75: QMSG qmsg;                                 /* message queue structure     */
                     76: 
                     77: VOID cdecl main() {
                     78:     hab = WinInitialize(NULL);
                     79:     hmq = WinCreateMsgQueue(hab, 0);
                     80:     if (!WinRegisterClass(hab, szClassName, GenericWndProc, CS_SIZEREDRAW, 0))
                     81:         DosExit(EXIT_PROCESS, 1);
                     82:     bflWinStyle = FCF_SYSMENU | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX |
                     83:     FCF_MENU;
                     84:     if (!(hwndFrame = WinCreateStdWindow(HWND_DESKTOP, 0L, &bflWinStyle,
                     85:            szClassName, "Line Graphics", 0L, NULL, ID_RESOURCE, &hwndClient)))
                     86:         DosExit(EXIT_PROCESS, 1);
                     87:     WinSetWindowPos(hwndFrame, NULL, 0, 0, 639, 349,
                     88:        SWP_SIZE | SWP_MOVE | SWP_SHOW);
                     89: 
                     90: /* obtain a handle to a window DC */
                     91:    hdc = WinOpenWindowDC(hwndClient);
                     92: 
                     93: /* create a ps */
                     94:    hps = GpiCreatePS (hab,                     /* handle to anchor block */
                     95:                       hdc,                     /* handle to window DC */
                     96:                       &page,                   /* page size is 0 by 0 */
                     97:                       PU_PELS | GPIA_ASSOC); /* map 1 world coordinate to 1
                     98:                                                 * pel, associate the new ps
                     99:                                                 * with hdc
                    100:                                                 */
                    101: 
                    102:     GpiSetMarker(hps, MARKSYM_SMALLCIRCLE);
                    103: 
                    104:     while (WinGetMsg(hab, &qmsg, NULL, 0, 0))
                    105:        WinDispatchMsg(hab, &qmsg);
                    106: 
                    107: 
                    108:     WinDestroyWindow(hwndFrame);
                    109:     WinDestroyMsgQueue(hmq);
                    110:     WinTerminate(hab);
                    111:     DosExit(EXIT_PROCESS, 0);
                    112: }
                    113: 
                    114: /****************************************************************************
                    115: 
                    116:     FUNCTION: GenericWndProc(HWND, USHORT, MPARAM, MPARAM)
                    117: 
                    118:     PURPOSE:  Processes messages
                    119: 
                    120:     MESSAGES:
                    121: 
                    122:         WM_COMMAND - input received
                    123:         WM_PAINT   - paint the window
                    124: 
                    125: ****************************************************************************/
                    126: 
                    127: MRESULT FAR PASCAL GenericWndProc(hwnd, usMessage, mp1, mp2)
                    128: HWND   hwnd;
                    129: USHORT usMessage;
                    130: MPARAM mp1;
                    131: MPARAM mp2;
                    132: {
                    133:     RECTL rcl;
                    134:     HWND hMenu;                              /* handle to the System menu */
                    135:     POINTL  point1, point2;                 /* point structures */
                    136:     RECTL   rect;                           /* rect structure */
                    137:     CHAR    str[126];                       /* array of characters */
                    138:     HPS     hgpi;                           /* special ps for repainting */
                    139: 
                    140:     switch (usMessage) {
                    141:         case WM_COMMAND:
                    142:            switch (LOUSHORT (mp1)) {
                    143: 
                    144:                /*
                    145:                 * ABOUT menu case statement
                    146:                 */
                    147:                 case IDM_ABOUT:
                    148:                     WinDlgBox(HWND_DESKTOP, hwndFrame, About, NULL, ID_ABOUT,
                    149:                        NULL);
                    150:                    return 0L;
                    151: 
                    152:                /*
                    153:                 * LINE menu case statement
                    154:                 */
                    155:                case IDM_DR_LINE:
                    156:                    geom_line_flag = TRUE;
                    157:                    collect_points = FALSE;
                    158:                    return 0L;
                    159: 
                    160:                /*
                    161:                 * ARC menu case statements
                    162:                 */
                    163:                case IDM_AR_PARM: /* display arc param dialog box */
                    164:                   WinDlgBox(HWND_DESKTOP,
                    165:                             hwndFrame,
                    166:                             (PFNWP)ArcPDlgProc,
                    167:                             NULL,
                    168:                             IDDLG_ARCP,
                    169:                             NULL);
                    170:                    return 0L;
                    171:                case IDM_AR_AXIS: /* draw cartesian coord system */
                    172:                            point1.x = 500; point1.y = 200;
                    173:                            GpiMove(hps, &point1);
                    174:                            DrawAxis(hps, &point1);
                    175:                    return 0L;
                    176:                case IDM_AR_FULL: /* draw a full arc */
                    177:                            point1.x = 500; point1.y = 200;
                    178:                            GpiMove(hps, &point1);
                    179:                            GpiFullArc(hps, DRO_OUTLINE, 50L * 65536L);
                    180:                    return 0L;
                    181:                case IDM_AR_3PNT: /* draw a 3 point arc */
                    182:                            point1.x = 500; point1.y = 200;
                    183:                            GpiMove(hps, &point1);
                    184:                            GpiPointArc(hps, arc_array);
                    185:                    return 0L;
                    186:                case IDM_AR_PRTL: /* draw a partial arc */
                    187:                            point1.x = 500; point1.y = 200;
                    188:                            GpiPartialArc(hps,
                    189:                                       &point1,     /* arc's center */
                    190:                                       50L * 65536L,/* radii multiplier */
                    191:                                       0L,          /* start angle=0 * 65536 */
                    192:                                       5898240L);   /* sweep angle=90 * 65536 */
                    193:                    return 0L;
                    194:                case IDM_AR_CPNT: /* collect points for fillet or spline */
                    195:                    draw_geom_line = FALSE;
                    196:                    geom_line_flag = FALSE;
                    197:                    collect_points = TRUE;
                    198:                    i = 0;
                    199:                    return 0L;
                    200:                case IDM_AR_SPLN: /* draw spline using collected points */
                    201:                            collect_points = FALSE;
                    202:                            if (!(j = --i % 3)){ /* check for mult. of 3 points */
                    203:                                j = i; /* set up j for polyspline call */
                    204:                                for (i = 0; i<=j; i++){  /* shift elements */
                    205:                                    farray[i].x = farray[i+1].x;
                    206:                                    farray[i].y = farray[i+1].y;
                    207:                                    }
                    208:                                farray[i].x = farray[i+1].x; farray[i].y = farray[i+1].y;
                    209:                                GpiQueryCurrentPosition(hps, &cur_pos);
                    210:                                GpiPolySpline(hps, j, farray);
                    211:                                for (i = 0; i<=j; i++){
                    212:                                        farray[i].x = 0;
                    213:                                        farray[i].y = 0;
                    214:                                }
                    215:                                     i = 0;
                    216:                            }
                    217:                            else
                    218:                                {
                    219:                                sprintf(str,"((Number_of_Points - 1) mod 3) != 0");
                    220:                                WinMessageBox(HWND_DESKTOP,
                    221:                                              hwndClient,
                    222:                                              str,
                    223:                                              "Try Again...",
                    224:                                              0,
                    225:                                              MB_OK);
                    226:                                for (i = 0; i<20; i++){
                    227:                                        farray[i].x = 0;
                    228:                                        farray[i].y = 0;
                    229:                                     }
                    230:                                    i = 0;
                    231:                               }
                    232:                    return 0L;
                    233:                case IDM_AR_SFLL: /* draw sharp fillet using collected pts */
                    234:                            collect_points = FALSE;
                    235:                            sprintf(str, "Plot 9 points. (If sharpness > 1, the fillet is a parabola, if sharpness < 0, the fillet is a hyperbola.) Four fillets will be drawn.");
                    236:                            WinMessageBox(HWND_DESKTOP,
                    237:                                          hwndClient,
                    238:                                          str,
                    239:                                          "PolyFilletSharp",
                    240:                                          0,
                    241:                                          MB_OK);
                    242:                            WinDlgBox(HWND_DESKTOP,
                    243:                                      hwndFrame,
                    244:                                      (PFNWP)Fil_S_DlgProc,
                    245:                                      NULL,
                    246:                                      IDDLG_FSDP,
                    247:                                      NULL);
                    248:                                j = i; /* set up j for polyspline call */
                    249:                                for (i = 0; i<=j; i++){  /* shift elements */
                    250:                                    farray[i].x = farray[i+1].x;
                    251:                                    farray[i].y = farray[i+1].y;
                    252:                                    }
                    253:                                GpiPolyFilletSharp(hps,--j, farray, larray);
                    254:                                for (i = 0; i<=j; i++){
                    255:                                        farray[i].x = 0;
                    256:                                        farray[i].y = 0;
                    257:                                }
                    258:                                     i = 0;
                    259:                    return 0L;
                    260:                case IDM_AR_FLLT: /* draw fillet using collected points */
                    261:                            collect_points = FALSE;
                    262:                            sprintf(str, "This selection will draw multiple fillets.");
                    263:                            WinMessageBox(HWND_DESKTOP,
                    264:                                          hwndClient,
                    265:                                          str,
                    266:                                          "PolyFillet",
                    267:                                          0,
                    268:                                          MB_OK);
                    269:                                GpiPolyFillet(hps,i, farray);
                    270:                                for (i = 0; i<20; i++){
                    271:                                        farray[i].x = 0;
                    272:                                        farray[i].y = 0;
                    273:                                }
                    274:                                     i = 0;
                    275:                    return 0L;
                    276: 
                    277:                /*
                    278:                 * QUERY menu case statement
                    279:                 */
                    280:                case IDM_QUERY: /* query the line attributes */
                    281:                    QueryLBundle();
                    282:                    return 0L;
                    283: 
                    284:               /*
                    285:                * WIDTH menu case statments
                    286:                */
                    287:                case IDM_WI_2: /* set the line width to 2 pels */
                    288:                    width = 2;
                    289:                    return 0L;
                    290:                case IDM_WI_5: /* set the line width to 5 pels */
                    291:                    width = 5;
                    292:                    return 0L;
                    293:                case IDM_WI_10: /* set the line width to 10 pels */
                    294:                    width = 10;
                    295:                    return 0L;
                    296:                case IDM_WI_15: /* set the line width to 15 pels */
                    297:                    width = 15;
                    298:                    return 0L;
                    299:                case IDM_WI_20: /* set the line width to 20 pels */
                    300:                    width = 20;
                    301:                    return 0L;
                    302:                case IDM_WI_25: /* set the line width to 25 pels */
                    303:                    width = 25;
                    304:                    return 0L;
                    305:                case IDM_WI_50: /* set the line width to 50 pels */
                    306:                    width = 50;
                    307:                    return 0L;
                    308: 
                    309:                /*
                    310:                 * LINE END menu case statements
                    311:                 */
                    312:                case IDM_LE_DEFAULT: /* set the lineend to default */
                    313:                    GpiSetLineEnd(hps, LINEEND_DEFAULT);
                    314:                    return 0L;
                    315:                case IDM_LE_FLAT: /* set the lineend to flat */
                    316:                    GpiSetLineEnd(hps, LINEEND_FLAT);
                    317:                    return 0L;
                    318:                case IDM_LE_SQUARE: /* set the lineend to square */
                    319:                    GpiSetLineEnd(hps, LINEEND_SQUARE);
                    320:                    return 0L;
                    321:                case IDM_LE_ROUND: /* set the lineend to round */
                    322:                    GpiSetLineEnd(hps, LINEEND_ROUND);
                    323:                    return 0L;
                    324: 
                    325:                /*
                    326:                 * LINE JOIN menu case statments
                    327:                 */
                    328:                case IDM_LI_DEFAULT: /* set the linejoin to default */
                    329:                    GpiSetLineJoin(hps, LINEJOIN_DEFAULT);
                    330:                    return 0L;
                    331:                case IDM_LI_BEVEL:
                    332:                    GpiSetLineJoin(hps, LINEJOIN_BEVEL);
                    333:                    return 0L;
                    334:                case IDM_LI_ROUND:
                    335:                    GpiSetLineJoin(hps, LINEJOIN_ROUND);
                    336:                    return 0L;
                    337:                case IDM_LI_MITRE:
                    338:                    GpiSetLineJoin(hps, LINEJOIN_MITRE);
                    339:                    return 0L;
                    340: 
                    341:                /*
                    342:                 * COLOR menu case statments
                    343:                 */
                    344:                case IDM_CO_BACKGROUND: /* set the color to background */
                    345:                    GpiSetColor(hps, CLR_BACKGROUND);
                    346:                    return 0L;
                    347:                case IDM_CO_BLUE: /* set the color to blue */
                    348:                    GpiSetColor(hps, CLR_BLUE);
                    349:                    return 0L;
                    350:                case IDM_CO_RED: /* set the color to red */
                    351:                    GpiSetColor(hps, CLR_RED);
                    352:                    return 0L;
                    353:                case IDM_CO_PINK: /* set the color to pink */
                    354:                    GpiSetColor(hps, CLR_PINK);
                    355:                    return 0L;
                    356:                case IDM_CO_GREEN: /* set the color to green */
                    357:                    GpiSetColor(hps, CLR_GREEN);
                    358:                    return 0L;
                    359:                case IDM_CO_CYAN: /* set the color to cyan */
                    360:                    GpiSetColor(hps, CLR_CYAN);
                    361:                    return 0L;
                    362:                case IDM_CO_YELLOW: /* set the color to yellow */
                    363:                    GpiSetColor(hps, CLR_YELLOW);
                    364:                    return 0L;
                    365:                case IDM_CO_NEUTRAL: /* set the color to neutral */
                    366:                    GpiSetColor(hps, CLR_NEUTRAL);
                    367:                    return 0L;
                    368:                case IDM_CO_DARKGRAY: /* set the color to darkgray */
                    369:                    GpiSetColor(hps, CLR_DARKGRAY);
                    370:                    return 0L;
                    371:                case IDM_CO_PALEBLUE: /* set the color to paleblue */
                    372:                    GpiSetColor(hps, CLR_PALEBLUE);
                    373:                    return 0L;
                    374:                case IDM_CO_PALERED: /* set the color to palered */
                    375:                    GpiSetColor(hps, CLR_PALERED);
                    376:                    return 0L;
                    377:                case IDM_CO_PALEPINK: /* set the color to palepink */
                    378:                    GpiSetColor(hps, CLR_PALEPINK);
                    379:                    return 0L;
                    380:                case IDM_CO_DARKGREEN: /* set the color to darkgreen */
                    381:                    GpiSetColor(hps, CLR_DARKGREEN);
                    382:                    return 0L;
                    383:                case IDM_CO_DARKCYAN: /* set the color to darkcyan */
                    384:                    GpiSetColor(hps, CLR_DARKCYAN);
                    385:                    return 0L;
                    386:                case IDM_CO_BROWN: /* set the color to brown */
                    387:                    GpiSetColor(hps, CLR_BROWN);
                    388:                    return 0L;
                    389:                case IDM_CO_PALEGRAY: /* set the color to palegray */
                    390:                    GpiSetColor(hps, CLR_PALEGRAY);
                    391:                    return 0L;
                    392: 
                    393:                /*
                    394:                 * MIX MODE menu case statments
                    395:                 */
                    396:                case IDM_MM_DEFAULT: /* set the mix mode to default */
                    397:                    GpiSetMix(hps, FM_DEFAULT);
                    398:                    return 0L;
                    399:                case IDM_MM_OR: /* set the mix mode to or */
                    400:                    GpiSetMix(hps, FM_OR);
                    401:                    return 0L;
                    402:                case IDM_MM_OVERPAINT: /* set the mix mode to overpaint */
                    403:                    GpiSetMix(hps, FM_OVERPAINT);
                    404:                    return 0L;
                    405:                case IDM_MM_XOR: /* set the mix mode to xor */
                    406:                    GpiSetMix(hps, FM_XOR);
                    407:                    return 0L;
                    408:                case IDM_MM_LEAVEALONE: /* set the mix mode to leavealone */
                    409:                    GpiSetMix(hps, FM_LEAVEALONE);
                    410:                    return 0L;
                    411:                case IDM_MM_AND: /* set the mix mode to and */
                    412:                    GpiSetMix(hps, FM_AND);
                    413:                    return 0L;
                    414:                case IDM_MM_SUBTRACT: /* set the mix mode to subtract */
                    415:                    GpiSetMix(hps, FM_SUBTRACT);
                    416:                    return 0L;
                    417:                case IDM_MM_MASKSRCNOT: /* set the mixmode to masksrcnot */
                    418:                    GpiSetMix(hps, FM_MASKSRCNOT);
                    419:                    return 0L;
                    420:                case IDM_MM_ZERO: /* set the mix mode to zero */
                    421:                    GpiSetMix(hps, FM_ZERO);
                    422:                    return 0L;
                    423:                case IDM_MM_NOTMERGESRC: /* set the mix mode to notmergesrc */
                    424:                    GpiSetMix(hps, FM_NOTMERGESRC);
                    425:                    return 0L;
                    426:                case IDM_MM_NOTXORSRC: /* set the mix mode to notxorsrc */
                    427:                    GpiSetMix(hps, FM_NOTXORSRC);
                    428:                    return 0L;
                    429:                case IDM_MM_INVERT: /* set the mix mode to invert */
                    430:                    GpiSetMix (hps, FM_INVERT);
                    431:                    return 0L;
                    432:                case IDM_MM_MERGESRCNOT: /* set the mix mode to mergesrcnot
                    433:                    GpiSetMix (hps, FM_MERGESRCNOT);
                    434:                    return 0L;
                    435:                case IDM_MM_NOTCOPYSRC: /* setthe mix mode to notcopysrc */
                    436:                    GpiSetMix(hps, FM_NOTCOPYSRC);
                    437:                    return 0L;
                    438:                case IDM_MM_MERGENOTSRC:/* set the mix mode to mergenotsrc */
                    439:                    GpiSetMix(hps, FM_MERGENOTSRC);
                    440:                    return 0L;
                    441:                case IDM_MM_NOTMASKSRC: /* set the mix mode to notmasksrc */
                    442:                    GpiSetMix (hps, FM_NOTMASKSRC);
                    443:                    return 0L;
                    444:                case IDM_MM_ONE: /* set the mix mode to one */
                    445:                    GpiSetMix(hps, FM_ONE);
                    446:                    return 0L;
                    447: 
                    448:         /*
                    449:          * SCREEN menu case statement
                    450:          */
                    451:         case IDM_SC_ERASE: /* erase the screen */
                    452:            WinQueryWindowRect(hwnd, &rcl);
                    453:            WinFillRect(hps, &rcl, CLR_WHITE);
                    454:            return 0L;
                    455: 
                    456:         /*
                    457:          * SEGMENT menu case statements
                    458:          */
                    459:         case IDM_DR_DRAW1: /* open a segment for drawing */
                    460:            GpiSetDrawingMode(hps,
                    461:                              DM_DRAWANDRETAIN);
                    462:            GpiOpenSegment (hps,
                    463:                            ++seg_num);
                    464:            GpiSetSegmentAttrs (hps, seg_num, ATTR_CHAINED, ATTR_ON);
                    465:            return 0L;
                    466: 
                    467:         case IDM_DR_SAVE: /* close a segment and save its contents */
                    468:            GpiCloseSegment (hps);
                    469:            return 0L;
                    470: 
                    471: 
                    472:         case IDM_DR_DRAW2: /* display all of the saved segments */
                    473:            if (seg_num == 1)
                    474:                GpiDrawSegment(hps, seg_num);
                    475:            else
                    476:                GpiDrawFrom(hps, 1L, seg_num);
                    477:            return 0L;
                    478: 
                    479:             }
                    480:        return 0L;
                    481: 
                    482:        /*
                    483:        * User pressed the leftmost mouse button
                    484:        */
                    485:        case WM_BUTTON1DOWN: /*...and they're drawing or collecting points */
                    486:                    if (geom_line_flag){  /* drawing wide lines */
                    487:                         cur_pos.x = (LONG) LOUSHORT(mp1); /* get the x-coordinate of the current pos */
                    488:                         cur_pos.y = (LONG) HIUSHORT(mp1); /* get the y-coord of the current pos */
                    489:                         GpiMove (hps, &cur_pos); /* move to the current pos   */
                    490:                         draw_geom_line = TRUE;
                    491:                         }
                    492:                    if (collect_points){ /* collecting points */
                    493:                         cur_pos.x = (LONG) LOUSHORT(mp1); /* get the x-coordinate of the current pos */
                    494:                         cur_pos.y = (LONG) HIUSHORT(mp1); /* get the y-coord of the current pos */
                    495:                         if (i == 0){
                    496:                                point.x = cur_pos.x; point.y = cur_pos.y;
                    497:                         }
                    498:                         farray[i].x = cur_pos.x; farray[i++].y = cur_pos.y;
                    499:                         GpiMarker(hps, &cur_pos);
                    500:                         GpiSetCurrentPosition(hps, &point);
                    501:                         }
                    502:                    return TRUE;
                    503: 
                    504:        /*
                    505:        * User is dragging the mouse
                    506:        */
                    507:        case WM_MOUSEMOVE: /*...and their drawing */
                    508:                    if (draw_geom_line)
                    509:                       {
                    510:                            cur_pos.x = (LONG) LOUSHORT(mp1); /* get the x-coord for the mouse */
                    511:                            cur_pos.y = (LONG) HIUSHORT(mp1); /* get the y-coord for the mouse */
                    512:                            DrawWideLine(hps, cur_pos); /* draw the line  */
                    513:                       return TRUE;
                    514:                       }
                    515:                    return FALSE;
                    516:       /*
                    517:        * User released the leftmost mouse button
                    518:        */
                    519:       case WM_BUTTON1UP: /*...stop all drawing */
                    520:                    draw_geom_line = FALSE;
                    521:                    return TRUE;
                    522: 
                    523: 
                    524:        /*
                    525:         * Paint the window
                    526:         */
                    527:         case WM_PAINT:
                    528:            hgpi = WinBeginPaint(hwnd, NULL, NULL);
                    529:            GpiErase(hgpi);
                    530:            WinEndPaint(hgpi);
                    531:             break;
                    532: 
                    533:         default:
                    534:             return (WinDefWindowProc(hwnd, usMessage, mp1, mp2));
                    535:     }
                    536:     return (0L);
                    537: }
                    538: 
                    539: /****************************************************************************
                    540: 
                    541:     FUNCTION: About(HWND, USHORT, MPARAM, MPARAM)
                    542: 
                    543:     PURPOSE:  Processes messages for "About" dialog box
                    544: 
                    545:     MESSAGES:
                    546: 
                    547:        WM_COMMAND    - Input received
                    548: 
                    549:     COMMENTS:
                    550: 
                    551:        Wait for user to click on "Ok" button, then close the dialog box.
                    552: 
                    553: ****************************************************************************/
                    554: 
                    555: MRESULT FAR PASCAL About(hwnd, usMessage, mp1, mp2)
                    556: HWND   hwnd;
                    557: USHORT usMessage;
                    558: MPARAM mp1;
                    559: MPARAM mp2;
                    560: {
                    561:     switch (usMessage) {
                    562:         case WM_COMMAND:
                    563:             switch (LOUSHORT(mp1)) {
                    564:                 case ID_OK:
                    565:                     WinDismissDlg(hwnd, 0);
                    566:                     break;
                    567:             }
                    568:             break;
                    569: 
                    570:         default:
                    571:             return (WinDefDlgProc(hwnd, usMessage, mp1, mp2));
                    572:     }
                    573:     return (0L);
                    574: }
                    575: 
                    576: /***************************************************************************
                    577: 
                    578:     FUNCTION: DrawWideLine
                    579: 
                    580:     PURPOSE:  This function uses the coordinates of the cursor to draw
                    581:              a line of specified width and color. (Note: since this is
                    582:              a wide line, the drawing occurs within a path)
                    583: 
                    584: ***************************************************************************/
                    585: 
                    586: DrawWideLine(hps, cur_pos)
                    587: HPS hps;
                    588: POINTL cur_pos;
                    589:            {
                    590:            GpiSetLineWidthGeom(hps, width);
                    591:            GpiBeginPath(hps, 1L);      /* start a path            */
                    592:            GpiLine(hps, &cur_pos);
                    593:            GpiEndPath(hps);
                    594:            GpiModifyPath(hps,
                    595:                          1L,
                    596:                          MPATH_STROKE);
                    597:            GpiFillPath(hps,
                    598:                        1L,
                    599:                        FPATH_ALTERNATE);
                    600:             }
                    601: 
                    602: /***************************************************************************
                    603: 
                    604:     FUNCTION:     ArcParam Dlg Proc
                    605: 
                    606:     PURPOSE: This function processes the arc parameters and scaling factor
                    607:             that the user enters.
                    608: 
                    609:     COMMENTS: The application uses these values when it draws a full arc,
                    610:              a partial arc, or, a three-point arc.
                    611: 
                    612: ***************************************************************************/
                    613: 
                    614: 
                    615: MRESULT FAR PASCAL ArcPDlgProc(hwnd, Msg, lParam1, lParam2)
                    616: HWND hwnd;
                    617: USHORT Msg;
                    618: MPARAM lParam1;
                    619: MPARAM lParam2;
                    620:  {
                    621:     switch (Msg)
                    622:        {
                    623:         case WM_COMMAND:
                    624:              switch (LOUSHORT (lParam1))
                    625:                     {
                    626:                      case DM_QUIT:
                    627:                           WinDismissDlg(hwnd, FALSE);
                    628:                           break;
                    629:                       case DM_OK:
                    630:                       /*
                    631:                        * Capture lP
                    632:                        */
                    633:                        WinQueryDlgItemShort(hwnd,
                    634:                                             DM_LP,
                    635:                                             &lP,
                    636:                                             0);
                    637: 
                    638:                        /*
                    639:                         * Capture lQ
                    640:                         */
                    641:                         WinQueryDlgItemShort(hwnd,
                    642:                                              DM_LQ,
                    643:                                              &lQ,
                    644:                                              0);
                    645: 
                    646:                         /*
                    647:                          * Capture lR
                    648:                          */
                    649:                          WinQueryDlgItemShort(hwnd,
                    650:                                               DM_LR,
                    651:                                               &lR,
                    652:                                               0);
                    653: 
                    654:                          /*
                    655:                           * Capture lS
                    656:                           */
                    657:                           WinQueryDlgItemShort(hwnd,
                    658:                                                DM_LS,
                    659:                                                &lS,
                    660:                                                0);
                    661:                arcparams.lP = (LONG)(lP);
                    662:                arcparams.lQ = (LONG)(lQ);
                    663:                arcparams.lR = (LONG)(lR);
                    664:                arcparams.lS = (LONG)(lS);
                    665: 
                    666:                GpiSetArcParams(hps, &arcparams);
                    667:                WinDismissDlg(hwnd, TRUE);
                    668:               break;
                    669:          default:
                    670:          break;
                    671:         }
                    672:         break;
                    673:        default:
                    674:        return WinDefDlgProc (hwnd, Msg, lParam1, lParam2);
                    675:        }
                    676:     return 0L;
                    677:  }
                    678: 
                    679: 
                    680: /***************************************************************************
                    681: 
                    682:     FUNCTION: QueryLBundle
                    683: 
                    684:     PURPOSE:  Query the line attribute structure and print attributes
                    685:              in a message box
                    686: 
                    687: ***************************************************************************/
                    688: 
                    689: QueryLBundle()
                    690: {
                    691:        GpiQueryAttrs(hps,
                    692:                      PRIM_LINE,
                    693:                      LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH |
                    694:                      LBB_GEOM_WIDTH | LBB_TYPE | LBB_END |
                    695:                      LBB_JOIN,
                    696:                      &pbundle);
                    697: 
                    698:                 sprintf(str, "Color %ld  Mix %d  C_Width %ld G_Width %ld Type %d  End %d Join %d", pbundle.lColor, pbundle.usMixMode, pbundle.fxWidth, pbundle.lGeomWidth, pbundle.usType, pbundle.usEnd, pbundle.usJoin);
                    699: 
                    700:                 WinMessageBox(HWND_DESKTOP,
                    701:                               hwndClient,
                    702:                               str,
                    703:                               "Line Attributes",
                    704:                               0,
                    705:                               MB_OK);
                    706: 
                    707: }
                    708: 
                    709: /***************************************************************************
                    710: 
                    711:     FUNCTION: DrawAxis()
                    712: 
                    713:     PURPOSE:  Plots a Graph that identifies origin for full arcs
                    714: 
                    715: ***************************************************************************/
                    716: 
                    717: 
                    718: DrawAxis(hps, pOrigin)
                    719: HPS hps;
                    720: PPOINTL pOrigin;
                    721: {
                    722:        POINTL  start, end;     /* points for axis plotting */
                    723:        LONG    color;  /* old color */
                    724: 
                    725:        color = GpiQueryColor(hps);
                    726:        GpiSetColor (hps, CLR_BLUE);
                    727:        /* plot y-axis */
                    728:        start.x = pOrigin->x; start.y = 600;
                    729:        end.x = start.x; end.y = 5;
                    730:        DrawLine(hps, &start, &end);
                    731: 
                    732:        /* plot x-axis */
                    733:        start.x = 5; start.y = pOrigin->y;
                    734:        end.x = 810; end.y = start.y;
                    735:        DrawLine(hps, &start, &end);
                    736: 
                    737:        /* plot units along x-axis */
                    738:        start.x = 300; start.y = 202;
                    739:        end.x = 300; end.y = 198;
                    740:        DrawLine(hps, &start, &end);
                    741: 
                    742:        start.x = 400; start.y = 202;
                    743:        end.x = 400;    end.y= 198;
                    744:        DrawLine(hps, &start, &end);
                    745: 
                    746:        start.x = 600; start.y = 202;
                    747:        end.x = 600; end.y = 198;
                    748:        DrawLine(hps, &start, &end);
                    749: 
                    750:        start.x = 700; start.y = 202;
                    751:        end.x = 700;    end.y = 198;
                    752:        DrawLine(hps, &start, &end);
                    753: 
                    754:        /* plot units along y-axis */
                    755:        start.x = 497; start.y = 400;
                    756:        end.x = 502;    end.y = 400;
                    757:        DrawLine(hps, &start, &end);
                    758: 
                    759:        start.x = 497; start.y = 300;
                    760:        end.x = 502; end.y = 300;
                    761:        DrawLine(hps, &start, &end);
                    762: 
                    763:        start.x = 497; start.y = 100;
                    764:        end.x = 502;    end.y = 100;
                    765:        DrawLine(hps, &start, &end);
                    766: 
                    767:        GpiSetColor(hps, color);
                    768: }
                    769: 
                    770: /***************************************************************************
                    771: 
                    772:     FUNCTION:  DrawLine(start, end)
                    773: 
                    774:     PURPOSE: Draws a line from a starting point to an ending point
                    775: 
                    776: ***************************************************************************/
                    777: 
                    778: DrawLine(hps, pStart, pEnd)
                    779: HPS hps;
                    780: PPOINTL pStart;
                    781: PPOINTL pEnd;
                    782:     {
                    783:        POINTL start, end;  /* start and end points */
                    784:        start.x = pStart->x; start.y = pStart->y;
                    785:        end.x = pEnd->x; end.y = pEnd->y;
                    786:        GpiMove(hps, &start);
                    787:        GpiLine(hps, &end);
                    788:     }
                    789: MRESULT FAR PASCAL Fil_S_DlgProc(hwnd, Msg, lParam1, lParam2)
                    790: HWND hwnd;
                    791: USHORT Msg;
                    792: MPARAM lParam1;
                    793: MPARAM lParam2;
                    794:  {
                    795:   switch (Msg)
                    796:     {
                    797:      case WM_COMMAND:
                    798:          switch (LOUSHORT (lParam1))
                    799:          {
                    800:            case DM_QUITF:
                    801:                 WinDismissDlg(hwnd, FALSE);
                    802:            break;
                    803:            case DM_OKF:
                    804:            /*
                    805:             * Capture Sharpness for Fillet1
                    806:             */
                    807:            WinQueryDlgItemShort(hwnd,
                    808:                                 DM_S1,
                    809:                                 &lP,
                    810:                                 1);
                    811: 
                    812:           /*
                    813:            * Capture Sharpness for Fillet2
                    814:            */
                    815:            WinQueryDlgItemShort(hwnd,
                    816:                                 DM_S2,
                    817:                                 &lQ,
                    818:                                 1);
                    819: 
                    820:           /*
                    821:            * Capture Sharpness for Fillet3
                    822:            */
                    823:            WinQueryDlgItemShort(hwnd,
                    824:                                 DM_S3,
                    825:                                 &lR,
                    826:                                 1);
                    827: 
                    828:          /*
                    829:           * Capture Sharpness for Fillet4
                    830:           */
                    831:           WinQueryDlgItemShort(hwnd,
                    832:                                DM_S4,
                    833:                                &lS,
                    834:                                1);
                    835:          larray[0] = (LONG)(65536 * lP);
                    836:          larray[1] = (LONG)(65536 * lQ);
                    837:          larray[2] = (LONG)(65536 * lR);
                    838:          larray[3] = (LONG)(65536 * lS);
                    839: 
                    840:          WinDismissDlg(hwnd, TRUE);
                    841:          break;
                    842:          default:
                    843:          break;
                    844:         }
                    845:       break;
                    846:       default:
                    847:        return WinDefDlgProc (hwnd, Msg, lParam1, lParam2);
                    848:       }
                    849:  return 0L;
                    850:  }

unix.superglobalmegacorp.com

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