/***************************************************************************** * * Copyright (c) 1999, KL GROUP INC. All Rights Reserved. * http://www.klgroup.com * * This file is provided for demonstration and educational uses only. * Permission to use, copy, modify and distribute this file for * any purpose and without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies, and that the name of KL Group not be used in advertising * or publicity pertaining to this material without the specific, * prior written permission of an authorized representative of * KL Group. * * KL GROUP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. KL GROUP SHALL NOT BE LIABLE FOR ANY * DAMAGES SUFFERED BY USERS AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ /* Project oc3owl OVERVIEW ======== Source file for implementation of oc3owlMDIClient (TMDIClient). */ #include #pragma hdrstop #include #include "oc3wlapp.h" #include "oc3wmdi1.h" #include "oc3wmdic.h" #include "apxprint.h" #include "apxprev.h" //{{oc3owlMDIClient Implementation}} // // Build a response table for all messages/commands handled // by oc3owlMDIClient derived from TMDIClient. // DEFINE_RESPONSE_TABLE1(oc3owlMDIClient, TMDIClient) //{{oc3owlMDIClientRSP_TBL_BEGIN}} EV_COMMAND(CM_FILEPRINT, CmFilePrint), EV_COMMAND(CM_FILEPRINTERSETUP, CmFilePrintSetup), EV_COMMAND(CM_FILEPRINTPREVIEW, CmFilePrintPreview), EV_COMMAND_ENABLE(CM_FILEPRINT, CmPrintEnable), EV_COMMAND_ENABLE(CM_FILEPRINTERSETUP, CmPrintEnable), EV_COMMAND_ENABLE(CM_FILEPRINTPREVIEW, CmPrintEnable), EV_WM_DROPFILES, //{{oc3owlMDIClientRSP_TBL_END}} END_RESPONSE_TABLE; ////////////////////////////////////////////////////////// // oc3owlMDIClient // =========== // Construction/Destruction handling. oc3owlMDIClient::oc3owlMDIClient (TModule* module) : TMDIClient (module) { ChildCount = 0; // INSERT>> Your constructor code here. } oc3owlMDIClient::~oc3owlMDIClient () { Destroy(); // INSERT>> Your destructor code here. } ////////////////////////////////////////////////////////// // oc3owlMDIClient // =========== // MDIClient site initialization. void oc3owlMDIClient::SetupWindow () { // Default SetUpWindow processing. TMDIClient::SetupWindow (); // Accept files via drag/drop in the client window. DragAcceptFiles(true); } ////////////////////////////////////////////////////////// // oc3owlMDIClient // ========== // Menu File Print command void oc3owlMDIClient::CmFilePrint () { // // Create Printer object if not already created. // oc3owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc3owlApp); if (theApp) { if (!theApp->Printer) theApp->Printer = new TPrinter(GetApplication()); // // Create Printout window and set characteristics. // APXPrintOut printout(theApp->Printer, Title, GetActiveMDIChild()->GetClientWindow(), true); theApp->Printing++; // // Bring up the Print dialog and print the document. // theApp->Printer->Print(GetWindowPtr(GetActiveWindow()), printout, true); theApp->Printing--; } } ////////////////////////////////////////////////////////// // oc3owlMDIClient // ========== // Menu File Print Setup command void oc3owlMDIClient::CmFilePrintSetup () { oc3owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc3owlApp); if (theApp) { if (!theApp->Printer) theApp->Printer = new TPrinter(GetApplication()); // // Bring up the Print Setup dialog. // theApp->Printer->Setup(this); } } ////////////////////////////////////////////////////////// // oc3owlMDIClient // ========== // Menu File Print Preview command void oc3owlMDIClient::CmFilePrintPreview () { oc3owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc3owlApp); if (theApp) { if (!theApp->Printer) theApp->Printer = new TPrinter(GetApplication()); theApp->Printing++; PreviewWindow *prevW = new PreviewWindow(Parent, theApp->Printer, GetActiveMDIChild()->GetClientWindow(), "Print Preview", new TLayoutWindow(0)); prevW->Create(); GetApplication()->BeginModal(GetApplication()->GetMainWindow()); // We must destroy the preview window explicitly. Otherwise, the window will not be destroyed until // it's parent the MainWindow is destroyed. prevW->Destroy(); delete prevW; theApp->Printing--; } } ////////////////////////////////////////////////////////// // oc3owlMDIClient // ========== // Menu enabler used by Print, Print Setup and Print Preview. void oc3owlMDIClient::CmPrintEnable (TCommandEnabler &tce) { if (GetActiveMDIChild()) { oc3owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc3owlApp); if (theApp) { // If we have a Printer already created just test if all is okay. // Otherwise create a Printer object and make sure the printer // really exists and then delete the Printer object. if (!theApp->Printer) { theApp->Printer = new TPrinter(GetApplication()); tce.Enable(theApp->Printer->GetSetup().Error == 0); } else tce.Enable(theApp->Printer->GetSetup().Error == 0); } } else tce.Enable(false); } void oc3owlMDIClient::EvDropFiles (TDropInfo) { Parent->ForwardMessage(); }