#include "wx/dcmemory.h"
#include "wx/window.h"
#include "wx/app.h"
+#include "wx/image.h"
+
#include <math.h>
#include <Xm/Xm.h>
XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
m_oldFont = (WXFont) valReturn.font;
+
+ SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID));
};
wxWindowDC::~wxWindowDC(void)
#endif
};
+// TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities
bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
wxDC *source, long xsrc, long ysrc, int rop, bool useMask )
{
// last selected background color. [::SetBackground]
if (m_pen.Ok() && m_autoSetting)
SetPen (m_pen);
-
- if (m_pixmap && sourceDC->m_pixmap)
+
+ // Do bitmap scaling if necessary
+
+ wxBitmap *scaledBitmap = (wxBitmap*) NULL;
+ Pixmap sourcePixmap = (Pixmap) NULL;
+ double scaleX, scaleY;
+ GetUserScale(& scaleX, & scaleY);
+
+ // Sorry, can't scale masks just yet
+ if (!useMask && (scaleX != 1.0 || scaleY != 1.0) && sourceDC->IsKindOf(CLASSINFO(wxMemoryDC)))
+ {
+ wxMemoryDC* memDC = (wxMemoryDC*) sourceDC;
+ wxBitmap& bitmap = memDC->GetBitmap();
+
+ wxASSERT_MSG( (bitmap.Ok()), "Bad source bitmap in wxWindowDC::Blit");
+
+ wxImage image(bitmap);
+ if (!image.Ok())
+ {
+ sourcePixmap = (Pixmap) bitmap.GetPixmap();
+ }
+ else
+ {
+ int scaledW = (int) (bitmap.GetWidth() * scaleX);
+ int scaledH = (int) (bitmap.GetHeight() * scaleY);
+
+ image = image.Scale(scaledW, scaledH);
+ scaledBitmap = new wxBitmap(image.ConvertToBitmap());
+ sourcePixmap = (Pixmap) scaledBitmap->GetPixmap();
+ }
+ }
+ else
+ sourcePixmap = (Pixmap) sourceDC->m_pixmap;
+
+ if (m_pixmap && sourcePixmap)
{
/* MATTHEW: [9] */
int orig = m_logicalFunction;
if (m_window && m_window->GetBackingPixmap())
XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display,
- (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),
+ (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),
(GC) m_gcBacking,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
}
}
- XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
// +++ MARKUS (mho@comnets.rwth-aachen): error on blitting bitmaps with depth 1
if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && ((wxMemoryDC*) source)->GetBitmap().GetDepth() == 1)
{
- XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
}
else
{
- XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
if (source->IsKindOf(CLASSINFO(wxMemoryDC)) &&
((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1))
{
- XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
}
else
{
- XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
CalcBoundingBox (xdest + width, ydest + height);
SetLogicalFunction(orig);
+
+ if (scaledBitmap) delete scaledBitmap;
return TRUE;
}
+ if (scaledBitmap) delete scaledBitmap;
+
return FALSE;
};
return;
int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
-
+
+ // New behaviour, 10/2/99: setting the background brush of a DC
+ // doesn't affect the window background colour.
+/*
// XSetWindowBackground doesn't work for non-Window pixmaps
if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
+*/
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
// And Blit,... (Any fct that use XCopyPlane, in fact.)
wx_spline_draw_point_array( this );
};
+// Resolution in pixels per logical inch
+wxSize wxWindowDC::GetPPI(void) const
+{
+ return wxSize(100, 100);
+}
+
/*
* wxPaintDC
*/