X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e9bafca0f56de34638d4c3fef8cf74fe9351193..bceff574a860c4ecd9bb2d5a1a3f8889fef9306a:/contrib/src/stc/PlatWX.cpp diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index 5d7948423b..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" @@ -47,14 +48,21 @@ wxColour wxColourFromCA(const ColourAllocated& ca) { 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) @@ -67,11 +75,20 @@ void Palette::WantFind(ColourPair &cp, bool want) { 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; jDrawRoundedRectangle(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*/) { + 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) { PenColour(fore); BrushColour(back); @@ -543,13 +631,11 @@ void Window::Show(bool show) { 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) { @@ -667,7 +753,7 @@ END_EVENT_TABLE() -#if wxUSE_POPUPWIN //----------------------------------- +#if wxUSE_POPUPWIN //----------------------------------- #include @@ -677,9 +763,9 @@ END_EVENT_TABLE() // implement wxPopupWindow for the Mac!!) // // In the meantime, be careful to duplicate any changes as needed... -// - -// A popup window to place the wxSTCListBox upon +// + +// A popup window to place the wxSTCListBox upon class wxSTCListBoxWin : public wxPopupWindow { private: @@ -687,7 +773,7 @@ private: CallBackAction doubleClickAction; void* doubleClickActionData; public: - wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point location) : + wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : wxPopupWindow(parent, wxBORDER_NONE) { SetBackgroundColour(*wxBLACK); // for our simple border @@ -703,7 +789,7 @@ public: // "right" to the user. But since the wxPopupWindow or its children // can't receive focus then we have to pull a fast one and temporarily // parent the listctrl on the STC window and then call SetFocus and - // then reparent it back to the popup. + // then reparent it back to the popup. lv->SetFocus(); lv->Reparent(this); #ifdef __WXMSW__ @@ -794,7 +880,7 @@ BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxPopupWindow) EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) END_EVENT_TABLE() - + #else // wxUSE_POPUPWIN ----------------------------------- @@ -882,7 +968,7 @@ public: return rv; } #endif - + void OnActivate(wxListEvent& WXUNUSED(event)) { doubleClickAction(doubleClickActionData); } @@ -919,7 +1005,7 @@ private: bool unicodeMode; int desiredVisibleRows; int aveCharWidth; - int maxStrWidth; + size_t maxStrWidth; Point location; // Caret location at which the list is opened wxImageList* imgList; wxArrayInt* imgTypeMap; @@ -1055,7 +1141,7 @@ void ListBoxImpl::Append(const wxString& text, int type) { long count = GETLB(id)->GetItemCount(); long itemID = GETLB(id)->InsertItem(count, wxEmptyString); GETLB(id)->SetItem(itemID, 1, text); - maxStrWidth = wxMax(maxStrWidth, text.Length()); + maxStrWidth = wxMax(maxStrWidth, text.length()); if (type != -1) { wxCHECK_RET(imgTypeMap, wxT("Unexpected NULL imgTypeMap")); long idx = imgTypeMap->Item(type); @@ -1065,7 +1151,7 @@ void ListBoxImpl::Append(const wxString& text, int type) { void ListBoxImpl::SetList(const char* list, char separator, char typesep) { GETLB(id)->Freeze(); - Clear(); + Clear(); wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); while ( tkzr.HasMoreTokens() ) { wxString token = tkzr.GetNextToken(); @@ -1342,11 +1428,20 @@ int Platform::DBCSCharMaxLength() { //---------------------------------------------------------------------- ElapsedTime::ElapsedTime() { - wxStartTimer(); + wxLongLong localTime = wxGetLocalTimeMillis(); + littleBit = localTime.GetLo(); + bigBit = localTime.GetHi(); } double ElapsedTime::Duration(bool reset) { - double result = wxGetElapsedTime(reset); + wxLongLong prevTime(bigBit, littleBit); + wxLongLong localTime = wxGetLocalTimeMillis(); + if(reset) { + littleBit = localTime.GetLo(); + bigBit = localTime.GetHi(); + } + wxLongLong duration = localTime - prevTime; + double result = duration.ToDouble(); result /= 1000.0; return result; } @@ -1396,9 +1491,3 @@ const wxWX2MBbuf wx2stc(const wxString& str) } #endif - - - - - -