diff --git a/include/applicat.cpp b/include/applicat.cpp index e0f14d574..29a9ef3f4 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -1,5 +1,3 @@ -#define STRICT -#define XVT_INCL_NATIVE #include #include #include @@ -78,7 +76,7 @@ HIDDEN const char* prassi_spa(TString& firm) } if (firm.empty()) - firm = "PR.A.S.S.I. S.p.A."; + firm = "Campo"; return firm; } @@ -89,11 +87,8 @@ HIDDEN const char* prassi_spa(TString& firm) HIDDEN long backdrop_eh(WINDOW win, EVENT* ep) { - bool has_palette = TRUE; -#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 - HDC hdc = (HDC)xvt_vobj_get_attr(win, ATTR_NATIVE_GRAPHIC_CONTEXT); - has_palette = (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) != 0; -#endif + XVT_DISPLAY_TYPE type = (XVT_DISPLAY_TYPE)xvt_vobj_get_attr(win, ATTR_DISPLAY_TYPE); + bool has_palette = type != XVT_DISPLAY_DIRECT_COLOR; if (!has_palette) { @@ -148,7 +143,7 @@ public: TBanner::TBanner() { - create(-1, 6, 72, 6, "BANNER", WSF_NONE, W_PLAIN); + create(-1, 1, 76, 4, "BANNER", WSF_NONE, W_PLAIN); hide_brush(); open(); do_events(); @@ -186,11 +181,6 @@ void TBanner::handler(WINDOW win, EVENT* ep) x = (r.right-r.left-w)>>1; y = BIGY; xvt_dwin_draw_text(win, x, y, t, -1); - t = "Caricamento in corso"; - w = xvt_dwin_get_text_width(win, t, -1); - x = (r.right-r.left-w)>>1, y = r.bottom - CHARY; - xvt_dwin_draw_text(win, x, y, t, -1); - r.left += 5; r.right -= 4; r.top += 5; r.bottom -= 4; set_pen(COLOR_WHITE); xvt_dwin_draw_rect(win, &r); @@ -203,7 +193,7 @@ void TBanner::handler(WINDOW win, EVENT* ep) TWindow::handler(win, ep); } -long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep) +long TApplication::task_eh(WINDOW win, EVENT *ep) { switch (ep->type) { @@ -275,7 +265,7 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep) break; } - return _application->handler(win, ep); + return _application->handler(win, ep); } void TApplication::dispatch_e_menu(MENU_TAG tag) @@ -350,6 +340,10 @@ long TApplication::handler(WINDOW win, EVENT* ep) case E_CLOSE: if (can_close()) stop_run(); +#ifdef XVGUY + else + return 1; // Divieto! +#endif break; case E_FONT: { @@ -489,7 +483,7 @@ const char* TApplication::get_module_name() const TString& module = ((TApplication*)this)->_module_name; // Fool the compiler if (module.empty()) { - TScanner scanner("prassi.aut"); + TScanner scanner(AUT_FILE); bool ok = FALSE; for (int aut = 0; scanner.line() != ""; aut++) diff --git a/include/applicat.h b/include/applicat.h index 6d83d0c64..4ba26595f 100755 --- a/include/applicat.h +++ b/include/applicat.h @@ -9,7 +9,6 @@ #include #endif - #define MSG_AI "AI" // message auto_insert (relapp) #define MSG_FS "FS" // message filtered start (relapp) #define MSG_LN "LN" // message link (printapp -> relapp) @@ -18,6 +17,12 @@ #define CHK_DONGLE 0 // dongle authorization checks #define CHK_USER 1 // user authorization checks +#ifdef XVGUY +#define AUT_FILE "campo.aut" +#else +#define AUT_FILE "prassi.aut" +#endif + #ifndef __ASSOC_H class TAssoc_array; #endif @@ -73,7 +78,7 @@ protected: // @cmember Ritorna il nome del modulo dell'applicazione const char* get_module_name() const; // @cmember Event handler della finestra principale del programma - static long XVT_CALLCONV1 task_eh(WINDOW win, EVENT* ep); + static long task_eh(WINDOW win, EVENT* ep); // @cmember Handler degli eventi della finestra principale, chiamato da virtual long handler(WINDOW win, EVENT* ep); diff --git a/include/array.cpp b/include/array.cpp index d94909438..3c1f203e2 100755 --- a/include/array.cpp +++ b/include/array.cpp @@ -1,5 +1,6 @@ -#include #include +#include +#include #include diff --git a/include/bagn001a.h b/include/bagn001a.h index a480a31f0..8ee3e6956 100755 --- a/include/bagn001a.h +++ b/include/bagn001a.h @@ -3,7 +3,7 @@ #define MSK_TYPE 101 #define MSK_FILENAME 102 #define MSK_PRINTERS 103 -#define MSK_CODES 111 +// #define MSK_CODES 111 // IMPORTANTE! lasciare il numero 111, // in modo che la maschera sia compatibile // con i metodi di ba2300, usati anche @@ -14,7 +14,9 @@ #define MSK_NPAGES 337 #define MSK_FONT 338 +/* #define MSK_PRINTERFILE prn.epf #define MSK_NAMESFILE nms.epf #define PRINTERSFILE "prn.epf" #define NAMESFILE "nms.epf" +*/ \ No newline at end of file diff --git a/include/bagn001a.uml b/include/bagn001a.uml index 59846f325..65c4a1eb5 100755 --- a/include/bagn001a.uml +++ b/include/bagn001a.uml @@ -1,15 +1,14 @@ #include -PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 76 11 +PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 69 11 -RADIOBUTTON MSK_TYPE 1 74 +RADIOBUTTON MSK_TYPE 1 66 BEGIN PROMPT 2 1 "Stampa su..." HELP "Selezionare il tipo dove direzionare la stampa" ITEM "0|Stampante" MESSAGE HIDE,MSK_FILENAME MESSAGE SHOW,MSK_PRINTERS|ENABLE,MSK_PRINTERS - MESSAGE ENABLE,MSK_CODES MESSAGE ENABLE,MSK_SIZE MESSAGE ENABLE,MSK_LINES MESSAGE ENABLE,MSK_FONT @@ -17,7 +16,6 @@ BEGIN ITEM "2|Visualizzazione" MESSAGE HIDE,MSK_FILENAME MESSAGE SHOW,MSK_PRINTERS|DISABLE,MSK_PRINTERS - MESSAGE DISABLE,MSK_CODES MESSAGE DISABLE,MSK_SIZE MESSAGE DISABLE,MSK_LINES MESSAGE DISABLE,MSK_FONT @@ -25,7 +23,6 @@ BEGIN ITEM "1|File su disco" MESSAGE SHOW,MSK_FILENAME MESSAGE HIDE,MSK_PRINTERS - MESSAGE ENABLE,MSK_CODES MESSAGE DISABLE,MSK_SIZE MESSAGE DISABLE,MSK_LINES MESSAGE DISABLE,MSK_FONT @@ -51,14 +48,7 @@ BEGIN WARNING "E' necessario specificare un nome di file" END -LIST MSK_CODES 40 -BEGIN - PROMPT 4 6 "Tipo stampa " - HELP "Modalita' nelle quale si desidera la stampa" - FLAGS "H" -END - -LIST MSK_FONT 2 16 +LIST MSK_FONT 32 BEGIN PROMPT 4 6 "Font " HELP "Font di stampa su video o stampante" @@ -67,14 +57,14 @@ END LIST MSK_SIZE 3 BEGIN - PROMPT 31 6 "Carattere " - ITEM "12|12" + PROMPT 53 6 "Carattere " + ITEM "10|10" HELP "Dimensioni del carattere di stampa" END LIST MSK_LINES 3 BEGIN - PROMPT 52 6 "Linee/Inch " + PROMPT 45 7 "Linee per pollice " ITEM "4|4" ITEM "5|5" ITEM "6|6" diff --git a/include/ccustio.h b/include/ccustio.h index e9eea4bb3..9333710e6 100755 --- a/include/ccustio.h +++ b/include/ccustio.h @@ -20,6 +20,17 @@ typedef char *FileName; typedef char *RecType; typedef long RecNoType; + +#ifdef __GNUC__ +#define __PACKED__ __attribute__ ((packed)) +#define __ALIGNED__ __attribute__ ((aligned(2))) +#define __PACK_1__ +#else +#define __PACKED__ +#define __ALIGNED__ +#pragma pack(2) +#endif + typedef struct { int F; FILE *Fd; @@ -43,14 +54,9 @@ typedef struct { #endif #define BLOCKEXT(len,rec) (((((RecNoType) (len)) * ((RecNoType) (rec))) / BlockLenIO) + 1) -/* @(!) 2.3.01.325 */ #ifdef DOS -//#define ASPETTA(x) (sleep_dos(x)) -#else -//#define ASPETTA(x) (sleep(x)) +#pragma pack() #endif -/* @(:) 2.3.01.325 */ - #ifdef __cplusplus extern "C" { diff --git a/include/cfiles.h b/include/cfiles.h index d57927f4d..5cbe321f5 100755 --- a/include/cfiles.h +++ b/include/cfiles.h @@ -2,7 +2,7 @@ #define __CFILES_H #ifndef __CCUSTIO_H -#include "ccustio.h" +#include "ccustio.h" #endif #ifdef __GNUC__ @@ -54,7 +54,7 @@ typedef struct typedef struct { - BOOLEAN DupKeys __ALIGNED__ ; + short DupKeys __ALIGNED__ ; // Was BOOLEAN and dangerous byte NkFields __ALIGNED__ ; byte FieldSeq[MKFields] __PACKED__ ; byte FromCh[MKFields] __PACKED__ ; diff --git a/include/checks.cpp b/include/checks.cpp index dbbb128af..76e029931 100755 --- a/include/checks.cpp +++ b/include/checks.cpp @@ -36,24 +36,11 @@ bool fatal_box( { buildmsg(); -#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 - MessageBeep(MB_ICONHAND); - MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL); - + xvt_dm_post_fatal_exit(msg); if (xvt_running()) main_app().stop_run(); else exit(1); -#else - beep(); - if (xvt_running()) xvt_dm_post_fatal_exit("%s", msg); - else - { - fprintf(stderr, "%s\n", msg); - getchar(); - exit(1); - } -#endif return 0; } diff --git a/include/codeb.c b/include/codeb.c index c2571837d..423b6fe20 100755 --- a/include/codeb.c +++ b/include/codeb.c @@ -407,7 +407,7 @@ int DB_flush(int handle) #ifdef DBG yesnofatal_box("Sono in attesa nella DB_flush"); #else - u4delay_sec(); + u4delaySec(); #endif return rt; } diff --git a/include/controls.cpp b/include/controls.cpp index 99b6c1afb..2490e0454 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,7 @@ HIDDEN int _last_mouse_button = 0; short low_get_focus_id(WINDOW win) { - XI_OBJ * itf = xi_get_itf(win); + XI_OBJ * itf = xi_get_itf((XinWindow)win); XI_OBJ * obj = xi_get_focus(itf); if (obj == NULL || obj->type == XIT_ITF) @@ -65,7 +66,7 @@ short low_get_focus_id(WINDOW win) // Doesn't work: DON'T USE! void low_set_focus_id(WINDOW win, short cid) { - XI_OBJ * itf = xi_get_itf(win); + XI_OBJ * itf = xi_get_itf((XinWindow)win); if (cid > 0) { } @@ -102,7 +103,7 @@ KEY TControl::xiev_to_key(const XI_EVENT* xiev) class TPicture_array : public TArray { public: - TImage& add(short id); + bool add(short id); const TImage& image(short id) const { return (const TImage&)operator[](id); } bool exist(short id) const { return objptr(id) != NULL; } @@ -112,18 +113,24 @@ public: virtual ~TPicture_array() {} }; -TImage& TPicture_array::add(short id) +bool TPicture_array::add(short id) { TImage* i = (TImage*)objptr(id); - if (i == NULL) { i = new TImage(id); - i->convert_transparent_color(BTN_BACK_COLOR); - TArray::add(i, id); + if (i->ok()) + { + i->convert_transparent_color(BTN_BACK_COLOR); + TArray::add(i, id); + } + else + { + delete i; + i = NULL; + } } - - return *i; + return i != NULL; } void TPicture_array::reload() @@ -156,7 +163,7 @@ XVT_FNTID xvt_default_font(bool bold) TConfig font(CONFIG_USER, "Font"); TString font_ser_desc(font.get("FontDesc")); if (font_ser_desc.empty()) - font_ser_desc << "01\\Courier\\0\\10\\WIN01/-13/0/0/0/400/0/0/0/0/1/2/1/49/Courier"; + font_ser_desc = "01\\Courier\\0\\10\\WIN01/-13/0/0/0/400/0/0/0/0/1/2/1/49/Courier"; xvt_font_deserialize(DEF_FONT, (char *)(const char *) font_ser_desc); xvt_font_map_using_default(DEF_FONT); CHECK(xvt_font_is_mapped(DEF_FONT), "Can't map native font"); @@ -210,6 +217,7 @@ XVT_FNTID xvt_load_default_font() X_FU_MULTIPLE = Y_FU_MULTIPLE = 0; XVT_FNTID font = xvt_default_font(FALSE); + xi_init_sysvals(); // Ricalcola i FU units statbar_set_fontid(TASK_WIN, font); @@ -232,7 +240,7 @@ HIDDEN void set_default_palette(WINDOW win) DISABLED_COLOR, DISABLED_BACK_COLOR, BTN_BACK_COLOR, BTN_LIGHT_COLOR, BTN_DARK_COLOR }; - XVT_PALETTE wp = xvt_vobj_get_palet(win); + XVT_PALETTE wp = xvt_vobj_get_palet(win); if (wp != NULL) { XVT_PALETTE up = xvt_palet_create(XVT_PALETTE_USER, NULL); @@ -416,8 +424,10 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, if (x <= 0 || y <= 0 || dx <= 0 || dy <= 0) { RCT max_rct; xvt_vobj_get_client_rect(parent, &max_rct); +#ifndef WIN32 if (parent == TASK_WIN) max_rct.bottom -= 26; // Non contare la status bar +#endif if (dy <= 0) { @@ -459,11 +469,11 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, def->v.itf->back_color = MASK_BACK_COLOR; def->v.itf->font_id = xvt_default_font(FALSE); def->v.itf->tab_on_enter = TRUE; - def->v.itf->win = win; + def->v.itf->win = (XinWindow)win; #ifdef XI_R4 def->v.itf->edit_menu = TRUE; // Update edit menu items - def->v.itf->menu_win = TASK_WIN; // Window that owns the menu + def->v.itf->menu_win = (XinWindow)TASK_WIN; // Window that owns the menu #endif XI_OBJ* itf = xi_create(NULL, def); @@ -518,7 +528,7 @@ void attach_interface(WINDOW win, COLOR back) def->v.itf->automatic_back_color = FALSE; def->v.itf->back_color = back; def->v.itf->tab_on_enter = TRUE; - def->v.itf->win = win; + def->v.itf->win = (XinWindow)win; XI_OBJ* itf = xi_create(NULL, def); CHECK(itf, "Can't create an interface"); @@ -652,7 +662,7 @@ XI_OBJ* TControl::get_interface(WINDOW win) const } else { - itf = xi_get_itf(win); + itf = xi_get_itf((XinWindow)win); CHECK(itf, "Can't get the interface from a window"); } return itf; @@ -942,7 +952,7 @@ const char* TControl::parse_caption(const char* cap, bool& bold, COLOR& color) c WINDOW TControl::parent() const { - return xi_get_window(_obj->itf); + return (WINDOW)xi_get_window(_obj->itf); } void TControl::set_focus() const @@ -1275,7 +1285,7 @@ void TField_control::show_button(bool on) if (has_button != on) { f->button = on; - xi_invalidate_rect(parent(), &f->btn_rct); + xi_invalidate_rect((XinWindow)parent(), &f->btn_rct); } } @@ -1546,18 +1556,37 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn) { if (bmp_up > 0) { - _picture->add(_bmp_up = bmp_up); - if (bmp_dn > 0) - _picture->add(_bmp_dn = bmp_dn); - else - _bmp_dn = _bmp_up; + _bmp_up = (bmp_up > 0 && _picture->add(bmp_up)) ? bmp_up : 0; + _bmp_dn = (bmp_dn > 0 && _picture->add(bmp_dn)) ? bmp_dn : _bmp_up; set_native_icon(0); - _obj->v.btn->drawable = TRUE; } else - { _bmp_up = _bmp_dn = 0; - } + _obj->v.btn->drawable = _bmp_up > 0; +/* + if (bmp_up > 0) + { + XI_BITMAP* b1 = xi_bitmap_create_res(bmp_up, XI_BITMAP_NORMAL); + xi_bitmap_background_set(b1, BTN_BACK_COLOR); + xi_bitmap_hcenter_set(b1, TRUE); + xi_bitmap_vcenter_set(b1, TRUE); + xi_set_bitmap(_obj, b1); + if (bmp_dn <= 0) + bmp_dn = bmp_up; + } + else + xi_set_bitmap(_obj, NULL); + if (bmp_dn > 0) + { + XI_BITMAP* b2 = xi_bitmap_create_res(bmp_dn, XI_BITMAP_NORMAL); + xi_bitmap_background_set(b2, BTN_BACK_COLOR); + xi_bitmap_hcenter_set(b2, TRUE); + xi_bitmap_vcenter_set(b2, TRUE); + xi_set_down_bitmap(_obj, b2); + } + else + xi_set_down_bitmap(_obj, NULL); +*/ } void TPushbutton_control::update() @@ -1582,6 +1611,11 @@ void TPushbutton_control::update() if (_native_hicon) { + if (_obj->v.btn->down) + { + rct.left += 2; rct.right += 2; + rct.top += 2; rct.bottom += 2; + } os_draw_native_icon(win, rct, _native_hicon); return; } @@ -1913,7 +1947,6 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev) return; const char* row = NULL; -// long rec = 0l; switch(xiev->type) { @@ -2004,8 +2037,8 @@ void TDropDownList::close() _open = FALSE; if (_xi_lst) { - xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), FALSE); - xvt_dwin_update (xi_get_window(_obj->itf)); + xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), FALSE); + xvt_dwin_update((WINDOW)xi_get_window(_obj->itf)); } } } @@ -2129,7 +2162,7 @@ void TDropDownList::create() ld->scroll_bar = items() > 6; ld->no_heading = TRUE; ld->no_horz_lines = TRUE; -// ld->no_vert_lines = TRUE; + ld->no_vert_lines = TRUE; ld->resize_with_window = TRUE; ld->single_select = TRUE; @@ -2143,10 +2176,13 @@ void TDropDownList::create() // Larghezza in pixel del bottone const int bw = int(_obj->itf->v.itf->fu_height * XI_FU_MULTIPLE / _obj->itf->v.itf->fu_width); len -= bw; +#ifdef XVGUY + len -= 4; // Don't ask why +#endif } // Larghezza in form units dell'edit field len = len * XI_FU_MULTIPLE / _obj->itf->v.itf->fu_width - 2; - + if (_obj->type == XIT_CELL) { const int m = calc_min_width(); @@ -2163,7 +2199,7 @@ void TDropDownList::create() RCT l; xi_get_def_rect(lstdef, (XinRect *) &l); PNT p; p.h = r.left; - WINDOW pwin = xi_get_window(_obj->itf); + WINDOW pwin = (WINDOW)xi_get_window(_obj->itf); RCT w; xvt_vobj_get_client_rect(pwin, &w); // place rectangle if (r.bottom + l.bottom - l.top <= w.bottom) @@ -2175,8 +2211,8 @@ void TDropDownList::create() } RCT wr; wr.left = p.h; wr.top = p.v; - xi_get_def_rect(lstdef, (XinRect *) &l); - wr.right = r.right; // wr.left + (l.right - l.left) -1; +// xi_get_def_rect(lstdef, (XinRect *) &l); + wr.right = r.right; wr.bottom = wr.top + l.bottom - l.top; const int delta_x = _obj->itf->v.itf->delta_x; const int delta_y = _obj->itf->v.itf->delta_y; @@ -2187,7 +2223,7 @@ void TDropDownList::create() WINDOW win = xvt_win_create(W_PLAIN, &wr, "", 0, pwin, WSF_NO_MENUBAR, EM_ALL, (EVENT_HANDLER)xi_event, 0L); - itfdef->v.itf->win = win; + itfdef->v.itf->win = (XinWindow)win; itfdef->v.itf->rctp = (XinRect *) ≀ XI_OBJ* itfobj = xi_create(NULL, itfdef); xi_tree_free(itfdef); @@ -2202,7 +2238,7 @@ void TDropDownList::create() void TDropDownList::open() { if (_xi_lst) - xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), TRUE); + xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), TRUE); else create(); @@ -2212,7 +2248,7 @@ void TDropDownList::open() _open = TRUE; xi_cell_request(_xi_lst); - WINDOW win = xi_get_window(_xi_lst->itf); + WINDOW win = (WINDOW)xi_get_window(_xi_lst->itf); xvt_scr_set_focus_vobj(win); xvt_vobj_raise(win); diff --git a/include/controls.h b/include/controls.h index 421e54dcb..5b4d7afc4 100755 --- a/include/controls.h +++ b/include/controls.h @@ -309,7 +309,7 @@ public: void close(); bool is_open() const { return _open; } - const char* item(long i) { return _values.get(int(i)); } + const char* item(long i) { const char* s = _values.get(int(i)); return s ? s : ""; } int items() const { return _values.items(); } long row2rec(int) const; int rec2row(long rec) const; diff --git a/include/date.cpp b/include/date.cpp index cf2f5ee5c..46dc8a40e 100755 --- a/include/date.cpp +++ b/include/date.cpp @@ -1,4 +1,5 @@ #include +#include #include #define __DATE_CPP diff --git a/include/dongle.cpp b/include/dongle.cpp index 6a3d34168..aaf215085 100755 --- a/include/dongle.cpp +++ b/include/dongle.cpp @@ -1,5 +1,5 @@ -#include #define XVT_INCL_NATIVE +#include #include #include @@ -13,15 +13,14 @@ /////////////////////////////////////////////////////////// #ifndef _DEMO_ - #include #define USERADR 26952 #define AGAADR 26953 #define PRASSIADR 26954 #define PROCOMADR 26956 -#define REFKEY "CAMPOKEY" -#define VERKEY "ìpÙˆ¬cê<" +#define REFKEY (unsigned char*)"CAMPOKEY" +#define VERKEY (unsigned char*)"ìpÙˆ¬cê<" #endif @@ -185,12 +184,22 @@ const TString& TDongle::administrator(TString* pwd) TConfig ini("install.ini", "Main"); _admin = ini.get("Administrator"); if (_admin.empty()) + { +#ifdef XVGUY _admin = "PRASSI"; +#else + _admin = "ADMIN"; +#endif + } else _admin = ::decode(_admin); _admpwd = ini.get("Password"); if (_admpwd.empty()) - _admpwd = "pr.assi"; + { + _admpwd = _admin; + _admpwd.lower(); + _admpwd.insert(".", 2); + } else _admpwd = ::decode(_admpwd); } @@ -209,7 +218,7 @@ void TDongle::garble(word* data) const switch (_hardware) { case _dongle_hardlock: - HL_CODE(EYECAST data, 1); + HL_CODE(data, 1); break; case _dongle_eutron: if (_eutron_key) @@ -299,7 +308,7 @@ bool TDongle::hardlock_login(bool test_all_keys) { _hardware = _dongle_hardlock; - HL_READBL((char*)_eprom); + HL_READBL((unsigned char*)_eprom); word data[4]; memcpy(data, _eprom, sizeof(data)); @@ -646,7 +655,7 @@ bool TDongle::read_words(word reg, word len, word* ud) const case _dongle_hardlock: { for (word i = 0; i < len; i++) - HL_READ(reg+i, (int*)&ud[i]); + HL_READ(reg+i, &ud[i]); ok = TRUE; } break; diff --git a/include/filetext.cpp b/include/filetext.cpp index 437549990..7a0aba92c 100755 --- a/include/filetext.cpp +++ b/include/filetext.cpp @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/include/formed.cpp b/include/formed.cpp index 09c426506..1f5419533 100755 --- a/include/formed.cpp +++ b/include/formed.cpp @@ -641,7 +641,7 @@ typedef struct real ratio; // ratio (width_old_font/width_new_font) } s_data; -BOOLEAN XVT_CALLCONV1 wpr (long data) +BOOLEAN wpr(long data) { s_data* st =(s_data*)data; WINDOW prwin = xvt_print_create_win(printer().get_printrcd(),""); diff --git a/include/golem.cpp b/include/golem.cpp index 36e16dcf8..295db386b 100755 --- a/include/golem.cpp +++ b/include/golem.cpp @@ -5,14 +5,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include -#include #include #include diff --git a/include/hlapi_c.h b/include/hlapi_c.h index 7a38384d8..8de50391c 100755 --- a/include/hlapi_c.h +++ b/include/hlapi_c.h @@ -1,172 +1,72 @@ -#ifndef __HLAPI_H -#define __HLAPI_H +/* $Id: hlapi_c.h,v 1.2 2002-02-28 11:34:54 guy Exp $ */ -/****************************************************************************/ -/** **/ -/** Hardlock E-Y-E **/ -/** API-Structures and definitions **/ -/** **/ -/** This file contains some helpful defines to access a Hardlock using **/ -/** the application programing interface (API) for Hardlock E-Y-E. **/ -/** **/ -/** (c) 1992 by ///FAST Electronic **/ -/** **/ -/** **/ -/** Authors : Thomas Schr”ter **/ -/** Henri Volk **/ -/** Version : 3.0 **/ -/** Date : 01-Sep-1992 **/ -/** **/ -/****************************************************************************/ - -#define EYECAST (char huge *) - -/* -------------------------------- */ -/* Definitions and API structures : */ -/* -------------------------------- */ -typedef unsigned char Byte; -typedef signed short Word; -typedef unsigned long Long; - -typedef struct -{ - Word Use_Key; - Byte Key[8]; -} -DES_MODE; - -typedef struct -{ - Word ModAd; /* Moduleaddress EYE */ - Word Register; /* Memory register adress */ - Word Value; /* Memory value */ - Byte Reserved[4]; -} -EYE_MODE; - -typedef union -{ - DES_MODE Des; - EYE_MODE Eye; -} -HARDWARE; - -typedef struct hl_api -{ - Byte API_Version_ID[2]; /* Version */ - Word API_Options[2]; /* API Optionflags */ - Word ModID; /* Modul-ID (EYE = 0...) */ - HARDWARE Module; /* Hardware type */ - void far *Data; /* Pointer to cipher data */ - Word Bcnt; /* Number of blocks */ - Word Function; /* Function number */ - Word Status; /* Actual status */ - Word Remote; /* Remote or local?? */ - Word Port; /* Port address if local */ - Word Speed; /* Speed of port if local */ - Word NetUsers; /* Current Logins (HLSERVER) */ - Byte ID_Ref[8]; /* Referencestring */ - Byte ID_Verify[8]; /* Encrypted ID_Ref */ - Long Task_ID; /* Multitasking program ID */ - Byte Reserved[200]; /* Reserved area */ -} -HL_API; - -/* ------------- */ -/* Module-ID's : */ -/* ------------- */ -#define EYE_DONGLE 0 /* Hardlock E-Y-E */ -#define DES_DONGLE 1 /* FAST DES */ +#include "fastapi.h" /* --------------------- */ -/* API function calls : */ +/* Function prototypes : */ /* --------------------- */ -#define API_INIT 0 /* Init API structure */ -#define API_DOWN 1 /* Free API structure */ -#define API_FORCE_DOWN 31 /* Force deinintialization */ -#define API_MULTI_SHELL_ON 2 /* MTS is enabled */ -#define API_MULTI_SHELL_OFF 3 /* MTS is disabled */ -#define API_MULTI_ON 4 /* Enable MTS */ -#define API_MULTI_OFF 5 /* Disable MTS */ -#define API_AVAIL 6 /* Dongle available? */ -#define API_LOGIN 7 /* Login dongle server */ -#define API_LOGOUT 8 /* Logout dongle server */ -#define API_INFO 9 /* Get API informations */ - -/* --------------------------- */ -/* Data and memory functions : */ -/* --------------------------- */ -#define API_KEYE 11 /* Use KEYE for encryption */ -#define API_READ 20 /* Read one word of dongle EEPROM */ -#define API_WRITE 21 /* Write one word of dongle EEPROM */ -#define API_READ_BLOCK 23 /* Read EEPROM in one block */ -#define API_WRITE_BLOCK 24 /* Write EEPROM in one block */ -#define API_GET_ID_KEY 30 /* Encrypt ID_Ref to ID_Verify */ -#define API_ABORT 53 /* Critical Error Abort */ - -/* -------------------- */ -/* Dongle access mode : */ -/* -------------------- */ -#define LOCAL_DEVICE 1 /* Query local HL only */ -#define NET_DEVICE 2 /* Query remote HL only */ -#define DONT_CARE 3 /* Query local or remote HL */ +#ifdef __cplusplus + extern "C" { +#endif /* ------------------ */ -/* API Status Codes : */ +/* Basic Hardlock API */ /* ------------------ */ -#define STATUS_OK 0 /* API call was succesfull */ -#define NOT_INIT 1 /* DONGLE not initialized */ -#define ALREADY_INIT 2 /* Already initialized */ -#define UNKNOWN_DONGLE 3 /* Device not supported */ -#define UNKNOWN_FUNCTION 4 /* Function not supported */ -#define NO_DONGLE 7 /* No device available */ -#define NETWORK_ERROR 8 /* A network error occured */ -#define NO_ACCESS 9 /* No device available */ -#define INVALID_PARAM 10 /* A wrong parameter occured */ -#define VERSION_MISMATCH 11 /* HL-Server not API version */ +RET_ FAR_ CALL_ HL_LOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey); +RET_ FAR_ CALL_ HL_LOGOUT (void); +RET_ FAR_ CALL_ HL_AVAIL (void); +RET_ FAR_ CALL_ HL_PORTINF (void); +RET_ FAR_ CALL_ HL_ACCINF (void); +RET_ FAR_ CALL_ HL_USERINF (void); +RET_ FAR_ CALL_ HL_MAXUSER (void); +RET_ FAR_ CALL_ HL_MEMINF (void); +RET_ FAR_ CALL_ HL_CODE (void DATAFAR_ *Data, Word Count); +RET_ FAR_ CALL_ HL_WRITE (Word Reg, Word Value); +RET_ FAR_ CALL_ HL_READ (Word Reg, Word DATAFAR_ *Value); +RET_ FAR_ CALL_ HL_READBL (Byte DATAFAR_ *Eeprom); +RET_ FAR_ CALL_ HL_WRITEBL (Byte DATAFAR_ *Eeprom); +RET_ FAR_ CALL_ HL_ABORT (void); +RET_ FAR_ CALL_ HL_VERSION (void); +RET_ FAR_ CALL_ HL_HLSVERS (void); +RET_ FAR_ CALL_ HL_SELECT (HL_API DATAFAR_ *hl_ptr); +RET_ FAR_ CALL_ HL_READID (Word DATAFAR_ *IDLow, Word DATAFAR_ *IDHigh); + +/* ---------------- */ +/* Hardlock RUS API */ +/* ---------------- */ +RET_ FAR_ CALL_ HLM_LOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey, Byte DATAFAR_ * VKey, Long RUSOptions, Byte DATAFAR_ * SearchStr); +RET_ FAR_ CALL_ HLM_OCCUPYSLOT (Long Slot); +RET_ FAR_ CALL_ HLM_FREESLOT (Long Slot); +RET_ FAR_ CALL_ HLM_CHECKSLOT (Long Slot, Long * MaxUser, Long * CurrentUser); +RET_ FAR_ CALL_ HLM_CHECKCOUNTER (Word IncVal, Long * MaxCounter, Long * CurrentCounter); +RET_ FAR_ CALL_ HLM_CHECKEXPDATE (Long Slot, Word * Year, Word * Month, Word * Day); +RET_ FAR_ CALL_ HLM_GETRUSINFO (Long * BufLen, Byte DATAFAR_ * RTBBuffer, Word Base64); +RET_ FAR_ CALL_ HLM_WRITELICENSE (Long BufLen, Byte DATAFAR_ * RTBBuffer, Word Access, Byte DATAFAR_ * SearchStr,Word Options); +RET_ FAR_ CALL_ HLM_ISRUSHL (Long * ID); +RET_ FAR_ CALL_ HLM_CHECKALLSLOTS (Long *BufLen, HL_LIS *Buffer); +RET_ FAR_ CALL_ HLM_LOGOUT (void); + +/* ---------------------- */ +/* Hardlock Error Routine */ +/* ---------------------- */ +const char * FAR_ CALL_ HL_ERRMSG (Word num, Long options, Byte ** errdefine, Byte ** errextmsg); + +/* ------------------------------------------- */ +/* Obsolete functions, for compatiblity only!! */ +/* ------------------------------------------- */ +#ifndef __OS2__ +void FAR_ CALL_ HL_ON (Word Port, Word ModAd); +void FAR_ CALL_ HL_OFF (Word Port); +Word FAR_ CALL_ K_EYE (Word Port, char DATAFAR_ *Inp, Word BlkCnt); +void FAR_ CALL_ HL_WR (Word Port, Word Reg, Word Val); +Word FAR_ CALL_ HL_RD (Word Port, Word Reg); +void FAR_ CALL_ INT_ON (void); +void FAR_ CALL_ INT_OFF (void); +#endif +RET_ FAR_ CALL_ HL_CALC (Word i1, Word i2, Word i3, Word i4); +RET_ FAR_ CALL_ HL_LMLOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey, Word SlotID, Byte DATAFAR_ *SearchStr); #ifdef __cplusplus -extern "C" { -#endif - - /* --------------------- */ - /* Function prototypes : */ - /* --------------------- */ - static int CALL_API (HL_API far *as); - Word far HL_LOGIN (Word ModAd, Word Access, char * RefKey, char * VerKey); - Word far HL_LOGOUT (void); - Word far HL_AVAIL (void); - Word far HL_PORTINF (void); - Word far HL_ACCINF (void); - Word far HL_USERINF (void); - Word far HL_MAXUSER (void); - Word far HL_MEMINF (void); - Word far HL_CODE (void far *Data, Word Count); - Word far HL_WRITE (Word Register, Word Value); - Word far HL_READ (Word Register, int far *Value); - char far * HL_GET_ID (char * id_ref); - Word far HL_READBL (char * Eeprom); - Word far HL_WRITEBL (char * Eeprom); - Word far HL_ABORT (void); - Word far HL_VERSION (void); - - /****************************************************************************/ - /****************************************************************************/ - /* The following functions map the old Hardlock Calls on the new API. These */ - /* functions are defined only for compatibility reasons. */ - /* !!! Don't mix old and new functions. Don't use if it is not necessary.!!!*/ - /****************************************************************************/ - /****************************************************************************/ - void far HL_ON (int Port, Word ModAd); - void far HL_OFF (int Port); - int far K_EYE (int Port, char huge *Inp, int BlkCnt); - void far HL_WR (int Port, int Register, Word Val); - Word far HL_RD (int Port, int Register); - void far INT_ON (void); - void far INT_OFF (void); - -#ifdef __cplusplus -} -#endif - + }; #endif +/* eof */ diff --git a/include/ioresult.c b/include/ioresult.c index fbc2c8e8e..1b028dcbc 100755 --- a/include/ioresult.c +++ b/include/ioresult.c @@ -13,11 +13,9 @@ */ -int CIOResult() - +int CIOResult() { - int res = errno ; - - errno = NoErr ; - return(res) ; + const int res = errno; + errno = NoErr; + return res; } diff --git a/include/isam.cpp b/include/isam.cpp index f3fd410e8..21199092d 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -2,14 +2,13 @@ #include #include #include +#include #define __ISAM_CPP -#ifndef FOXPRO #include #include #include -#endif #include #include @@ -84,8 +83,6 @@ void write_journal(TJournalHeader& jh, void* data, int len) Str80 cprefix; bool __field_changed = FALSE; -HIDDEN char _isam_string[257]; - #define NOALLOC (char **) -1 HIDDEN bool __autoload = TRUE; @@ -752,16 +749,18 @@ long TBaseisamfile::items() const const char* TBaseisamfile::name() const { - sprintf(_isam_string, "%d", num()); - return _isam_string; + TString& tmp = get_tmp_string(); + tmp.format("%d", num()); + return tmp; } const char* TBaseisamfile::filename() const { const int n = _isam_handle > 0 ? _isam_handle : num(); - strcpy(_isam_string, prefix().get_filename(n)); - strcat(_isam_string, ".dbf"); - return _isam_string; + TString& tmp = get_tmp_string(); + tmp = prefix().get_filename(n); + tmp << ".dbf"; + return tmp; } const char* TBaseisamfile::description() @@ -2988,7 +2987,7 @@ const char* TRectype::fieldname(int i) const const TString& TRectype::get_str(const char* fieldname) const { - static TFixed_string tmp(_isam_string, sizeof(_isam_string)); + TString& tmp = get_tmp_string(256); const RecDes * recd = rec_des(); const int nf = findfld(recd, fieldname); const RecFieldDes& fd = recd->Fd[nf]; @@ -2999,13 +2998,11 @@ const TString& TRectype::get_str(const char* fieldname) const } else { - __getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, _isam_string); + __getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, tmp.get_buffer()); } return tmp; } -#ifndef FOXPRO - const TString& TRectype::get(const char* fieldname) const { if (_memo_data && type(fieldname) == _memofld) @@ -3088,7 +3085,6 @@ bool TRectype::get_memo( return TRUE; } -#endif // FOXPRO TDate TRectype::get_date(const char* fieldname) const @@ -3097,19 +3093,19 @@ TDate TRectype::get_date(const char* fieldname) const return d; } -#ifndef FOXPRO - void TRectype::put(const char* fieldname, int val) { - sprintf(_isam_string, "%d", val); - put_str( fieldname, _isam_string); + TString16 tmp; + tmp.format("%d", val); + put_str(fieldname, tmp); } void TRectype::put(const char* fieldname, long val) { - sprintf(_isam_string, "%ld", val); - put_str( fieldname, _isam_string); + TString16 tmp; + tmp.format("%ld", val); + put_str(fieldname, tmp); } void TRectype::put(const char* fieldname, TTextfile& txt) @@ -3128,15 +3124,15 @@ void TRectype::put(const char* fieldname, TTextfile& txt) const long id = memo.set_field(txt, isnew ? FIELDERR : val); if (isnew) val = id; - sprintf(_isam_string, "%ld", val); - put_str( fieldname, _isam_string); + TString16 tmp; tmp.format("%ld", val); + put_str( fieldname, tmp); } void TRectype::put(const char* fieldname, word val) { - sprintf(_isam_string, "%u", val); - put_str( fieldname, _isam_string); + TString16 tmp; tmp.format("%u", val); + put_str( fieldname, tmp); } void TRectype::put(const char* fieldname, const real& val) @@ -3169,8 +3165,6 @@ void TRectype::put(const char* fieldname, bool val) put_str( fieldname, s); } -#endif // FOXPRO - void TRectype::put_str(const char* fieldname, const char* val) { @@ -3355,8 +3349,9 @@ TRectype& TRectype::operator =(const char* rec) const char* TRectype::key(int numkey) const { - __build_key(rec_des(), numkey, _rec, _isam_string,FALSE); - return _isam_string; + TString& tmp = get_tmp_string(256); + __build_key(rec_des(), numkey, _rec, tmp.get_buffer(), FALSE); + return tmp; } void TRectype::fill_transaction(TConfig& cfg, int row) const @@ -3455,9 +3450,6 @@ long TRecfield::operator =(long l) return l; } - -#ifndef FOXPRO - const real& TRecfield::operator =(const real& r) { char buff[80]; @@ -3467,9 +3459,6 @@ const real& TRecfield::operator =(const real& r) return r; } -#endif // FOXPRO - - const TDate& TRecfield::operator =(const TDate& d) { char buff[16]; @@ -3506,60 +3495,59 @@ void TRecfield::setptr(TRecnotype r) TRecfield::operator int() const { + char tmp[32]; if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld) { - strncpy(_isam_string, _p, _len); - _isam_string[_len] = '\0'; + strncpy(tmp, _p, _len); + tmp[_len] = '\0'; } else - __getfieldbuff( _len, _type, _p, _isam_string); - return atoi(_isam_string); + __getfieldbuff( _len, _type, _p, tmp); + return atoi(tmp); } TRecfield::operator long() const { + char tmp[32]; if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld) { - strncpy(_isam_string, _p, _len); - _isam_string[_len] = '\0'; + strncpy(tmp, _p, _len); + tmp[_len] = '\0'; } else - __getfieldbuff( _len, _type, _p, _isam_string); + __getfieldbuff( _len, _type, _p, tmp); - return atol(_isam_string); + return atol(tmp); } - -#ifndef FOXPRO - TRecfield::operator const real() const { + char tmp[32]; if (_type == _realfld) { - strncpy(_isam_string, _p, _len); - _isam_string[_len] = '\0'; + strncpy(tmp, _p, _len); + tmp[_len] = '\0'; } else - __getfieldbuff( _len, _type, _p, _isam_string); - real r(_isam_string); + __getfieldbuff( _len, _type, _p, tmp); + real r(tmp); return r; } -#endif // FOXPRO - TRecfield::operator TDate() const { + char tmp[16]; if (_type == _datefld) { - strncpy(_isam_string, _p, 8); - _isam_string[8] = '\0'; - return TDate(atol(_isam_string)); + strncpy(tmp, _p, 8); + tmp[8] = '\0'; + return TDate(atol(tmp)); } - __getfieldbuff(_len, _type, _p, _isam_string); - return TDate(_isam_string); + __getfieldbuff(_len, _type, _p, tmp); + return TDate(tmp); } @@ -3568,8 +3556,9 @@ TRecfield::operator const char*() const if (_type == _memofld) return _rec->get(_name); - __getfieldbuff(_len, _type, _p, _isam_string); - return _isam_string; + TString& tmp = get_tmp_string(_len); + __getfieldbuff(_len, _type, _p, tmp.get_buffer()); + return tmp; } diff --git a/include/mask.cpp b/include/mask.cpp index 676c9aff6..03534e5dc 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -89,7 +89,7 @@ TMask::TMask() TMask::TMask(const char* title, int pages, int cols, int rows, int xpos, int ypos) - : _mask_num(0) + : _mask_num(0) { init_mask(); for (_pages = 0; _pages < pages; _pages++) @@ -231,12 +231,12 @@ void TMask::add_field(TMask_field* f) void TMask::add_tag_button(byte pag, TToken_string& tags, byte sel) { - TPage_field* pf = new TPage_field(this); - pf->_ctl_data._dlg = DLG_PAGETAGS + 100 * pag; - pf->replace_items("1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16", tags); - pf->set_default(sel); - pf->create(_pagewin[pag]); - add_field(pf); + TPage_field* pf = new TPage_field(this); + pf->_ctl_data._dlg = DLG_PAGETAGS + 100 * pag; + pf->replace_items("1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16", tags); + pf->set_default(sel); + pf->create(_pagewin[pag]); + add_field(pf); } void TMask::add_tag_buttons(TToken_string& tags) @@ -266,6 +266,7 @@ TMask::TMask(const char* maskname, int num, int max) TMask::~TMask() { + _field.destroy(); for (int p = MAX_PAGES; p >= 0; p--) if (_pagewin[p]) { diff --git a/include/maskfld.cpp b/include/maskfld.cpp index 00becd34f..b543a741a 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -4792,8 +4792,8 @@ const char* TZoom_field::get_first_line() const #ifndef INCL_XI extern "C" { - void XVT_CALLCONV1 xi_draw_3d_rect XVT_CC_ARGS( ( WINDOW win, RCT* rctp, BOOLEAN well, int height, - COLOR color_light, COLOR color_ctrl, COLOR color_dark ) ); + void xi_draw_3d_rect( WINDOW win, RCT* rctp, BOOLEAN well, int height, + COLOR color_light, COLOR color_ctrl, COLOR color_dark ); } #endif @@ -4805,7 +4805,7 @@ void TField_window::handler(WINDOW win, EVENT* ep) if (ep->v.active) { WINDOW parent = xvt_vobj_get_parent(win); - XI_OBJ* itf = xi_get_itf(parent); + XI_OBJ* itf = xi_get_itf((XinWindow)parent); xi_set_focus(itf); } break; @@ -4851,7 +4851,7 @@ void TField_window::update() const WINDOW pa = parent(); RCT rct; xvt_vobj_get_outer_rect(me, &rct); rct.left -= 2; rct.top -= 2; rct.right += 2; rct.bottom += 2; - xi_draw_3d_rect(pa, (XinRect *) &rct, TRUE, 2, // qui + xi_draw_3d_rect((XinWindow)pa, (XinRect *) &rct, TRUE, 2, // qui MASK_LIGHT_COLOR, MASK_BACK_COLOR, MASK_DARK_COLOR); } xvt_dwin_clear(me, NORMAL_BACK_COLOR); diff --git a/include/maskfld.h b/include/maskfld.h index f5cf0026e..808a72115 100755 --- a/include/maskfld.h +++ b/include/maskfld.h @@ -13,6 +13,10 @@ #include #endif +#ifndef __WINDOW_H +#include +#endif + class TControl; // __CONTROL_H class TText_control; class TPushbutton_control; diff --git a/include/memo.cpp b/include/memo.cpp index ad38a25d1..e164e8e8f 100755 --- a/include/memo.cpp +++ b/include/memo.cpp @@ -1,5 +1,7 @@ #include #include + +#include #include #define HEADER_SIZE (sizeof(long)+sizeof(char)) diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 6be3cd4f6..a0aaf32e6 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -2227,7 +2227,7 @@ bool TSpreadsheet::notify(int rec, KEY k) { const bool ok = _notify ? _notify(owner(), rec, k) : TRUE; if (k == K_ENTER) - set_dirty(ok ? TRUE : 3); + set_dirty(ok ? 1 : 3); return ok; } @@ -2452,7 +2452,6 @@ TString_array& TSheet_field::rows_array() const return ((TSpreadsheet*)_ctl)->rows_array(); } - // Certified 100% // Ritorna l'indice della prima riga vuota dello sheet int TSheet_field::first_empty() const diff --git a/include/os_win32.cpp b/include/os_win32.cpp index b4ed8163e..3d52eb16b 100755 --- a/include/os_win32.cpp +++ b/include/os_win32.cpp @@ -672,3 +672,14 @@ void os_sleep(long m) { ::Sleep(m); } + +void os_beep(int severity) +{ + switch (severity) + { + case 0: MessageBeep(MB_OK); break; + case 1: MessageBeep(MB_ICONEXCLAMATION); break; + default: MessageBeep(MB_ICONSTOP); break; + } +} + diff --git a/include/printapp.cpp b/include/printapp.cpp index d1b76ab89..060184020 100755 --- a/include/printapp.cpp +++ b/include/printapp.cpp @@ -1526,7 +1526,7 @@ bool TPrint_application::print_one ( pos[pr->row ()] += ps.len (); } } - } + } // print! const int last = rw.last(); @@ -1551,10 +1551,10 @@ bool TPrint_application::menu(MENU_TAG m) { // funziona da se' fino a 20 voci della menubar if (m >= BAR_ITEM (1) && m <= BAR_ITEM (20)) - { - _last_choice = m; - do_print((m - BAR_ITEM (0)) / 100); - } + { + _last_choice = m; + do_print((m - BAR_ITEM (0)) / 100); + } // Se non esistono altre voci di menu termina l'applicazione return xvt_test_menu_tag (BAR_ITEM (2)); @@ -1632,7 +1632,8 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10), _cur_file = 0; _magic_currency = FALSE; _print_zero = FALSE; - _last_choice = BAR_ITEM (1); + + _last_choice = BAR_ITEM (1); } void TPrint_application::reset_files() diff --git a/include/printer.cpp b/include/printer.cpp index d7691e9e6..1ea5ed776 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include #define STYLE_NUM 4 @@ -199,7 +201,7 @@ struct PrDesc TPrinter * _p; } PrintWhat; -BOOLEAN XVT_CALLCONV1 TPrinter::start_print (long data) +BOOLEAN TPrinter::start_print(long data) { const PrDesc *pd = (PrDesc *) data; TTextfile& txt = *(pd->_txt); @@ -545,106 +547,7 @@ TString_array& TPrinter::getbgdesc(word page) const return *bg; } - -bool printers_on_key(TMask_field & f, KEY key); - -// fv support structs for config - -// @doc INTERNAL - -// @mfunc Legge la descrizione della stampante dal file -// -// @rdesc Ritorna il risultato dell'operazione: -// -// @flag TRUE | Se e' riuscito a leggere la descrizione della stampante -// @flag FALSE | Se non e' riuscito a leggere la descrizione della stampante -bool PrinterDef::read( - const char *name, // @parm Nome della stampante di cui cercarne la descrizione - FILE * fd) // @parm Puntatore al file contenente la descrizione -{ - _printername = name; - _printername.trim (); - - TToken_string tmp (64, '='); - TString l (48); - TString r (16); - - while (TRUE) - { - const long p = ftell (fd); // Memorizza inizio paragrafo - - if (fgets (__tmp_string, 256, fd) == NULL) - return FALSE; - tmp = __tmp_string; - tmp.trim (); - - if (tmp == "[End of File]") - return FALSE; - - if (tmp[0] == '[') - { - fseek (fd, p, SEEK_SET); // Ritorna ad inizio paragrafo - - break; - } - - l = tmp.get (); - l.trim (); - r = tmp.get (); - r.trim (); - - if (l == "Device name") - { - _devicename = r; - } - else if (l == "Filter name") - { - _filtername = r; - } - else if (l == "Printer type") - { - _printertype = r; - } - else if (l == "Normal") - { - strcpy (_atstr[normalstyle], r); - } - else if (l == "Bold") - { - strcpy (_atstr[boldstyle], r); - } - else if (l == "Italic") - { - strcpy (_atstr[italicstyle], r); - } - else if (l == "Underlined") - { - strcpy (_atstr[underlinedstyle], r); - } - else if (l == "Code") - { - TToken_string code (r); - _names.add ( code.get() ); - _codes.add ( code.get() ); - } - else if (l == "Form feed") - { - _ffcode = r; - } - else if (l == "Newline") - { - _nlcode = r; - } - else - return error_box ("Riga di configurazione stampante errata:\n%s", (const char *) l); - } - return TRUE; -} - -bool PrinterDef::isdefault () -{ - return strcmp(_printername, "Default") == 0; -} +//bool printers_on_key(TMask_field & f, KEY key); ////////// TPRINTROW ////////// @@ -924,26 +827,6 @@ TPrintrow& TPrintrow::put(const char *str, int position, int len) ////////// TPRINTER ////////// -HIDDEN bool printer_handler (TMask_field & f, KEY key) -{ - if (key == K_SPACE) - { - TToken_string pn1(10), pn2(80); - - const PrinterDef & def = printer().get_description(atoi(f.get ())); - const char *s; - int j = 0; - while ((s = def.get_codenames (j)) != NULL) - { - pn1.add (format ("%02d", j)); - pn2.add (s); - j++; - } - ((TList_field &) f.mask ().field (MSK_CODES)).replace_items (pn1, pn2); - } - return TRUE; -} - void TPrinter::set_printrcd() { if (_print_rcd != NULL) @@ -1107,9 +990,6 @@ TPrinter::TPrinter() { _footerhandler = _headerhandler = NULL; _linkhandler = NULL; - _curprn = 0; // first in list if no default is specified - - _curcode = 0; // first in list if no default is specified _formlen = 66; _formwidth = 0; @@ -1125,31 +1005,12 @@ TPrinter::TPrinter() _isopen = FALSE; _multiple_copies = main_app().class_id() == CLASS_PRINT_APPLICATION; - // read configuration file + os_get_default_printer(_defPrinter); + + // read configuration file read_configuration (); init_formlen (); - - os_get_default_printer(_defPrinter); - - TToken_string pn2; os_get_printer_names(pn2); // get printer names - - CHECK(_curprn >= 0, "Can't find printer "); - - if (_curprn >= word(pn2.items())) - { - TString pdev(_defPrinter); // Nome stampante corrente - int comma = pdev.find(','); - if (comma > 0) - pdev.cut(comma); - _curprn = pn2.get_pos(pdev); - } - else - { - const TString pdev(pn2.get(_curprn)); // Nome stampante corrente - // scrivi (e semmai lo si risistema poi) - os_set_default_printer(pdev); - } set_fincatura("+++++++++-|"); @@ -1196,13 +1057,28 @@ void TPrinter::read_configuration( iniptr = new TConfig(CONFIG_USER, "Printer"); const int what = iniptr->get_int("Type", NULL, -1, 0); // Tipo stampante - _curprn = iniptr->get_int("Number", NULL, -1, 0); // Numero stampante corrente + _prname = iniptr->get("Name", NULL, -1, _defPrinter); // Nome stampante corrente _printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa - _curcode = iniptr->get_int("Codes", NULL, -1, 0); // Codici di stampa _fontname = iniptr->get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font _ch_size = iniptr->get_int("Size", NULL, -1, 12); // Dimensione del font _lines_per_inch = iniptr->get_int("Lines", NULL, -1, 6); // Linee per pollice _isgraphics = iniptr->get_bool("Graphic", NULL, -1, FALSE); // Grafica attiva + +#ifdef XVGUY + bool read_rcd = TRUE; + const TString& host = iniptr->get("Host"); + if (host.not_empty()) + { + char hostname[32]; + aga_get_host_name(hostname, sizeof(hostname)); + if (host != hostname) + { + read_rcd = yesno_box("Le impostazioni della stampante sono relative alla stazione di lavoro %s:\n" + "si desidera applicarle ugualmente alla stazione %s?", (const char*)host, hostname); + } + } + if (read_rcd) +#endif if (iniptr->exist("rcd", 0)) { @@ -1210,6 +1086,21 @@ void TPrinter::read_configuration( byte* rcd = (byte*)get_printrcd(&size); TToken_string s(256); + +#ifdef XVGUY + // Devo leggere tutti numeri, anche se sono di pìù di quelli attuali! + for (int index = 0; ; index++) + { + s = iniptr->get("rcd", NULL, index); + if (s.not_empty()) + { + for (const char* n = s.get(0); n; n = s.get()) + rcd[i++] = (byte)atoi(n); + } + else + break; + } +#else for (int index = 0; i < size; index++) { s = iniptr->get("rcd", NULL, index); @@ -1221,6 +1112,7 @@ void TPrinter::read_configuration( else break; } +#endif if (xvt_print_is_valid(_print_rcd)) { init_formlen(); @@ -1253,11 +1145,9 @@ void TPrinter::read_configuration( break; case 4: // video _printertype = screenvis; - _curcode = 0; break; case 6: // export _printertype = export; - _curcode = 0; break; default: break; @@ -1273,13 +1163,19 @@ void TPrinter::save_configuration() TConfig prini(_config == "Printer" ? CONFIG_USER : CONFIG_STAMPE, _config); prini.set("Type", _printertype); // Tipo stampante - prini.set("Number", _curprn); // Numero stampante corrente + prini.set("Name", _prname); // Numero stampante corrente prini.set("File", _printerfile); // File di stampa - prini.set("Codes", _curcode); // Codici di stampa prini.set("Font", _fontname); // Nome del font prini.set("Size", _ch_size); // Dimensione del font prini.set("Lines", _lines_per_inch); // Linee per pollice prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva + +#ifdef XVGUY + char hostname[32]; + aga_get_host_name(hostname, sizeof(hostname)); + prini.set("Host", hostname); + prini.set("User", user()); +#endif int n = 0, index = 0; TToken_string val(256); @@ -1631,9 +1527,7 @@ void TPrinter::reset() bool TPrinter::open() { - TToken_string pn2; os_get_printer_names(pn2); // get printer names - TString pdev(pn2.get(_curprn)); // Nome stampante corrente - os_set_default_printer(pdev); + os_set_default_printer(_prname); if (_printertype == screenvis) { @@ -1668,29 +1562,20 @@ bool TPrinter::set() TMask mask("bagn001a"); - TToken_string pn1(50); - int i; - mask.set(MSK_FILENAME, _printerfile); mask.set(MSK_NPAGES, _ncopies); const bool can_save = _config == "Printer"; mask.enable(DLG_OK, can_save); -// mask.enable(DLG_SAVEREC, can_save); + + // mask.enable(DLG_SAVEREC, can_save); TToken_string pn2; os_get_printer_names(pn2); - - TString old_default; - os_get_default_printer(old_default); - const int np = pn2.items(); - for (i = 0; i < np; i++) - pn1.add(i); - TList_field& plst = (TList_field&)mask.field (MSK_PRINTERS); - plst.replace_items(pn1, pn2); // Genera printer list + plst.replace_items(pn2, pn2); // Genera printer list - mask.set(MSK_PRINTERS, _curprn); // Genera font list + mask.set(MSK_PRINTERS, _prname); // Genera font list set_windows_print_device(mask.field(MSK_PRINTERS), K_TAB); mask.set(MSK_FONT, _fontname); // Genera size list @@ -1700,8 +1585,8 @@ bool TPrinter::set() mask.set(MSK_LINES, _lines_per_inch); mask.set(MSK_ISGRAPHICS, _isgraphics ? "X" : ""); - mask.set_handler (MSK_PRINTERS, set_windows_print_device); - mask.set_handler (MSK_FONT, font_handler); + mask.set_handler(MSK_PRINTERS, set_windows_print_device); + mask.set_handler(MSK_FONT, font_handler); if (!_multiple_copies) mask.hide(MSK_NPAGES); @@ -1713,11 +1598,12 @@ bool TPrinter::set() else mask.set (MSK_TYPE, "0"); - const int oldprn = _curprn; - s_printrcd * rcd = get_printrcd(); + const TString oldprn = _prname; + PRINT_RCD* rcd = get_printrcd(); - TString oldrcd(_print_rcd_size); - memcpy((char *) (const char *) oldrcd, rcd, _print_rcd_size); + const int old_rcd_size = _print_rcd_size; + TString oldrcd(old_rcd_size); + memcpy(oldrcd.get_buffer(), rcd, old_rcd_size); KEY k; while ((k = mask.run ()) != K_ESC && k != K_ENTER && k != K_INS) @@ -1729,28 +1615,18 @@ bool TPrinter::set() { // Ricarica la lista delle stampanti (L'utente puo' aggiungerne!) os_get_printer_names(pn2); - pn1.cut(0); - int i = 0; - FOR_EACH_TOKEN(pn2, tok) - pn1.add(i++); - plst.replace_items(pn1, pn2); // Genera printer list + plst.replace_items(pn2, pn2); // Genera printer list // see if user has changed printer // determine index of currently selected printer // ACTHUNG! Deep hacking of XVT internals! NON PORTABLE! - const char* name = (const char *)(get_printrcd() + 4); - _curprn = pn2.get_pos(name); - if (*name == '\0' || _curprn < 0) - { - NFCHECK("Can't find printer '%s'", name); - _curprn = oldprn; - } + _prname = (const char *)(get_printrcd() + 4); + if (_prname.blank()) + _prname = oldprn; - mask.set(MSK_PRINTERS, pn1.get(_curprn)); + mask.set(MSK_PRINTERS, _prname); } - else - beep (); } } @@ -1759,15 +1635,15 @@ bool TPrinter::set() // riaggiusta stampante default windows come prima // curprn e rcd sono quelle di prima main_app().enable_menu_item(M_FILE_PG_SETUP); - os_set_default_printer(old_default); - _curprn = oldprn; - s_printrcd * rcd = get_printrcd(); - memcpy(rcd, (const char *) oldrcd, _print_rcd_size); + os_set_default_printer(oldprn); + _prname = oldprn; + PRINT_RCD* rcd = get_printrcd(); + memcpy(rcd, (const char *)oldrcd, old_rcd_size); init_formlen(); return FALSE; } - _curprn = atoi(mask.get(MSK_PRINTERS)); + _prname = mask.get(MSK_PRINTERS); _ncopies = atoi (mask.get (MSK_NPAGES)); switch (atoi (mask.get (MSK_TYPE))) @@ -1778,11 +1654,9 @@ bool TPrinter::set() case 1: // file _printertype = fileprinter; _printerfile = mask.get (MSK_FILENAME); - _curcode = atoi (mask.get (MSK_CODES)); break; case 2: // video _printertype = screenvis; - _curcode = 0; break; } @@ -2049,8 +1923,7 @@ struct font_data int _columns; }; -HIDDEN -BOOLEAN XVT_CALLCONV1 calc_font_callback(long data) +HIDDEN BOOLEAN calc_font_callback(long data) { font_data& fd = *(font_data*)data; @@ -2084,7 +1957,7 @@ BOOLEAN XVT_CALLCONV1 calc_font_callback(long data) } HIDDEN -BOOLEAN XVT_CALLCONV1 calc_cols_callback(long data) +BOOLEAN calc_cols_callback(long data) { int &numcols=*(int *)data; diff --git a/include/printer.h b/include/printer.h index b57cc2f13..53691651b 100755 --- a/include/printer.h +++ b/include/printer.h @@ -9,10 +9,6 @@ #include #endif -#ifndef XVT_INCL_XVTTYPE -#include -#endif - #ifndef __DATE_H #include #endif @@ -137,57 +133,6 @@ public: // @doc INTERNAL -// @class PrinterDef | Classe per la definizione delle stampanti da utilizzare -// -// @base public | TObject -class PrinterDef : public TObject - -// @author:(INTERNAL) Villa - -{ - // @cfriend TPrinter - friend class TPrinter; - - // @access:(INTERNAL) Private Member - - // @cmember:(INTERNAL) Nome del file della stampante - TString _printername; - // @cmember:(INTERNAL) Tipo di stampante da utilizzare (0=diretta,1=locale,2=spool) - TString _printertype; - // @cmember:(INTERNAL) Filtro per la pipe '' (solo per unix - TString _filtername; - // @cmember:(INTERNAL) Nome del device di stampa - TString _devicename; - // @cmember:(INTERNAL) Codici attributo per la stampante corrente - char _atstr[4][10]; - // @cmember:(INTERNAL) Codici di stampa - TString_array _codes; - // @cmember:(INTERNAL) Nome dei codici di stampa - TString_array _names; - // @cmember:(INTERNAL) Codice del formfeed per la stampante corrente - TString _ffcode; - // @cmember:(INTERNAL) Codice del new line per la stampante corrente - TString _nlcode; - - // @access Public Member -public: - // @cmember Legge la descrizione della stampante dal file - bool read(const char* name, FILE* fd); - // @cmember Controlla se il nome del file della stampante e' "Default" - bool isdefault(); - // @cmember Ritorna l'

-esimo nome del codice di stampa - const char* get_codenames(word i) const - { return i < (word)_names.items() ? (const char*)_names.row(i) : NULL; } - // @cmember Ritorna l'

-esimo codice di stampa - const char* get_codes(word i) const - { return i < (word)_codes.items() ? (const char*)_codes.row(i) : NULL; } - // @cmember Costruttore - PrinterDef() : _printername(10), _filtername(10), _ffcode("\f"), _nlcode("\n") - {} -}; - -// @doc INTERNAL - // @class BkDef | Classe per la definizione dei bookmark in anteprima di stampa // // @base public | TObject @@ -251,7 +196,7 @@ class TPrinter : public TObject FILE* _fp; // @cmember:(INTERNAL) Puntatore al file di visualizzaizone TViswin* _vf; - // @cmember:(INTERNAL) Stampande di default di sistema + // @cmember:(INTERNAL) Stampante di default di sistema TString _defPrinter; // @cmember:(INTERNAL) Testo da stampare TTextfile _txt; @@ -265,12 +210,8 @@ class TPrinter : public TObject TArray _header; // @cmember:(INTERNAL) Contenuto del footer TArray _footer; - // @cmember:(INTERNAL) Descrizione delle stampanti - TArray _printers; - // @cmember:(INTERNAL) Indice corrente della stampante - word _curprn; - // @cmember:(INTERNAL) Codice corrente della stampante - int _curcode; + // @cmember:(INTERNAL) Nome della stampante corrente + TString _prname; // @cmember:(INTERNAL) Lunghezza della pagina logica int _formlen; // @cmember:(INTERNAL) Larghezza della pagina logica @@ -279,7 +220,7 @@ class TPrinter : public TObject int _currentrow; // @cmember:(INTERNAL) Nome del font per la stampa - TString80 _fontname; + TString _fontname; // @cmember:(INTERNAL) Dimensione del font per la stampa int _ch_size; @@ -395,7 +336,7 @@ public: virtual ~TPrinter(); // @cmember Inizia una nuova sessione di stampa. Viene passata alla - static BOOLEAN XVT_CALLCONV1 start_print(long data); + static BOOLEAN start_print(long data); // @cmember Setta il numero della prima pagina da stampare void set_from_page (word from) @@ -410,13 +351,6 @@ public: // @cmember Permette di tradurre la stringa con i codici @codes in un array utilizzabile dalla stampa void parse_background(const char* bgdesc, TString_array& background); - // @cmember Ritorna il numero delle stampanti disponibili - int descriptions() - { return _printers.items(); } - // @cmember Ritorna il nome della

-esima stampante disponibile - const PrinterDef& get_description(word i) const - { return (const PrinterDef&) _printers[i]; } - // @cmember Ritorna il nome della classe virtual const char* class_name() const; // @cmember Ritorna l'identificatore della classe @@ -675,12 +609,12 @@ public: int get_char_size() const { return _ch_size; } // @cmember Ritorna il nome del font di stampa - char* fontname() const - { return (char*)(const char*)_fontname; } + const TString& fontname() const + { return _fontname; } // @cmember Ritorna il nome della stampante - const char* printername() const - { return (const char*)get_description(_curprn)._devicename; } + const TString& printername() const + { return _prname; } // @cmember Setta la dimensione dei caratteri da stampare void set_char_size(int size) diff --git a/include/printwin.cpp b/include/printwin.cpp index 60651e741..3de335661 100755 --- a/include/printwin.cpp +++ b/include/printwin.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -12,12 +13,12 @@ HIDDEN int LEN_SPACES(WINDOW win, int x) } if (w == 0L) { - TString spc(132, 'm'); + TString256 spc; spc.fill('m', 132); w = xvt_dwin_get_text_width(win, spc.get_buffer(), 132); } const int k = int((w*x) / 132); -#ifdef DBG +#if defined(DBG) && !defined(XVGUY) static bool error_on = TRUE; if (error_on) { @@ -269,7 +270,7 @@ void TPrintwin::paint_row(long j) // @rdesc Ritorna se e' riuscito a stampare in una unica pagina bool TPrintwin::print_band( int page, // @parm Numero della pagina in cui stampare - RCT& r) // @parm Parte di finestra da stampare + const RCT& r) // @parm Parte di finestra da stampare // @comm Di solito viene disegnata l'intera pagina, ma la cosa dipende dal driver di stampa { @@ -294,6 +295,16 @@ bool TPrintwin::print_band( return (j + k < _txt.lines() + _frlc); } +#ifdef XVGUY +TPrintwin* _curr_print = NULL; + +bool print_callback(int page, const RCT& rct) +{ + return _curr_print->print_band(page-1, rct); +} + +#endif + // @doc INTERNAL // @mfunc Inizia la stampa @@ -303,19 +314,14 @@ bool TPrintwin::print_band( // @flag TRUE | La stampa e' andata a buon fine // @flag FALSE | La stampa e' stata interrotta bool TPrintwin::do_print() - - // @comm Quando possibile parte un processo concorrente (dipende dal sistema operativo) - +// @comm Quando possibile parte un processo concorrente (dipende dal sistema operativo) { - int page = 0; - RCT* rct; - bool ok = TRUE; - -#ifdef DBG - const long size = xvt_dwin_get_font_size_mapped(win()); -#endif _frlc = 0; _blank_lines_to_print = 0; + + int page = 0; + bool ok = TRUE; + RCT* rct; while (ok && !_aborted) { _aborted = xvt_print_open_page(_printrcd) == 0; @@ -324,16 +330,13 @@ bool TPrintwin::do_print() { set_font(XVT_FFN_SYSTEM, XVT_FS_NONE, _char_size); set_font(printer().fontname(), XVT_FS_NONE, _char_size); -#ifdef DBG - long size1 = xvt_dwin_get_font_size_mapped(win()); - CHECK(size == size1, "Failed to set font. xvt bugs???"); -#endif ok = print_band(page, *rct); } _aborted |= (xvt_print_close_page(_printrcd) == 0); page++; } - return !_aborted; + + return !_aborted; } diff --git a/include/printwin.h b/include/printwin.h index a8739794c..05621d8e6 100755 --- a/include/printwin.h +++ b/include/printwin.h @@ -73,11 +73,11 @@ class TPrintwin : public TWindow void paint_row(long j); // @cmember:(INTERNAL) Permette di disegnare un'immagine alla riga y void paint_image(int y, const char* cp); - // @cmember:(INTERNAL) Permette di disegnare la parte di finestra per la pagina

- bool print_band(int page, RCT&); // @access Public Member public: + // @cmember:(INTERNAL) Permette di disegnare la parte di finestra per la pagina

+ bool print_band(int page, const RCT& rct); // @cmember Ritorna se la stampa e' stata interrotta (viene ritornata anche della // ) diff --git a/include/progind.cpp b/include/progind.cpp index e6289598d..2a315f849 100755 --- a/include/progind.cpp +++ b/include/progind.cpp @@ -6,8 +6,8 @@ #ifndef INCL_XI extern "C" { - void XVT_CALLCONV1 xi_draw_3d_rect XVT_CC_ARGS( ( WINDOW win, RCT* rctp, BOOLEAN well, int height, - COLOR color_light, COLOR color_ctrl, COLOR color_dark ) ); + void xi_draw_3d_rect (WINDOW win, RCT* rctp, BOOLEAN well, int height, + COLOR color_light, COLOR color_ctrl, COLOR color_dark); } #endif diff --git a/include/real.cpp b/include/real.cpp index 4e4392a67..24f43647f 100755 --- a/include/real.cpp +++ b/include/real.cpp @@ -3,7 +3,6 @@ #include -HIDDEN char __string[128]; const real ZERO (0.0); #ifdef __LONGDOUBLE__ @@ -121,7 +120,7 @@ long real::integer () const // @mfunc Trasforma un reale in stringa // // @rdesc Ritorna la stringa nella lunghezza richiesta -char *real::string ( +const char *real::string ( int len, // @parm Lunghezza della stringa (compreso decimali) int dec, // @parm Numero di decimali (default UNDEFINED) char pad) const // @parm Carattere di riempimento (default ' ') @@ -143,6 +142,10 @@ char *real::string ( if (len != 0) fmt << len; if (dec != UNDEFINED) fmt << '.' << dec; fmt << "Lf"; + + TString& tmp = get_tmp_string(); + char* __string = tmp.get_buffer(len); + sprintf(__string, fmt, _dec); if (len == 0 && dec == UNDEFINED && strchr(__string, '.') != NULL) @@ -1210,7 +1213,7 @@ TObject* real::dup () const return new real(*this); } -char *real::eng2ita (char *s) +const char *real::eng2ita (char *s) { if (s) { @@ -1222,8 +1225,11 @@ char *real::eng2ita (char *s) } // Elimina gli spazi ed i punti, converte le virgole in punti -char *real::ita2eng (const char *s) +const char *real::ita2eng (const char *s) { + TString& tmp = get_tmp_string(); + char* __string = tmp.get_buffer(strlen(s)); + int j = 0; if (s) for (int i = 0; s[i]; i++) @@ -1282,7 +1288,7 @@ bool real::is_natural (const char *s) } // Certified 75% -char* real::literals() const +const char* real::literals() const { const char *primi20[] = {"", "uno", "due", "tre", "quattro", @@ -1308,7 +1314,7 @@ char* real::literals() const if (negativo) r.ltrim (1); - TFixed_string risultato (__string, 128); + TString& risultato = get_tmp_string(128); risultato.cut (0); TString centinaia; @@ -1377,11 +1383,11 @@ char* real::literals() const if (negativo) risultato.insert ("meno", 0); - return __string; + return risultato; } // Certified 75% -char* real::points (int dec) const +const char* real::points (int dec) const { const char *str = stringa (0, dec); const int neg = (*str == '-') ? 1 : 0; @@ -1408,7 +1414,7 @@ char* real::points (int dec) const for (i = dot - 3; i > neg; i -= 3) n.insert (".", i); - return __string; + return str; } HIDDEN int get_picture_decimals (const TString& picture, char& decsep) @@ -1452,7 +1458,7 @@ HIDDEN int get_picture_decimals (const TString& picture, char& decsep) return decimali; } -char* real::string(const char *picture) const +const char* real::string(const char *picture) const { if (*picture == '\0') return string (); @@ -1462,9 +1468,10 @@ char* real::string(const char *picture) const return literals (); TString v (string()); - TString f (picture); - char decsep = ','; // Separatore dei decimali + TString& f = get_tmp_string(); + f = picture; + char decsep = ','; // Separatore dei decimali if (f[f.len() - 1] == 'E') { f.rtrim(1); @@ -1546,17 +1553,16 @@ char* real::string(const char *picture) const default: break; } - return strcpy (__string, f); + return f; } // Certified 99% -char *real ::stringa (int len, int dec, char pad) const - +const char* real::stringa (int len, int dec, char pad) const { - string (len, dec, pad); + char* str = (char*)string(len, dec, pad); if (dec > 0 || dec == UNDEFINED) - eng2ita (__string); - return __string; + eng2ita (str); + return str; } void real::print_on(ostream& out) const diff --git a/include/real.h b/include/real.h index 1b09e3bd4..ff4216a0c 100755 --- a/include/real.h +++ b/include/real.h @@ -36,10 +36,10 @@ protected: // @cmember Duplica il numero reale (vedi classe ) virtual TObject* dup() const; // @cmember Traduce in lettere il numero reale - char* literals() const; + const char* literals() const; // @cmember Inserisce i punti separatori delle migliaia e riempe i decimali // alla lunghezza passata (es: 3.000,20) - char* points(int decimals = 0) const; + const char* points(int decimals = 0) const; // @access Public Member public: @@ -49,10 +49,10 @@ public: // @cmember Trasforma un numero dal formato inglese (decimali con punto) in // formato italiano (decimali con virgola) - static char* eng2ita(char* s); + static const char* eng2ita(char* s); // @cmember Trasforma un numero dal formato italiano (decimali con virgola) in // formato inglese (decimali con punto) - static char* ita2eng(const char* s); + static const char* ita2eng(const char* s); // @cmember Controlla se si tratta di un numero reale (TRUE se vero) static bool is_real(const char* n); // @cmember Controlla se si tratta di un numero naturale intero (TRUE se vero) @@ -60,12 +60,12 @@ public: // @cmember Controlla se si tratta di uno zero (TRUE se vero) static bool is_null(const char* n); // @cmember Trasforma un reale in stringa - char* string(int len = 0, int dec = UNDEFINED, char pad = ' ') const; + const char* string(int len = 0, int dec = UNDEFINED, char pad = ' ') const; // @cmember Trasforma un reale in stringa (chiama ), ma // ritorna il formato italiano - char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const; + const char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const; // @cmember Ritorna la stringa con il formato passato - char* string(const char* picture) const; + const char* string(const char* picture) const; // @cmember Ritorna la precisione del reale (numero di decimali) int precision() const; @@ -169,10 +169,10 @@ protected: // @cmember Duplica il numero reale (vedi classe ) virtual TObject* dup() const; // @cmember Traduce in lettere il numero reale - char* literals() const; + const char* literals() const; // @cmember Inserisce i punti separatori delle migliaia e riempe i decimali // alla lunghezza passata (es: 3.000,20) - char* points(int decimals = 0) const; + const char* points(int decimals = 0) const; // @access Public Member public: @@ -183,10 +183,10 @@ public: // @cmember Trasforma un numero dal formato inglese (decimali con punto) in // formato italiano (decimali con virgola) - static char* eng2ita(char* s); + static const char* eng2ita(char* s); // @cmember Trasforma un numero dal formato italiano (decimali con virgola) in // formato inglese (decimali con punto) - static char* ita2eng(const char* s); + static const char* ita2eng(const char* s); // @cmember Controlla se si tratta di un numero reale (TRUE se vero) static bool is_real(const char* n); // @cmember Controlla se si tratta di un numero naturale intero (TRUE se vero) diff --git a/include/recarray.cpp b/include/recarray.cpp index f1f815a87..0743989cb 100755 --- a/include/recarray.cpp +++ b/include/recarray.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/include/regexp.cpp b/include/regexp.cpp index 91489b1d4..cf6957ff1 100755 --- a/include/regexp.cpp +++ b/include/regexp.cpp @@ -1,3 +1,5 @@ +#include + #include // codici di ritorno della matche() diff --git a/include/scanner.cpp b/include/scanner.cpp index 4bc751fad..f1bc95437 100755 --- a/include/scanner.cpp +++ b/include/scanner.cpp @@ -1,4 +1,5 @@ #include +#include #include diff --git a/include/sheet.cpp b/include/sheet.cpp index 9183502bf..17139f03c 100755 --- a/include/sheet.cpp +++ b/include/sheet.cpp @@ -964,7 +964,7 @@ TSheet::TSheet(short x, short y, short dx, short dy, _parked(-1), _sheet(NULL), _select_row(-1) { TQuery_field* qf = new TQuery_field(this); - qf->construct(30883, head, 1, sht_y, -3, win(), "", -1); + qf->construct(25883, head, 1, sht_y, -3, win(), "", -1); fields_array().add(qf); _sheet = qf->sheet(); diff --git a/include/skeytsr.h b/include/skeytsr.h index 29dd28ccb..5f56e752d 100755 --- a/include/skeytsr.h +++ b/include/skeytsr.h @@ -12,7 +12,7 @@ /* Application : SkeyTsr */ /* Module : skeytsr.h */ /* Version : 1.0 */ -/* Date : 18.4.1995 */ +/* Date : 8.2.1996 */ /* Note : */ /* */ /* -------------------------------------------------------------------- */ @@ -74,6 +74,7 @@ #define ST_DRIVER_NOT_INST -13 /* SKEYTSR not installed */ #define ST_TOO_MANY_OPEN_KEY -14 /* Too many open SmartKey */ #define ST_NET_PASS_INVALID -15 /* Invalid net password */ +#define ST_EXEC_ERROR -16 /* Max exec reached */ #define ST_HW_FAILURE -20 /* Smartkey damaged */ /* -------------------------------------------------------------------- */ @@ -119,7 +120,6 @@ typedef struct smartkey { /* Interface function prototype */ /* -------------------------------------------------------------------- */ - -short __far __pascal smartlink(KEY_NET __far *pSkey); +short smartlink(KEY_NET *pSkey); #endif diff --git a/include/strings.cpp b/include/strings.cpp index 4c6a6cf65..7b7f9dc6f 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -30,81 +31,6 @@ const TToken_string& empty_string() const int DEFAULT_SIZE = 50; const int MAX_SIZE = 32000; -#ifdef FOXPRO -class TString512 : public TFixed_string -{ - char _str512[513]; - -public: - char* get_buffer(); - - TString512() : TFixed_string(_str512, 513) { } - const TString& operator =(const char* s); - const TString& operator =(const TString& s) { return operator =((const char*)s); } - void strncpy(const char* s, int n); -}; - -#else - -class TString512 : public TString -{ -public: - char* get_buffer(); - - TString512() : TString(512) { } - const TString& operator =(const char* s); - const TString& operator =(const TString& s) { return operator =((const char*)s); } - void strncpy(const char* s, int n); -}; - -#endif - -char* TString512::get_buffer() -{ - if (_size == 0) - { -#ifdef DBG - NFCHECK("Tentativo d'uso di una stringa statica non inizializzata."); -#endif -#ifdef FOXPRO - _str = _str512; - _size = 512; -#else - _str = new char[_size = 512]; -#endif - } - return _str; -} - - -const TString& TString512::operator =(const char* s) -{ - if (_size == 0) - get_buffer(); - return set(s); -} - -void TString512::strncpy(const char* s, int n) -{ - if (_size == 0) - get_buffer(); -#ifdef FOXPRO - TFixed_string::strncpy(s, n); -#else - if (n > _size) - resize(n, FALSE); - ::strncpy(_str, s, n); - _str[n] = '\0'; -#endif -} - -#ifdef FOXPRO -HIDDEN TString512 spark; -#else -HIDDEN TString512* ptr_spark = new TString512; -HIDDEN TString512& spark = *ptr_spark; -#endif - inline bool is_space(char c) { return c >= '\t' && c <= ' '; } @@ -484,7 +410,9 @@ const TString& TString::left( // @rdesc Ritorna l'indirizzo della stringa contenente i

caratteri da sinistra { - spark.strncpy(_str, count); + TString& spark = get_tmp_string(); + spark = _str; + spark.cut(count); return spark; } @@ -497,6 +425,7 @@ const TString& TString::right( // @rdesc Ritorna l'indirizzo della stringa contenente i

caratteri da destra { + TString& spark = get_tmp_string(); int from = len()-count; if (from < 0) from = 0; spark = _str + from; @@ -515,6 +444,7 @@ const TString& TString::mid( // @rdesc Ritorna l'indirizzo della stringa contenente i

cartteri da

{ + TString& spark = get_tmp_string(); const int l = len(); #ifdef DBG @@ -527,7 +457,8 @@ const TString& TString::mid( if (from > l) from = l; if (count < 0 || from+count>l) count = l-from; - spark.strncpy(&_str[from], count); + spark = &_str[from]; + spark.cut(count); return spark; } @@ -552,9 +483,6 @@ TString& TString::cut(int n) CHECKD(n >= 0, "Invalid TString::cut position ", n); if (n <= _size) _str[n] = '\0'; -// else -// NFCHECK("Hai tagliato a %d la stringa '%s' lunga %d(%d)", -// n, _str, len(), size()); return *this; } @@ -741,6 +669,7 @@ TString& TString::right_just( // // @xref { + TString& spark = get_tmp_string(); if (n < 0) n = size(); trim(); spark = _str; @@ -763,6 +692,7 @@ TString& TString::center_just( // // @xref { + TString& spark = get_tmp_string(); if (n < 0) n = size(); trim(); spark = _str; @@ -786,6 +716,7 @@ TString& TString::left_just( // // @xref { + TString& spark = get_tmp_string(); if (n < 0) n = size(); trim(); spark = _str; @@ -831,6 +762,7 @@ TString& TString::format( // @comm Funziona come la funzione "sprintf" standard del C e ritorna la // stringa formattata con i parametri passati. { + TString& spark = get_tmp_string(512); va_list pars; va_start(pars, fmt); const int tot = vsprintf(spark.get_buffer(), fmt, pars); @@ -953,9 +885,9 @@ TString& TString::insert( { const int l = strlen(s); make_room(l); - mid(pos); // Scrivi in spark la stringa da pos in poi - overwrite(s, pos); // Aggiungi s - strcpy(&_str[pos+l], spark); // Aggiungi spark + const TString& spark = mid(pos); // Scrivi in spark la stringa da pos in poi + overwrite(s, pos); // Aggiungi s + strcpy(&_str[pos+l], spark); // Aggiungi spark } return *this; } @@ -1084,7 +1016,9 @@ const char* TFilename::name() const if (_str[i] == '/' || _str[i] == '\\' || _str[i] == ':') break; - spark.strncpy(&_str[i+1], start-i); + TString& spark = get_tmp_string(); + spark = &_str[i+1]; + spark.cut(start-i); return spark; } @@ -1097,7 +1031,9 @@ const char* TFilename::path() const for (int i = start; i >= 0; i--) if (_str[i] == '/' || _str[i] == '\\' || _str[i] == ':') break; - spark.strncpy(_str, i+1); + TString& spark = get_tmp_string(); + spark = _str; + spark.cut(i+1); return spark; } @@ -1435,6 +1371,7 @@ const char* TToken_string::get( // @xref { CHECK(_separator, "Corrupted TToken_string: NULL separator"); + TString& spark = get_tmp_string(); if (n < 0) { @@ -1599,6 +1536,7 @@ bool TToken_string::get( bool TToken_string::set_item(const char* v, int n) { CHECK(_separator, "Corrupted TToken_string: NULL separator"); + TString& spark = get_tmp_string(); int sep = 0; for (int i = 0; sep < n && _str[i]; i++) @@ -1615,7 +1553,7 @@ bool TToken_string::set_item(const char* v, int n) int e = find(_separator, i); if (e < 0) e = len(); - spark = _str+e; // Salva items seguenti + spark = _str+e; // Salva items seguenti cut(i); // Considera solo items precedenti *this << v << spark; // Aggiunge item desiderato e seguenti return TRUE; @@ -1938,3 +1876,23 @@ void TString_array::sort(bool ascending) TArray::sort(ascending ? ascending_string : descending_string); } +// Temporary strings generator: a little step for a man, a big step for campo! + +TToken_string& get_tmp_string(int len) +{ + static TString_array ararar(128); + static int next = 0; + + TToken_string* str = (TToken_string*)ararar.objptr(next); + if (str == NULL || str->size() < len) + { + str = new TToken_string(len); + ararar.add(str, next); + } + else + str->cut(0); + + if (++next >= ararar.size()) + next = 0; + return *str; +} diff --git a/include/strings.h b/include/strings.h index 894b79296..2ee3e7af4 100755 --- a/include/strings.h +++ b/include/strings.h @@ -282,11 +282,8 @@ public: // @cmember Distruttore virtual ~TFixed_string(); -#ifndef __WATCOMC__ - virtual -#endif - // @cmember Manda un output formattato alla stringa oggetto - TString& format(const char* fmt, ...); + // @cmember Manda un output formattato alla stringa oggetto + virtual TString& format(const char* fmt, ...); // @cmember Assegna la stringa passata con indirizzo const TString& operator =(const TString& s) @@ -719,6 +716,8 @@ public: TString& user(); +TToken_string& get_tmp_string(int len = -1); + const TToken_string& empty_string(); #define EMPTY_STRING empty_string() diff --git a/include/tree.cpp b/include/tree.cpp index 3c37f7d29..f18c3e996 100755 --- a/include/tree.cpp +++ b/include/tree.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include /////////////////////////////////////////////////////////// // Callbacks diff --git a/include/viswin.cpp b/include/viswin.cpp index 7d59bd03a..9db019088 100755 --- a/include/viswin.cpp +++ b/include/viswin.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,6 @@ public: class _BkMenuDesc : public TObject { public: - TString_array _menu; int _father_id; _BkMenuDesc() {} @@ -71,15 +71,6 @@ public: int TViswin::tabx(int x) const { -/* - HIDDEN long w = 0L; - if (w == 0L) - { - const TString t(256, 'm'); - w = xvt_dwin_get_text_width(win(), (char*)(const char*)t, 256); - } - return int((w*x) >> 8); -*/ return char2pixel(x); } @@ -1590,10 +1581,8 @@ void TViswin::handler (WINDOW win, EVENT * ep) autoscroll(TRUE); if (_selecting) - _isselection = TRUE;; - { _isselection = TRUE; - } + // scroll if necessary if (p.y >= _textrows + 1l) { @@ -1895,7 +1884,7 @@ void TViswin::handler (WINDOW win, EVENT * ep) update (); } -bool TViswin::on_key (KEY key) +bool TViswin::on_key(KEY key) { EVENT_TYPE type = E_USER; @@ -2277,8 +2266,9 @@ void TViswin::sel_to_clipboard() // put data for (i = 0; i < txt.items(); i++) { - TString& s = txt.row(i); - for (int j = 0; j < s.len(); j++) + const TString& s = txt.row(i); + const int slen = s.len(); + for (int j = 0; j < slen; j++) *p++ = s[j]; for (j = 0; j < eol_len; j++) *p++ = EOL_SEQ[j]; diff --git a/include/window.cpp b/include/window.cpp index 50783a1b5..7a4a8d6f4 100755 --- a/include/window.cpp +++ b/include/window.cpp @@ -61,9 +61,9 @@ HIDDEN void set_menu_item(MENU_ITEM& m, TToken_string& tt) m.tag = tag; m.text = text; - m.enabled = !(flag.find('D') != -1); - m.checkable = flag.find('C') != -1 || flag.find('c') != -1; - m.checked = flag.find('c') != -1; + m.enabled = flag.find('D') < 0; + m.checkable = flag.find('C') >= 0 || flag.find('c') >= 0; + m.checked = flag.find('c') >= 0; m.separator = text == NULL; } @@ -198,9 +198,12 @@ HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on) void TWindow_manager::menu_enable(bool on) const { MENU_ITEM *mi = xvt_menu_get_tree(TASK_WIN); - xvt_menu_enable(mi, on); - xvt_menu_update(TASK_WIN); - xvt_res_free_menu_tree(mi); + if (mi) + { + xvt_menu_enable(mi, on); + xvt_menu_update(TASK_WIN); + xvt_res_free_menu_tree(mi); + } } @@ -311,256 +314,6 @@ WINDOW cur_win() return win; } -/////////////////////////////////////////////////////////// -// TImage -/////////////////////////////////////////////////////////// - - -// Certified 99% -// @doc EXTERNAL - -// @mfunc Setta l'immagine e le sue dimensioni -// -// @rdesc Ritorna l'immagine stessa -XVT_IMAGE TImage::set( - XVT_IMAGE i) // @parm Immagine da settare - - // @comm L'immagine precedente viene cancellata quando viene settata una nuova -{ - if (_image) - xvt_image_destroy(_image); - _image = i; - if (i) - { - _src.left = _src.top = 0; - xvt_image_get_dimensions(i, &_src.right, &_src.bottom); - _dst = _src; - } - return _image; -} - -// Certified 100% -// @doc EXTERNAL - -// @mfunc Legge l'immagine dal file -XVT_IMAGE TImage::load( - const char* n) // @parm Nome del file contenente l'immagine -{ - WinManager.free_handle(); - XVT_IMAGE i = xvt_image_read_bmp((char*)n); - WinManager.lock_handle(); - - if (i != NULL) set(i); - return i; -} - -// Certified 100% -XVT_IMAGE TImage::load(short id) -{ - return set(xvt_res_get_image(id)); -} - - -// Certified 100% -TImage::TImage(const char* n) : _image(NULL) -{ - if (n && *n) load(n); -} - -// Certified 100% -TImage::TImage(short id) : _image(NULL) -{ - if (id > 0) load(id); -} - -// Certified 90% -TImage::TImage(const TImage& im, short w, short h) : _image(NULL) -{ - const XVT_IMAGE_FORMAT fmt = xvt_image_get_format(im._image); - if (w < 0 || h < 0) - { - short iw, ih; - xvt_image_get_dimensions(im._image, &iw, &ih); - if (w < 0) w = iw; - if (h < 0) h = ih; - } - set(xvt_image_create(fmt, w, h, NULL)); - - if (ok()) - { - if (fmt == XVT_IMAGE_CL8) - { - const short colors = xvt_image_get_ncolors(im._image); - xvt_image_set_ncolors(_image, colors); - for (short c = 0; c < colors; c++) - xvt_image_set_clut(_image, c, xvt_image_get_clut((XVT_IMAGE)im._image, c)); - } - xvt_image_transfer(_image, (XVT_IMAGE)im._image, &_src, (RCT*)&im._src); - } -} - -// Certified 90% -TImage::TImage(short w, short h, XVT_IMAGE_FORMAT fmt) : _image(NULL) -{ - set(xvt_image_create(fmt, w, h, NULL)); -} - -// Certified 100% -TImage::~TImage() -{ - if (_image != NULL) - xvt_image_destroy(_image); -} - -// Certified 100% -// @doc EXTERNAL - -// @mfunc Permette di settare la posizione della figura -void TImage::set_pos( - int x, // @parm Coordinata x dell'immagine da settare - int y) // @parm Coordinata y dell'immagine da settare - - // @comm Permette di aggiornare il mebro

sommandogli i valori - // passati con

e

-{ - _dst = _src; - xvt_rect_offset(&_dst, x, y); -} - -// Certified 100% -void TImage::draw(WINDOW w) const -{ - xvt_dwin_draw_image(w, _image, (RCT*)&_dst, (RCT*)&_src); -} - -// Certified 100% -// @doc EXTERNAL - -// @mfunc Permette di gestire il disegno dell'immagine sullo schermo -void TImage::draw( - WINDOW w, // @parm Immagine da disegnare - int x, // @parm Coordinata x in cui disegnare l'immagine - int y) const // @parm Coordinata y in cui disegnare l'immagine - // @parm RCT& | _src | Rettangolo contenente l'immagine da disegnare - // @parm RCT& | _dst | Rettangolo in cui disegnare l'immagine - - // @syntax void draw(WINDOW w); - // @syntax void draw(WINDOW w, int x, int y); - // @syntax void draw(WINDOW w, const RCT& dst); - // @syntax void draw(WINDOW w, const RCT& dst, const RCT& src); - - // @comm Nel caso utilizzo l'ultima sintassi e' possibile disegnare solo una parte - // dell'immagine, precisamente delle dimensioni

se tale parametro e' - // minore di

-{ - RCT dst = _src; - xvt_rect_offset(&dst, x, y); - xvt_dwin_draw_image(w, _image, &dst, (RCT*)&_src); -} - -// Certified 100% -void TImage::draw(WINDOW w, const RCT& dst) const -{ - xvt_dwin_draw_image(w, _image, (RCT*)&dst, (RCT*)&_src); -} - -// Certified 100% -void TImage::draw(WINDOW w, const RCT& dst, const RCT& src) const -{ - xvt_dwin_draw_image(w, _image, (RCT*)&dst, (RCT*)&src); -} - -// Certified 99% -// @doc EXTERNAL - -// @mfunc Fa corrispondere la palette della finestra a quella dell'immagine -void TImage::set_palette( - WINDOW w) const // @parm Finestra a cui settare la palette -{ - XVT_PALETTE wp = xvt_vobj_get_palet(w); - if (wp != NULL) - { - XVT_PALETTE p = xvt_palet_create(XVT_PALETTE_USER, NULL); - const int ncolors = xvt_palet_get_ncolors(wp); - COLOR* color = new COLOR[ncolors]; - xvt_palet_get_colors(wp, color, ncolors); - xvt_palet_add_colors(p, color, ncolors); - delete color; - xvt_palet_add_colors_from_image(p, _image); - xvt_vobj_set_palet(w, p); - xvt_palet_destroy(wp); - } -} - -// Certified 100% -void TImage::set_clut(byte n, COLOR c) -{ - if (xvt_image_get_format(_image) == XVT_IMAGE_CL8) - xvt_image_set_clut(_image, n, c); -} - -void TImage::set_pixel(int x, int y, COLOR col) -{ - xvt_image_set_pixel(_image, x, y, col); -} - -COLOR TImage::get_pixel(int x, int y) const -{ - return xvt_image_get_pixel(_image, x, y); -} - -// Certified 99% -// @doc EXTERNAL - -// @mfunc Setta i colori dell'immagine in modo da renderla trasparente -void TImage::convert_to_default_colors() - - // @comm Legge nell'immagine i colori CYAN e DARK_CYAN e li setta a seconda del colore - // della finestra per fare in modo di rendere trasparenti tali colori. -{ - if (MASK_BACK_COLOR != COLOR_DKCYAN && xvt_image_get_format(_image) == XVT_IMAGE_CL8) - { - short dx, dy; xvt_image_get_dimensions(_image, &dx, &dy); - for (short y = 0; y < dy; y++) for (short x = 0; x < dx; x++) - { - const COLOR c = get_pixel(x, y); - switch (c) - { - case COLOR_DKCYAN & 0x00FFFFFF: - set_pixel(x, y, MASK_BACK_COLOR); break; - case COLOR_CYAN & 0x00FFFFFF: - set_pixel(x, y, MASK_LIGHT_COLOR); break; - case COLOR_GRAY & 0x00FFFFFF: - set_pixel(x, y, MASK_DARK_COLOR); break; - default: - break; - } - } - } -} - -// @mfunc Setta i colori dell'immagine in modo da renderla trasparente -void TImage::convert_transparent_color(COLOR transparent) - - // @comm Legge nell'immagine i pixel uguali a quello in alto a sinistra e li setta - // uguali allo sfondo delle maschere -{ - if (_image) - { - const COLOR trans = get_pixel(0, 0) & 0x00FFFFFF; - if (trans != (transparent & 0x00FFFFFF) && - xvt_image_get_format(_image) == XVT_IMAGE_CL8) - { - for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--) - if (trans == (xvt_image_get_clut(_image, index) & 0x00FFFFFF)) - { - xvt_image_set_clut(_image, index, transparent); - // break; don't break: replace all colors equal to upper left in the palette - } - } - } -} - /////////////////////////////////////////////////////////// // TWindow /////////////////////////////////////////////////////////// @@ -577,7 +330,7 @@ TWindow::TWindow() word TWindow::class_id() const { return CLASS_WINDOW; } -long XVT_CALLCONV1 TWindow::window_handler(WINDOW win, EVENT* ep) +long TWindow::window_handler(WINDOW win, EVENT* ep) { TWindow* w = (TWindow*)xvt_vobj_get_data(win); CHECK(w != NULL, "Invalid window"); @@ -810,7 +563,7 @@ void TWindow::maximize() const void TWindow::set_background_color(COLOR col) { - XI_OBJ* itf = xi_get_itf(win()); + XI_OBJ* itf = xi_get_itf((XinWindow)win()); itf->v.itf->back_color = col; force_update(); } @@ -942,14 +695,18 @@ void TWindow::frame( if (left > right) swap(left, right); if (top > bottom) swap(top, bottom); - const bool saved = flag && save_ctools(); + const bool saved = flag != 0 && save_ctools(); if (flag & 1) hide_pen(); if (flag & 2) hide_brush(); if (flag & 4) { set_mode(M_XOR); +#ifdef XVGUY + set_brush(COLOR_WHITE); +#else set_brush(COLOR_BLACK); // Needed for Windows +#endif } const PNT f = log2dev(left,top); @@ -1044,7 +801,6 @@ TPoint TWindow::dev2log(const PNT& p) const TPoint pnt(p.h, p.v); if (!_pixmap) { -// pnt.x /= CHARX; pnt.x = int(128L * p.h / char2pixel(128)); pnt.y /= CHARY; } diff --git a/include/window.h b/include/window.h index f1ffde02a..f41636a1b 100755 --- a/include/window.h +++ b/include/window.h @@ -51,93 +51,6 @@ struct TPoint { return p.x != x || p.y != y; } }; -/////////////////////////////////////////////////////////// -// TImage -/////////////////////////////////////////////////////////// - -// @doc EXTERNAL - -// @class TImage | Classe per la gestione delle imagini a video -// -// @base public | TObject -class TImage : public TObject - -// @author:(INTERNAL) Guido -{ - // @access Private Member - - // @cmember:(INTERNAL) Immagine de gestire - XVT_IMAGE _image; - // @cmember:(INTERNAL) Rettangolo originale (origine 0,0 e dimensioni originali) dell'immagine - RCT _src; - // @cmember:(INTERNAL) Rettangolo di visualizzazione dell'immagine (dove mettere l'immagine) - RCT _dst; - - // @access Public Member -public: - // @cmember Fa corrispondere la palette della finestra a quella dell'immagine - void set_palette(WINDOW w) const; - // @cmember Permette di settare la posizione della figura - void set_pos(int x, int y); - - // @cmember Disegna l'immagine nella poszione di default e nella dimensione - // di defalut - void draw(WINDOW w) const ; - // @cmember Disegna l'immagine con dimensione default in un punto dello schermo - void draw(WINDOW w, int x, int y) const; - // @cmember Disegna/modifica l'immagine sullo schermo - void draw(WINDOW w, const RCT& dst) const; - // @cmember Disegna l'immagine sulla finestra - void draw(WINDOW w, const RCT& dst, const RCT& src) const; - // @cmember Setta un pixel - void set_pixel(int x, int y, COLOR c); - // @cmember Legge un pixel - COLOR get_pixel(int x, int y) const; - - // @cmember Setta l'immagine e le sue dimensioni - XVT_IMAGE set(XVT_IMAGE i); - // @cmember Legge l'immagine dal file - XVT_IMAGE load(const char* n); - // @cmember Legge l'immagine dal file di risorse - XVT_IMAGE load(short id); - - // @cmember Controlla che l'immagine sia un oggetto valido (diverso da NULL) - virtual bool ok() const - { return _image != NULL; } - - // @cmember Ritorna la larghezza dell'immagine - short width() const - { return _src.right; } - // @cmember Ritorna l'altezza dell'immagine - short height() const - { return _src.bottom; } - // @cmember Ritorna il rettangolo dell'immagine originale - const RCT& rect() const - { return _src; } - - // @cmember Setta i colori dell'immagine in modo da renderla trasparente - // usando i colori di default (di Morpurgo) - void convert_to_default_colors(); - - // @cmember Setta i colori dell'immagine in modo da renderla trasparente - // usando l'angolo in alto a sinistra dell'imagine stessa - void convert_transparent_color(COLOR transparent); - - // @cmember Setta l'

.esime entry della paletta al colore

- void set_clut(byte n, COLOR c); - - // @cmember Costruttore. Viene passato il nome del file - TImage(const char* n); - // @cmember Costruttore. Viene passato l'identificatore dell'immagine sul file di risorsa - TImage(short id); - // @cmember Costruttore. Viene passata l'immagine e le sue diemsioni - TImage(const TImage& i, short width = -1, short height = -1); - // @cmember Costruttore. Viene passata l'immagine e le sue diemsioni - TImage(short width, short height, XVT_IMAGE_FORMAT fmt = XVT_IMAGE_CL8); - // @cmember Distruttore - virtual ~TImage(); -}; - // @doc EXTERNAL // @class TWindow | Classe per la definizione di una finestra generica @@ -183,7 +96,7 @@ protected: bool _pixmap : 1; // @cmember Intercetta tutti i messaggi diretti alla finestra di XVT - static long XVT_CALLCONV1 window_handler(WINDOW win, EVENT* ep); + static long window_handler(WINDOW win, EVENT* ep); // @cmember Crea la finestra virtual WINDOW create(short x, short y, short dx, short dy, const char* title = "", long flags = WSF_NONE, WIN_TYPE rt = W_DOC, WINDOW parent = NULL_WIN, int menu = 0) ; diff --git a/include/xvtility.cpp b/include/xvtility.cpp index df1a1de45..50df1419b 100755 --- a/include/xvtility.cpp +++ b/include/xvtility.cpp @@ -1,5 +1,3 @@ -#define STRICT -#define XVT_INCL_NATIVE #include #include #include @@ -589,7 +587,7 @@ void xvt_statbar_set( // @doc INTERNAL -// @func Permette di cambiare il titolo alla barra di stato presente +// @func Setta il testo standard della barra di stato void xvt_statbar_refresh() // @xref @@ -628,10 +626,14 @@ HIDDEN bool test_menu_tag(MENU_ITEM* mi, MENU_TAG tag) bool xvt_test_menu_tag( MENU_TAG tag) // @parm Menu' nel quale cercare la voce -{ +{ + bool ok = FALSE; MENU_ITEM *mi = xvt_menu_get_tree(TASK_WIN); - const bool ok = test_menu_tag(mi, tag); - xvt_res_free_menu_tree(mi); + if (mi) + { + ok = test_menu_tag(mi, tag); + xvt_res_free_menu_tree(mi); + } return ok; }