home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / canvas / vportbmp / vportbmp.cpp < prev    next >
Text File  |  1996-10-29  |  2KB  |  75 lines

  1. //*********************************************************
  2. // Canvas - IViewPort that Scrolls a Bitmap
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //*********************************************************
  8. #include <iapp.hpp>
  9. #include <icconst.h>
  10. #include <ibmpctl.hpp>
  11. #include <iframe.hpp>
  12. #include <iscroll.hpp>
  13. #include <ivport.hpp>
  14. #include "vportcmd.hpp"
  15. #include "vportbmp.h"
  16.  
  17. void main ( )
  18. {
  19.   // Create the frame window and its client view port.
  20.   IFrameWindow
  21.     frame( IFrameWindow::classDefaultStyle
  22.              | IFrameWindow::menuBar );
  23.   IViewPort
  24.     vport( IC_FRAME_CLIENT_ID, &frame, &frame, IRectangle(),
  25.            IViewPort::classDefaultStyle
  26.              & ~IViewPort::asNeededHorizontalScrollBar
  27.              & ~IViewPort::asNeededVerticalScrollBar
  28.              | IViewPort::alwaysHorizontalScrollBar
  29.              | IViewPort::alwaysVerticalScrollBar
  30.              | IViewPort::noViewWindowFill );
  31.  
  32.   // Set up the bitmap for the view port to scroll.  We make it
  33.   // the view window by making it the child window of the view
  34.   // port.  By not sizing the view window, the view port sizes
  35.   // it to its minimum size.
  36.   IBitmapControl
  37.     bmp( 1, &vport, &vport, ID_DEFAULT_BMP );
  38.  
  39.   // Double the amount of a "line" scroll and increase by half
  40.   // the width of the scroll bars.
  41.   unsigned long
  42.     scrollIncrement =
  43.            vport.verticalScrollBar()->minScrollIncrement() * 2;
  44.   ( *( vport.verticalScrollBar() ) )
  45.     .setMinScrollIncrement( scrollIncrement )
  46.     .sizeTo( ISize( IScrollBar::systemScrollBarWidth( true )
  47.                                                 * 3 / 2, 0 ) );
  48.   ( *( vport.horizontalScrollBar() ) )
  49.     .setMinScrollIncrement( scrollIncrement )
  50.     .sizeTo( ISize( 0,
  51.                     IScrollBar::systemScrollBarWidth( false )
  52.                                                    * 3 / 2 ) );
  53.  
  54.   // Add command handlers for the menu bar choices.
  55.   NewBitmapCmdHandler
  56.     cmdHdr1( &bmp );
  57.   cmdHdr1
  58.    .handleEventsFor( &vport );
  59.   SizeBitmapCmdHandler
  60.     cmdHdr2( &bmp, &vport );
  61.   cmdHdr2
  62.    .handleEventsFor( &vport );
  63.   ScrollViewCmdHandler
  64.     cmdHdr3( &vport );
  65.   cmdHdr3
  66.    .handleEventsFor( &vport );
  67.  
  68.   // Show it all now.
  69.   frame
  70.    .setFocus()
  71.    .show();
  72.  
  73.   IApplication::current().run();
  74. }
  75.