From e61426336ca4219abc0815564b9d0e21f81ca1e2 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 24 Oct 1994 15:06:49 +0000 Subject: [PATCH] Modificati leggermete metodi dei TMessage e TMailbox Aggiunta distruzione cursori alla printapp F2 cancella anche i campi automagic e persistent git-svn-id: svn://10.65.10.50/trunk@446 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/config.cpp | 4 ++-- include/date.h | 3 +-- include/mailbox.cpp | 12 +++++------- include/mailbox.h | 32 ++++++++++++++++---------------- include/maskfld.cpp | 5 +++-- include/msksheet.cpp | 17 +++++++++++++++++ include/printapp.cpp | 21 +++++++++++++++------ include/printapp.h | 2 +- include/printer.cpp | 34 +++++++++++++++------------------- include/relapp.cpp | 6 +++--- include/utility.cpp | 3 ++- 11 files changed, 80 insertions(+), 59 deletions(-) diff --git a/include/config.cpp b/include/config.cpp index b272f64ef..8636edc56 100755 --- a/include/config.cpp +++ b/include/config.cpp @@ -32,7 +32,7 @@ bool TConfig::_read_paragraph() int ind = l.find('='); if (ind == -1) { - warning_box("Errore configurazione: file %s, vicino a riga %ud", + warning_box("Errore configurazione: file %s, vicino alla riga %ud", (const char*)_file, scan.linenum()); continue; } @@ -171,7 +171,7 @@ bool TConfig::set(const char* var, const char* value, const char* section, bool TConfig::set(const char* var, long value, const char* section, bool force, int index) { - TString t; t << value; + TString16 t; t << value; return set(var,t,section,force,index); } diff --git a/include/date.h b/include/date.h index d9e3290e5..aab6e65d3 100755 --- a/include/date.h +++ b/include/date.h @@ -26,8 +26,6 @@ class TDate : TObject friend bool operator ==(const TDate& a, const TDate& b); friend bool operator !=(const TDate& a, const TDate& b); - static int last_day(int month, int year); - public: // @FPUB char* string(int yeardgts = 4, char sep = '-') const ; @@ -41,6 +39,7 @@ public: bool ok() const; // Vero se la data e' corretta static bool isdate(const char*); // Vero se la stringa passata e' una data corretta + static int last_day(int month, int year); bool is_end_month(); void set_end_month(); // setta il giorno del mese all'ultimo possibile // implementando la filastrocchina diff --git a/include/mailbox.cpp b/include/mailbox.cpp index 0a2135a15..2998e0516 100755 --- a/include/mailbox.cpp +++ b/include/mailbox.cpp @@ -1,4 +1,4 @@ -// $Id: mailbox.cpp,v 1.3 1994-09-28 10:35:45 villa Exp $ +// $Id: mailbox.cpp,v 1.4 1994-10-24 15:06:26 guy Exp $ #include #include @@ -21,7 +21,7 @@ TMessage::TMessage(const char* to, const char* sub, const char* text, { _to = to; _subject = sub; _text = text; - _from = (from == NULL ? MainApp()->name() : from); + _from = (from == NULL || *from == '\0' ? main_app().name() : from); _flags = 0x00; _number = -1; } @@ -136,10 +136,8 @@ TMessage* TMailbox::next_f(char* f, bool read) void TMailbox::send(TMessage& m) { - - CHECK(m.from() != NULL && m.to() != NULL && - (m.subject() != NULL || m.body() != NULL), - "can't send partially empty message"); + CHECK(m.from() && m.to() && (m.subject() || m.body()), + "Can't send partially empty message"); // strcpy(to_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR")); TFilename to_path; to_path.tempdir(); @@ -175,7 +173,7 @@ char* TMailbox::readcmd(char*) TMailbox::TMailbox(const char* appname) : _msgs(DEF_MSGS_CAPACITY) { if (appname == NULL) - appname = MainApp()->name(); // myself; must be global + appname = main_app().name(); // myself; must be global _path.tempdir(); // strcpy(_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR")); diff --git a/include/mailbox.h b/include/mailbox.h index c88b24655..a9512df34 100755 --- a/include/mailbox.h +++ b/include/mailbox.h @@ -1,4 +1,4 @@ -// $Id: mailbox.h,v 1.3 1994-09-28 10:35:46 villa Exp $ +// $Id: mailbox.h,v 1.4 1994-10-24 15:06:27 guy Exp $ /* si', trattasi di -*-c++-*- */ // Mailbox.h @@ -21,31 +21,31 @@ class TMessage : public TObject // basic message { - TString _from; - TString _to; - TString _subject; + TString16 _from; + TString16 _to; + TString80 _subject; TString _text; byte _flags; int _number; friend class TMailbox; +protected: void setread() { _flags |= MSG_READ; } bool isread() { return _flags & MSG_READ; } - int number(int n = -1) - { return (n == -1 ? _number : (_number = n)); } + int number(int n = -1) { return (n == -1 ? _number : (_number = n)); } public: + const TString& from() const { return _from; } + const TString& to() const { return _to; } + const TString& subject() const { return _subject; } + const TString& body() const { return _text; } - const char* from(const char* f = NULL) // get-set sender - { return f == NULL ? _from : (_from = f); } - const char* to (const char* f = NULL) // get-set recipient - { return f == NULL ? _to : (_to = f); } - const char* subject(const char* f = NULL) // get-set subject - { return f == NULL ? _subject : (_subject = f); } - const char* body(const char* f = NULL) // get-set body - { return f == NULL ? _text : (_text = f); } - + const TString& from(const char* f) { return _from = f; } + const TString& to(const char* t) { return _to = t; } + const TString& subject(const char* s) { return _subject = s; } + const TString& body(const char* b) { return _text = b; } + void send(); TMessage(const char* to, const char* sub, const char* text, @@ -58,7 +58,7 @@ class TMailbox : public TObject TArray _msgs; int _lastread, n_new; long _lastpos; - int _cnt; + int _cnt; protected: diff --git a/include/maskfld.cpp b/include/maskfld.cpp index dec57f388..e14a0cb50 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -1,4 +1,4 @@ -// $Id: maskfld.cpp,v 1.34 1994-10-20 13:32:15 guy Exp $ +// $Id: maskfld.cpp,v 1.35 1994-10-24 15:06:30 guy Exp $ #include #include @@ -732,7 +732,8 @@ bool TMask_field::on_key(KEY key) beep(); break; case K_F2: - reset(); + if (is_edit()) set(""); + else reset(); set_dirty(); break; case K_F3: diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 50bdeea24..da3d21de0 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -871,7 +871,24 @@ void TSpreadsheet::enable_cell(int row, int column, bool on) void TSpreadsheet::enable_column(int col, bool on) { + const bool change = _column_disabled[col] == on; _column_disabled.set(col, !on); + if (change) + { + int num; + XI_OBJ** columns = xi_get_member_list(_list, &num); + CHECKD(col+1 < num, "Can't enable column ", col); + XI_OBJ* column = columns[col+1]; + + long attr = xi_get_attrib(column); + if (on) attr |= XI_ATR_ENABLED; + else attr &= ~XI_ATR_ENABLED; + + xi_move_focus(_itf); // Set focus to interface + xi_set_attrib(column, attr); // Set new attributes + RCT r; xi_get_rect(column, &r); + xi_set_column_width(column, (r.right-r.left+1) / CHARX); // Force redraw + } } diff --git a/include/printapp.cpp b/include/printapp.cpp index e0f5633c3..1a47de18b 100755 --- a/include/printapp.cpp +++ b/include/printapp.cpp @@ -1,4 +1,4 @@ -// $Id: printapp.cpp,v 1.12 1994-09-22 07:47:59 guy Exp $ +// $Id: printapp.cpp,v 1.13 1994-10-24 15:06:37 guy Exp $ #include #include @@ -1217,8 +1217,9 @@ bool TPrint_application::create () bool TPrint_application::destroy () { user_destroy (); - TApplication::destroy (); - return TRUE; + reset_files(); + _cursors.destroy(); + return TApplication::destroy (); } void TPrint_application::do_print (int n) @@ -1274,7 +1275,15 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10), _last_choice = BAR_ITEM (1); } +void TPrint_application::reset_files() +{ + if (_pr_tree != NULL) + { + _reset_tree(_pr_tree); + _pr_tree = NULL; + } +} + + TPrint_application::~TPrint_application () -{ - reset_files (); -} +{} diff --git a/include/printapp.h b/include/printapp.h index 27560fdff..719f7e84a 100755 --- a/include/printapp.h +++ b/include/printapp.h @@ -415,7 +415,7 @@ public: void reset_footer(); // vedi sopra per capire - void reset_files() { _reset_tree(_pr_tree); _pr_tree = NULL; } + void reset_files(); void add_file(int file, int from = 0); void add_file(const char* tab, int from = 0); diff --git a/include/printer.cpp b/include/printer.cpp index 7601d20cc..41315a65e 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -662,7 +662,7 @@ TPrinter::TPrinter() _headersize = 0; _footersize = 0; _isopen = FALSE; - _multiple_copies = MainApp()->class_id() == CLASS_PRINT_APPLICATION; + _multiple_copies = main_app().class_id() == CLASS_PRINT_APPLICATION; // read configuration file read_configuration (_config); @@ -743,7 +743,7 @@ void TPrinter::read_configuration (const char *conf) } fclose (cnfp); - TString s ("printer.def"); + TFilename s ("printer.def"); #if XVT_OS == XVT_OS_SCOUNIX s << format (".%d", getuid ()); #endif @@ -1133,11 +1133,18 @@ bool TPrinter::open () void TPrinter::set() { + main_app().disable_menu_item (M_FILE_PG_SETUP); + TMask mask ("bagn001a"); TToken_string pn1 (50), pn2 (100); int i; + + TFilename defile("printer.def"); +#if XVT_OS == XVT_OS_SCOUNIX + defile << format (".%d", getuid ()); +#endif + mask.set_workfile(defile); - MainApp()->disable_menu_item (M_FILE_PG_SETUP); #if XVT_OS != XVT_OS_WIN @@ -1177,19 +1184,12 @@ void TPrinter::set() mask.set(MSK_1_NPAGES, _ncopies); mask.reset (MSK_1_SAVE); - + if (mask.run () == K_ESC) return; - if (mask.get (MSK_1_SAVE).not_empty ()) - { - TString s ("printer.def"); -#if XVT_OS == XVT_OS_SCOUNIX - s << format (".%d", getuid ()); -#endif - mask.set_workfile (s); - mask.save (); - } + if (mask.get_bool(MSK_1_SAVE)) + mask.save(); // get user choices @@ -1302,12 +1302,8 @@ void TPrinter::set() _curprn = atoi(mask.get(MSK_1_PRINTERS)); - if (mask.get (MSK_1_SAVE).not_empty ()) - { - TString s ("printer.def"); - mask.set_workfile (s); + if (mask.get_bool(MSK_1_SAVE)) mask.save (); - } _ncopies = atoi (mask.get (MSK_1_NPAGES)); @@ -1337,7 +1333,7 @@ void TPrinter::set() #endif - MainApp ()->enable_menu_item (M_FILE_PG_SETUP); + main_app().enable_menu_item (M_FILE_PG_SETUP); } void TPrinter::close () diff --git a/include/relapp.cpp b/include/relapp.cpp index b14242a1a..ad287ecb4 100755 --- a/include/relapp.cpp +++ b/include/relapp.cpp @@ -1,4 +1,4 @@ -// $Id: relapp.cpp,v 1.18 1994-10-20 13:32:20 guy Exp $ +// $Id: relapp.cpp,v 1.19 1994-10-24 15:06:47 guy Exp $ #include #include #include @@ -799,7 +799,7 @@ bool TRelation_application::filter() if (msg) { _mask = get_mask(MODE_MOD); - TToken_string body(msg->body()); + TToken_string body = msg->body(); short id = body.get_int(); while (id > 0) @@ -843,13 +843,13 @@ bool TRelation_application::filter() { TToken_string body(msg->body()); const int key = body.get_int(); - const int max = _mask->fields(); _autoins_caller = msg->from(); _lnflag = TRUE; const char* v = body.get(); + const int max = _mask->fields(); for (int i = 0; i < max && v != NULL; i++) { TMask_field& f = _mask->fld(i); diff --git a/include/utility.cpp b/include/utility.cpp index a886cbcc9..f2eaffcc8 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -75,7 +75,8 @@ char* format(const char* fmt, ...) const char* cmd2name(const char* argv0, const char* argv1) { TFilename app(argv0); app.ext(""); app = app.name(); - if (argv1 != NULL) app << ' ' << argv1; + if (argv1 != NULL && *argv1 != '\0') app << ' ' << argv1; + else app << " -0"; app.lower(); const int par = app.find(" -");