From 5df8cfc13ba3db482a4ca69f6faddffe7b32474f Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 3 Oct 1994 08:47:32 +0000 Subject: [PATCH] Potenziamento degli sheet: riconoscono numeri romani e allineamenti a destra. Gli operatori left, mid, sub e right delle stringhe ritornano un TString&. Corretta la relapp nel caso di ripensamento dopo aver premuto Annulla o Fine. git-svn-id: svn://10.65.10.50/trunk@302 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/applicat.cpp | 11 +- include/controls.cpp | 10 +- include/isam.cpp | 8 +- include/isam.h | 3 +- include/mask.cpp | 50 +++++---- include/maskfld.cpp | 121 ++++++++++++++-------- include/msksheet.cpp | 61 +++++------ include/prassi.ver | 2 +- include/real.cpp | 12 +-- include/relapp.cpp | 3 +- include/relapp.h | 68 ++++++++----- include/sheet.cpp | 40 ++++++-- include/sheet.h | 2 +- include/strings.cpp | 89 +++++++++------- include/strings.h | 18 ++-- include/xvtility.cpp | 235 ++++++++++++++++++++++++++----------------- 16 files changed, 449 insertions(+), 284 deletions(-) diff --git a/include/applicat.cpp b/include/applicat.cpp index b50ef4d53..d4eff166f 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -79,7 +79,6 @@ HIDDEN void create_backdrop( void ) class TBanner : public TWindow { - enum { FONT_SIZE = 28 }; protected: virtual void handler(WINDOW win, EVENT* ep); @@ -90,7 +89,7 @@ public: TBanner::TBanner() { - create(-1, 2, 72, 6, "BANNER", WSF_NONE, W_PLAIN); + create(-1, 6, 72, 6, "BANNER", WSF_NONE, W_PLAIN); hide_brush(); open_modal(); do_events(); @@ -109,7 +108,7 @@ void TBanner::handler(WINDOW win, EVENT* ep) RCT r; get_client_rect(win, &r); set_color(COLOR_WHITE, COLOR_LTGRAY); - set_font(FF_TIMES, FS_BOLD | FS_ITALIC, FONT_SIZE); + set_font(FF_TIMES, FS_BOLD | FS_ITALIC, CHARY<<1); char* t = (char*)(const char*)main_app().title(); int w = win_get_text_width(win, t, -1); int x = (r.right-r.left-w)>>1, y = r.bottom - 4*CHARY; @@ -186,11 +185,13 @@ void TApplication::wait_for(const char* command) TTemp_window tw(TASK_WIN); tw.iconize(); name2id(cmd2name(command)); + + const long old_hook = get_value(TASK_WIN, ATTR_EVENT_HOOK); set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)waiting_event_hook); while (waiting_for) do_events(); // We need to restore these things - customize_controls(TRUE); + set_value(TASK_WIN, ATTR_EVENT_HOOK, old_hook); xvt_statbar_refresh(); } @@ -425,7 +426,7 @@ void TApplication::about() const { #include const TFilename n(__argv[0]); - message_box("PRASSI Versione SMAU 1.%g\nProgramma %s\nLibreria del %s", + message_box("PRASSI Versione Beta %3.1f\nProgramma %s\nLibreria del %s", VERSION, (const char*)n.name(), __DATE__); } diff --git a/include/controls.cpp b/include/controls.cpp index 67a48d25c..51b031522 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -759,7 +759,11 @@ void TTag_button::update() const win_draw_rect(_hdc, &r); if (i == _page) - xvt_draw_rect(_hdc, r, COLOR_CYAN, COLOR_GRAY); +#ifdef __CTL3D__ + xvt_draw_rect(_hdc, r, COLOR_WHITE, COLOR_GRAY); +#else + xvt_draw_rect(_hdc, r, COLOR_CYAN, COLOR_GRAY); +#endif char n[4]; sprintf(n, "%d", i+1); win_draw_text(_hdc, (width-CHARX)/2 + i*width, CHARY-3, n, -1); @@ -769,7 +773,11 @@ void TTag_button::update() const pen.width = 1; pen.pat = PAT_SOLID; pen.style = P_SOLID; +#ifdef __CTL3D__ + pen.color = COLOR_WHITE; +#else pen.color = COLOR_CYAN; +#endif win_set_cpen(_hdc, &pen); PNT p = { _client.bottom, 0 }; diff --git a/include/isam.cpp b/include/isam.cpp index 31ae08ada..f103d39a6 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -174,12 +174,18 @@ const char* TBaseisamfile::name() const } const char* TBaseisamfile::filename() const - { NOT_OPEN(name()); return _isamfile->d->SysName; } +const char* TBaseisamfile::description() const +{ + NOT_OPEN(name()); + return _isamfile->d->Des; +} + + void TBaseisamfile::setkey(int nkey) { diff --git a/include/isam.h b/include/isam.h index 320b5c779..15ab9f599 100755 --- a/include/isam.h +++ b/include/isam.h @@ -234,7 +234,8 @@ public: bool good() const { return status() == NOERR;} // Vero se _lasterr non contiene codici d'errore bool bad() const { return status() != NOERR;} // Vero se _lasterr contiene codici d'errore bool empty(); // Vero se il file e' vuoto - int num() const { return _logicnum;} // Ritorna il numero logico del record corrente + int num() const { return _logicnum;} // Ritorna il numero logico del record corrente + const char* description() const; TRecnotype eod() const { return filehnd()->d->EOD;} isdef* filehnd() const { return (isdef*) _isamfile;} // Ritorna l'handle del file isam nella tabella diff --git a/include/mask.cpp b/include/mask.cpp index 1a9709ce4..520754f46 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -95,16 +95,6 @@ void TMask::control_handler(EVENT* ep) { if (ep->v.ctl.ci.v.edit.active) { - /* - TMask_field& old = fld(_focus); - if (old.dlg() != f->dlg() && old.on_key(K_TAB) == FALSE) - set_focus_win(old.win(), TRUE); - else - { - set_focus_win(win, FALSE); - f->set_focusdirty(FALSE); - } - */ if (test_focus_change(win)) { set_focus_win(win, FALSE); @@ -128,7 +118,11 @@ void TMask::handler(WINDOW win, EVENT* ep) { clear_window(win, MASK_BACK_COLOR); RCT r; get_client_rect(win, &r); +#ifdef __CTL3D__ + xvt_draw_rect(win, r, COLOR_WHITE, COLOR_GRAY, 1); +#else xvt_draw_rect(win, r, COLOR_CYAN, COLOR_GRAY, 1); +#endif } else clear_window(win, COLOR_GRAY); #else @@ -699,9 +693,9 @@ bool TMask::stop_run(KEY key) { const bool ok = check_fields(); if (!ok) return FALSE; - if (is_running()) // Gestisce correttamenete le maschere chiuse - get_mask_fields(); } + if (is_running()) // Gestisce correttamenete le maschere chiuse + get_mask_fields(); return TWindow::stop_run(key); } @@ -865,21 +859,23 @@ int TMask::find_first_field(WINDOW w, int dir) const bool TMask::check_current_page() { - if (!test_focus_change()) - return FALSE; - - if (sheets() > 0) - return TRUE; - - const int last = fields(); - const WINDOW page = win(); - - for (int i = 0; i < last; i++) - { - TMask_field& f = fld(i); - if (f.parent() == page && f.active() && f.on_key(K_ENTER) == FALSE) - return FALSE; - } + /* + if (!test_focus_change()) + return FALSE; + + if (sheets() > 0) + return TRUE; + + const int last = fields(); + const WINDOW page = win(); + + for (int i = 0; i < last; i++) + { + TMask_field& f = fld(i); + if (f.parent() == page && f.active() && f.on_key(K_ENTER) == FALSE) + return FALSE; + } + */ return TRUE; } diff --git a/include/maskfld.cpp b/include/maskfld.cpp index a0bda23f6..563f6f1dc 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -1,4 +1,4 @@ -// $Id: maskfld.cpp,v 1.24 1994-09-27 09:55:43 alex Exp $ +// $Id: maskfld.cpp,v 1.25 1994-10-03 08:47:14 guy Exp $ #include #include @@ -968,14 +968,13 @@ bool TList_sheet::check(CheckTime t) // Certified 100% TBrowse::TBrowse(TEdit_field* f, TRelation* r, int key, const char* filter) : _relation(r), _cursor(new TCursor (r, filter, key)), - _fld(f), _filter(filter), _secondary(FALSE), - _checked(FALSE) + _fld(f), _filter(filter), _secondary(FALSE), _checked(FALSE) {} // Certified 100% TBrowse::TBrowse(TEdit_field* f, TCursor* c) -: _relation(NULL), _cursor(c), _fld(f) +: _relation(NULL), _cursor(c), _fld(f), _secondary(FALSE), _checked(FALSE) {} @@ -1237,10 +1236,19 @@ void TBrowse::do_output(CheckTime t) if (t != STARTING_CHECK || f.field() == NULL || f.mask().mode() == MODE_INS) { sum.cut(0); - for(const char* fr = flds.get(); fr; fr = flds.get()) - { - TFieldref fld(fr, 0); - const char* val = fld.read(_cursor->relation()); + for(const char* fr = flds.get(0); fr; fr = flds.get()) + { + const char* val; + if (*fr == '"') + { + const TString80 v(fr); + val = v.mid(1, v.len()-2); + } + else + { + const TFieldref fld(fr, 0); + val = fld.read(_cursor->relation()); + } sum << val; } @@ -1323,27 +1331,28 @@ TToken_string& TBrowse::create_siblings(TToken_string& siblings) return siblings; // Non saprei come fare TBit_array key(4); // Elenco delle chiavi gia' utilizzate + key.set(_cursor->key()); // Scorre la lista dei campi di output int n = 0; for (const char* i = _out_id.get(0); i; i = _out_id.get(), n++) { - const short id = atoi(i); + const short id = _fld->atodlg(i); const TMask_field& f = mask.field(id); if (!f.showed() || !f.is_edit()) // Scarta i campi non editabili continue; const TEdit_field& e = (const TEdit_field&)f; const TBrowse* b = e.browse(); if (b == NULL) - continue; // Scarta i campi senza ricerca (improbabile) + continue; // Scarta i campi senza ricerca const TCursor* c = b->cursor(); // Considera ricerche sullo stesso file ma con chiave diversa if (c && c->file().num() == _cursor->file().num() && - key[c->key()] == FALSE) + (key[c->key()] == FALSE || id == _fld->dlg())) { - const TString16 fn(_out_fn.get(n)); // Legge nome del campo su file + const TString16 fn(_out_fn.get(n)); // Legge nome del campo su file const int pos = _items.get_pos(fn); // Determina header corrispondente if (pos >= 0) { @@ -1366,8 +1375,23 @@ KEY TBrowse::run() do_input(TRUE); _cursor->read(); - const char* caption = field().prompt(); - if (!isalnum(*caption)) caption = "Selezione"; + TString80 caption; + const TLocalisamfile& f = _cursor->file(); + if (f.tab()) + { + TFilename name("batb"); + if (f.num() == LF_TABCOM) name << '%'; + name << _cursor->file().name() << ".msk"; + TScanner m(name.lower()); + while (m.line().left(2) != "PA"); // Find PAGE + const int apicia = m.token().find('"')+1; + const int apicic = m.token().find('"', apicia); + caption = m.token().sub(apicia, apicic); + } + else + caption = f.description(); + if (!isalnum(*caption)) + caption = "Selezione"; KEY k = K_ESC; long selected = 0; @@ -1410,7 +1434,7 @@ bool TBrowse::check(CheckTime t) { bool passed = TRUE; - if (_secondary && t != RUNNING_CHECK) + if (_secondary == TRUE && t != RUNNING_CHECK) return TRUE; // if (_checked && t == FINAL_CHECK) // return TRUE; @@ -1500,12 +1524,13 @@ void TEdit_field::show(bool on) void TEdit_field::parse_head(TScanner& scanner) { _size = scanner.integer(); +#ifdef DBG if (_size < 1) { _size = 8; - error_box("Il campo %d ha dimensione nulla (uso %d)", dlg(), _size); + yesnofatal_box("Il campo %d ha dimensione nulla (uso %d)", dlg(), _size); } - +#endif _width = scanner.integer(); if (_width == 0) _width = _size; } @@ -1514,19 +1539,12 @@ void TEdit_field::parse_head(TScanner& scanner) const TBrowse* TEdit_field::get_browse(TScanner& scanner) const { const int id = scanner.integer(); - TMask_field& m = mask().field(id); - if (!m.is_edit()) - { - error_box("Il campo %d non puo' fare una COPY del campo %d", - dlg(), id); - return NULL; - } - - TEdit_field& f = (TEdit_field&)m ; - TBrowse* b = (TBrowse*) f.browse(); + const TEdit_field& f = mask().efield(id); + const TBrowse* b = (const TBrowse*)f.browse(); +#ifdef DBG if (b == NULL) - error_box("La USE del campo %d non puo' essere copiata da %d", - id, dlg()); + error_box("La USE del campo %d non puo' essere copiata nel campo %d", id, dlg()); +#endif return b; } @@ -1536,6 +1554,11 @@ bool TEdit_field::parse_item(TScanner& scanner) if (scanner.key() == "PI") // PICTURE { _picture = scanner.string(); +#ifdef DBG + if (_picture == "." && _size > 9 && _size != 15) + ::warning_box("Guy propone una dimensione di 15 per il campo %d: %s\nMa probabilmente ha toppato ...", + dlg(), (const char*)_prompt); +#endif return TRUE; } @@ -1551,9 +1574,11 @@ bool TEdit_field::parse_item(TScanner& scanner) if (scanner.key() == "US") // USE { +#ifdef DBG if (_browse != NULL) return error_box("USE duplicata nel campo %d", dlg()); - +#endif + int key = 1; TRelation* r; @@ -1565,20 +1590,24 @@ bool TEdit_field::parse_item(TScanner& scanner) else { tabmaskname = scanner.pop(); +#ifdef DBG if (tabmaskname.len() > 4) return error_box("'%s' non e' una tabella valida: %d", (const char*)tabmaskname, dlg()); +#endif r = new TRelation(tabmaskname); } if (scanner.popkey() == "KE") { key = scanner.integer(); +#ifdef DBG if (key < 1) { - error_box("Chiave %d non valida nella USE del campo %d", key, dlg()); + yesnofatal_box("Chiave %d non valida nella USE del campo %d", key, dlg()); key = 1; } +#endif } else scanner.push(); @@ -1607,10 +1636,8 @@ bool TEdit_field::parse_item(TScanner& scanner) const TString16 what(scanner.popkey()); const TBrowse* b = get_browse(scanner); -#ifdef DBG - if (b == NULL) - return yesnofatal_box("Impossibile COPYare la browse nel campo %d", dlg()); -#endif + if (b == NULL) return FALSE; + if (what == "US" || what == "AL") _browse = new TBrowse(this, b->cursor()); @@ -1633,15 +1660,18 @@ bool TEdit_field::parse_item(TScanner& scanner) if (scanner.key() == "SH") // SHEET { +#ifdef DBG if (_sheet) return error_box("SHEET duplicato nel campo %d", dlg()); +#endif _sheet = new TList_sheet(this, _prompt, scanner.string()); return TRUE; } if (scanner.key() == "IT") // ITEM { - if (_sheet == NULL) - return error_box("ITEM senza SHEET nel campo %d", dlg()); +#ifdef DBG + if (_sheet == NULL) return error_box("ITEM senza SHEET nel campo %d", dlg()); +#endif _sheet->read_item(scanner); return TRUE; } @@ -1650,14 +1680,17 @@ bool TEdit_field::parse_item(TScanner& scanner) { if (_browse) _browse->parse_input(scanner); else if (_sheet) _sheet->parse_input(scanner); +#ifdef DBG else error_box("INPUT senza USE o SHEET nel campo %d", dlg()); +#endif return TRUE; } if (scanner.key() == "DI") { - if(!_browse) - return error_box("DISPLAY senza USE nel campo %d", dlg()); +#ifdef DBG + if(!_browse) return error_box("DISPLAY senza USE nel campo %d", dlg()); +#endif _browse->parse_display(scanner); return TRUE; } @@ -1666,13 +1699,17 @@ bool TEdit_field::parse_item(TScanner& scanner) { if (_browse) _browse->parse_output(scanner); else if (_sheet) _sheet->parse_output(scanner); +#ifdef DBG else return error_box("OUTPUT senza USE nel campo %d", dlg()); +#endif return TRUE; } if (scanner.key() == "AD") { +#ifdef DBG if(!_browse) return error_box("ADD senza USE nel campo %d", dlg()); +#endif _browse->parse_insert(scanner); return TRUE; } @@ -1681,12 +1718,16 @@ bool TEdit_field::parse_item(TScanner& scanner) { const char* n = scanner.pop(); _validate_func = isdigit(*n) ? atoi(n) : -1; +#ifdef DBG if (_validate_func < 0) return yesnofatal_box("Funzione di validazione '%s' errata nel campo %d", n, dlg()); +#endif const int _nparms = scanner.integer(); +#ifdef DBG if (_nparms < 0) return yesnofatal_box("Numero di parametri VALIDATE errato nel campo %d", dlg()); +#endif for(int i = 0; i < _nparms; i++) _validate_parms.add(scanner.operand()); @@ -1737,7 +1778,7 @@ void TEdit_field::create(WINDOW parent) #if XVT_OS == XVT_OS_WIN HWND hwnd = (HWND)get_value(win(), ATTR_NATIVE_WINDOW); - SendMessage(hwnd, EM_LIMITTEXT, _size, 0L); // Limita il testo + SendMessage(hwnd, EM_LIMITTEXT, _size, 0L); // Limita il testo long style = GetWindowLong(hwnd, GWL_STYLE); if (_flags.uppercase) style != ES_UPPERCASE; // Edit in maiuscolo SetWindowLong(hwnd, GWL_STYLE, style); diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 6697a0a50..ccddf74a0 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -115,7 +115,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, { const int NUMBER_WIDTH = 3; const int MAX_COL = 32; - int width[MAX_COL]; + int m_width[MAX_COL], v_width[MAX_COL]; init(); @@ -127,23 +127,31 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, for (const char* h = header.get(); h; h = header.get(), i++) { CHECKD(i < MAX_COL, "Tu meni calumns in scit: ", i); - int w; - char* at = strchr(h, '@'); - if (at) - { - w = atoi(at+1); - *at = '\0'; - } else w = strlen(h); - - width[i] = w+1; const int cid = FIRST_FIELD+i; // Column & Field ID const TMask_field* f = field(cid); // Field on mask CHECKD(f, "The spreadsheet mask needs ALSO field ", cid); - if (f->has_query()) w += 2; - tot_width += w; - new_header.add(h); + TString80 testa(h); + const int at = testa.find('@'); + int m, v; + if (at >= 0) + { + m = atoi(testa.mid(at+1)); + testa.cut(at); + v = max(at, m+(f->has_query() ? 1 : 0)); + } + else + { + m = testa.len(); + v = m+(f->has_query() ? 1 : 0); + } + + m_width[i] = m+1; // m = number of allowed chars + v_width[i] = v+1; // v = width of column + tot_width += v_width[i]; + + new_header.add(testa); } _columns = i; @@ -192,15 +200,13 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, { const int cid = FIRST_FIELD+i; // Column & Field ID const TMask_field* f = field(cid); // Field on mask - const int w = width[i] + (f->has_query() ? 2 : 0); // Column width long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL; if (f->class_id() == CLASS_REAL_FIELD) flags |= XI_ATR_RJUST; if (f->active()) flags |= XI_ATR_ENABLED; else _column_disabled.set(i); - coldef = xi_add_column_def(listdef, cid, - flags, cid, w, width[i], (char*)h); + coldef = xi_add_column_def(listdef, cid, flags, cid, v_width[i], m_width[i], (char*)h); coldef->v.column->heading_platform = TRUE; coldef->v.column->center_heading = TRUE; } @@ -363,14 +369,14 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev) case XIE_GET_FIRST: { const long max = items(); - if (max <= 0L) + if (max > 0L) { - xiev->refused = TRUE; - break; + long n = max * (long)xiev->v.rec_request.percent / 100L; + if (n < 0L) n = 0L; + xiev->v.rec_request.data_rec = n; } - long n = max * (long)xiev->v.rec_request.percent / 100L; - if (n < 0L) n = 0L; - xiev->v.rec_request.data_rec = n; + else + xiev->refused = TRUE; } break; case XIE_GET_LAST: @@ -617,10 +623,9 @@ break; } break; case K_ESC: - case K_CTRL+K_ENTER: { - const bool ok = (bool)xi_move_focus(_itf); - dispatch_e_char(parent(), k == K_ESC ? K_ESC : K_TAB); + xi_set_focus(_itf); + dispatch_e_char(parent(), K_ESC); } break; @@ -1030,10 +1035,10 @@ TToken_string& TSheet_field::row(int n) void TSheet_field::force_update(int r) { -#if XVTWS == WMWS - _sheet->open(); -#else +#if XVT_OS == XVT_OS_WIN _sheet->update(r); +#else + _sheet->open(); #endif } diff --git a/include/prassi.ver b/include/prassi.ver index 65855e643..a597294c5 100755 --- a/include/prassi.ver +++ b/include/prassi.ver @@ -1 +1 @@ -#define VERSION 1.5 +#define VERSION 1.7 diff --git a/include/real.cpp b/include/real.cpp index 397aeafd5..04cd73cb3 100755 --- a/include/real.cpp +++ b/include/real.cpp @@ -227,7 +227,7 @@ char *real ::literals () const __tmp_real = *this; __tmp_real.round (0); - TString r (__tmp_real.string (0, 0)); + TString80 r (__tmp_real.string (0, 0)); const bool negativo = r[0] == '-'; if (negativo) r.ltrim (1); @@ -235,7 +235,7 @@ char *real ::literals () const TFixed_string risultato (__string, 80); risultato.cut (0); - TString centinaia (16); + TString16 centinaia; for (int migliaia = 0;; migliaia++) { @@ -319,7 +319,7 @@ char *real ::points (int dec) const } -HIDDEN int get_picture_decimals (const TString & picture) +HIDDEN int get_picture_decimals (const TString& picture) { int decimali = 0; const int virgola = picture.find (','); @@ -344,8 +344,8 @@ char *real ::string (const char *picture) if (strcmp (picture, "LETTERE") == 0) return literals (); - TString v (string ()); - TString f (picture); + TString80 v (string()); + TString80 f (picture); const int voluti = get_picture_decimals (f); const int virgola = v.find ('.'); @@ -363,7 +363,7 @@ char *real ::string (const char *picture) if (strchr ("#@~", z)) { char c = v[j--]; - if (v[j] == '.') + if (j >= 0 && v[j] == '.') j--; if (z == '~') c = ' '; diff --git a/include/relapp.cpp b/include/relapp.cpp index 2fd07dc73..c6c7c5090 100755 --- a/include/relapp.cpp +++ b/include/relapp.cpp @@ -1,4 +1,4 @@ -// $Id: relapp.cpp,v 1.11 1994-09-22 07:48:03 guy Exp $ +// $Id: relapp.cpp,v 1.12 1994-10-03 08:47:24 guy Exp $ #include #include #include @@ -568,7 +568,6 @@ bool TRelation_application::save(bool check_dirty) } if (_mask->last_key() == K_ESC || _mask->last_key() == K_QUIT) { - _mask->get_mask_fields(); if (!_mask->check_fields()) // Exit with ESC didn't check values { _mask->first_focus(-_mask->fld(_mask->focus_field()).dlg()); diff --git a/include/relapp.h b/include/relapp.h index 62e051617..7bb159d05 100755 --- a/include/relapp.h +++ b/include/relapp.h @@ -9,7 +9,6 @@ #include #endif - #ifndef __MASK_H #include #endif @@ -20,7 +19,7 @@ class TRelation_application : public TApplication { TMask * _mask; TKey_array* _maskeys; - long _first, _last; + TRecnotype _first, _last; int _search_id; TString _autoins_caller; @@ -43,50 +42,65 @@ class TRelation_application : public TApplication virtual bool main_loop(); // Ciclo principale TMask_field* get_search_field() const; -protected: - TLocalisamfile& file() const { return get_relation()->lfile(); } - void set_fixed(); // Fissa i campi non modificabili - bool search_mode(); // Attiva la maschera di ricerca + bool autonum(TMask* m, bool rec); + void set_fixed(); // Fissa i campi non modificabili + bool search_mode(); // Attiva la maschera di ricerca void query_mode(bool pre_ins = FALSE); // Entra in modo ricerca - bool modify_mode(); // Entra in modo modifica + bool modify_mode(); // Entra in modo modifica void setkey(); bool lnflag() const { return _lnflag;} - long first() const { return _first;} - long last() const { return _first;} + bool has_filtered_cursor() const { return filtered() || force_cursor_usage();} + +protected: + TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione + TRecnotype first() const { return _first;} + TRecnotype last() const { return _first;} TMask& curr_mask() const { return *_mask; } const TString& autoins_caller() const { return _autoins_caller;} virtual bool menu(MENU_TAG m); - virtual bool user_create() pure; - virtual bool user_destroy() pure; - virtual TMask* get_mask(int mode) pure; - virtual bool changing_mask(int mode) pure; - virtual TRelation* get_relation() const pure; - virtual int read(TMask& m); - virtual int write(const TMask& m); - virtual int rewrite(const TMask& m); - virtual bool remove(); + virtual bool user_create() pure; // Inizializzazione dati utente + virtual bool user_destroy() pure; // Distruzione dati utente + + // La richiesta della maschera da utilizzare per ogni fase di lavoro (ricerca, inserimento, + // modifica avviene sempre in due tempi: changing_mask e get_mask. Cio' serve per gestire + // Correttamente le applicazioni con mashere multiple. La prima funzione serve a sapere se + // la futura get_mask ritornera' una maschera diversa dalla corrente. + virtual bool changing_mask(int mode) pure; + virtual TMask* get_mask(int mode) pure; // Richiede la maschera da usare + + virtual TRelation* get_relation() const pure; // Relazione da modificare + virtual int read(TMask& m); // Legge dalla relazione i valori nella maschera + virtual int write(const TMask& m); // Scrive sulla relazione i valori dalla maschera + virtual int rewrite(const TMask& m); // Riscrive sulla relazione i valori dalla maschera + virtual bool remove(); // Cancella il record corrente + + // Richiede una stringa nella forma CAMPO1|VALORE1|CAMPO2|VALORE2|...|CAMPOn|VALOREn + // contenente le coppie NUMERO_CAMPO_MASCHERA - VALORE_DA_ASSEGNARE che descrivono il + // prossimo codice libero da utilizzare per la autonumerazione. + // Nel caso di banale numerazione progressiva potrebbe essere implementata come + // return format("%d|%s", F_NUM, get_relation()->items()); virtual const char* get_next_key() { return ""; } + + // Richiede se il record corrente e' protetto (non cancellabile) virtual bool protected_record(TRectype&) { return FALSE; } - virtual void init_query_mode(TMask&) { } + + virtual void init_query_mode(TMask&) { } // Inizializza la maschera per il modo ricerca virtual void init_query_insert_mode(TMask& m) { init_query_mode(m); } - virtual void init_insert_mode(TMask&) { } - virtual void init_modify_mode(TMask&) { } + virtual void init_insert_mode(TMask&) { } // Inizializza la maschera per il modo inserimento + virtual void init_modify_mode(TMask&) { } // Inizializza la maschera per il modo modifica + + virtual bool force_cursor_usage() const { return FALSE;} virtual void write_enable(const bool on = TRUE) { get_relation()->write_enable(-1, on); } void write_disable() { write_enable(FALSE); } - bool autonum(TMask* m, bool rec); - void set_search_field(short id) { _search_id = id;} - bool has_filtered_cursor() const { return filtered() || force_cursor_usage();} + void set_search_field(short id) { _search_id = id;} // Impone il campo da utilizzare col bottone Ricerca public: TRelation_application(); virtual ~TRelation_application(); bool filtered() const { return _fixed.not_empty(); } - void set_first(long first) { _first = first;} - void set_last(long last) { _last = last;} bool find(byte key = 0); - virtual bool force_cursor_usage() const { return FALSE;} }; #endif diff --git a/include/sheet.cpp b/include/sheet.cpp index 5cab4457e..ae5c2f7e2 100755 --- a/include/sheet.cpp +++ b/include/sheet.cpp @@ -5,6 +5,7 @@ #include #include #include +#include TSheet::TSheet(short x, short y, short dx, short dy, const char* title, const char* head, byte buttons, @@ -26,10 +27,14 @@ TSheet::TSheet(short x, short y, short dx, short dy, const int et = item.find('@'); if (et >= 0) { - _size[_columns] = atoi(item.mid(et+1)); + const char t = item.right(1)[0]; + _type[_columns] = isalpha(t) ? toupper(t) : '\0'; + const int l = atoi(item.mid(et+1)); item.cut(et); - if (_columns == 0 && et == 0) - _checkable = _size[0] == 1; + if (_columns == 0 && et == 0 && l <= 1) + _checkable = _size[0] = 1; + else + _size[_columns] = l > 0 ? l : item.len(); } else _size[_columns] = item.len(); item.trim(); @@ -417,11 +422,26 @@ bool TSheet::update_row(long n) for (int j = 0; (s = t.get()) != NULL; x += _size[j++]+1) { int x1 = x; - if (n < 0) // Centra le testate - x1 += (_size[j]-strlen(s)) / 2; - else + if (n >= 0) + { if (_checkable && j == 0) s = _checked[n] ? "X" : " "; + + switch (_type[j]) + { + case 'R': + x1 += _size[j]-strlen(s); // Allinea a destra + break; + case 'M': + s = itor(atoi(s)); // Numeri romani + break; + default: + break; + } + } + else + x1 += (_size[j]-strlen(s)) >> 1; // Centra le testate + stringat(x1, y, s); } @@ -561,7 +581,7 @@ TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields, { TToken_string fldlst(fields); int campi = 0; - for (const char* t = fldlst.get(); t; t = fldlst.get(), campi++) + for (const char* t = fldlst.get(0); t; t = fldlst.get(), campi++) if (*t > ' ' && *t != '\"') { TFieldref fr(t, 0); @@ -685,9 +705,9 @@ bool TBrowse_sheet::on_key(KEY k) if (alnum || k == K_BACKSPACE || k == K_DEL) { const long oldsel = selected(); - const TString old(_field->get()); + const TString80 old(_field->get()); - TString val(old.size()+1); val = old; + TString80 val((const char*)old); if (alnum) { if (val.len() >= field().size()) @@ -739,7 +759,7 @@ void TBrowse_sheet::handler(WINDOW win, EVENT* ep) KEY TBrowse_sheet::run() { const bool spork = field().dirty(); // Store field status - const TString old(field().get()); + const TString80 old(field().get()); const KEY key = TCursor_sheet::run(); diff --git a/include/sheet.h b/include/sheet.h index 2300ab7e3..f774ef1c1 100755 --- a/include/sheet.h +++ b/include/sheet.h @@ -32,7 +32,7 @@ class TSheet : public TScroll_window TArray _page; byte _columns; - byte _size[MAX_COL]; + byte _size[MAX_COL], _type[MAX_COL]; long _curr, _last_update; short _visible_rows; diff --git a/include/strings.cpp b/include/strings.cpp index 89e17c0ae..0185eae43 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -236,45 +236,45 @@ int TString::find(const char* s, int from) const // Certified 99% -const char* TString::left(int count) const +const TString& TString::left(int count) const { spark.strncpy(_str, count); return spark; } // Certified 99% -const char* TString::right(int count) const +const TString& TString::right(int count) const { int from = len()-count; if (from < 0) from = 0; - spark = &_str[from]; + spark = _str + from; return spark; } -// Certified 90% -const char* TString::mid(int from, int count) const +// Certified 100% +const TString& TString::mid(int from, int count) const { const int l = len(); #ifdef DBG if (from < 0) { - error_box("Ivalid MID parameter: from = %d", from); + yesnofatal_box("Ivalid MID parameter: from = %d", from); from = 0; } #endif if (from > l) from = l; - if (count < 1) count = l-from; - + if (count < 0) count = l-from; + spark.strncpy(&_str[from],count); return spark; } -// Certified 100% (uses mid) -const char* TString::sub(int from, int to) const +// Certified 100% +const TString& TString::sub(int from, int to) const { const int count = to-from; return mid(from, count); @@ -283,9 +283,7 @@ const char* TString::sub(int from, int to) const // Certified 100% TString& TString::cut(int n) { - CHECKD(n >= 0, "Can't cut the string at ", n); - if (n <= size()) - _str[n] = '\0'; + _str[n] = '\0'; return *this; } @@ -404,7 +402,7 @@ TString& TString::picture(const char* pic, const char* s) for (int i = len()-1; i >= 0; i--) { const char k = pic[i]; - if (k == '#') _str[i] = (l >= 0) ? s[l--] : ' '; + if (k == '#') _str[i] = (l >= 0) ? s[l--] : ' '; else if (k == '~') { _str[i] = ' '; l--; } } @@ -465,9 +463,9 @@ TString& TString::insert(const char* s, int pos) { const int l = strlen(s); make_room(l); - mid(pos); // Scrivi in spark la stringa da pos in poi + mid(pos); // Scrivi in spark la stringa da pos in poi overwrite(s, pos); // Aggiungi s - strcpy(&_str[pos+l], spark); // Aggiungi spark + strcpy(&_str[pos+l], spark); // Aggiungi spark } return *this; } @@ -504,7 +502,8 @@ TFixed_string::~TFixed_string() void TFixed_string::resize(int size, bool) { #ifdef DBG - fatal_box("Impossibile ridimensionare una stringa fissa da %d a %d", _size, size); + fatal_box("Impossibile ridimensionare una stringa fissa da %d a %d caratteri:\n'%s'", + _size, size, _str); #endif } @@ -543,7 +542,7 @@ const char* TFilename::ext() const { const char* d = strrchr(name(), '.'); if (d && is_not_slash(*(++d))) return d; - return NULL; + return ""; } // Certified 90% @@ -569,33 +568,46 @@ const char* TFilename::name() const // Certified 70% -TString& TFilename::tempdir() +const TFilename& TFilename::tempdir() { const char* dirpref = getenv("TEMP"); if (dirpref == NULL) dirpref = getenv("TMP"); if (dirpref == NULL) dirpref = "/tmp"; - - if (!fexist(dirpref)) -#if XVT_OS==XVT_OS_SCOUNIX - mkdir(dirpref, 0777); -#else - mkdir(dirpref); -#endif - set(dirpref); + const int last = len()-1; + if (!is_not_slash(_str[last])) cut(last); + + if (!fexist(_str)) + { + int res = +#if XVT_OS==XVT_OS_SCOUNIX + mkdir(_str, 0777); +#else + mkdir(_str); +#endif + if (res == 0) + warning_box("E' stata creata la directory per i file temporanei '%s'", _str); + else + fatal_box("Impossibile creare la directory '%s' per i file temporanei", _str); + } return *this; } // Certified 50% -TString& TFilename::temp(const char* prefix) +const TFilename& TFilename::temp(const char* prefix) { - const TString dirpref(tempdir()); + const TFilename dirpref(tempdir()); char* t = NULL; + + TString16 est; if (prefix) { set(prefix); + est = ext(); // Memorizza eventuale estensione + if (est.not_empty()) ext(""); // Toglie " " + strip("$#"); t = tempnam((char*)(const char*)dirpref, (char*)_str); set(t); @@ -619,6 +631,13 @@ TString& TFilename::temp(const char* prefix) set(t); } + if (est.not_empty()) ext(est); // Ripristina estensione + else + { + const char* const e = ext(); + if (e == NULL || *e == '\0') // Aggiunge estensione + ext("tmp"); + } if (t) free(t); return *this; @@ -727,14 +746,14 @@ const char* TToken_string::get(int n) // Certified 99% char TToken_string::get_char(int n) { - const char* num = get(n); - return num ? *num : '\0'; + const char* const car = get(n); + return car ? *car : '\0'; } // Certified 99% int TToken_string::get_int(int n) { - const char* num = get(n); + const char* const num = get(n); return num ? atoi(num) : 0; } @@ -742,7 +761,7 @@ int TToken_string::get_int(int n) // Certified 99% long TToken_string::get_long(int n) { - const char* num = get(n); + const char* const num = get(n); return num ? atol(num) : 0L; } @@ -764,7 +783,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; @@ -877,7 +896,7 @@ void TToken_string::destroy(int n) TParagraph_string::TParagraph_string(const char* s, int width) : TToken_string(s, '|'), _width(width) -{ tokenize(); } +{ tokenize(); } const TString& TParagraph_string::operator =(const char* s) { diff --git a/include/strings.h b/include/strings.h index 3db2d9e29..8290576f9 100755 --- a/include/strings.h +++ b/include/strings.h @@ -72,10 +72,10 @@ public: int find(char, int from = 0) const; // Ritorna la posizione del carattere char nell'oggetto TString int find(const char* s, int from = 0) const; // Ritorna la posizione della stringa s nell'oggetto TString - const char* left(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da sinistra - const char* mid(int from, int count = -1) const; // Ritorna l'oggetto TString composto dai count caratteri a partire da from - const char* sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso) - const char* right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra + const TString& left(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da sinistra + const TString& mid(int from, int count = -1) const; // Ritorna l'oggetto TString composto dai count caratteri a partire da from + const TString& sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso) + const TString& right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra /////////////////////////////////////////////////////////// // @DES Modifying methods @@ -188,15 +188,15 @@ public: // @C -// Classe TFilename : public TString +// Classe TFilename : public TString80 (256 su Windows'95) // @END -class TFilename : public TString +class TFilename : public TString80 { public: // @FPUB - TFilename(const char* n = "") : TString(24) { set(n); } + TFilename(const char* n = "") : TString80(n) {} const TString& operator =(const char* s) { return set(s); } // assegnazione tra TFile e stringa @@ -205,8 +205,8 @@ public: void ext(const char*); // Imposta come estensione la stringa puntata da char* const char* name() const; // Ritorna il nome del file - TString& temp(const char* prefix = NULL); // Genera il nome di un file temporaneo - TString& tempdir(); // Genera il nome della directory temporanea + const TFilename& temp(const char* prefix = NULL); // Genera il nome di un file temporaneo + const TFilename& tempdir(); // Genera il nome della directory temporanea }; // @C diff --git a/include/xvtility.cpp b/include/xvtility.cpp index 9cbf66b66..d5cf08cb9 100755 --- a/include/xvtility.cpp +++ b/include/xvtility.cpp @@ -5,19 +5,18 @@ #include #if XVT_OS == XVT_OS_SCOUNIX -extern "C" {long nap(long period);} +extern "C" { long nap(long period); } #endif - +#ifdef DBG // FATAL_HOOK che intercetta errori fatali XVT // put breakpoint here void fatal_hook() { -#ifdef DBG int dummy = 0; dummy++; -#endif } +#endif #if XVTWS == WMWS @@ -38,6 +37,9 @@ COLOR FOCUS_BACK_COLOR = COLOR_WHITE; #include +#ifdef __CTL3D__ +#include +#endif HIDDEN COLORREF COLOR2RGB(COLOR c) { @@ -73,15 +75,20 @@ HIDDEN LOGFONT NormalLogFont = 0, 0, 300, FALSE, FALSE, FALSE, OEM_CHARSET, - OUT_CHARACTER_PRECIS, - CLIP_DEFAULT_PRECIS, + OUT_TT_PRECIS, + CLIP_STROKE_PRECIS, PROOF_QUALITY, - VARIABLE_PITCH | FF_SWISS, - NULL + FIXED_PITCH | FF_ROMAN, + (LPSTR)"Times New Roman" }; HIDDEN HFONT NormalFont = CreateFontIndirect(&NormalLogFont); +#ifdef __CTL3D__ +COLOR MASK_BACK_COLOR = COLOR_LTGRAY; +#else COLOR MASK_BACK_COLOR = MAKE_COLOR(0,128,128); +#endif + COLOR NORMAL_COLOR = COLOR_BLACK; COLOR NORMAL_BACK_COLOR = COLOR_LTGRAY; COLOR DISABLED_COLOR = COLOR_GRAY; @@ -90,8 +97,8 @@ COLOR DISABLED_BACK_COLOR = MASK_BACK_COLOR; HIDDEN COLORREF MaskColor = COLOR2RGB(MASK_BACK_COLOR); HIDDEN HBRUSH MaskBrush = CreateSolidBrush(MaskColor); -HIDDEN COLORREF FocusForeColor = COLOR2RGB(COLOR_BLACK); // GetSysColor(COLOR_HIGHLIGHTTEXT); -HIDDEN COLORREF FocusBackColor = COLOR2RGB(COLOR_CYAN); // GetSysColor(COLOR_HIGHLIGHT); +HIDDEN COLORREF FocusForeColor = COLOR2RGB(COLOR_BLACK); +HIDDEN COLORREF FocusBackColor = COLOR2RGB(COLOR_CYAN); HIDDEN HBRUSH FocusBrush = CreateSolidBrush(FocusBackColor); COLOR FOCUS_COLOR = RGB2COLOR(FocusForeColor); @@ -101,18 +108,26 @@ HIDDEN COLORREF NormalForeColor = COLOR2RGB(NORMAL_COLOR); HIDDEN COLORREF NormalBackColor = COLOR2RGB(NORMAL_BACK_COLOR); HIDDEN HBRUSH NormalBrush = CreateSolidBrush(NormalBackColor); -HIDDEN BOOLEAN event_hook(HWND hwnd, +static BOOLEAN event_hook(HWND hwnd, UINT msg, UINT wparam, ULONG lparam, long* ret) { switch(msg) - { + { +#ifdef __CTL3D__ + case WM_SYSCOLORCHANGE: + Ctl3dColorChange(); + break; +#endif case WM_CTLCOLOR: { +#ifdef __CTL3D__ + *ret = Ctl3dCtlColorEx(msg, wparam, lparam); + return TRUE; +#else const word type = HIWORD(lparam); - if (type == CTLCOLOR_LISTBOX || type == CTLCOLOR_EDIT || type == CTLCOLOR_MSGBOX) { @@ -139,64 +154,83 @@ HIDDEN BOOLEAN event_hook(HWND hwnd, *ret = focus ? FocusBrush : NormalBrush; return TRUE; } +#endif } - break; - case WM_COMMAND: -{ - const word notify = HIWORD(lparam); - if (notify == EN_KILLFOCUS || notify == EN_SETFOCUS) + break; + case WM_COMMAND: { - HWND hwnd = LOWORD(lparam); // Ridisegna BENE il campo - InvalidateRect(hwnd, NULL, TRUE); - } -} -break; - case WM_KEYDOWN: - if (wparam == VK_PRIOR || wparam == VK_NEXT || - wparam == VK_UP || wparam == VK_DOWN ) -{ - char name[16]; - GetClassName(hwnd, name, 5); - if (stricmp(name, "Edit") == 0) - { - KEY key; - switch(wparam) + const word notify = HIWORD(lparam); + if (notify == EN_KILLFOCUS || notify == EN_SETFOCUS) { - case VK_PRIOR: - key = K_PREV; break; - case VK_NEXT: - key = K_NEXT; break; - case VK_UP: - key = K_UP; break; - case VK_DOWN: - key = K_DOWN; break; - default: - key = 0; break; + HWND hwnd = LOWORD(lparam); // Ridisegna BENE il campo + InvalidateRect(hwnd, NULL, TRUE); } - if (key > 0) + } + break; + case WM_KEYDOWN: + if (wparam == VK_PRIOR || wparam == VK_NEXT || + wparam == VK_UP || wparam == VK_DOWN ) { - WINDOW w = cur_win(); - if (w != NULL_WIN) - dispatch_e_char(w, key); - } - } -} -break; - case WM_MENUCHAR: -{ - WINDOW w = cur_win(); - if (w != NULL_WIN) - { - const KEY key = toupper(wparam)+K_CTRL; - dispatch_e_char(w, key); - } -} -break; -default: -break; -} + char name[16]; + GetClassName(hwnd, name, 5); + if (stricmp(name, "Edit") == 0) + { + KEY key; + switch(wparam) + { + case VK_PRIOR: + key = K_PREV; break; + case VK_NEXT: + key = K_NEXT; break; + case VK_UP: + key = K_UP; break; + case VK_DOWN: + key = K_DOWN; break; + default: + key = 0; break; + } + if (key > 0) + { + WINDOW w = cur_win(); + if (w != NULL_WIN) + dispatch_e_char(w, key); + } + } + } + break; + case WM_MENUCHAR: + { + WINDOW w = cur_win(); + if (w != NULL_WIN) + { + const KEY key = toupper(wparam)+K_CTRL; + dispatch_e_char(w, key); + } + } + break; + default: + break; + } -return FALSE; + return FALSE; +} + + +HIDDEN WIN_TYPE _wc_type = W_NONE; + +static void createwindow_hook(DWORD* exstyle, LPCSTR* classname, LPCSTR* windowname, DWORD* styl, + int* x, int* y, int* width, int* height, HWND* parent, HMENU* menu, + HINSTANCE inst, void **) +{ + if (_wc_type == WC_EDIT) + { + *y++; + } else + if (_wc_type == WC_GROUPBOX) + { + *classname = "Static"; + } + _wc_type = W_NONE; } #endif @@ -460,13 +494,24 @@ void customize_controls(bool on) #if XVT_OS == XVT_OS_WIN if (on) { - const long style = WSF_ICONIZABLE | WSF_SIZE | WSF_CLOSE | WSF_MAXIMIZED; - set_value(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, style); + const long taskwin_style = WSF_ICONIZABLE | WSF_SIZE | WSF_CLOSE | WSF_MAXIMIZED; + set_value(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, taskwin_style); set_value(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE); set_value(NULL_WIN,ATTR_EVENT_HOOK, (long)event_hook); + +#ifdef __CTL3D__ + set_value(NULL_WIN,ATTR_WIN_CREATEWINDOW_HOOK, (long)createwindow_hook); + HINSTANCE _hInstance = (HINSTANCE)get_value(NULL_WIN, ATTR_WIN_INSTANCE); + Ctl3dRegister(_hInstance); + Ctl3dAutoSubclass(_hInstance); +#endif } else { +#ifdef __CTL3D__ + HINSTANCE _hInstance = (HINSTANCE)get_value(NULL_WIN, ATTR_WIN_INSTANCE); + Ctl3dUnregister(_hInstance); +#endif DeleteObject(NormalFont); DeleteObject(MaskBrush); DeleteObject(NormalBrush); @@ -474,15 +519,16 @@ void customize_controls(bool on) free_controls_bmp(); } #endif - - if (on) set_value(NULL_WIN,ATTR_FATAL_ERR_HANDLER, (long)fatal_hook); +#ifdef DBG + if (on) set_value(NULL_WIN,ATTR_FATAL_ERR_HANDLER, (long)fatal_hook); +#endif } void xvt_set_font(WINDOW win, int family, int style, int dim) { - CHECK(win > 0, "Can't set the font in a NULL window"); + CHECK(win != NULL_WIN, "Can't set the font in a NULL window"); #if XVT_OS == XVT_OS_WIN @@ -552,6 +598,13 @@ WINDOW xvt_create_control(WIN_TYPE wt, WINDOW win = NULL_WIN; #if XVT_OS == XVT_OS_WIN + _wc_type = wt; + + if (wt == WC_PUSHBUTTON) + win = xvt_create_pushbutton(r.left, r.top, r.right, r.bottom, + caption, parent, flags, app_data, id); + +#ifndef __CTL3D__ if (wt == WC_CHECKBOX) win = xvt_create_checkbox(r.left, r.top, r.right, r.bottom, caption, parent, flags, app_data, id); @@ -560,10 +613,6 @@ WINDOW xvt_create_control(WIN_TYPE wt, win = xvt_create_radiobutton(r.left, r.top, r.right, r.bottom, caption, parent, flags, app_data, id); - if (wt == WC_PUSHBUTTON) - win = xvt_create_pushbutton(r.left, r.top, r.right, r.bottom, - caption, parent, flags, app_data, id); - if (wt == WC_GROUPBOX) { win = xvt_create_groupbox(r.left, r.top, r.right, r.bottom, @@ -575,7 +624,8 @@ WINDOW xvt_create_control(WIN_TYPE wt, win = xvt_create_text(r.left, r.top, r.right, r.bottom, caption, parent, flags, app_data, id); } - +#endif + #endif if (win == NULL_WIN) @@ -598,11 +648,18 @@ WINDOW xvt_create_control(WIN_TYPE wt, #endif #if XVT_OS == XVT_OS_WIN - if (wt == WC_EDIT || wt == WC_LISTBUTTON) - { - HWND hwnd = (HWND)get_value(win, ATTR_NATIVE_WINDOW); - SendMessage(hwnd, WM_SETFONT, NormalFont, TRUE); - } +#ifdef __CTL3D__ + if (wt != WC_PUSHBUTTON) +#else + if (wt == WC_EDIT || wt == WC_LISTBUTTON) +#endif + { + HWND hwnd = (HWND)get_value(win, ATTR_NATIVE_WINDOW); + SendMessage(hwnd, WM_SETFONT, NormalFont, TRUE); +#ifdef __CTL3D__ + Ctl3dSubclassCtl(hwnd); +#endif + } #endif return win; @@ -611,7 +668,7 @@ WINDOW xvt_create_control(WIN_TYPE wt, const char* xvt_get_title(WINDOW win) { -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN && !defined(__CTL3D__) TControl* c = TControl::WINDOW2TControl(win); return c->caption(); #else @@ -623,7 +680,7 @@ const char* xvt_get_title(WINDOW win) void xvt_set_front_control(WINDOW win) { -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN && !defined(__CTL3D__) TControl* c = TControl::WINDOW2TControl(win); c->focus(TRUE); #endif @@ -633,7 +690,7 @@ void xvt_set_front_control(WINDOW win) void xvt_enable_control(WINDOW win, bool on) { -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN && !defined(__CTL3D__) TControl* c = TControl::WINDOW2TControl(win); c->enable(on); #else @@ -644,7 +701,7 @@ void xvt_enable_control(WINDOW win, bool on) void xvt_check_box(WINDOW win, bool on) { -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN && !defined(__CTL3D__) TControl* c = (TControl*)TControl::WINDOW2TControl(win); c->check(on); #else @@ -655,18 +712,18 @@ void xvt_check_box(WINDOW win, bool on) bool xvt_get_checked_state(WINDOW win) { -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN && !defined(__CTL3D__) TControl* c = TControl::WINDOW2TControl(win); return c->checked(); #else - return get_checked_state(win); + return get_checked_state(win) ? TRUE : FALSE; #endif } void xvt_check_radio_button(WINDOW win, const WINDOW* ctls, int count) { -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN && !defined(__CTL3D__) for (int i = 0; i < count; i++) xvt_check_box(ctls[i], ctls[i] == win); #else @@ -693,7 +750,7 @@ int xvt_get_checked_radio(const WINDOW* ctls, int count) /////////////////////////////////////////////////////////// HIDDEN WINDOW statbar = NULL_WIN; -HIDDEN TString80 stattext; +HIDDEN TString256 stattext; WINDOW xvt_create_statbar() { @@ -749,8 +806,6 @@ void xvt_statbar_refresh() HIDDEN bool test_menu_tag(MENU_ITEM* mi, MENU_TAG tag) { - CHECK(mi, "Can't test NULL MENU_ITEM"); - while (mi->tag) { if (mi->tag == tag) return TRUE;