Patch level : 02.00.303
Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione P@rtners 2.0 patch 302 sul main trunk git-svn-id: svn://10.65.10.50/trunk@10388 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3849f63cf0
commit
51e59ea61f
@ -8,47 +8,44 @@
|
||||
#include <windows.h>
|
||||
#include <winspool.h>
|
||||
|
||||
bool OsWin32_CheckPrinterInfo(const void* data)
|
||||
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size)
|
||||
{
|
||||
bool ok = data != NULL;
|
||||
if (ok)
|
||||
{
|
||||
LPDEVMODE pdm = (LPDEVMODE)data;
|
||||
const int s = pdm->dmSize + pdm->dmDriverExtra;
|
||||
ok = s > 0;
|
||||
const unsigned int s = pdm->dmSize + pdm->dmDriverExtra;
|
||||
ok = s > 0 && s == size;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal)
|
||||
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nDataSize)
|
||||
{
|
||||
void* data = new char[1024]; memset(data, 0, 1024);
|
||||
void* ptr = ::GlobalLock(hGlobal);
|
||||
PDEVMODE dm = (PDEVMODE)ptr;
|
||||
const int size = dm->dmSize+dm->dmDriverExtra;
|
||||
memcpy(data, ptr, size);
|
||||
nDataSize = dm->dmSize+dm->dmDriverExtra;
|
||||
void* buff = new char[nDataSize];
|
||||
memcpy(buff, ptr, nDataSize);
|
||||
::GlobalUnlock(hGlobal);
|
||||
return data;
|
||||
return buff;
|
||||
}
|
||||
|
||||
void* OsWin32_ConvertToNativePrinterInfo(void* data)
|
||||
void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nDataSize)
|
||||
{
|
||||
HGLOBAL hGlobal = ::GlobalAlloc(GHND, 1024);
|
||||
HGLOBAL hGlobal = ::GlobalAlloc(GHND, nDataSize);
|
||||
void* ptr = ::GlobalLock(hGlobal);
|
||||
memcpy(ptr, data, 1024);
|
||||
memcpy(ptr, data, nDataSize);
|
||||
::GlobalUnlock(hGlobal);
|
||||
return hGlobal;
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
|
||||
struct XvtData
|
||||
{
|
||||
char** families;
|
||||
long* sizes;
|
||||
short* scalable;
|
||||
short* scalable;
|
||||
long max_count;
|
||||
|
||||
long cur_count;
|
||||
|
||||
XvtData() { memset(this, 0, sizeof(XvtData)); }
|
||||
@ -79,7 +76,8 @@ int CALLBACK SizeEnumerator(
|
||||
if (i == 0 || size > d->sizes[i-1])
|
||||
{
|
||||
d->sizes[i] = size;
|
||||
*d->scalable = (plf->lfPitchAndFamily & VARIABLE_PITCH) != 0;
|
||||
if (lpntme->tmPitchAndFamily & TMPF_TRUETYPE)
|
||||
*d->scalable = TRUE;
|
||||
i++;
|
||||
}
|
||||
return i < d->max_count;
|
||||
@ -116,24 +114,31 @@ int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, shor
|
||||
return data.cur_count;
|
||||
}
|
||||
|
||||
int OsWin32_GetDefaultPrinterInfo(void* data, int max_size)
|
||||
void* OsWin32_GetPrinterInfo(int& size, const char* printer)
|
||||
{
|
||||
char name[80];
|
||||
if (GetProfileString ("windows", "device", ",,,", name, sizeof(name)) == 0)
|
||||
return 0;
|
||||
char* comma = strchr(name, ',');
|
||||
if (comma) *comma = '\0';
|
||||
char name[256];
|
||||
|
||||
LPDEVMODE pdm = (LPDEVMODE)data;
|
||||
size = 0;
|
||||
if (printer == NULL || *printer == '\0')
|
||||
{
|
||||
if (::GetProfileString("windows", "device", ",,,", name, sizeof(name)) == 0)
|
||||
return NULL;
|
||||
char* comma = strchr(name, ',');
|
||||
if (comma) *comma = '\0';
|
||||
}
|
||||
else
|
||||
strcpy(name, printer);
|
||||
|
||||
LPDEVMODE pdm = (LPDEVMODE) new char[16*1024];
|
||||
HANDLE hPrinter;
|
||||
if (::OpenPrinter(name, &hPrinter, NULL) == 0)
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
::DocumentProperties(0, hPrinter, name, pdm, NULL, DM_OUT_BUFFER);
|
||||
::ClosePrinter(hPrinter);
|
||||
|
||||
const int size = pdm->dmSize + pdm->dmDriverExtra;
|
||||
return size;
|
||||
size = pdm->dmSize + pdm->dmDriverExtra;
|
||||
return pdm;
|
||||
}
|
||||
|
||||
void OsWin32_SetCaptionStyle(unsigned int handle, bool set)
|
||||
@ -163,15 +168,55 @@ void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h)
|
||||
::SelectClipRgn(hdc, NULL);
|
||||
}
|
||||
|
||||
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
|
||||
unsigned int hSrc, int xs, int ys, int ws, int hs)
|
||||
{
|
||||
::StretchBlt((HDC)hDst, xd, yd, wd, hd, (HDC)hSrc, xs, ys, ws, hs, SRCCOPY);
|
||||
}
|
||||
|
||||
void OsWin32_UpdateWindow(unsigned int handle)
|
||||
{
|
||||
HWND hwnd = (HWND)handle;
|
||||
::UpdateWindow(hwnd);
|
||||
}
|
||||
|
||||
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
|
||||
unsigned int hSrc, int xs, int ys, int ws, int hs)
|
||||
{
|
||||
const int nColors = ::GetDeviceCaps((HDC)hDst, NUMCOLORS);
|
||||
::SetStretchBltMode((HDC)hDst, nColors == 2 ? STRETCH_HALFTONE : STRETCH_DELETESCANS);
|
||||
::StretchBlt((HDC)hDst, xd, yd, wd, hd, (HDC)hSrc, xs, ys, ws, hs, SRCCOPY);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Drawing bitmaps
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
|
||||
int xd, int yd, int wd, int hd,
|
||||
int xs, int ys, int ws, int hs)
|
||||
{
|
||||
const int nTechno = ::GetDeviceCaps((HDC)hDC, TECHNOLOGY);
|
||||
if (nTechno == DT_RASPRINTER) // Sto stampando!
|
||||
{
|
||||
BITMAPINFO bi; memset(&bi, 0, sizeof(bi));
|
||||
BITMAPINFOHEADER& bih = bi.bmiHeader;
|
||||
bih.biSize = sizeof(bih);
|
||||
HDC hMemDC = ::CreateCompatibleDC(NULL);
|
||||
GetDIBits(hMemDC, (HBITMAP)hBitmap, 0, 0, NULL, &bi, DIB_RGB_COLORS);
|
||||
if (bih.biSizeImage > 0)
|
||||
{
|
||||
LPBYTE bits = new BYTE[bih.biSizeImage];
|
||||
::GetDIBits(hMemDC, (HBITMAP)hBitmap, 0, bih.biHeight,
|
||||
bits, &bi, DIB_RGB_COLORS);
|
||||
::StretchDIBits((HDC)hDC, xd, yd, wd, hd, xs, ys, ws, hs,
|
||||
bits, &bi, DIB_RGB_COLORS, SRCCOPY);
|
||||
delete bits;
|
||||
}
|
||||
::DeleteDC(hMemDC);
|
||||
}
|
||||
else
|
||||
{
|
||||
HDC hMemDC = ::CreateCompatibleDC((HDC)hDC);
|
||||
HGDIOBJ hOldBitmap = ::SelectObject(hMemDC, (HBITMAP)hBitmap);
|
||||
::SetStretchBltMode((HDC)hDC, STRETCH_DELETESCANS);
|
||||
::StretchBlt((HDC)hDC, xd, yd, wd, hd, hMemDC, xs, ys, ws, hs, SRCCOPY);
|
||||
::SelectObject(hMemDC, hOldBitmap);
|
||||
::DeleteDC(hMemDC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
bool OsWin32_CheckPrinterInfo(const void* data);
|
||||
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal);
|
||||
void* OsWin32_ConvertToNativePrinterInfo(void* data);
|
||||
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size);
|
||||
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nSize);
|
||||
void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize);
|
||||
int OsWin32_EnumerateFamilies(unsigned int hDC, char** families, int max_count);
|
||||
int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, short* scalable, int max_count);
|
||||
void OsWin32_SetCaptionStyle(unsigned int handle, bool set);
|
||||
int OsWin32_GetDefaultPrinterInfo(void* data, int max_size);
|
||||
void* OsWin32_GetPrinterInfo(int& size, const char* printer);
|
||||
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h);
|
||||
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
|
||||
unsigned int hSrc, int xs, int ys, int ws, int hs);
|
||||
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
|
||||
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
|
||||
void OsWin32_UpdateWindow(unsigned int handle);
|
||||
|
||||
|
276
xvaga/xvaga.cpp
276
xvaga/xvaga.cpp
@ -41,7 +41,7 @@ void XVT_ASSERT(bool test, XVT_ERRSEV sev = SEV_FATAL)
|
||||
{
|
||||
const wxString strMessage = "We're very sorry, but you passed some invalid parameters...";
|
||||
const wxString strCaption = "Emulated XVT Error";
|
||||
// wxMessageBox(strMessage, strCaption, wxOK|wxICON_ERROR);
|
||||
::wxMessageBox(strMessage, strCaption, wxOK|wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,6 +160,86 @@ wxCursor* GetCursorResource(int rid)
|
||||
return cursor;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Caret emulation
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TwxCaret : private wxTimer
|
||||
{
|
||||
WINDOW _owner;
|
||||
PNT _pos;
|
||||
wxSize _size;
|
||||
bool _visible;
|
||||
bool _drawn;
|
||||
|
||||
protected:
|
||||
void Toggle();
|
||||
virtual void Notify() { Toggle(); }
|
||||
|
||||
public:
|
||||
void SetPos(int x, int y) { _pos.h = x; _pos.v = y; }
|
||||
void SetSize(int x, int y) { _size.x = x; _size.y = y; }
|
||||
void Show(WINDOW w, bool on = true);
|
||||
void Hide() { Show(false); }
|
||||
bool IsVisible() const { return _visible; }
|
||||
WINDOW Owner() const { return _owner; }
|
||||
void Kill();
|
||||
|
||||
TwxCaret() : _visible(false), _owner(NULL_WIN) { }
|
||||
virtual ~TwxCaret() { Kill(); }
|
||||
} _TheCaret;
|
||||
|
||||
void TwxCaret::Kill()
|
||||
{
|
||||
_owner = NULL_WIN;
|
||||
// if (IsRunning())
|
||||
// Stop();
|
||||
}
|
||||
|
||||
void TwxCaret::Show(WINDOW w, bool on)
|
||||
{
|
||||
if (_visible && _drawn)
|
||||
Toggle(); // Lo cancella
|
||||
|
||||
_visible = on;
|
||||
if (on)
|
||||
{
|
||||
_owner = w;
|
||||
Toggle();
|
||||
wxTimer::Start(500); // Lampeggia ogni mezzo secondo
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w == _owner)
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
|
||||
void TwxCaret::Toggle()
|
||||
{
|
||||
if (!_visible || _owner == NULL_WIN)
|
||||
return;
|
||||
|
||||
_drawn = !_drawn;
|
||||
|
||||
DRAW_CTOOLS dct;
|
||||
xvt_dwin_get_draw_ctools(_owner, &dct);
|
||||
|
||||
CPEN pen;
|
||||
pen.width = _size.x;
|
||||
pen.pat = PAT_SOLID;
|
||||
pen.style = P_SOLID;
|
||||
pen.color = _drawn ? dct.fore_color : dct.back_color;
|
||||
xvt_dwin_set_cpen(_owner, &pen);
|
||||
xvt_dwin_set_draw_mode(_owner, M_COPY);
|
||||
xvt_dwin_draw_set_pos(_owner, _pos);
|
||||
PNT p = _pos; p.v -= _size.y;
|
||||
|
||||
xvt_dwin_set_clip(_owner, NULL); // Non si mai!
|
||||
xvt_dwin_draw_line(_owner, p);
|
||||
xvt_dwin_set_draw_ctools(_owner, &dct);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Dummy application
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -167,6 +247,7 @@ wxCursor* GetCursorResource(int rid)
|
||||
class TMainApp : public wxApp
|
||||
{
|
||||
virtual bool OnInit();
|
||||
virtual int OnExit();
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(TMainApp);
|
||||
};
|
||||
@ -180,10 +261,17 @@ IMPLEMENT_APP(TMainApp)
|
||||
|
||||
bool TMainApp::OnInit()
|
||||
{
|
||||
::wxInitAllImageHandlers();
|
||||
|
||||
xvt_main(argc, argv);
|
||||
return FALSE; // Prevents entering the Main Loop
|
||||
}
|
||||
|
||||
int TMainApp::OnExit()
|
||||
{
|
||||
return wxApp::OnExit();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Generic Display context
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -376,7 +464,8 @@ void TDC::SetClippingBox(const RCT* pRct)
|
||||
if (_dc != NULL)
|
||||
_dc->DestroyClippingRegion();
|
||||
#endif
|
||||
const wxRect rct = NormalizeRCT(pRct);
|
||||
wxRect rct = NormalizeRCT(pRct);
|
||||
// rct.width++; rct.height++;
|
||||
GetDC().SetClippingRegion(rct);
|
||||
_clip = *pRct;
|
||||
}
|
||||
@ -460,86 +549,6 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
|
||||
return pDC != NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Caret emulation
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TwxCaret : private wxTimer
|
||||
{
|
||||
WINDOW _owner;
|
||||
PNT _pos;
|
||||
wxSize _size;
|
||||
bool _visible;
|
||||
bool _drawn;
|
||||
|
||||
protected:
|
||||
void Toggle();
|
||||
virtual void Notify() { Toggle(); }
|
||||
|
||||
public:
|
||||
void SetPos(int x, int y) { _pos.h = x; _pos.v = y; }
|
||||
void SetSize(int x, int y) { _size.x = x; _size.y = y; }
|
||||
void Show(WINDOW w, bool on = true);
|
||||
void Hide() { Show(false); }
|
||||
bool IsVisible() const { return _visible; }
|
||||
WINDOW Owner() const { return _owner; }
|
||||
void Kill();
|
||||
|
||||
TwxCaret() : _visible(false), _owner(NULL_WIN) { }
|
||||
virtual ~TwxCaret() { Kill(); }
|
||||
} _TheCaret;
|
||||
|
||||
void TwxCaret::Kill()
|
||||
{
|
||||
_owner = NULL_WIN;
|
||||
if (wxTimer::IsRunning())
|
||||
wxTimer::Stop();
|
||||
}
|
||||
|
||||
void TwxCaret::Show(WINDOW w, bool on)
|
||||
{
|
||||
if (_visible && _drawn)
|
||||
Toggle(); // Lo cancella
|
||||
|
||||
_visible = on;
|
||||
if (on)
|
||||
{
|
||||
_owner = w;
|
||||
Toggle();
|
||||
wxTimer::Start(500); // Lampeggia ogni mezzo secondo
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w == _owner)
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
|
||||
void TwxCaret::Toggle()
|
||||
{
|
||||
if (!_visible || _owner == NULL_WIN)
|
||||
return;
|
||||
|
||||
_drawn = !_drawn;
|
||||
|
||||
DRAW_CTOOLS dct;
|
||||
xvt_dwin_get_draw_ctools(_owner, &dct);
|
||||
|
||||
CPEN pen;
|
||||
pen.width = _size.x;
|
||||
pen.pat = PAT_SOLID;
|
||||
pen.style = P_SOLID;
|
||||
pen.color = _drawn ? dct.fore_color : dct.back_color;
|
||||
xvt_dwin_set_cpen(_owner, &pen);
|
||||
xvt_dwin_set_draw_mode(_owner, M_COPY);
|
||||
xvt_dwin_draw_set_pos(_owner, _pos);
|
||||
PNT p = _pos; p.v -= _size.y;
|
||||
|
||||
xvt_dwin_set_clip(_owner, NULL); // Non si mai!
|
||||
xvt_dwin_draw_line(_owner, p);
|
||||
xvt_dwin_set_draw_ctools(_owner, &dct);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Generic window class
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -572,7 +581,7 @@ class TwxWindow : public TwxWindowBase
|
||||
void DoXvtEvent(EVENT& e);
|
||||
|
||||
protected:
|
||||
virtual void OnKeyDown(wxKeyEvent& e);
|
||||
virtual void OnChar(wxKeyEvent& e);
|
||||
virtual void OnKillFocus(wxFocusEvent& e);
|
||||
virtual void OnMenu(wxCommandEvent& event);
|
||||
virtual void OnMouseDouble(wxMouseEvent& e);
|
||||
@ -641,7 +650,7 @@ public:
|
||||
IMPLEMENT_DYNAMIC_CLASS(TwxWindow, TwxWindowBase)
|
||||
|
||||
BEGIN_EVENT_TABLE(TwxWindow, TwxWindowBase)
|
||||
EVT_CHAR(TwxWindow::OnKeyDown)
|
||||
EVT_CHAR(TwxWindow::OnChar)
|
||||
EVT_KILL_FOCUS(TwxWindow::OnKillFocus)
|
||||
EVT_LEFT_DCLICK(TwxWindow::OnMouseDouble)
|
||||
EVT_LEFT_DOWN(TwxWindow::OnMouseDown)
|
||||
@ -664,7 +673,7 @@ void TwxWindow::DoXvtEvent(EVENT& e)
|
||||
_eh((WINDOW)this, &e);
|
||||
}
|
||||
|
||||
void TwxWindow::OnKeyDown(wxKeyEvent& event)
|
||||
void TwxWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CHAR;
|
||||
@ -879,7 +888,7 @@ void TwxWindow::OnTimer(wxTimerEvent& event)
|
||||
void TwxWindow::SetMenuTree(const MENU_ITEM* tree)
|
||||
{
|
||||
XVT_ASSERT(tree != NULL);
|
||||
if (tree)
|
||||
if (tree != NULL)
|
||||
{
|
||||
if (m_menu)
|
||||
xvt_res_free_menu_tree(m_menu);
|
||||
@ -953,9 +962,12 @@ void TTaskWin::OnPaint()
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_UPDATE;
|
||||
RCT& rct = e.v.update.rct;
|
||||
rct.left = rct.top = 0;
|
||||
int w, h; GetClientSize(&w, &h);
|
||||
rct.right = w; rct.bottom = h;
|
||||
|
||||
wxRect rctDamaged = GetUpdateRegion().GetBox();
|
||||
rct.left = rctDamaged.x;
|
||||
rct.top = rctDamaged.y;
|
||||
rct.right = rctDamaged.GetRight()+1;
|
||||
rct.bottom = rctDamaged.GetBottom()+1;
|
||||
|
||||
TDC& dc = _dc_map.GetTDC(this);
|
||||
dc.GetDC(true); // Forza la creazione di un wxPaintDC
|
||||
@ -1008,7 +1020,8 @@ void TTaskWin::SetMenuTree(const MENU_ITEM* tree)
|
||||
|
||||
void TTaskWin::PushMenuTree(const MENU_ITEM* tree, wxWindow* owner)
|
||||
{
|
||||
XVT_ASSERT(m_pOldBar == NULL);
|
||||
if(m_pOldBar != NULL)
|
||||
PopMenuTree();
|
||||
m_pOldBar = GetMenuBar();
|
||||
|
||||
wxMenuBar* pBar = new wxMenuBar;
|
||||
@ -1052,8 +1065,6 @@ TTaskWin::TTaskWin(wxWindow *parent, wxWindowID id,
|
||||
|
||||
TTaskWin::~TTaskWin()
|
||||
{
|
||||
_TheCaret.Kill();
|
||||
|
||||
if (m_menu)
|
||||
{
|
||||
xvt_res_free_menu_tree(m_menu);
|
||||
@ -1124,7 +1135,6 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
((wxFrame*)_task_win)->SetMenuBar(pMenubar);
|
||||
|
||||
_task_win->Show();
|
||||
_task_win->Raise();
|
||||
if (style & wxMAXIMIZE)
|
||||
((wxFrame*)_task_win)->Maximize();
|
||||
|
||||
@ -1492,22 +1502,21 @@ void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
|
||||
if (image)
|
||||
{
|
||||
CAST_DC(win, dc);
|
||||
const wxBitmap& bmp = ((TXVT_IMAGE*)image)->Bitmap();
|
||||
const wxRect src = NormalizeRCT(source);
|
||||
const wxRect dst = NormalizeRCT(dest);
|
||||
if (src.GetSize() == dst.GetSize())
|
||||
const wxBitmap& bmp = ((TXVT_IMAGE*)image)->Bitmap();
|
||||
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize())
|
||||
{
|
||||
dc.DrawBitmap(bmp, dst.GetPosition());
|
||||
}
|
||||
else
|
||||
{
|
||||
wxMemoryDC temp_dc;
|
||||
temp_dc.SelectObject(bmp);
|
||||
#ifdef WIN32
|
||||
OsWin32_StretchBlt(dc.GetHDC(), dst.x, dst.y, dst.width, dst.height,
|
||||
temp_dc.GetHDC(), src.x, src.y, src.width, src.height);
|
||||
OsWin32_DrawBitmap(bmp.GetHBITMAP(), dc.GetHDC(),
|
||||
dst.x, dst.y, dst.width, dst.height,
|
||||
src.x, src.y, src.width, src.height);
|
||||
#else
|
||||
dc.Blit(dst.GetPosition(), dst.GetSize(), &temp_dc, wxPoint(0,0));
|
||||
SORRY_BOX();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1745,7 +1754,9 @@ void xvt_dwin_draw_line(WINDOW win, PNT pnt)
|
||||
{
|
||||
CAST_TDC(win, dc);
|
||||
const wxPoint to(pnt.h, pnt.v);
|
||||
dc.GetDC().DrawLine(dc._pnt, to);
|
||||
if (dc._pnt != to)
|
||||
dc.GetDC().DrawLine(dc._pnt, to);
|
||||
dc.GetDC().DrawPoint(to);
|
||||
dc._pnt = to;
|
||||
}
|
||||
|
||||
@ -2024,7 +2035,6 @@ BOOLEAN xvt_fsys_set_dir(DIRECTORY *dirp)
|
||||
|
||||
XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, long reserved)
|
||||
{
|
||||
SORRY_BOX();
|
||||
TXVT_IMAGE* i = new TXVT_IMAGE;
|
||||
i->Image().Create(width, height);
|
||||
return (XVT_IMAGE)i;
|
||||
@ -2180,7 +2190,19 @@ void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color)
|
||||
}
|
||||
|
||||
void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp)
|
||||
{ SORRY_BOX(); }
|
||||
{
|
||||
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
|
||||
const wxImage& src = ((const TXVT_IMAGE*)srcimage)->Image();
|
||||
const wxRect rctDst = NormalizeRCT(dstrctp);
|
||||
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
||||
|
||||
wxImage sub = src.GetSubImage(NormalizeRCT(srcrctp));
|
||||
sub.Rescale(rctDst.width, rctDst.height);
|
||||
if (rctDst.x == 0 && rctDst.y == 0)
|
||||
dst = sub;
|
||||
else
|
||||
SORRY_BOX();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Memory management
|
||||
@ -2197,13 +2219,23 @@ DATA_PTR xvt_mem_realloc(DATA_PTR p, size_t size)
|
||||
|
||||
DATA_PTR xvt_mem_rep(DATA_PTR dst, DATA_PTR src, unsigned int srclen, long reps)
|
||||
{
|
||||
memcpy(dst, src, srclen*reps);
|
||||
XVT_ASSERT(dst != NULL || src != NULL);
|
||||
|
||||
if (srclen == 1)
|
||||
memset(dst, *src, reps);
|
||||
else
|
||||
{
|
||||
for (long i = 0; i < reps; i++)
|
||||
memcpy(dst + i*srclen, src, srclen);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
DATA_PTR xvt_mem_zalloc(size_t size)
|
||||
{
|
||||
return (DATA_PTR)calloc(size, 1);
|
||||
DATA_PTR ptr = xvt_mem_alloc(size);
|
||||
memset(ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -2223,7 +2255,7 @@ MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m)
|
||||
if (m != NULL && m->tag > 0)
|
||||
{
|
||||
const int n = xvt_menu_count(m)+1;
|
||||
TheMenu = new MENU_ITEM[n];
|
||||
TheMenu = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*n);
|
||||
memcpy(TheMenu, m, n*sizeof(MENU_ITEM));
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
@ -2350,10 +2382,9 @@ BOOLEAN xvt_rect_intersect(RCT *drctp, RCT *rctp1, RCT *rctp2)
|
||||
return yes;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_rect_is_empty(RCT *rct)
|
||||
BOOLEAN xvt_rect_is_empty(const RCT *rct)
|
||||
{
|
||||
XVT_ASSERT(rct != NULL);
|
||||
return rct->left==rct->right && rct->top==rct->bottom;
|
||||
return rct == NULL || (rct->left==rct->right && rct->top==rct->bottom);
|
||||
}
|
||||
|
||||
void xvt_rect_offset(RCT *rctp, short dh, short dv)
|
||||
@ -2403,16 +2434,16 @@ BOOLEAN xvt_rect_set_pos(RCT *rctp, PNT pos)
|
||||
void xvt_res_free_menu_tree(MENU_ITEM* tree)
|
||||
{
|
||||
XVT_ASSERT(tree != NULL);
|
||||
if (tree)
|
||||
if (tree != NULL)
|
||||
{
|
||||
for ( ; tree->tag != 0; tree++)
|
||||
for (MENU_ITEM* item = tree; item->tag != 0; item++)
|
||||
{
|
||||
if (tree->text)
|
||||
free(tree->text);
|
||||
if (tree->child)
|
||||
xvt_res_free_menu_tree(tree->child);
|
||||
if (item->text)
|
||||
xvt_mem_free(item->text);
|
||||
if (item->child != NULL)
|
||||
xvt_res_free_menu_tree(item->child);
|
||||
}
|
||||
delete [] tree;
|
||||
xvt_mem_free((DATA_PTR)tree);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2475,8 +2506,7 @@ MENU_ITEM* xvt_res_get_menu(int rid)
|
||||
wxFileConfig ini("", "", strName);
|
||||
|
||||
const int MAX_MENU = 16;
|
||||
MENU_ITEM* TheMenu = new MENU_ITEM[MAX_MENU];
|
||||
memset(TheMenu, 0, MAX_MENU*sizeof(MENU_ITEM));
|
||||
MENU_ITEM* TheMenu = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*MAX_MENU);
|
||||
|
||||
if (rid >= 10000 && rid < 10100)
|
||||
{
|
||||
@ -2496,8 +2526,8 @@ MENU_ITEM* xvt_res_get_menu(int rid)
|
||||
if (ini.Read(strItem, &strName))
|
||||
{
|
||||
FillMenuItem(strName, mi);
|
||||
mi = mi->child = new MENU_ITEM[MAX_MENU];
|
||||
memset(mi, 0, MAX_MENU*sizeof(MENU_ITEM)); // Reset menu
|
||||
mi = mi->child = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*MAX_MENU);
|
||||
|
||||
for (int j = 0; j < MAX_MENU; j++, mi++)
|
||||
{
|
||||
strItem = wxString::Format("Item_%02d_%02d", i, j);
|
||||
@ -3042,7 +3072,7 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
|
||||
style |= wxCAPTION | wxSYSTEM_MENU;
|
||||
break;
|
||||
case W_PLAIN:
|
||||
style |= wxBORDER;
|
||||
// style |= wxBORDER; // Non attivare MAI il bordo!
|
||||
break;
|
||||
default:
|
||||
SORRY_BOX(); break;
|
||||
@ -3152,7 +3182,8 @@ void xvt_win_set_handler(WINDOW win, EVENT_HANDLER eh)
|
||||
void xvt_win_trap_pointer(WINDOW win)
|
||||
{
|
||||
CAST_WIN(win, w);
|
||||
XVT_ASSERT(_mouse_trapper == NULL || _mouse_trapper == &w);
|
||||
if (_mouse_trapper != NULL)
|
||||
_mouse_trapper->ReleaseMouse();
|
||||
w.CaptureMouse();
|
||||
_mouse_trapper = &w;
|
||||
}
|
||||
@ -3206,6 +3237,7 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
|
||||
XVT_ASSERT(parent_win == TASK_WIN);
|
||||
TTaskWin& w = *(TTaskWin*)parent_win;
|
||||
w.CreateStatusBar(2);
|
||||
w.GetStatusBar()->Show();
|
||||
wxSize sz = w.GetClientSize();
|
||||
|
||||
int widths[2];
|
||||
|
@ -169,6 +169,7 @@ void xvt_palet_set_tolerance(XVT_PALETTE p, int t);
|
||||
void xvt_print_close(void);
|
||||
BOOLEAN xvt_print_close_page(PRINT_RCD *precp);
|
||||
PRINT_RCD* xvt_print_create(int *sizep);
|
||||
PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name);
|
||||
WINDOW xvt_print_create_win(PRINT_RCD *precp, char *title);
|
||||
void xvt_print_destroy(PRINT_RCD *precp);
|
||||
RCT* xvt_print_get_next_band(void);
|
||||
@ -181,7 +182,7 @@ int xvt_rect_get_height(RCT *rctp);
|
||||
int xvt_rect_get_width(RCT *rctp);
|
||||
BOOLEAN xvt_rect_has_point(RCT *rctp, PNT pnt);
|
||||
BOOLEAN xvt_rect_intersect(RCT *drctp, RCT *rctp1, RCT *rctp2);
|
||||
BOOLEAN xvt_rect_is_empty(RCT *rctp);
|
||||
BOOLEAN xvt_rect_is_empty(const RCT *rctp);
|
||||
void xvt_rect_offset(RCT *rctp, short dh, short dv);
|
||||
void xvt_rect_set(RCT *rctp, short left, short top, short right, short bottom);
|
||||
void xvt_rect_set_empty(RCT *rctp);
|
||||
|
@ -8,13 +8,42 @@
|
||||
|
||||
#include "xvintern.h"
|
||||
|
||||
#pragma pack(4)
|
||||
|
||||
struct TPRINT_RCD : public PRINT_RCD
|
||||
{
|
||||
char m_data[4096];
|
||||
unsigned char m_data[16*1024];
|
||||
unsigned int m_size; // Dimensione della struct DEVMODE
|
||||
|
||||
TPRINT_RCD() { pr = NULL; memset(m_data, 0, sizeof(m_data)); }
|
||||
void SetData(void* data, unsigned int nSize);
|
||||
TPRINT_RCD();
|
||||
~TPRINT_RCD();
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
void TPRINT_RCD::SetData(void* data, unsigned int nSize)
|
||||
{
|
||||
if (nSize <= sizeof(m_data))
|
||||
{
|
||||
memcpy(m_data, data, nSize);
|
||||
m_size = nSize;
|
||||
}
|
||||
}
|
||||
|
||||
TPRINT_RCD::TPRINT_RCD() : m_size(0)
|
||||
{
|
||||
pr = NULL;
|
||||
memset(m_data, 0, sizeof(m_data));
|
||||
}
|
||||
|
||||
TPRINT_RCD::~TPRINT_RCD()
|
||||
{
|
||||
memset(m_data, 0, sizeof(m_data));
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TwxPrintOut
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -58,7 +87,7 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
|
||||
{
|
||||
wxPrintData data;
|
||||
#ifdef WIN32
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data));
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
|
||||
#else
|
||||
data.SetNativeData(prcd->m_data);
|
||||
#endif
|
||||
@ -142,11 +171,11 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
|
||||
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
||||
|
||||
wxPageSetupData& pdd = dlg.GetPageSetupData();
|
||||
pdd.EnablePrinter(false); // Vieta di cambiare stampante
|
||||
// pdd.EnablePrinter(false); // Vieta di cambiare stampante
|
||||
wxPrintData& data = pdd.GetPrintData();
|
||||
|
||||
#ifdef WIN32
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(rcd->m_data));
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(rcd->m_data, rcd->m_size));
|
||||
#else
|
||||
data.SetNativeData(rcd->m_data);
|
||||
#endif
|
||||
@ -157,11 +186,12 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
|
||||
data.ConvertToNative();
|
||||
void* pHandle = data.GetNativeData();
|
||||
#ifdef WIN32
|
||||
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle);
|
||||
memcpy(rcd->m_data, ptr, sizeof(rcd->m_data));
|
||||
unsigned int nSize = 0;
|
||||
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
|
||||
rcd->SetData(ptr, nSize);
|
||||
delete ptr;
|
||||
#else
|
||||
memcpy(rcd->m_data, pHandle, sizeof(rcd->m_data));
|
||||
rcd->SetData(pHandle, 1024);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
@ -204,7 +234,7 @@ long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_famil
|
||||
|
||||
void xvt_print_close(void)
|
||||
{
|
||||
// Nothing to do
|
||||
// Nothing to do ?
|
||||
}
|
||||
|
||||
BOOLEAN xvt_print_close_page(PRINT_RCD* /*precp*/)
|
||||
@ -219,12 +249,32 @@ PRINT_RCD* xvt_print_create(int *sizep)
|
||||
{
|
||||
TPRINT_RCD* pr = new TPRINT_RCD;
|
||||
#ifdef WIN32
|
||||
*sizep = OsWin32_GetDefaultPrinterInfo(pr->m_data, sizeof(pr->m_data));
|
||||
void* data = OsWin32_GetPrinterInfo(*sizep, NULL);
|
||||
pr->SetData(data, *sizep);
|
||||
delete data;
|
||||
*sizep += 4; // Spazio per puntatore iniziale
|
||||
#else
|
||||
*sizep = 0;
|
||||
#endif
|
||||
*sizep += 4; // Unused pointer size
|
||||
return pr;
|
||||
}
|
||||
|
||||
// Nuova funzione inventata da Aga
|
||||
PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
|
||||
{
|
||||
TPRINT_RCD* pr = new TPRINT_RCD;
|
||||
#ifdef WIN32
|
||||
void* data = OsWin32_GetPrinterInfo(*sizep, name);
|
||||
pr->SetData(data, *sizep);
|
||||
delete data;
|
||||
*sizep += 4; // Spazio per puntatore iniziale
|
||||
#else
|
||||
*sizep = 0;
|
||||
#endif
|
||||
return pr;
|
||||
}
|
||||
|
||||
|
||||
WINDOW xvt_print_create_win(PRINT_RCD* precp, char* /* title */)
|
||||
{
|
||||
WINDOW win = NULL_WIN;
|
||||
@ -263,11 +313,12 @@ RCT* xvt_print_get_next_band(void)
|
||||
|
||||
BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
|
||||
{
|
||||
BOOLEAN ok = precp != NULL;
|
||||
BOOLEAN ok = precp != NULL && precp->pr == NULL;
|
||||
if (ok)
|
||||
{
|
||||
#ifdef WIN32
|
||||
ok = OsWin32_CheckPrinterInfo(((TPRINT_RCD*)precp)->m_data);
|
||||
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
||||
ok = OsWin32_CheckPrinterInfo(rcd->m_data, rcd->m_size);
|
||||
#endif
|
||||
}
|
||||
return ok;
|
||||
|
Loading…
x
Reference in New Issue
Block a user