home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / expert.pak / TWINDOWV.OWL < prev    next >
Text File  |  1997-07-23  |  4KB  |  148 lines

  1. <<[H]TWindowView [[TWindowView]]
  2. ##{hheader.snp}
  3. #include <owl\owlpch.h>
  4. #pragma hdrstop
  5.  
  6.  
  7. ##<<TApplication QUERY_FILENAME_CPP [[Filename]]
  8. #include "[[Filename]].rh"            // Definition of all resources.
  9.  
  10.  
  11. //{{TWindowView = [[TWindowView]]}}
  12. class [[TWindowView]] : public TWindowView {
  13. public:
  14.     [[TWindowView]] (TDocument& doc, TWindow* parent = 0);
  15.     virtual ~[[TWindowView]] ();
  16. ##--BEGIN-- @OPT_APPL_PRINTING
  17.  
  18. //{{[[TWindowView]]VIRTUAL_BEGIN}}
  19. public:
  20.     virtual void Paint (TDC& dc, bool erase, TRect& rect);
  21. ##:DBVirtual(\\"[[TWindowView]]", "Paint")
  22. //{{[[TWindowView]]VIRTUAL_END}}
  23. //{{[[TWindowView]]RSP_TBL_BEGIN}}
  24. protected:
  25.     void EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo);
  26. //{{[[TWindowView]]RSP_TBL_END}}
  27. DECLARE_RESPONSE_TABLE([[TWindowView]]);
  28. ##--END-- @OPT_APPL_PRINTING
  29. };    //{{[[TWindowView]]}}
  30. ##{hfooter.snp}
  31. >>[H]TWindowView [[TWindowView]]
  32.  
  33.  
  34. <<[CPP]TWindowView [[TWindowView]]
  35. ##{cheader.snp}
  36. #include <owl\owlpch.h>
  37. #pragma hdrstop
  38.  
  39. ##<<TApplication QUERY_FILE_H [[FileName]]
  40. #include "[[FileName]]"
  41. ##QUERY_FILE_H [[FileName]]
  42. #include "[[FileName]]"
  43.  
  44. #include <stdio.h>
  45.  
  46.  
  47. //{{[[TWindowView]] Implementation}}
  48.  
  49.  
  50. ##--BEGIN-- @OPT_APPL_PRINTING
  51. ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  52. //
  53. // Build a response table for all messages/commands handled
  54. // by [[TWindowView]] derived from TWindowView.
  55. //
  56. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  57. DEFINE_RESPONSE_TABLE1([[TWindowView]], TWindowView)
  58. //{{[[TWindowView]]RSP_TBL_BEGIN}}
  59. ##:DBResponse(\\"[[TWindowView]]", "", "", "WM_GETMINMAXINFO", "")
  60.     EV_WM_GETMINMAXINFO,
  61. //{{[[TWindowView]]RSP_TBL_END}}
  62. END_RESPONSE_TABLE;
  63.  
  64.  
  65. ##--END-- @OPT_APPL_PRINTING
  66. ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  67. //////////////////////////////////////////////////////////
  68. // [[TWindowView]]
  69. // ==========
  70. // Construction/Destruction handling.
  71. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  72. [[TWindowView]]::[[TWindowView]] (TDocument& doc, TWindow* parent)
  73.     : TWindowView(doc, parent)
  74. {
  75. ##QUERY_WIND_STYLE [[StyleAttributes]]
  76. ##StyleAttributes != "" 3
  77.     // Override the default window style for TWindowView.
  78. [[StyleAttributes]]
  79.  
  80. ##QUERY_WIND_BACKGRND [[BackgroundColor]]
  81. ##BackgroundColor != "" 3
  82.     // Change the window's background color
  83.     SetBkgndColor([[BackgroundColor]]);
  84.  
  85.     // INSERT>> Your constructor code here.
  86.  
  87. }
  88.  
  89.  
  90. [[TWindowView]]::~[[TWindowView]] ()
  91. {
  92.     // INSERT>> Your destructor code here.
  93.  
  94. }
  95. ##--BEGIN-- @OPT_APPL_PRINTING == TRUE
  96.  
  97.  
  98. ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  99. //
  100. // Paint routine for Window, Printer, and PrintPreview for a TWindowView client.
  101. //
  102. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  103. void [[TWindowView]]::Paint (TDC&, bool, TRect& rect)
  104. {
  105. ##<<TApplication QUERY_CLASS_NAME [[TApplication]]
  106.     [[TApplication]] *theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
  107.     if (theApp) {
  108. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  109.         // Only paint if we're printing and we have something to paint, otherwise do nothing.
  110.         if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
  111. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
  112.             // Use pageSize to get the size of the window to render into.  For a Window it's the client area,
  113.             // for a printer it's the printer DC dimensions and for print preview it's the layout window.
  114.             TSize   pageSize(rect.right - rect.left, rect.bottom - rect.top);
  115.  
  116.             TPrintDialog::TData &printerData = theApp->Printer->GetSetup();
  117.  
  118. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  119.             // Compute the number of pages to print.
  120.             printerData.MinPage = 1;
  121.             printerData.MaxPage = 1;
  122.  
  123.             // INSERT>> Special printing code goes here.
  124.  
  125.         } else {
  126.             // INSERT>> Normal painting code goes here.
  127.  
  128.         }
  129.     }
  130. }
  131.  
  132.  
  133. void [[TWindowView]]::EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo)
  134. {
  135. ##<<TApplication QUERY_CLASS_NAME [[TApplication]]
  136.     [[TApplication]] *theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
  137.     if (theApp) {
  138.         if (theApp->Printing) {
  139.             minmaxinfo.ptMaxSize = TPoint(32000, 32000);
  140.             minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000);
  141.             return;
  142.         }
  143.     }
  144.     TWindowView::EvGetMinMaxInfo(minmaxinfo);
  145. }
  146. ##--END-- @OPT_APPL_PRINTING == TRUE
  147. >>[CPP]TWindowView [[TWindowView]]
  148.