home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / EXPERT.PAK / TWINDOW.OWL < prev    next >
Text File  |  1995-08-29  |  5KB  |  160 lines

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