//---------------------------------------------------------------------------- // Project rect // jyu // Copyright © Vesa Lappalainen 1996. All Rights Reserved. // // SUBSYSTEM: rect.apx Application // FILE: rctlstvw.cpp // AUTHOR: vl // // OVERVIEW // ~~~~~~~~ // Source file for implementation of TRectListView (TListView). // //---------------------------------------------------------------------------- #include #include "rctlstvw.h" // // Build a response table for all messages/commands handled by the application. // DEFINE_RESPONSE_TABLE1(TRectListView, TListView) //{{TRectListViewRSP_TBL_BEGIN}} EV_VN_RECTMODIFY, EV_COMMAND(CM_EDITEDIT, CmEditItem), EV_COMMAND(CM_EDITDELETE, CmEditDelete), EV_COMMAND(CM_EDITCUT, CmEditCut), EV_COMMAND(CM_EDITPASTE, CmEditPaste), EV_COMMAND(CM_EDITCLEAR, CmEditClear), EV_NOTIFY_AT_CHILD(LBN_DBLCLK, CmEditItem), //{{TRectListViewRSP_TBL_END}} END_RESPONSE_TABLE; //{{TRectListView Implementation}} //{{DOC_VIEW}} DEFINE_DOC_TEMPLATE_CLASS(TRectDocument,TRectListView,TRectListTemplete); //{{DOC_VIEW_END}} //{{DOC_MANAGER}} TRectListTemplete RectListTemplate("Rect list files","*.rct",0,"rct", dtAutoDelete | dtUpdateDir | dtOverwritePrompt); //{{DOC_MANAGER_END}} TRectListView::TRectListView(TRectDocument& doc, TWindow* parent) : TListView(doc, parent), Doc(doc) { // INSERT>> Your constructor code here. } TRectListView::~TRectListView() { Destroy(); // INSERT>> Your destructor code here. } bool TRectListView::Create() { bool result; result = TListView::Create(); // INSERT>> Your code here. LoadData(); return result; } bool TRectListView::LoadData() { const char *rct; int sel = GetSelIndex(); int i=0; TListView::CmEditClear(); while ( ( rct = Doc.GetRectText(i++) ) != NULL ) AddString(rct); SetSelIndex(sel); return true; } void TRectListView::CmEditItem() { // INSERT>> Your code here. int index = GetSelIndex(); TListView::CmEditItem(); char text[100]; GetString(text,index); Doc.SetRect(text,index); } bool TRectListView::VnModify(unsigned int /* index */) { return LoadData(); } void TRectListView::CmEditDelete() { // INSERT>> Your code here. Doc.DelRect(GetSelIndex()); } void TRectListView::CmEditCut() { // INSERT>> Your code here. CmEditCopy(); CmEditDelete(); } void TRectListView::CmEditPaste() { // INSERT>> Your code here. int index = GetSelIndex(); TClipboard cb(*this); if (!cb) return; // clipboard open by another program HANDLE cbhdl = cb.GetClipboardData(CF_TEXT); if (cbhdl) { char far* text = (char far*)::GlobalLock(cbhdl); Doc.SetRect(text,index); ::GlobalUnlock(cbhdl); } } void TRectListView::CmEditClear() { // INSERT>> Your code here. Doc.Clear(); }