Eliminate dipendenze dal sistema operativo tramite os_dep.h

git-svn-id: svn://10.65.10.50/trunk@6251 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-02-24 10:37:28 +00:00
parent 10b448f7fc
commit 369bde9243
65 changed files with 596 additions and 1857 deletions

View File

@ -1,13 +1,3 @@
#include <stdlib.h>
#define STRICT
#define XVT_INCL_NATIVE
#include <xvt.h>
#if XVT_OS == XVT_OS_WIN
#include <toolhelp.h>
#endif
#include <applicat.h>
#include <colors.h>
#include <config.h>
@ -17,23 +7,21 @@
#include <extcdecl.h>
#include <mask.h>
#include <modaut.h>
#include <os_dep.h>
#include <prefix.h>
#include <printer.h>
#include <relation.h>
#include <urldefid.h>
#include <utility.h>
#include <xvtility.h>
#include <bagn002.h>
// #define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
///////////////////////////////////////////////////////////
// Metodi di accesso globali all'applicazione corrente
///////////////////////////////////////////////////////////
HIDDEN TApplication* _application = NULL;
HIDDEN BOOL _xvt_running = FALSE;
HIDDEN bool _xvt_running = FALSE;
// @doc EXTERNAL
@ -239,14 +227,12 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep)
message_box("Attach to process %d ...", getpid());
#endif
do_events();
allow_another_instance();
os_allow_another_instance();
}
break;
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
case E_UPDATE:
backdrop_eh(win, ep);
break;
#endif
default:
break;
}
@ -254,6 +240,11 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep)
return _application->handler(win, ep);
}
void TApplication::dispatch_e_menu(MENU_TAG tag)
{
::dispatch_e_menu(TASK_WIN, tag);
}
long TApplication::handler(WINDOW win, EVENT* ep)
{
switch (ep->type)
@ -267,9 +258,7 @@ long TApplication::handler(WINDOW win, EVENT* ep)
{
on_firm_change();
on_config_change();
#if XVT_OS == XVT_OS_SCOUNIX
do_events();
#endif
}
else
stop_run();
@ -300,23 +289,7 @@ long TApplication::handler(WINDOW win, EVENT* ep)
case M_HELP_CONTENTS:
case M_HELP_SEARCH:
case M_HELP_HELPONHELP:
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (fexist("prassi.hlp"))
{
TFilename hlp("prassi.hlp");
TString mod(main_app().name());
mod.cut(2); mod.lower();
if (mod != "ba") hlp.insert(mod, 0);
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
switch(ep->v.cmd.tag)
{
case M_HELP_CONTENTS: WinHelp(hwnd, hlp, HELP_CONTENTS, 0); break;
case M_HELP_SEARCH: WinHelp(hwnd, hlp, HELP_PARTIALKEY, (DWORD)""); break;
case M_HELP_HELPONHELP: WinHelp(hwnd, hlp, HELP_HELPONHELP, 0); break;
default: break;
}
}
#endif
os_exec_help_command(ep->v.cmd.tag);
break;
default:
if (ep->v.cmd.tag > MAX_MENU_TAG)
@ -430,27 +403,9 @@ bool TApplication::destroy()
return TRUE;
}
HIDDEN void wake_up_caller()
{
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
#if XVT_OS == XVT_OS_WIN
const HTASK ht = GetCurrentTask();
#else
const HANDLE ht = GetCurrentProcess();
#endif
// SendMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L);
PostMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L);
HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, "prassi.hlp", HELP_QUIT, 0L);
do_events();
}
void TApplication::terminate()
{
wake_up_caller();
os_wake_up_caller();
close_all_dialogs();
@ -715,16 +670,6 @@ void TApplication::enable_menu_item(
xvt_menu_update(TASK_WIN);
}
void TApplication::dispatch_e_menu(MENU_TAG item)
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
HWND w = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
PostMessage(w, WM_COMMAND, item, 0L);
#else
::dispatch_e_menu(TASK_WIN, item);
#endif
}
// @cmember Setta il cursore a clessidra (To be removed soon)
void TApplication::begin_wait()
{
@ -784,7 +729,7 @@ bool TApplication::set_firm(long newfirm)
const int tipodir = mask.get_int(F_TIPO);
if (tipodir == 0 && !prefix().exist(newfirm) &&
!build_firm_data(newfirm))
!prefix().build_firm_data(newfirm))
return FALSE;
if (tipodir > 0)
{
@ -902,34 +847,14 @@ bool TApplication::firm_change_enabled() const
// @comm Praticamente controlla se e' stato lanciato da ba0 o dal program manager
{
#ifdef _DEMO_
return FALSE;
#else
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
static bool can = 2;
if (can == 2)
{
#if XVT_OS == XVT_OS_WIN
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
HTASK ct = GetCurrentTask();
TaskFindHandle(&te, ct);
TaskFindHandle(&te, te.hTaskParent);
can = stricmp(te.szModule, "BA0") == 0 ||
#ifdef DBG
stricmp(te.szModule, "CVW4") == 0 ||
stricmp(te.szModule, "MSVC") == 0 ||
#endif
stricmp(te.szModule, "Explorer") == 0 ||
stricmp(te.szModule, "PROGMAN") == 0;
#ifdef _DEMO_
can FALSE;
#else
can = TRUE;
can = os_spawn_by_menu();
#endif
}
return can;
#else
return TRUE;
#endif
#endif
}
void TApplication::on_firm_change()
@ -948,9 +873,10 @@ bool TSkeleton_application::create()
return TRUE;
}
bool TSkeleton_application::menu(MENU_TAG)
bool TSkeleton_application::menu(MENU_TAG tag)
{
main_loop();
if (tag == BAR_ITEM(1))
main_loop();
return FALSE;
}

View File

@ -51,8 +51,6 @@ class TApplication
long _savefirm;
// @cmember:(INTERNAL) Indica se l'applicazione e' stata creata con successo
bool _create_ok;
// @cmember:(INTERNAL) Handle del modulo del programma di cui si sta attendendo la fine
word _waiting;
// @cmember:(INTERNAL) Termine dell'applicazione
void terminate();
@ -87,9 +85,6 @@ protected:
// @cmember Controlla il menu'
virtual bool menu(MENU_TAG)
{ return TRUE; }
// @cmember Chiamata ogni volta che viene cambiata una ditta
virtual bool build_firm_data(long cod, bool flagcom = FALSE)
{ return TRUE;}
// @cmember Rimuove l'applicazione
virtual bool destroy();
@ -176,16 +171,6 @@ public:
// @cmember Ritorna la directory in cui si trovano i dati della ditta corrente
const char* get_firm_dir() const;
// @cmember Attende la fine del modulo con handle <p taskid>
void wait_for(word taskid)
{ _waiting = taskid; }
// @cmember Interrompe lo stato di attesa
void wake_up()
{ _waiting = 0xFFFF; }
// @cmember Ritorna l'handle del task di cui l'applicazione e' in attesa
word waiting() const
{ return _waiting; }
// @cmember Setta il cursore a clessidra
void begin_wait();
// @cmember Setta il cursore standard

View File

@ -17,7 +17,6 @@
// TProgress_win declaration
///////////////////////////////////////////////////////////
class TProgress_win : public TMask
{
ALWindowsMessage* _monitor;
@ -70,7 +69,7 @@ FILE* TArchive::ask_disk(
disk, floppy, disk-1);
if (!ok) return NULL;
}
} while (fexist(prev)); // Non facciamo i furbetti!
} while (prev.exist()); // Non facciamo i furbetti!
name.ext(format("%03d", disk)); // File attuale
@ -218,7 +217,7 @@ bool TArchive::fsplit(
TFilename parag(work.name()); parag.ext("");
TFilename ini("a:/backup.ini"); ini[0] = floppy;
if (fexist(ini))
if (ini.exist())
{
TConfig c(ini, parag);
const int d = c.get_int("Disk");
@ -550,7 +549,7 @@ void TArchive::stop_job()
///////////////////////////////////////////////////////////
TProgress_win::TProgress_win(const char* title, TArchive* arc)
: TMask(title, 1, 60, 6), _arc(arc)
: TMask(title, 1, 60, 6), _arc(arc), _monitor(NULL)
{
RCT rct;
xvt_rect_set(&rct, CHARX, CHARY, 58*CHARX, 5*CHARY/2);

View File

@ -1,6 +1,5 @@
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
#include <strings.h>
@ -283,6 +282,28 @@ bool TArray::ok() const
return(size() != 0 && (_data != NULL));
}
#ifdef DBG
TObject& TArray::operator[] (int index) const
{
TObject* o = objptr(index);
if (o == NULL)
{
NFCHECK("Can't access NULL array item %d of %d", index, _size);
if (index >= 0)
{
const int f = first();
if (f >= 0)
{
o = objptr(f)->dup();
((TArray*)this)->add(o, index);
}
}
CHECK(o, "Unrecoverable array access error");
}
return *o;
}
#endif
// @doc EXTERNAL
// @mfunc Aggiunge un oggetto ad un array.

View File

@ -196,15 +196,12 @@ inline TObject* TArray::objptr(int index) const
return (index < _size && index >= 0) ? _data[index] : NULL;
}
#ifndef DBG
inline TObject& TArray::operator[] (int index) const
{
TObject* o = objptr(index);
#ifdef DBG
if (o == NULL)
fatal_box("Can't access NULL array item: %d of %d", index, size());
#endif
return *o;
return *objptr(index);
}
#endif
class TPointer_array : public TArray
{

View File

@ -283,7 +283,7 @@ TObject* TAssoc_array::get()
return NULL;
}
THash_object* o = (THash_object*)arr->objptr(_col++);
return (o == NULL || o->_obj == NULL) ? &error : o->_obj;
return (o == NULL || o->_obj == NULL) ? &error_object : o->_obj;
}
// @doc EXTERNAL

View File

@ -5,7 +5,7 @@
// TBrowse_application
///////////////////////////////////////////////////////////
bool TBrowse_application::main_loop()
void TBrowse_application::main_loop()
{
long recins = -1;
@ -104,5 +104,4 @@ bool TBrowse_application::main_loop()
msg.send();
}
}
return k != K_QUIT;
}

View File

@ -18,7 +18,7 @@ class TBrowse_application : public TRelation_application
// @access Protected Member
protected:
// @cmember:(INTERNAL) Ciclo principale
virtual bool main_loop();
virtual void main_loop();
// @access Public Member
public:

View File

@ -14,6 +14,7 @@
#define LPCSTR const LPSTR
int WINAPI GetPrivateProfileString(LPCSTR, LPCSTR, LPCSTR, LPSTR, int, LPCSTR);
int WINAPI WritePrivateProfileString(LPCSTR, LPCSTR, LPCSTR, LPCSTR);
#define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3
#define DRIVE_REMOTE 4
@ -25,9 +26,9 @@ int hashfun(const char *);
void setdec(char *, int);
const char* prefname();
HIDDEN BOOLEAN pathpread = FALSE;
HIDDEN BOOLEAN pathpread = 0;
BOOLEAN dispferr = TRUE;
BOOLEAN dispferr = 1;
int dirfl[2] = {0, 0}, recfl[2] = {0, 0} ;
PathSt __ptprf = "";
@ -534,7 +535,7 @@ const char* CGetPref()
if (!pathpread)
{
FILE* f = fopen("pathpref.ini", "r");
pathpread = TRUE;
pathpread = 1;
if (f != NULL)
{
if (fgets(__ptprf, 42, f) != NULL)

View File

@ -181,6 +181,18 @@ int yesno_box(
#endif
}
int noyes_box(const char* fmt, ...)
{
buildmsg();
MessageBeep(MB_ICONQUESTION);
int r = MessageBox(GetFocus(), msg, "RICHIESTA",
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
return r == IDYES;
}
// @doc EXTERNAL
// @msg yesnofatal_box | Crea una finestra di RICHIESTA con il relativo

View File

@ -10,6 +10,7 @@ extern "C" {
int error_box(const char* fmt, ...);
int fatal_box(const char* fmt, ...);
int yesno_box(const char* fmt, ...);
int noyes_box(const char* fmt, ...);
int yesnocancel_box(const char* fmt, ...);
int yesnofatal_box(const char* fmt, ...);
int __trace(const char* fmt, ...);

View File

@ -1,12 +1,6 @@
#define XVT_INCL_NATIVE
#define STRICT
#include <os_dep.h>
#include <colors.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <commdlg.h>
#endif
COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue)
{
COLOR def = MAKE_COLOR(red, green, blue);
@ -35,65 +29,5 @@ COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue)
COLOR choose_color(COLOR col, WINDOW win)
{
int ok = FALSE;
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
CHOOSECOLOR cc;
memset(&cc, 0, sizeof(cc)); // Azzera struttura
if (win == NULL_WIN) win = TASK_WIN; // Sceglie una finestra valida
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
HDC hdc = GetDC(hwnd);
// Legge la palette di sistema
PALETTEENTRY* pe = NULL;
int max_entries = 0;
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
{
max_entries = GetDeviceCaps(hdc, SIZEPALETTE);
pe = new PALETTEENTRY[max_entries];
GetSystemPaletteEntries(hdc, 0, max_entries, pe);
}
ReleaseDC(hwnd, hdc);
// Definisce i 16 colori customizzabili
unsigned long custom_colors[16];
for (int c = 0; c < 16; c++)
{
if (pe)
{
const PALETTEENTRY& e = pe[c < 8 ? c : max_entries - 16 + c];
custom_colors[c] = RGB(e.peRed, e.peGreen, e.peBlue);
}
else
{
const unsigned char val = (c & 0x8) ? 255 : 127;
const unsigned char red = (c & 0x1) ? val : 0;
const unsigned char green = (c & 0x2) ? val : 0;
const unsigned char blue = (c & 0x4) ? val : 0;
custom_colors[c] = RGB(red, green, blue);
}
}
if (pe)
{
delete pe;
pe = NULL;
}
cc.lStructSize = sizeof(cc); // Setta dimensioni
cc.hwndOwner = hwnd; // Setta finestra padre
cc.rgbResult = RGB(XVT_COLOR_GET_RED(c), XVT_COLOR_GET_GREEN(c), XVT_COLOR_GET_BLUE(c));
cc.lpCustColors = custom_colors; // Fissa colori custom
cc.Flags = CC_RGBINIT; // Usa col come primo colore
ok = ChooseColor(&cc) != 0;
#endif
if (ok)
col = RGB2COLOR(GetRValue(cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult));
else
col = COLOR_INVALID;
return col;
}
return os_choose_color(col, win);
}

View File

@ -1,6 +1,6 @@
#include <time.h>
#define XVT_INCL_NATIVE
#include <applicat.h>
#include <colors.h>
#include <config.h>
#include <scanner.h>
@ -559,9 +559,7 @@ void TConfig::init(
if (_paragraph.blank())
{
TFilename name;
HINSTANCE HInstance = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE);
GetModuleFileName(HInstance, name.get_buffer(), name.size());
TFilename name = main_app().argv(0);
_paragraph = name.name();
_paragraph.cut(2);
_paragraph.lower();

View File

@ -1,8 +1,3 @@
#if XVT_OS == XVT_OS_WIN || XVT_OS_WIN32
#define STRICT
#define XVT_INCL_NATIVE
#endif
#define XI_INTERNAL
#include <xinclude.h>
@ -10,6 +5,7 @@
#include <config.h>
#include <controls.h>
#include <mask.h>
#include <os_dep.h>
#include <urldefid.h>
#include <statbar.h>
@ -164,26 +160,27 @@ XVT_FNTID xvt_default_font(bool bold)
xvt_font_set_style(FAT_FONT, XVT_FS_BOLD);
xvt_font_map_using_default(FAT_FONT);
CHECK(xvt_font_is_mapped(FAT_FONT), "Can't map native font");
// Get true text size
#if XVT_OS == XVT_OS_WIN || XVT_OS_WIN32
TEXTMETRIC tm;
HDC hdc = (HDC)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_GRAPHIC_CONTEXT);
GetTextMetrics(hdc, &tm);
// Compute true text size
RCT pc; xvt_vobj_get_client_rect(TASK_WIN, &pc);
ROWY = (pc.bottom - pc.top) / 23;
const int COLX = (pc.right - pc.left) / 80;
CHARX = tm.tmAveCharWidth+1;
if (CHARX > COLX)
CHARX = COLX;
const int MAX_CHARX = (pc.right - pc.left) / 80;
TString str(80, 'M');
CHARX = xvt_dwin_get_text_width(TASK_WIN, str.get_buffer(), str.size()) / str.size();
int leading, ascent, descent;
xvt_dwin_get_font_metrics(TASK_WIN, &leading, &ascent, &descent);
CHARY = ascent + descent;
BASEY = ascent;
if (CHARX > MAX_CHARX)
CHARX = MAX_CHARX;
CHARY = tm.tmHeight;
BASEY = tm.tmAscent;
if (CHARY > ROWY-2)
CHARY = ROWY-2;
#endif
}
return bold ? FAT_FONT : DEF_FONT;
@ -976,8 +973,8 @@ void TControl::change_attrib(unsigned long mask, bool on, XI_OBJ* obj)
return;
}
}
// Usa tranquillamente il metodo ortodosso
#endif
// Usa tranquillamente il metodo ortodosso
xi_set_attrib(obj, attr);
}
}
@ -1426,7 +1423,7 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid,
short left, short top, short width, short height,
const char* flags, const char* text,
short bmp_up, short bmp_dn)
: _bmp_up(bmp_up), _bmp_dn(bmp_dn), _hicon(0)
: _bmp_up(bmp_up), _bmp_dn(bmp_dn), _native_hicon(0)
{
bool bold;
@ -1448,21 +1445,38 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid,
}
TPushbutton_control::~TPushbutton_control()
{
if (_hicon)
DestroyIcon((HICON)_hicon);
{
if (_native_hicon)
os_destroy_native_icon(_native_hicon);
}
void TPushbutton_control::set_icon(word hicon)
const char* TPushbutton_control::caption() const
{
if (_hicon)
return _caption;
}
void TPushbutton_control::set_caption(const char* c)
{
bool bold;
COLOR color;
_caption = parse_caption(c, bold, color);
if (_caption.not_empty())
{
DestroyIcon((HICON)_hicon);
_hicon = NULL;
set_native_icon(0);
set_bmp(0, 0);
}
}
void TPushbutton_control::set_native_icon(unsigned hicon)
{
if (_native_hicon)
{
os_destroy_native_icon(_native_hicon);
_native_hicon = 0;
}
if (hicon)
{
_hicon = hicon;
_native_hicon = hicon;
set_bmp(0, 0);
}
}
@ -1476,7 +1490,7 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
_picture->add(_bmp_dn = bmp_dn);
else
_bmp_dn = _bmp_up;
set_icon(NULL);
set_native_icon(0);
}
else
{
@ -1491,13 +1505,10 @@ void TPushbutton_control::update()
if (attrib & XI_ATR_VISIBLE)
{
if (_hicon)
if (_native_hicon)
{
HDC hdc = (HDC)xvt_vobj_get_attr(win, ATTR_NATIVE_GRAPHIC_CONTEXT);
const RCT& rct = (RCT &) _obj->v.btn->rct;
int x = rct.left + (rct.right - rct.left - 32) / 2;
int y = rct.top + (rct.bottom - rct.top - 32) / 2;
DrawIcon(hdc, x, y, (HICON)_hicon);
os_draw_native_icon(win, rct, _native_hicon);
return;
}
@ -1575,9 +1586,10 @@ void TPushbutton_control::update()
if (_underscore >= 0)
{
TString80 cap = _caption;
cap[_underscore] = '_';
xvt_dwin_draw_text(win, x, y, (char*)(const char*)cap, _underscore+1);
const char old = _caption[_underscore];
_caption[_underscore] = '_';
xvt_dwin_draw_text(win, x, y, (char*)(const char*)_caption, _underscore+1);
_caption[_underscore] = old;
}
}
}

View File

@ -211,17 +211,21 @@ class TPushbutton_control : public TButton_control
TString _caption;
int _underscore;
short _bmp_up, _bmp_dn;
word _hicon;
unsigned _native_hicon;
protected:
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev);
virtual const char* caption() const { return _caption; }
public:
virtual void update();
// @cmember Ritorna il prompt del bottone
virtual const char* caption() const;
// @cmember Setta il prompt del bottone
virtual void set_caption(const char* c);
void set_bmp(short up, short dn);
void set_icon(word hicon);
void set_native_icon(unsigned hicon);
TPushbutton_control(WINDOW win, short cid,
short left, short top, short width, short height,

View File

@ -1,6 +1,5 @@
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define __DATE_CPP
#include <date.h>
@ -8,8 +7,6 @@
#include <real.h>
#endif
#include <strings.h>
#include <utility.h>
#include <time.h>
#define DAYYEAR 365
#define DAYBIAS 36525L
@ -22,7 +19,6 @@ HIDDEN TDate __tmp_date;
HIDDEN char __date_tmp_string[128];
HIDDEN const byte _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
TDate::TDate(const TDate &d) : _val(d._val)
{}
@ -30,41 +26,20 @@ TDate::TDate(long l) : _val(l)
{
if (_val == TODAY)
{
#if XVT_OS == XVT_OS_SCOUNIX
#ifndef FOXPRO
long lt;
struct tm *timeloc;
FILE *f;
sprintf(__date_tmp_string, "date.%-d", getuid());
if ((f = fopen(__date_tmp_string, "r")) == NULL)
{
if (time(&lt) == -1) return ;
timeloc = localtime(&lt) ;
if (timeloc == NULL)
fatal_box("Impossibile reperire la data corrente del sistema.");
_val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900);
}
else
{
fscanf(f, "%ld", _val);
fclose(f);
}
#endif
#else
time_t lt;
struct tm * timeloc;
if (time(&lt) == -1) return ;
timeloc = localtime(&lt) ;
if (time(&lt) == -1)
return;
struct tm * timeloc = localtime(&lt);
if (timeloc == NULL)
fatal_box("Impossibile reperire la data corrente del sistema.");
_val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900);
#endif
} else
}
else
{
if (_val == 0)
_val = NULLDATE;
else
{
if (_val < 1000000L)
{
long wd = _val;
@ -88,6 +63,8 @@ TDate::TDate(long l) : _val(l)
wd -= (_days_in_month[m] + (leap && (m == 1)));
_val = makedata((int) wd, m+1, y+cnt);
}
}
}
}
@ -264,7 +241,7 @@ char* TDate::string(
sep='\0';
}
TString df(2), yf(4), mf(2);
TString df(16), yf(16), mf(16);
bool letterflag = FALSE;
// format day
@ -278,11 +255,11 @@ char* TDate::string(
}
else if (dayf == weekday)
{
df = format("%s %d", itow(wday()), day());
df.format("%s %d", itow(wday()), day());
letterflag = TRUE;
}
else
df = format(dayf == brief ? "%d" : "%02d", day());
df.format(dayf == brief ? "%d" : "%02d", day());
// format year
if (yearf == letters)
@ -295,9 +272,9 @@ char* TDate::string(
}
else
if (yearf == brief)
yf = format("%02d", year() % 100);
yf.format("%02d", year() % 100);
else
yf = format("%04d", year());
yf.format("%04d", year());
// format month
if (monthf == letters)
@ -308,10 +285,10 @@ char* TDate::string(
else if (monthf == quarter)
{
if (ord < m_date) ord = ma_date;
mf = format("%do trimestre", (month() / 3) + 1);
mf.format("%do trimestre", (month() / 3) + 1);
}
else
mf = format(monthf == brief ? "%d" : "%02d", month());
mf.format(monthf == brief ? "%d" : "%02d", month());
if ((letterflag && sep == '-') || sep == 'S')
sep = ' ';

View File

@ -23,7 +23,7 @@
#define NO_STD_FONT_MENU
#define NO_STD_ABOUT_BOX
#define NO_STD_HELP_MENU
#define NO_HELP_RESOURCES
#define NO_HELP_VIEWER
#include <url.h>

View File

@ -1,52 +1,8 @@
#include <stdio.h>
//#define STRICT // Guai a me
#define XVT_INCL_NATIVE
#include <xvt.h>
#if XVT_OS == XVT_OS_WIN
#include <toolhelp.h>
#endif
#if XVT_OS == XVT_OS_SCOUNIX
#include <sys/fcntl.h>
#include <sys/wait.h>
#endif
#include <applicat.h>
#include <dongle.h>
#include <execp.h>
#include <os_dep.h>
#include <prefix.h>
#include <utility.h>
#include <window.h>
#include <extcdecl.h>
// @doc EXTERNAL
// @mfunc Controlla se il processo puo' essere eseguito
//
// @rdesc Ritorna i seguenti valori:
//
// @flag TRUE | Se l'applicazione puo' essere eseguita
// @flag FALSE | Se l'applicazione non puo' essere eseguita
bool TExternal_app::can_run() const
// @comm Se si opera sotto Windows si controlla se vi sono risorse necessarie
// per l'esecuzione del processo, altrimenti viene tornato sempre TRUE.
{
#if XVT_OS == XVT_OS_WIN
const TFixed_string p(_path);
const bool big = p.find("cg0") == 0 && p.right(2) == "-1";
const int richieste = big ? 50 : 15;
const int libere = GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
return libere >= richieste;
#else
return TRUE;
#endif
}
// @doc EXTERNAL
// @mfunc Esegue il processo
@ -91,7 +47,6 @@ word TExternal_app::run(
xvt_fsys_save_dir();
const TFilename dir(comm_name.path());
if (dir.not_empty())
{
DIRECTORY d;
@ -145,191 +100,11 @@ word TExternal_app::run(
}
*/
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (can_run())
{
TWait_cursor hourglass;
#if XVT_OS == XVT_OS_WIN
if (dongle().local())
dongle().logout();
_exitcode = WinExec((const char*)path, show ? SW_SHOWNORMAL : SW_HIDE);
if (dongle().local())
dongle().logout();
if (_exitcode >= 32)
{
if (!async)
{
const char* szModule = path.name();
HTASK child = NULL;
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
for (bool ok = TaskFirst(&te); ok; ok = TaskNext(&te))
if (te.hInst == (HINSTANCE)_exitcode ||
stricmp(te.szModule, szModule) == 0)
{
child = te.hTask;
break;
}
TTemp_window tw(TASK_WIN);
if (iconize)
{
tw.iconize();
tw.deactivate();
}
// Warning! child could be NULL if you run that beast called Foxpro
main_app().wait_for((word)child);
for (byte i = 0; main_app().waiting() == (word)child; i++)
{
// Esegue il controllo solo ogni 256 cicli
if (i == 0 && ok && TaskFindHandle(&te, child) == FALSE)
{
main_app().wake_up(); // Annulla attesa del processo
break;
}
xvt_app_process_pending_events();
}
if (iconize)
{
tw.maximize();
tw.activate();
}
xvt_app_process_pending_events();
}
xvt_statbar_refresh();
}
#else
STARTUPINFO start;
PROCESS_INFORMATION pi;
start.cb = sizeof(start);
start.lpReserved = start.lpDesktop = start.lpTitle = NULL;
start.dwX = start.dwY = start.dwXSize = start.dwYSize = CW_USEDEFAULT;
start.dwXCountChars = start.dwYCountChars = start.dwFillAttribute = 0L;
start.dwFlags = STARTF_USESHOWWINDOW;
start.wShowWindow = SW_SHOW ;
start.cbReserved2 = 0;
start.lpReserved2 = NULL;
start.hStdInput = NULL;
start.hStdOutput = NULL ;
start.hStdError = NULL;
BOOL started = CreateProcess(NULL,(char*)(const char*)path, NULL, NULL, FALSE, 0,
NULL, NULL, &start, &pi);
if (started)
{
HANDLE hProcess = pi.hProcess;
if (!async)
{
TTemp_window tw(TASK_WIN);
if (utente)
{
tw.iconize();
tw.deactivate();
}
if (WaitForSingleObject(hProcess, INFINITE) != 0xFFFFFFFF)
{
unsigned long exitcode;
if (GetExitCodeProcess(hProcess, &exitcode))
_exitcode = (int) exitcode;
else
_exitcode = -2;
}
if (utente)
{
tw.maximize();
tw.activate();
}
}
else
_exitcode = 0;
CloseHandle(pi.hThread);
CloseHandle(hProcess);
}
else _exitcode = -1;
#endif
} else _exitcode = 1;
#if XVT_OS == XVT_OS_WIN
_error = _exitcode;
switch (_exitcode)
{
case 0:
case 1:
error_box("Risorse insufficienti per eseguire '%s'", (const char*)_path); break;
case 2:
case 3:
error_box("Impossibile trovare '%s'", (const char*)_path); break;
case 16:
error_box("'%s' e' gia' in esecuzione", (const char*)_path); break;
default:
if (_exitcode < 32 && _exitcode != 8)
error_box("Impossibile eseguire '%s':\nErrore %u", (const char*)_path, _exitcode);
else
{
if (_exitcode != 8) _error = 0;
_exitcode = 0;
}
break;
}
#else
switch (_exitcode)
{
case -2:
error_box("Impossibile ricevere il valore di ritorno da '%s':\nErrore %ld", (const char*)_path, GetLastError()); break;
case -1:
error_box("Impossibile eseguire '%s':\nErrore %ld", (const char*)_path, GetLastError()); break;
case 8:
error_box("Risorse insufficienti per eseguire '%s'", (const char*)_path); break;
case 0:
break;
default:
error_box("Valore di ritorno di '%s':\n %ld", (const char*)_path, _exitcode); break;
}
#endif
#else
switch (fork())
{
case -1:
_error = errno;
_exitcode = -1;
break;
case 0:
const char* s = strdup(path);
char* p = strchr(s, ' ');
if (p) *p = '\0';
const char* pathn = strdup(s);
const char* args[21];
int i = 0;
args[i++] = pathn;
while ((i < 20) && (p))
{
s = p + 1;
p = strchr(s, ' ');
if (p) *p = '\0';
args[i++] = strdup(s);
}
args[i] = NULL;
for (i = 3; i < _NFILE; i++) fcntl(i,F_SETFD,1);
// execvp( path, NULL);
execvp ( pathn , args );
exit ( -1 );
default:
if(wait(&_exitcode) == -1)
{
error_box("Impossibile eseguire '%s':\nErrore %d", (const char*)_path, _exitcode);
_exitcode = -1;
}
else _exitcode = _exitcode >> 8;
break;
}
_error = errno;
xvt_app_escape(XVT_ESC_CH_REFRESH);
#endif
iconize &= !async && show;
_exitcode = os_execute(path, !async, iconize, show);
// restore cwd
xvt_fsys_restore_dir();
@ -337,7 +112,7 @@ word TExternal_app::run(
// update counts
if (_exitcode == 0)
_count++;
#if XVT_OS == XVT_OS_WIN
// Ignora volutamente il return code da HL_LOGIN(). Se va bene riprende il posto
// altrimenti fa lo stesso. Infatti puo' capitare con una chiave di rete, che
// nel lasso di tempo trascorso dalla HL_LOGOUT() dell'applicazione chiamata,
@ -349,7 +124,7 @@ word TExternal_app::run(
// ignorato.
if (dongle().local())
dongle().login();
#endif
return _exitcode;
}

View File

@ -27,21 +27,19 @@ class TExternal_app : public TObject
// @cmember:(INTERNAL) Ultimo errore (codice dell'errore)
int _error;
// @cmember:(INTERNAL) Ultimo exit code
word _exitcode;
int _exitcode;
// @cmember:(INTERNAL) Numero di chiamate
int _count;
// @access Public Member
public:
// @cmember Controlla se il processo puo' essere eseguito
bool can_run() const;
// @cmember Esegue il processo
word run(bool async = FALSE, bool user = TRUE, bool iconize = TRUE, bool show = TRUE);
// @cmember Ritorna il codice dell'ultimo errore
int error()
{ return _error; }
// @cmember Ritorna l'ultimo codice di uscita
word exitcode()
int exitcode()
{ return _exitcode; }
// @cmember Ritorna il numero di chiamate effettuate
int count()

View File

@ -1,14 +1,11 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#define __EXPR_CPP
#include <expr.h>
#include <stack.h>
#include <utility.h>
#include <date.h>
TValue::TValue(const real& val)
{
_r = val;
@ -196,7 +193,11 @@ TExpression::TExpression(const char* expression, TTypeexp type, bool ignore_err)
_dirty = TRUE;
_type = type;
if (!compile(_original, type))
print_error(format("Wrong expression : %s", expression));
{
TString msg(256);
msg.format("Wrong expression : %s", expression);
print_error(msg);
}
}
@ -1012,7 +1013,8 @@ TCodesym TExpression::__factor(TCodesym startsym)
else
{
_code.add(_number, real(__parms_found));
val.set(format("%d", index));
TString16 str; str.format("%d", index);
val.set(str);
_code.add(startsym, val);
_user_func_defined = TRUE;
}

View File

@ -1,5 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
#include <files.h>
#include <utility.h>

View File

@ -1,6 +1,4 @@
#include <filetext.h>
#include <utility.h>
#include <tabutil.h>
//////////////////////////////////////// TTracciato_Campo ////////////////////////////////////////
@ -765,16 +763,39 @@ void TFile_text::format_date(const TDate& data, const TString& form, TString& da
switch (k)
{
case 'g': CHECKD(cnt >= 1 && cnt <= 4, "Formato per giorno non valido ", cnt);
if (cnt == 1) data_str << data.day();
if (cnt == 2) data_str << format("%02d", data.day());
if (cnt == 3) {TString s = itow(data.wday());s.cut(3);data_str << s;}
if (cnt == 4) data_str << itow(data.wday());
if (cnt == 1)
data_str << data.day();
if (cnt == 2)
{
TString16 s;
s.format("%02d", data.day());
data_str << s;
}
if (cnt == 3)
{
TString16 s = itow(data.wday());
s.cut(3);
data_str << s;
}
if (cnt == 4)
data_str << itow(data.wday());
cnt = 0;
break;
case 'm': CHECKD(cnt >= 1 && cnt <= 4, "Formato per mese non valido ", cnt);
if (cnt == 1) data_str << data.month();
if (cnt == 2) data_str << format("%02d", data.month());
if (cnt == 3) {TString s = itom(data.month());s.cut(3);data_str << s;}
if (cnt == 1)
data_str << data.month();
if (cnt == 2)
{
TString16 s;
s.format("%02d", data.month());
data_str << s;
}
if (cnt == 3)
{
TString16 s = itom(data.month());
s.cut(3);
data_str << s;
}
if (cnt == 4) data_str << itom(data.month());
cnt = 0;
break;

View File

@ -1,24 +1,17 @@
#include <ctype.h>
#include <stdlib.h>
#define STRICT
#define XVT_INCL_NATIVE
#include <applicat.h>
#include <defmask.h>
#include <form.h>
#include <msksheet.h>
#include <os_dep.h>
#include <printer.h>
#include <relation.h>
#include <sheet.h>
#include <utility.h>
#include <spool.h>
#include <expr.h>
#include <tabutil.h>
#ifndef __DEFMASK_H
#include <defmask.h>
#endif
#include "../ba/bafrm.h"
// per lo sheet di edit campi
@ -657,11 +650,12 @@ void TForm_item::string_at(int x, int y, const char* s)
if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario
{
strncpy(__tmp_string, s, width());
__tmp_string[_width] = '\0';
s = __tmp_string;
TString tmp(s);
tmp.cut(_width);
row.put(tmp, x-1);
}
row.put(s, x-1); // Stampa testo
else
row.put(s, x-1); // Stampa testo
}
}
@ -4092,38 +4086,15 @@ void TForm::arrange_form()
TString str_pos;
TMask m("ba2100c");
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
/*
char defPrinter[80];
char szDevice[50];
// get default printer driver
GetProfileString ("windows", "device", ",,,", defPrinter, sizeof(defPrinter));
TToken_string pdev (defPrinter, ',');
GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
pdev.add(szDevice);
device = pdev.get(2);
device = device.left(4); //Legge solo LPTx...
*/
#else
TString device(printer.printername());
FILE* lpt = fopen(device,"w");
if (lpt == NULL)
fatal_box("Impossibile aprire il device %s.",device);
#endif
if (!os_open_spool_row(printer().printername()))
fatal_box("Impossibile aprire il device %s.", (const char*)printer().printername());
// _ipy viene assunto uguale per entrambi i posizionamneti
str_pos = "\017"; // Questo e' 15 in ottale...
for (i=1; i < _ipy; i++) str_pos << "\n";
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
SpoolRow((char *) (const char *) str_pos, str_pos.len());
#else
fprintf(lpt,"%s",(const char*) str_pos);
fflush(lpt); // Salta le righe...
fclose(lpt);
#endif
os_spool_row(str_pos);
str_pos = ""; //Azzera la stringa di posizionamento
for (i=1; i < _ipx; i++) str_pos << " "; //Aggiunge gli spazi necessari...
if (_ipx > 0)
@ -4136,24 +4107,11 @@ void TForm::arrange_form()
// TString bspc; bspc.fill('\b',str_pos.len()); // Questi servono per tornare indietro...
do
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
SpoolRow((char *)(const char *) str_pos, str_pos.len());
#else
lpt = fopen(device,"w");
if (lpt == NULL) fatal_box("Impossibile aprire il device %s.",device);
// fprintf(lpt,"%s",(const char*) bspc);
fprintf(lpt,"%s\r",(const char*) str_pos);
fflush(lpt);
fclose(lpt);
#endif
os_spool_row(str_pos);
} while (m.run() == K_ESC); // cicla sulla stampa posizionamento...
/* const int h = height(odd_page);
str_pos.cut(0);
for (i=0; i < h; i++) str_pos << "\n";
lpt = fopen(device,"w");
if (lpt == NULL) fatal_box("Non rieso ad aprire il device %s.",device);
fprintf(lpt, "%s", (const char*) str_pos); // Salta tante righe quanto e' lungo il form standard
fclose (lpt); */
os_close_spool_row();
printer().set_offset(-(_ipy-1), printer().get_column_offset());
}

View File

@ -456,7 +456,7 @@ TGolem_mask::TGolem_mask()
FOR_EACH_ARRAY_ROW(list, r, row)
{
TString16 ext = *row;
word icon;
unsigned icon;
if (ext == "mailto")
{
@ -473,7 +473,7 @@ TGolem_mask::TGolem_mask()
const int y = i < ITEMS_PER_ROW ? 0 : 2;
TButton_field& btn = add_button(301+i, 0, ext, x, y, 3, 2);
btn.set_handler(ole_handler);
btn.set_icon(icon);
btn.set_native_icon(icon);
i++;
if (i > MAX_ITEMS)
break;
@ -492,7 +492,7 @@ TString& TGolem_field::get_window_data()
void TGolem_field::set_window_data(const char* data)
{
WORD icon = 0;
unsigned icon = 0;
char* pipe = strchr(data, '|');
if (pipe)
@ -504,7 +504,7 @@ void TGolem_field::set_window_data(const char* data)
TPushbutton_control* btn = (TPushbutton_control*)_ctl;
if (icon)
btn->set_icon(icon);
btn->set_native_icon(icon);
else
btn->set_bmp(BMP_OLE, 0);

View File

@ -1128,14 +1128,17 @@ int TBaseisamfile::_write(const TRectype& rec)
#endif
NOT_OPEN();
int oldkey=getkey();
browse_null(rec.string(),DB_reclen(_isamfile->fhnd));
const int dst_len = DB_reclen(_isamfile->fhnd);
CHECKD(rec.len() == dst_len, "Record size mismatch on file ", _logicnum);
setkey(1);
memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd));
const int oldkey=getkey();
browse_null(rec.string(), dst_len);
setkey(1);
memcpy(DB_getrecord(_isamfile->fhnd), rec.string(), dst_len);
_lasterr = DB_add(_isamfile->fhnd);
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
setkey(oldkey);
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
if (_lasterr == NOERR && rec.has_memo())
((TRectype &)rec).write_memo( _isamfile, _recno );
@ -1169,6 +1172,7 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
if (_lasterr == NOERR)
{
const int len = DB_reclen(_isamfile->fhnd);
CHECKD(len == save_rec.len(), "Record size mismatch on file ", _logicnum);
browse_null(rec.string(), len);
if (memcmp(rec.string(), save_rec.string(), len) != 0)
@ -2049,20 +2053,15 @@ int TSystemisamfile::exec_convapp(
f.ext(".exe");
s << " " << prefix().get_codditta();
TExternal_app app(s);
if (app.can_run())
if (f.exist())
{
if (fexist(f))
{
app.run(FALSE, 0x3); // Synchronous Spawn with User
err = app.error();
TMailbox mail;
TMessage* msg = mail.next(TRUE);
if (err == 0 && msg != NULL)
err = atoi(msg->body());
}
app.run(FALSE, 0x3); // Synchronous Spawn with User
err = app.error();
TMailbox mail;
TMessage* msg = mail.next(TRUE);
if (err == 0 && msg != NULL)
err = atoi(msg->body());
}
else err = 16;
if (err && err != 8)
return error_box("Impossibile eseguire il programma di %sconversione\ndel livello %ld/%ld\nErrore n.ro %d", before ? "pre" : "post", l / 100, l % 100, err);
}

View File

@ -1,4 +1,3 @@
#include <stdlib.h>
#include <fstream.h>
#include <applicat.h>

View File

@ -1,14 +1,12 @@
#include <time.h>
#include <stdio.h>
#define XVT_INCL_NATIVE
#define STRICT
#include <applicat.h>
#include <controls.h>
#include <browfile.h>
#include <colors.h>
#include <msksheet.h>
#include <os_dep.h>
#include <relation.h>
#include <urldefid.h>
#include <utility.h>
@ -740,29 +738,11 @@ bool TMask::on_key(
next_page(+1);
break;
case K_F1:
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (fexist("prassi.hlp"))
{
struct MULTIGUY
{
UINT mkSize;
BYTE mkKeylist;
char mkKeyphrase[16];
} mk;
mk.mkSize = sizeof(MULTIGUY);
mk.mkKeylist = 'M';
_splitpath(source_file(), NULL, NULL, mk.mkKeyphrase, NULL);
TFilename hlp("prassi.hlp");
TString16 mod(mk.mkKeyphrase);
mod.cut(2); mod.lower();
if (mod != "ba") hlp.insert(mod, 0);
HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk);
char key[32];
_splitpath(source_file(), NULL, NULL, key, NULL);
os_exec_help_command(M_HELP_ONCONTEXT, key);
}
#endif
break;
case K_F12:
post_error_message(format("Lettura = %ld\n"
@ -1820,10 +1800,10 @@ void TMask::copy_values(
}
}
const char* TMask::get_caption() const
const char* TMask::get_caption(TString& str) const
{
char* title = &__tmp_string[512];
xvt_vobj_get_title(_pagewin[0], title, 80);
char* title = str.get_buffer(128);
xvt_vobj_get_title(_pagewin[0], title, str.size());
return title;
}

View File

@ -394,7 +394,7 @@ public:
{ return _mode == MODE_QUERYINS || _mode == MODE_INS; }
// @cmember Ritorna il titolo della maschera
virtual const char* get_caption() const;
virtual const char* get_caption(TString& str) const;
// @cmember Setta il titolo della maschera
virtual void set_caption(const char* c);

View File

@ -1,7 +1,3 @@
#define STRICT
#define XVT_INCL_NATIVE
#include <xvt.h>
#include <applicat.h>
#include <colors.h>
#include <controls.h>
@ -1113,9 +1109,9 @@ void TButton_field::set_bmp(short up, short dn)
((TPushbutton_control*)_ctl)->set_bmp(up, dn);
}
void TButton_field::set_icon(word icon)
void TButton_field::set_native_icon(unsigned icon)
{
((TPushbutton_control*)_ctl)->set_icon(icon);
((TPushbutton_control*)_ctl)->set_native_icon(icon);
}
///////////////////////////////////////////////////////////
@ -2166,13 +2162,14 @@ bool TBrowse::do_link(bool insert)
prg = c.get("TabPrg",module);
if (prg.empty())
prg = "ba3 -0";
}
app = format("%s %s", (const char*)prg,(const char*)nm.mid(2));
// Obbligatorio usare la format globale
}
// Obbligatorio usare la format globale
app.format("%s %s", (const char*)prg,(const char*)nm.mid(2));
}
else // Programma generico di browse/edit
// Obbligatorio usare la format globale
app = format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num());
// Obbligatorio usare la format globale
}
else
{

View File

@ -524,7 +524,7 @@ public:
void set_hot_key(KEY k) { _virtual_key = _exit_key = k; }
void set_bmp(short up, short dn);
void set_icon(word icon);
void set_native_icon(unsigned icon);
// @cmember Costruttore
TButton_field(TMask* mask);

View File

@ -20,6 +20,7 @@
#define MOV_REG "REG"
#define MOV_PROTIVA "PROTIVA"
#define MOV_UPROTIVA "UPROTIVA"
#define MOV_MESELIQ "MESELIQ"
#define MOV_CODVAL "CODVAL"
#define MOV_CAMBIO "CAMBIO"
#define MOV_DATACAM "DATACAM"

View File

@ -1,4 +1,3 @@
#include <checks.h>
#include <strings.h>
// skstream.h
@ -19,7 +18,7 @@
// [JCW 96-Jan-01] removed UDP capabilities from skstream
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include "winsock.h"
@ -119,9 +118,6 @@ protected:
// [JCW 96-Oct-20] protected skstream::init and ::shutdown changed.
// char( 255 ) == EOF bug fixed.
#include <stdio.h>
#include <stdlib.h>
#ifdef _UNIX
#define INVALID_SOCKET -1
// Add definitions here

View File

@ -5,24 +5,6 @@
#include "NetUtils.h"
OsType GetOsType()
{
OsType ver;
DWORD dwVersion = GetVersion();
if (dwVersion < 0x80000000)
ver = WINDOWS_NT;
else
{
if (LOBYTE(LOWORD(dwVersion)) < 4)
ver = WINDOWS_31;
else
ver = WINDOWS_95;
}
return ver;
}
TLanManager::TLanManager()
{ }

View File

@ -2,8 +2,9 @@
#define __NETUTILS_H__
#ifdef NO_MFC
#define STRICT
#include <windows.h>
#define BOOL int
#define BYTE unsigned char
#define DWORD unsigned long
#include "assoc.h"
#endif
@ -109,7 +110,4 @@ public:
virtual ~TConnection();
};
enum OsType { WINDOWS_31, WINDOWS_95, WINDOWS_NT };
OsType GetOsType();
#endif

View File

@ -11,7 +11,6 @@ const char* TObject::class_name() const
return "Object";
}
word TObject::class_id() const
{
return CLASS_OBJECT;
@ -64,8 +63,6 @@ bool TError_Object::is_kind_of(word cid) const
return cid == CLASS_ERROR || TObject::is_kind_of(cid);
}
bool TError_Object::ok() const
{
@ -77,15 +74,16 @@ bool TError_Object::ok() const
///////////////////////////////////////////////////////////
const char* TSortable::class_name() const
{
return "Sortable";
}
word TSortable::class_id() const
{
return CLASS_SORTABLE;
}
bool TSortable::is_kind_of(word cid) const
{
return cid == CLASS_SORTABLE || TObject::is_kind_of(cid);
}

View File

@ -103,6 +103,8 @@ public:
virtual const char* class_name() const;
// @cmember Ritorna l'id della classe
virtual word class_id() const;
// @cmember Controlla se si tratta di un oggetto derivato dalla classe <p cid>
virtual bool is_kind_of(word cid) const;
// @cmember Distruttore
virtual ~TSortable()
{}
@ -259,7 +261,7 @@ inline bool operator !=(
#define extern
#endif
extern TError_Object error;
extern TError_Object error_object;
#undef extern

View File

@ -1,20 +1,19 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#define __PREFIX_CPP
#include <prefix.h>
#include <codeb.h>
#include <extcdecl.h>
#include <tabutil.h>
#include <progind.h>
#include <scanner.h>
#include <tabutil.h>
#include <utility.h>
#include <codeb.h>
#include <nditte.h>
extern int get_error(int);
///////////////////////////////////////////////////////////
// extern variables are NO-NO!
///////////////////////////////////////////////////////////
@ -288,11 +287,11 @@ bool TPrefix::exist(long codditta) const
TFilename s(firm2dir(codditta));
s.add("dir.gen");
if (fexist(s))
if (s.exist())
{
s = s.path();
s.add("trc.gen");
return fexist(s);
return s.exist();
}
return FALSE;
}
@ -305,7 +304,7 @@ bool TPrefix::test(const char* s) const
s1.add(s);
s1.add("dir.gen");
if (!fexist(s1))
if (!s1.exist())
return error_box("Impossibile trovare il file '%s'", (const char*)s1);
}
@ -354,7 +353,7 @@ bool TPrefix::set_studio(const char* study, long ditta)
{
TFilename dirtest(study);
dirtest.add("com/dir.gen");
if (!fexist(dirtest))
if (!dirtest.exist())
return FALSE;
const TString old_study(__ptprf);
@ -448,4 +447,118 @@ const char* firm2dir(
return __tmp_string;
}
bool TPrefix::build_firm_data(long codditta, bool flagcom)
{
const char * const ndir = "/dir.gen";
const char * const ntrc = "/trc.gen";
TFilename s(firm2dir(codditta)); s << ndir;
bool exist = s.exist();
if (!exist)
{
s = s.path(); s.rtrim(1); s << ntrc;
exist = s.exist();
}
if (exist)
return message_box("Direttorio dati danneggiato, impossibile attivare la ditta %ld", codditta);
if (!yesno_box("Gli archivi della ditta %ld non esistono: si desidera generarli?", codditta))
return FALSE;
TLocalisamfile ditte(LF_NDITTE);
ditte.zero();
ditte.put(NDT_CODDITTA,codditta);
if (ditte.read(_isequal,_testandlock) == _islocked)
{
message_box("Archivi della ditta %ld in fase di creazione da parte di un altro utente.",codditta);
return FALSE;
}
set_autoload_new_files(yesno_box("Si desidera precaricare gli archivi standard"));
s = s.path(); s.rtrim(1);
if (!s.exist() && !make_dir(s))
return error_box("Impossibile creare il direttorio della ditta %ld (%s)",
codditta, (const char*)s);
s << ndir;
if (!fcopy(&ndir[1], s))
return error_box("Impossibile copiare il file %s della ditta %ld",
&ndir[1], codditta);
s = s.path(); s << ntrc;
if (!fcopy(&ntrc[1], s))
return error_box("Impossibile copiare il file %s della ditta %ld",
ntrc, codditta);
TDir dir, dir1;
TTrec rec;
prefix().set("");
dir1.get(LF_DIR, _nolock, _nordir, _sysdirop);
const long maxeod0 = dir1.eod();
prefix().set_codditta(codditta);
dir.get(LF_DIR, _nolock, _nordir, _sysdirop);
if (dir.eod() == 0)
{
dir1.eod() = 1L;
dir1.put(LF_DIR, _nordir, _sysdirop);
dir.get(LF_DIR, _nolock, _nordir, _sysdirop);
}
const long maxeod1 = dir.eod();
if (maxeod0 > maxeod1)
{
dir.get(LF_DIR, _nolock, _nordir, _sysdirop);
dir.eod() = maxeod0;
dir.put(LF_DIR, _nordir, _sysdirop);
rec.zero();
}
TString mess("Generazione archivi della ditta "); mess << codditta;
TProgind p(maxeod0 ? maxeod0 : 1, mess, FALSE, TRUE, 70);
for (int i = LF_DIR + 1; i <= maxeod0; i++)
{
p.addstatus(1);
prefix().set("");
dir.get(i, _nolock, _nordir, _sysdirop);
rec.get(i);
bool create_now = dir.is_active();
prefix().set_codditta(codditta);
dir.put(i, _nordir, _sysdirop);
rec.put(i);
const char* name = dir.name();
dir.flags() = 0L;
create_now = create_now && (flagcom ? dir.is_com() : dir.is_firm());
if (dir.is_valid() && create_now)
{
TSystemisamfile f(i);
f.build(30);
}
else
{
dir.put(i, _nordir, _sysdirop);
rec.put(i);
}
}
TConfig c(CONFIG_STUDIO, "cg");
if (c.get_bool("StiReg"))
{
TTable reg("REG");
for (reg.first(_lock); reg.good(); reg.next(_lock))
{
reg.put("B9", "X");
reg.rewrite();
}
}
ditte.reread(_unlock);
prefix().set_codditta(codditta);
set_autoload_new_files(TRUE);
return TRUE;
}

View File

@ -82,7 +82,8 @@ public:
// @cmember Controlla che siano attivi i dati comuni (e non una ditta)
bool is_com() const
{ return !is_firm();}
// @cmember Crea gli archivi dii una nuova ditta
bool build_firm_data(long codditta, bool flagcom = FALSE);
// @cmember Riapre tutti gli archivi della ditta attiva
void reopen() const ;

View File

@ -1,37 +1,18 @@
#define STRICT
#define XVT_INCL_NATIVE
#include <xvt.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
#if XVT_OS==XVT_OS_SCOUNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <stdio.h>
#endif
#define STYLE_NUM 4
#include <applicat.h>
#include <config.h>
#include <execp.h>
#include <golem.h>
#include <mask.h>
#include <os_dep.h>
#include <printer.h>
#include <printwin.h>
#include <urldefid.h>
#include <utility.h>
#include <viswin.h>
#include <spool.h>
#include <bagn001a.h>
#define STYLE_NUM 4
HIDDEN TPrinter* _printer = NULL;
TPrinter& printer()
@ -215,34 +196,12 @@ void TPrint_intersector::clear()
struct PrDesc
{
TTextfile *_txt;
// PRINT_RCD *_prcd;
// bool _graphics;
// int _formlen;
// int _charsize;
// int _lines_per_inch;
TPrinter * _p;
}
PrintWhat;
} PrintWhat;
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
void TPrinter::_get_windows_printer_names (TToken_string& t)
BOOLEAN XVT_CALLCONV1 TPrinter::start_print (long data)
{
char* buf = t.get_buffer(2048); // ammazzao'
GetProfileString ("devices", NULL, "", buf, t.size());
for (int i = 0; i < t.size(); i++)
{
if (buf[i] == '\0')
{
if (buf[i+1] != '\0') buf[i] = '|';
else break;
}
}
}
BOOLEAN XVT_CALLCONV1 TPrinter::start_winprint (long data)
{
PrDesc *pd = (PrDesc *) data;
const PrDesc *pd = (PrDesc *) data;
TTextfile& txt = *(pd->_txt);
const int vofs = pd->_p->get_line_offset();
const int hofs = pd->_p->get_column_offset();
@ -296,11 +255,11 @@ BOOLEAN XVT_CALLCONV1 TPrinter::start_winprint (long data)
else
{
TPrintwin pw(txt);
pw.do_print();
if (pw.win() != NULL_WIN)
pw.do_print();
return pw.aborted();
}
}
#endif
// utils del caz
HIDDEN int read_int (const char *s, int &n, int &cnt)
@ -966,12 +925,10 @@ PRINT_RCD* TPrinter::get_printrcd(int *size)
return _print_rcd;
}
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
// @doc EXTERNAL
// @mfunc Setta le caratteristiche della stampante leggendole da <p _print_rcd>
void TPrinter::set_win_formlen(
void TPrinter::init_formlen(
WINDOW prwin) // @parm Finestra effettiva di stampa (default NULL_WIN)
// @comm Nel caso <p prwin> sia NULL_WIN vengono solamente aggiornati i valori
@ -987,9 +944,7 @@ void TPrinter::set_win_formlen(
if (prwin != NULL_WIN)
{
TString spc; // Compute maximum number of chars per line
// spc.spaces(256);
spc.fill('M', 256);
const TString spc(256, 'M'); // Compute maximum number of chars per line
int w = 0;
for (_formwidth = spc.len(); _formwidth >= 80; _formwidth--)
@ -1024,20 +979,14 @@ HIDDEN bool set_windows_print_device (TMask_field& f, KEY key)
TPrinter& pr = printer();
TToken_string& pn = pr.getprinternames ();
TString80 pdev (pn.get(atoi (f.get()))); // Nome stampante corrente
char szDevice[80];
GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice));
pdev << "," << szDevice;
// scrivi (e semmai lo si risistema poi)
WriteProfileString("windows", "device", pdev);
TToken_string pn; os_get_printer_names(pn);
const TString pdev (pn.get(atoi (f.get()))); // Nome stampante corrente
os_set_default_printer(pdev);
if (m.is_running())
{
pr.set_printrcd();
pr.set_win_formlen();
pr.init_formlen();
}
const int MAX_FAMILIES = 128;
@ -1099,17 +1048,11 @@ HIDDEN bool font_handler(TMask_field& f, KEY key)
return TRUE;
}
#endif
HIDDEN char defPrinter[80];
TPrinter::TPrinter()
: _date (TODAY), _multiple_link (FALSE), _frozen (FALSE), _isgraphics (TRUE),
_lines_per_inch (6), _ch_size (12), _ncopies(1), _export_header(FALSE),
_export_header_len(0), _vf(NULL), _l_offset(0), _c_offset(0), _appendfile(FALSE)
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
, _print_rcd(NULL)
#endif
_export_header_len(0), _vf(NULL), _l_offset(0), _c_offset(0), _appendfile(FALSE),
_print_rcd(NULL)
{
_footerhandler = _headerhandler = NULL;
@ -1133,76 +1076,46 @@ TPrinter::TPrinter()
// read configuration file
read_configuration ();
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
// xvt_print_open ();
set_win_formlen ();
init_formlen ();
// char szDevice[50];
// get default printer driver
GetProfileString ("windows", "device", ",,,", defPrinter, sizeof(defPrinter));
os_get_default_printer(_defPrinter);
TToken_string& pn2 = getprinternames(); // get printer names
TToken_string pn2; os_get_printer_names(pn2); // get printer names
CHECK(_curprn >= 0, "Can't find printer ");
if (_curprn >= pn2.items())
{
TToken_string pdev (defPrinter, ',');
// GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
// pdev.add(szDevice);
const TString80 p1(pdev.get(0)); // current printer
_curprn = pn2.get_pos(p1);
TString pdev(_defPrinter); // Nome stampante corrente
int comma = pdev.find(',');
if (comma > 0)
pdev.cut(comma);
_curprn = pn2.get_pos(pdev);
}
else
{
TString80 pdev(pn2.get(_curprn)); // Nome stampante corrente
char szDevice[80];
GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice));
pdev << "," << szDevice;
const TString pdev(pn2.get(_curprn)); // Nome stampante corrente
// scrivi (e semmai lo si risistema poi)
WriteProfileString("windows", "device", pdev);
os_set_default_printer(pdev);
}
set_fincatura("+++++++++-|");
#else
_isgraphics = FALSE;
#endif
set_fink_mode(TRUE);
_finker = _isgraphics && _fink_mode ? NULL : new TPrint_intersector(_fink, _formlen);
}
bool TPrinter::isfax() const
{
bool fax = _printertype == winprinter /* || _printertype == screenvis */;
if (fax)
{
bool fax = FALSE;
if (_printertype == winprinter)
{
const char* name = (const char*)((TPrinter*)this)->get_printrcd() + 4;
fax = strncmp(name, "FaxMan", 6) == 0;
if (!fax)
{
TToken_string p(256, ',');
GetProfileString ("devices", name, "", (char*)(const char*)p, p.size());
const char * driver = p.get(1);
fax = driver != NULL && stricmp(driver, "EASYFAX") == 0;
}
}
return fax;
}
TToken_string& TPrinter::getprinternames ()
{
// per ora va solo in windows
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (_printer_names.empty())
_get_windows_printer_names(_printer_names);
#endif
return _printer_names;
}
// @doc EXTERNAL
// @mfunc Legge la configurazione della stampante
@ -1213,41 +1126,6 @@ void TPrinter::read_configuration(
{
TWait_cursor hourglass;
#if XVT_OS == XVT_OS_SCOUNIX
const char* const config = "printer.ini";
FILE *cnfp = fopen (config, "r");
if (cnfp == NULL)
fatal_box ("Impossibile aprire il file %s", config);
for (int i = 0; !feof (cnfp); i++)
{
if (fgets (__tmp_string, 256, cnfp) == NULL)
return;
// else
if (strncmp (__tmp_string, "[Default]", 9) != 0)
// fgets(__tmp_string,256,cnfp);
// else
{
if (*__tmp_string == '[')
{
// fatal_box("[ expected in file of printer configuration");
char *u = strchr (__tmp_string, ']');
if (u)
*u = '\0';
u = __tmp_string + 1;
PrinterDef *pp = new PrinterDef;
_printers.add (pp);
if (pp->read (u, cnfp) == FALSE)
break;
}
}
}
fclose (cnfp);
#endif
_config = parag; // Inizializza nome configurazione
if (_config.empty()) // Se non specificata ...
_config = "Printer"; // ... usa configurazione standard
@ -1304,11 +1182,7 @@ void TPrinter::read_configuration(
if (_printerfile.empty())
{
_printerfile.tempdir();
#if XVT_OS == XVT_OS_SCOUNIX
_printerfile << '/';
#else
_printerfile << '\\';
#endif
}
if (_config == "Printer" || _printertype == winprinter)
@ -1316,23 +1190,7 @@ void TPrinter::read_configuration(
{
case 0:
case 5:
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
_printertype = winprinter;
#else
PrinterDef & def = (PrinterDef &) get_description (_curprn);
switch (atoi (def._printertype))
{
case 1:
_printertype = localprinter;
break;
case 2:
_printertype = spoolprinter;
break;
default:
_printertype = normprinter;
break;
}
#endif
break;
case 1: // file
_printertype = fileprinter;
@ -1391,36 +1249,32 @@ void TPrinter::save_configuration()
TPrinter::~TPrinter ()
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (_print_rcd != NULL)
{
xvt_print_destroy(_print_rcd);
_print_rcd = NULL;
}
WriteProfileString("windows", "device", defPrinter);
// xvt_print_close();
#endif
}
os_set_default_printer(_defPrinter);
}
const char* TPrinter::class_name () const
const char* TPrinter::class_name() const
{
return "Printer";
}
word TPrinter::class_id () const
word TPrinter::class_id() const
{
return CLASS_PRINTER;
}
TPrintrow *TPrinter::getheaderline (int linetoget)
TPrintrow *TPrinter::getheaderline(int linetoget)
{
return ((TPrintrow *) _header.objptr (linetoget));
return ((TPrintrow *)_header.objptr (linetoget));
}
TPrintrow *TPrinter::getfooterline (int linetoget)
TPrintrow *TPrinter::getfooterline(int linetoget)
{
return ((TPrintrow *) _footer.objptr (linetoget));
return ((TPrintrow *)_footer.objptr(linetoget));
}
// @doc EXTERNAL
@ -1551,36 +1405,13 @@ bool TPrinter::printrow(
return TRUE;
}
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (_printertype == fileprinter)
{
// add line to txt
if (!_frozen)
_txt.append (rw);
return TRUE;
}
#else
const PrinterDef & pd = get_description (_curprn);
int prvstl = -1;
for (idx = 0; idx < lun; idx++)
{
int cst = rowtoprint->get_style (idx);
if (cst != prvstl)
{
fprintf (_fp, "%s", pd._atstr[normalstyle]);
if (cst != normalstyle)
fprintf (_fp, "%s", pd._atstr[cst]);
}
prvstl = cst;
putc (rw[idx], _fp);
}
if (newline ())
putc (newline (), _fp);
#endif
return TRUE;
}
@ -1651,11 +1482,6 @@ bool TPrinter::printfooter()
for (int i = 0; i < _footersize && ok; i++)
ok = printrow(getfooterline(i));
#if XVT_OS == XVT_OS_SCOUNIX
if (ok)
printformfeed();
#endif
_currentrow = 1;
_currentpage++;
@ -1747,118 +1573,31 @@ void TPrinter::reset()
_currentrow = 1;
}
bool TPrinter::printformfeed()
{
#if XVT_OS == XVT_OS_SCOUNIX
const PrinterDef & pd = get_description(_curprn);
if (_printertype != screenvis && _hwformfeed)
fprintf(_fp, "%s",(const char *)pd._ffcode);
#endif
return TRUE;
}
bool TPrinter::open()
{
#if XVT_OS==XVT_OS_SCOUNIX
if (_printertype == spoolprinter)
{
const PrinterDef & def = get_description(_curprn);
int pfd[2];
TToken_string pn2; os_get_printer_names(pn2); // get printer names
TString pdev(pn2.get(_curprn)); // Nome stampante corrente
os_set_default_printer(pdev);
if (pipe(pfd) == -1)
return error_box ("Impossibile creare processo di stampa " "(pipe)");
int ret = fork();
if (ret == -1)
return error_box("Impossibile creare processo di stampa " "(fork)");
if (ret == 0)
{
if ((::close(0) != -1) && (::dup(pfd[0]) == 0) &&
(::close(pfd[0]) == 0) && (::close(pfd[1]) != -1))
{
char s0[80];
sprintf (s0, "-d%s", (const char *) def._devicename);
if ((def._filtername).not_empty ())
{
char s1[80];
sprintf (s1, "-o %s", (const char *) def._filtername);
char *ws[5] =
{"lpr", "-s", s0, s1, NULL};
execvp (ws[0], ws);
}
else
{
char *ws[4] =
{"lpr", "-s", s0, NULL};
execvp(ws[0], ws);
}
exit(-1);
}
}
if ((::close (pfd[0]) == -1) || ((_fp = fdopen(pfd[1], "w")) == NULL))
return error_box ("Impossibile creare processo di stampa" "(close)");
if (_printertype == screenvis)
{
CHECK(_vf == NULL, "Print preview already open");
_vf = new TViswin (NULL, "Anteprima di stampa", TRUE, TRUE,
_linksdescr.items () > 0);
_vf->open_modal ();
}
else
#endif
else
{
TToken_string& pn2 = getprinternames(); // get printer names
TString80 pdev(pn2.get(_curprn)); // Nome stampante corrente
char szDevice[80];
GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice));
pdev << "," << szDevice;
// scrivi (e semmai lo si risistema poi)
WriteProfileString("windows", "device", pdev);
if (_printertype == screenvis)
{
CHECK(_vf == NULL, "Print preview already open");
_vf = new TViswin (NULL, "Anteprima di stampa", TRUE, TRUE,
_linksdescr.items () > 0);
_vf->open_modal ();
}
else if (_printertype == winprinter || _printertype == export
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
|| _printertype == fileprinter
#endif
)
if (_printertype == winprinter || _printertype == export || _printertype == fileprinter)
{
// prepare text object for new text
_txt.destroy();
_txt.interactive(FALSE);
if (isfax())
start_fax_server();
}
}
#if XVT_OS==XVT_OS_SCOUNIX
else
{
const PrinterDef & def = get_description (_curprn);
TFilename fname (_printerfile);
if (_printertype == normprinter)
fname = def._devicename;
_fp = fopen (fname, "w");
if (_fp == NULL)
return error_box ("Errore di apertura file stampa: '%s'",
(const char *) fname);
TString code (def.get_codes (_curcode));
if (code.not_empty ())
{
const char *s = code;
fputs (esc ((char *) s), _fp);
}
}
#endif
}
_currentrow = 1;
_currentpage = 1;
@ -1883,9 +1622,10 @@ bool TPrinter::set()
mask.enable(DLG_OK, can_save);
// mask.enable(DLG_SAVEREC, can_save);
TToken_string& pn2 = getprinternames();
char old_default[80];
GetProfileString ("windows", "device", ",,,", old_default, sizeof(old_default));
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++)
@ -1932,7 +1672,7 @@ bool TPrinter::set()
if (xvt_dm_post_page_setup(get_printrcd()))
{
// Ricarica la lista delle stampanti (L'utente puo' aggiungerne!)
_get_windows_printer_names(pn2);
os_get_printer_names(pn2);
pn1.cut(0);
int i = 0;
FOR_EACH_TOKEN(pn2, tok)
@ -1945,9 +1685,9 @@ bool TPrinter::set()
const char* name = (const char *)(get_printrcd() + 4);
_curprn = pn2.get_pos(name);
if (_curprn < 0)
if (*name == '\0' || _curprn < 0)
{
NFCHECK("Can't find printer %s", name);
NFCHECK("Can't find printer '%s'", name);
_curprn = oldprn;
}
@ -1964,11 +1704,11 @@ 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);
WriteProfileString("windows", "device", old_default);
os_set_default_printer(old_default);
_curprn = oldprn;
s_printrcd * rcd = get_printrcd();
memcpy(rcd, (const char *) oldrcd, _print_rcd_size);
set_win_formlen();
init_formlen();
return FALSE;
}
@ -1998,7 +1738,7 @@ bool TPrinter::set()
_lines_per_inch = mask.get_int (MSK_LINES);
_isgraphics = mask.get_bool (MSK_ISGRAPHICS);
set_win_formlen ();
init_formlen ();
if (k == K_INS)
save_configuration();
@ -2062,19 +1802,14 @@ int TPrinter::set_bookmark(
void TPrinter::print_txt(TTextfile& txt)
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (txt.lines() > 0)
{
// PrintWhat._prcd = _print_rcd;
PrintWhat._txt = &txt;
// PrintWhat._graphics = _isgraphics;
// PrintWhat._charsize = _ch_size;
PrintWhat._p = this;
xvt_print_open();
xvt_print_start_thread (start_winprint, (long) (&PrintWhat));
xvt_print_start_thread(start_print, (long) (&PrintWhat));
xvt_print_close();
}
#endif
}
@ -2117,12 +1852,12 @@ void TPrinter::close ()
txt.close();
}
}
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
else if (_printertype == winprinter && _txt.lines() > 0L)
{
print_txt(_txt);
if (is_generic())
SpoolRow("\n",1); // Force flushing on Generic printer
os_spool_row("\n"); // Force flushing on Generic printer
os_set_default_printer(_defPrinter);
}
else if (_printertype == fileprinter)
{
@ -2137,23 +1872,6 @@ void TPrinter::close ()
fclose(fp);
message_box("Stampa su file terminata. Nome archivio: %s",(const char *)_printerfile);
}
#endif
else if (_printertype == localprinter)
{
#if XVT_OS == XVT_OS_SCOUNIX
TFilename s1 = tmpnam (NULL);
switch (fork ())
{
case -1:
break;
case 0:
execlp ("localprint", "localprint", (const char *) s1, NULL);
default:
wait ((int *) NULL);
}
remove (s1);
#endif
}
if (_finker)
{
@ -2163,10 +1881,8 @@ void TPrinter::close ()
// Dealloca sfondi ormai inutili
_backgrounds.destroy();
freeze (FALSE);
_isopen = FALSE;
WriteProfileString("windows", "device", defPrinter);
}
//
@ -2175,12 +1891,6 @@ void TPrinter::close ()
#include <bagn004.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
const char* const FORMAT_COMMAND = "FORMAT";
#else
const char* const FORMAT_COMMAND = "dosformat -fq";
#endif
const long disk_sizes[] = { 360000L, 1200000L, 720000L, 1400000L, 2880000L };
TFile_printer::TFile_printer (const char *ffile, const char *label, int len_rec, int num_rec_inizio, int num_rec_fine, int tipo_disco)
@ -2195,7 +1905,6 @@ TFile_printer::TFile_printer (const char *ffile, const char *label, int len_rec,
_size = disk_sizes[tipo_disco];
_num_rec_volume = int ((_size / len_rec) - _num_rec_testa_coda);
_nome_file_fissato = TRUE;
_formatta = FALSE;
_label_fissata = TRUE;
}
@ -2219,22 +1928,8 @@ bool TFile_printer::genera_dischetti ()
if (!r)
return error_box ("Procedura interrotta!");
// e eventualmente lo formatta
if (_formatta)
{
TString80 dep;
if (_label != NULL)
dep << FORMAT_COMMAND << " " << "/v:" << _label << " " << _drive;
else
dep << FORMAT_COMMAND << " " << _drive;
TExternal_app sys (dep);
sys.run ();
}
// copia il file sul dischetto
fcopy ((const char *) &_tmp_files[i], (const char *) _drive);
}
return TRUE;
}
@ -2274,7 +1969,6 @@ bool TFile_printer::set ()
_drive = m.get(F_DRIVE);
_file = m.get(F_FILE_DESTINAZIONE);
_label = m.get(F_LABEL);
_formatta = (bool)(m.get(F_FORMATTA) == "X");
_size = disk_sizes[f];
_num_rec_volume = int ((_size / _len_rec) - _num_rec_testa_coda);
}
@ -2371,7 +2065,7 @@ bool TPrinter::send_fax(const char* tipo, const char* codice)
{
if (tipo && codice)
{
TString cmd(80);
TString cmd;
cmd << "[SetRecipient(" << tipo << ',' << codice << ")]";
TDDE dde;

View File

@ -243,7 +243,8 @@ class TPrinter : public TObject
FILE* _fp;
// @cmember:(INTERNAL) Puntatore al file di visualizzaizone
TViswin* _vf;
// @cmember:(INTERNAL) Stampande di default di sistema
TString _defPrinter;
// @cmember:(INTERNAL) Testo da stampare
TTextfile _txt;
// @cmember:(INTERNAL) Nome del file di esportazione
@ -305,9 +306,6 @@ class TPrinter : public TObject
// @cmember:(INTERNAL) Nomi dei file delle immagini da stampare
TString_array _image_names;
// @cmember:(INTERNAL) Nomi delle stampanti utilizzabile
TToken_string _printer_names;
// @cmember:(INTERNAL) Indica se la stampante e' abilitata a trattare grafica
bool _isgraphics;
// @cmember:(INTERNAL) Indica se la stampante e' stata momentaneamente interrotta
@ -390,11 +388,8 @@ public:
// @cmember Distruttore
virtual ~TPrinter();
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
// @cmember Inizia una nuova sessione di stampa. Viene passata alla <mf TPrintwin::do_print>
static BOOLEAN XVT_CALLCONV1 start_winprint(long);
#endif
static BOOLEAN XVT_CALLCONV1 start_print(long data);
// @cmember Setta il numero della prima pagina da stampare
void set_from_page (word from)
@ -496,8 +491,6 @@ public:
void enable_multiple_copies(bool b = TRUE)
{ _multiple_copies = b; }
// @cmember Ritorna il nome delle stampanti utilizzabili
TToken_string& getprinternames();
// @cmember Ritorna il testo da stampare
TTextfile& get_txt()
{ return _txt; }
@ -633,10 +626,8 @@ public:
void set_printrcd();
// @cmember Ritorna il record per la descrizione dello stato dell stampante
PRINT_RCD* get_printrcd(int* size = NULL);
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
// @cmember Setta le caratteristiche della stampante leggendole da <p _print_rcd>
void set_win_formlen(WINDOW prwin = NULL_WIN);
#endif
void init_formlen(WINDOW prwin = NULL_WIN);
// @cmember Setta la definizione della stampante in linee per pollice
void set_lines_per_inch(int n)
{ _lines_per_inch = n; }
@ -735,8 +726,6 @@ class TFile_printer : public TPrinter
bool _nome_file_fissato;
// @cmember:(INTERNAL) Indica se l'etichetta dei dischetti deve essere fissa
bool _label_fissata;
// @cmember:(INTERNAL) Indica se il disco deve essere formattato prima di fare la stampa
bool _formatta;
// @cmember:(INTERNAL) File da generare sui dischetti
const char* _file;
// @cmember:(INTERNAL) Etichetta da scrivere sui dischetti

View File

@ -1,7 +1,6 @@
#include <applicat.h>
#include <printer.h>
#include <printwin.h>
#include <xvtility.h>
HIDDEN int LEN_SPACES(WINDOW win, int x)
{
@ -13,7 +12,7 @@ HIDDEN int LEN_SPACES(WINDOW win, int x)
}
if (w == 0L)
{
TString256 spc; spc.fill('m', 132);
const TString spc(132, 'm');
w = xvt_dwin_get_text_width(win,(char*)(const char*)spc, 132);
}
const int k = int((w*x) / 132);
@ -22,7 +21,7 @@ HIDDEN int LEN_SPACES(WINDOW win, int x)
static bool error_on = TRUE;
if (error_on)
{
TString256 spc; spc.fill('m', x);
TString spc(x, 'm');
const int k1 = xvt_dwin_get_text_width(win,(char*)(const char*)spc,x);
if (k != k1)
error_on = error_box("Maguire disagrees: %d != %d", k, k1);
@ -183,16 +182,12 @@ void TPrintwin::paint_row(long j)
const char* cp;
while((cp = _txt.piece()) != NULL)
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
const int st = _txt.get_style();
set_font(printer().fontname(), st, _char_size);
const COLOR bg = trans_color(_txt.get_background());
const COLOR fg = trans_color(_txt.get_foreground());
set_color(fg, bg);
#else
set_color(COLOR_BLACK, COLOR_WHITE);
#endif
const char* beg = cp;
while (*beg)
@ -217,7 +212,6 @@ void TPrintwin::paint_row(long j)
set_font(printer().fontname(), XVT_FS_NONE, _char_size);
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
// Questa e' la patch per TTY.DRV.
if (j > 0 && (j % _realformlen) == 0)
{
_frlc++;
@ -225,7 +219,7 @@ void TPrintwin::paint_row(long j)
}
else
#endif
xvt_dwin_draw_text(win(), 0, y /* + _frlc_cnst */, (char*)(const char*)_txt.line(j - _frlc), -1);
xvt_dwin_draw_text(win(), 0, y, (char*)(const char*)_txt.line(j - _frlc), -1);
}
}
@ -309,8 +303,12 @@ TPrintwin::TPrintwin(TTextfile& txt)
{
TPrinter& p = printer();
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
_printrcd = p.get_printrcd();
if (!xvt_print_is_valid(_printrcd))
{
_aborted = TRUE;
return;
}
WINDOW prwin = xvt_print_create_win(_printrcd, (char*)(const char*)main_app().title());
if (prwin == NULL_WIN)
@ -319,15 +317,14 @@ TPrintwin::TPrintwin(TTextfile& txt)
return;
}
set_win(prwin);
#endif
_char_size = p.get_char_size();
set_font(p.fontname(), XVT_FS_NONE, _char_size);
LEN_SPACES(win(), -1); // force update
_pagelen = p.formlen();
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
p.set_win_formlen(prwin); // Calcola offset e altre misure pagina
p.init_formlen(prwin); // Calcola offset e altre misure pagina
int abs_column=p.get_column_offset();
int segno = abs_column>=0 ? 1 : -1;
@ -337,7 +334,6 @@ TPrintwin::TPrintwin(TTextfile& txt)
_chary = p.get_dots_per_line();
_hofs = p.get_horz_offset() + segno*LEN_SPACES(prwin,abs_column);
_vofs = p.get_vert_offset() + p.get_line_offset()*_chary;
#endif
_formlen = p.formlen();
p.formlen(_pagelen);

View File

@ -1,7 +1,4 @@
#include <math.h>
#include <colors.h>
#include <defmask.h>
#include <progind.h>
#include <controls.h>
#include <urldefid.h>
@ -152,7 +149,7 @@ void TIndwin::update_bar()
BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
}
char n[8]; sprintf(n, "%d%%", (int)floor(prc * 100.0 + 0.5));
char n[8]; sprintf(n, "%d%%", int(prc * 100.0 + 0.5));
xvt_dwin_draw_text(w, r.left+r.right/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
check_stop();

View File

@ -1,7 +1,4 @@
#ifndef __REGEXP_H
#include <regexp.h>
#endif
#include <stdlib.h>
// codici di ritorno della matche()
#define regexp_MATCH_PATTERN (6) // pattern non valido

View File

@ -1,15 +1,10 @@
#include <mailbox.h>
#include <msksheet.h>
#include <progind.h>
#include <sheet.h>
#include <msksheet.h>
#include <urldefid.h>
#include <recarray.h>
#include <relapp.h>
#include <utility.h>
#define XVT_INCL_NATIVE
#define STRICT
#include <xvtility.h>
#include <defmask.h>
///////////////////////////////////////////////////////////
// TRelation_application
@ -99,7 +94,7 @@ void TRelation_application::set_limits(
bool TRelation_application::create()
{
bool ok = TApplication::create();
bool ok = TSkeleton_application::create();
if (ok)
ok = user_create();
if (ok)
@ -108,24 +103,15 @@ bool TRelation_application::create()
_mask = get_mask(MODE_QUERY);
filter();
set_limits();
dispatch_e_menu(BAR_ITEM(1));
}
return ok;
}
bool TRelation_application::menu(MENU_TAG m)
{
if (m == BAR_ITEM(1))
return main_loop();
return TRUE;
}
bool TRelation_application::destroy()
{
user_destroy();
return TApplication::destroy();
return TSkeleton_application::destroy();
}
@ -846,7 +832,7 @@ bool TRelation_application::firm_change_enabled() const
return ok;
}
bool TRelation_application::main_loop()
void TRelation_application::main_loop()
{
_recins = -1;
@ -1009,8 +995,10 @@ bool TRelation_application::main_loop()
_mask->set_mode(NO_MODE);
if (autoins_caller().not_empty() && _recins >= 0)
{
TMessage msg(autoins_caller(), _lnflag ? MSG_LN : MSG_AI, format("%ld", _recins));
{
TString16 num;
num.format("%ld", _recins);
TMessage msg(autoins_caller(), _lnflag ? MSG_LN : MSG_AI, num);
msg.send();
}
@ -1030,8 +1018,6 @@ bool TRelation_application::main_loop()
ini.set("Error", err);
}
}
return k != K_QUIT;
}
bool TRelation_application::filter()
@ -1093,16 +1079,17 @@ bool TRelation_application::filter()
_autoins_caller = msg->from();
_lnflag = TRUE;
TString str, tmp;
const char* v = body.get();
TString80 s;
for (int i = 0; v != NULL && i < _mask->fields(); i++)
{
TMask_field& f = _mask->fld(i);
if (f.active() && f.dlg() > 0 && f.in_key(key))
{
s = v;
_fixed.add(format("%d=%s", f.dlg(), (const char*)s));
str = v;
tmp.format("%d=", f.dlg());
str.insert(tmp, 0);
_fixed.add(str);
v = body.get();
}
}
@ -1163,7 +1150,11 @@ bool TRelation_application::filter()
if (v) val = *v;
if (v)
_fixed.add(format("%d=%s", f.dlg(), (const char*)val));
{
t.format("%d=", f.dlg());
val.insert(t, 0);
_fixed.add(val);
}
}
}
}
@ -1181,6 +1172,7 @@ void TRelation_application::set_link(TMask & m, const char * keyexpr)
const char* v = body.get();
TString16 tmp;
const int max = m.fields();
for (int i = 0; i < max && v != NULL; i++)
{
@ -1188,8 +1180,10 @@ void TRelation_application::set_link(TMask & m, const char * keyexpr)
if (f.active() && f.dlg() > 0 && f.in_key(key))
{
const TString s(v);
_fixed.add(format("%d=%s", f.dlg(), (const char*) s));
TString s(v);
tmp.format("%d=", f.dlg());
s.insert(tmp, 0);
_fixed.add(s);
v = body.get();
}
}
@ -1239,8 +1233,10 @@ bool TRelation_application::parse_command_line()
void TRelation_application::ini2query_mask()
{
if (_transaction.not_empty())
{
TConfig ini(_ini, format("%d", get_relation()->lfile().num()));
{
TString16 parag;
parag.format("%d", get_relation()->lfile().num());
TConfig ini(_ini, parag);
ini2mask(ini, *_mask, TRUE);
}
}
@ -1249,7 +1245,9 @@ void TRelation_application::ini2insert_mask()
{
if (_transaction.not_empty())
{
TConfig ini(_ini, format("%d", get_relation()->lfile().num()));
TString16 parag;
parag.format("%d", get_relation()->lfile().num());
TConfig ini(_ini, parag);
ini2mask(ini, *_mask, FALSE);
}
}

View File

@ -23,7 +23,7 @@
// o piu' archivi utilizzando una relazione
//
// @base public | TApplication
class TRelation_application : public TApplication
class TRelation_application : public TSkeleton_application
// @author:(INTERNAL) Guido
@ -110,10 +110,8 @@ protected:
const TString& autoins_caller() const
{ return _autoins_caller;}
// @cmember Gestisce la barra dei menu' (chiama <mf TRelation_application::main_loop>)
virtual bool menu(MENU_TAG m);
// @cmember Ciclo principale
virtual bool main_loop();
virtual void main_loop();
// @cmember Inizializzazione dei dati dell'utente
virtual bool user_create() pure;

View File

@ -1,6 +1,3 @@
#include <ctype.h>
#include <stdlib.h>
#include <config.h>
#include <expr.h>
#include <extcdecl.h>
@ -9,8 +6,6 @@
#include <sheet.h>
#include <sort.h>
#include <tabutil.h>
#include <utility.h>
#include <xvtility.h>
#include <codeb.h>
// *** check if not already defined
@ -326,7 +321,7 @@ void TRelation::save_status()
for (i = 0; i < _reldefs.items(); i++)
{
const bool first_match = reldef(i)._first_match;
_status.add(format("%d",first_match));
_status.add(first_match);
}
}
@ -930,20 +925,12 @@ HIDDEN bool __evalcondition(const TRelation& r,TExpression* cond, const TArray &
FILE* TCursor::open_index(
bool create) // @parm Indica se creare l'indice nel caso manchi (default FALSE)
{
#if XVT_OS == XVT_OS_SCOUNIX
const char* const r = "r";
const char* const w = "w";
#else
const char* const r = "rb";
const char* const w = "wb";
#endif
if (create && _indexname.empty()) _indexname.temp("ci$$");
FILE* f = fopen(_indexname, create ? w : r);
if (create && _indexname.empty())
_indexname.temp("ci");
FILE* f = fopen(_indexname, create ? "wb" : "rb");
if (f == NULL)
fatal_box("Can't use cursor index for file %d: '%s'\n",
file().filehnd()->ln, (const char*)_indexname);
return f;
}

View File

@ -1,16 +1,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <utility.h>
#include <scanner.h>
HIDDEN const char* strlwr (const char* str)
{
for (char* s = __tmp_string; *str; s++, str++) *s = tolower(*str);
*s = '\0';
return __tmp_string;
}
inline bool string_start(char c)
{ return c == '"' || c == '\'' || c == '{'; }
@ -19,7 +10,7 @@ inline char match(char c)
TScanner::TScanner(const char* filename)
: _pushed(FALSE), _line(0),
_token(128), _key(2), _buffer(1024*16)
_token(128), _key(2), _buffer(1024*16), _tmp(1024*8)
{
setbuf((char*)(const char*)_buffer, _buffer.size());
open(filename, ios::in | ios::nocreate, filebuf::sh_read);
@ -57,9 +48,9 @@ TString& TScanner::line(
do
{
if (!_pushed) _token = "";
getline(__tmp_string, sizeof(__tmp_string), eol);
getline(_tmp.get_buffer(), _tmp.size(), eol);
_line++;
_token << __tmp_string;
_token << _tmp;
_token.trim();
} while (_token.empty() && good() && !eof());
@ -76,8 +67,8 @@ const TString& TScanner::string()
while (isspace(c = get()));
if (string_start(c))
{
getline(__tmp_string, sizeof(__tmp_string), match(c));
_token = __tmp_string;
getline(_tmp.get_buffer(), _tmp.size(), match(c));
_token = _tmp;
}
else
{

View File

@ -23,8 +23,10 @@ class TScanner : public ifstream
TString _token;
// @cmember:(INTERNAL) Chiave del token (prime due lettere)
TString _key;
// @cmember:(INTERNAL) Buffer utilizzato per la lettura della riga da file
// @cmember:(INTERNAL) Buffer utilizzato come buffer dello stream
TString _buffer;
// @cmember:(INTERNAL) Buffer utilizzato per la lettura della riga da file
TString _tmp;
// @cmember:(INTERNAL) Indica se il token e' stato ritornato al file
bool _pushed;
// @cmember:(INTERNAL) Numero della linea in corso di lettura

View File

@ -1,4 +1,5 @@
#include <extcdecl.h>
#include <isam.h>
#include <sort.h>

View File

@ -5,6 +5,8 @@
#include <object.h>
#endif
class TRecfield;
// @doc EXTERNAL
// @class TSort | Classe per l'ordinamento di strutture o di record
@ -13,9 +15,6 @@
class TSort : public TObject
// @author:(INTERNAL) Sandro
{
// @friend TRecfield
friend class TRecfield;
// @access:(INTERNAL) Private Member
// @cmember:(INTERNAL) Puntatore alla struttura di un sort

View File

@ -1,16 +1,12 @@
#include <stdlib.h>
#include <stdio.h>
#define __STDTYPES_CPP
#include <extcdecl.h>
#include <dongle.h>
#include <codeb.h>
#include <applicat.h>
#include <dongle.h>
#include <isam.h>
#include <prefix.h>
#include <codeb.h>
extern isfdptr *openf;
extern isfdptr *ext_files;

View File

@ -2,26 +2,13 @@
#include <direct.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
#include <prefix.h>
#include <regexp.h>
#include <strings.h>
#include <prefix.h>
#include <utility.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <process.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
const TToken_string& empty_string()
{
static TToken_string _ts(1);
@ -1128,7 +1115,7 @@ const TFilename& TFilename::tempdir()
bool ok = TRUE;
_tempdir.lower();
if (!fexist(_tempdir))
if (!_tempdir.exist())
ok = make_dir(_tempdir);
if (ok)
@ -1142,7 +1129,7 @@ const TFilename& TFilename::tempdir()
if (f < 0 || f != _tempdir.len() - theuser.len())
_tempdir << SLASH << theuser;
_tempdir.lower();
if (!fexist(_tempdir))
if (!_tempdir.exist())
ok = make_dir(_tempdir);
}
@ -1210,18 +1197,16 @@ const TFilename& TFilename::temp(
strip("$#*?."); // ... toglie caratteri jolly
const TFixed_string f(prefix);
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (f.find("$$") != -1)
if (f.find("$$") >= 0)
{
NFCHECK("Unsupported metacharacter $$");
/*
char pid[8];
sprintf(pid, "%d", getpid());
pid[3] = '\0';
*this << pid;
*this << pid;
*/
}
#else
if (f.find("$$") != -1) *this << getpid();
if (f.find("##") != -1) *this << getuid();
#endif
}
else
cut(0);

View File

@ -468,6 +468,7 @@ public:
virtual TObject* dup() const;
// @cmember Setta il carattere separatore a s
void separator(char s);
char separator() const { return _separator; }
// @cmember Rimette all'inizio il puntatore
void restart()

View File

@ -1,7 +1,6 @@
#include <execp.h>
#include <tabapp.h>
#include <tabutil.h>
#include <utility.h>
// @cmember Costruttore
Tab_application::Tab_application()
@ -116,10 +115,11 @@ bool Tab_application::user_create()
TFilename rpt;
get_mask_name(rpt);
rpt.ext("rpt");
if (fexist(rpt))
if (rpt.exist())
enable_menu_item(M_FILE_PRINT);
const char* title = _msk->get_caption();
TString title;
_msk->get_caption(title);
set_title(title);
return TRUE;
}

View File

@ -30,8 +30,6 @@
#define STR_FIRMNAME 101
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#define ICO_SEARCH 109
#define ICO_CHECK_ON 110
#define ICO_CHECK_OFF 111
@ -81,7 +79,6 @@
#define BMP_DIR 167
#define BMP_DIRDN 168
#define BMP_FILE 169
#endif
/* @END */
#endif

View File

@ -1,42 +1,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef FOXPRO
#define STRICT
#define XVT_INCL_NATIVE
#include <xvt.h>
#endif
#include <xvtility.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <direct.h>
#include <io.h>
#define F_OK 0
#undef DIRECTORY
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
// @doc EXTERNAL
// @func Permette di rimuovere un file (chiama unlink)
//
// @rdesc Ritorna il risultato dell'operazione
//
// @flag 0 | Se l'operazione ha successo
// @flag -1 | Se l'operazione non e' riuscita. Viene inoltre settata la variabile
// <p errno> con la causa dell'insuccesso
int remove(
const char* path) // @parm Nome del file da eliminare (non valgono i caratteri jolly)
{ return unlink(path); }
#endif
#include <os_dep.h>
#include <strings.h>
#define __UTILITY_CPP
#include <utility.h>
@ -60,13 +25,8 @@ bool fcopy(
{
CHECK(orig && *orig && dest && *dest, "fcopy: Invalid file name");
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
const char* const rflag = "rb";
const char* wflag = append ? "ab" : "wb";
#else
const char* const rflag = "r";
const char* wflag = append ? "a" : "w";
#endif
// Copia il file su se stesso?
if (stricmp(orig, dest) == 0)
@ -110,17 +70,13 @@ bool fcopy(
// @flag TRUE | Se il file esiste
// @flag FALSE | Se il file non esiste
bool fexist(
const char* file) // @parm Nome del file di cui contrallarne l'esistenza
const char* file) // @parm Nome del file di cui contrallare l'esistenza
{
int err = access(file, F_OK);
if (err) // Se la access fallisce provo con la _lopen
{
HFILE hf = _lopen(file, READ);
if (hf != HFILE_ERROR)
{
_lclose(hf);
int err = access(file, 0x00);
if (err) // Se la access fallisce provo con una funzione dipendente dal sistema
{
if (os_file_exist(file))
err = 0;
}
}
return err == 0;
}
@ -153,12 +109,7 @@ long fsize(const char* name)
bool make_dir(
const char* dir) // @parm Nome della directory da creare
{
int res =
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
mkdir(dir);
#else
mkdir(dir, 0777);
#endif
int res = mkdir(dir);
return res == 0;
}
@ -178,7 +129,6 @@ int list_files(
// @comm Per comodita' la lista desiderata vine anch'essa messa in <p filelist> in quanto e'
// gia' costruita
{
TWait_cursor hourglass;
TFilename dir(filelist);
for (int i = dir.len()-1; i >= 0; i--)
if (dir[i] == '/' || dir[i] == '\\' || dir[i] == ':') break;
@ -256,7 +206,6 @@ const char* cmd2name(
app = app.name();
if (argv1 && *argv1)
app << ' ' << argv1;
// else app << " -0";
else
{
const char* space = strchr(argv0, ' ');
@ -463,21 +412,3 @@ const char * decode(
return __tmp_string;
}
os_type get_os_type()
{
#if XVT_OS == XVT_OS_WIN
const WORD winver = LOWORD(GetVersion());
const BYTE majver = LOBYTE(winver);
const BYTE minver = HIBYTE(winver);
if (majver > 3 || (majver == 3 && minver > 11))
return os_Windows95;
const DWORD winflags = GetWinFlags();
if (winflags & 0x4000)
return os_WindowsNT;
return os_Windows;
#else
// #error Ricordati di Win32
return os_WindowsNT;
#endif
}

View File

@ -1,10 +1,12 @@
#ifndef __UTILITY_H
#define __UTILITY_H
#ifndef __STRINGS_H
#include <strings.h>
#ifndef __STDTYPES_H
#include <stdtypes.h>
#endif
class TString_array;
char* format (const char* fmt, ...);
const char* cmd2name(const char* argv0, const char* argv1 = "");
int rtoi(const char * roman);
@ -13,9 +15,6 @@ bool fcopy(const char* orig, const char* dest, bool append=FALSE);
bool fexist(const char* file);
long fsize(const char* file);
enum os_type { os_Windows, os_Win32s, os_Windows95, os_WindowsNT };
os_type get_os_type();
bool make_dir(const char* file);
int list_files(const char* mask, TString_array& result);
@ -34,13 +33,6 @@ inline bool is_not_slash(
char s) // @parm Carattere da confrontare
{ return s != '\\' && s != '/'; }
#if XVT_OS == XVT_OS_SCOUNIX
int stricmp(const char*, const char*);
#endif
#ifdef __WATCOMC__
char * tempnam(const char * dir, const char * prefix);
#endif
const char* esc(const char*);
#define ODD(x) (x & 1)

View File

@ -1,6 +1,3 @@
#include <stdlib.h>
#include <ctype.h>
#include <expr.h>
#include <isam.h>
#include <mask.h>

View File

@ -1,8 +1,5 @@
#include <varrec.h>
#ifndef __RELATION_H
#include <relation.h>
#endif
#include <varrec.h>
TVariable_field::TVariable_field(
const char * name, //

View File

@ -1,6 +1,3 @@
#define XVT_INCL_NATIVE
#define STRICT
#include <browfile.h>
#include <colors.h>
#include <config.h>
@ -11,14 +8,13 @@
#include <printapp.h>
#include <urldefid.h>
#include <viswin.h>
#include <xvtility.h>
#include <bagn005.h>
const char* const PRINT_FONT = XVT_FFN_FIXED;
const int PRINT_HEIGHT = 10;
#define BUTTONROW_SIZE (_showbuts ? 3 : 0)
#define BUTTONROW_SIZE (_showbuts ? 4 : 0)
#define X_OFFSET (_rulers ? 6 : 1)
#define Y_OFFSET (_rulers ? 1 : 0)
#define TEXTROWS (rows() - Y_OFFSET - BUTTONROW_SIZE)
@ -101,14 +97,18 @@ void TViswin::check_menu_item(
// @flag TRUE | Viene abilitata la voce
// @flag TRUE | Viene disabilitata la voce
{
ignore_xvt_errors(TRUE);
xvt_menu_set_item_checked(win(), item, on);
xvt_menu_update(win());
ignore_xvt_errors(FALSE);
}
void TViswin::enable_menu_item(MENU_TAG item, bool on)
{
{
ignore_xvt_errors(TRUE);
xvt_menu_set_item_enabled(win(), item, on);
xvt_menu_update(win());
ignore_xvt_errors(FALSE);
}
HIDDEN _BkMenuItem* find_menu_node(TArray& tree, int id)
@ -589,10 +589,6 @@ TPushbutton_control* TViswin::add_button (
{
TPushbutton_control* b = new TPushbutton_control(win(), id, -11, -1, 11, 2, "",
caption, bup, bdn);
// ridimensiona sempre uguale dato che sono tutte bitmap
RCT br; b->get_rect(br);
br.top = br.bottom - taby(2);
b->set_rect(br);
_button.add(b);
return b;
}
@ -600,25 +596,32 @@ TPushbutton_control* TViswin::add_button (
void TViswin::repos_buttons ()
{
if (_toplevel)
{
{
RCT wr; xvt_vobj_get_client_rect(win(), &wr);
const int bar_h = BUTTONROW_SIZE * CHARY;
const int bar_y = wr.bottom - bar_h + 1;
for (int i = 0; i < _modules.items(); i++)
((TImage&)_modules[i]).set_pos(4, 4+int(rows()-BUTTONROW_SIZE)*CHARY);
{
TImage& image = (TImage&)_modules[i];
const int iy = bar_y + (bar_h - image.height()) / 2;
image.set_pos(4, iy);
}
const int buttons = _button.items();
if (buttons > 0)
{
RCT br; ((TPushbutton_control&)_button[0]).get_rect(br);
const short width = br.right - br.left;
RCT wr; xvt_vobj_get_client_rect(win(), &wr);
int space = ((wr.right - wr.left) - buttons * (br.right-br.left)) / (buttons + 1);
const int by = bar_y + (bar_h - br.bottom + br.top) / 2;
const int width = br.right - br.left;
int space = ((wr.right - wr.left) - buttons * width) / (buttons + 1);
if (space < 0)
space = 0;
int x = space;
const int y = (wr.bottom - wr.top) - (br.bottom - br.top) - 8;
for (int b = 0; b < buttons; b++)
{
const PNT p = { y, x };
const PNT p = { by, x };
xvt_rect_set_pos(&br, p);
((TPushbutton_control&)_button[b]).set_rect(br);
x += space + width;
@ -1153,9 +1156,8 @@ void TViswin::paint_selection ()
// @doc INTERNAL
// @mfunc Disegna la barra di attesa
void TViswin::paint_waitbar (
bool xor) // @parm Utilizzato in UNIX. (default TRUE)
// @mfunc Disegna la pagina che scorre
void TViswin::paint_waitbar()
{
HIDDEN int pic = 0;
((TImage&)_modules[pic]).draw(win());
@ -1206,7 +1208,7 @@ void TViswin::update ()
// if (_showbuts)
// bar ((X_OFFSET -1), rows()-BUTTONROW_SIZE, columns() + 1, rows() + 1); //**
if (_showbuts && _isopen)
paint_waitbar (FALSE);
paint_waitbar();
else
if (_showbuts) ((TImage&)_modules[4]).draw(win());
autoscroll (TRUE);
@ -1238,17 +1240,10 @@ void TViswin::scroll_error(long x, long y)
{
beep();
update_thumb(x, y);
POINT p; GetCursorPos(&p);
if (x < 0) p.x -= 16;
if (y < 0) p.y -= 16;
SetCursorPos(p.x, p.y);
}
void TViswin::on_button(short dlg)
{
// if (ep->v.ctl.ci.type == WC_PUSHBUTTON)
switch (dlg)
{
case DLG_QUIT:

View File

@ -206,9 +206,8 @@ protected:
virtual void paint_column(long c, bool end);
// @cmember Disegna in xor la selezione corrente a meno che non sia gia' disegnata
void paint_selection();
// @cmember Controlla l'immagine di 'busy'; xor serve solo per UNIX, dove si
// disegna una barra che viene cancellata alla prossima paint.
void paint_waitbar(bool xor = TRUE);
// @cmember Disegna una pagina che scorre.
void paint_waitbar();
// @cmember Permette di stampare il bakcground di riga <p row> e colonna <p col>
void paint_background(long, int);
// @cmember Chiama l'editor selezionato nel file PRASSI.INI. Ritorna il risultato della

View File

@ -1,17 +1,14 @@
#define XVT_INCL_NATIVE
#define STRICT
#define XI_INTERNAL
#include <xinclude.h>
#include <applicat.h>
#include <checks.h>
#include <colors.h>
#include <os_dep.h>
#include <urldefid.h>
#include <utility.h>
#define __WINDOW_CPP
#include <window.h>
#include <colors.h>
#include <window.h>
#include <xvtility.h>
HIDDEN MENU_ITEM* find_menu_item(MENU_ITEM* menu, MENU_TAG id, bool ismbar)
{
@ -177,18 +174,6 @@ HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
{
while (m->tag)
{
/*
switch(m->tag)
{
case MENU_FILE: // Leave it as is
case M_FONT:
case M_DEFAULT_SEPARATOR:
break;
default:
xvt_menu_set_item_enabled(TASK_WIN, m->tag, on);
break;
}
*/
if (m->tag > BAR_ITEM(0) && m->tag < BAR_ITEM(16))
xvt_menu_set_item_enabled(TASK_WIN, m->tag, on);
m++;
@ -545,7 +530,6 @@ void TImage::convert_transparent_color(COLOR transparent)
}
}
///////////////////////////////////////////////////////////
// TWindow
///////////////////////////////////////////////////////////
@ -775,27 +759,16 @@ void TWindow::set_focus()
}
}
void TWindow::iconize() const
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
HWND hwnd = (HWND)xvt_vobj_get_attr(win(), ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_MINIMIZE);
#endif
os_iconize_window(win());
}
void TWindow::maximize() const
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
HWND hwnd = (HWND)xvt_vobj_get_attr(win(), ATTR_NATIVE_WINDOW);
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
#else
RCT r; xvt_rect_set(&r, 1,1,79,23);
xvt_vobj_move(win(),&r);
#endif
os_maximize_window(win());
}
void TWindow::set_background_color(COLOR col)
{
XI_OBJ* itf = xi_get_itf(win());
@ -822,10 +795,10 @@ void TWindow::set_caption(const char* title)
}
const char* TWindow::get_caption() const
const char* TWindow::get_caption(TString& str) const
{
char* title = &__tmp_string[512];
xvt_vobj_get_title(win(), title, 80);
char* title = str.get_buffer(128);
xvt_vobj_get_title(win(), title, str.size());
return title;
}
@ -1043,14 +1016,14 @@ void TWindow::printat(
const char* fmt, // @parm Formato che deve essere dato al testo
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
{
char tmp[128];
va_list argptr;
va_start(argptr, fmt);
vsprintf(__tmp_string, fmt, argptr);
va_start(argptr, fmt);
vsprintf(tmp, fmt, argptr);
va_end(argptr);
stringat(x, y, __tmp_string);
stringat(x, y, tmp);
}
void TWindow::line(short x0, short y0, short x1, short y1)
{
PNT f = log2dev(x0,y0);

View File

@ -1,18 +1,14 @@
#ifndef __WINDOW_H
#define __WINDOW_H
#ifndef __OBJECT_H
#include <object.h>
#endif
#ifndef __STRINGS_H
#include <strings.h>
#endif
#ifndef __XVTILITY_H
#include <xvtility.h>
#endif
#ifndef __STRINGS_H
class TString_array;
#endif
void close_all_dialogs();
bool can_close();
WINDOW cur_win();
@ -33,16 +29,16 @@ struct TPoint
TPoint(long sx = 0, long sy = 0) : x(sx), y(sy)
{}
// @cmember Costruttore (occorre passare il punto)
TPoint(PNT pnt) : x(pnt.h/CHARX), y(pnt.v/CHARY)
{}
TPoint(const PNT& pnt)
{ set(pnt); }
// @cmember Setta le coordinate x e y del punto
void set(long sx, long sy)
{ x = sx; y = sy; }
// @cmember Setta le coordinate x e y del punto
void set(PNT pnt)
void set(const PNT& pnt)
{ x = pnt.h/CHARX; y = pnt.v/CHARY; }
// @cmember Operatore di assegnamento tra punti
TPoint& operator= (PNT pnt)
TPoint& operator= (const PNT& pnt)
{ set(pnt); return *this; }
// @cmember Operatore di assegnamento tra punti
TPoint& operator= (TPoint pnt)
@ -290,7 +286,7 @@ public:
// @cmember Permette di settare il titolo della finestra
virtual void set_caption(const char* title);
// @cmember Ritorna il titolo della finestra
virtual const char* get_caption() const;
virtual const char* get_caption(TString& str) const;
// @cmember Riempie la finestra con il colore <p color>
void clear(COLOR color);

View File

@ -1,32 +1,29 @@
#define XVT_INCL_NATIVE
#include <applicat.h>
#include <colors.h>
#include <config.h>
#include <controls.h>
#include <mask.h>
#include <urldefid.h>
#include <utility.h>
#include <os_dep.h>
#include <statbar.h>
#if XVT_OS == XVT_OS_SCOUNIX
extern "C" { long nap(long period); }
#endif
short CHARX = 8;
short CHARY = 14;
short ROWY = -CHARY; // Not so good!
short BASEY = 12;
// ERROR HOOK che intercetta errori XVT
// put breakpoint here
static bool _ignore_errors = FALSE;
HIDDEN bool _ignore_xvt_errors = FALSE;
void ignore_xvt_errors(bool ie)
{
_ignore_errors = ie;
_ignore_xvt_errors = ie;
}
BOOLEAN error_hook(XVT_ERRMSG err, DATA_PTR)
{
if (_ignore_errors)
if (_ignore_xvt_errors)
return TRUE;
const XVT_ERRSEV sev = xvt_errmsg_get_sev_id(err);
#ifdef DBG
@ -36,247 +33,6 @@ BOOLEAN error_hook(XVT_ERRMSG err, DATA_PTR)
#endif
}
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#ifndef ATTR_WIN_USE_CTL3D
#include <ctl3d.h>
#endif
#endif
HIDDEN HINSTANCE HInstance;
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
static BOOLEAN event_hook(HWND hwnd,
UINT msg,
UINT wparam,
ULONG lparam,
long* ret)
{
switch(msg)
{
#ifndef ATTR_WIN_USE_CTL3D
case WM_SYSCOLORCHANGE:
Ctl3dColorChange();
break;
#endif
case WM_MENUCHAR:
if (wparam > ' ' && wparam <= 'z')
{
WINDOW win = cur_win();
if (win != NULL_WIN)
{
const KEY key = toupper(wparam)+K_CTRL;
dispatch_e_char(win, key);
*ret = 2 << 8;
}
}
break;
case WM_KEYDOWN:
if (wparam == VK_F1)
{
if ((lparam & (1<<29)) == 0) // Il tasto alt non e' premuto
{
KEY k = K_F1;
int sc = GetAsyncKeyState(VK_CONTROL); // Stato del tasto control
if (sc & 0x8000) k += K_CTRL;
int ss = GetAsyncKeyState(VK_SHIFT); // Stato del tasto shift
if (ss & 0x8000) k += K_SHIFT;
WINDOW win = cur_win();
if (win != NULL_WIN)
dispatch_e_char(win, k);
}
}
break;
default:
if (msg == WM_WAKEUP)
{
if (wparam == main_app().waiting())
main_app().wake_up();
}
break;
}
return TRUE; // Continua col processo normale
}
#if XVT_OS == XVT_OS_WIN
#include <string.h>
#include <ctype.h>
#pragma hdrstop
#include "prochook.h"
#define MAX_PATH 260 // This really should be in WINDOWS.H, but is
// inexplicably hard-coded into the data structures
extern "C" { WINDOW xvtwi_hwnd_to_window(HWND); }
short CHARX = 8;
short ROWY = -GetSystemMetrics(SM_CYSCREEN) / 25; // Not so good!
short CHARY = 14;
short BASEY = 12;
// By Matt Pietrek
//########################################################################
// Code that does the real work
//########################################################################
//
// Central function that modifies a module table to trick the loader
// into letting a second instance of a multiple data segment program run.
//
int MungeModuleHeader( HINSTANCE hInstance, BOOL fMunge )
{
HMODULE hModuleSel;
LPSTR lpszModName, lpszFileName;
BYTE cbModuleName;
static BOOL fResidentNamesMunged = FALSE;
hModuleSel = SELECTOROF( // Convert the HINSTANCE to an HMODULE
GlobalLock(GetModuleHandle((LPSTR)MAKELP(0,hInstance))));
if ( hModuleSel == 0 ) // Make sure we succeeded.
return 0;
//
// First, we'll take care of the resident names table
//
if ( FALSE == fResidentNamesMunged )
{
// Make pointers to the module name in the resident names table
lpszModName = (LPSTR)MAKELP(hModuleSel,
*(WORD FAR *)MAKELP(hModuleSel, 0x26) );
// Get the module name length, and advance to the actual string
cbModuleName = *lpszModName++; // First byte is a length byte
// Convert the first uppercase letter of the modulename to lowercase
while ( cbModuleName )
{
if ( isupper(*lpszModName) )
{
*lpszModName = tolower(*lpszModName); break;
}
cbModuleName--; lpszModName++;
}
if ( cbModuleName == 0 ) // Make sure we succeeded
return 0;
// Remember that we've done this, so that we don't bother doing
// it in the future.
fResidentNamesMunged = TRUE;
}
//
// Now, we'll turn our attention to the module file name in the OFSTRUCT
//
lpszFileName = (LPSTR)MAKELP(hModuleSel,
*(WORD FAR *)MAKELP(hModuleSel, 0x0A));
// Position to the end of the filename. First byte is a length byte
lpszFileName += *lpszFileName - 1;
// If we're munging, added 0x30 to the last character value, otherwise
// subtract 0x30. 0x30 is chosen completely at random.
if ( fMunge )
*lpszFileName += 0x30;
else
*lpszFileName -= 0x30;
return 1;
}
//########################################################################
// This section watches calls to LoadModule and munges the EXE's module
// database as needed.
//########################################################################
HIDDEN NPHOOKCHILD npHookLoadModule = 0;
HIDDEN char szOurFileName[MAX_PATH];
HINSTANCE
WINAPI
__export MultInst95LoadModule( LPCSTR lpszModuleName,
LPVOID lpvParameterBlock )
{
HINSTANCE retValue;
// Uppercase the name of the module name that was passed to LoadModule
char szNewFileName[MAX_PATH];
lstrcpy( szNewFileName, lpszModuleName );
strupr( szNewFileName );
// Compare the incoming filename to our EXE's module name. If they
// don't match, we don't need to bother munging the module database
BOOL fSecondInstance = strstr(szOurFileName, szNewFileName) ? TRUE:FALSE;
// Unhook our LoadModule hook so that we can call the real LoadModule
ProcUnhook( npHookLoadModule );
// Munge module database if needed
if ( fSecondInstance )
MungeModuleHeader( HInstance, TRUE );
// Call the original LoadModule code
retValue = LoadModule( lpszModuleName, lpvParameterBlock );
// Unmunge module database if needed
if ( fSecondInstance )
MungeModuleHeader( HInstance, FALSE );
// Reinstall our LoadModule hook so that we see future loads
ProcHook( npHookLoadModule );
return retValue;
}
BOOL deny_another_instance()
{
if ( !npHookLoadModule )
return FALSE;
SetProcRelease( npHookLoadModule );
npHookLoadModule = 0;
return TRUE;
}
BOOL allow_another_instance()
{
#ifdef DBG
bool noMunge = getenv("NOMUNGE") != NULL;
if (noMunge)
return FALSE;
#endif
if ( npHookLoadModule )
return TRUE;
// Get the EXE's filename into a global string variable and uppercase it
GetModuleFileName( HInstance, szOurFileName, sizeof(szOurFileName) );
strupr( szOurFileName );
// Create a MakeProcInstance thunk so that our callback function
// will always be using the correct DS selector
FARPROC lpfnMPI
= MakeProcInstance( (FARPROC)MultInst95LoadModule, HInstance );
if ( !lpfnMPI )
return FALSE;
// Call PROCHOOK.DLL to hook calls to LoadModule
npHookLoadModule = SetProcAddress( (FARPROC)LoadModule,
lpfnMPI, FALSE );
return (BOOL)npHookLoadModule;
}
#endif
// @doc INTERNAL
// @func Calcola dimensioni e posizione di un controllo contenuto nella finestra
@ -459,9 +215,6 @@ void do_events()
{
xvt_app_process_pending_events();
EM.pop();
#if XVT_OS == XVT_OS_SCOUNIX
nap(20);
#endif
}
// @doc EXTERNAL
@ -511,11 +264,7 @@ void dispatch_e_menu(
// @xref <f dispatch_e_char> <f dispatch_e_scroll>
{
EVENT e; memset(&e, 0, sizeof(e));
e.type = E_COMMAND;
e.v.cmd.tag = item;
e.v.cmd.shift = e.v.cmd.control = 0;
dispatch_event(win, e, TRUE);
os_post_menu_event(win, item);
}
// @doc EXTERNAL
@ -614,34 +363,7 @@ void set_xvt_hooks()
{
xvt_vobj_set_attr(NULL_WIN,ATTR_ERRMSG_HANDLER, (long)error_hook);
xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE);
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
xvt_vobj_set_attr(NULL_WIN, ATTR_EVENT_HOOK, (long)event_hook);
#ifdef ATTR_WIN_USE_CTL3D
xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_USE_CTL3D, TRUE);
#endif
long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE;
const int scx = GetSystemMetrics(SM_CXSCREEN);
if (scx == 640 && get_os_type() == os_Windows95)
{
const int scy = GetSystemMetrics(SM_CYSCREEN);
const int bcx = GetSystemMetrics(SM_CXFRAME);
const int bcy = GetSystemMetrics(SM_CYFRAME);
static RCT rct;
rct.left = -bcx;
rct.top = GetSystemMetrics(SM_CYCAPTION)-bcy-1;
rct.right = scx+bcx;
rct.bottom = scy+bcy;
xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct));
}
else
twin_style |= WSF_MAXIMIZED;
xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, twin_style);
#endif
os_set_event_hook();
}
// @doc INTERNAL
@ -652,27 +374,12 @@ void customize_controls(
{
if (on)
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#ifndef ATTR_WIN_USE_CTL3D
HInstance = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE);
Ctl3dRegister(HInstance);
Ctl3dAutoSubclass(HInstance);
#endif
#endif
customize_colors();
init_controls();
}
else
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#ifndef ATTR_WIN_USE_CTL3D
Ctl3dUnregister(HInstance);
#endif
deny_another_instance();
#endif
os_deny_another_instance();
free_controls();
}
}
@ -785,8 +492,8 @@ WINDOW xvt_create_window(
{
RCT& rect = resize_rect(x, y, dx, dy, wt, parent);
if (wt == WD_MODAL) wt = W_DOC;
if (wt == WD_MODAL)
wt = W_DOC;
WINDOW win = xvt_win_create(wt,
&rect,
(char*)caption,
@ -796,162 +503,9 @@ WINDOW xvt_create_window(
app_data);
CHECK(win, "Can't create a window: XVT error");
#if XVT_OS == XVT_OS_WIN
static bool to_set = TRUE;
HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW);
if (to_set)
{
word style = GetClassWord(hwnd, GCW_STYLE);
style |= CS_BYTEALIGNCLIENT;
SetClassWord(hwnd, GCW_STYLE, style);
to_set = FALSE;
}
#endif
return win;
}
// @doc INTERNAL
// @func Permette di creare i controlli all'interno di una finestra
//
// @rdesc Ritorna la finestra del controllo
WINDOW xvt_create_control(
WIN_TYPE wt, // @parm Tipo di controllo da creare
short x, // @parm Coordinata x del control
short y, // @parm Coordinata y del control
short dx, // @parm Larghezza della control
short dy, // @parm Altezza della control
const char* caption, // @parm Titolo da assegnare alla control
WINDOW parent, // @parm Identificatore della finestra padre
long flags, // @parm Attributi della finestra
long app_data, // @parm Puntatore alla classe C++ che gestisce la finestra
int id) // @parm Indentificatore del controlllo
{
RCT r = resize_rect(x, y, dx, dy, wt, parent);
while (*caption == '@') caption += 2;
WINDOW win = xvt_ctl_create(wt, &r, (char*)caption, parent,
flags, app_data, id);
if (win == NULL_WIN)
fatal_box("Can't create control %d: '%s'", id, caption);
return win;
}
// @doc INTERNAL
// @func Restituisce il titolo della finestra
//
// @rdesc Stringa contenente il titolo della finestra
const char* xvt_get_title(
WINDOW win) // @parm Finestra della quale si vuole conoscere il titolo
// @xref <f xvt_set_title>
{
xvt_vobj_get_title(win, __tmp_string, 80);
return __tmp_string;
}
// @doc INTERNAL
// @func Permette di assegnare il titolo ad una finestra
void xvt_set_title(
WINDOW win, // @parm Finestra a cui assegnare il titolo
const char* cap) // @parm Titolo da assegnare
// @xref <f xvt_get_title>
{
xvt_vobj_set_title(win, (char*)cap);
}
// @doc INTERNAL
// @func Permette di abilitare il focus su un controllo
void xvt_set_front_control(
WINDOW win) // @parm Finestra nella quale abilitare il focus
{
xvt_scr_set_focus_vobj(win);
}
// @doc INTERNAL
// @func Permette di togliere il focus da un controllo
void xvt_kill_focus(
WINDOW win) // @parm Finestra nella quale togliere il focus
{
}
// @doc INTERNAL
// @func Permette di abilitare o disabilitare un controllo
void xvt_enable_control(
WINDOW win, // @parm Finestra all'interno della quale abilitare il controllo
bool on) // @parm Abilita (TRUE) o disabilita (FALSE) il controllo
{
xvt_vobj_set_enabled(win, on);
}
// @doc INTERNAL
// @func Permette di gestire un check box all'interno di una finestra
void xvt_check_box(
WINDOW win, // @parm Finestra all'interno della quale abilitare il check box
bool on) // @parm Permette di inizializzare (TRUE) o scaricare (FALSE) i parametri
{
xvt_ctl_set_checked(win, on);
}
// @doc INTERNAL
// @func Permette di controllare se un controllo e' stato selezionato
//
// @rdesc Ritorna i seguenti valori:
//
// @flag TRUE | Se il controllo e' stato selezionato
// @flag FALSE | Se il controllo non e' stato selezionato
bool xvt_get_checked_state(
WINDOW win) // @parm Finestra di cui si vuole conoscere lo stato
{
return xvt_ctl_is_checked(win) ? TRUE : FALSE;
}
// @doc INTERNAL
// @func Permette di gestire un radio button all'interno di una finestra
void xvt_check_radio_button(
WINDOW win, // @parm Finestra all'interno della quale abilitare il radio button
const WINDOW* ctls, // @parm Array di stringhe contenenti le scelte del radiobutton
int count) // @parm Numero di elementi del radiobutton
{
xvt_ctl_check_radio_button(win, (WINDOW*)ctls, count);
}
// @doc INTERNAL
// @func Permette di controllare lo stato di un radiobutton
//
// @rdesc Ritorna il numero dell'elemento del radiobutton selezionato
int xvt_get_checked_radio(
const WINDOW* ctls, // @parm Array di stringhe contenenti le scelte del radiobutton
int count) // @parm Numero di elemnti del radiobutton
{
return 0;
}
// @doc INTERNAL
// @func Permette di cambiare il colore di sfondo di un controllo
void xvt_set_ctrl_back_color(
WINDOW win, // @parm Finestra di cui si vuole cambiare lo sfondo
COLOR col) // @parm Colore dello sfondo
{
}
///////////////////////////////////////////////////////////
// Gestione Status bar
///////////////////////////////////////////////////////////
@ -964,12 +518,10 @@ HIDDEN WINDOW _statbar = NULL_WIN;
//
// @rdesc Ritorna l'identificatore della barra di stato creata
WINDOW xvt_create_statbar()
// @xref <f xvt_statbar_set> <f xvt_statbar_refresh>
// @xref <f xvt_statbar_set> <f xvt_statbar_refresh>
{
CHECK(_statbar == NULL_WIN, "Onli uan statbar, plis");
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
const int prop_count = 4;
char* prop_list[prop_count+1] =
{
@ -978,16 +530,13 @@ WINDOW xvt_create_statbar()
"TASK_WIN",
"FIELD_OFFSET=24",
NULL
};
};
_statbar = statbar_create(0, 0, 600, 1024, 800, prop_count, prop_list,
TASK_WIN, 0, 0, "");
CHECK(_statbar, "Can't create the status bar");
statbar_set_fontid(_statbar, xvt_default_font());
#endif
return _statbar;
}

View File

@ -29,9 +29,6 @@ WINDOW xvt_create_window
long app_data
);
int allow_another_instance();
int deny_another_instance();
WINDOW xvt_create_statbar();
void xvt_statbar_set(const char* text, bool def = FALSE);
void xvt_statbar_refresh();