home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / BENCH.ZIP / BENCH.C next >
Text File  |  1990-12-09  |  61KB  |  1,975 lines

  1. /*    Bench.c (c) Axel Salomon, 1990, Public Domain   */
  2.  
  3. #define INCL_DOS  /* inlude what we need */
  4. #define INCL_WIN
  5. #define INCL_GPI
  6.  
  7. #include <os2.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <time.h>
  12. #include "bench.h" /* recource definitons */
  13.  
  14.  
  15. /* not that much interesting macros */
  16.  
  17. #define FLOAT float
  18. #define MIN(a,b)     ( a<b ? a : b )
  19. #define IRAND(a)     ( rand() % a )
  20. #define LRAND(a)     ( (LONG)rand() % a )
  21.  
  22. #define MS_HUNDREDTHS   10L
  23. #define MS_SECONDS    1000L  
  24. #define MS_MINUTES   60000L
  25. #define MS_HOUR    3600000L 
  26.  
  27. #define CALC_MSEC( dt ) dt->hours      * MS_HOUR    + \
  28.                         dt->minutes    * MS_MINUTES + \
  29.                         dt->seconds    * MS_SECONDS + \
  30.                         dt->hundredths * MS_HUNDREDTHS
  31.  
  32.  
  33. /* let us start with prototyping */
  34.  
  35. MRESULT EXPENTRY BenchWinProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2); /* the main client window proc */
  36. MRESULT EXPENTRY BenchDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2); /* the standard dialog proc */
  37.  
  38. VOID cdecl main (VOID);        /* the main function, everything starts here */
  39. VOID do_paint   (HWND hwnd);   /* execute when a WM_PAINT message occure    */
  40. VOID do_size    (MPARAM mp2);  /* execute when a WM_SIZE message occure (someone was playing with the sizeframe or with the min/max-buttons */
  41. VOID do_command (HWND hwnd, MPARAM mp1);       /* Execute a menu selection  */
  42.  
  43.  
  44. /* here are all the benchmark functions */
  45.  
  46.  
  47. VOID do_gpi_fonts_all     (HWND hwnd);   
  48. VOID do_gpi_fonts_box     (HWND hwnd);  /* GpiSetCharBox() */
  49. VOID do_gpi_fonts_chars   (HWND hwnd);  /* FATTR.usSelection */
  50. VOID do_gpi_fonts_direct  (HWND hwnd);  /* GpiSetCharDirection() */ 
  51. VOID do_gpi_fonts_angle   (HWND hwnd);  /* GpiSetCharAngle() */
  52. VOID do_gpi_fonts_shear   (HWND hwnd);  /* GpiSetCharShear() */
  53.  
  54. VOID do_gpi_lines_all     (HWND hwnd);  
  55. VOID do_gpi_lines_arcs    (HWND hwnd);  /* GpiFullArc() */
  56. VOID do_gpi_lines_boxes   (HWND hwnd);  /* GpiBox() */
  57. VOID do_gpi_lines_fillets (HWND hwnd);  /* GpiPolyFillet() */
  58. VOID do_gpi_lines_lines   (HWND hwnd);  /* GpiLine() */
  59. VOID do_gpi_lines_splines (HWND hwnd);  /* GpiPolySpline() */
  60. VOID do_gpi_lines_styles  (HWND hwnd);  /* GpiSetLineType() */
  61.  
  62. VOID do_gpi_marker_all    (HWND hwnd); 
  63. VOID do_gpi_marker_box    (HWND hwnd);  /* GpiSetMarkerBox() */
  64. VOID do_gpi_marker_poly   (HWND hwnd);  /* GpiPolyMarker() */
  65. VOID do_gpi_marker_single (HWND hwnd);  /* GpiMarker() */
  66. VOID do_gpi_marker_userdef(HWND hwnd);  /* GpiSetMarkerSet() */
  67.  
  68. VOID do_gpi_paths_all     (HWND hwnd);
  69. VOID do_gpi_paths_ends    (HWND hwnd);  /* GpiSetLineEnd() */
  70. VOID do_gpi_paths_fill    (HWND hwnd);  /* GpiFillPath() */
  71. VOID do_gpi_paths_join    (HWND hwnd);  /* GpiSetLineJoin() */
  72. VOID do_gpi_paths_lines   (HWND hwnd);  /* GpiStrokePath() */
  73. VOID do_gpi_paths_pattern (HWND hwnd);  /* GpiSetPattern() */
  74. VOID do_gpi_paths_width   (HWND hwnd);  /* GpiSetLineWidthGeom() */
  75.  
  76. VOID do_gpi_all           (HWND hwnd);
  77.  
  78. VOID do_gpi_extend        (HWND hwnd);  /* A sample GPI-programm */
  79.  
  80. VOID do_win_dialog_all    (HWND hwnd);
  81. VOID do_win_dialog_buttons(HWND hwnd);  /* Some pushbutton functions */
  82. VOID do_win_dialog_entrys (HWND hwnd);  /* Play with entryfields */
  83. VOID do_win_dialog_listbox(HWND hwnd);  /* Listbox messages */
  84. VOID do_win_dialog_scrollb(HWND hwnd);  /* Scrollbar messages */ 
  85. VOID do_win_dialog_statics(HWND hwnd);  /* Look at different statics */
  86.  
  87. VOID do_win_menus_all     (HWND hwnd);
  88. VOID do_win_menus_attrib  (HWND hwnd);  /* MM_SETITEMATTR - Msg */
  89. VOID do_win_menus_bitmap  (HWND hwnd);  /* MM_SETITEM     - Msg */
  90. VOID do_win_menus_items   (HWND hwnd);  /* Some MM_?ITEM? - Msg */
  91. VOID do_win_menus_show    (HWND hwnd);  /* MM_SELECTITEM  - Msg */
  92.  
  93. VOID do_win_all           (HWND hwnd);
  94.  
  95. /* global functions to help me programm all this, also helpful for you */
  96.  
  97. VOID do_clear_screen( HWND hwnd ); /* clear the window */
  98. INT  do_init(VOID);                /* PM init function */
  99.  
  100. VOID Display_Time(HWND hwnd, PDATETIME start, PDATETIME ende);     /* Displays the Benchmark result in the window title bar */
  101.  
  102. #define TMA_INC_SUBMENU   1    /* Definition for ToggleMenuAttr() */
  103. #define TMA_INC_SYSMENU   2
  104.  
  105. SHORT ToggleMenuAttr( HWND frame, USHORT flags, SHORT id_of_menuitem, SHORT menuitem_attribute ); /* Toggles the attribute of a minuitem */
  106.  
  107. BOOL GpiSetFont (HPS hps, LONG fontid, CHAR *fontname);
  108. BOOL GpiSetCharPointSize(HPS hps, SHORT pointwidth, SHORT pointhight);
  109. BOOL GpiSetCharSelection(HPS hps, LONG fontid, CHAR *fontname, SHORT select);
  110.  
  111.  
  112. /* global variables */
  113.   
  114. HAB      hab;     /* the handle of the anchor block, main connection to PM */
  115. HMQ      hmq;     /* the message queue handle */
  116. HDC      hdc;     /* the handle for a device context, not yet used */
  117. HWND     hwndMainFrame,hwndMainClient;  /* Frame and Client Window handle */
  118.  
  119. POINTL   center;  /* The center of the client window */
  120. INT      cx,cy;   /* The x and y size of the client window */
  121.  
  122. DATETIME start_dt,ende_dt; /* Date and Time of our Benchmark Start and End */
  123.  
  124.  
  125. /* Constants for use in the Benchmark prog. */
  126.  
  127. LONG colors[16] = { CLR_BLACK,        /* the standard colors */
  128.                     CLR_DARKBLUE,
  129.                     CLR_DARKGREEN,
  130.                     CLR_DARKCYAN,
  131.                     CLR_DARKPINK,
  132.                     CLR_DARKRED,
  133.                     CLR_BROWN,
  134.                     CLR_PALEGRAY,
  135.                     CLR_DARKGRAY,
  136.                     CLR_BLUE,
  137.                     CLR_GREEN, 
  138.                     CLR_CYAN,
  139.                     CLR_PINK,
  140.                     CLR_RED,
  141.                     CLR_YELLOW,
  142.                     CLR_WHITE };
  143.  
  144. LONG linetype[8] = { LINETYPE_DEFAULT, /* the standard line styles */
  145.                      LINETYPE_DOT,
  146.                      LINETYPE_SHORTDASH,
  147.                      LINETYPE_DASHDOT,
  148.                      LINETYPE_DOUBLEDOT,
  149.                      LINETYPE_LONGDASH,
  150.                      LINETYPE_DASHDOUBLEDOT,
  151.                      LINETYPE_SOLID };
  152.  
  153. CHAR linetext[8][15] = { "DEFAULT",  /* the text of the lintypes */
  154.                          "DOT",
  155.                          "SHORTDASH",
  156.                          "DASHDOT",
  157.                          "DOUBLEDOT",
  158.                          "LONGDASH",
  159.                          "DASHDOUBLEDOT",
  160.                          "SOLID" };
  161.  
  162. LONG endstyles[4] = { LINEEND_DEFAULT, /* line ending types */
  163.                       LINEEND_FLAT,
  164.                       LINEEND_ROUND,
  165.                       LINEEND_SQUARE };
  166.  
  167. LONG markertype[11] = { MARKSYM_DEFAULT, /* standard marker symbols */
  168.                         MARKSYM_CROSS,
  169.                         MARKSYM_PLUS,
  170.                         MARKSYM_DIAMOND,
  171.                         MARKSYM_SQUARE,
  172.                         MARKSYM_SIXPOINTSTAR,
  173.                         MARKSYM_EIGHTPOINTSTAR,
  174.                         MARKSYM_SOLIDDIAMOND,
  175.                         MARKSYM_SOLIDSQUARE,
  176.                         MARKSYM_DOT,
  177.                         MARKSYM_SMALLCIRCLE };
  178.  
  179. LONG pattern[19] = { PATSYM_BLANK,  /* standard fill pattern */
  180.                      PATSYM_DEFAULT,
  181.                      PATSYM_DENSE1,
  182.                      PATSYM_DENSE2,
  183.                      PATSYM_DENSE3,
  184.                      PATSYM_DENSE4,
  185.                      PATSYM_DENSE5,
  186.                      PATSYM_DENSE6,
  187.                      PATSYM_DENSE7,
  188.                      PATSYM_DENSE8,
  189.                      PATSYM_DIAG1,
  190.                      PATSYM_DIAG2,
  191.                      PATSYM_DIAG3,
  192.                      PATSYM_DIAG4,
  193.                      PATSYM_HALFTONE,
  194.                      PATSYM_HORIZ,
  195.                      PATSYM_NOSHADE,
  196.                      PATSYM_SOLID,
  197.                      PATSYM_VERT };
  198.  
  199. SHORT select[15] = { 0,                 /* all possible selections for font attributes */
  200.                      FATTR_SEL_ITALIC,
  201.                      FATTR_SEL_ITALIC ^ FATTR_SEL_UNDERSCORE,
  202.                      FATTR_SEL_ITALIC ^ FATTR_SEL_STRIKEOUT,
  203.                      FATTR_SEL_ITALIC ^ FATTR_SEL_BOLD,
  204.                      FATTR_SEL_ITALIC ^ FATTR_SEL_UNDERSCORE ^ FATTR_SEL_STRIKEOUT,
  205.                      FATTR_SEL_ITALIC ^ FATTR_SEL_UNDERSCORE ^ FATTR_SEL_BOLD,
  206.                      FATTR_SEL_ITALIC ^ FATTR_SEL_UNDERSCORE ^ FATTR_SEL_STRIKEOUT ^ FATTR_SEL_BOLD,
  207.                      FATTR_SEL_UNDERSCORE,
  208.                      FATTR_SEL_UNDERSCORE ^ FATTR_SEL_STRIKEOUT,
  209.                      FATTR_SEL_UNDERSCORE ^ FATTR_SEL_BOLD,
  210.                      FATTR_SEL_UNDERSCORE ^ FATTR_SEL_STRIKEOUT ^ FATTR_SEL_BOLD,
  211.                      FATTR_SEL_STRIKEOUT,
  212.                      FATTR_SEL_STRIKEOUT ^ FATTR_SEL_BOLD,
  213.                      FATTR_SEL_BOLD };
  214.  
  215. LONG direct[4] = { CHDIRN_LEFTRIGHT, /* the standard char directions */
  216.                    CHDIRN_RIGHTLEFT,
  217.                    CHDIRN_TOPBOTTOM,
  218.                    CHDIRN_BOTTOMTOP };
  219.  
  220.  
  221. CHAR lbsamp[30][40] = { "House of the rising sun",
  222.                         "With a little help from your friends",
  223.                         "The year of the cat",
  224.                         "Bad Moon Rising",
  225.                         "Papa was a rolling stone",
  226.                         "Why can't we live together",
  227.                         "Under the broadwalk",
  228.                         "MacArther park",
  229.                         "Venus",
  230.                         "Aquarius",
  231.                         "Stairways to heaven",
  232.                         "Bat out of hell",
  233.                         "Sounds of silence",
  234.                         "Woman in love",
  235.                         "Never gonna give you up",
  236.                         "Crazy for you",
  237.                         "In the mood",
  238.                         "Nikita",
  239.                         "Even the bad times are good",
  240.                         "See you later alligator",
  241.                         "Running for our lives",
  242.                         "Somewhere in africa",
  243.                         "Wonderful world",
  244.                         "Midnight special",
  245.                         "Hit the road jack",
  246.                         "Babooshka",
  247.                         "I heard it through the grapevine",
  248.                         "Madame de la luna",
  249.                         "If i had a hammer",
  250.                         "C'mon everybody" };
  251.  
  252. /*-----------------------------------------------------------------*/
  253. /*                          M A I N                                */
  254. /*-----------------------------------------------------------------*/
  255. void cdecl main()
  256. {
  257.  QMSG qmsg;    /* a message queue item */
  258.  
  259.  srand( (unsigned) time(NULL) ); /* initialize the random number generator */
  260.  
  261.  if ( do_init() ){               /* do the init stuff */
  262.     while(WinGetMsg(hab, &qmsg, NULL, 0, 0)) /* make the PM workfor you */
  263.        WinDispatchMsg(hab, &qmsg);
  264.  
  265.     WinDestroyWindow( hwndMainFrame ); /* clean up everything */
  266.     WinDestroyMsgQueue( hmq );
  267.     WinTerminate( hab );
  268.  }
  269.  
  270. }
  271.  
  272. /*-----------------------------------------------------------------*/
  273. /*                  Initialisierungs-Prozedur                      */
  274. /*-----------------------------------------------------------------*/
  275. INT do_init()
  276. {
  277.   BOOL ok;
  278.   ULONG flFlags = FCF_STANDARD;
  279.  
  280.   hab = WinInitialize( NULL );         /* Handle Anchor Block to the PM */
  281.   hmq = WinCreateMsgQueue( hab,0 );    /* The Message Queue ... */
  282.  
  283.   ok = GpiLoadFonts( hab, "C:\\OS2\\DLL\\TIMES.FON" ); /* Load Fonts here */
  284.  
  285.   /* Register our window proc. */
  286.   if (!(WinRegisterClass(hab,"BenchWinProc", BenchWinProc, CS_SIZEREDRAW, 0))) {
  287.      WinDestroyMsgQueue( hmq );
  288.      WinTerminate( hab );
  289.      return FALSE;
  290.   }
  291.  
  292.   /* Open the main window */
  293.   if (!(hwndMainFrame = WinCreateStdWindow(HWND_DESKTOP,WS_VISIBLE,&flFlags,
  294.                        "BenchWinProc",NULL,WS_CLIPSIBLINGS,(HMODULE)NULL,MID_MAIN,&hwndMainClient))) {
  295.      WinDestroyMsgQueue( hmq );
  296.      WinTerminate( hab );
  297.      return FALSE;
  298.   }
  299.  
  300.   /* and give it a title */
  301.   WinSetWindowText(hwndMainFrame,"Benchmark Program");
  302.   return TRUE;
  303. }
  304.  
  305. /*-----------------------------------------------------------------*/
  306. /*                 M A I N C L I E N T P R O C                     */
  307. /*-----------------------------------------------------------------*/
  308. MRESULT EXPENTRY BenchWinProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  309. {
  310.   switch (msg)
  311.    {
  312.      case WM_CREATE:       /* Do what you need on creation */
  313.           break; 
  314.      case WM_COMMAND:      /* Menu selection and Accelerator keys are handled here */
  315.           do_command(hwnd,mp1);
  316.           return 0;
  317.      case WM_PAINT:        /* Do painting here */
  318.           do_paint(hwnd);
  319.           return 0;
  320.      case WM_SIZE:         /* The size of the screen has changed */
  321.           do_size(mp2);
  322.           return 0;
  323.      case WM_CLOSE:        /* We want to close the screen now */
  324.           WinPostMsg( hwnd, WM_QUIT, 0L, 0L);
  325.           return 0;
  326.      default:              /* The rest is the best */
  327.           break;
  328.    }
  329.     return (WinDefWindowProc(hwnd, msg, mp1, mp2 )); /* so don't worry about it */
  330. }
  331.  
  332.  
  333. /*-----------------------------------------------------------------*/
  334. /*                          BenchDlgProc                           */
  335. /*-----------------------------------------------------------------*/
  336. MRESULT EXPENTRY BenchDlgProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  337. {
  338.    USHORT dialogdata;
  339.  
  340.    switch (msg) {
  341.      case WM_INITDLG:
  342.           WinPostMsg( hwnd, MID_BENCHMARK, mp2, (MPARAM) NULL );
  343.           break;
  344.      case WM_PAINT:
  345.           break;
  346.      case WM_CONTROL:
  347.           break;
  348.      case WM_SETFOCUS:
  349.           break;
  350.      case WM_CHAR:
  351.           break; 
  352.      case WM_COMMAND:
  353.           break;
  354.      case MID_BENCHMARK:
  355.           memcpy(&dialogdata, mp1, sizeof(USHORT));
  356.           switch (dialogdata) {
  357.             case MID_WIN_DIALOGS_BUTTONS: 
  358.                  do_win_dialog_buttons( hwnd );
  359.                  break;
  360.             case MID_WIN_DIALOGS_ENTRYS:
  361.                  do_win_dialog_entrys( hwnd );
  362.                  break;
  363.             case MID_WIN_DIALOGS_LISTBOX:
  364.                  do_win_dialog_listbox( hwnd );
  365.                  break;
  366.             case MID_WIN_DIALOGS_SCROLLB:
  367.                  do_win_dialog_scrollb( hwnd );
  368.                  break;
  369.             case MID_WIN_DIALOGS_STATICS:
  370.                  do_win_dialog_statics( hwnd );
  371.                  break;
  372.             default:
  373.                  return;
  374.           }
  375.           WinDismissDlg( hwnd, TRUE );
  376.           break;
  377.      default:
  378.           break;
  379.    }
  380.   
  381.   return ( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );
  382. }
  383.  
  384.  
  385. /*-----------------------------------------------------------------*/
  386. /*                       Command-Prozeduren                        */
  387. /*-----------------------------------------------------------------*/
  388. VOID do_command(HWND hwnd, MPARAM mp1)
  389. {
  390.    HPOINTER hptr;  /* get a handle for the mouse-pointer */
  391.    USHORT dialogdata;
  392.  
  393.    hptr = WinQueryPointer( HWND_DESKTOP ); /* Query the actual Pointer and save it */
  394.    WinSetPointer( HWND_DESKTOP, (HPOINTER) NULL ); /* Erase the Pointer */
  395.  
  396.    DosGetDateTime(&start_dt); /* Get the current date and time for calculation */
  397.  
  398.    switch (SHORT1FROMMP(mp1))       /* And now : the Messages */
  399.    { 
  400.      case MID_GPI_FONTS_BOX:        /* Draw Text in different Character sizes */ 
  401.           do_gpi_fonts_box(hwnd);
  402.           break;
  403.      case MID_GPI_FONTS_CHARS:      /* Draw Text with different standard attributes */
  404.           do_gpi_fonts_chars(hwnd);
  405.           break;
  406.      case MID_GPI_FONTS_DIRECT:     /* Draw Text in different directions */
  407.           do_gpi_fonts_direct(hwnd);
  408.           break;
  409.      case MID_GPI_FONTS_ANGLE:      /* Draw Text with different angles */
  410.           do_gpi_fonts_angle(hwnd);
  411.           break;
  412.      case MID_GPI_FONTS_SHEAR:      /* Draw Text with shears (like shadows) */
  413.           do_gpi_fonts_shear(hwnd);
  414.           break;
  415.      case MID_GPI_FONTS_ALL:        /* Execute all font benchmark tests */
  416.           do_gpi_fonts_all(hwnd);
  417.           break;
  418.  
  419.      case MID_GPI_LINES_ARCS:       /* Draw filled arcs like spots */
  420.           do_gpi_lines_arcs(hwnd);
  421.           break;
  422.      case MID_GPI_LINES_BOXES:      /* Draw random boxes, you know that ... */
  423.           do_gpi_lines_boxes(hwnd);
  424.           break;
  425.      case MID_GPI_LINES_FILLETS:    /* Draw 3-Point curves, like your baby sister did */
  426.           do_gpi_lines_fillets(hwnd);
  427.           break;
  428.      case MID_GPI_LINES_LINES:      /* Draw some lines around the center, and check your Monitor ! */
  429.           do_gpi_lines_lines(hwnd); /* you'll get "flimmer" on interlaced monitors ! */
  430.           break;
  431.      case MID_GPI_LINES_SPLINES:    /* Draw 4-Point curves, like you do !? <g> */
  432.           do_gpi_lines_splines(hwnd);
  433.           break;
  434.      case MID_GPI_LINES_STYLES:     /* Draw different line-styles */
  435.           do_gpi_lines_styles(hwnd);
  436.           break;
  437.      case MID_GPI_LINES_ALL:        /* execute all line benchmark tests */
  438.           do_gpi_lines_all(hwnd);
  439.           break;
  440.  
  441.      case MID_GPI_MARKER_BOX :      /* draw markers with different sizes */
  442.           do_gpi_marker_box(hwnd); 
  443.           break;
  444.      case MID_GPI_MARKER_POLY :     /* draw 30 Markers each call */
  445.           do_gpi_marker_poly(hwnd);
  446.           break;
  447.      case MID_GPI_MARKER_SINGLE :   /* draw 1 marker each call */
  448.           do_gpi_marker_single(hwnd);
  449.           break;
  450.      case MID_GPI_MARKER_USERDEF :  /* draws very small character markers */
  451.           do_gpi_marker_userdef(hwnd);
  452.           break;
  453.      case MID_GPI_MARKER_ALL :      /* execute all marker benchmark tests */
  454.           do_gpi_marker_all(hwnd);
  455.           break;
  456.  
  457.      case MID_GPI_PATHS_ENDS:       /* draw stroked lines with different endings */
  458.           do_gpi_paths_ends(hwnd);
  459.           break;
  460.      case MID_GPI_PATHS_FILL:       /* draw filled triangles using GpiFillPath() */
  461.           do_gpi_paths_fill(hwnd);
  462.           break;
  463.      case MID_GPI_PATHS_JOIN:       /* draw stroked triangles with different line join attributes */
  464.           do_gpi_paths_join(hwnd);
  465.           break;
  466.      case MID_GPI_PATHS_LINES:      /* draw filled partial arcs, 3-point and 4-point curves and 4-line areas */
  467.           do_gpi_paths_lines(hwnd); /* using GpiPartialArc(), GpiPolyFillet(), GpiPolySpline(), GpiPolyLine() */
  468.           break;
  469.      case MID_GPI_PATHS_PATTERN:    /* same as do_gpi_paths_line, but filled with pattern */
  470.           do_gpi_paths_pattern(hwnd);
  471.           break;
  472.      case MID_GPI_PATHS_WIDTH:      /* same as do_gpi_paths_line, but stroked, not filled, that means only the */
  473.           do_gpi_paths_width(hwnd); /* bounding curve is drawn with a defined line width using GpiSetLineWidthGeom() */
  474.           break;
  475.      case MID_GPI_PATHS_ALL:        /* execute all paths benchmark tests */
  476.           do_gpi_paths_all(hwnd);
  477.           break;
  478.  
  479.      case MID_GPI_ALL:              /* execute all gpi benchmark tests */
  480.           do_gpi_all(hwnd);
  481.           break;
  482.  
  483.      case MID_GPI_EXTEND:           /* draw a extended demo, to see what you can dow with gpi function calls */
  484.           do_gpi_extend(hwnd);
  485.           break;
  486.  
  487.      case MID_WIN_DIALOGS_ALL:
  488.           do_win_dialog_all(hwnd);
  489.           break;
  490.      case MID_WIN_DIALOGS_BUTTONS:
  491.           dialogdata = SHORT1FROMMP(mp1);
  492.           WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH1_DLG, (PVOID) &dialogdata ) );
  493.           break;
  494.      case MID_WIN_DIALOGS_ENTRYS:
  495.           dialogdata = SHORT1FROMMP(mp1);
  496.           WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH2_DLG, (PVOID) &dialogdata ) );
  497.           break;
  498.      case MID_WIN_DIALOGS_LISTBOX:
  499.           dialogdata = SHORT1FROMMP(mp1);
  500.           WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH3_DLG, (PVOID) &dialogdata ) );
  501.           break;
  502.      case MID_WIN_DIALOGS_SCROLLB:
  503.           dialogdata = SHORT1FROMMP(mp1);
  504.           WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH4_DLG, (PVOID) &dialogdata ) );
  505.           break;
  506.      case MID_WIN_DIALOGS_STATICS:
  507.           dialogdata = SHORT1FROMMP(mp1);
  508.           WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH5_DLG, (PVOID) &dialogdata ) );
  509.           break;
  510.  
  511.      case MID_WIN_MENUS_ALL:     
  512.           do_win_menus_all(hwndMainFrame);
  513.           break;
  514.      case MID_WIN_MENUS_ATTRIB:     /* Enable and Disable different menu attributs */
  515.           do_win_menus_attrib(hwndMainFrame);
  516.           break;
  517.      case MID_WIN_MENUS_BITMAPS:    /* Load a bitmap and displays it as a Menuitem */
  518.           do_win_menus_bitmap(hwndMainFrame);
  519.           break;
  520.      case MID_WIN_MENUS_ITEMS:      /* Work on menu items with different messages */
  521.           do_win_menus_items(hwndMainFrame);
  522.           break;
  523.      case MID_WIN_MENUS_SHOW:      /* Selects different Menuitems */
  524.           do_win_menus_show(hwndMainFrame);
  525.           break;
  526.      case MID_WIN_ALL:
  527.           do_win_all(hwndMainFrame);
  528.           break;
  529.  
  530.      case CMD_CLEAR:                /* Clear the screen */
  531.           do_clear_screen(hwnd);
  532.           break;
  533.  
  534.      case CMD_EXIT:                 /* Leave the benchmark test */
  535.           WinPostMsg(hwnd,WM_CLOSE,(MPARAM) NULL,(MPARAM) NULL);
  536.           return;
  537.  
  538.      default:
  539.           return;
  540.      }
  541.  
  542.    DosGetDateTime(&ende_dt);        /* Get the actual time and date */
  543.    Display_Time(hwnd, &start_dt, &ende_dt); /* Calculate and display the time in [ms] in the title bar */
  544.  
  545.    WinSetPointer(HWND_DESKTOP, hptr); /* restore the pointer */
  546.  
  547. }
  548.  
  549.  
  550. /* This function Calculates the difference between start and end of a bench-
  551.    marktest. The result is formatted with sprintf and stored in a buffer.
  552.    The buffer is displayed in title bar. */
  553.  
  554. VOID Display_Time(HWND hwnd, PDATETIME start, PDATETIME ende)     
  555. {
  556.   CHAR buffer[50];
  557.  
  558.   sprintf( buffer, "Benchmark result : %lu ms", (CALC_MSEC(ende))-(CALC_MSEC(start)));
  559.  
  560.   WinSetWindowText( hwndMainFrame, buffer );
  561.  
  562. }
  563.  
  564.  
  565. /*-----------------------------------------------------------------*/
  566. /*                       drawing-procedures                        */
  567. /*-----------------------------------------------------------------*/
  568.  
  569. /* Fill the screen with color of a window */
  570.  
  571. VOID do_paint(HWND hwnd)
  572. {
  573.   RECTL rc; /* the window rectangle */
  574.   HPS hps;  /* the presantation space of the window */
  575.  
  576.   hps =  WinBeginPaint(hwnd, (HPS)NULL, &rc);    /* let us begin */
  577.          WinFillRect( hps, &rc, SYSCLR_WINDOW);  /* fill the space */
  578.          WinEndPaint(hps);                       /* that∩s all */
  579. }
  580.  
  581.  
  582. /* Clear the screen, please */
  583.  
  584. VOID do_clear_screen( HWND hwnd )
  585. {
  586.   HPS hps;
  587.   RECTL rc;
  588.  
  589.   rc.xLeft  = rc.yBottom = 0L;
  590.   rc.xRight = cx;
  591.   rc.yTop   = cy;
  592.  
  593.   hps = WinGetPS( hwnd );                             /* Get the PS */
  594.         WinFillRect( hps, &rc, colors[ IRAND(16) ] ); /* and fill it with a random color */ 
  595.         WinReleasePS( hwnd );                         /* release the PS again */
  596.  
  597. }
  598.  
  599.  
  600. /* store the actual sizes in public varibles, when the WM_SIZE message occur
  601.    also calculate the center of the screen */
  602.  
  603. VOID do_size( MPARAM mp2 )
  604. {
  605.   cx = SHORT1FROMMP(mp2);    /* get the width */
  606.   cy = SHORT2FROMMP(mp2);    /* and hight */
  607.   center.x = (LONG)cx/2;     /* and calculate the */
  608.   center.y = (LONG)cy/2;     /* the center of the screen */
  609.  
  610.  
  611. /*-----------------------------------------------------------------*/
  612. /*                      benchmark-procedures                       */
  613. /*-----------------------------------------------------------------*/
  614.  
  615. /* Fonts */
  616.  
  617. VOID do_gpi_fonts_box(HWND hwnd)
  618. {
  619.   INT i,j;
  620.   POINTL pkt;
  621.   SIZEF size;
  622.   BOOL ok;
  623.   HPS hps;
  624.  
  625.   hps = WinGetPS( hwnd );
  626.  
  627.   ok = GpiSetFont( hps, 1L, (CHAR *)"Tms Rmn" );
  628.  
  629.   for (i=0; i<100; i++ ) {
  630.       pkt.x = LRAND( cx/3 );
  631.       pkt.y = LRAND( cy );
  632.       size.cx = MAKEFIXED( IRAND(200) ,0 );
  633.       size.cy = MAKEFIXED( IRAND(200) ,0 );
  634.       ok = GpiSetColor( hps, colors[ IRAND(16) ] );
  635.       ok = GpiMove( hps, &pkt );
  636.       ok = GpiSetCharBox( hps, &size );
  637.       ok = GpiCharString( hps, 10, "Benchmark");
  638.   }
  639.  
  640.   ok = GpiSetCharSet( hps, 0 );
  641.   ok = GpiDeleteSetId( hps, 1);
  642.  
  643.   WinReleasePS( hwnd );
  644.  
  645. }
  646.  
  647. VOID do_gpi_fonts_direct(HWND hwnd)
  648. {
  649.   INT i,j;
  650.   POINTL pkt;
  651.   SIZEF size;
  652.   BOOL ok;
  653.   HPS hps;
  654.  
  655.   size.cx = MAKEFIXED( 50,0 );
  656.   size.cy = MAKEFIXED( 50,0 );
  657.  
  658.   hps = WinGetPS( hwnd );
  659.  
  660.   ok = GpiSetFont( hps, 1L, (CHAR *)"Tms Rmn" );
  661.   ok = GpiSetCharBox( hps, &size );
  662.  
  663.   for (i=0; i<100; i++ ) {
  664.       pkt.x = LRAND( cx );
  665.       pkt.y = LRAND( cy );
  666.       ok = GpiSetColor( hps, colors[IRAND(16)] );
  667.       ok = GpiSetCharDirection( hps, direct[IRAND(4)] );
  668.       ok = GpiMove( hps, &pkt );
  669.       ok = GpiCharString( hps, 10, "Benchmark");
  670.   }
  671.  
  672.   ok = GpiSetCharSet( hps, 0 );
  673.   ok = GpiDeleteSetId( hps, 1);
  674.  
  675.   WinReleasePS( hwnd );
  676.  
  677. }
  678.  
  679. VOID do_gpi_fonts_chars(HWND hwnd)
  680. {
  681.   INT i,j;
  682.   POINTL pkt;
  683.   SIZEF size;
  684.   BOOL ok;
  685.   HPS hps;
  686.  
  687.   size.cx = MAKEFIXED( 50,0 );
  688.   size.cy = MAKEFIXED( 50,0 );
  689.  
  690.   hps = WinGetPS( hwnd );
  691.  
  692.   for (i=0; i<100; i++ ) {
  693.       pkt.x = LRAND( cx );
  694.       pkt.y = LRAND( cy );
  695.       ok = GpiSetCharSelection( hps, 1L, (CHAR *)"Tms Rmn", select[IRAND(15)] );
  696.       ok = GpiSetCharBox( hps, &size );
  697.       ok = GpiSetColor( hps, colors[IRAND(16)] );
  698.       ok = GpiMove( hps, &pkt );
  699.       ok = GpiCharString( hps, 10, "Benchmark");
  700.       ok = GpiSetCharSet( hps, 0 );
  701.       ok = GpiDeleteSetId( hps, 1);
  702.   }
  703.  
  704.   WinReleasePS( hwnd );
  705.  
  706. }
  707.  
  708. VOID do_gpi_fonts_angle(HWND hwnd)
  709. {
  710.   INT i;
  711.   POINTL pkt;
  712.   GRADIENTL grad;
  713.   SIZEF size;
  714.   BOOL ok;
  715.   HPS hps;
  716.  
  717.   size.cx = MAKEFIXED( 50,0 );
  718.   size.cy = MAKEFIXED( 50,0 );
  719.  
  720.   hps = WinGetPS( hwnd );
  721.  
  722.   ok = GpiSetFont( hps, 1L, (CHAR *)"Tms Rmn" );
  723.   ok = GpiSetCharBox( hps, &size );
  724.  
  725.   for (i=0; i<100; i++ ) {
  726.       pkt.x = LRAND( cx );
  727.       pkt.y = LRAND( cy );
  728.       grad.x = (LONG)(25-rand() % 50 );
  729.       grad.y = (LONG)(25-rand() % 50 );
  730.       ok = GpiSetColor( hps, colors[rand() % 16] );
  731.       ok = GpiMove( hps, &pkt );
  732.       ok = GpiSetCharAngle( hps, &grad );      
  733.       ok = GpiCharString( hps, 10, "Benchmark" );
  734.   }
  735.  
  736.   ok = GpiSetCharSet( hps, 0 );
  737.   ok = GpiDeleteSetId( hps, 1);
  738.  
  739.   WinReleasePS( hwnd );
  740.  
  741. }
  742.  
  743. VOID do_gpi_fonts_shear(HWND hwnd)
  744. {
  745.   INT i;
  746.   POINTL pkt,shear;
  747.   SIZEF size;
  748.   BOOL ok;
  749.   HPS hps;
  750.  
  751.   size.cx = MAKEFIXED( 50,0 );
  752.   size.cy = MAKEFIXED( 50,0 );
  753.  
  754.   hps = WinGetPS( hwnd );
  755.  
  756.   ok = GpiSetFont( hps, 1L, (CHAR *)"Tms Rmn" );
  757.   ok = GpiSetCharBox( hps, &size );
  758.  
  759.   for (i=0; i<100; i++ ) {
  760.       pkt.x = LRAND( cx );
  761.       pkt.y = LRAND( cy );
  762.       shear.x = (LONG)(25-rand() % 50 );
  763.       shear.y = (LONG)(25-rand() % 50 );
  764.       ok = GpiSetColor( hps, colors[rand() % 16] );
  765.       ok = GpiMove( hps, &pkt );
  766.       ok = GpiSetCharShear( hps, &shear );      
  767.       ok = GpiCharString( hps, 10, "Benchmark" );
  768.   }
  769.  
  770.   ok = GpiSetCharSet( hps, 0 );
  771.   ok = GpiDeleteSetId( hps, 1);
  772.  
  773.   WinReleasePS( hwnd );
  774.  
  775. }
  776.  
  777. VOID do_gpi_fonts_all(HWND hwnd)
  778. {
  779.   do_gpi_fonts_box     (hwnd);
  780.   do_gpi_fonts_chars   (hwnd);
  781.   do_gpi_fonts_direct  (hwnd);
  782.   do_gpi_fonts_angle   (hwnd);
  783.   do_gpi_fonts_shear   (hwnd);
  784. }
  785.  
  786. /* Lines */
  787.  
  788. VOID do_gpi_lines_arcs(HWND hwnd)
  789. {
  790.  
  791.   INT i;
  792.   ARCPARAMS arcp = { 1, 1, 0, 0 };
  793.   POINTL pkt;
  794.   BOOL ok;
  795.   HPS hps;
  796.  
  797.   hps = WinGetPS( hwnd );
  798.  
  799.   ok = GpiSetArcParams( hps, &arcp );
  800.  
  801.   for (i=0; i<500; i++) {
  802.       pkt.x = LRAND( cx );
  803.       pkt.y = LRAND( cy );
  804.       ok = GpiSetColor( hps, colors[rand() % 16] );
  805.       ok = GpiMove( hps, &pkt );
  806.       ok = GpiFullArc( hps, DRO_OUTLINEFILL, MAKEFIXED( rand() % 64, 0 ) );
  807.   }
  808.  
  809.   WinReleasePS( hwnd );
  810.  
  811. }
  812.  
  813. VOID do_gpi_lines_boxes(HWND hwnd)
  814. {
  815.  
  816.   INT i;
  817.   BOOL ok;
  818.   HPS hps;
  819.   POINTL pkt;
  820.  
  821.   hps = WinGetPS( hwnd );
  822.  
  823.   ok = GpiMove( hps, ¢er );
  824.   ok = GpiSetColor( hps, CLR_DARKGRAY );
  825.  
  826.   for (i=0; i<500; i++) {
  827.       pkt.x = LRAND( cx );
  828.       pkt.y = LRAND( cy );
  829.       ok = GpiSetColor( hps, colors[rand() % 16] );
  830.       ok = GpiBox( hps, DRO_OUTLINEFILL, &pkt, NULL, NULL );
  831.       ok = GpiMove( hps, &pkt );
  832.   }
  833.  
  834.   WinReleasePS( hwnd );
  835.  
  836. }
  837.  
  838. VOID do_gpi_lines_fillets(HWND hwnd)
  839.   HPS hps;
  840.   POINTL Multipkt[2];
  841.   BOOL ok;
  842.   INT i,j;
  843.  
  844.   hps = WinGetPS( hwnd );
  845.  
  846.   ok =  GpiMove(hps, ¢er);
  847.   for (j=0; j<500; j++ ) {
  848.       for (i=0; i<2; i++ ) {
  849.           ok = GpiSetColor( hps, colors[rand() % 16] );
  850.           Multipkt[i].x = LRAND( cx );
  851.           Multipkt[i].y = LRAND( cy );
  852.           ok =  GpiPolyFillet(hps, 2, Multipkt);
  853.       }
  854.   }
  855.  
  856.   WinReleasePS( hwnd );
  857. }
  858.  
  859. VOID do_gpi_lines_lines(HWND hwnd)
  860.   BOOL ok;
  861.   POINTL p1;
  862.   INT i,c;
  863.   HPS hps;
  864.  
  865.   hps = WinGetPS( hwnd );
  866.  
  867.   p1.x = 0L;
  868.   p1.y = 0L;
  869.  
  870.   for (c=0; c<16; c++ ) {
  871.       ok = GpiSetColor( hps, colors[c] );
  872.       for (i=0 ; i<360; i++ ) {
  873.           ok = GpiMove( hps, ¢er );
  874.           if (i<90) {
  875.              p1.x =(LONG)((FLOAT)cx*(FLOAT)i/90.0);
  876.              }
  877.           else if ( i<180 ) {
  878.              p1.x = cx;
  879.              p1.y = (LONG)((FLOAT)cy*(FLOAT)(i-90)/90.0);
  880.              }
  881.           else if ( i<270 ) {
  882.              p1.x = (LONG)((FLOAT)cx*(FLOAT)(270-i)/90.0);
  883.              p1.y = cy;
  884.              }
  885.           else if ( i<360 ) {
  886.              p1.x = 0L;
  887.              p1.y = (LONG)((FLOAT)cy*(FLOAT)(360-i)/90.0);
  888.              }
  889.           ok = GpiLine( hps, &p1 );
  890.       }
  891.   } 
  892.   WinReleasePS( hwnd );
  893.  
  894. }
  895.  
  896. VOID do_gpi_lines_splines(HWND hwnd)
  897. {
  898.   HPS hps;
  899.   POINTL Multipkt[3];
  900.   BOOL ok;
  901.   INT i,j;
  902.  
  903.   hps = WinGetPS( hwnd );
  904.  
  905.   ok =  GpiSetColor(hps, CLR_CYAN);
  906.   ok =  GpiMove(hps, ¢er);   
  907.  
  908.   for (i=0; i<500; i++ ) {
  909.       for (j=0;j<3;j++) {
  910.           Multipkt[j].x = LRAND( cx );
  911.           Multipkt[j].y = LRAND( cy );
  912.       }
  913.       ok = GpiSetColor( hps, colors[rand() % 16] );
  914.       ok = GpiPolySpline(hps, 3, Multipkt);
  915.   } 
  916.  
  917.  
  918.   WinReleasePS( hwnd );
  919. }
  920.  
  921. VOID do_gpi_lines_styles(HWND hwnd)
  922. {
  923.   HPS hps;
  924.   BOOL ok;
  925.   POINTL pkt;
  926.   INT i,j;
  927.  
  928.   hps = WinGetPS( hwnd );
  929.   
  930.   for ( i=0; i<8; i++) {
  931.       pkt.y = (LONG)((FLOAT)cy/8.0*(FLOAT)i);
  932.       ok = GpiSetLineType(hps,linetype[i]);
  933.       for (j=0; j<(INT)((FLOAT)cy/8.0);j+=3) {
  934.           ok = GpiSetColor( hps, colors[rand() % 16] );
  935.           pkt.x = 0L;
  936.           ok = GpiMove(hps,&pkt);
  937.           pkt.x = cx;
  938.           ok = GpiLine(hps,&pkt);
  939.           pkt.y+=3;
  940.       }
  941.       ok = GpiSetColor( hps, colors[0] );
  942.       pkt.x = 10L;
  943.       pkt.y = (LONG)((FLOAT)cy/8.0*(FLOAT)i);
  944.       ok = GpiMove( hps, &pkt );
  945.       ok = GpiCharString( hps, strlen(linetext[i]), linetext[i] );
  946.   }
  947.  
  948.   WinReleasePS( hwnd );
  949. }
  950.  
  951. VOID do_gpi_lines_all(HWND hwnd)
  952. {
  953.   do_gpi_lines_arcs    (hwnd);
  954.   do_gpi_lines_boxes   (hwnd);
  955.   do_gpi_lines_fillets (hwnd);
  956.   do_gpi_lines_lines   (hwnd);
  957.   do_gpi_lines_splines (hwnd);
  958.   do_gpi_lines_styles  (hwnd);
  959. }
  960.  
  961.  
  962. /* marker */
  963.  
  964. VOID do_gpi_marker_box(HWND hwnd)
  965. {
  966.  
  967.   INT i,j;
  968.   POINTL pkt;
  969.   FATTRS fat;
  970.   SIZEF siz;
  971.   BOOL ok;
  972.   HPS hps;
  973.  
  974.   fat.usRecordLength = sizeof(FATTRS);
  975.   fat.fsSelection    = 0;
  976.   fat.lMatch         = 0;
  977.   fat.idRegistry     = 0;
  978.   fat.usCodePage     = 850;
  979.   fat.lMaxBaselineExt= 0L;
  980.   fat.lAveCharWidth  = 0L;
  981.   fat.fsType         = 0;
  982.   fat.fsFontUse      = FATTR_FONTUSE_OUTLINE;
  983.   strcpy(fat.szFacename,"Tms Rmn");
  984.  
  985.   hps = WinGetPS( hwnd );
  986.  
  987.   ok = GpiCreateLogFont( hps, (PSTR8) NULL, 1, &fat );
  988.   ok = GpiSetMarkerSet( hps, 1 );
  989.  
  990.   for (i=0; i<500; i++) {
  991.      pkt.x = LRAND( cx );
  992.      pkt.y = LRAND( cy );
  993.      siz.cx = MAKEFIXED( rand() % 200, 0 );
  994.      siz.cy = MAKEFIXED( rand() % 200, 0 );
  995.      ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  996.      ok = GpiSetMarker( hps, rand() % 256 );
  997.      ok = GpiSetMarkerBox( hps, &siz );
  998.      ok = GpiMarker( hps, &pkt );
  999.  
  1000.   }
  1001.  
  1002.   WinReleasePS( hwnd );
  1003.  
  1004. }
  1005.  
  1006. VOID do_gpi_marker_poly(HWND hwnd)
  1007. {
  1008.  
  1009.   INT i,j;
  1010.   POINTL pkt,pkte[30];
  1011.   BOOL ok;
  1012.   HPS hps;
  1013.  
  1014.   hps = WinGetPS( hwnd );
  1015.   for (i=0; i<17; i++) {
  1016.       for (j=0; j<30; j++ ) {
  1017.           pkte[j].x = LRAND( cx );
  1018.           pkte[j].y = LRAND( cy );
  1019.       }
  1020.      ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  1021.      ok = GpiSetMarker( hps, markertype[ rand() % 11 ] );
  1022.      ok = GpiPolyMarker( hps, 30, pkte );
  1023.       
  1024.   }
  1025.   WinReleasePS( hwnd );
  1026.  
  1027. }
  1028.  
  1029. VOID do_gpi_marker_single(HWND hwnd)
  1030. {
  1031.  
  1032.   INT i;
  1033.   POINTL pkt;
  1034.   BOOL ok;
  1035.   HPS hps;
  1036.  
  1037.   hps = WinGetPS( hwnd );
  1038.   for( i=0; i<500; i++ ) {
  1039.      pkt.x = LRAND( cx );
  1040.      pkt.y = LRAND( cy );
  1041.      ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  1042.      ok = GpiSetMarker( hps, markertype[ rand() % 11 ] );
  1043.      ok = GpiMarker( hps, &pkt );
  1044.   }
  1045.  
  1046.   WinReleasePS( hwnd );
  1047.  
  1048. }
  1049.  
  1050. VOID do_gpi_marker_userdef(HWND hwnd)
  1051. {
  1052.  
  1053.   INT i,j;
  1054.   POINTL pkt;
  1055.   FATTRS fat;
  1056.   BOOL ok;
  1057.   HPS hps;
  1058.  
  1059.   fat.usRecordLength = sizeof(FATTRS);
  1060.   fat.fsSelection    = 0;
  1061.   fat.lMatch         = 0;
  1062.   fat.idRegistry     = 0;
  1063.   fat.usCodePage     = 850;
  1064.   fat.lMaxBaselineExt= 0L;
  1065.   fat.lAveCharWidth  = 0L;
  1066.   fat.fsType         = 0;
  1067.   fat.fsFontUse      = FATTR_FONTUSE_OUTLINE;
  1068.  
  1069.   hps = WinGetPS( hwnd );
  1070.  
  1071.   ok = GpiCreateLogFont( hps, (PSTR8) NULL, 1, &fat );
  1072.   ok = GpiSetMarkerSet( hps, 1 );
  1073.  
  1074.   for (i=0; i<500; i++) {
  1075.      pkt.x = LRAND( cx );
  1076.      pkt.y = LRAND( cy );
  1077.      ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  1078.      ok = GpiSetMarker( hps, rand() % 256 );
  1079.      ok = GpiMarker( hps, &pkt );
  1080.  
  1081.   }
  1082.  
  1083.   WinReleasePS( hwnd );
  1084.  
  1085. }
  1086.  
  1087. VOID do_gpi_marker_all(HWND hwnd)
  1088. {
  1089.   do_gpi_marker_box(hwnd);
  1090.   do_gpi_marker_poly(hwnd);
  1091.   do_gpi_marker_single(hwnd);
  1092.   do_gpi_marker_userdef(hwnd);
  1093. }
  1094.  
  1095.  
  1096. /* paths */
  1097.  
  1098. VOID do_gpi_paths_ends(HWND hwnd)
  1099. {
  1100.   HPS hps;
  1101.   BOOL ok;
  1102.   POINTL p1,p2;
  1103.   INT i,j;
  1104.  
  1105.   hps = WinGetPS( hwnd );
  1106.   
  1107.   for (i=0; i<4; i++ ) {
  1108.       for (j=0; j<125; j++) {
  1109.           p1.x = LRAND( cx );
  1110.           p1.y = LRAND( cy );
  1111.           p2.x = LRAND( cx );
  1112.           p2.y = LRAND( cy );
  1113.           ok = GpiBeginPath( hps, 1L );
  1114.           ok = GpiSetLineEnd( hps, endstyles[i] );
  1115.           ok = GpiSetLineWidthGeom( hps, 20L );
  1116.           ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  1117.           ok = GpiMove( hps, &p1 );
  1118.           ok = GpiLine( hps, &p2 );
  1119.           ok = GpiEndPath( hps );
  1120.           ok = GpiStrokePath( hps, 1L, NULL );
  1121.       }
  1122.   }
  1123.  
  1124.   WinReleasePS( hwnd );
  1125.  
  1126. }
  1127.  
  1128. VOID do_gpi_paths_fill(HWND hwnd)
  1129. {
  1130.   HPS hps;
  1131.   BOOL ok;
  1132.   INT i;
  1133.   POINTL p1, pkt[2];
  1134.  
  1135.   hps = WinGetPS( hwnd );
  1136.   for (i=0; i<500; i++) {
  1137.       p1.x = LRAND( cx );
  1138.       p1.y = LRAND( cy );
  1139.       pkt[0].x = LRAND( cx );
  1140.       pkt[0].y = LRAND( cy );
  1141.       pkt[1].x = LRAND( cx );
  1142.       pkt[1].y = LRAND( cy );
  1143.       ok = GpiBeginPath( hps, 1L );
  1144.       ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  1145.       ok = GpiMove( hps, &p1 );
  1146.       ok = GpiPolyLine( hps, 2, pkt );
  1147.       ok = GpiLine( hps, &p1 );
  1148.       ok = GpiEndPath( hps );
  1149.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1150.   }
  1151.  
  1152.   WinReleasePS( hwnd );
  1153.  
  1154. }
  1155.  
  1156. VOID do_gpi_paths_join(HWND hwnd)
  1157. {
  1158.   static LONG joinstyle[4] = { LINEJOIN_BEVEL,
  1159.                                LINEJOIN_DEFAULT,
  1160.                                LINEJOIN_MITRE,
  1161.                                LINEJOIN_ROUND };
  1162.   HPS hps;
  1163.   BOOL ok;
  1164.   INT i;
  1165.   POINTL p1, pkt[2];
  1166.  
  1167.   hps = WinGetPS( hwnd );
  1168.   for (i=0; i<500; i++) {
  1169.       p1.x = LRAND( cx );
  1170.       p1.y = LRAND( cy );
  1171.       pkt[0].x = LRAND( cx );
  1172.       pkt[0].y = LRAND( cy );
  1173.       pkt[1].x = LRAND( cx );
  1174.       pkt[1].y = LRAND( cy );
  1175.       ok = GpiBeginPath( hps, 1L );
  1176.       ok = GpiSetColor( hps, colors[ rand() % 16 ] );
  1177.       ok = GpiSetLineWidthGeom( hps, 10L );
  1178.       ok = GpiSetLineJoin( hps, joinstyle[ rand() % 4 ] ); 
  1179.       ok = GpiMove( hps, &p1 );
  1180.       ok = GpiPolyLine( hps, 2, pkt );
  1181.       ok = GpiLine( hps, &p1 );
  1182.       ok = GpiEndPath( hps );
  1183.       ok = GpiStrokePath( hps, 1L, NULL );
  1184.   }
  1185.  
  1186.   WinReleasePS( hwnd );
  1187.  
  1188. }
  1189.  
  1190. VOID do_gpi_paths_lines(HWND hwnd)
  1191. {
  1192.   HPS hps;
  1193.   BOOL ok;
  1194.   POINTL pkt,pa1[2],pa2[3];
  1195.   INT i,sa,ea,ra;
  1196.  
  1197.   hps = WinGetPS( hwnd );
  1198.   for (i=0; i<125; i++) {
  1199.       pkt.x = LRAND( cx );
  1200.       pkt.y = LRAND( cy );
  1201.       sa = (INT) LRAND( 360L );
  1202.       ea = (INT) LRAND( 360L );
  1203.       ra = (INT) LRAND( 200L );
  1204.       ok = GpiBeginPath( hps, 1L );
  1205.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1206.       ok = GpiMove( hps, &pkt ); 
  1207.       ok = GpiPartialArc( hps, &pkt, MAKEFIXED( ra, 0), MAKEFIXED( sa, 0 ), MAKEFIXED( ea,0) );
  1208.       ok = GpiLine( hps, &pkt );
  1209.       ok = GpiEndPath( hps );
  1210.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1211.   }
  1212.  
  1213.   for (i=0; i<125; i++) {
  1214.       pkt.x = LRAND( cx );
  1215.       pkt.y = LRAND( cy );
  1216.       pa1[0].x = LRAND( cx );
  1217.       pa1[0].y = LRAND( cy );
  1218.       pa1[1].x = LRAND( cx );
  1219.       pa1[1].y = LRAND( cy );
  1220.       ok = GpiBeginPath( hps, 1L );
  1221.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1222.       ok = GpiMove( hps, &pkt );
  1223.       ok = GpiPolyFillet( hps, 2, pa1 );
  1224.       ok = GpiLine( hps, &pkt );
  1225.       ok = GpiEndPath( hps );
  1226.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1227.   }
  1228.  
  1229.   for (i=0; i<125; i++) {
  1230.       pkt.x = LRAND( cx );
  1231.       pkt.y = LRAND( cy );
  1232.       pa2[0].x = LRAND( cx );
  1233.       pa2[0].y = LRAND( cy );
  1234.       pa2[1].x = LRAND( cx );
  1235.       pa2[1].y = LRAND( cy );
  1236.       pa2[2].x = LRAND( cx );
  1237.       pa2[2].y = LRAND( cy );
  1238.       ok = GpiBeginPath( hps, 1L );
  1239.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1240.       ok = GpiMove( hps, &pkt );
  1241.       ok = GpiPolySpline( hps, 3, pa2 );
  1242.       ok = GpiLine( hps, &pkt );
  1243.       ok = GpiEndPath( hps );
  1244.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1245.   }
  1246.  
  1247.   for (i=0; i<125; i++) {
  1248.       pkt.x = LRAND( cx );
  1249.       pkt.y = LRAND( cy );
  1250.       pa2[0].x = LRAND( cx );
  1251.       pa2[0].y = LRAND( cy );
  1252.       pa2[1].x = LRAND( cx );
  1253.       pa2[1].y = LRAND( cy );
  1254.       pa2[2].x = LRAND( cx );
  1255.       pa2[2].y = LRAND( cy );
  1256.       ok = GpiBeginPath( hps, 1L );
  1257.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1258.       ok = GpiMove( hps, &pkt );
  1259.       ok = GpiPolyLine( hps, 3, pa2 );
  1260.       ok = GpiLine( hps, &pkt );
  1261.       ok = GpiEndPath( hps );
  1262.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1263.   }
  1264.  
  1265.   WinReleasePS( hwnd );
  1266.  
  1267. }
  1268.  
  1269. VOID do_gpi_paths_pattern(HWND hwnd)
  1270. {
  1271.   HPS hps;
  1272.   BOOL ok;
  1273.   POINTL pkt,pa1[2],pa2[3];
  1274.   INT i,sa,ea,ra;
  1275.  
  1276.   hps = WinGetPS( hwnd );
  1277.   for (i=0; i<125; i++) {
  1278.       pkt.x = LRAND( cx );
  1279.       pkt.y = LRAND( cy );
  1280.       sa = (INT) LRAND( 360L );
  1281.       ea = (INT) LRAND( 360L );
  1282.       ra = (INT) LRAND( 200L );
  1283.       ok = GpiBeginPath( hps, 1L );
  1284.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1285.       ok = GpiSetPattern( hps, pattern[ rand() % 19 ] );
  1286.       ok = GpiMove( hps, &pkt ); 
  1287.       ok = GpiPartialArc( hps, &pkt, MAKEFIXED( ra, 0), MAKEFIXED( sa, 0 ), MAKEFIXED( ea,0) );
  1288.       ok = GpiLine( hps, &pkt );
  1289.       ok = GpiEndPath( hps );
  1290.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1291.   }
  1292.  
  1293.   for (i=0; i<125; i++) {
  1294.       pkt.x = LRAND( cx );
  1295.       pkt.y = LRAND( cy );
  1296.       pa1[0].x = LRAND( cx );
  1297.       pa1[0].y = LRAND( cy );
  1298.       pa1[1].x = LRAND( cx );
  1299.       pa1[1].y = LRAND( cy );
  1300.       ok = GpiBeginPath( hps, 1L );
  1301.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1302.       ok = GpiSetPattern( hps, pattern[ rand() % 19 ] );
  1303.       ok = GpiMove( hps, &pkt );
  1304.       ok = GpiPolyFillet( hps, 2, pa1 );
  1305.       ok = GpiLine( hps, &pkt );
  1306.       ok = GpiEndPath( hps );
  1307.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1308.   }
  1309.  
  1310.   for (i=0; i<125; i++) {
  1311.       pkt.x = LRAND( cx );
  1312.       pkt.y = LRAND( cy );
  1313.       pa2[0].x = LRAND( cx );
  1314.       pa2[0].y = LRAND( cy );
  1315.       pa2[1].x = LRAND( cx );
  1316.       pa2[1].y = LRAND( cy );
  1317.       pa2[2].x = LRAND( cx );
  1318.       pa2[2].y = LRAND( cy );
  1319.       ok = GpiBeginPath( hps, 1L );
  1320.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1321.       ok = GpiSetPattern( hps, pattern[ rand() % 19 ] );
  1322.       ok = GpiMove( hps, &pkt );
  1323.       ok = GpiPolySpline( hps, 3, pa2 );
  1324.       ok = GpiLine( hps, &pkt );
  1325.       ok = GpiEndPath( hps );
  1326.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1327.   }
  1328.  
  1329.   for (i=0; i<125; i++) {
  1330.       pkt.x = LRAND( cx );
  1331.       pkt.y = LRAND( cy );
  1332.       pa2[0].x = LRAND( cx );
  1333.       pa2[0].y = LRAND( cy );
  1334.       pa2[1].x = LRAND( cx );
  1335.       pa2[1].y = LRAND( cy );
  1336.       pa2[2].x = LRAND( cx );
  1337.       pa2[2].y = LRAND( cy );
  1338.       ok = GpiBeginPath( hps, 1L );
  1339.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1340.       ok = GpiSetPattern( hps, pattern[ rand() % 19 ] );
  1341.       ok = GpiMove( hps, &pkt );
  1342.       ok = GpiPolyLine( hps, 3, pa2 );
  1343.       ok = GpiLine( hps, &pkt );
  1344.       ok = GpiEndPath( hps );
  1345.       ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1346.   }
  1347.  
  1348.   WinReleasePS( hwnd );
  1349.  
  1350. }
  1351.  
  1352. VOID do_gpi_paths_width(HWND hwnd)
  1353. {
  1354.   HPS hps;
  1355.   BOOL ok;
  1356.   POINTL pkt,pa1[2],pa2[3];
  1357.   INT i,sa,ea,ra;
  1358.  
  1359.   hps = WinGetPS( hwnd );
  1360.  
  1361.   for (i=0; i<125; i++) {
  1362.       pkt.x = LRAND( cx );
  1363.       pkt.y = LRAND( cy );
  1364.       sa = (INT) LRAND( 360L );
  1365.       ea = (INT) LRAND( 360L );
  1366.       ra = (INT) LRAND( 200L );
  1367.       ok = GpiBeginPath( hps, 1L );
  1368.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1369.       ok = GpiSetLineWidthGeom( hps, LRAND( 64L ) );
  1370.       ok = GpiMove( hps, &pkt ); 
  1371.       ok = GpiPartialArc( hps, &pkt, MAKEFIXED( ra, 0), MAKEFIXED( sa, 0 ), MAKEFIXED( ea,0) );
  1372.       ok = GpiLine( hps, &pkt );
  1373.       ok = GpiEndPath( hps );
  1374.       ok = GpiStrokePath( hps, 1L, NULL );
  1375.   }
  1376.  
  1377.   for (i=0; i<125; i++) {
  1378.       pkt.x = LRAND( cx );
  1379.       pkt.y = LRAND( cy );
  1380.       pa1[0].x = LRAND( cx );
  1381.       pa1[0].y = LRAND( cy );
  1382.       pa1[1].x = LRAND( cx );
  1383.       pa1[1].y = LRAND( cy );
  1384.       ok = GpiBeginPath( hps, 1L );
  1385.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1386.       ok = GpiSetLineWidthGeom( hps, LRAND( 64L ) );
  1387.       ok = GpiMove( hps, &pkt );
  1388.       ok = GpiPolyFillet( hps, 2, pa1 );
  1389.       ok = GpiLine( hps, &pkt );
  1390.       ok = GpiEndPath( hps );
  1391.       ok = GpiStrokePath( hps, 1L, NULL );
  1392.   }
  1393.  
  1394.   for (i=0; i<125; i++) {
  1395.       pkt.x = LRAND( cx );
  1396.       pkt.y = LRAND( cy );
  1397.       pa2[0].x = LRAND( cx );
  1398.       pa2[0].y = LRAND( cy );
  1399.       pa2[1].x = LRAND( cx );
  1400.       pa2[1].y = LRAND( cy );
  1401.       pa2[2].x = LRAND( cx );
  1402.       pa2[2].y = LRAND( cy );
  1403.       ok = GpiBeginPath( hps, 1L );
  1404.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1405.       ok = GpiSetLineWidthGeom( hps, LRAND( 64L ) );
  1406.       ok = GpiMove( hps, &pkt );
  1407.       ok = GpiPolySpline( hps, 3, pa2 );
  1408.       ok = GpiLine( hps, &pkt );
  1409.       ok = GpiEndPath( hps );
  1410.       ok = GpiStrokePath( hps, 1L, NULL );
  1411.   }
  1412.  
  1413.   for (i=0; i<125; i++) {
  1414.       pkt.x = LRAND( cx );
  1415.       pkt.y = LRAND( cy );
  1416.       pa2[0].x = LRAND( cx );
  1417.       pa2[0].y = LRAND( cy );
  1418.       pa2[1].x = LRAND( cx );
  1419.       pa2[1].y = LRAND( cy );
  1420.       pa2[2].x = LRAND( cx );
  1421.       pa2[2].y = LRAND( cy );
  1422.       ok = GpiBeginPath( hps, 1L );
  1423.       ok = GpiSetColor( hps, colors[rand() % 16] );
  1424.       ok = GpiSetLineWidthGeom( hps, LRAND( 64L ) );
  1425.       ok = GpiMove( hps, &pkt );
  1426.       ok = GpiPolyLine( hps, 3, pa2 );
  1427.       ok = GpiLine( hps, &pkt );
  1428.       ok = GpiEndPath( hps );
  1429.       ok = GpiStrokePath( hps, 1L, NULL );
  1430.   }
  1431.  
  1432.   WinReleasePS( hwnd );
  1433.  
  1434. }
  1435.  
  1436. VOID do_gpi_paths_all(HWND hwnd)
  1437. {
  1438.   do_gpi_paths_ends    (hwnd);
  1439.   do_gpi_paths_fill    (hwnd);
  1440.   do_gpi_paths_join    (hwnd);
  1441.   do_gpi_paths_lines   (hwnd);
  1442.   do_gpi_paths_pattern (hwnd);
  1443.   do_gpi_paths_width   (hwnd);
  1444. }
  1445.  
  1446. VOID do_gpi_all(HWND hwnd)
  1447.   do_gpi_fonts_all  (hwnd);
  1448.   do_gpi_lines_all  (hwnd);
  1449.   do_gpi_marker_all (hwnd);
  1450.   do_gpi_paths_all  (hwnd);
  1451. }
  1452.  
  1453. VOID do_gpi_extend(HWND hwnd)
  1454. {
  1455.   HPS hps;
  1456.   BOOL ok;
  1457.   POINTL pkt,shear;
  1458.   INT i,sa,ea,ra;
  1459.   FATTRS fat;
  1460.   SIZEF size;
  1461.   GRADIENTL grad;
  1462.  
  1463.   static INT  pie[5] = { 40, 60, 95, 65, 50 };
  1464.   static LONG col[5] = { CLR_PINK, CLR_DARKCYAN, CLR_YELLOW, CLR_DARKPINK, CLR_CYAN }; 
  1465.  
  1466.   fat.usRecordLength = sizeof(FATTRS);
  1467.   fat.fsSelection    = 0;
  1468.   fat.lMatch         = 0;
  1469.   fat.idRegistry     = 0;
  1470.   fat.usCodePage     = 850;
  1471.   fat.lMaxBaselineExt= 0L;
  1472.   fat.lAveCharWidth  = 0L;
  1473.   fat.fsType         = 0;
  1474.   fat.fsFontUse      = FATTR_FONTUSE_OUTLINE;
  1475.   strcpy(fat.szFacename,"Tms Rmn");
  1476.  
  1477.   size.cx = MAKEFIXED( 50,0 );
  1478.   size.cy = MAKEFIXED( 50,0 );
  1479.  
  1480.   shear.x = 20;
  1481.   shear.y = 20;
  1482.  
  1483.   pkt.x = 10;
  1484.   pkt.y = 10;
  1485.  
  1486.   hps = WinGetPS( hwnd );
  1487.  
  1488.   ok = GpiCreateLogFont( hps, (PSTR8) NULL, 1, &fat );
  1489.   ok = GpiSetCharSet( hps, 1 );
  1490.   ok = GpiSetCharBox( hps, &size );
  1491.   ok = GpiSetCharShear( hps, &shear );
  1492.   ok = GpiMove( hps, &pkt );
  1493.   ok = GpiSetColor( hps, CLR_DARKGRAY );
  1494.   ok = GpiCharString( hps, 10, "Benchmark" );
  1495.  
  1496.   shear.x = 0;
  1497.   shear.y = 0;
  1498.  
  1499.   ok = GpiMove( hps, &pkt );
  1500.   ok = GpiSetColor( hps, CLR_PALEGRAY );
  1501.   ok = GpiSetCharShear( hps, &shear );
  1502.   ok = GpiCharString( hps, 10, "Benchmark" );
  1503.  
  1504.   pkt.x = center.x/2;
  1505.   pkt.y = center.y;
  1506.  
  1507.   ra = 75; sa = 0; ea = 50;
  1508.  
  1509.   for (i=0; i<5; i++ ) {
  1510.      ok = GpiBeginPath( hps, 1L );
  1511.      ok = GpiSetColor( hps, col[i] );
  1512.      ok = GpiMove( hps, &pkt);
  1513.      ok = GpiPartialArc( hps, &pkt, MAKEFIXED( ra, 0 ), MAKEFIXED( sa, 0 ), MAKEFIXED( ea, 0 )  );
  1514.      ok = GpiLine( hps, &pkt);
  1515.      ok = GpiEndPath( hps );
  1516.      ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1517.      sa += ea; ea = pie[i];
  1518.   }
  1519.  
  1520.   pkt.x += 10;
  1521.   pkt.y -= 4;
  1522.  
  1523.   ok = GpiBeginPath( hps, 1L );
  1524.   ok = GpiSetColor( hps, CLR_BLUE );
  1525.   ok = GpiMove( hps, &pkt);
  1526.   ok = GpiPartialArc( hps, &pkt, MAKEFIXED( ra, 0 ), MAKEFIXED( sa, 0 ), MAKEFIXED( ea, 0 )  );
  1527.   ok = GpiLine( hps, &pkt);
  1528.   ok = GpiEndPath( hps );
  1529.   ok = GpiFillPath( hps, 1L, FPATH_ALTERNATE );
  1530.  
  1531.   grad.x =  50;
  1532.   grad.y = -25;
  1533.  
  1534.   size.cx = MAKEFIXED( 20,0 );
  1535.   size.cy = MAKEFIXED( 20,0 );
  1536.  
  1537.   pkt.x += 80;
  1538.   pkt.y -= 38;
  1539.  
  1540.   ok = GpiSetColor( hps, CLR_DARKBLUE );
  1541.   ok = GpiMove( hps, &pkt );
  1542.   ok = GpiSetCharAngle( hps, &grad );
  1543.   ok = GpiSetCharBox( hps, &size );
  1544.   ok = GpiCharString( hps, 14, "Extra Segment" );
  1545.  
  1546.   ok = GpiBeginPath( hps, 1L );
  1547.   ok = GpiSetColor( hps, CLR_BLACK );
  1548.   pkt.x = center.x+20;
  1549.   pkt.y = center.y-5;
  1550.   ok = GpiMove( hps, &pkt );
  1551.   pkt.y = cy-5;
  1552.   ok = GpiLine( hps, &pkt );
  1553.   pkt.x = center.x+15;
  1554.   pkt.y = center.y;
  1555.   ok = GpiMove( hps, &pkt );
  1556.   pkt.x = cx-5;
  1557.   ok = GpiLine( hps, &pkt );
  1558.   ok = GpiEndPath( hps );
  1559.   ok = GpiStrokePath( hps, 1L, FPATH_ALTERNATE );
  1560.  
  1561.   WinReleasePS( hwnd );
  1562.  
  1563. }
  1564.  
  1565.  
  1566. /* win-funcs */
  1567.  
  1568. VOID do_win_dialog_buttons( HWND hwnd )
  1569. {
  1570.   int i,j;
  1571.   CHAR bench[13] = "MBAERNKC H  ";
  1572.   CHAR c[2] = "A";
  1573.   LONG col1,col2;
  1574.  
  1575.   for (i=DID_BUTTONS_0; i<=DID_BUTTONS_B; i++) {
  1576.       WinShowWindow( WinWindowFromID( hwnd, i ), FALSE );
  1577.   }
  1578.   for (i=DID_BUTTONS_0; i<=DID_BUTTONS_B; i++) {
  1579.       WinShowWindow( WinWindowFromID( hwnd, i ), TRUE );
  1580.   }
  1581.  
  1582.   for (i=0; i<13; i++) {
  1583.       col1=colors[i+1]; col2=colors[14-i];
  1584.       WinSetPresParam( WinWindowFromID( hwnd, DID_BUTTONS_0+i ), PP_FOREGROUNDCOLORINDEX, sizeof(col1), &col1 );
  1585.       WinSetPresParam( WinWindowFromID( hwnd, DID_BUTTONS_0+i ), PP_BACKGROUNDCOLORINDEX, sizeof(col2), &col2 );
  1586.   }
  1587.  
  1588.   for (i=0; i<13; i++) {
  1589.       for (j=127; j>=bench[i]; j-- ) {
  1590.           c[0] = j;
  1591.           WinSetWindowText( WinWindowFromID( hwnd, DID_BUTTONS_0+i ), c );
  1592.       }
  1593.   }
  1594. }
  1595.  
  1596. VOID do_win_dialog_entrys ( HWND hwnd )
  1597. {
  1598.   HWND entry;
  1599.   int i;
  1600.  
  1601.   entry = WinWindowFromID( hwnd, DID_ENTRYFIELD );
  1602.  
  1603.   WinSendMsg( entry, EM_SETTEXTLIMIT, (MPARAM) 100, (MPARAM) NULL );
  1604.   WinSetWindowText( entry, "Benchmark Benchmark Benchmark Benchmark Benchmark Benchmark ");
  1605.  
  1606.   /* Clipbord messages */
  1607.   
  1608.   WinSendMsg( entry, EM_SETSEL, MPFROM2SHORT((USHORT) 10, (USHORT) 19), (MPARAM) NULL );
  1609.   WinSendMsg( entry, EM_CUT, (MPARAM) NULL, (MPARAM) NULL );
  1610.   WinSendMsg( entry, EM_SETSEL, MPFROM2SHORT((USHORT) 1, (USHORT) 1), (MPARAM) NULL );
  1611.   WinSendMsg( entry, EM_COPY, (MPARAM) NULL, (MPARAM) NULL ); 
  1612.   WinSendMsg( entry, EM_SETSEL, MPFROM2SHORT((USHORT) 2, (USHORT) 11), (MPARAM) NULL );
  1613.   WinSendMsg( entry, EM_PASTE, (MPARAM) NULL, (MPARAM) NULL );
  1614.   WinSendMsg( entry, EM_SETSEL, MPFROM2SHORT((USHORT) 5, (USHORT) 5), (MPARAM) NULL );
  1615.   WinSendMsg( entry, EM_COPY, (MPARAM) NULL, (MPARAM) NULL ); 
  1616.  
  1617.   /* Cursormovement and selection */
  1618.  
  1619.   for (i=0; i<60; i++) {
  1620.       WinSendMsg( entry, EM_SETFIRSTCHAR, MPFROMSHORT((SHORT) i), (MPARAM) NULL );
  1621.   }
  1622.  
  1623.   for (i=58; i>=0; i--) {
  1624.       WinSendMsg( entry, EM_SETFIRSTCHAR, MPFROMSHORT((SHORT) i), (MPARAM) NULL );
  1625.   }
  1626.  
  1627.   for (i=0; i<40; i++) {
  1628.       WinSendMsg( entry, EM_SETSEL, MPFROM2SHORT((USHORT) 0, (USHORT) i), (MPARAM) NULL );
  1629.   } 
  1630.  
  1631.   for (i=39; i>=0; i--) {
  1632.       WinSendMsg( entry, EM_SETSEL, MPFROM2SHORT((USHORT) 0, (USHORT) i), (MPARAM) NULL );
  1633.   } 
  1634.  
  1635.   for (i=0; i<100; i++) {
  1636.       WinSendMsg( entry, EM_SETINSERTMODE, MPFROMSHORT( (SHORT)(i%2) ), (MPARAM) NULL );
  1637.   }
  1638.  
  1639. }
  1640.  
  1641. VOID do_win_dialog_listbox( HWND hwnd )
  1642. {
  1643.   HWND listbox;
  1644.   CHAR buffer[40];
  1645.   int i;
  1646.  
  1647.   listbox = WinWindowFromID( hwnd, DID_LISTBOX );
  1648.  
  1649.   for (i=0; i<30; i++) {
  1650.       WinSendMsg( listbox, LM_INSERTITEM, MPFROMSHORT((SHORT) LIT_SORTASCENDING), MPFROMP( (PSZ) lbsamp[i] ) );
  1651.   }
  1652.  
  1653.   WinSendMsg( listbox, LM_DELETEALL, (MPARAM) NULL, (MPARAM) NULL );
  1654.  
  1655.   for (i=0; i<30; i++) {
  1656.       WinSendMsg( listbox, LM_INSERTITEM, MPFROMSHORT((SHORT) LIT_SORTASCENDING), MPFROMP( (PSZ) lbsamp[i] ) );
  1657.   }
  1658.  
  1659.   for (i=0; i<180; i++) {
  1660.       WinSendMsg( listbox, LM_SELECTITEM, MPFROMSHORT((SHORT) (i%30)), MPFROMSHORT((SHORT) TRUE) );
  1661.   }  
  1662.  
  1663.   for (i=0; i<80; i++) {
  1664.       WinSendMsg( listbox, LM_QUERYITEMTEXT, MPFROM2SHORT( (SHORT) 1, (SHORT) 40 ), MPFROMP( (PSZ) buffer ) );
  1665.       WinSendMsg( listbox, LM_DELETEITEM, MPFROMSHORT((SHORT) 1), (MPARAM) NULL );
  1666.       WinSendMsg( listbox, LM_INSERTITEM, MPFROMSHORT((SHORT) LIT_END), MPFROMP( (PSZ) buffer ) );
  1667.   }  
  1668.  
  1669. }
  1670.  
  1671. VOID do_win_dialog_scrollb( HWND hwnd )
  1672. {
  1673.   HWND sb1, sb2;
  1674.   int i;
  1675.  
  1676.   sb1 = WinWindowFromID( hwnd, DID_SCROLLBAR1 );
  1677.   sb2 = WinWindowFromID( hwnd, DID_SCROLLBAR2 );
  1678.  
  1679.   WinSendMsg( sb1, SBM_SETSCROLLBAR, (MPARAM) NULL, MPFROM2SHORT( (USHORT) 0, (USHORT) 255 ) );
  1680.   WinSendMsg( sb2, SBM_SETSCROLLBAR, (MPARAM) NULL, MPFROM2SHORT( (USHORT) 0, (USHORT) 255 ) );
  1681.  
  1682.   for (i=0; i<256; i++) {
  1683.       WinSendMsg( sb1, SBM_SETPOS, MPFROMSHORT( (USHORT) i ), (MPARAM) NULL );
  1684.       WinSendMsg( sb2, SBM_SETPOS, MPFROMSHORT( (USHORT) i ), (MPARAM) NULL );
  1685.   }
  1686.  
  1687.   for (i=255; i>=0; i--) {
  1688.       WinSendMsg( sb1, SBM_SETPOS, MPFROMSHORT( (USHORT) i ), (MPARAM) NULL );
  1689.       WinSendMsg( sb2, SBM_SETPOS, MPFROMSHORT( (USHORT) i ), (MPARAM) NULL );
  1690.   }
  1691.  
  1692.   for (i=0; i<256; i++) {
  1693.       WinSendMsg( sb1, SBM_SETTHUMBSIZE, MPFROM2SHORT( (USHORT) i, (USHORT) 256 ), (MPARAM) NULL );
  1694.       WinSendMsg( sb2, SBM_SETTHUMBSIZE, MPFROM2SHORT( (USHORT) i, (USHORT) 256 ), (MPARAM) NULL );
  1695.   }
  1696.  
  1697.   for (i=255; i>=0; i--) {
  1698.       WinSendMsg( sb1, SBM_SETTHUMBSIZE, MPFROM2SHORT( (USHORT) i, (USHORT) 256 ), (MPARAM) NULL );
  1699.       WinSendMsg( sb2, SBM_SETTHUMBSIZE, MPFROM2SHORT( (USHORT) i, (USHORT) 256 ), (MPARAM) NULL );
  1700.   }
  1701.  
  1702. }
  1703.  
  1704. VOID do_win_dialog_statics( HWND hwnd )
  1705. {
  1706.   HWND hStatic;
  1707.   HBITMAP hBmp1, hBmp2;
  1708.   HPS hps;
  1709.   int i;
  1710.  
  1711.   hps   = WinGetPS( hwnd );
  1712.   hBmp1 = GpiLoadBitmap( hps, (HMODULE) NULL, MID_BMP1, 58L, 48L );
  1713.   hBmp2 = GpiLoadBitmap( hps, (HMODULE) NULL, MID_BMP2, 58L, 48L );
  1714.   WinReleasePS( hps );
  1715.  
  1716.   hStatic = WinWindowFromID( hwnd, DID_STATIC_1 ); /* Get Bitmap */
  1717.  
  1718.   for (i=0; i<100; i++) {
  1719.       WinSendMsg( hStatic, SM_SETHANDLE, MPFROMLONG( (ULONG) hBmp2 ), (MPARAM) NULL );
  1720.       WinSendMsg( hStatic, SM_SETHANDLE, MPFROMLONG( (ULONG) hBmp1 ), (MPARAM) NULL );
  1721.   }  
  1722.  
  1723. }
  1724.  
  1725. VOID do_win_dialog_all( HWND hwnd )
  1726. {
  1727.   SHORT dialogdata;
  1728.  
  1729.   dialogdata = MID_WIN_DIALOGS_BUTTONS;
  1730.   WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH1_DLG, (PVOID) &dialogdata ) );
  1731.   dialogdata = MID_WIN_DIALOGS_ENTRYS;
  1732.   WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH2_DLG, (PVOID) &dialogdata ) );
  1733.   dialogdata = MID_WIN_DIALOGS_LISTBOX;
  1734.   WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH3_DLG, (PVOID) &dialogdata ) );
  1735.   dialogdata = MID_WIN_DIALOGS_SCROLLB;
  1736.   WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH4_DLG, (PVOID) &dialogdata ) );
  1737.   dialogdata = MID_WIN_DIALOGS_STATICS;
  1738.   WinProcessDlg( WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, (PFNWP) BenchDlgProc, (HMODULE) NULL, DID_BENCH5_DLG, (PVOID) &dialogdata ) );
  1739. }
  1740.  
  1741.  
  1742. /* This functions toggles the attributes of each menuitem in the actionbar.
  1743.    Everything works real fine, but MIA_CHECKED don∩t work. Why ? */
  1744.  
  1745. VOID do_win_menus_attrib( HWND hwnd )
  1746. {
  1747.   int i,j,k;
  1748.   SHORT mia[4] = { MIA_CHECKED, MIA_DISABLED, MIA_FRAMED, MIA_HILITED };
  1749.  
  1750.   for (i=0; i<4; i++) {
  1751.       for (j=1100; j<1900; j+=100) {
  1752.           for (k=0; k<10; k++ ) {
  1753.               ToggleMenuAttr( hwnd, 0, j, mia[i] );
  1754.               ToggleMenuAttr( hwnd, 0, j, mia[i] );
  1755.           }
  1756.       }
  1757.   }
  1758.  
  1759. }
  1760.  
  1761. VOID do_win_menus_bitmap( HWND hwnd )
  1762. {
  1763.   MENUITEM mi;
  1764.   SHORT retvalue;
  1765.   HWND menu;
  1766.   HBITMAP hBmp1, hBmp2;
  1767.   HPS hps;
  1768.   int i;
  1769.  
  1770.   hps   = WinGetPS( hwnd );
  1771.   hBmp1 = GpiLoadBitmap( hps, (HMODULE) NULL, MID_BMP1, 64L, 64L );
  1772.   hBmp2 = GpiLoadBitmap( hps, (HMODULE) NULL, MID_BMP2, 64L, 64L );
  1773.   WinReleasePS( hps );
  1774.  
  1775.   mi.iPosition   = MIT_END; 
  1776.   mi.afStyle     = MIS_BITMAP;    /* A bitmap menuitem will be inserted */
  1777.   mi.afAttribute = 0;
  1778.   mi.id          = MID_NEWITEM;  
  1779.   mi.hwndSubMenu = (HWND) NULL;   /* Specify a SubMenu handle if the menuitem is inserted in Submenu ! */
  1780.   mi.hItem       = (ULONG) hBmp1;
  1781.  
  1782.   menu = WinWindowFromID( hwnd, FID_MENU ); /* You may use FID_SYSMENU to effect the System menu here */
  1783.  
  1784.   retvalue = (SHORT) WinSendMsg( menu, MM_INSERTITEM, (MPARAM) &mi, MPFROMP( (PSZ) "~Bitmaps" ) );
  1785.  
  1786.   for (i=0; i<10; i++ ) {
  1787.       WinSendMsg( menu, MM_SETITEMHANDLE, MPFROMSHORT( MID_NEWITEM ), MPFROMLONG( (ULONG) hBmp1 ) );
  1788.       WinSendMsg( menu, MM_SETITEMHANDLE, MPFROMSHORT( MID_NEWITEM ), MPFROMLONG( (ULONG) hBmp2 ) );
  1789.  
  1790. /* you may also use :
  1791.       mi.hItem = (ULONG) hBmp2;
  1792.       WinSendMsg( menu, MM_SETITEM, (MPARAM) NULL, (MPARAM) &mi );
  1793.       mi.hItem = (ULONG) hBmp1;
  1794.       WinSendMsg( menu, MM_SETITEM, (MPARAM) NULL, (MPARAM) &mi );
  1795.    if you like ... */
  1796.  
  1797.   }
  1798.  
  1799.   WinSendMsg( menu, MM_DELETEITEM, MPFROM2SHORT(MID_NEWITEM, FALSE), (MPARAM) NULL );
  1800.  
  1801. }
  1802.  
  1803. VOID do_win_menus_items( HWND hwnd )
  1804. {
  1805.   MENUITEM mi;
  1806.   SHORT retvalue;
  1807.   HWND menu;
  1808.   int i,j;
  1809.  
  1810.   CHAR menutext[10][3]= { "~0", "~1", "~2", "~3", "~4", "~5", "~6", "~7", "~8", "~9" };
  1811.  
  1812.   mi.iPosition   = MIT_END; 
  1813.   mi.afStyle     = MIS_TEXT;    /* A simple menuitem is used first */
  1814.   mi.afAttribute = 0;
  1815.   mi.id          = MID_NEWITEM;  
  1816.   mi.hwndSubMenu = (HWND) NULL; /* Specify a SubMenu handle if the menuitem is inserted in Submenu ! */
  1817.   mi.hItem       = NULL; /* We have MIS_TEXT menuitem, so no handle is used */
  1818.  
  1819.   menu = WinWindowFromID( hwnd, FID_MENU ); /* You may use FID_SYSMENU to effect the System menu here */
  1820.  
  1821.   for (j=0; j<10; j++ ) {
  1822.       for (i=0; i<10; i++ ) {
  1823.           mi.id = MID_NEWITEM + i;
  1824.           retvalue = (SHORT) WinSendMsg( menu, MM_INSERTITEM, (MPARAM) &mi, MPFROMP( (PSZ) menutext[i] ) );
  1825.       }
  1826.       for (i=9; i>=0; i-- ) {
  1827.          WinSendMsg( menu, MM_DELETEITEM, MPFROM2SHORT(MID_NEWITEM + i, FALSE), (MPARAM) NULL );
  1828.       }
  1829.   }
  1830. }
  1831.  
  1832. VOID do_win_menus_show( HWND hwnd )
  1833. {
  1834.   HWND menu;
  1835.   int i,j;
  1836.  
  1837.   menu = WinWindowFromID( hwnd, FID_MENU );
  1838.  
  1839.   for (i=0; i<10; i++) {
  1840.       for (j=1100; j<1900; j+=100) {
  1841.           WinSendMsg( menu, MM_SELECTITEM, MPFROM2SHORT( (USHORT) j, FALSE), MPFROMSHORT( FALSE ) );
  1842.       }
  1843.   }
  1844.  
  1845. }
  1846.  
  1847. VOID do_win_menus_all( HWND hwnd )
  1848. {
  1849.   do_win_menus_attrib( hwnd );
  1850.   do_win_menus_bitmap( hwnd );
  1851.   do_win_menus_items ( hwnd );
  1852.   do_win_menus_show  ( hwnd );
  1853. }
  1854.  
  1855. VOID do_win_all( HWND hwnd )
  1856. {
  1857.   do_win_menus_all( hwnd );
  1858.   do_win_dialog_all( hwnd );
  1859. }
  1860.  
  1861.  
  1862. /* The helping hand */
  1863.  
  1864. /* Toggle the MIA_??? Attributes of your mneuitems with this function */
  1865.  
  1866. ToggleMenuAttr(HWND frame, USHORT flags, SHORT id, SHORT mia_id )
  1867. {
  1868.   HWND menu,submenu;                     /* menu handle and submenu handle */
  1869.   MENUITEM submenuinfo;                  /* information of the menuitem    */
  1870.   SHORT oldvalue,newvalue;               /* old and new attribute value    */
  1871.   BOOL submenues, sysmenu, ok;
  1872.  
  1873.   submenues = (flags & TMA_INC_SUBMENU);
  1874.   sysmenu   = (flags & TMA_INC_SYSMENU);
  1875.  
  1876.   if ( sysmenu ) {
  1877.      menu = WinWindowFromID( frame, FID_SYSMENU );     /* get the system menu handle */
  1878.   }
  1879.   else {
  1880.      menu = WinWindowFromID( frame, FID_MENU );        /* get the action bar menu handle */
  1881.   }
  1882.  
  1883.   if ( submenues ) {                                /* include submenues ? */
  1884.      WinSendMsg( menu, MM_QUERYITEM, MPFROM2SHORT( id, submenues ), (MPARAM) &submenuinfo ); /* info of menuitem */
  1885.      submenu = submenuinfo.hwndSubMenu;          /* save handle of submenu */
  1886.   }
  1887.   else {                                                   /* no submenues */
  1888.      submenu = menu;
  1889.   }
  1890.  
  1891.   oldvalue = (SHORT) WinSendMsg( submenu, MM_QUERYITEMATTR, MPFROM2SHORT( id, submenues ), MPFROMSHORT( mia_id ) ); /* retrieve old value */
  1892.   newvalue = oldvalue ^ mia_id; /* toggle value */
  1893.   ok = (BOOL) WinSendMsg( submenu, MM_SETITEMATTR, MPFROM2SHORT(id, submenues ),  MPFROM2SHORT(mia_id, newvalue) );
  1894.  
  1895.   return oldvalue;
  1896. }
  1897.  
  1898. BOOL GpiSetFont (HPS hps, LONG fontid, CHAR *fontname)
  1899. {
  1900.   FATTRS fat;
  1901.   BOOL ok;
  1902.  
  1903.   fat.usRecordLength  = sizeof(fat);
  1904.   fat.fsSelection     = 0;
  1905.   fat.lMatch          = 0;
  1906.   fat.idRegistry      = 0;
  1907.   fat.usCodePage      = GpiQueryCp(hps); /* get the Codepage */
  1908.   fat.lMaxBaselineExt = 0;
  1909.   fat.lAveCharWidth   = 0;
  1910.   fat.fsType          = 0;
  1911.   fat.fsFontUse       = FATTR_FONTUSE_OUTLINE | FATTR_FONTUSE_TRANSFORMABLE;
  1912.   strcpy (fat.szFacename, fontname);  /* Save the fontname */
  1913.  
  1914.   if (ok = GpiCreateLogFont( hps, (PSTR8) NULL, fontid, &fat )) /* Create the font */
  1915.      ok = GpiSetCharSet( hps, fontid ); /* make the font the active font */
  1916.  
  1917.   return ok;
  1918. }
  1919.  
  1920.  
  1921. /* Set the character box size using point-sizes. The pointsize is a multiple
  1922.    of 10. For example:  12 Points  equals 120. For more information look at
  1923.    the VECTFONT-Sample by Charles Petzold */
  1924.  
  1925. BOOL GpiSetCharPointSize(HPS hps, SHORT pointwidth, SHORT pointhight)
  1926. {
  1927.   HDC    hdc;                   /* you need a device context */
  1928.   LONG   dev_width, dev_hight;  /* physical device resolution */
  1929.   POINTL pkt;                   /* Use GpiConvert() to calculate for you */
  1930.   SIZEF  size;                  /* store the size of the font here */
  1931.  
  1932.   hdc = GpiQueryDevice (hps) ;  /* get the device context */
  1933.  
  1934.   DevQueryCaps( hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &dev_width ); /* get the width */
  1935.   DevQueryCaps( hdc, CAPS_VERTICAL_RESOLUTION,   1L, &dev_hight ); /* and high of your graphics card in pels */
  1936.  
  1937.   pkt.x = 254L * pointwidth * dev_width / 7200000L ; /* calculate the world coordinates */
  1938.   pkt.y = 254L * pointhight * dev_hight / 7200000L ; /* of the fontsize and store it as a point */ 
  1939.  
  1940.   GpiConvert( hps, CVTC_DEVICE, CVTC_PAGE, 1L, &pkt ); /* convert the point now */
  1941.  
  1942.   size.cx = MAKEFIXED( pkt.x, 0 );  /* save the converted values */
  1943.   size.cy = MAKEFIXED( pkt.y, 0 );
  1944.  
  1945.   return GpiSetCharBox( hps, &size ); /* and size the character box */
  1946. }
  1947.  
  1948. BOOL GpiSetCharSelection(HPS hps, LONG fontid, CHAR *fontname, SHORT select)
  1949. {
  1950.   FATTRS fat;
  1951.   BOOL ok;
  1952.  
  1953.   fat.usRecordLength  = sizeof(fat);
  1954.   fat.fsSelection     = select;
  1955.   fat.lMatch          = 0;
  1956.   fat.idRegistry      = 0;
  1957.   fat.usCodePage      = GpiQueryCp(hps); /* get the Codepage */
  1958.   fat.lMaxBaselineExt = 0;
  1959.   fat.lAveCharWidth   = 0;
  1960.   fat.fsType          = 0;
  1961.   fat.fsFontUse       = FATTR_FONTUSE_OUTLINE | FATTR_FONTUSE_TRANSFORMABLE;
  1962.   strcpy (fat.szFacename, fontname);  /* Save the fontname */
  1963.  
  1964.   if (ok = GpiCreateLogFont( hps, (PSTR8) NULL, fontid, &fat )) /* Create the font */
  1965.      ok = GpiSetCharSet( hps, fontid ); /* make the font the active font */
  1966.  
  1967.   return ok;
  1968. }
  1969.  
  1970.  
  1971.