home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2BAS.ZIP / GPIMARK.BAS < prev    next >
BASIC Source File  |  1989-09-07  |  6KB  |  162 lines

  1. '***********************************************************
  2. '*
  3. '* Program Name: GpiMark.BAS
  4. '*
  5. '* Include File: GpiMark.BI
  6. '*
  7. '* Functions   : GpiSetMarkerSet
  8. '*               GpiQueryMarkerSet
  9. '*               GpiSetMarker
  10. '*               GpiQueryMarker
  11. '*               GpiSetMarkerBox
  12. '*               GpiQueryMarkerBox
  13. '*               GpiMarker     not demonstrated (Same as GpiPolyMarker)
  14. '*               GpiPolyMarker
  15. '*
  16. '* Description : This program demomstrates the routines contained
  17. '*               in GpiMark.BI.  It demonstrates the default
  18. '*               marker set only, which are image markers.
  19. '*               Ten lines are drawn containing 4 points each
  20. '*               using a different marker for each line.  The
  21. '*               lines are drawn proportional to the current
  22. '*               window size.
  23. '***********************************************************
  24.  
  25. '*********         Initialization section        ***********
  26.  
  27. REM $INCLUDE: 'OS2Def.BI'
  28. REM $INCLUDE: 'PMBase.BI'
  29. REM $INCLUDE: 'WinMan1.BI'         Needed for WinInvalidateRect
  30. REM $INCLUDE: 'GpiCont.BI'         Needed for GpiErase
  31. REM $INCLUDE: 'GpiLine.BI'         Needed for GpiMove and GpiLine
  32. REM $INCLUDE: 'GpiMark.BI'
  33.  
  34. DECLARE SUB ScreenPaint(hwnd&)
  35. DIM aqmsg AS QMSG
  36.  
  37. flFrameFlags& =  FCFTITLEBAR      OR FCFSYSMENU OR _
  38.                  FCFSIZEBORDER    OR FCFMINMAX  OR _
  39.                  FCFSHELLPOSITION OR FCFTASKLIST
  40.  
  41. szClientClass$ = "ClassName" + CHR$(0)
  42.  
  43. hab&  = WinInitialize    (0)
  44. hmq&  = WinCreateMsgQueue(hab&, 0)
  45.  
  46. bool% = WinRegisterClass(_
  47.         hab&,_
  48.         MakeLong(VARSEG(szClientClass$), SADD(szClientClass$)),_
  49.         RegBas,_
  50.         CSSIZEREDRAW,_
  51.         0)
  52.  
  53. hwndFrame& = WinCreateStdWindow (_
  54.              HWNDDESKTOP,_
  55.              WSVISIBLE,_
  56.              MakeLong (VARSEG(flFrameFlags&),  VARPTR(flFrameFlags&)),_
  57.              MakeLong (VARSEG(szClientClass$), SADD(szClientClass$)),_
  58.              0,_
  59.              0,_
  60.              0,_
  61.              0,_
  62.              MakeLong (VARSEG(hwndClient&), VARPTR(hwndClient&)))
  63.  
  64. '**************         Message loop         ***************
  65.  
  66. WHILE WinGetMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)), 0, 0, 0)
  67.   bool% = WinDispatchMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)))
  68. WEND
  69.  
  70. '***********         Finalize section        ***************
  71.  
  72. bool% = WinDestroyWindow   (hwndFrame&)
  73. bool% = WinDestroyMsgQueue (hmq&)
  74. bool% = WinTerminate       (hab&)
  75.  
  76. END
  77.  
  78. '***********         Window procedure        ***************
  79.  
  80. FUNCTION ClientWndProc& (hwnd&, msg%, mp1&, mp2&) STATIC
  81. SHARED cxClient%, cyClient%
  82.  
  83.   ClientWndProc&=0
  84.   SELECT CASE msg%
  85.     CASE WMSIZE
  86.       CALL BreakLong(mp2&, cyClient%, cxClient%)
  87.     CASE WMPAINT
  88.       bool% = WinInvalidateRect%(hwnd&, 0, 0)
  89.       CALL ScreenPaint(hwnd&)
  90.     CASE ELSE
  91.       ClientWndProc& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  92.   END SELECT
  93.  
  94. END FUNCTION
  95. '**********************************************************************
  96. '*                                                                    *
  97. '* SUBprogram ScreenPaint:  Called from ClientWndProc& when a WMPAINT *
  98. '*                          message is received.                      *
  99. '*                                                                    *
  100. '**********************************************************************
  101. SUB ScreenPaint(hwnd&)
  102. SHARED cxClient%, cyClient%
  103. DIM ptl(3) AS POINTL
  104.  
  105.   hps&  = WinBeginPaint(hwnd&, 0, 0)
  106.   bool% = GpiErase     (hps&)
  107. '*
  108. '* GpiSetMarkerBox and GpiQueryMarkerBox are only used when a vector
  109. '* font has been selected.  This example program only demonstrates the
  110. '* default marker set which are image markers, so the following two calls
  111. '* have no affect on the program.
  112. '*
  113.   bool% = GpiSetMarkerBox  (hps&, MakeLong(VARSEG(ptl(0)), VARPTR(ptl(0))))
  114.   bool% = GpiQueryMarkerBox(hps&, MakeLong(VARSEG(ptl(0)), VARPTR(ptl(0))))
  115. '*
  116. '* Initialize ptl(0) with points to draw line with and locations
  117. '* to draw markers
  118. '*
  119.   ptl(0).x = 0                  : ptl(0).y = 0
  120.   ptl(1).x = cxClient% / 20     : ptl(1).y = cyClient% / 4
  121.   ptl(2).x = cxClient% / 20 * 3 : ptl(2).y = cyClient% / 2
  122.   ptl(3).x = cxClient% / 20 * 8 : ptl(3).y = cyClient% / 4 * 3
  123. '*
  124. '* Selects default marker set, then draws 10 lines consisting of 4 points
  125. '* each, using a different default marker (marker%) for each line.
  126. '* "marker%" corresponds to the CONST marker types declared in GpiMark.BI      :
  127. '*
  128. '*              CONST  MARKSYMERROR      =    -1   (not demonstated)
  129. '*              CONST  MARKSYMDEFAULT      =    0    (not demonstated)
  130. '*              CONST  MARKSYMCROSS      =    1
  131. '*              CONST  MARKSYMPLUS      =    2
  132. '*              CONST  MARKSYMDIAMOND      =    3
  133. '*              CONST  MARKSYMSQUARE      =    4
  134. '*              CONST  MARKSYMSIXPOINTSTAR  =  5
  135. '*              CONST  MARKSYMEIGHTPOINTSTAR = 6
  136. '*              CONST  MARKSYMSOLIDDIAMOND  =  7
  137. '*              CONST  MARKSYMSOLIDSQUARE   =  8
  138. '*              CONST  MARKSYMDOT        =  9
  139. '*              CONST  MARKSYMSMALLCIRCLE   =  10
  140. '*              CONST  MARKSYMBLANK        =  64   (not demonstrated)
  141.  
  142.   bool% = GpiSetMarkerSet  (hps&, LCIDDEFAULT)
  143.   mset% = GpiQueryMarkerSet(hps&)        'JUST TO ILLUSTRATE GpiQueryMarkerSet
  144.   FOR marker% = 1 to 10
  145.     bool%   = GpiSetMarker  (hps&, marker%)
  146.     marker% = GpiQueryMarker(hps&)       'JUST TO ILLUSTRATE GpiQueryMarker
  147.     bool%   = GpiMove       (hps&,    MakeLong(VARSEG(ptl(0)), VARPTR(ptl(0))))
  148.     bool%   = GpiPolyLine   (hps&, 3, MakeLong(VARSEG(ptl(1)), VARPTR(ptl(1))))
  149.     bool%   = GpiPolyMarker (hps&, 3, MakeLong(VARSEG(ptl(1)), VARPTR(ptl(1))))
  150. '*
  151. '* Increment X values to move line to the right
  152. '*
  153.     ptl(0).x = ptl(0).x + cxClient% / 16
  154.     ptl(1).x = ptl(1).x + cxClient% / 16
  155.     ptl(2).x = ptl(2).x + cxClient% / 16
  156.     ptl(3).x = ptl(3).x + cxClient% / 16
  157.   NEXT marker%
  158.  
  159.   bool% = WinEndPaint(hps&)
  160.  
  161. END SUB
  162.