X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e730a78765d0e70ca5b77512569c94585070fe2..b77b87881bae2e6306366d79e7fe160334b3d4a2:/src/stc/PlatWX.cpp diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 80f8f795ce..ceb50296a6 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -288,7 +288,7 @@ void SurfaceImpl::Init(SurfaceID hdc_, WindowID) { hdc = (wxDC*)hdc_; } -void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID) { +void SurfaceImpl::InitPixMap(int width, int height, Surface *WXUNUSED(surface_), WindowID) { Release(); hdc = new wxMemoryDC(); hdcOwned = true; @@ -405,7 +405,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase, SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); - //FillRectangle(rc, back); + FillRectangle(rc, back); // 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... @@ -418,11 +418,12 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase, SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); - //FillRectangle(rc, back); + FillRectangle(rc, back); hdc->SetClippingRegion(wxRectFromPRectangle(rc)); // see comments above hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); + hdc->DestroyClippingRegion(); } @@ -450,7 +451,7 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio #ifndef __WXMAC__ // Calculate the position of each character based on the widths of // the previous characters - int* tpos = new int[len]; + int* tpos = new int[len+1]; int totalWidth = 0; size_t i; for (i=0; i= 0x80) { @@ -541,7 +542,7 @@ int SurfaceImpl::Descent(Font &font) { return d; } -int SurfaceImpl::InternalLeading(Font &font) { +int SurfaceImpl::InternalLeading(Font &WXUNUSED(font)) { return 0; } @@ -562,7 +563,7 @@ int SurfaceImpl::AverageCharWidth(Font &font) { return hdc->GetCharWidth(); } -int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) { +int SurfaceImpl::SetPalette(Palette *WXUNUSED(pal), bool WXUNUSED(inBackGround)) { return 0; } @@ -575,16 +576,9 @@ void SurfaceImpl::FlushCachedState() { void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { unicodeMode=unicodeMode_; -#if wxUSE_UNICODE - wxASSERT_MSG(unicodeMode == wxUSE_UNICODE, - wxT("Only unicode may be used when wxUSE_UNICODE is on.")); -#else - wxASSERT_MSG(unicodeMode == wxUSE_UNICODE, - wxT("Only non-unicode may be used when wxUSE_UNICODE is off.")); -#endif } -void SurfaceImpl::SetDBCSMode(int codePage) { +void SurfaceImpl::SetDBCSMode(int WXUNUSED(codePage)) { // dbcsMode = codePage == SC_CP_DBCS; } @@ -681,6 +675,7 @@ void Window::SetCursor(Cursor curs) { break; case cursorHand: cursorId = wxCURSOR_HAND; + break; default: cursorId = wxCURSOR_ARROW; break; @@ -703,7 +698,7 @@ void Window::SetTitle(const char *s) { // Helper classes for ListBox -// This is a simple subclass of wxLIstView that just resets focus to the +// This is a simple subclass of wxListView that just resets focus to the // parent when it gets it. class wxSTCListBox : public wxListView { public: @@ -718,12 +713,17 @@ public: event.Skip(); } + void OnKillFocus(wxFocusEvent& event) { + // Do nothing. Prevents base class from resetting the colors... + } + private: DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(wxSTCListBox, wxListView) EVT_SET_FOCUS( wxSTCListBox::OnFocus) + EVT_KILL_FOCUS(wxSTCListBox::OnKillFocus) END_EVENT_TABLE() @@ -746,9 +746,26 @@ public: lv->SetCursor(wxCursor(wxCURSOR_ARROW)); lv->InsertColumn(0, wxEmptyString); lv->InsertColumn(1, wxEmptyString); + + // Eventhough we immediately reset the focus to the parent, this helps + // things to look right... + lv->SetFocus(); + Hide(); } + + // On OSX and (possibly others) there can still be pending + // messages/events for the list control when Scintilla wants to + // close it, so do a pending delete of it instead of destroying + // immediately. + bool Destroy() { + if ( !wxPendingDelete.Member(this) ) + wxPendingDelete.Append(this); + return TRUE; + } + + int IconWidth() { wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); if (il != NULL) { @@ -894,7 +911,7 @@ PRectangle ListBoxImpl::GetDesiredRect() { // wxListCtrl doesn't have a DoGetBestSize, so instead we kept track of // the max size in Append and calculate it here... int maxw = maxStrWidth; - int maxh = 0; + int maxh ; // give it a default if there are no lines, and/or add a bit more if (maxw == 0) maxw = 100; @@ -975,7 +992,7 @@ int ListBoxImpl::GetSelection() { } -int ListBoxImpl::Find(const char *prefix) { +int ListBoxImpl::Find(const char *WXUNUSED(prefix)) { // No longer used return -1; } @@ -1009,7 +1026,7 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { // do we need to extend the mapping array? wxArrayInt& itm = *imgTypeMap; - if ( itm.GetCount() < type+1) + if ( itm.GetCount() < (size_t)type+1) itm.Add(-1, type - itm.GetCount() + 1); // Add an item that maps type to the image index @@ -1069,6 +1086,13 @@ void Menu::Show(Point pt, Window &w) { //---------------------------------------------------------------------- +DynamicLibrary *DynamicLibrary::Load(const char *WXUNUSED(modulePath)) { + wxFAIL_MSG(wxT("Dynamic lexer loading not implemented yet")); + return NULL; +} + +//---------------------------------------------------------------------- + ColourDesired Platform::Chrome() { wxColour c; c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); @@ -1102,7 +1126,7 @@ void Platform::DebugDisplay(const char *s) { wxLogDebug(stc2wx(s)); } -bool Platform::IsKeyDown(int key) { +bool Platform::IsKeyDown(int WXUNUSED(key)) { return false; // I don't think we'll need this. } @@ -1195,16 +1219,16 @@ int Platform::Clamp(int val, int minVal, int maxVal) { } -bool Platform::IsDBCSLeadByte(int codePage, char ch) { +bool Platform::IsDBCSLeadByte(int WXUNUSED(codePage), char WXUNUSED(ch)) { return false; } -int Platform::DBCSCharLength(int codePage, const char *s) { - return 0; +int Platform::DBCSCharLength(int WXUNUSED(codePage), const char *WXUNUSED(s)) { + return 1; } int Platform::DBCSCharMaxLength() { - return 0; + return 1; } @@ -1223,6 +1247,22 @@ double ElapsedTime::Duration(bool reset) { //---------------------------------------------------------------------- +#if wxUSE_UNICODE +wxString stc2wx(const char* str, size_t len) +{ + char *buffer=new char[len+1]; + strncpy(buffer, str, len); + buffer[len]=0; + + wxString cstr(buffer, wxConvUTF8); + + delete[] buffer; + return cstr; +} +#endif + + +