diff --git a/ve/ve0100.cpp b/ve/ve0100.cpp index 5b4dc72ba..510759d23 100755 --- a/ve/ve0100.cpp +++ b/ve/ve0100.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -27,26 +26,13 @@ TCursor& TMotore_application::get_filtered_cursor() const bool TMotore_application::save_and_new() const { - TDocumento_mask & m = edit_mask(); bool new_doc = false; - + + TDocumento_mask & m = edit_mask(); if (m.insert_mode()) { - TDocumento & doc = m.doc(); - new_doc = doc.codice_numerazione().save_and_new(); - - if (new_doc && doc.tipo().printable()) // && yesno_box(TR("Si desidera stampare il documento"))) - { - const char s[2] = { doc.tipo().stato_finale_stampa(), '\0' }; - - app()._print_directly = true; - app().print(); - app()._print_directly= false; - m.set(F_STATO, s, TRUE); - doc.read(); - doc.put(DOC_STATO, s); - doc.rewrite(); - } + TDocumento& doc = m.doc(); + new_doc = doc.codice_numerazione().save_and_new(); } return new_doc; @@ -55,6 +41,7 @@ bool TMotore_application::save_and_new() const void TMotore_application::init_query_mode( TMask& m ) { disable_menu_item(M_FILE_PRINT); + disable_menu_item(M_FILE_PREVIEW); disable_menu_item(MENU_ITEM_ID(1)); TEdit_field& cn = _msk->efield(F_CODNUM); @@ -153,7 +140,8 @@ void TMotore_application::init_insert_mode( TMask& m ) m.enable(DLG_CONFERMA); else m.disable(DLG_CONFERMA); - m.disable(DLG_PRINT); + m.disable(DLG_PRINT); + m.disable(DLG_PREVIEW); m.disable(DLG_ELABORA); if (curdo.tipo().auto_add()) @@ -173,18 +161,23 @@ void TMotore_application::init_modify_mode( TMask& m ) n.set(""); n.update_flags("R"); const bool enable_print = edit_mask().doc().tipo().printable(); - const TString4 provv = m.get(F_PROVV); - enable_menu_item(M_FILE_PRINT, provv == "D" && enable_print); + const char provv = m.get(F_PROVV)[0]; enable_menu_item(MENU_ITEM_ID(1)); - if (provv[0] == 'P') + if (provv == 'P') { - m.disable(DLG_PRINT); m.enable(DLG_CONFERMA); + m.disable(DLG_PRINT); + m.disable(DLG_PREVIEW); + enable_menu_item(M_FILE_PRINT, false); + enable_menu_item(M_FILE_PREVIEW, false); } else { m.disable(DLG_CONFERMA); m.enable(DLG_PRINT, enable_print); + m.enable(DLG_PREVIEW, enable_print); + enable_menu_item(M_FILE_PRINT, enable_print); + enable_menu_item(M_FILE_PREVIEW, enable_print); } m.enable(DLG_ELABORA); m.disable(F_STATO); @@ -382,8 +375,17 @@ int TMotore_application::write( const TMask& m ) // C 90 { mask.update_father_rows(); mask.save_father_rows(); + + // Stampa immediatamente dopo aver salvato se possibile + if (d.codice_numerazione().save_and_new() && d.tipo().printable()) + { + const TString& sis = d.tipo().stati_iniziali_stampa(); + if (sis.find(d.stato()) >= 0) + save_and_print(false, winprinter); + } } - return err; + + return err; } int TMotore_application::rewrite( const TMask& m ) // C 90 @@ -922,71 +924,86 @@ void TMotore_application::ini2mask(TConfig& ini, TMask& msk, bool query) } } -void TMotore_application::print() +bool TMotore_application::save_and_print(bool savedoc, TPrtype mode) { - bool ok = _print_directly; - if (!ok) + if (savedoc) { - ok = save(false); - edit_mask().update_father_rows(false); - } - if (ok) // Registra il record corrente - { - TDocumento& doc = (TDocumento&)get_relation()->curr(); - - const TTipo_documento& tipo = doc.tipo(); - TFilename rep; - if (tipo.main_print_profile(rep, 0)) - { - const bool da_stampare = doc.stampabile(); + if (save(false)) + edit_mask().update_father_rows(false); + else + return false; + } - TString commandline; - if (rep.ends_with(".rep")) - commandline = "ve1 -2"; // Esiste il nuovo report :-) - else - commandline = "ve1 -0"; // Esiste il vecchio form :-( - - commandline << ' ' << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO) << ' '; - commandline << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << ' '; - if (printer().printtype() == screenvis) - commandline << 'A'; - else - commandline << 'S'; - commandline << ' ' << (da_stampare ? 'D' : 'P'); - - const int ncopie = tipo.ncopie(); - if (ncopie > 0) - commandline << ' ' << ncopie; + TDocumento& doc = (TDocumento&)get_relation()->curr(); - TExternal_app interattivo( commandline ); - if (interattivo.run() == NOERR) - { - if (da_stampare) // Aggiorna stato documento se necessario - { - TDocumento_mask& m = edit_mask(); - TDocumento& maindoc = m.doc(); - maindoc.read(); // Aggiorna STATO e MOVMAG generati da ve1 + const TTipo_documento& tipo = doc.tipo(); + TFilename rep; + if (tipo.main_print_profile(rep, 0)) + { + const bool da_stampare = doc.stampabile(); - // Lo stato del documento vive di vita propria - const char sfs = maindoc.tipo().stato_finale_stampa(); - maindoc.stato(sfs); - const char str_sfs[2] = { sfs, '\0' }; - m.set(F_STATO, str_sfs, true); - } + TString commandline; + if (rep.ends_with(".rep")) + commandline = "ve1 -2"; // Esiste il nuovo report :-) + else + commandline = "ve1 -0"; // Esiste il vecchio form :-( + + commandline << ' ' << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO) << ' '; + commandline << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << ' '; + switch (mode) + { + case fileprinter: commandline << " P"; break; + case screenvis : commandline << " A"; break; + default : commandline << " S"; break; + } + commandline << ' ' << (da_stampare ? 'D' : 'P'); + + const int ncopie = tipo.ncopie(); + if (ncopie > 0) + commandline << ' ' << ncopie; + + TExternal_app interattivo( commandline ); + if (interattivo.run() == NOERR) + { + if (da_stampare) // Aggiorna stato documento se necessario + { + TDocumento_mask& m = edit_mask(); + TDocumento& maindoc = m.doc(); + maindoc.read(); // Aggiorna STATO e MOVMAG generati da ve1 + + // Lo stato del documento vive di vita propria + const char sfs = maindoc.tipo().stato_finale_stampa(); + maindoc.stato(sfs); + const char str_sfs[2] = { sfs, '\0' }; + m.set(F_STATO, str_sfs, true); } } - else - { - rep.ext(""); - message_box("Il profilo %s non esiste", (const char *) rep); - } } + else + { + rep.ext(""); + return error_box("Il profilo %s non esiste", (const char*)rep); + } + + return true; +} + +void TMotore_application::print() +{ + if (edit_mask().id2pos(DLG_PREVIEW) < 0) + save_and_print(true, printer().printtype()); + else + save_and_print(true, winprinter); +} + +void TMotore_application::preview() +{ + save_and_print(true, screenvis); } int ve0100( int argc, char* argv[]) { TMotore_application a; - a.run( argc, argv, TR("Gestione documenti")); return 0; } diff --git a/ve/ve0100.h b/ve/ve0100.h index 735118d05..37720544c 100755 --- a/ve/ve0100.h +++ b/ve/ve0100.h @@ -7,6 +7,11 @@ #include #endif +#ifndef __PRINTER_H +#include +#endif + + #ifndef __VELIB_H #include "velib.h" #endif @@ -30,8 +35,6 @@ class TMotore_application : public TRelation_application TString4 _tipodoc; TString80 __last_key; - bool _print_directly; - protected: // Array di maschere documento TAssoc_array _doc_masks; @@ -50,6 +53,7 @@ protected: virtual int rewrite( const TMask& m ); virtual bool remove(); virtual void print(); + virtual void preview(); virtual bool has_filtered_cursor() const { return true; } virtual TCursor& get_filtered_cursor() const; virtual bool save_and_new() const; @@ -73,6 +77,7 @@ protected: virtual void ini2mask(TConfig& ini, TMask& m, bool query); bool last_doc(char provv, int anno, const char* codnum, long& ndoc, TDate& datadoc) const; + bool save_and_print(bool savedoc, TPrtype mode); public: virtual TRelation* get_relation( ) const { return _rel;} @@ -87,7 +92,7 @@ public: TDocumento & doc() {return edit_mask().doc(); } // Operazione - TMotore_application( ) : _print_directly(false) { } + TMotore_application( ) { } virtual ~TMotore_application( ) { } virtual const char* get_next_key( ); diff --git a/ve/ve0300.cpp b/ve/ve0300.cpp index c5fc7e107..afaadf8fa 100755 --- a/ve/ve0300.cpp +++ b/ve/ve0300.cpp @@ -1486,18 +1486,28 @@ void TMask_generator::genera( const TString& profilo ) _m->message( "EXIT,127" ); _m->end( ); + _m->control( T_BOTTONE, DLG_NULL, 202 ); + _m->begin( ); + _m->end( ); + _m->control( T_BOTTONE, DLG_ELABORA, 202 ); _m->begin( ); _m->prompt( 4, 1, "E~labora" ); _m->picture(TOOL_ELABORA); _m->end( ); + _m->control( T_BOTTONE, DLG_PREVIEW, 202 ); + _m->begin( ); + _m->prompt( 5, 1, "Anteprima" ); + _m->picture(TOOL_PREVIEW); + _m->end( ); + _m->control( T_BOTTONE, DLG_PRINT, 202 ); _m->begin( ); _m->prompt( 5, 1 ); _m->message( "EXIT,20082" ); _m->end( ); - + _m->control( T_BOTTONE, DLG_CONFERMA, 202 ); _m->begin( ); _m->prompt( 6, 1, "~Conferma"); @@ -1505,6 +1515,10 @@ void TMask_generator::genera( const TString& profilo ) _m->flag("D"); _m->end( ); + _m->control( T_BOTTONE, DLG_NULL, 202 ); + _m->begin( ); + _m->end( ); + _m->control( T_BOTTONE, DLG_FIRSTREC, 202 ); _m->begin( ); _m->prompt( 7, 1, "Primo"); @@ -1540,32 +1554,32 @@ void TMask_generator::genera( const TString& profilo ) _m->picture(TOOL_LASTREC); _m->end( ); + _m->control( T_BOTTONE, DLG_NULL, 202 ); + _m->begin( ); + _m->end( ); + + /* Occupa spazio prezioso _m->control( T_BOTTONE, DLG_INFO, 202 ); _m->begin( ); _m->prompt( 12, 1, "Info"); _m->message( "EXIT,332" ); _m->picture(TOOL_INFO); _m->end( ); - -/* non funziona per ora -_m->control( T_BOTTONE, DLG_HELP, 202 ); - _m->begin( ); - _m->prompt( 12, 1 ); - _m->message( "EXIT,331" ); - _m->picture(BMP_HELP); - _m->end( ); */ + */ _m->control( T_BOTTONE, DLG_CANCEL, 202 ); _m->begin( ); - _m->prompt( 13, 1 ); + _m->prompt( 13, 1, PR("Indietro") ); _m->message( "EXIT,27" ); _m->end( ); + /* Occupa spazio prezioso _m->control( T_BOTTONE, DLG_QUIT, 202 ); _m->begin( ); _m->prompt( 14, 1 ); _m->message( "EXIT,20334" ); _m->end( ); + */ // End della toolbar _m->end( ); diff --git a/ve/velib06.cpp b/ve/velib06.cpp index ecabfaccb..12f9a17ce 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -161,6 +161,7 @@ TDocumento_mask::TDocumento_mask(const char* td) set_field_handler( F_DATADOCRIF, datadocrif_handler); set_handler( DLG_ELABORA, elabora_handler ); set_handler( DLG_PRINT, print_handler ); + set_handler( DLG_PREVIEW, print_handler ); set_handler( DLG_CONFERMA, confirm_handler ); const TString_array& handlers = tdoc.handlers(); @@ -3134,9 +3135,14 @@ bool TDocumento_mask::elabora_handler( TMask_field& f, KEY key ) bool TDocumento_mask::print_handler( TMask_field& f, KEY key ) { - if (key == K_SPACE) - main_app().print(); - return TRUE; + if (key == K_SPACE) + { + if (f.dlg() == DLG_PREVIEW) + main_app().preview(); + else + main_app().print(); + } + return true; } void TDocumento_mask::set_field_handler(short fieldid, CONTROL_HANDLER handler)