home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / notebook / vportdlg / vportdlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  2.1 KB  |  66 lines

  1. //************************************************************
  2. // Notebook Control - Adding Notebook Windows to a Viewport
  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 <inotebk.hpp>
  9. #include <iframe.hpp>
  10. #include <iapp.hpp>
  11. #include <ihandle.hpp>
  12. #include <ifont.hpp>
  13. #include <ipoint.hpp>
  14. #include <ivport.hpp>
  15. #include <icolor.hpp>
  16. #include <icconst.h>
  17. #include "deferacc.hpp"
  18. #include "vportdlg.h"
  19.  
  20. void main()
  21. {
  22.   // Create the frame, notebook, and view port.
  23.   IFrameWindow frame ("ViewPort Notebook");
  24.   INotebook    notebook (IC_FRAME_CLIENT_ID, &frame, &frame);
  25.   IViewPort    viewport (0x102, ¬ebook, ¬ebook);
  26.  
  27.   // Set the window and the page to the
  28.   // color of a dialog background.
  29.   viewport.setBackgroundColor(
  30.               IGUIColor(IGUIColor::dialogBgnd));
  31.   notebook
  32.     .setPageBackgroundColor(
  33.               IGUIColor(IGUIColor::dialogBgnd))
  34.     .setMajorTabBackgroundColor(
  35.               IGUIColor(IGUIColor::dialogBgnd));
  36.  
  37.   // Create a dialog on the view port
  38.   IFrameWindow dialog1(ID_DIALOG1, &viewport, &viewport);
  39.   DeferAccelerators accelHdr;
  40.   accelHdr.handleEventsFor(&dialog1);
  41.  
  42.   // Declare a page settings with text, major tab, and
  43.   // a dialog.
  44.   INotebook::PageSettings pageData =
  45.                  INotebook::PageSettings (
  46.                          "dialog1",
  47.                          "Page 1",
  48.                          INotebook::PageSettings::autoPageSize |
  49.                          INotebook::PageSettings::statusTextOn |
  50.                          INotebook::PageSettings::majorTab);
  51.   notebook.addLastPage( pageData, &viewport);
  52.  
  53.   // Make sure the tabs are big enough.
  54.   IFont noteFont(¬ebook);
  55.   ISize tabSize(ISize(noteFont.minTextWidth("Page_1"),
  56.                 noteFont.maxCharHeight()) + ISize(6,6));
  57.   notebook.setMajorTabSize(tabSize);
  58.  
  59.   // Set the client and show the window.
  60.   frame
  61.     .setClient(¬ebook)
  62.     .show();
  63.   IApplication::current().run();
  64. }
  65.  
  66.