home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pwrgu2.zip / POWERGU2.EXE / CANVAS / VPORTBMP / VPORTBMP.CPP < prev    next >
Text File  |  1995-07-25  |  2KB  |  60 lines

  1. //************************************************************
  2. // Canvas - IViewPort that Scrolls a Bitmap.
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // All Rights Reserved.
  6. //************************************************************
  7. #include <iapp.hpp>
  8. #include <iframe.hpp>
  9. #include <iscroll.hpp>
  10. #include "vportbmp.hpp"
  11. #include <icconst.h>
  12.  
  13. void main ( )
  14. {
  15.   // Create the frame window and its client view port.
  16.   IFrameWindow frame( IFrameWindow::classDefaultStyle
  17.                         | IFrameWindow::menuBar );
  18.   IViewPort vport( IC_FRAME_CLIENT_ID, &frame, &frame, IRectangle(),
  19.                    IViewPort::classDefaultStyle
  20.                      & ~IViewPort::asNeededHorizontalScrollBar
  21.                      & ~IViewPort::asNeededVerticalScrollBar
  22.                      | IViewPort::alwaysHorizontalScrollBar
  23.                      | IViewPort::alwaysVerticalScrollBar
  24. #if IC_MAJOR_VERSION >= 201
  25.                      | IViewPort::noViewWindowFill );
  26. #else
  27.                      );
  28. #endif
  29.   unsigned long scrollIncrement =
  30.            vport.verticalScrollBar()->minScrollIncrement() * 2;
  31.   (*(vport.verticalScrollBar()))
  32.     .setMinScrollIncrement( scrollIncrement )
  33.     .sizeTo( ISize( IScrollBar::systemScrollBarWidth(true)
  34.                                                  * 3 / 2, 0 ));
  35.   (*(vport.horizontalScrollBar()))
  36.     .setMinScrollIncrement( scrollIncrement )
  37.     .sizeTo( ISize( 0,
  38.                     IScrollBar::systemScrollBarWidth(false)
  39.                                                     * 3 / 2 ));
  40.  
  41. #if IC_MAJOR_VERSION >= 201
  42.   IBitmapControl bmp( 1, &vport, &vport, ID_DEFAULTBMP,
  43. #else
  44.   IBitmapControl bmp( 1, &vport, &vport,
  45.                       IResourceId(ID_DEFAULTBMP),
  46. #endif
  47.                       IWindow::desktopWindow()->size() / 2 );
  48.  
  49.   NewBitmapCmdHandler cmdHdr1( &bmp );
  50.   cmdHdr1.handleEventsFor( &vport );
  51.   SizeBitmapCmdHandler cmdHdr2( &bmp, &vport );
  52.   cmdHdr2.handleEventsFor( &vport );
  53.   ScrollViewCmdHandler cmdHdr3( &vport );
  54.   cmdHdr3.handleEventsFor( &vport );
  55.  
  56.   // Show it all now.
  57.   frame.setFocus().show();
  58.   IApplication::current().run();
  59. }  // main()
  60.