home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / APXOLE.PAK / APXOLOLV.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.7 KB  |  152 lines

  1. //----------------------------------------------------------------------------
  2. //  Project ApxOle
  3. //  Borland International
  4. //  Copyright ⌐ 1996. All Rights Reserved.
  5. //
  6. //  SUBSYSTEM:    ApxOle Application
  7. //  FILE:         apxololv.cpp
  8. //  AUTHOR:       
  9. //
  10. //  OVERVIEW
  11. //  ~~~~~~~~
  12. //  Source file for implementation of TApxOleOleView (TOleView).
  13. //
  14. //----------------------------------------------------------------------------
  15.  
  16. #include <owl/pch.h>
  17.  
  18. #include "apxolapp.h"
  19. #include "apxololv.h"
  20.  
  21. #include <stdio.h>
  22.  
  23.  
  24. //{{TApxOleOleView Implementation}}
  25.  
  26. //
  27. // Build a response table for all messages/commands handled
  28. // by TApxOleOleView derived from TOleView.
  29. //
  30. DEFINE_RESPONSE_TABLE1(TApxOleOleView, TOleView)
  31. //{{TApxOleOleViewRSP_TBL_BEGIN}}
  32.   EV_WM_GETMINMAXINFO,
  33.   EV_OC_VIEWSHOWTOOLS,
  34. //{{TApxOleOleViewRSP_TBL_END}}
  35. END_RESPONSE_TABLE;
  36.  
  37.  
  38. //--------------------------------------------------------
  39. // TApxOleOleView
  40. // ~~~~~~~~~~
  41. // Construction/Destruction handling.
  42. //
  43. TApxOleOleView::TApxOleOleView(TDocument& doc, TWindow* parent)
  44. :
  45.   TOleView(doc, parent)
  46. {
  47.   ToolBar = 0;
  48.  
  49.   // INSERT>> Your constructor code here.
  50.  
  51. }
  52.  
  53.  
  54. TApxOleOleView::~TApxOleOleView()
  55. {
  56.   // INSERT>> Your destructor code here.
  57.  
  58. }
  59.  
  60.  
  61. //
  62. // Paint routine for Window, Printer, and PrintPreview for a TOleView client.
  63. //
  64. void TApxOleOleView::Paint(TDC& dc, bool erase, TRect& rect)
  65. {
  66.   TApxOleApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TApxOleApp);
  67.   if (theApp) {
  68.     // Only paint if we're printing and we have something to paint, otherwise do nothing.
  69.     //
  70.     if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
  71.       // Use pageSize to get the size of the window to render into.  For a Window it's the client area,
  72.       // for a printer it's the printer DC dimensions and for print preview it's the layout window.
  73.       //
  74.       TSize   pageSize(rect.right - rect.left, rect.bottom - rect.top);
  75.  
  76.       TPrintDialog::TData& printerData = theApp->Printer->GetSetup();
  77.  
  78.       // Compute the number of pages to print.
  79.       //
  80.       printerData.MinPage = 1;
  81.       printerData.MaxPage = 1;
  82.  
  83.       TOcView*  ocView = GetOcView();
  84.  
  85.       // Default TOcPart painting
  86.       //
  87.       TRect clientRect = GetClientRect();
  88.       TRect logicalRect = clientRect +(TSize&)ocView->GetOrigin();
  89.         for (TOcPartCollectionIter i(GetOcDoc()->GetParts()); i; i++) {
  90.         TOcPart& p = *i.Current();
  91.         if (p.IsVisible(logicalRect)) {
  92.           TRect r = p.GetRect();
  93.           r -= ocView->GetOrigin();
  94.           p.Draw(dc, r, clientRect);        // Draw the embedded object.
  95.         }
  96.       }
  97.  
  98.       // INSERT>> Special printing code goes here.
  99.  
  100.     }
  101.     else {
  102.       TOleView::Paint(dc, erase, rect);
  103.  
  104.       // INSERT>> Normal painting code goes here.
  105.  
  106.     }
  107.   }
  108. }
  109.  
  110.  
  111. void TApxOleOleView::EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo)
  112. {
  113.   TApxOleApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TApxOleApp);
  114.   if (theApp) {
  115.     if (theApp->Printing) {
  116.       minmaxinfo.ptMaxSize = TPoint(32000, 32000);
  117.       minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000);
  118.       return;
  119.     }
  120.   }
  121.   TOleView::EvGetMinMaxInfo(minmaxinfo);
  122. }
  123.  
  124.  
  125. bool TApxOleOleView::EvOcViewShowTools(TOcToolBarInfo far& tbi)
  126. {
  127.   // Construct & create a control bar for show, destroy our bar for hide
  128.   //
  129.   if (tbi.Show) {
  130.     if (!ToolBar) {
  131.       ToolBar = new TControlBar(this);
  132.  
  133.       TApxOleApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TApxOleApp);
  134.       CHECK(theApp);
  135.  
  136.       theApp->CreateGadgets(ToolBar, true);
  137.     }
  138.  
  139.     ToolBar->Create();
  140.     tbi.HTopTB = (HWND)*ToolBar;
  141.   }
  142.   else {
  143.     if (ToolBar) {
  144.       ToolBar->Destroy();
  145.       delete ToolBar;
  146.       ToolBar = 0;
  147.     }
  148.   }
  149.  
  150.   return true;
  151. }
  152.