/***************************************************************************** * * 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 oc2owl OVERVIEW ======== Source file for implementation of oc2owlWindowView (TWindowView). */ #include #pragma hdrstop #include "och2dowl.h" #include "och2dowl.cpp" #include "oc2wlapp.h" #include "oc2wlwnv.h" #include //{{oc2owlWindowView Implementation}} // // Build a response table for all messages/commands handled // by oc2owlWindowView derived from TWindowView. // DEFINE_RESPONSE_TABLE1(oc2owlWindowView, TWindowView) //{{oc2owlWindowViewRSP_TBL_BEGIN}} EV_WM_GETMINMAXINFO, EV_WM_SIZE, EV_WM_PAINT, EV_WM_QUERYNEWPALETTE, EV_WM_PALETTECHANGED, EV_WM_SETFOCUS, //{{oc2owlWindowViewRSP_TBL_END}} EV_MESSAGE(XRTN_PALETTECHANGED, EvXrtPaletteChanged), END_RESPONSE_TABLE; ////////////////////////////////////////////////////////// // oc2owlWindowView // ========== // Construction/Destruction handling. oc2owlWindowView::oc2owlWindowView (TDocument& doc, TWindow* parent) : TWindowView(doc, parent) { // INSERT>> Your constructor code here. Chart = NULL; Data = NULL; // Allocate a new chart with each View } oc2owlWindowView::~oc2owlWindowView () { // 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 oc2owlWindowView::Paint (TDC& /* dc */, bool /* erase */, TRect& rect) { oc2owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc2owlApp); 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 oc2owlWindowView::EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo) { oc2owlApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), oc2owlApp); if (theApp) { if (theApp->Printing) { minmaxinfo.ptMaxSize = TPoint(32000, 32000); minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000); return; } } TWindowView::EvGetMinMaxInfo(minmaxinfo); } bool oc2owlWindowView::Create() { bool result; result = TWindowView::Create(); Chart = new TChart2D(this, 0, 0, 0, 0, 0); Chart->Create(); int i; char buffer[30]; char *header[] = { "This is a chart!", NULL }; // set some properties, load some data Chart->SetBackgroundColor(RGB(0xAA,0xBB,0xCC)); Chart->SetType(XRT_TYPE_BAR); Chart->SetGraphDepth(20); Chart->SetGraphInclination(15); Chart->SetGraphRotation(10); Chart->SetGraphBorder(XRT_BORDER_SHADOW); Chart->SetGraphBorderWidth(5); Chart->SetGraphBackgroundColor(RGB(0xBB,0xCC,0xDD)); Chart->SetDataAreaBackgroundColor(RGB(0xDD,0xDD,0xEE)); Chart->SetAxisBoundingBox(TRUE); Chart->SetHeaderStrings(header); Chart->SetHeaderBorder(XRT_BORDER_ETCHED_IN); Chart->SetPropString(XRT_HEADER_FONT, "Arial, 18,Bold"); Chart->SetXAnnotationMethod(XRT_ANNO_POINT_LABELS); Data = new TChart2DData("pop.dat"); Chart->SetData(*Data); for (i=0; iGetNPoints(0); i++) { sprintf(buffer, "Point %d", i+1); Chart->SetNthPointLabel(i, buffer); } for (i=0; iGetNSets(); i++) { sprintf(buffer, "Set %d", i+1); Chart->SetNthSetLabel(i, buffer); } return result; } void oc2owlWindowView::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 oc2owlWindowView::EvQueryNewPalette () { return (bool)ForwardMessage(*Chart); } void oc2owlWindowView::EvPaletteChanged (HWND) { ForwardMessage(*Chart); } LRESULT oc2owlWindowView::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 oc2owlWindowView::EvSetFocus (HWND hWndLostFocus ) { TWindowView::EvSetFocus(hWndLostFocus ); HWND hWnd = *Chart; ::SendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0); GetApplication()->GetMainWindow()->SendMessage(WM_PALETTECHANGED, (WPARAM)(hWnd)); }