#include "wx/imaglist.h"
#include "wx/tokenzr.h"
+#ifdef wxHAVE_RAW_BITMAP
+#include "wx/rawbmp.h"
+#endif
+
#include "Platform.h"
#include "PlatWX.h"
#include "wx/stc/stc.h"
Palette::Palette() {
used = 0;
allowRealization = false;
+ size = 100;
+ entries = new ColourPair[size];
}
Palette::~Palette() {
Release();
+ delete [] entries;
+ entries = 0;
}
void Palette::Release() {
used = 0;
+ delete [] entries;
+ size = 100;
+ entries = new ColourPair[size];
}
// This method either adds a colour to the list of wanted colours (want==true)
return;
}
- if (used < numEntries) {
- entries[used].desired = cp.desired;
- entries[used].allocated.Set(cp.desired.AsLong());
- used++;
+ if (used >= size) {
+ int sizeNew = size * 2;
+ ColourPair *entriesNew = new ColourPair[sizeNew];
+ for (int j=0; j<size; j++) {
+ entriesNew[j] = entries[j];
+ }
+ delete []entries;
+ entries = entriesNew;
+ size = sizeNew;
}
+
+ entries[used].desired = cp.desired;
+ entries[used].allocated.Set(cp.desired.AsLong());
+ used++;
} else {
for (int i=0; i < used; i++) {
if (entries[i].desired == cp.desired) {
virtual void FillRectangle(PRectangle rc, ColourAllocated back);
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern);
virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
+ ColourAllocated outline, int alphaOutline, int flags);
virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource);
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
}
+#ifdef __WXMSW__
+#define wxPy_premultiply(p, a) ((p) * (a) / 0xff)
+#else
+#define wxPy_premultiply(p, a) (p)
+#endif
+
+void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize,
+ ColourAllocated fill, int alphaFill,
+ ColourAllocated outline, int alphaOutline,
+ int /*flags*/) {
+#ifdef wxHAVE_RAW_BITMAP
+
+ // TODO: do something with cornerSize
+ wxUnusedVar(cornerSize);
+
+ int x, y;
+ wxRect r = wxRectFromPRectangle(rc);
+ wxBitmap bmp(r.width, r.height, 32);
+ wxAlphaPixelData pixData(bmp);
+ pixData.UseAlpha();
+
+ // Set the fill pixels
+ ColourDesired cdf(fill.AsLong());
+ int red = cdf.GetRed();
+ int green = cdf.GetGreen();
+ int blue = cdf.GetBlue();
+
+ wxAlphaPixelData::Iterator p(pixData);
+ for (y=0; y<r.height; y++) {
+ p.MoveTo(pixData, 0, y);
+ for (x=0; x<r.width; x++) {
+ p.Red() = wxPy_premultiply(red, alphaFill);
+ p.Green() = wxPy_premultiply(green, alphaFill);
+ p.Blue() = wxPy_premultiply(blue, alphaFill);
+ p.Alpha() = alphaFill;
+ ++p;
+ }
+ }
+
+ // Set the outline pixels
+ ColourDesired cdo(outline.AsLong());
+ red = cdo.GetRed();
+ green = cdo.GetGreen();
+ blue = cdo.GetBlue();
+ for (x=0; x<r.width; x++) {
+ p.MoveTo(pixData, x, 0);
+ p.Red() = wxPy_premultiply(red, alphaOutline);
+ p.Green() = wxPy_premultiply(green, alphaOutline);
+ p.Blue() = wxPy_premultiply(blue, alphaOutline);
+ p.Alpha() = alphaOutline;
+ p.MoveTo(pixData, x, r.height-1);
+ p.Red() = wxPy_premultiply(red, alphaOutline);
+ p.Green() = wxPy_premultiply(green, alphaOutline);
+ p.Blue() = wxPy_premultiply(blue, alphaOutline);
+ p.Alpha() = alphaOutline;
+ }
+
+ for (y=0; y<r.height; y++) {
+ p.MoveTo(pixData, 0, y);
+ p.Red() = wxPy_premultiply(red, alphaOutline);
+ p.Green() = wxPy_premultiply(green, alphaOutline);
+ p.Blue() = wxPy_premultiply(blue, alphaOutline);
+ p.Alpha() = alphaOutline;
+ p.MoveTo(pixData, r.width-1, y);
+ p.Red() = wxPy_premultiply(red, alphaOutline);
+ p.Green() = wxPy_premultiply(green, alphaOutline);
+ p.Blue() = wxPy_premultiply(blue, alphaOutline);
+ p.Alpha() = alphaOutline;
+ }
+
+ // Draw the bitmap
+ hdc->DrawBitmap(bmp, r.x, r.y, true);
+
+#else
+ wxUnusedVar(cornerSize);
+ wxUnusedVar(alphaFill);
+ wxUnusedVar(alphaOutline);
+ RectangleDraw(rc, outline, fill);
+#endif
+}
+
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
BrushColour(back);
void Window::InvalidateAll() {
GETWIN(id)->Refresh(false);
- wxWakeUpIdle();
}
void Window::InvalidateRectangle(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc);
GETWIN(id)->Refresh(false, &r);
- wxWakeUpIdle();
}
void Window::SetFont(Font &font) {