X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1032be03d5323cc50f993d944349bc48c3d78346..08f744fb3be54d7f13c265bc05d3c37fadf67b06:/src/stc/PlatWX.cpp diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index d219e12cb1..a58a60d8f5 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -21,6 +21,10 @@ #include +#if wxUSE_DISPLAY +#include "wx/display.h" +#endif + #include "wx/encconv.h" #include "wx/listctrl.h" #include "wx/mstream.h" @@ -28,13 +32,14 @@ #include "wx/imaglist.h" #include "wx/tokenzr.h" -#ifdef wxHAVE_RAW_BITMAP +#ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" #endif #include "Platform.h" #include "PlatWX.h" #include "wx/stc/stc.h" +#include "wx/stc/private.h" @@ -133,8 +138,9 @@ Font::Font() { Font::~Font() { } -void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic, bool extraFontFlag) { - +void Font::Create(const char *faceName, int characterSet, + int size, bool bold, bool italic, + bool extraFontFlag) { Release(); // The minus one is done because since Scintilla uses SC_SHARSET_DEFAULT @@ -285,11 +291,11 @@ bool SurfaceImpl::Initialised() { void SurfaceImpl::PenColour(ColourAllocated fore) { - hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID)); + hdc->SetPen(wxPen(wxColourFromCA(fore))); } void SurfaceImpl::BrushColour(ColourAllocated back) { - hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID)); + hdc->SetBrush(wxBrush(wxColourFromCA(back))); } void SurfaceImpl::SetFont(Font &font_) { @@ -340,7 +346,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { if (((SurfaceImpl&)surfacePattern).bitmap) br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap); else // Something is wrong so display in red - br = wxBrush(*wxRED, wxSOLID); + br = wxBrush(*wxRED); hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetBrush(br); hdc->DrawRectangle(wxRectFromPRectangle(rc)); @@ -362,11 +368,11 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int /*flags*/) { -#ifdef wxHAVE_RAW_BITMAP +#ifdef wxHAS_RAW_BITMAP // TODO: do something with cornerSize wxUnusedVar(cornerSize); - + int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); @@ -386,7 +392,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, p.Green() = wxPy_premultiply(green, alphaFill); p.Blue() = wxPy_premultiply(blue, alphaFill); p.Alpha() = alphaFill; - ++p; + ++p; } } @@ -400,12 +406,12 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); - p.Alpha() = 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; + p.Alpha() = alphaOutline; } for (y=0; yDrawBitmap(bmp, r.x, r.y, true); @@ -479,13 +485,13 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font, int ybase, SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); - hdc->SetBackgroundMode(wxTRANSPARENT); + hdc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); // ybase is where the baseline should be, but wxWin uses the upper left // corner, so I need to calculate the real position for the text... hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); - hdc->SetBackgroundMode(wxSOLID); + hdc->SetBackgroundMode(wxBRUSHSTYLE_SOLID); } @@ -671,7 +677,7 @@ void Window::SetFont(Font &font) { } void Window::SetCursor(Cursor curs) { - int cursorId; + wxStockCursor cursorId; switch (curs) { case cursorText: @@ -702,16 +708,13 @@ void Window::SetCursor(Cursor curs) { cursorId = wxCURSOR_ARROW; break; } -#ifdef __WXMOTIF__ - wxCursor wc = wxStockCursor(cursorId) ; -#else - wxCursor wc = wxCursor(cursorId) ; -#endif - if(curs != cursorLast) - { - GETWIN(id)->SetCursor(wc); - cursorLast = curs; - } + + wxCursor wc = wxCursor(cursorId); + if(curs != cursorLast) + { + GETWIN(id)->SetCursor(wc); + cursorLast = curs; + } } @@ -720,6 +723,19 @@ void Window::SetTitle(const char *s) { } +// Returns rectangle of monitor pt is on +PRectangle Window::GetMonitorRect(Point pt) { + wxRect rect; + if (! id) return PRectangle(); +#if wxUSE_DISPLAY + // Get the display the point is found on + int n = wxDisplay::GetFromPoint(wxPoint(pt.x, pt.y)); + wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); + rect = dpy.GetGeometry(); +#endif + return PRectangleFromwxRect(rect); +} + //---------------------------------------------------------------------- // Helper classes for ListBox @@ -804,7 +820,7 @@ public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : wxPopupWindow(parent, wxBORDER_NONE) { - + SetBackgroundColour(*wxBLACK); // for our simple border lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, @@ -927,7 +943,7 @@ public: wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT #ifdef __WXMAC__ - | wxPOPUP_WINDOW + | wxPOPUP_WINDOW | wxNO_BORDER #else | wxSIMPLE_BORDER @@ -946,7 +962,7 @@ public: lv->SetFocus(); Hide(); - } + } // On OSX and (possibly others) there can still be pending @@ -1016,7 +1032,7 @@ public: if (frame) frame->Raise(); } - + virtual void DoSetSize(int x, int y, int width, int height, @@ -1215,13 +1231,14 @@ void ListBoxImpl::Append(char *s, int type) { void ListBoxImpl::Append(const wxString& text, int type) { long count = GETLB(id)->GetItemCount(); long itemID = GETLB(id)->InsertItem(count, wxEmptyString); + long idx = -1; GETLB(id)->SetItem(itemID, 1, text); maxStrWidth = wxMax(maxStrWidth, text.length()); if (type != -1) { wxCHECK_RET(imgTypeMap, wxT("Unexpected NULL imgTypeMap")); - long idx = imgTypeMap->Item(type); - GETLB(id)->SetItemImage(itemID, idx, idx); + idx = imgTypeMap->Item(type); } + GETLB(id)->SetItemImage(itemID, idx, idx); } void ListBoxImpl::SetList(const char* list, char separator, char typesep) { @@ -1410,7 +1427,7 @@ long Platform::SendScintillaPointer(WindowID w, void *lParam) { wxStyledTextCtrl* stc = (wxStyledTextCtrl*)w; - return stc->SendMsg(msg, wParam, (long)lParam); + return stc->SendMsg(msg, wParam, (wxIntPtr)lParam); } @@ -1542,10 +1559,10 @@ wxString stc2wx(const char* str, size_t len) if (!len) return wxEmptyString; - size_t wclen = UCS2Length(str, len); + size_t wclen = UTF16Length(str, len); wxWCharBuffer buffer(wclen+1); - size_t actualLen = UCS2FromUTF8(str, len, buffer.data(), wclen+1); + size_t actualLen = UTF16FromUTF8(str, len, buffer.data(), wclen+1); return wxString(buffer.data(), actualLen); } @@ -1564,7 +1581,7 @@ const wxWX2MBbuf wx2stc(const wxString& str) size_t len = UTF8Length(wcstr, wclen); wxCharBuffer buffer(len+1); - UTF8FromUCS2(wcstr, wclen, buffer.data(), len); + UTF8FromUTF16(wcstr, wclen, buffer.data(), len); // TODO check NULL termination!!