//---------------------------------------------------------------------------- // Project rect // jyu // Copyright © Vesa Lappalainen 1996. All Rights Reserved. // // SUBSYSTEM: rect.apx Application // FILE: rectview.cpp // AUTHOR: vl // // OVERVIEW // ~~~~~~~~ // Source file for implementation of TRectView (TWindowView). // //---------------------------------------------------------------------------- #include #include "rectview.h" // // Build a response table for all messages/commands handled by the application. // DEFINE_RESPONSE_TABLE1(TRectView, TWindowView) //{{TRectViewRSP_TBL_BEGIN}} EV_WM_LBUTTONDOWN, EV_WM_MOUSEMOVE, EV_WM_LBUTTONUP, EV_VN_RECTMODIFY, //{{TRectViewRSP_TBL_END}} END_RESPONSE_TABLE; //{{TRectView Implementation}} //{{DOC_VIEW}} DEFINE_DOC_TEMPLATE_CLASS(TRectDocument,TRectView,TRectTemplete); //{{DOC_VIEW_END}} //{{DOC_MANAGER}} TRectTemplete RectTemplate("Rect files","*.rct",0,"rct", dtAutoDelete | dtUpdateDir | dtOverwritePrompt); //{{DOC_MANAGER_END}} TRectView::TRectView(TRectDocument& doc, TWindow* parent) : TWindowView(doc, parent), Doc(doc), DragDC(NULL) { // INSERT>> Your constructor code here. } TRectView::~TRectView() { // INSERT>> Your destructor code here. } void TRectView::Paint(TDC& dc, bool erase, TRect& rect) { TWindowView::Paint(dc, erase, rect); // INSERT>> Your code here. const TRect *rct; int i=0; while ( ( rct = Doc.GetRect(i++) ) != NULL ) dc.Rectangle(*rct); } void TRectView::EvLButtonDown(uint modKeys, TPoint& point) { TWindowView::EvLButtonDown(modKeys, point); // INSERT>> Your code here. if ( !DragDC ) { SetCapture(); DragDC = new TClientDC(*this); if ( !DragDC ) { ReleaseCapture(); return; } DragPoint = point; DragRect = TRect(DragPoint,point); DragDC->DrawFocusRect(DragRect); } } void TRectView::EvMouseMove(uint modKeys, TPoint& point) { TWindowView::EvMouseMove(modKeys, point); // INSERT>> Your code here. if ( DragDC ) { DragDC->DrawFocusRect(DragRect); DragRect = TRect(DragPoint,point); DragDC->DrawFocusRect(DragRect); } } void TRectView::EvLButtonUp(uint modKeys, TPoint& point) { TWindowView::EvLButtonUp(modKeys, point); // INSERT>> Your code here. if ( DragDC ) { DragDC->DrawFocusRect(DragRect); ReleaseCapture(); delete DragDC; DragDC = NULL; Doc.SetRect(DragRect); } } bool TRectView::VnModify(unsigned int /* index */) { Invalidate(); return true; }