home *** CD-ROM | disk | FTP | other *** search
Wrap
<<[H]TEditFile [[TEditFile]] ##{hheader.snp} #include <owl/editfile.h> ##<<TApplication QUERY_FILENAME_CPP [[Filename]] #include "[[Filename]].rh" // Definition of all resources. //{{TEditFile = [[TEditFile]]}} class [[TEditFile]] : public TEditFile { public: [[TEditFile]](TWindow* parent = 0, int id = 0, const char far* text = 0, int x = 0, int y = 0, int w = 0, int h = 0, const char far* fileName = 0, TModule* module = 0); virtual ~[[TEditFile]](); ##--BEGIN-- @OPT_APPL_PRINTING //{{[[TEditFile]]VIRTUAL_BEGIN}} public: virtual void Paint(TDC& dc, bool erase, TRect& rect); ##:DBVirtual(\\"[[TEditFile]]", "Paint") virtual void SetupWindow(); ##:DBVirtual(\\"[[TEditFile]]", "SetupWindow") ##--BEGIN-- @OPT_APPL_MRU virtual bool SaveAs(); ##:DBVirtual(\\"[[TEditFile]]", "SaveAs") ##--END-- @OPT_APPL_MRU //{{[[TEditFile]]VIRTUAL_END}} //{{[[TEditFile]]RSP_TBL_BEGIN}} protected: void EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo); //{{[[TEditFile]]RSP_TBL_END}} DECLARE_RESPONSE_TABLE([[TEditFile]]); ##--END-- @OPT_APPL_PRINTING ##--BEGIN-- !@OPT_APPL_PRINTING //{{[[TEditFile]]VIRTUAL_BEGIN}} public: virtual void SetupWindow(); ##:DBVirtual(\\"[[TEditFile]]", "SetupWindow") ##--BEGIN-- @OPT_APPL_MRU virtual bool SaveAs(); ##:DBVirtual(\\"[[TEditFile]]", "SaveAs") ##--END-- @OPT_APPL_MRU //{{[[TEditFile]]VIRTUAL_END}} ##--END-- !@OPT_APPL_PRINTING }; //{{[[TEditFile]]}} ##{hfooter.snp} >>[H]TEditFile [[TEditFile]] <<[CPP]TEditFile [[TEditFile]] ##{cheader.snp} #include <owl/pch.h> ##<<TApplication QUERY_FILE_H [[FileName]] #include "[[FileName]]" ##--BEGIN-- !@OPT_APPL_DOCVIEW ## --BEGIN-- @QUERY_APPL_MODEL == VALUE_MDI ##: <<TMDIChild QUERY_WIND_CLIENT [[Client]] ##: <<*Client QUERY_FILE_H [[FileName]] #include "[[FileName]]" ## --END-- @QUERY_APPL_MODEL == VALUE_MDI ##--END-- !@OPT_APPL_DOCVIEW ##QUERY_FILE_H [[FileName]] #include "[[FileName]]" #include <stdio.h> //{{[[TEditFile]] Implementation}} ##--BEGIN-- @OPT_APPL_PRINTING ##@QUERY_APPL_COMMENT == VALUE_VERBOSE 4 // // Build a response table for all messages/commands handled // by [[TEditFile]] derived from TEditFile. // DEFINE_RESPONSE_TABLE1([[TEditFile]], TEditFile) //{{[[TEditFile]]RSP_TBL_BEGIN}} ##:DBResponse(\\"[[TEditFile]]", "", "", "WM_GETMINMAXINFO", "") EV_WM_GETMINMAXINFO, //{{[[TEditFile]]RSP_TBL_END}} END_RESPONSE_TABLE; ##--END-- @OPT_APPL_PRINTING ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE //-------------------------------------------------------- // [[TEditFile]] // ~~~~~~~~~~ // Construction/Destruction handling. // ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE [[TEditFile]]::[[TEditFile]](TWindow* parent, int id, const char far* text, int x, int y, int w, int h, const char far* fileName, TModule* module) : TEditFile(parent, id, text, x, y, w, h, fileName, module) { ##QUERY_WIND_STYLE [[StyleAttributes]] ##StyleAttributes != "" 3 // Override the default window style for TEditFile. [[StyleAttributes]] ##{wndbkgd.snp} // INSERT>> Your constructor code here. } [[TEditFile]]::~[[TEditFile]]() { Destroy(); // INSERT>> Your destructor code here. } void [[TEditFile]]::SetupWindow() { TEditFile::SetupWindow(); ##<<TApplication QUERY_CLASS_NAME [[TApplication]] [[TApplication]]* theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]); FileData = theApp->FileData; } ##--BEGIN-- @OPT_APPL_PRINTING == TRUE ##@QUERY_APPL_COMMENT == VALUE_VERBOSE 3 // // Paint routine for Window, Printer, and PrintPreview for an TEdit client. // void [[TEditFile]]::Paint(TDC& dc, bool, TRect& rect) { ##<<TApplication QUERY_CLASS_NAME [[TApplication]] [[TApplication]]* theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]); if (theApp) { ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2 // Only paint if we're printing and we have something to paint, otherwise do nothing. // if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) { ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 3 // Use pageSize to get the size of the window to render into. For a Window it's the client area, // for a printer it's the printer DC dimensions and for print preview it's the layout window. // TSize pageSize(rect.right - rect.left, rect.bottom - rect.top); HFONT hFont = (HFONT)GetWindowFont(); TFont font("Arial", -12); if (!hFont) dc.SelectObject(font); else dc.SelectObject(TFont(hFont)); TEXTMETRIC tm; int fHeight = dc.GetTextMetrics(tm) ? tm.tmHeight + tm.tmExternalLeading : 10; ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2 // How many lines of this font can we fit on a page. // int linesPerPage = MulDiv(pageSize.cy, 1, fHeight); if (linesPerPage) { TPrintDialog::TData& printerData = theApp->Printer->GetSetup(); int maxPg = ((GetNumLines() / linesPerPage) + 1.0); ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2 // Compute the number of pages to print. // printerData.MinPage = 1; printerData.MaxPage = maxPg; ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2 // Do the text stuff: // int fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage; int toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage; int currentPage = fromPage; TAPointer<char> buffer = new char[255]; while (currentPage <= toPage) { int startLine = (currentPage - 1) * linesPerPage; int lineIdx = 0; while (lineIdx < linesPerPage) { ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2 // If the string is no longer valid then there's nothing more to display. // if (!GetLine(buffer, 255, startLine + lineIdx)) break; dc.TabbedTextOut(TPoint(0, lineIdx * fHeight), buffer, strlen(buffer), 0, 0, 0); lineIdx++; } currentPage++; } } } } } void [[TEditFile]]::EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo) { ##<<TApplication QUERY_CLASS_NAME [[TApplication]] [[TApplication]]* theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]); if (theApp) { if (theApp->Printing) { minmaxinfo.ptMaxSize = TPoint(32000, 32000); minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000); return; } } TEditFile::EvGetMinMaxInfo(minmaxinfo); } ##--END-- @OPT_APPL_PRINTING == TRUE ##--BEGIN-- @OPT_APPL_MRU ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE // Override SaveAs to store the menu choice. // ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE bool [[TEditFile]]::SaveAs() { if (TEditFile::SaveAs()) { ##<<TApplication QUERY_CLASS_NAME [[TApplication]] [[TApplication]]* theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]); theApp->SaveMenuChoice(GetFileName()); return true; } return false; } ##--END-- @OPT_APPL_MRU >>[CPP]TEditFile [[TEditFile]]