Patch level : 10.0

Files correlati     : xvaga
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@17434 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-10-20 14:59:24 +00:00
parent 429faed747
commit 60b68debc1
10 changed files with 182 additions and 210 deletions

View File

@ -57,6 +57,10 @@ static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *nVersion);
#define WNT4STR _T("Windows NT 4") #define WNT4STR _T("Windows NT 4")
#define W2KSTR _T("Windows 2000") #define W2KSTR _T("Windows 2000")
#define WXPSTR _T("Windows XP") #define WXPSTR _T("Windows XP")
#define W2003STR _T("Windows Server 2003")
#define WVISTASTR _T("Windows Vista")
#define W2008STR _T("Windows Server 2008")
#define W7STR _T("Windows 7")
#define WCESTR _T("Windows CE") #define WCESTR _T("Windows CE")
@ -64,24 +68,28 @@ static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *nVersion);
#define WUNKNOWN 0 #define WUNKNOWN 0
#define W9XFIRST 1 #define W9XFIRST 1
#define W95 1 #define W95 1
#define W95SP1 2 #define W95SP1 2
#define W95OSR2 3 #define W95OSR2 3
#define W98 4 #define W98 4
#define W98SP1 5 #define W98SP1 5
#define W98SE 6 #define W98SE 6
#define WME 7 #define WME 7
#define W9XLAST 99 #define W9XLAST 99
#define WNTFIRST 101 #define WNTFIRST 101
#define WNT351 101 #define WNT351 101
#define WNT4 102 #define WNT4 102
#define W2K 103 #define W2K 103
#define WXP 104 #define WXP 104
#define W2003 105
#define WVISTA 106
#define W2008 107
#define W7 108
#define WNTLAST 199 #define WNTLAST 199
#define WCEFIRST 201 #define WCEFIRST 201
#define WCE 201 #define WCE 201
#define WCELAST 299 #define WCELAST 299
@ -588,12 +596,9 @@ static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
_tcsncpy(lpszVersion, WUNKNOWNSTR, nVersionSize-1); _tcsncpy(lpszVersion, WUNKNOWNSTR, nVersionSize-1);
*pnVersion = WUNKNOWN; *pnVersion = WUNKNOWN;
TCHAR *cp = NULL; OSVERSIONINFO osinfo; memset(&osinfo, 0, sizeof(osinfo));
OSVERSIONINFO osinfo;
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!::GetVersionEx(&osinfo))
if (!GetVersionEx(&osinfo))
return FALSE; return FALSE;
DWORD dwPlatformId = osinfo.dwPlatformId; DWORD dwPlatformId = osinfo.dwPlatformId;
@ -602,6 +607,7 @@ static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
TRACE(_T("%d: %d.%d.%d\n"), dwPlatformId, dwMajorVersion, dwMinorVersion, dwBuildNumber); TRACE(_T("%d: %d.%d.%d\n"), dwPlatformId, dwMajorVersion, dwMinorVersion, dwBuildNumber);
LPCTSTR cp = WUNKNOWNSTR;
if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4)) if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4))
{ {
if ((dwMinorVersion < 10) && (dwBuildNumber == 950)) if ((dwMinorVersion < 10) && (dwBuildNumber == 950))
@ -644,25 +650,36 @@ static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
} }
else if (dwPlatformId == VER_PLATFORM_WIN32_NT) else if (dwPlatformId == VER_PLATFORM_WIN32_NT)
{ {
if ((dwMajorVersion == 3) && (dwMinorVersion == 51)) if (dwMajorVersion == 3)
{ {
cp = WNT351STR; cp = WNT351STR;
*pnVersion = WNT351; *pnVersion = WNT351;
} }
else if ((dwMajorVersion == 4) && (dwMinorVersion == 0)) else if (dwMajorVersion == 4)
{ {
cp = WNT4STR; cp = WNT4STR;
*pnVersion = WNT4; *pnVersion = WNT4;
} }
else if ((dwMajorVersion == 5) && (dwMinorVersion == 0)) else if (dwMajorVersion == 5)
{ {
cp = W2KSTR; switch (dwMinorVersion)
*pnVersion = W2K; {
case 0: cp = W2KSTR; *pnVersion = W2K; break;
case 1: cp = WXPSTR; *pnVersion = WXP; break;
case 2:
default: cp = W2003STR; *pnVersion = W2003; break;
}
} }
else if ((dwMajorVersion == 5) && (dwMinorVersion == 1)) else if (dwMajorVersion == 6)
{ {
cp = WXPSTR; cp = WVISTASTR;
*pnVersion = WXP; *pnVersion = WVISTA;
// TBI: Windows 2008 Server
}
else if (dwMajorVersion >= 7)
{
cp = W7STR;
*pnVersion = W7;
} }
} }
else if (dwPlatformId == VER_PLATFORM_WIN32_CE) else if (dwPlatformId == VER_PLATFORM_WIN32_CE)

View File

@ -2,7 +2,6 @@
#ifndef __WXINC_H__ #ifndef __WXINC_H__
#define __WXINC_H__ #define __WXINC_H__
#ifdef WIN32 #ifdef WIN32
#define __WINDOWS__ #define __WINDOWS__
#define __WXMSW__ #define __WXMSW__

View File

@ -21,10 +21,7 @@
#include "agasys.h" #include "agasys.h"
#include "fstrcmp.h" #include "fstrcmp.h"
#include <limits.h>
#include "matche.h" #include "matche.h"
#include "xvtpdf.h"
#include "xvtwin.h" #include "xvtwin.h"
#ifdef WIN32 #ifdef WIN32
@ -227,7 +224,7 @@ wxString GetResourceIni()
wxString _GetResourceName(const char* type, int rid) wxString _GetResourceName(const char* type, int rid)
{ {
wxString strName; strName.Printf("%ss", type); wxString strName(type); strName << "s";
wxString strKey; strKey.Printf("%d", rid); wxString strKey; strKey.Printf("%d", rid);
wxString val; wxString val;
@ -1441,13 +1438,6 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const
#endif #endif
} }
void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, RCT* dest)
{
CAST_DC(win, dc);
const wxRect dst = NormalizeRCT(dest);
((TwxPDFDC&)dc).DrawImage(name, dst);
}
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE img, RCT* dest, RCT* source) void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE img, RCT* dest, RCT* source)
{ {
CAST_TIMAGE(img, image); CAST_TIMAGE(img, image);
@ -1900,7 +1890,7 @@ void xvt_font_destroy(XVT_FNTID font_id)
BOOLEAN xvt_font_get_family(XVT_FNTID font_id, char* buf, long max_buf) BOOLEAN xvt_font_get_family(XVT_FNTID font_id, char* buf, long max_buf)
{ {
CAST_FONT(font_id, font); CAST_FONT(font_id, font);
strncpy(buf, font.FaceName(), max_buf); wxStrncpy(buf, font.FaceName(), max_buf);
buf[max_buf-1] = '\0'; buf[max_buf-1] = '\0';
return TRUE; return TRUE;
} }
@ -1998,7 +1988,7 @@ long xvt_font_serialize(XVT_FNTID font_id, char *buf, long max_buf)
str = wxString::Format("01\\%s\\0\\%d\\WIN01/%d/%d/0/0/%d/0/0/0/0/0/0/0/0/%s", str = wxString::Format("01\\%s\\0\\%d\\WIN01/%d/%d/0/0/%d/0/0/0/0/0/0/0/0/%s",
name, size, size, weight, italic, name); name, size, size, weight, italic, name);
strncpy(buf, str, max_buf); wxStrncpy(buf, str, max_buf);
buf[max_buf-1] = '\0'; buf[max_buf-1] = '\0';
return strlen(buf); return strlen(buf);
} }
@ -2013,7 +2003,7 @@ void xvt_font_unmap(XVT_FNTID font_id)
// File system // File system
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirname, const char *leafroot, const char *leafext, const char* /* leafvers */) BOOLEAN xvt_fsys_build_pathname(char* mbs, const char* volname, const char* dirname, const char* leafroot, const char* leafext, const char* /* leafvers */)
{ {
#ifdef WIN32 #ifdef WIN32
_makepath(mbs, volname, dirname, leafroot, leafext); _makepath(mbs, volname, dirname, leafroot, leafext);
@ -2037,7 +2027,7 @@ BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirn
return TRUE; return TRUE;
} }
BOOLEAN xvt_fsys_parse_pathname(const char *mbs, char *volname, char *dirname, char *leafroot, char *leafext, char *leafvers) BOOLEAN xvt_fsys_parse_pathname(const char* mbs, char* volname, char* dirname, char* leafroot, char* leafext, char* leafvers)
{ {
wxString volume, path, file, ext; wxString volume, path, file, ext;
wxFileName::SplitPath(mbs, &volume, &path, &file, &ext); wxFileName::SplitPath(mbs, &volume, &path, &file, &ext);
@ -2067,18 +2057,27 @@ BOOLEAN xvt_fsys_parse_pathname(const char *mbs, char *volname, char *dirname, c
return true; return true;
} }
BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY *dirp, char *path, int sz_path) BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY* dirp, char* path, int sz_path)
{ {
wxStrncpy(path, dirp->path, sz_path); BOOLEAN ok = path != NULL && dirp != NULL;
path[sz_path-1] = '\0'; if (ok)
return TRUE; {
wxStrncpy(path, dirp->path, sz_path-1);
path[sz_path-1] = '\0';
}
return ok;
} }
BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp) BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp)
{ {
if (dirp != NULL) BOOLEAN ok = path != NULL && dirp != NULL;
strcpy(dirp->path, path); if (ok)
return dirp != NULL; {
const int sz = sizeof(dirp->path)-1;
wxStrncpy(dirp->path, path, sz);
dirp->path[sz] = '\0';
}
return ok;
} }
BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path) BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path)
@ -3009,7 +3008,7 @@ char* xvt_res_get_str(int rid, char *s, int sz_s)
{ {
XVT_ASSERT(s != NULL && sz_s > 0); XVT_ASSERT(s != NULL && sz_s > 0);
const wxString str = _GetResourceName("String", rid); const wxString str = _GetResourceName("String", rid);
strncpy(s, str, sz_s); wxStrncpy(s, str, sz_s);
s[sz_s-1] = '\0'; s[sz_s-1] = '\0';
return s; return s;
} }

View File

@ -276,7 +276,7 @@ XVTDLL BOOLEAN xvt_print_set_default_device(const char* name);
XVTDLL BOOLEAN xvt_print_get_default_device(char* name, int namesize); XVTDLL BOOLEAN xvt_print_get_default_device(char* name, int namesize);
XVTDLL BOOLEAN xvt_print_suspend_thread(); XVTDLL BOOLEAN xvt_print_suspend_thread();
XVTDLL BOOLEAN xvt_print_restart_thread(); XVTDLL BOOLEAN xvt_print_restart_thread();
XVTDLL BOOLEAN xvt_print_is_pdf(PRINT_RCD* precp); XVTDLL BOOLEAN xvt_print_is_pdf(const PRINT_RCD* precp);
XVTDLL BOOLEAN xvt_print_pdf_version(char* version, int size); XVTDLL BOOLEAN xvt_print_pdf_version(char* version, int size);
XVTDLL int xvt_rect_get_height(RCT *rctp); XVTDLL int xvt_rect_get_height(RCT *rctp);
@ -442,6 +442,7 @@ typedef int ODBC_CALLBACK(void*,int,char**, char**);
XVTDLL XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir); XVTDLL XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir);
XVTDLL BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle); XVTDLL BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle);
XVTDLL ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly); XVTDLL ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly);
XVTDLL BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size);
XVTDLL BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, XVTDLL BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn,
const char* subject, const char* msg, const char* attach, BOOLEAN ui); const char* subject, const char* msg, const char* attach, BOOLEAN ui);

View File

@ -151,7 +151,6 @@ class TwxOutlookBar : public wxVListBox
TwxOutlookItem m_item[MAX_ITEMS]; TwxOutlookItem m_item[MAX_ITEMS];
bool m_bCaptured; bool m_bCaptured;
int m_nHovering; int m_nHovering;
wxColour m_clrLite, m_clrDark;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@ -165,7 +164,6 @@ protected:
public: public:
int Add(short nIconId, const wxString strText, int nFlags); int Add(short nIconId, const wxString strText, int nFlags);
void SetColors(const XVT_COLOR_COMPONENT* colors);
TwxOutlookBar(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style); TwxOutlookBar(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
~TwxOutlookBar(); ~TwxOutlookBar();
@ -254,7 +252,6 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
long style = 0; long style = 0;
TwxOutlookBar* tob = new TwxOutlookBar(pParent, id, rct.GetPosition(), rct.GetSize(), style); TwxOutlookBar* tob = new TwxOutlookBar(pParent, id, rct.GetPosition(), rct.GetSize(), style);
win = (WINDOW)tob; win = (WINDOW)tob;
tob->SetColors(win_def_p->ctlcolors);
} }
break; break;
default: default:
@ -291,11 +288,11 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
break; break;
case XVT_COLOR_BACKGROUND: case XVT_COLOR_BACKGROUND:
if (win_def_p->wtype == WC_PUSHBUTTON) if (win_def_p->wtype == WC_PUSHBUTTON)
w.SetBackgroundColour(rgb); w.SetOwnBackgroundColour(rgb);
break; break;
case XVT_COLOR_BLEND: case XVT_COLOR_BLEND:
if (win_def_p->wtype != WC_PUSHBUTTON) if (win_def_p->wtype != WC_PUSHBUTTON)
w.SetBackgroundColour(rgb); w.SetOwnBackgroundColour(rgb);
break; break;
default: break; default: break;
} }
@ -1251,8 +1248,17 @@ void TwxOutlookBar::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) con
} }
else else
{ {
color1 = m_clrLite; if (InheritsBackgroundColour())
color2 = m_clrDark; {
color1 = ModulateColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION), +20);
color2 = ModulateColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION), -20);
}
else
{
const wxColour bkg = GetBackgroundColour();
color1 = ModulateColour(bkg, +20);
color2 = ModulateColour(bkg, -20);
}
} }
} }
dc.GradientFillLinear(rect, color1, color2, wxDOWN); dc.GradientFillLinear(rect, color1, color2, wxDOWN);
@ -1394,49 +1400,11 @@ static bool AreSystemColors(const XVT_COLOR_COMPONENT* colors)
return yes; return yes;
} }
void TwxOutlookBar::SetColors(const XVT_COLOR_COMPONENT* colors)
{
if (AreSystemColors(colors))
{
m_clrLite = ModulateColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION), +20);
m_clrDark = ModulateColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION), -20);
}
else
{
int nFound = 0;
wxColour lite, dark, back;
for (int c = 0; colors[c].type; c++)
{
CAST_COLOR(colors[c].color, rgb);
switch(colors[c].type)
{
case XVT_COLOR_BLEND : lite = rgb; nFound |= 1; break;
case XVT_COLOR_BORDER : dark = rgb; nFound |= 2; break;
case XVT_COLOR_BACKGROUND : back = rgb; nFound |= 4; break;
default: break;
}
}
switch (nFound)
{
case 0x1: m_clrLite = lite; m_clrDark = ModulateColour(lite, -40); break;
case 0x2: m_clrLite = ModulateColour(dark, 40); m_clrDark = dark; break;
case 0x3: m_clrLite = lite; m_clrDark = dark; break;
case 0x4: m_clrLite = ModulateColour(back, 20); m_clrDark = ModulateColour(back, -20); break;
case 0x5: m_clrLite = MeanColour(back, lite); m_clrDark = ModulateColour(back, -20); break;
case 0x6: m_clrLite = ModulateColour(back, 20); m_clrDark = MeanColour(back, dark); break;
case 0x7: m_clrLite = MeanColour(back, lite); m_clrDark = MeanColour(back, dark); break;
default: break;
}
}
}
TwxOutlookBar::TwxOutlookBar(wxWindow *parent, wxWindowID id, TwxOutlookBar::TwxOutlookBar(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style) const wxPoint& pos, const wxSize& size, long style)
: wxVListBox(parent, id, pos, size, style), : wxVListBox(parent, id, pos, size, style), m_bCaptured(false), m_nHovering(wxNOT_FOUND)
m_bCaptured(false), m_nHovering(wxNOT_FOUND)
{ {
SetItemCount(0); SetItemCount(0);
SetColors(NULL); // Set default colors
} }
TwxOutlookBar::~TwxOutlookBar() TwxOutlookBar::~TwxOutlookBar()

View File

@ -1,6 +1,5 @@
#include "wxinc.h" #include "wxinc.h"
#include "wx/print.h" #include "wx/print.h"
#include "wx/printdlg.h"
#include "xvt.h" #include "xvt.h"
@ -117,7 +116,7 @@ public:
bool HasBadDriver() const { return m_bBadDriver; } bool HasBadDriver() const { return m_bBadDriver; }
wxString PrinterName() const; wxString PrinterName() const;
bool IsPDF() const { return !HasBadDriver() && xvt_print_is_pdf((PRINT_RCD *)m_prcd) != 0; } bool IsPDF() const { return !HasBadDriver() && xvt_print_is_pdf(m_prcd) != 0; }
void InitDC(const TPRINT_RCD* prcd, const char* title); void InitDC(const TPRINT_RCD* prcd, const char* title);
TwxPrintOut(const TPRINT_RCD* prcd = NULL); TwxPrintOut(const TPRINT_RCD* prcd = NULL);
@ -214,7 +213,6 @@ wxDC* TwxPrintOut::CreateDC(const TPRINT_RCD* prcd, const char* title)
if (s.x > 0) if (s.x > 0)
SetPPIPrinter(s.x, s.y); SetPPIPrinter(s.x, s.y);
s = dc->GetSize(); s = dc->GetSize();
if (s.x > 0) if (s.x > 0)
SetPageSizePixels(s.x, s.y); SetPageSizePixels(s.x, s.y);
@ -244,7 +242,7 @@ void TwxPrintOut::InitDC(const TPRINT_RCD* prcd, const char* title)
wxDC* dc = CreateDC(prcd, title); wxDC* dc = CreateDC(prcd, title);
wxSize s = dc->GetPPI(); wxSize s = dc->GetPPI();
if (s.x >0) if (s.x > 0)
SetPPIPrinter(s.x, s.y); SetPPIPrinter(s.x, s.y);
s = dc->GetSize(); s = dc->GetSize();
@ -413,28 +411,17 @@ BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* p
case XVT_ESC_SET_PRINTER_INFO: case XVT_ESC_SET_PRINTER_INFO:
if (xvt_print_is_valid(rcd) && ph != NULL && pw != NULL) if (xvt_print_is_valid(rcd) && ph != NULL && pw != NULL)
{ {
TPRINT_RCD* prcd = (TPRINT_RCD*)rcd;
wxPrintData data; wxPrintData data;
TPRINT_RCD* prcd = (TPRINT_RCD*)rcd;
#ifdef WIN32
RCD2data(prcd, data); RCD2data(prcd, data);
data.SetOrientation(*ph > *pw ? 1 : 2); data.SetOrientation(*ph > *pw ? 1 : 2);
data.ConvertToNative(); data.ConvertToNative();
data2RCD(data, prcd); data2RCD(data, prcd);
#else
RCD2data(prcd, data);
data.SetOrientation(*ph > *pw ? 1 : 2);
data2RCD(data, prcd);
#endif
return true; return true;
} }
break; break;
default: default:
break; break;
} }
@ -463,6 +450,14 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
return ok; return ok;
} }
void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, RCT* dest)
{
wxASSERT(win == PRINTER_WIN);
const wxRect dst = NormalizeRCT(dest);
TwxPDFDC& dc = *wxStaticCast(&GetTDCMapper().GetDC(win), TwxPDFDC);
dc.DrawImage(name, dst);
}
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 = 0; long size = 0;
@ -552,7 +547,7 @@ int xvt_print_set_name(PRINT_RCD* precp, const char* name)
wxString n = name; wxString n = name;
#ifdef WIN32 #ifdef WIN32
strncpy(((char*)precp) + 4, name, 32); wxStrncpy(((char*)precp) + 4, name, 32);
#else #else
TPRINT_RCD* rcd = (TPRINT_RCD*)precp; TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
wxPrintData data; wxPrintData data;
@ -622,7 +617,8 @@ WINDOW xvt_print_create_win(PRINT_RCD* precp, const char* title)
void xvt_print_destroy(PRINT_RCD* precp) void xvt_print_destroy(PRINT_RCD* precp)
{ {
delete precp; if (precp != NULL)
delete precp;
} }
RCT* xvt_print_get_next_band(void) RCT* xvt_print_get_next_band(void)
@ -644,7 +640,7 @@ RCT* xvt_print_get_next_band(void)
return &rct; return &rct;
} }
BOOLEAN xvt_print_is_pdf(PRINT_RCD* precp) BOOLEAN xvt_print_is_pdf(const PRINT_RCD* precp)
{ {
char strName[MAX_PATH]; char strName[MAX_PATH];
xvt_print_get_name(precp, strName, sizeof(strName)); xvt_print_get_name(precp, strName, sizeof(strName));
@ -725,29 +721,41 @@ BOOLEAN xvt_print_open(void)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void CreateAbortWindow() class TwxPrintAbortDialog : public wxPrintAbortDialog
{ {
wxFrame* parent = (wxFrame*)TASK_WIN; public:
wxString strCaption = wxT("Stampa"); void Pulse();
wxString strPrompt = strCaption + wxT(" in corso..."); TwxPrintAbortDialog();
wxPrintAbortDialog* win = new wxPrintAbortDialog(parent, strCaption, };
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
void TwxPrintAbortDialog::Pulse()
{
wxGauge* pGauge = wxStaticCast(FindWindow(wxID_FORWARD), wxGauge);
pGauge->Pulse();
}
TwxPrintAbortDialog::TwxPrintAbortDialog()
: wxPrintAbortDialog(NULL, wxT("Stampa"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
{
wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL );
button_sizer->Add(new wxStaticText( win, wxID_STATIC, strPrompt, wxDefaultPosition, wxSize(320,-1)), 0, wxALL, 10 ); button_sizer->Add(new wxStaticText(this, wxID_STATIC, wxT("Stampa in corso..."), wxDefaultPosition, wxSize(320,-1)), 0, wxALL, 10 );
button_sizer->Add( new wxButton( win, wxID_CANCEL, wxT("Annulla") ), 0, wxALL | wxALIGN_CENTER, 10 ); button_sizer->Add(new wxGauge(this, wxID_FORWARD, 1, wxDefaultPosition, wxSize(320,-1)), 0, wxALL, 10 );
button_sizer->Add(new wxButton(this, wxID_CANCEL, wxT("Annulla") ), 0, wxALL | wxALIGN_CENTER, 10 );
win->SetAutoLayout(true); SetAutoLayout(true);
win->SetSizer(button_sizer); SetSizer(button_sizer);
button_sizer->Fit(win); button_sizer->Fit(this);
button_sizer->SetSizeHints(win); button_sizer->SetSizeHints(this);
win->Show(); Show();
win->Update(); Update();
}
wxPrinterBase::sm_abortWindow = win; void CreateAbortWindow()
{
wxPrinterBase::sm_abortWindow = new TwxPrintAbortDialog;
} }
void DestroyAbortWindow() void DestroyAbortWindow()
@ -767,15 +775,13 @@ BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
const wxString strDir = ::wxGetCwd(); // Memorizzo la directory corrente (Acrobat la cambia) const wxString strDir = ::wxGetCwd(); // Memorizzo la directory corrente (Acrobat la cambia)
wxBeginBusyCursor(); wxBeginBusyCursor();
m_PrintoutCache.Reset(); // Forza nuovo contesto di stampa m_PrintoutCache.Reset(); // Forza nuovo contesto di stampa
TwxPrintOut& po = m_PrintoutCache.Get(NULL); TwxPrintOut& po = m_PrintoutCache.Get(NULL);
m_PrintoutCache.Lock(); m_PrintoutCache.Lock();
wxEndBusyCursor(); wxEndBusyCursor();
CreateAbortWindow(); CreateAbortWindow();
const BOOLEAN aborted = print_fcn(data);
const BOOLEAN aborted = print_fcn(data);
DestroyAbortWindow(); DestroyAbortWindow();
po.OnEndDocument(); po.OnEndDocument();
@ -823,6 +829,11 @@ BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
TwxPrintOut& po = m_PrintoutCache.Get(NULL); TwxPrintOut& po = m_PrintoutCache.Get(NULL);
po.GetDC()->StartPage(); po.GetDC()->StartPage();
TPrintDC::SetPageStart(); // Flag per azzeramento dati DC TPrintDC::SetPageStart(); // Flag per azzeramento dati DC
// Aggiorna barra di attesa
TwxPrintAbortDialog* pad = wxDynamicCast(wxPrinterBase::sm_abortWindow, TwxPrintAbortDialog);
if (pad != NULL)
pad->Pulse();
} }
} }
return ok; return ok;
@ -852,19 +863,6 @@ SLIST xvt_print_list_devices()
{ {
SLIST list = xvt_slist_create(); SLIST list = xvt_slist_create();
#ifdef WIN32 #ifdef WIN32
/* Vecchio modo oblsoleto
char buf[4096]; memset(buf, 0, sizeof(buf));
GetProfileString("devices", NULL, "", buf, sizeof(buf));
int start = 0;
for (int i = 0; i < sizeof(buf); i++) if (buf[i] == '\0')
{
const char* pname = buf+start;
if (*pname == '\0')
break;
xvt_slist_add_at_elt(list, NULL, pname, NULL);
start = i+1;
} */
const DWORD dwFlags = PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS; const DWORD dwFlags = PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS;
const int level = xvt_sys_get_os_version() >= XVT_WS_WIN_NT ? 4 : 5; const int level = xvt_sys_get_os_version() >= XVT_WS_WIN_NT ? 4 : 5;
DWORD dwSize = 0, dwPrinters = 0; DWORD dwSize = 0, dwPrinters = 0;
@ -1159,3 +1157,4 @@ BOOLEAN xvt_fsys_file_md5(const char* path, char* outstr)
} }
return ok; return ok;
} }

View File

@ -1,10 +1,15 @@
#include "wxinc.h" #include "wxinc.h"
#include <wx/db.h>
#include "xvt.h" #include "xvt.h"
#if wxUSE_ODBC #if wxUSE_ODBC
#include <wx/db.h>
///////////////////////////////////////////////////////////
// TwxConnectionDlg
///////////////////////////////////////////////////////////
class TwxConnectionDlg : public wxDialog class TwxConnectionDlg : public wxDialog
{ {
protected: protected:
@ -42,13 +47,17 @@ TwxConnectionDlg::TwxConnectionDlg() : wxDialog(NULL, wxID_ANY, "ODBC",
wxSizer* ctlButtonSizer = CreateButtonSizer(wxOK | wxCANCEL); wxSizer* ctlButtonSizer = CreateButtonSizer(wxOK | wxCANCEL);
wxBoxSizer* ctlTopSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* ctlTopSizer = new wxBoxSizer(wxVERTICAL);
ctlTopSizer ->Add(ctlTextSizer, 0, wxALIGN_CENTER); ctlTopSizer->Add(ctlTextSizer, 0, wxALIGN_CENTER);
ctlTopSizer ->Add(ctlButtonSizer, 0, wxALIGN_CENTER); ctlTopSizer->Add(ctlButtonSizer, 0, wxALIGN_CENTER);
SetSizer(ctlTopSizer); SetSizer(ctlTopSizer);
ctlTopSizer->SetSizeHints(this); ctlTopSizer->SetSizeHints(this);
} }
///////////////////////////////////////////////////////////
// xvt_odbc_...
///////////////////////////////////////////////////////////
XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir) XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir)
{ {
wxString strDsn(dsn), strUsr(usr), strPwd(pwd), strDir(dir); wxString strDsn(dsn), strUsr(usr), strPwd(pwd), strDir(dir);
@ -100,7 +109,6 @@ ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void*
if (handle && sql && *sql) if (handle && sql && *sql)
{ {
wxDb* db = (wxDb*)handle; wxDb* db = (wxDb*)handle;
if (cb != NULL) // Ho una vera callback? if (cb != NULL) // Ho una vera callback?
{ {
wxDbColInf* columns = NULL; wxDbColInf* columns = NULL;
@ -197,6 +205,18 @@ ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void*
return nCount; return nCount;
} }
BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size)
{
if (handle != NULL)
{
const wxDb* db = (const wxDb*)handle;
wxStrncpy(str, db->dbInf.driverName, max_size);
}
else
wxStrncpy(str, "ODBC 2.0", max_size);
return handle != NULL;
}
#else #else
XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir) XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir)
@ -206,14 +226,12 @@ XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* p
} }
BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle) BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle)
{ { return FALSE; }
return FALSE;
}
ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly) ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly)
{ { return 0; }
return 0; BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size)
} { return FALSE; }
#endif #endif

View File

@ -1,15 +1,7 @@
#include "wxinc.h" #include "wxinc.h"
#include "xvtpdf.h"
#include "wx/log.h"
#include "wx/icon.h"
#include "wx/image.h"
#include "wx/paper.h"
#include "wx/bitmap.h"
#include "wx/dcmemory.h"
#include "XFont.h" #include "XFont.h"
#include <math.h> #include "xvtpdf.h"
#define RAD2DEG 57.29577951308 #define RAD2DEG 57.29577951308
#define BEZIERK 0.55228475 #define BEZIERK 0.55228475
@ -19,53 +11,31 @@ IMPLEMENT_DYNAMIC_CLASS(TwxPDFDC, wxDC)
//-- Contructor and Destructor ------------------------------------------- //-- Contructor and Destructor -------------------------------------------
TwxPDFDC::TwxPDFDC () TwxPDFDC::TwxPDFDC()
{ {
m_pageNumber = 0; wxASSERT(false); // Dummy constructor!
m_topDown = true;
m_clipping = false;
m_pageopen = false;
m_ok = FALSE;
for(int i=0;i<PDF_IMG_CACHE_SIZE;i++)
{
m_filenames[i] = "";
m_handles[i] = 0;
}
m_cacheidx = 0;
if ((m_PDFlib = PDF_new_dl(&m_p)) == (PDFlib_api *) NULL)
{
wxLogError( _("Cannot create PDFlib object (DLL not found?)\n"));
m_ok = FALSE;
}
} }
TwxPDFDC::TwxPDFDC (const wxPrintData& printData, const char* strFilename) TwxPDFDC::TwxPDFDC (const wxPrintData& printData, const char* strFilename)
: m_PDFlib(NULL), m_p(NULL)
{ {
m_pageNumber = 0; m_pageNumber = 0;
m_topDown = true; m_topDown = true;
m_clipping = false; m_clipping = false;
m_pageopen = false; m_pageopen = false;
m_printData = printData; m_printData = printData;
m_fileName = strFilename; m_fileName = strFilename;
m_ok = TRUE; for(int i=0; i < PDF_IMG_CACHE_SIZE; i++)
for(int i=0;i<PDF_IMG_CACHE_SIZE;i++)
{ {
m_filenames[i] = ""; m_filenames[i] = "";
m_handles[i] = 0; m_handles[i] = 0;
} }
m_cacheidx = 0; m_cacheidx = 0;
m_PDFlib = PDF_new_dl(&m_p);
if ((m_PDFlib = PDF_new_dl(&m_p)) == (PDFlib_api *) NULL) m_ok = m_PDFlib != NULL;
{ if (!m_ok)
wxLogError( _("Cannot create PDFlib object (DLL not found?)\n")); wxLogError( _("Cannot create PDFlib object (DLL not found?)\n"));
m_ok = FALSE;
}
} }
TwxPDFDC::~TwxPDFDC () TwxPDFDC::~TwxPDFDC ()
@ -77,9 +47,7 @@ TwxPDFDC::~TwxPDFDC ()
//-- Status -------------------------------------------------------------- //-- Status --------------------------------------------------------------
bool TwxPDFDC::Ok() const bool TwxPDFDC::Ok() const
{ { return m_ok; }
return m_ok;
}
//-- Document and Pages -------------------------------------------------- //-- Document and Pages --------------------------------------------------
@ -90,8 +58,8 @@ bool TwxPDFDC::StartDoc( const wxString& message )
if (m_PDFlib->PDF_begin_document(m_p, m_fileName, 0, "") == -1) if (m_PDFlib->PDF_begin_document(m_p, m_fileName, 0, "") == -1)
{ {
wxLogError( _("Cannot open file for PDF printing!")); wxLogError( _("Cannot open file for PDF printing!"));
m_ok = FALSE; m_ok = false;
return FALSE; return false;
} }
PDF_TRY_DL(m_PDFlib, m_p) PDF_TRY_DL(m_PDFlib, m_p)
@ -103,13 +71,13 @@ bool TwxPDFDC::StartDoc( const wxString& message )
PDF_CATCH_DL(m_PDFlib, m_p) PDF_CATCH_DL(m_PDFlib, m_p)
{ {
wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p)); wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p));
m_ok = FALSE; m_ok = false;
} }
m_pageNumber = 0; m_pageNumber = 0;
m_ok = TRUE; m_ok = true;
return TRUE; return true;
} }
void TwxPDFDC::EndDoc () void TwxPDFDC::EndDoc ()
@ -125,7 +93,7 @@ void TwxPDFDC::EndDoc ()
PDF_CATCH_DL(m_PDFlib, m_p) PDF_CATCH_DL(m_PDFlib, m_p)
{ {
wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p)); wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p));
m_ok = FALSE; m_ok = false;
} }
} }
@ -153,7 +121,7 @@ void TwxPDFDC::StartPage()
PDF_CATCH_DL(m_PDFlib, m_p) PDF_CATCH_DL(m_PDFlib, m_p)
{ {
wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p)); wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p));
m_ok = FALSE; m_ok = false;
} }
SetBrush(*wxBLACK_BRUSH); SetBrush(*wxBLACK_BRUSH);
@ -181,7 +149,7 @@ void TwxPDFDC::EndPage()
PDF_CATCH_DL(m_PDFlib, m_p) PDF_CATCH_DL(m_PDFlib, m_p)
{ {
wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p)); wxLogError("%s: %s", m_PDFlib->PDF_get_apiname(m_p), m_PDFlib->PDF_get_errmsg(m_p));
m_ok = FALSE; m_ok = false;
} }
} }
@ -1198,6 +1166,5 @@ void TwxPDFDC::DestroyClippingRegion()
} }
} }
wxDC::DestroyClippingRegion(); wxDC::DestroyClippingRegion();
} }

View File

@ -1,7 +1,10 @@
#ifndef __XVTPDF_H #ifndef __XVTPDF_H
#define __XVTPDF_H #define __XVTPDF_H
#ifndef PDFLIB_H
struct PDF_c {};
#include "../pdf/pdflib/pdflibdl.h" #include "../pdf/pdflib/pdflibdl.h"
#endif
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TwxPDFDC // TwxPDFDC
@ -9,11 +12,12 @@
class TwxPDFDC : public wxDC class TwxPDFDC : public wxDC
{ {
enum { PDF_IMG_CACHE_SIZE = 5 }; enum { PDF_IMG_CACHE_SIZE = 4 };
protected:
TwxPDFDC(); // Dummy constructor for dynamic construction
public: public:
TwxPDFDC();
// Recommended constructor // Recommended constructor
TwxPDFDC(const wxPrintData& data, const char* strFilename); TwxPDFDC(const wxPrintData& data, const char* strFilename);

View File

@ -15,8 +15,8 @@
// Utilities // Utilities
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
wxHashTable _nice_windows; wxHashTable _nice_windows;
wxFrame* _task_win = NULL; wxFrame* _task_win = NULL;
EVENT_HANDLER _task_win_handler = NULL; EVENT_HANDLER _task_win_handler = NULL;
wxRect NormalizeRCT(const RCT* prct) wxRect NormalizeRCT(const RCT* prct)