Patch level : 2.0 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Corretta stampa bitmap enormi sotto Win98


git-svn-id: svn://10.65.10.50/trunk@11652 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-12-03 09:42:58 +00:00
parent 6bac6177c4
commit fc086717c5
3 changed files with 53 additions and 100 deletions

View File

@ -181,25 +181,6 @@ void OsWin32_SetCaptionStyle(unsigned int handle, bool set)
::SetWindowLong(hwnd, GWL_STYLE, s);
}
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h)
{
HDC hdc = (HDC)hDC;
if (w > 0 && h > 0)
{
HRGN hrgn = ::CreateRectRgn(x, y, x+w, y+h);
::SelectClipRgn(hdc, hrgn);
::DeleteObject(hrgn);
}
else
::SelectClipRgn(hdc, NULL);
}
void OsWin32_UpdateWindow(unsigned int handle)
{
HWND hwnd = (HWND)handle;
::UpdateWindow(hwnd);
}
///////////////////////////////////////////////////////////
// Drawing bitmaps
///////////////////////////////////////////////////////////
@ -236,7 +217,8 @@ bool OsWin32_DrawBitmap(const wxBitmap& bmp, wxDC& dc, const wxRect& dst, const
else
{
HGDIOBJ hOldBitmap = ::SelectObject(hMemDC, hBMP);
::SetStretchBltMode(hDC, COLORONCOLOR);
const wxPalette* pPalette = bmp.GetPalette();
::SetStretchBltMode(hDC, pPalette == NULL ? COLORONCOLOR : HALFTONE);
::StretchBlt(hDC, dst.x, dst.y, dst.width, dst.height,
hMemDC, src.x, src.y, src.width, src.height, SRCCOPY);
::SelectObject(hMemDC, hOldBitmap);
@ -307,39 +289,6 @@ int OsWin32_Help(unsigned int handle, const char* hlp, unsigned int cmd, const c
{
HWND hwnd = (HWND)handle;
/*
switch(cmd)
{
case M_HELP_CONTENTS:
::WinHelp(hwnd, hlp, HELP_CONTENTS, 0);
break;
case M_HELP_SEARCH:
::WinHelp(hwnd, hlp, HELP_PARTIALKEY, (DWORD)"");
break;
case M_HELP_HELPONHELP:
::WinHelp(hwnd, hlp, HELP_HELPONHELP, 0);
break;
case M_HELP_ONCONTEXT:
if (topic != NULL)
{
struct MULTIGUY
{
DWORD mkSize;
TCHAR mkKeylist;
TCHAR mkKeyphrase[16];
} mk;
mk.mkSize = sizeof(MULTIGUY);
mk.mkKeylist = 'M';
strncpy(mk.mkKeyphrase, topic, sizeof(mk.mkKeyphrase));
::WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk);
}
break;
default:
::WinHelp(hwnd, hlp, HELP_QUIT, 0);
break;
}
*/
wxString str;
switch(cmd)
{

View File

@ -13,7 +13,6 @@ 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);
void* OsWin32_GetPrinterInfo(int& size, const char* printer);
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h);
void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
void OsWin32_UpdateWindow(unsigned int handle);

View File

@ -5,13 +5,11 @@
#include "wx/confbase.h"
#include "wx/fileconf.h"
#include "wx/fontdlg.h"
#include "wx/fs_zip.h"
#include "wx/image.h"
#include <wx/snglinst.h>
#include <wx/thread.h>
#include "wx/fs_zip.h"
#include "wx/html/helpctrl.h"
#include "xvt.h"
#include "statbar.h"
@ -1705,7 +1703,7 @@ struct XVAGA_HELP_INFO
{
wxString m_strFilename;
bool m_hlp;
wxHtmlHelpController m_hc;
// wxHtmlHelpController m_hc;
} help_info;
XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags)
@ -2025,7 +2023,7 @@ void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid)
}
}
wxRect ComputeRect(const wxRect& rct, int h, int v, int k)
static wxRect ComputeRect(const wxRect& rct, int h, int v, int k)
{
const int sx = rct.x + h * rct.width / k;
const int ex = rct.x + (h+1) * rct.width / k;
@ -2034,45 +2032,49 @@ wxRect ComputeRect(const wxRect& rct, int h, int v, int k)
return wxRect(sx, sy, ex-sx, ey-sy);
}
static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const wxRect& src)
{
const wxBitmap& bmp = image->Bitmap();
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize() && bmp.Ok())
{
dc.DrawBitmap(bmp, dst.GetPosition());
}
else
{
#ifdef WIN32
if (!OsWin32_DrawBitmap(bmp, dc, dst, src))
{
const int k = 4;
for (int h = 0; h < k; h++)
{
for (int v = 0; v < k; v++)
{
const wxRect destin = ComputeRect(dst, h, v, k);
wxRect source = ComputeRect(src, h, v, k);
wxImage img = image->Image().GetSubImage(source);
source.x = source.y = 0;
OsWin32_DrawBitmap(img.ConvertToBitmap(), dc, destin, source);
}
}
}
#else
const wxImage& img = ((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height);
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
#endif
}
}
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
{
XVT_ASSERT(image != NULL);
if (image)
if (image != NULL)
{
CAST_DC(win, dc);
const wxRect src = NormalizeRCT(source);
const wxRect dst = NormalizeRCT(dest);
const wxBitmap& bmp = ((TXVT_IMAGE*)image)->Bitmap();
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize() && bmp.Ok())
{
dc.DrawBitmap(bmp, dst.GetPosition());
}
else
{
#ifdef WIN32
if (!OsWin32_DrawBitmap(bmp, dc, dst, src))
{
const int k = 4;
for (int h = 0; h < k; h++)
{
for (int v = 0; v < k; v++)
{
const wxRect destin = ComputeRect(dst, h, v, k);
wxRect source = ComputeRect(src, h, v, k);
wxImage img = ((TXVT_IMAGE*)image)->Image().GetSubImage(source);
source.x = source.y = 0;
OsWin32_DrawBitmap(img.ConvertToBitmap(), dc, destin, source);
}
}
}
#else
const wxImage& img = ((TXVT_IMAGE*)image)->Image());
wxImage sub = img.GetSubImage(src);
sub.Rescale(dst.width, dst.height);
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
#endif
}
DrawImageOnDC(dc, (TXVT_IMAGE*)image, dst, src);
}
}
@ -2354,13 +2356,8 @@ void xvt_dwin_draw_line(WINDOW win, PNT pnt)
void xvt_dwin_update(WINDOW win)
{
// "sembra" che non serva ad un fico secco, ma FORSE in Windows serve!
#ifdef WIN32
CAST_TWIN(win, w);
OsWin32_UpdateWindow(w.GetHWND());
#else
OsLinux_UpdateWindow(win);
#endif
w.Update();
}
///////////////////////////////////////////////////////////
@ -2933,16 +2930,24 @@ 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)
{
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
const wxImage& src = ((const TXVT_IMAGE*)srcimage)->Image();
const wxRect rctDst = NormalizeRCT(dstrctp);
const wxRect rctDst = NormalizeRCT(dstrctp);
const wxRect rctSrc = NormalizeRCT(srcrctp);
#if 0
// Vecchio modo obsoleto e meno potente
const wxImage& src = ((const TXVT_IMAGE*)srcimage)->Image();
wxImage sub = src.GetSubImage(rctSrc);
sub.Rescale(rctDst.width, rctDst.height);
if (rctDst.x == 0 && rctDst.y == 0)
dst = sub;
else
SORRY_BOX();
#else
wxMemoryDC dc;
dc.SelectObject( ((TXVT_IMAGE*)dstimage)->Bitmap() );
DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc);
dst = dc.GetSelectedBitmap();
dc.SelectObject(wxNullBitmap);
#endif
}
///////////////////////////////////////////////////////////