From 6a93571daf0f1dc47ac37951852b895153cbd779 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 31 Aug 2006 05:35:26 +0000 Subject: [PATCH] Provide an implementation for SurfaceImpl::AlphaRectangle, and rename [G|S]etCaretLineBack git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/stc/stc.h | 4 +- contrib/src/stc/PlatWX.cpp | 68 +++++++++++++++++++++++++++-- contrib/src/stc/gen_iface.py | 4 +- contrib/src/stc/stc.cpp | 4 +- include/wx/stc/stc.h | 4 +- src/stc/PlatWX.cpp | 68 +++++++++++++++++++++++++++-- src/stc/gen_iface.py | 4 +- src/stc/stc.cpp | 4 +- wxPython/contrib/stc/_stc_gendocs.i | 4 +- 9 files changed, 146 insertions(+), 18 deletions(-) diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index dde5aa02b6..a48accc7f4 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -2157,10 +2157,10 @@ public: void SetCaretLineVisible(bool show); // Get the colour of the background of the line containing the caret. - wxColour GetCaretLineBack(); + wxColour GetCaretLineBackground(); // Set the colour of the background of the line containing the caret. - void SetCaretLineBack(const wxColour& back); + void SetCaretLineBackground(const wxColour& back); // Set a style to be changeable or not (read only). // Experimental feature, currently buggy. diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index 2e80894a47..e0445dd848 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -13,6 +13,7 @@ #include "wx/image.h" #include "wx/imaglist.h" #include "wx/tokenzr.h" +#include "wx/rawbmp.h" #include "Platform.h" #include "PlatWX.h" @@ -334,12 +335,73 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAl 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) { -// ** TODO + ColourAllocated outline, int alphaOutline, + int /*flags*/) { + 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; yDrawBitmap(bmp, r.x, r.y, true); } void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { diff --git a/contrib/src/stc/gen_iface.py b/contrib/src/stc/gen_iface.py index 5c268849a3..c432d18884 100644 --- a/contrib/src/stc/gen_iface.py +++ b/contrib/src/stc/gen_iface.py @@ -488,7 +488,9 @@ methodOverrideMap = { 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0), 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0), - + + 'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0), + 'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0), 'ReplaceTarget' : (0, diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 108dc0288c..bc54bf966c 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -786,13 +786,13 @@ void wxStyledTextCtrl::SetCaretLineVisible(bool show) { } // Get the colour of the background of the line containing the caret. -wxColour wxStyledTextCtrl::GetCaretLineBack() { +wxColour wxStyledTextCtrl::GetCaretLineBackground() { long c = SendMsg(2097, 0, 0); return wxColourFromLong(c); } // Set the colour of the background of the line containing the caret. -void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) { +void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back) { SendMsg(2098, wxColourAsLong(back), 0); } diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index dde5aa02b6..a48accc7f4 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -2157,10 +2157,10 @@ public: void SetCaretLineVisible(bool show); // Get the colour of the background of the line containing the caret. - wxColour GetCaretLineBack(); + wxColour GetCaretLineBackground(); // Set the colour of the background of the line containing the caret. - void SetCaretLineBack(const wxColour& back); + void SetCaretLineBackground(const wxColour& back); // Set a style to be changeable or not (read only). // Experimental feature, currently buggy. diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 2e80894a47..e0445dd848 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -13,6 +13,7 @@ #include "wx/image.h" #include "wx/imaglist.h" #include "wx/tokenzr.h" +#include "wx/rawbmp.h" #include "Platform.h" #include "PlatWX.h" @@ -334,12 +335,73 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAl 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) { -// ** TODO + ColourAllocated outline, int alphaOutline, + int /*flags*/) { + 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; yDrawBitmap(bmp, r.x, r.y, true); } void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 5c268849a3..c432d18884 100644 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -488,7 +488,9 @@ methodOverrideMap = { 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0), 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0), - + + 'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0), + 'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0), 'ReplaceTarget' : (0, diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 108dc0288c..bc54bf966c 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -786,13 +786,13 @@ void wxStyledTextCtrl::SetCaretLineVisible(bool show) { } // Get the colour of the background of the line containing the caret. -wxColour wxStyledTextCtrl::GetCaretLineBack() { +wxColour wxStyledTextCtrl::GetCaretLineBackground() { long c = SendMsg(2097, 0, 0); return wxColourFromLong(c); } // Set the colour of the background of the line containing the caret. -void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) { +void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back) { SendMsg(2098, wxColourAsLong(back), 0); } diff --git a/wxPython/contrib/stc/_stc_gendocs.i b/wxPython/contrib/stc/_stc_gendocs.i index a7686c21a8..e109b07ddf 100644 --- a/wxPython/contrib/stc/_stc_gendocs.i +++ b/wxPython/contrib/stc/_stc_gendocs.i @@ -306,10 +306,10 @@ DocStr(wxStyledTextCtrl::GetCaretLineVisible, DocStr(wxStyledTextCtrl::SetCaretLineVisible, "Display the background of the line containing the caret in a different colour.", ""); -DocStr(wxStyledTextCtrl::GetCaretLineBack, +DocStr(wxStyledTextCtrl::GetCaretLineBackground, "Get the colour of the background of the line containing the caret.", ""); -DocStr(wxStyledTextCtrl::SetCaretLineBack, +DocStr(wxStyledTextCtrl::SetCaretLineBackground, "Set the colour of the background of the line containing the caret.", ""); DocStr(wxStyledTextCtrl::StyleSetChangeable, -- 2.45.2