drawos2.for

来自「开放源码的编译器open watcom 1.6.0版的源代码」· FOR 代码 · 共 504 行 · 第 1/2 页

FOR
504
字号
      if(WinIntersectRect(Main_hab,intersect,paint,Draw_area)) then
c$ifdef DRAW_ALL_AT_ONCE
            width = Draw_area.xRight - Draw_area.xLeft
            height = Draw_area.yTop - Draw_area.yBottom
            interior.xLeft = 0
            interior.yBottom = 0
            interior.xRight = width
            interior.yTop = height
            if( Draw_bitmap .eq. NULLHANDLE ) then
               Hdc = DevOpenDC(Main_hab, OD_MEMORY, '*'//char(0), 5,
     &            dop, NULLHANDLE )
               Mem_dc = GpiCreatePS( Main_hab, Hdc, sizl,
     &                  ( PU_PELS .or. GPIA_ASSOC ) )
         call memclear(loc(bmih), 0, isizeof(BITMAPINFOHEADER2))
               call GpiQueryDeviceBitmapFormats(Mem_dc, 24, formats)
               bmih.cbFix = isizeof( BITMAPINFOHEADER2 )
               bmih.cx = width
               bmih.cy = height
               bmih.cPlanes = formats( 0 )
               bmih.cBitCount = formats( 1 )
               Draw_bitmap = GpiCreateBitmap( Mem_dc, bmih, 0, 0, 0 )
               Old_bitmap = GpiSetBitmap( Mem_dc, Draw_bitmap )
               GpiCreateLogColorTable( Mem_dc, 0, LCOLF_RGB, 0, 0, 0)
               WinFillRect( Mem_dc, interior, SYSCLR_WINDOW )

               hour_glass_cur = WinQuerySysPointer( HWND_DESKTOP,
     &                       SPTR_WAIT, 0 )
               old_cursor = WinQueryPointer( HWND_DESKTOP )
               call WinSetPointer( HWND_DESKTOP, hour_glass_cur )

               hThree_d = three_d_begin( Mem_dc, &interior )
               call draw_room()
               call three_d_draw( hThree_d )
               call three_d_end( hThree_d )

               call WinSetPointer( HWND_DESKTOP, old_cursor )
            endif

            pts(0).x = Draw_area.xLeft
            pts(0).y = Draw_area.yBottom
            pts(1).x = Draw_area.xLeft + width
            pts(1).y = Draw_area.yBottom + height
            pts(2).x = 0
            pts(2).y = 0
            call GpiBitBlt(win_dc,Mem_dc,3,pts,ROP_SRCCOPY,BBO_IGNORE)
c$else
            hThree_d = three_d_begin( win_dc, Draw_area )
            call draw_room()
            call three_d_draw( hThree_d )
            call three_d_end( hThree_d )
c$endif
      endif
      call WinEndPaint( win_dc )
      end


c$pragma aux (__syscall) main_proc parm( value, value, value, value )
      integer function main_proc( hwnd, msg, mp1, mp2 )
      integer hwnd
      integer msg
      integer mp1
      integer mp2

        include 'drawos2.fi'
      include 'threed.fi'

      logical  ltmp
        integer count
        integer will_be_one
      record /CREATESTRUCT/  pcreate(:)

      if( msg .eq. WM_CREATE ) then
            allocate( pcreate( 1 ), location = mp2 )
            Draw_area.xRight = pcreate(1).x + pcreate(1).cx
            Draw_area.yTop = pcreate(1).y + pcreate(1).cy
            Draw_area.yBottom = pcreate(1).y
            Draw_area.xLeft = pcreate(1).x
            call WinQueryWindowRect( hwnd, Draw_area )

      else if( (msg .eq. WM_COMMAND) .or.
     &          ( (msg .eq. WM_CONTROL) .and.
     &       (SHORT2FROMMP( mp1 ) .ne. BN_PAINT) ) ) then

            select( SHORT1FROMMP( mp1 ) )
            case( IDM_EXIT )
                call new_display()
                call WinPostMsg( hwnd, WM_QUIT, 0, 0 )
                main_proc = 0
                return
            case( IDM_ROTATE_LEFT )
                call new_display()
                call add_wrap( THREE_D_HORZ_ANGLE, -15, 0, 360 )
            case( IDM_ROTATE_RIGHT )
                call new_display()
                call add_wrap( THREE_D_HORZ_ANGLE, 15, 0, 360 )
            case( IDM_ROTATE_UP )
                call new_display()
                call add_range( THREE_D_VERT_ANGLE, 5, -90, 90 )
            case( IDM_ROTATE_DOWN )
                call new_display()
                call add_range( THREE_D_VERT_ANGLE, -5, -90, 90 )
            case( IDM_MOVE_IN )
                call new_display()
                call add_range(THREE_D_ZOOM, 10, 5, 200 )
            case( IDM_MOVE_OUT )
                call new_display()
                call add_range( THREE_D_ZOOM, -10, 5, 200 )
            case( IDM_MORE_PERSPECTIVE )
                call new_display()
                call add_range( THREE_D_PERSPECTIVE, 10, 5, 200 )
            case( IDM_LESS_PERSPECTIVE )
                call new_display()
                call add_range( THREE_D_PERSPECTIVE, -10, 5, 200 )
            case( IDM_MORE_CONTRAST )
                call new_display()
                call add_range( THREE_D_CONTRAST, 10, 0, 100 )
            case( IDM_LESS_CONTRAST )
                call new_display()
                call add_range( THREE_D_CONTRAST, -10, 0, 100 )
            case( IDM_MORE_BRIGHTNESS )
                call new_display()
                call add_range( THREE_D_BRIGHTNESS, 10, 0, 100 )
            case( IDM_LESS_BRIGHTNESS )
                call new_display()
                call add_range( THREE_D_BRIGHTNESS, -10, 0, 100 )
            case( IDM_LIGHT_HORZ_LEFT )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 1 )
            case( IDM_LIGHT_HORZ_MIDDLE )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 2 )
            case( IDM_LIGHT_HORZ_RIGHT )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 3 )
            case( IDM_LIGHT_VERT_TOP )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_VERT, 1 )
            case( IDM_LIGHT_VERT_MIDDLE )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_VERT, 2 )
            case( IDM_LIGHT_VERT_BOTTOM )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_VERT, 3 )
            case( IDM_LIGHT_DEPTH_FRONT )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 1 )
            case( IDM_LIGHT_DEPTH_MIDDLE )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 2 )
            case( IDM_LIGHT_DEPTH_BACK )
                call new_display()
                call three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 3 )
          end select
            ltmp = SHORT1FROMMP(mp1) .ge. IDM_FIRST_REQUIRING_CLEAR
            call WinInvalidateRect( hwnd, Draw_area, ltmp )

      else if( msg .eq. WM_DESTROY ) then
            call WinPostMsg( hwnd, WM_QUIT, 0, 0 )
            main_proc = FALSE
          return

      else if( msg .eq. WM_PAINT ) then
            call draw_stuff( hwnd )
            if( Auto_run .ne. 0 ) then
                if( Auto_run .eq. 5 ) then
                    call WinPostMsg( hwnd, WM_QUIT, 0, 0 )
                else
                    will_be_one = 1
             count = 0
             while( count .lt. 1000000 ) do
             will_be_one = will_be_one .xor. 1
             count = count + 1
             end while
                    Auto_run = Auto_run + will_be_one
                    call WinPostMsg( hwnd, WM_COMMAND,
     &                          MPFROMSHORT( IDM_ROTATE_LEFT ),
     &                 0 )
         endif
            endif
          main_proc = FALSE
            return

      else if( msg .eq. WM_SIZE ) then
            call WinQueryWindowRect( hwnd, Draw_area )
            Draw_area.yTop = Draw_area.yTop - Button_height
            call WinInvalidateRect( hwnd, 0, 1 )
          main_proc = FALSE
            return

      else if( msg .eq. WM_MEASUREITEM ) then
            main_proc = measure_button( hwnd, mp1, mp2 )
            return

        else if( (msg .eq. WM_CONTROL) .and.
     &         (SHORT2FROMMP(mp1) .eq. BN_PAINT) ) then
            call draw_button( mp1, mp2 )
            main_proc = TRUE
            return
      endif
        main_proc = WinDefWindowProc( hwnd, msg, mp1, mp2 )
      end


      integer function init_instance( show )
      integer show

        include 'drawos2.fi'

      integer frame_hwnd
      integer flags

      flags = FCF_SIZEBORDER .or. FCF_TITLEBAR .or. FCF_SYSMENU .or.
     &      FCF_MENU .or. FCF_MINMAX .or. FCF_SHELLPOSITION

      frame_hwnd = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE,
     &                flags, 'DrawDemo'//char(0),
     &                'Draw a Picture'//char(0),
     &                WS_VISIBLE, 0, 200, Main_hwnd)

      ! If window could not be created, return 'failure'

      if( ( Main_hwnd .eq. 0 ) .or. ( frame_hwnd .eq. 0 ) ) then
          init_instance = FALSE
            return
      endif

      ! Make the window visible
      ! update its client area
      ! and return 'success'

      call WinSetWindowPos( frame_hwnd, HWND_TOP, 50, 50, 200, 200,
     &               show )

      call make_buttons( Main_hwnd)
      call WinShowWindow( frame_hwnd, TRUE )
      call WinUpdateWindow( frame_hwnd )

      init_instance = TRUE
      end


      integer function init_app( hab )
      integer hab

        include 'drawos2.fi'
      external main_proc

      ! Register the window class and return success/failure code.
      init_app=WinRegisterClass(hab, 'DrawDemo'//char(0), main_proc,
     &              NULL, 0 )
      end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?