/****************/ /* doclask.cpp */ /****************/ // Autolaskurin Doc/View -version yleiset osat // #include "doclask.h" //------------------------------------------------------------------------------ // Dokumenttiluokka joka huolehtii pelkästään dokumentista //------------------------------------------------------------------------------ static int ekakerta = 1; TLaskuriDocument::TLaskuriDocument(TDocument* parent) : TFileDocument(parent) { for (int i=0; i>(istream &is, TLaskuriDocument &doc) { for (int i=0; i> doc.laskurit[i]; doc.SetDirty(true); doc.Refresh(); return is; } ostream &operator<<(ostream &os, const TLaskuriDocument &doc) { for (int i=0; i> *this; delete is; } dataOK = 1; SetDirty(false); return true; } DEFINE_RESPONSE_TABLE2(TLaskuriDialog, TDialog, TView) EV_BN_CLICKED(HA ,BNHAClicked), EV_BN_CLICKED(KA ,BNKAClicked), EV_BN_CLICKED(NOLLAA ,BNNollaaClicked), EV_BN_CLICKED(EXIT ,BNExitClicked), EV_BN_CLICKED(IDCANCEL,BNExitClicked), // Tämä, niin ESCillä ei vahingossa EV_COMMAND(IDM_EDIT_CUT, CmCut ), EV_COMMAND(IDM_EDIT_COPY, CmCopy ), EV_COMMAND(IDM_EDIT_PASTE, CmPaste ), EV_COMMAND(IDM_OPTIONS_DEC ,CmDec ), EV_COMMAND(IDM_OPTIONS_INC ,CmInc ), EV_VN_REVERT, // Lue näytön tiedot dokusta EV_VN_COMMIT, // Onko näytössä muutoksia jotka pitäisi antaa dokulle EV_VN_ISWINDOW, // Jos tämä puuttuu, menuun ei tule Save -valintaa!!! END_RESPONSE_TABLE; bool TLaskuriDialog::VnRevert(bool /*clear*/) { hal->update(); kal->update(); return true; } bool TLaskuriDialog::VnCommit(bool /*force*/) { // nothing to do here, no data held in view ??? return true; } #ifdef OWL5 DEFINE_RESPONSE_TABLE2(TLaskuriApp, TApplication, TRecentFiles ) #else DEFINE_RESPONSE_TABLE1(TLaskuriApp, TApplication ) #endif EV_OWLVIEW(dnCreate, EvNewView), EV_OWLVIEW(dnClose, EvCloseView), #ifdef OWL5 EV_OWLDOCUMENT(dnCreate, EvOwlDocument), EV_OWLDOCUMENT(dnRename, EvOwlDocument), EV_REGISTERED(MruFileMessage, CmFileSelected), #endif // EV_COMMAND(CM_HELPABOUT, CmHelpAbout), END_RESPONSE_TABLE; void TLaskuriApp::EvNewView(TView& view) { // Koko ei tule 1. kerralla ihan oikein??? GetMainWindow()->SetFlag(wfShrinkToClient); GetMainWindow()->SetClientWindow(view.GetWindow()); if ( !view.IsOK() ) GetMainWindow()->SetClientWindow(0); else if ( view.GetViewMenu() ) // Jos View:llä oma menu GetMainWindow()->MergeMenu(*view.GetViewMenu()); } void TLaskuriApp::EvCloseView(TView&) { GetMainWindow()->ClearFlag(wfShrinkToClient); GetMainWindow()->SetClientWindow(0); GetMainWindow()->SetCaption("Laskurm3"); } #ifdef OWL5 // Nämä on viimeksikäytettyjen tiedostojen listan (MRU) takia void TLaskuriApp::EvOwlDocument(TDocument& doc) { if (doc.GetDocPath()) SaveMenuChoice(doc.GetDocPath()); } int32 TLaskuriApp::CmFileSelected(uint wp, int32) { TAPointer text = new char[_MAX_PATH]; GetMenuText(wp, text, _MAX_PATH); TDocTemplate* tpl = GetDocManager()->MatchTemplate(text); if ( tpl ) GetDocManager()->CreateDoc(tpl, text); return 0; } #endif