/***************************************************************************** * * 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 oc3owlWindowView (TWindowView). */ #include #pragma hdrstop #include "och3dowl.h" #include "och3dowl.cpp" #include "oc3wlapp.h" #include "oc3wlwnv.h" #include //{{oc3owlWindowView Implementation}} // // Build a response table for all messages/commands handled // by oc3owlWindowView derived from TWindowView. // DEFINE_RESPONSE_TABLE1(oc3owlWindowView, TWindowView) //{{oc3owlWindowViewRSP_TBL_BEGIN}} EV_WM_GETMINMAXINFO, EV_WM_SIZE, EV_WM_PAINT, EV_WM_QUERYNEWPALETTE, EV_WM_PALETTECHANGED, EV_WM_SETFOCUS, EV_WM_DESTROY, //{{oc3owlWindowViewRSP_TBL_END}} EV_MESSAGE(XRT3DN_PALETTECHANGED, EvXrtPaletteChanged), END_RESPONSE_TABLE; ////////////////////////////////////////////////////////// // oc3owlWindowView // ========== // Construction/Destruction handling. oc3owlWindowView::oc3owlWindowView (TDocument& doc, TWindow* parent) : TWindowView(doc, parent) { // INSERT>> Your constructor code here. Chart = NULL; Data = NULL; // Allocate a new chart with each View } oc3owlWindowView::~oc3owlWindowView () { // INSERT>> Your destructor code here. // clean up memory alocated with View delete Data; delete Chart; } // // Paint routine for Window, Printer, and PrintPreview for a TWindowView client. // void oc3owlWindowView::Paint (TDC& /* dc */, bool /* erase */, TRect& rect) { oc3owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc3owlApp); if (theApp) { // Only paint if we're printing and we have something to paint, otherwise do nothing. if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) { // 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); TPrintDialog::TData &printerData = theApp->Printer->GetSetup(); // Compute the number of pages to print. printerData.MinPage = 1; printerData.MaxPage = 1; // INSERT>> Special printing code goes here. } else { // INSERT>> Normal painting code goes here. } } } void oc3owlWindowView::EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo) { oc3owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc3owlApp); if (theApp) { if (theApp->Printing) { minmaxinfo.ptMaxSize = TPoint(32000, 32000); minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000); return; } } TWindowView::EvGetMinMaxInfo(minmaxinfo); } bool oc3owlWindowView::Create() { bool result; result = TWindowView::Create(); Chart = new TChart3D(this, 0, 0, 0, 0, 0); Chart->Create(); char *header[] = { "This is a chart!", NULL }; char *label0[] = { "New York", NULL }; char *label1[] = { "Tokyo", NULL }; char *label2[] = { "Mexico", NULL }; // set some properties, load some data Chart->SetBackgroundColor(RGB(0xAA,0xBB,0xCC)); Chart->SetGraphBorderWidth(5); Chart->SetGraphBorder(XRT3D_BORDER_SHADOW); Chart->SetGraphBackgroundColor(RGB(0xBB,0xCC,0xDD)); Chart->SetDataAreaBackgroundColor(RGB(0xDD,0xDD,0xEE)); Chart->SetSolidSurface(TRUE); Chart->SetPerspectiveDepth(10); Chart->SetXRotation(25.8883); Chart->SetYRotation(0.34); Chart->SetZRotation(310); Chart->SetXAnnoMethod(XRT3D_ANNO_VALUE_LABELS); Chart->SetYAnnoMethod(XRT3D_ANNO_VALUE_LABELS); Chart->SetHeaderStrings(header); Chart->SetHeaderBorder(XRT3D_BORDER_ETCHED_IN); Chart->SetPropString(XRT3D_HEADER_FONT, "Arial, 18,Bold"); Data = new TChart3DData("pop3d.dat"); Chart->SetSurfaceData(*Data); Labels[ 0 ] = new TChart3DTextArea(Chart); Labels[ 0 ]->SetStrings(label0); Labels[ 0 ]->SetAttachMethod(XRT3D_ATTACH_POINT); Labels[ 0 ]->SetAttachPointX(5.5); Labels[ 0 ]->SetAttachPointY(4.5); Labels[ 0 ]->SetAttachPointZ(15.5); Labels[ 0 ]->SetPlane(XRT3D_YZ_PLANE); Labels[ 1 ] = new TChart3DTextArea(Chart); Labels[ 1 ]->SetStrings(label1); Labels[ 1 ]->SetAttachMethod(XRT3D_ATTACH_POINT); Labels[ 1 ]->SetAttachPointX(3.5); Labels[ 1 ]->SetAttachPointY(3); Labels[ 1 ]->SetAttachPointZ(18); Labels[ 1 ]->SetPlane(XRT3D_YZ_PLANE); Labels[ 2 ] = new TChart3DTextArea(Chart); Labels[ 2 ]->SetStrings(label2); Labels[ 2 ]->SetAttachMethod(XRT3D_ATTACH_POINT); Labels[ 2 ]->SetAttachPointX(1.5); Labels[ 2 ]->SetAttachPointY(2); Labels[ 2 ]->SetAttachPointZ(8); Labels[ 2 ]->SetPlane(XRT3D_YZ_PLANE); return result; } void oc3owlWindowView::EvSize(uint sizeType, TSize& size) { Invalidate(); TWindow::EvSize(sizeType,size); if (Chart) { Chart->SetWindowPos(HWND_TOP, 0, 0, size.cx, size.cy, SWP_SHOWWINDOW); Chart->Invalidate(); } } bool oc3owlWindowView::EvQueryNewPalette () { return (bool)ForwardMessage(*Chart); } void oc3owlWindowView::EvPaletteChanged (HWND) { ForwardMessage(*Chart); } LRESULT oc3owlWindowView::EvXrtPaletteChanged (WPARAM, LPARAM) { TFrameWindow* pFrame; HWND hWnd; pFrame = GetApplication()->GetMainWindow(); hWnd = pFrame->GetCommandTarget(); if(hWnd == NULL) return 0; ::SendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0); pFrame->SendMessage(WM_PALETTECHANGED, (WPARAM)(hWnd)); return 0; } void oc3owlWindowView::EvSetFocus (HWND hWndLostFocus ) { TWindowView::EvSetFocus(hWndLostFocus ); HWND hWnd = *Chart; ::SendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0); GetApplication()->GetMainWindow()->SendMessage(WM_PALETTECHANGED, (WPARAM)(hWnd)); } void oc3owlWindowView::EvDestroy () { TWindowView::EvDestroy(); // INSERT>> Your code here. delete Labels[0]; delete Labels[1]; delete Labels[2]; }