Patch level : 2.0 476

Files correlati     : xvagaa.dll
Ricompilazione Demo : [ ]
Commento            :
Modifiche per Linux


git-svn-id: svn://10.65.10.50/trunk@11172 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2003-05-22 15:25:25 +00:00
parent 6055e4ab1a
commit 9d7cb84959
13 changed files with 1471 additions and 896 deletions

View File

@ -1,7 +1,10 @@
#include "wxinc.h"
#include <fstream.h>
#ifdef LINUX
#include "xvt_type.h"
#endif
#include "agasys.h"
///////////////////////////////////////////////////////////
@ -9,7 +12,7 @@
///////////////////////////////////////////////////////////
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include <wx/zipstrm.h>
#pragma pack(2)
@ -35,7 +38,7 @@ struct ZipDirectoryFileHeader
unsigned short nStartDisk;
unsigned short nInternalAttr;
unsigned long nExternalAttr;
unsigned long nLocalHeaderOffset;
unsigned long nLocalHeaderOffset;
};
struct ZipDirectoryEnd
@ -44,8 +47,8 @@ struct ZipDirectoryEnd
unsigned short nStartDisk;
unsigned short nDiskEntries;
unsigned short nTotalEntries;
unsigned long nSize;
unsigned long nStartOffset;
unsigned long nSize;
unsigned long nStartOffset;
unsigned short nCommentLength;
};
@ -102,7 +105,7 @@ bool aga_unzip(const char* zipfile, const char* destdir)
strOutFile += '/';
strOutFile += strFileName;
wxString strPath;
wxString strPath;
::wxSplitPath(strOutFile, &strPath, NULL, NULL);
if (!::wxDirExists(strPath))
::wxMkdir(strPath);
@ -168,7 +171,7 @@ static int AddFilesToList(const wxString& strBase, const wxString& strMask, wxSt
return n;
}
static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
wxFileOutputStream& fout, wxFileOutputStream& fdir)
{
if (!wxFileExists(strFile))
@ -182,7 +185,7 @@ static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
if (!strRelName.IsEmpty())
strRelName += '/';
strRelName += strName;
strRelName += '.';
strRelName += '.';
strRelName += strExt;
const off_t nStartPos = fout.TellO(); // Memorizzo posizione
@ -190,11 +193,11 @@ static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
const unsigned long dwLocalSignature = 0x04034B50;
fout.Write(&dwLocalSignature, sizeof(dwLocalSignature)); // Scrivo PK34
ZipLocalFileHeader zlfh; memset(&zlfh, 0, sizeof(zlfh));
zlfh.nVersionNeeded = 20; // You need at least pkunzip 2.0
zlfh.nFlags = 0x0002; // Deep Hacking ???
zlfh.nVersionNeeded = 20; // You need at least pkunzip 2.0
zlfh.nFlags = 0x0002; // Deep Hacking ???
zlfh.nMethod = 8; // Implode
zlfh.nNameLength = strRelName.Length();
fout.Write(&zlfh, sizeof(zlfh)); // Scrivo header azzerato
fout.Write(&zlfh, sizeof(zlfh)); // Scrivo header azzerato
fout.Write((const char*)strRelName, zlfh.nNameLength); // Scrivo nome file
const off_t nDataStart = fout.TellO(); // Memorizzo posizione dati compressi
@ -203,14 +206,14 @@ static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
{
wxFileInputStream fin(strFile);
AgaZlibOutputStream zout(fout);
zout.Write(fin); // Scrivo file compresso
zout.Write(fin); // Scrivo file compresso
zlfh.dwUncompressedSize = fin.TellI();
}
fout.SeekO(nMagicOffset, wxFromEnd);
zlfh.dwCompressedSize = fout.TellO();
zlfh.dwCompressedSize -= nDataStart;
zlfh.dwCompressedSize = fout.TellO();
zlfh.dwCompressedSize -= nDataStart;
zlfh.dwCRC = ComputeFileCRC32(strFile);
const time_t tMod = ::wxFileModificationTime(strFile);
@ -232,7 +235,7 @@ static void AddFileToZip(const wxString& strPrefix, const wxString& strFile,
fout.SeekO(nMagicOffset, wxFromEnd);
ZipDirectoryFileHeader zdfh; memset(&zdfh, 0, sizeof(zdfh));
zdfh.nVersionUsed = zlfh.nVersionNeeded;
zdfh.nVersionUsed = zlfh.nVersionNeeded;
memcpy(&zdfh.zlfh, &zlfh, sizeof(zlfh));
zdfh.nLocalHeaderOffset = nStartPos;
@ -304,7 +307,7 @@ bool aga_zip_filelist(const char* filelist, const char* zipfile)
ifstream fin(filelist);
while (!fin.eof())
{
char name[MAX_PATH];
char name[_MAX_PATH];
fin.getline(name, sizeof(name));
if (*name)
aFiles.Add(name);

View File

@ -8,7 +8,7 @@
#define XVTDLL __declspec(dllimport)
#endif
#else
#define
#define XVTDLL
#endif
XVTDLL bool aga_unzip(const char* zipfile, const char* destdir);

261
xvaga/oslinux.cpp Executable file
View File

@ -0,0 +1,261 @@
#include "wxinc.h"
#include "wx/print.h"
#include "wx/printdlg.h"
#include "xvt.h"
#include "oslinux.h"
#include "xvt_menu.h"
#include "xvt_help.h"
#include "xvintern.h"
#include <wx/fontenum.h>
#include <wx/string.h>
#include <wx/snglinst.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mntent.h>
#include <sys/vfs.h>
wxString OsLinux_File2App(const char* filename)
{
wxString app;
SORRY_BOX();
return app;
}
int OsLinux_EnumerateFamilies(char** families, int max_count)
{
wxFontEnumerator ef;
ef.EnumerateFacenames();
wxArrayString * fonts = ef.GetFacenames();
size_t items = fonts->GetCount();
size_t i;
for (i = 0; i < items; i++)
strcpy(families[i], (*fonts)[i].c_str());
return items;
}
int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int max_count)
{
int i = 0;
TFontId f;
wxPrinter printer;
wxPostScriptDC dc(printer.GetPrintDialogData().GetPrintData());
f.SetFaceName(name);
for (int size = 7; size < 80; size++)
{
f.SetPointSize(size);
if (f.Font((wxDC *) &dc).Ok())
sizes[i++] = size;
}
return i;
}
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent)
{
SORRY_BOX();
}
void OsLinux_UpdateWindow(unsigned int handle)
{
SORRY_BOX();
}
///////////////////////////////////////////////////////////
// Hardlock Support
///////////////////////////////////////////////////////////
#include "hlapi_c.h"
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password)
{
int err = HL_LOGIN(address, LOCAL_DEVICE, (unsigned char*)label, (unsigned char*)password);
return err == STATUS_OK;
}
bool OsLinux_HL_Logout()
{
HL_LOGOUT();
return TRUE;
}
bool OsLinux_HL_Read(unsigned short reg, unsigned short* data)
{
int err = HL_READ(reg, data);
return err == STATUS_OK;
}
bool OsLinux_HL_ReadBlock(unsigned char* data)
{
int err = HL_READBL(data);
return err == STATUS_OK;
}
bool OsLinux_HL_Write(unsigned short reg, unsigned short data)
{
int err = HL_WRITE(reg, data);
return err == STATUS_OK;
}
bool OsLinux_HL_Crypt(unsigned short* data) // Array di 4 words (8 bytes)
{
int err = HL_CODE(data, 1);
return err == STATUS_OK;
}
///////////////////////////////////////////////////////////
// Eutron Smartlink Support
///////////////////////////////////////////////////////////
#include "skeylink.h"
static KEY_NET _eutron_key;
static short smartlink(KEY_NET * key)
{
SKEY_DATA skey;
int i;
skey.lpt = key->lpt;
skey.command = key->command;
for (i = 0; i < LABEL_LENGTH; i++)
skey.label[i] = key->label[i];
for (i = 0; i < PASSWORD_LENGTH; i++)
skey.password[i] = key->password[i];
for (i = 0; i < DATA_LENGTH; i++)
skey.data[i] = key->data[i];
skey.fail_counter = key->fail_counter;
skey.status = key->status;
for (i = 0; i < EXTENDED_DATA_LENGTH; i++)
skey.ext_data[i] = key->ext_data[i];
short retval = clink(&skey);
key->lpt = skey.lpt;
key->command = skey.command;
for (i = 0; i < LABEL_LENGTH; i++)
key->label[i] = skey.label[i];
for (i = 0; i < PASSWORD_LENGTH; i++)
key->password[i] = skey.password[i];
for (i = 0; i < DATA_LENGTH; i++)
key->data[i] = skey.data[i];
key->fail_counter = skey.fail_counter;
key->status = skey.status;
for (i = 0; i < EXTENDED_DATA_LENGTH; i++)
key->ext_data[i] = skey.ext_data[i];
return retval;
}
bool OsLinux_SL_Crypt(unsigned short* data)
{
_eutron_key.net_command = NET_KEY_ACCESS;
_eutron_key.command = SCRAMBLING_MODE;
memcpy(_eutron_key.data, data, 8);
smartlink(&_eutron_key);
if (_eutron_key.status == ST_OK)
memcpy(data, _eutron_key.data, 8);
return _eutron_key.status == ST_OK;
}
bool OsLinux_SL_Login(const unsigned char* label, const unsigned char* password)
{
memset(&_eutron_key, 0, sizeof(KEY_NET));
_eutron_key.net_command = NET_KEY_OPEN;
_eutron_key.status = ST_HW_FAILURE; // Don't leave ST_OK = 0 here!
memcpy(_eutron_key.label, label, strlen((const char*)label));
memcpy(_eutron_key.password, password, strlen((const char*)password));
smartlink(&_eutron_key);
return _eutron_key.status == ST_OK;
}
bool OsLinux_SL_Logout()
{
_eutron_key.net_command = NET_KEY_CLOSE;
_eutron_key.command = 0;
smartlink(&_eutron_key);
return true;
}
bool OsLinux_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned short* data)
{
_eutron_key.net_command = NET_KEY_ACCESS;
_eutron_key.command = BLOCK_READING_MODE;
unsigned short* pointer = (unsigned short*)(&_eutron_key.data[0]);
unsigned short* number = (unsigned short*)(&_eutron_key.data[2]);
*pointer = reg;
*number = size;
smartlink(&_eutron_key);
bool ok = _eutron_key.status == ST_OK;
if (ok)
memcpy(data, &_eutron_key.data[4], size*sizeof(unsigned short));
return ok;
}
bool OsLinux_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data)
{
_eutron_key.net_command = NET_KEY_ACCESS;
_eutron_key.command = BLOCK_WRITING_MODE;
unsigned short* pointer = (unsigned short*)(&_eutron_key.data[0]);
unsigned short* number = (unsigned short*)(&_eutron_key.data[2]);
*pointer = reg;
*number = size;
memcpy(&_eutron_key.data[4], data, size*sizeof(unsigned short));
smartlink(&_eutron_key);
return _eutron_key.status == ST_OK;
}
void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type)
{
struct mntent *m;
FILE *f = setmntent("/etc/mnttab", "r");
while ((m = getmntent(f)) && strncmp(path, m->mnt_dir, strlen(m->mnt_dir)) != 0);
if (m)
{
if (dev) strcpy(dev, m->mnt_fsname);
if (dir) strcpy(dir, m->mnt_dir);
if (type) strcpy(type, m->mnt_type);
}
else
{
if (dev) *dev = '\0';
if (dir) *dir = '\0';
if (type) *type = '\0';
}
endmntent(f);
}
bool OsLinux_IsNetworkDrive(const char * path)
{
struct statfs buf;
if (statfs(path, &buf) == -1)
return FALSE;
return (buf.f_type == 0x6969 /*NFS_SUPER_MAGIC */) ||
(buf.f_type == 0x517B /*SMB_SUPER_MAGIC)*/);
}
int64_t OsLinux_GetDiskFreeSpace(const char * path)
{
struct statfs buf;
int64_t nBytes = 0L;
if (statfs(path, &buf) != -1)
{
nBytes = buf.f_bsize;
nBytes *= buf.f_bavail;
nBytes *= 1024;
}
return nBytes;
}

22
xvaga/oslinux.h Executable file
View File

@ -0,0 +1,22 @@
wxString OsLinux_File2App(const char* filename);
int OsLinux_EnumerateFamilies(char** families, int max_count);
int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int max_count);
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
void OsLinux_UpdateWindow(unsigned int handle);
bool OsLinux_HL_Crypt(unsigned short* data);
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password);
bool OsLinux_HL_Logout() ;
bool OsLinux_HL_Read(unsigned short reg, unsigned short* data);
bool OsLinux_HL_ReadBlock(unsigned char* data);
bool OsLinux_HL_Write(unsigned short reg, unsigned short data);
bool OsLinux_SL_Crypt(unsigned short* data);
bool OsLinux_SL_Login(const unsigned char* label, const unsigned char* password);
bool OsLinux_SL_Logout() ;
bool OsLinux_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned short* data);
bool OsLinux_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data);
void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type);
bool OsLinux_IsNetworkDrive(const char * path);
int64_t OsLinux_GetDiskFreeSpace(const char * path);

View File

@ -131,7 +131,7 @@ typedef struct __SKEY_DATA {
#define ST_NET_LOCAL_INIT_ERROR -25 /* Error inizializing the Local protocol */
#define ST_NET_KEY_NOT_MAP -26 /* Not MAP programmed key found when MAP is requested */
/*
/*
Code returned in data[0] after NET_OPEN
*/
#define NET_TYPE_LOCAL 0
@ -172,7 +172,12 @@ typedef struct __KEY_NET {
Call the driver.
Return key->k.status code
*/
#ifdef WIN32
short __cdecl smartlink(KEY_NET*);
#else
int clink(SKEY_DATA *);
#endif
#ifdef __cplusplus
}

View File

@ -2,6 +2,7 @@
#ifndef __WXINC_H__
#define __WXINC_H__
#ifdef WIN32
#define __WINDOWS__
#define __WXMSW__
@ -10,9 +11,14 @@
#define WINVER 0x0400
#define STRICT
#define WXUSINGDLL 1
#include <wx/wxprec.h>
#else
#define _FILE_OFFSET_BITS 64
#define _LARGE_FILES
#define __WXGTK__
#define GTK_NO_CHECK_CASTS
#include <wx/wx.h>
#endif
#include "wx/wxprec.h"
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
#include "..\xvaga\wxinc.h"
#include "../xvaga/wxinc.h"
extern int xvt_main(int argc, char** argv);
extern int xvt_main(int argc, char** argv);
class TMainApp : public wxApp
{

View File

@ -37,13 +37,13 @@ public:
bool operator==(const TFontId& f) const { return IsEqual(f); }
bool operator!=(const TFontId& f) const { return !IsEqual(f); }
TFontId() : m_win(NULL_WIN), m_nSize(0), m_wMask(0) { }
TFontId() : m_nSize(0), m_wMask(0), m_win(NULL_WIN) { }
TFontId(const TFontId& f) : m_win(NULL_WIN) { Copy(f); }
};
class TDC : public wxObject
class TDC : public wxObject
{
wxWindow* _owner;
wxWindow* _owner;
protected:
wxDC* _dc;

View File

@ -2,14 +2,12 @@
#define XVT_INCL_XVT
#ifdef XVT_INCL_NATIVE
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#define STRICT
#include <windows.h>
#endif
#endif
#ifdef WIN32
@ -18,6 +16,7 @@
#else
#define XVTDLL __declspec(dllimport)
#endif
#include <io.h>
#else
#define XVTDLL
#endif
@ -25,7 +24,6 @@
#define XVAGA 1
#include <ctype.h>
#include <io.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@ -162,6 +160,11 @@ XVTDLL BOOLEAN xvt_fsys_is_removable_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_is_network_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_is_fixed_drive(const char* path);
XVTDLL BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize);
XVTDLL BOOLEAN xvt_fsys_mkdir(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_rmdir(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_removefile(const char *pathname);
XVTDLL BOOLEAN xvt_fsys_access(const char *pathname, int mode);
XVTDLL BOOLEAN xvt_fsys_file_exists(const char *pathname);
XVTDLL void xvt_help_close_helpfile(XVT_HELP_INFO hi);
XVTDLL XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags);
@ -255,7 +258,7 @@ XVTDLL void xvt_scr_set_focus_vobj(WINDOW win);
XVTDLL BOOLEAN xvt_slist_add_at_elt(SLIST x, SLIST_ELT e, const char *sx, long data);
XVTDLL int xvt_slist_count(SLIST x);
XVTDLL SLIST xvt_slist_create();
XVTDLL SLIST xvt_slist_create();
XVTDLL void xvt_slist_destroy(SLIST list);
XVTDLL char* xvt_slist_get(SLIST x, SLIST_ELT e, long *datap);
XVTDLL long* xvt_slist_get_data(SLIST_ELT elt);
@ -275,20 +278,20 @@ XVTDLL BOOLEAN xvt_sys_get_user_name(char* name, int maxlen);
XVTDLL BOOLEAN xvt_sys_goto_url(const char* url, const char* action);
XVTDLL BOOLEAN xvt_sys_dongle_server_is_running();
XVTDLL BOOLEAN xvt_sys_find_editor(const char* file, char* editor);
XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
const char* defval, char* value, int maxsize);
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
const char* value);
XVTDLL unsigned long xvt_sys_get_free_memory();
XVTDLL unsigned long xvt_sys_get_free_memory_kb();
XVTDLL int xvt_sys_get_os_version();
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
XVTDLL void xvt_sys_sleep(unsigned long msec);
XVTDLL BOOLEAN xvt_sys_test_network_version();
XVTDLL long xvt_timer_create(WINDOW win, long interval);
XVTDLL void xvt_timer_destroy(long id);
XVTDLL int xvt_sys_get_os_version();
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
XVTDLL void xvt_sys_sleep(unsigned long msec);
XVTDLL BOOLEAN xvt_sys_test_network_version();
XVTDLL void xvt_sys_searchenv(const char *filename, const char *varname, char *pathname);
XVTDLL void xvt_sys_sorry_box(const char * file, int line);
XVTDLL long xvt_timer_create(WINDOW win, long interval);
XVTDLL void xvt_timer_destroy(long id);
XVTDLL void xvt_vobj_destroy(WINDOW win);
XVTDLL long xvt_vobj_get_attr(WINDOW win, long data);
XVTDLL RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp);
@ -309,7 +312,6 @@ XVTDLL void xvt_vobj_set_palet(WINDOW win, XVT_PALETTE palet);
XVTDLL void xvt_vobj_set_title(WINDOW win, char *title);
XVTDLL void xvt_vobj_set_visible(WINDOW win, BOOLEAN show);
XVTDLL void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int npnts);
XVTDLL WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WINDOW parent_win, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data);
XVTDLL long xvt_win_dispatch_event(WINDOW win, EVENT* event_p);
XVTDLL void xvt_win_post_event(WINDOW win, EVENT* event_p); // Added by XVAGA
@ -325,4 +327,6 @@ XVTDLL void xvt_win_trap_pointer(WINDOW win);
}
#endif
#define SORRY_BOX() xvt_sys_sorry_box(__FILE__, __LINE__)
#endif

View File

@ -30,4 +30,4 @@
#define ATTR_WIN_PM_TWIN_STARTUP_RCT (ATTR_WIN_BASE + 11)
#define ATTR_WIN_PM_TWIN_STARTUP_STYLE (ATTR_WIN_BASE + 12)
#define main xvt_main
#define main xvt_main

View File

@ -1,9 +1,19 @@
#ifndef BOOLEAN
#define BOOLEAN short
#endif
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
#ifdef LINUX
#define _MAX_PATH 512
#define _MAX_EXT 6
#define _MAX_DRIVE 6
#define _MAX_DIR 512
#define _MAX_FNAME 512
#endif
typedef unsigned long WINDOW;
typedef unsigned int UNIT_TYPE;
typedef unsigned long ULONG;
@ -29,11 +39,11 @@ typedef unsigned long XVT_FONT_STYLE_MASK;
typedef long PICTURE;
typedef void* XVT_IMAGE;
typedef enum {
XVT_IMAGE_NONE,
XVT_IMAGE_CL8,
typedef enum {
XVT_IMAGE_NONE,
XVT_IMAGE_CL8,
XVT_IMAGE_RGB,
XVT_IMAGE_MONO,
XVT_IMAGE_MONO,
} XVT_IMAGE_FORMAT;
#define XVT_FNTID void*
@ -46,19 +56,19 @@ typedef enum e_display_type {
XVT_DISPLAY_MONO, /* monochromatic display */
XVT_DISPLAY_GRAY_16, /* 16-entry grayscale */
XVT_DISPLAY_GRAY_256, /* 256-entry grayscale */
XVT_DISPLAY_COLOR_16, /* 16-entry color */
XVT_DISPLAY_COLOR_16, /* 16-entry color */
XVT_DISPLAY_COLOR_256, /* 256-entry color */
XVT_DISPLAY_DIRECT_COLOR, /* full color capabilities */
} XVT_DISPLAY_TYPE;
typedef enum {
typedef enum {
XVT_PALETTE_NONE,
XVT_PALETTE_STOCK,
XVT_PALETTE_CURRENT,
XVT_PALETTE_CUBE16,
XVT_PALETTE_CUBE256,
XVT_PALETTE_USER
XVT_PALETTE_NONE,
XVT_PALETTE_STOCK,
XVT_PALETTE_CURRENT,
XVT_PALETTE_CUBE16,
XVT_PALETTE_CUBE256,
XVT_PALETTE_USER
} XVT_PALETTE_TYPE;
typedef enum { /* response from ask fcn */
@ -73,34 +83,34 @@ typedef enum { /* result from file open & save dialogs */
FL_OK, /* OK button clicked */
} FL_STATUS;
typedef struct
{
typedef struct
{
char path[_MAX_DIR];
} DIRECTORY;
typedef struct s_mitem {
typedef struct s_mitem {
MENU_TAG tag; /* menu tag */
char *text; /* text to appear in menu */
short mkey; /* mnemonic */
unsigned enabled: 1; /* enabled? */
unsigned checked: 1; /* checked? */
unsigned checkable: 1; /* checkable? */
unsigned separator: 1; /* separator? */
struct s_mitem *child; /* pointer to submenu */
MENU_TAG tag; /* menu tag */
char *text; /* text to appear in menu */
short mkey; /* mnemonic */
unsigned enabled: 1; /* enabled? */
unsigned checked: 1; /* checked? */
unsigned checkable: 1; /* checkable? */
unsigned separator: 1; /* separator? */
struct s_mitem *child; /* pointer to submenu */
} MENU_ITEM;
#define SZ_FNAME _MAX_FNAME
typedef struct { /* file specification */
DIRECTORY dir; /* directory */
char type[6]; /* file type/extension */
char name[_MAX_FNAME]; /* filename */
char creator[6]; /* file creator */
typedef struct { /* file specification */
DIRECTORY dir; /* directory */
char type[6]; /* file type/extension */
char name[_MAX_FNAME]; /* filename */
char creator[6]; /* file creator */
} FILE_SPEC;
typedef struct
{
{
void* pr;
} PRINT_RCD;
@ -115,42 +125,42 @@ typedef SLIST_ITEM* SLIST_ELT;
typedef struct { SLIST_ELT head; long count; } xvtList;
typedef xvtList* SLIST;
typedef enum { /* drawing (transfer) mode */
M_COPY,
M_OR,
M_XOR,
M_CLEAR,
M_NOT_COPY,
M_NOT_OR,
M_NOT_XOR,
M_NOT_CLEAR
typedef enum { /* drawing (transfer) mode */
M_COPY,
M_OR,
M_XOR,
M_CLEAR,
M_NOT_COPY,
M_NOT_OR,
M_NOT_XOR,
M_NOT_CLEAR
} DRAW_MODE;
typedef enum e_pen_style { /* pen style */
P_SOLID, /* solid */
P_DOT, /* dotted line */
P_DASH /* dashed line */
typedef enum e_pen_style { /* pen style */
P_SOLID, /* solid */
P_DOT, /* dotted line */
P_DASH /* dashed line */
} PEN_STYLE;
typedef enum {
PAT_NONE, /* no pattern */
PAT_HOLLOW, /* hollow */
PAT_SOLID, /* solid fill */
PAT_HORZ, /* horizontal lines */
PAT_VERT, /* vertical lines */
PAT_FDIAG, /* diagonal lines -- top-left to bottom-right */
PAT_BDIAG, /* diagonal lines -- top-right to bottom-left */
PAT_CROSS, /* horizontal and vertical crossing lines */
PAT_DIAGCROSS, /* diagonol crossing lines */
PAT_RUBBER, /* rubber banding */
PAT_SPECIAL
typedef enum {
PAT_NONE, /* no pattern */
PAT_HOLLOW, /* hollow */
PAT_SOLID, /* solid fill */
PAT_HORZ, /* horizontal lines */
PAT_VERT, /* vertical lines */
PAT_FDIAG, /* diagonal lines -- top-left to bottom-right */
PAT_BDIAG, /* diagonal lines -- top-right to bottom-left */
PAT_CROSS, /* horizontal and vertical crossing lines */
PAT_DIAGCROSS, /* diagonol crossing lines */
PAT_RUBBER, /* rubber banding */
PAT_SPECIAL
} PAT_STYLE;
typedef struct { /* color pen tool */
short width; /* width */
PAT_STYLE pat; /* pattern */
PEN_STYLE style; /* style */
COLOR color; /* color */
typedef struct { /* color pen tool */
short width; /* width */
PAT_STYLE pat; /* pattern */
PEN_STYLE style; /* style */
COLOR color; /* color */
} CPEN;
typedef struct
@ -159,265 +169,265 @@ typedef struct
COLOR color;
} CBRUSH;
typedef struct { /* color drawing tools */
CPEN pen; /* color pen */
CBRUSH brush; /* color brush */
DRAW_MODE mode; /* drawing mode */
COLOR fore_color; /* foreground color */
COLOR back_color; /* background color */
BOOLEAN opaque_text; /* is text opaque*/
typedef struct { /* color drawing tools */
CPEN pen; /* color pen */
CBRUSH brush; /* color brush */
DRAW_MODE mode; /* drawing mode */
COLOR fore_color; /* foreground color */
COLOR back_color; /* background color */
BOOLEAN opaque_text; /* is text opaque*/
} DRAW_CTOOLS;
typedef enum { /* scrollbar activity */
SC_NONE, /* nowhere (ignore) */
SC_LINE_UP, /* one line up */
SC_LINE_DOWN, /* one line down */
SC_PAGE_UP, /* previous page */
SC_PAGE_DOWN, /* next page */
SC_THUMB, /* thumb repositioning */
SC_THUMBTRACK /* thumb tracking */
typedef enum { /* scrollbar activity */
SC_NONE, /* nowhere (ignore) */
SC_LINE_UP, /* one line up */
SC_LINE_DOWN, /* one line down */
SC_PAGE_UP, /* previous page */
SC_PAGE_DOWN, /* next page */
SC_THUMB, /* thumb repositioning */
SC_THUMBTRACK /* thumb tracking */
} SCROLL_CONTROL;
typedef enum { /* type of window */
typedef enum { /* type of window */
W_NONE, /* marker for end of WIN_DEF array */
W_DOC, /* document window */
W_PLAIN, /* window with plain border */
W_DBL, /* window with double border */
W_PRINT, /* XVT internal use only */
W_TASK, /* task window */
W_SCREEN, /* screen window */
W_NO_BORDER, /* no border */
W_PIXMAP, /* pixmap */
W_MODAL, /* modal window */
WD_MODAL, /* modal dialog */
WD_MODELESS, /* modeless dialog */
WC_PUSHBUTTON, /* button control */
WC_RADIOBUTTON, /* radio button control */
WC_CHECKBOX, /* check box control */
WC_HSCROLL, /* horizontal scrollbar control */
WC_VSCROLL, /* vertical scrollbar control */
WC_EDIT, /* edit control */
WC_TEXT, /* static text control */
WC_LBOX, /* list box control */
WC_LISTBUTTON, /* button with list */
W_NONE, /* marker for end of WIN_DEF array */
W_DOC, /* document window */
W_PLAIN, /* window with plain border */
W_DBL, /* window with double border */
W_PRINT, /* XVT internal use only */
W_TASK, /* task window */
W_SCREEN, /* screen window */
W_NO_BORDER, /* no border */
W_PIXMAP, /* pixmap */
W_MODAL, /* modal window */
WD_MODAL, /* modal dialog */
WD_MODELESS, /* modeless dialog */
WC_PUSHBUTTON, /* button control */
WC_RADIOBUTTON, /* radio button control */
WC_CHECKBOX, /* check box control */
WC_HSCROLL, /* horizontal scrollbar control */
WC_VSCROLL, /* vertical scrollbar control */
WC_EDIT, /* edit control */
WC_TEXT, /* static text control */
WC_LBOX, /* list box control */
WC_LISTBUTTON, /* button with list */
WC_LISTEDIT, /* edit with field list */
WC_GROUPBOX, /* group box */
WC_TEXTEDIT, /* text edit object */
WC_ICON, /* icon control */
WC_LISTEDIT, /* edit with field list */
WC_GROUPBOX, /* group box */
WC_TEXTEDIT, /* text edit object */
WC_ICON, /* icon control */
WO_TE, /* text edit */
} WIN_TYPE;
typedef enum {
SEV_NONE,
typedef enum {
SEV_NONE,
SEV_WARNING,
SEV_ERROR,
SEV_FATAL,
SEV_ERROR,
SEV_FATAL,
} XVT_ERRSEV;
typedef enum { /* type of scrollbar */
typedef enum { /* type of scrollbar */
HSCROLL, /* horizontal */
VSCROLL, /* vertical */
HVSCROLL, /* either */
HSCROLL, /* horizontal */
VSCROLL, /* vertical */
HVSCROLL, /* either */
} SCROLL_TYPE;
typedef struct s_ctlinfo {
typedef struct s_ctlinfo {
WIN_TYPE type;
WINDOW win;
union {
WIN_TYPE type;
WINDOW win;
union {
struct s_scroll {
struct s_scroll {
SCROLL_CONTROL what;
short pos;
SCROLL_CONTROL what;
short pos;
} scroll;
struct s_edit {
} scroll;
struct s_edit {
BOOLEAN focus_change;
BOOLEAN active;
BOOLEAN focus_change;
BOOLEAN active;
} edit;
struct s_lbox {
} edit;
struct s_lbox {
BOOLEAN dbl_click;
BOOLEAN dbl_click;
} lbox;
struct s_listedit {
} lbox;
struct s_listedit {
BOOLEAN focus_change;
BOOLEAN active;
BOOLEAN focus_change;
BOOLEAN active;
} listedit;
} listedit;
} v;
} v;
} CONTROL_INFO;
typedef struct s_xvt_color_component {
typedef struct s_xvt_color_component {
XVT_COLOR_TYPE type; /* color component being defined */
COLOR color; /* RGB color value */
XVT_COLOR_TYPE type; /* color component being defined */
COLOR color; /* RGB color value */
} XVT_COLOR_COMPONENT;
typedef struct s_win_def {
typedef struct s_win_def {
WIN_TYPE wtype; /* WC_* or WO_* type */
WIN_TYPE wtype; /* WC_* or WO_* type */
RCT rct;
char *text;
UNIT_TYPE units;
XVT_COLOR_COMPONENT * ctlcolors;
union {
RCT rct;
char *text;
UNIT_TYPE units;
XVT_COLOR_COMPONENT * ctlcolors;
union {
struct s_win_def_win { /* WINDOW's */
struct s_win_def_win { /* WINDOW's */
short int menu_rid; /* menu resource id */
MENU_ITEM *menu_p; /* pointer to menu tree */
long flags; /* WSF_* flags */
XVT_FNTID ctl_font_id; /* control font id */
short int menu_rid; /* menu resource id */
MENU_ITEM *menu_p; /* pointer to menu tree */
long flags; /* WSF_* flags */
XVT_FNTID ctl_font_id; /* control font id */
} win;
struct s_win_def_dlg { /* DIALOG's */
struct s_win_def_dlg { /* DIALOG's */
long flags; /* WSF_* flags */
XVT_FNTID ctl_font_id; /* control font id */
long flags; /* WSF_* flags */
XVT_FNTID ctl_font_id; /* control font id */
} dlg;
struct s_win_def_ctl { /* CONTROL's */
struct s_win_def_ctl { /* CONTROL's */
short int ctrl_id;
short int ctrl_id;
short int icon_id; /* for icons only */
long flags; /* CTL_* flags */
XVT_FNTID font_id; /* logical font */
short int icon_id; /* for icons only */
long flags; /* CTL_* flags */
XVT_FNTID font_id; /* logical font */
} ctl;
struct s_win_def_tx { /* text edit objects */
struct s_win_def_tx { /* text edit objects */
unsigned short attrib; /* TX_* flags */
XVT_FNTID font_id; /* logical font */
short margin; /* right margin */
short limit; /* max chars */
short int tx_id; /* text ID */
unsigned short attrib; /* TX_* flags */
XVT_FNTID font_id; /* logical font */
short margin; /* right margin */
short limit; /* max chars */
short int tx_id; /* text ID */
} tx;
} tx;
} v;
} v;
} WIN_DEF;
typedef enum {
E_CREATE, /* creation */
E_DESTROY, /* destruction */
E_FOCUS, /* window focus gain/loss */
E_SIZE, /* resize */
E_UPDATE, /* update */
E_CLOSE, /* close window request */
E_MOUSE_DOWN, /* mouse down */
E_MOUSE_UP, /* mouse up */
E_MOUSE_MOVE, /* mouse move */
E_MOUSE_DBL, /* mouse double click */
E_CHAR, /* character typed */
E_VSCROLL, /* vert. window scrollbar activity */
E_HSCROLL, /* horz. window scrollbar activity */
E_COMMAND, /* menu command */
E_FONT, /* font menu selection */
E_CONTROL, /* control activity */
E_TIMER, /* timer */
E_QUIT, /* application shutdown request */
E_HELP, /* help invoked */
E_USER, /* user defined */
typedef enum {
E_CREATE, /* creation */
E_DESTROY, /* destruction */
E_FOCUS, /* window focus gain/loss */
E_SIZE, /* resize */
E_UPDATE, /* update */
E_CLOSE, /* close window request */
E_MOUSE_DOWN, /* mouse down */
E_MOUSE_UP, /* mouse up */
E_MOUSE_MOVE, /* mouse move */
E_MOUSE_DBL, /* mouse double click */
E_CHAR, /* character typed */
E_VSCROLL, /* vert. window scrollbar activity */
E_HSCROLL, /* horz. window scrollbar activity */
E_COMMAND, /* menu command */
E_FONT, /* font menu selection */
E_CONTROL, /* control activity */
E_TIMER, /* timer */
E_QUIT, /* application shutdown request */
E_HELP, /* help invoked */
E_USER, /* user defined */
} EVENT_TYPE;
typedef struct s_event {
typedef struct s_event {
EVENT_TYPE type;
union {
EVENT_TYPE type;
union {
struct s_mouse {
struct s_mouse {
PNT where;
BOOLEAN shift;
BOOLEAN control;
short button;
PNT where;
BOOLEAN shift;
BOOLEAN control;
short button;
} mouse;
struct s_char {
} mouse;
struct s_char {
XVT_WCHAR ch;
BOOLEAN shift;
BOOLEAN control;
BOOLEAN virtual_key;
unsigned long modifiers;
XVT_WCHAR ch;
BOOLEAN shift;
BOOLEAN control;
BOOLEAN virtual_key;
unsigned long modifiers;
} chr;
BOOLEAN active;
BOOLEAN query;
struct s_scroll_info {
} chr;
BOOLEAN active;
BOOLEAN query;
struct s_scroll_info {
SCROLL_CONTROL what;
short pos;
SCROLL_CONTROL what;
short pos;
} scroll;
struct s_cmd {
} scroll;
struct s_cmd {
MENU_TAG tag;
BOOLEAN shift;
BOOLEAN control;
MENU_TAG tag;
BOOLEAN shift;
BOOLEAN control;
} cmd;
struct s_size {
} cmd;
struct s_size {
short height;
short width;
short height;
short width;
} size;
struct s_efont {
} size;
struct s_efont {
XVT_FNTID font_id;
XVT_FNTID font_id;
} font;
struct s_ctl {
} font;
struct s_ctl {
short id;
CONTROL_INFO ci;
short id;
CONTROL_INFO ci;
} ctl;
struct s_update {
} ctl;
struct s_update {
RCT rct;
RCT rct;
} update;
struct s_timer {
} update;
struct s_timer {
long id;
long id;
} timer;
struct s_user {
} timer;
struct s_user {
long id;
void *ptr;
long id;
void *ptr;
} user;
struct s_help {
} user;
struct s_help {
WINDOW obj;
MENU_TAG tag;
XVT_HELP_TID tid;
WINDOW obj;
MENU_TAG tag;
XVT_HELP_TID tid;
}help;
} v;
} v;
} EVENT;
@ -426,18 +436,18 @@ typedef long (* EVENT_HANDLER) (WINDOW win, EVENT *ep);
typedef BOOLEAN (* XVT_ERRMSG_HANDLER) (XVT_ERRMSG err, DATA_PTR context);
typedef enum { /* std. clipboard format */
CB_TEXT, /* ASCII text */
CB_PICT, /* encapsulated picture */
CB_APPL /* app's own (must have name) */
typedef enum { /* std. clipboard format */
CB_TEXT, /* ASCII text */
CB_PICT, /* encapsulated picture */
CB_APPL /* app's own (must have name) */
} CB_FORMAT;
typedef struct s_xvt_config {
typedef struct s_xvt_config {
short menu_bar_ID; /* task menubar ResID */
short about_box_ID; /* default aboutbox ResID */
char *base_appl_name; /* application's "filename" */
char *appl_name; /* application's name */
char *taskwin_title; /* title for task window */
short menu_bar_ID; /* task menubar ResID */
short about_box_ID; /* default aboutbox ResID */
char *base_appl_name; /* application's "filename" */
char *appl_name; /* application's name */
char *taskwin_title; /* title for task window */
} XVT_CONFIG;

View File

@ -3,7 +3,12 @@
#include "wx/printdlg.h"
#include "xvt.h"
#ifdef WIN32
#include "oswin32.h"
#else
#include "oslinux.h"
#include <fstream.h>
#endif
#include "xvintern.h"
@ -31,9 +36,9 @@ void TPRINT_RCD::SetData(void* data, unsigned int nSize)
}
}
TPRINT_RCD::TPRINT_RCD() : m_size(0)
{
pr = NULL;
TPRINT_RCD::TPRINT_RCD() : m_size(0)
{
pr = NULL;
memset(m_data, 0, sizeof(m_data));
}
@ -71,7 +76,7 @@ bool TwxPrintOut::OnPrintPage(int pageNum)
void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
{
wxDC* dc = GetDC();
wxDC* dc = GetDC();
if (dc != NULL)
delete dc;
@ -80,18 +85,22 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
if (m_prcd == NULL)
{
wxPrinter printer;
#ifdef WIN32
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
#else
dc = new wxPostScriptDC(printer.GetPrintDialogData().GetPrintData());
#endif
}
else
{
wxPrintData data;
#ifdef WIN32
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
#else
data.SetNativeData(prcd->m_data);
#endif
data.ConvertFromNative();
dc = new wxPrinterDC(data);
#else
dc = new wxPostScriptDC(prcd->m_data);
#endif
}
wxSize s = dc->GetPPI();
@ -104,13 +113,13 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
}
TwxPrintOut::TwxPrintOut(TPRINT_RCD* prcd)
{
{
InitDC(prcd);
}
TwxPrintOut::~TwxPrintOut()
{
wxDC* dc = GetDC();
wxDC* dc = GetDC();
if (dc != NULL)
delete dc;
}
@ -127,7 +136,7 @@ wxDC& TPrintDC::GetDC(bool)
return TDC::GetDC(false);
}
TPrintDC::TPrintDC(wxWindow* owner) : TDC(owner)
TPrintDC::TPrintDC(wxWindow* owner) : TDC(owner)
{ }
TPrintDC::~TPrintDC()
@ -139,8 +148,8 @@ TPrintDC::~TPrintDC()
// Printing management :-(((((
///////////////////////////////////////////////////////////
BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* pvr, long* phr)
{
BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* pvr, long* phr)
{
*ph = *pw = *pvr = *phr = 0;
switch (esc_code)
{
@ -163,14 +172,14 @@ BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* p
return TRUE;
}
break;
default:
default:
break;
}
return FALSE;
}
BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
{
BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
{
wxPageSetupDialog dlg((wxWindow*)TASK_WIN);
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
@ -178,79 +187,83 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
// pdd.EnablePrinter(false); // Vieta di cambiare stampante
wxPrintData& data = pdd.GetPrintData();
#ifdef WIN32
#ifdef WIN32
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(rcd->m_data, rcd->m_size));
#else
data.SetNativeData(rcd->m_data);
#endif
data.ConvertFromNative();
#endif
if (dlg.ShowModal() == wxID_OK)
{
#ifdef WIN32
data.ConvertToNative();
void* pHandle = data.GetNativeData();
#ifdef WIN32
unsigned int nSize = 0;
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
rcd->SetData(ptr, nSize);
delete ptr;
#else
rcd->SetData(pHandle, 1024);
rcd->SetData((void *) &data, (unsigned int) sizeof(data));
#endif
return TRUE;
}
return FALSE;
return FALSE;
}
long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array, BOOLEAN *scalable, long max_sizes)
{
long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array, BOOLEAN *scalable, long max_sizes)
{
long size = 1;
size_array[0] = 13;
*scalable = FALSE;
#ifdef WIN32
if (precp != NULL)
{
#ifdef WIN32
TwxPrintOut* po = new TwxPrintOut((TPRINT_RCD*)precp);
size = OsWin32_EnumerateSizes(po->GetDC()->GetHDC(), family, size_array, scalable, max_sizes);
#else
size = OsLinux_EnumerateSizes(family, size_array, scalable, max_sizes);
#endif
}
#endif
return size;
return size;
}
long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_families)
{
long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_families)
{
long size = 1;
family_array[0] = xvt_str_duplicate(XVT_FFN_COURIER);
#ifdef WIN32
if (precp != NULL)
{
#ifdef WIN32
TwxPrintOut* po = new TwxPrintOut((TPRINT_RCD*)precp);
size = OsWin32_EnumerateFamilies(po->GetDC()->GetHDC(), family_array, max_families);
#else
size = OsLinux_EnumerateFamilies(family_array, max_families);
#endif
}
#endif
return size;
return size;
}
void xvt_print_close(void)
{
void xvt_print_close(void)
{
// Nothing to do ?
}
BOOLEAN xvt_print_close_page(PRINT_RCD* /*precp*/)
{
BOOLEAN xvt_print_close_page(PRINT_RCD* /*precp*/)
{
BOOLEAN ok = m_po != NULL;
if (ok)
m_po->GetDC()->EndPage();
return ok;
return ok;
}
PRINT_RCD* xvt_print_create(int *sizep)
{
PRINT_RCD* xvt_print_create(int *sizep)
{
TPRINT_RCD* pr = NULL;
*sizep = 0;
@ -258,19 +271,26 @@ PRINT_RCD* xvt_print_create(int *sizep)
void* data = OsWin32_GetPrinterInfo(*sizep, NULL);
if (data != NULL)
{
pr = new TPRINT_RCD;
pr = new TPRINT_RCD;
pr->SetData(data, *sizep);
*sizep += 4; // Spazio per puntatore iniziale
delete data;
}
#else
wxPrinter printer;
wxPrintData &data = printer.GetPrintDialogData().GetPrintData();
data.SetPrinterName(""); //verificare
pr = new TPRINT_RCD;
pr->SetData((void *) &data, (unsigned int) sizeof(data));
#endif
return pr;
}
// Nuova funzione inventata da Aga
PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
{
PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
{
TPRINT_RCD* pr = NULL;
*sizep = 0;
@ -278,37 +298,45 @@ PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
void* data = OsWin32_GetPrinterInfo(*sizep, name);
if (data != NULL)
{
pr = new TPRINT_RCD;
pr = new TPRINT_RCD;
pr->SetData(data, *sizep);
*sizep += 4; // Spazio per puntatore iniziale
delete data;
}
#else
wxPrinter printer;
wxPrintData &data = printer.GetPrintDialogData().GetPrintData();
wxString PrinterName(name);
data.SetPrinterName(PrinterName); //verificare
pr = new TPRINT_RCD;
pr->SetData((void *) &data, (unsigned int) sizeof(data));
#endif
return pr;
}
WINDOW xvt_print_create_win(PRINT_RCD* precp, char* /* title */)
{
WINDOW xvt_print_create_win(PRINT_RCD* precp, char* /* title */)
{
WINDOW win = NULL_WIN;
if (m_po != NULL)
{
m_po->InitDC((TPRINT_RCD*)precp);
m_po->OnBeginPrinting();
m_po->OnBeginDocument(1, 32000);
win = _print_win;
win = _print_win;
}
return win;
}
void xvt_print_destroy(PRINT_RCD *precp)
{
void xvt_print_destroy(PRINT_RCD *precp)
{
// Nothing to do!
}
RCT* xvt_print_get_next_band(void)
{
RCT* xvt_print_get_next_band(void)
{
static bool yes = false;
static RCT rct;
yes = !yes;
@ -322,30 +350,31 @@ RCT* xvt_print_get_next_band(void)
rct.right = w;
rct.bottom = h;
return &rct;
return &rct;
}
BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
{
BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
{
BOOLEAN ok = precp != NULL && precp->pr == NULL;
if (ok)
{
#ifdef WIN32
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
ok = OsWin32_CheckPrinterInfo(rcd->m_data, rcd->m_size);
#else
// verificare (c'e' da fare qualcosa ?)
#endif
}
return ok;
return ok;
}
BOOLEAN xvt_print_open(void)
{
return m_po == NULL;
BOOLEAN xvt_print_open(void)
{
return m_po == NULL;
}
BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
{
wxWindow* tw = (wxWindow*)TASK_WIN;
BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
{
m_po = new TwxPrintOut;
print_fcn(data);
@ -357,20 +386,31 @@ BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
return TRUE;
}
BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
{
BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
{
BOOLEAN ok = m_po != NULL;
if (ok)
{
m_po->GetDC()->StartPage();
}
return ok;
return ok;
}
///////////////////////////////////////////////////////////
// Added by XVAGA
///////////////////////////////////////////////////////////
#ifdef LINUX
static bool is_cups()
{
static int printer_system = -1;
if (printer_system < 0)
printer_system = xvt_fsys_file_exists("/etc/cups/printer.conf") ? 1 : 2;
return (printer_system == 1);
}
#endif
SLIST xvt_print_list_devices()
{
SLIST list = xvt_slist_create();
@ -381,19 +421,75 @@ SLIST xvt_print_list_devices()
for (int i = 0; i < sizeof(buf); i++) if (buf[i] == '\0')
{
const char* pname = buf+start;
if (*pname == '\0')
if (*pname == '\0')
break;
xvt_slist_add_at_elt(list, NULL, pname, NULL);
start = i+1;
}
#else
xvt_slist_add_at_elt(list, NULL, "/dev/prn", NULL); // TBI
if (is_cups())
{
ifstream p("/etc/cups/printer.conf"); // vedere
char line[4096];
while (p.getline(line, sizeof(line)))
{
if (line[0] == '<')
{
char * s = strstr(line, "Printer") ;
if (s != NULL)
{
s += 7;
while (isspace(*s))
s++;
if (*s)
{
char * l = s + strlen(s) - 1;
while (isspace(*l))
l--;
*(l + 1) = '\0';
xvt_slist_add_at_elt(list, NULL, s, 0L);
}
}
}
}
}
else
{
ifstream p("/etc/printcap"); // vedere
char line[4096];
while (p.getline(line, sizeof(line)))
{
if (line[0] != '#')
{
const int len = strlen(line);
int i;
for (i = 0; i < len; i++)
{
const char c = line[i];
if (!(isalpha(c) || isdigit(c) || isblank(c)))
break;
}
line[i] = '\0';
xvt_slist_add_at_elt(list, NULL, line, 0L);
}
}
}
#endif
return list;
}
BOOLEAN xvt_print_set_default_device(const char* name)
{
{
BOOLEAN ok = name && *name > ' ';
#ifdef WIN32
if (ok)
@ -401,24 +497,59 @@ BOOLEAN xvt_print_set_default_device(const char* name)
wxString pdev(name);
if (pdev.Find(',') < 0)
{
char szDevice[256];
char szDevice[256];
::GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
pdev << ',' << szDevice;
}
ok = ::WriteProfileString("windows", "device", pdev) != 0;
}
ok = ::WriteProfileString("windows", "device", pdev) != 0;
}
#endif
return ok;
}
BOOLEAN xvt_print_get_default_device(char* name, int namesize)
{
bool ok = TRUE;
#ifdef WIN32
ok = ::GetProfileString ("windows", "device", ",,,", name, namesize) != 0;
#else
strcpy(name, "/dev/prn");
SORRY_BOX(); //verificare
#endif
return ok;
}
BOOLEAN xvt_print_get_default_device(char* name, int namesize)
{
bool ok = FALSE;
#ifdef WIN32
ok = ::GetProfileString ("windows", "device", ",,,", name, namesize) != 0;
#else
*name = '\0';
if (is_cups())
{
ifstream p("/etc/cups/printer.conf"); // vedere
char line[4096];
while (p.getline(line, sizeof(line)))
{
if (line[0] == '<')
{
char * s = strstr(line, "ltPrinter") ;
if (s != NULL)
{
s += 9;
while (isspace(*s))
s++;
if (*s)
{
char * l = s + strlen(s) - 1;
while (isspace(*l))
l--;
*(l + 1) = '\0';
strcpy(name, s);
}
ok = TRUE;
}
}
}
}
#endif
return ok;
}