From 76d2e432933a9e2744e7ac23e3b86eb28af2170a Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 21 Oct 1996 10:42:45 +0000 Subject: [PATCH] default.url Aggiunto supporto per l'italiano printer.cpp Vietao il registra di configurazioni utente text.cpp Modificati include inutili text.h Cambiati valori di un enum per compatibilita con release 4.5 viswin.cpp Tolto bottone di chiusura window.cpp Aggiunti controlli sulla chiusura/distruzione delle finestre. git-svn-id: svn://10.65.10.50/trunk@3804 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/default.url | 4 +++- include/printer.cpp | 13 +++++------ include/text.cpp | 6 +++-- include/text.h | 17 ++++++++------- include/viswin.cpp | 53 +++++++++------------------------------------ include/window.cpp | 29 ++++++++++++++++++++----- 6 files changed, 55 insertions(+), 67 deletions(-) diff --git a/include/default.url b/include/default.url index ae638f46d..239adcea3 100755 --- a/include/default.url +++ b/include/default.url @@ -3,8 +3,10 @@ #define QAPPNAME "PRASSI" #endif +#define LANG_ITA_W52 + #ifndef LIBDIR -#define LIBDIR f:\xvt.403\win_x86\ptk\lib +#define LIBDIR c:\xvt.450\w16_x86\lib #endif #define NO_STD_EDIT_MENU diff --git a/include/printer.cpp b/include/printer.cpp index e94083ffc..76603edf6 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -1072,7 +1072,6 @@ TPrinter::TPrinter() // char szDevice[50]; // get default printer driver GetProfileString ("windows", "device", ",,,", defPrinter, sizeof(defPrinter)); - TToken_string& pn2 = getprinternames(); // get printer names @@ -1099,7 +1098,6 @@ TPrinter::TPrinter() WriteProfileString("windows", "device", pdev); } - set_fincatura("+++++++++-|"); #else @@ -1759,15 +1757,17 @@ bool TPrinter::set() { main_app().disable_menu_item (M_FILE_PG_SETUP); - TMask* msk = new TMask("bagn001a"); - TMask& mask = *msk; + TMask mask("bagn001a"); TToken_string pn1(50), pn2(100); int i; mask.set(MSK_FILENAME, _printerfile); mask.set(MSK_NPAGES, _ncopies); - mask.enable(DLG_OK, _config == "Printer"); + + const bool can_save = _config == "Printer"; + mask.enable(DLG_OK, can_save); + mask.enable(DLG_SAVEREC, can_save); #if XVT_OS == XVT_OS_WIN @@ -1844,7 +1844,6 @@ bool TPrinter::set() s_printrcd * rcd = get_printrcd(); memcpy(rcd, (const char *) oldrcd, _print_rcd_size); set_win_formlen(); - delete msk; return FALSE; } @@ -1882,8 +1881,6 @@ bool TPrinter::set() main_app().enable_menu_item (M_FILE_PG_SETUP); - if (msk) - delete msk; return TRUE; } diff --git a/include/text.cpp b/include/text.cpp index 0707e3601..94c34d535 100755 --- a/include/text.cpp +++ b/include/text.cpp @@ -1,8 +1,10 @@ #include -#include -#include #include +#include +#include +#include +#include static char TEXT_TMP[513]; diff --git a/include/text.h b/include/text.h index 5e68c0be6..3c854034a 100755 --- a/include/text.h +++ b/include/text.h @@ -10,11 +10,11 @@ #endif #ifndef __RELATION_H -#include +class TRelation; #endif -#ifndef __WINDOW_H -#include +#ifndef __WINDOW_H +struct TPoint; #endif // @doc INTERNAL @@ -30,11 +30,12 @@ enum direction { // @enum style | Stile del carattere da utilizzare per il disegno del testo enum style { - normal = XVT_FS_NONE, // @emem Stile carattere normale - bold = XVT_FS_BOLD, // @emem Stile carattere in grassetto - italic = XVT_FS_ITALIC, // @emem Stile carattere in corsivo - underlined = XVT_FS_UNDERLINE, // @emem Stile carattere sottolineato - tabbed = XVT_FS_SCALE }; // @emem Stile carattere scalato + normal, // @emem Stile carattere normale + bold, // @emem Stile carattere in grassetto + italic, // @emem Stile carattere in corsivo + underlined, // @emem Stile carattere sottolineato + tabbed // @emem Stile di comodo per tabulazioni +}; // @doc EXTERNAL diff --git a/include/viswin.cpp b/include/viswin.cpp index 44a68a0c3..5e689f4a2 100755 --- a/include/viswin.cpp +++ b/include/viswin.cpp @@ -244,9 +244,7 @@ void TViswin::exec_link() { ((TPrint_application&)main_app()).repeat_print(); ((TPrint_application&)main_app()).current_cursor()->freeze(FALSE); -#if XVT_OS == XVT_OS_WIN xvt_statbar_refresh (); -#endif stop_run(K_ENTER); } } @@ -307,13 +305,13 @@ void TViswin::erase_link ( paint_link (y, x1, x2); _link_displayed = FALSE; if (in_update) return; -#if XVT_OS == XVT_OS_WIN + if (!in_update) { xvt_statbar_set(""); xvt_statbar_refresh(); } -#endif + if (_link_button) { if (_showbuts) _link_button->disable(); @@ -649,7 +647,6 @@ void TViswin::paint_screen () paint_row (rw); else if (!_isopen) { -#if XVT_OS == XVT_OS_WIN autoscroll (FALSE); set_mode (M_COPY); set_pen (COLOR_BLACK); @@ -671,7 +668,6 @@ void TViswin::paint_screen () (int)columns()+1, (int)(rows()-(long)BUTTONROW_SIZE)); autoscroll (TRUE); break; -#endif } } } @@ -924,7 +920,6 @@ void TViswin::paint_row (long j) printat (X_OFFSET+pos, row, fill); } -#if XVT_OS == XVT_OS_WIN // paint page limits if ((j % _formlen) == (_formlen - 1) && _toplevel) // last row { PNT b, e; @@ -937,7 +932,7 @@ void TViswin::paint_row (long j) xvt_dwin_draw_set_pos (win(), b); xvt_dwin_draw_line (win(), e); } -#endif + autoscroll (TRUE); } @@ -977,7 +972,7 @@ void TViswin::paint_column ( const long riga_txt = orig_y + l; const int riga_scr = (int)l+Y_OFFSET; paint_background (riga_txt, riga_scr); -#if XVT_OS == XVT_OS_WIN // paint page limits + if ((riga_txt% _formlen) == (_formlen - 1) && _toplevel) { PNT b, e; @@ -990,16 +985,15 @@ void TViswin::paint_column ( xvt_dwin_draw_set_pos (win(), b); xvt_dwin_draw_line (win(), e); } -#endif const char *c = (const char *) _txt.line (riga_txt); -#if XVT_OS != XVT_OS_SCOUNIX + int st = _txt.get_style ((int) j); set_font (PRINT_FONT, st, PRINT_HEIGHT); COLOR bg = trans_color (_txt.get_background ((int) j)); COLOR fg = trans_color (_txt.get_foreground ((int) j)); set_color (fg, bg); -#endif + printat (col, riga_scr, "%c", (unsigned int) j < strlen (c) ? c[(int) j] : ' '); } @@ -1012,8 +1006,6 @@ void TViswin::paint_column ( void TViswin::draw_crossbars () // prints reference crossbars { -#if XVT_OS == XVT_OS_WIN - if (_cross.v > taby(1) && _cross.v < taby(rows () - BUTTONROW_SIZE) && _cross.h > tabx (X_OFFSET - 1) && _cross.h < tabx(columns()) ) { @@ -1037,7 +1029,6 @@ void TViswin::draw_crossbars () xvt_dwin_draw_line (win (), e2); autoscroll (TRUE); } -#endif } void TViswin::display_crossbar () @@ -1159,18 +1150,9 @@ void TViswin::paint_selection () void TViswin::paint_waitbar ( bool xor) // @parm Utilizzato in UNIX. (default TRUE) { -#if XVT_OS == XVT_OS_WIN HIDDEN int pic = 0; ((TImage&)_modules[pic]).draw(win()); pic = (pic+1) & 0x3; -#else - autoscroll (FALSE); - if (xor) - invert_bar (3, rows() - 2, 4, rows() - 1); - else - printat (3, rows() - 2, "%c", '*'); - autoscroll (TRUE); -#endif } void TViswin::txt_clear(COLOR color) @@ -1215,10 +1197,8 @@ void TViswin::update () // bar ((X_OFFSET -1), rows()-BUTTONROW_SIZE, columns() + 1, rows() + 1); //** if (_showbuts && _isopen) paint_waitbar (FALSE); -#if XVT_OS == XVT_OS_WIN -else - if (_showbuts) ((TImage&)_modules[4]).draw(win()); -#endif + else + if (_showbuts) ((TImage&)_modules[4]).draw(win()); autoscroll (TRUE); paint_header (); paint_screen (); @@ -1249,12 +1229,10 @@ void TViswin::scroll_error(long x, long y) beep(); update_thumb(x, y); -#if XVT_OS == XVT_OS_WIN POINT p; GetCursorPos(&p); if (x < 0) p.x -= 16; if (y < 0) p.y -= 16; SetCursorPos(p.x, p.y); -#endif } @@ -1267,10 +1245,8 @@ void TViswin::on_button(short dlg) if (_isopen) abort_print(); else { -#if XVT_OS == XVT_OS_WIN xvt_statbar_set(""); xvt_statbar_refresh(); -#endif stop_run(K_ENTER); } break; @@ -1351,11 +1327,9 @@ void TViswin::handler (WINDOW win, EVENT * ep) dispatch_e_char(win, CTRL_E); break; case M_EDIT_SEL_ALL: // stampa -#if XVT_OS == XVT_OS_WIN xvt_statbar_set (""); xvt_statbar_refresh (); stop_run(CTRL_S); -#endif break; case M_SHOW_RULERS: // mostra righelli show_rulers(!_rulers); @@ -1366,10 +1340,8 @@ void TViswin::handler (WINDOW win, EVENT * ep) check_menu_item(M_SHOW_BUTTONS, _showbuts); break; case M_EDIT_QUIT: // chiudi -#if XVT_OS == XVT_OS_WIN xvt_statbar_set (""); xvt_statbar_refresh (); -#endif stop_run (K_ENTER); break; case M_EDIT_COPY: // copia nella clipboard @@ -1837,7 +1809,7 @@ void TViswin::handler (WINDOW win, EVENT * ep) display_selection (); } if (ep->type != E_UPDATE || _need_update) - TWindow ::handler (win, ep); + TWindow::handler (win, ep); else if (ep->type == E_UPDATE) update (); } @@ -1900,11 +1872,8 @@ bool TViswin::on_key (KEY key) abort_print (); else { - -#if XVT_OS == XVT_OS_WIN xvt_statbar_set (""); xvt_statbar_refresh (); -#endif stop_run (K_ESC); } break; @@ -2544,16 +2513,14 @@ TViswin::TViswin(const char *fname, if (_toplevel && alt > maxalt) maxalt = alt; -#if XVT_OS == XVT_OS_WIN for (int i = 0; i < 4; i++) _modules.add(new TImage(BMP_MODULE1 + i), i); _modules.add(new TImage(BMP_MODULE), i); -#endif long flags = WSF_HSCROLL | WSF_VSCROLL; if (_toplevel) { - flags |= (WSF_CLOSE | WSF_SIZE); + flags |= WSF_SIZE /* | WSF_CLOSE */; } WIN_TYPE rt = _toplevel ? W_DOC : W_PLAIN; diff --git a/include/window.cpp b/include/window.cpp index 18ef730c0..39b640102 100755 --- a/include/window.cpp +++ b/include/window.cpp @@ -284,6 +284,14 @@ bool can_close() return WinManager.can_close(); } +bool is_valid_window(WINDOW w) +{ + bool ok = FALSE; + if (w != NULL_WIN) + ok = xvt_vobj_get_attr(w, ATTR_NATIVE_WINDOW) != NULL; + return ok; +} + // @func Ritorna l'handle della finestra corrente // // @rdesc Restituisce l'handle della finestra corrente. @@ -291,8 +299,18 @@ WINDOW cur_win() // @comm Se non esiste una finestra corrente allora ritorna NULL_WIN { - const TWindow* w = WinManager.cur_win(); - return w ? w->win() : NULL_WIN; + WINDOW win = NULL_WIN; + TWindow* w = WinManager.cur_win(); + if (w) + { + win = w->win(); + if (!is_valid_window(w->win())) + { + w->stop_run(K_FORCE_CLOSE); + win = NULL_WIN; + } + } + return win; } /////////////////////////////////////////////////////////// @@ -587,7 +605,7 @@ TWindow::~TWindow() { if (_win != NULL_WIN) { - if (xvt_vobj_get_attr(_win, ATTR_NATIVE_WINDOW) != 0) + if (is_valid_window(_win)); xvt_vobj_destroy(_win); _win = NULL_WIN; } @@ -597,7 +615,7 @@ TWindow::~TWindow() void TWindow::open() { WINDOW w = win(); - CHECK(w != NULL_WIN, "Can't open a NULL window"); + CHECK(is_valid_window(w), "Can't open a NULL window"); xvt_vobj_set_visible(w, _open = TRUE); xvt_scr_set_focus_vobj(w); xvt_vobj_raise(w); @@ -617,7 +635,8 @@ void TWindow::open_modal() void TWindow::close() { CHECK(_win != NULL_WIN, "Can't close a NULL window"); - xvt_vobj_set_visible(_win, _open = FALSE); + if (is_valid_window(_win)) + xvt_vobj_set_visible(_win, _open = FALSE); }