wxColour wxColourFromCA(const ColourAllocated& ca) {
ColourDesired cd(ca.AsLong());
- return wxColour(cd.GetRed(), cd.GetGreen(), cd.GetBlue());
+ return wxColour((unsigned char)cd.GetRed(),
+ (unsigned char)cd.GetGreen(),
+ (unsigned char)cd.GetBlue());
}
//----------------------------------------------------------------------
void Window::Destroy() {
if (id) {
- Show(FALSE);
+ Show(false);
GETWIN(id)->Destroy();
}
id = 0;
: wxListView(parent, id, pos, size, style)
{}
-
+
void OnFocus(wxFocusEvent& event) {
GetParent()->SetFocus();
event.Skip();
void OnKillFocus(wxFocusEvent& WXUNUSED(event)) {
// Do nothing. Prevents base class from resetting the colors...
}
-
+
#ifdef __WXMAC__
// For some reason I don't understand yet the focus doesn't really leave
// the listbox like it should, so if we get any events feed them back to
// And we need to force the focus back when being destroyed
~wxSTCListBox() {
GetGrandParent()->SetFocus();
- }
-#endif
-
+ }
+#endif
+
private:
DECLARE_EVENT_TABLE()
};
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
#endif
if ( !wxPendingDelete.Member(this) )
wxPendingDelete.Append(this);
- return TRUE;
+ return true;
}
-
+
int IconWidth() {
wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL);
if (il != NULL) {
BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxWindow)
- EVT_SET_FOCUS ( wxSTCListBoxWin::OnFocus)
- EVT_SIZE ( wxSTCListBoxWin::OnSize)
- EVT_LIST_ITEM_ACTIVATED(-1, wxSTCListBoxWin::OnActivate)
+ EVT_SET_FOCUS ( wxSTCListBoxWin::OnFocus)
+ EVT_SIZE ( wxSTCListBoxWin::OnSize)
+ EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate)
END_EVENT_TABLE()
void ListBoxImpl::Select(int n) {
- bool select = TRUE;
+ bool select = true;
if (n == -1) {
n = 0;
- select = FALSE;
+ select = false;
}
GETLB(id)->Focus(n);
GETLB(id)->Select(n, select);
int ListBoxImpl::Find(const char *WXUNUSED(prefix)) {
// No longer used
- return -1;
+ return wxNOT_FOUND;
}
void ListBoxImpl::RegisterImage(int type, const char *xpm_data) {
wxMemoryInputStream stream(xpm_data, strlen(xpm_data)+1);
- wxBitmap bmp(wxImage(stream, wxBITMAP_TYPE_XPM));
+ wxImage img(stream, wxBITMAP_TYPE_XPM);
+ wxBitmap bmp(img);
if (! imgList) {
// assumes all images are the same size
- imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight(), TRUE);
+ imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight(), true);
imgTypeMap = new wxArrayInt;
}
}
bool Platform::MouseButtonBounce() {
- return FALSE;
+ return false;
}
void Platform::DebugDisplay(const char *s) {
wxLogDebug(stc2wx(s));
static bool assertionPopUps = true;
bool Platform::ShowAssertionPopUps(bool assertionPopUps_) {
- bool ret = assertionPopUps;
- assertionPopUps = assertionPopUps_;
- return ret;
+ bool ret = assertionPopUps;
+ assertionPopUps = assertionPopUps_;
+ return ret;
}
void Platform::Assert(const char *c, const char *file, int line) {
- char buffer[2000];
- sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
- if (assertionPopUps) {
- /*int idButton = */
- wxMessageBox(stc2wx(buffer),
- wxT("Assertion failure"),
- wxICON_HAND | wxOK);
-// if (idButton == IDRETRY) {
-// ::DebugBreak();
-// } else if (idButton == IDIGNORE) {
-// // all OK
-// } else {
-// abort();
-// }
- } else {
- strcat(buffer, "\r\n");
- Platform::DebugDisplay(buffer);
- abort();
- }
+ char buffer[2000];
+ sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
+ if (assertionPopUps) {
+ /*int idButton = */
+ wxMessageBox(stc2wx(buffer),
+ wxT("Assertion failure"),
+ wxICON_HAND | wxOK);
+// if (idButton == IDRETRY) {
+// ::DebugBreak();
+// } else if (idButton == IDIGNORE) {
+// // all OK
+// } else {
+// abort();
+// }
+ } else {
+ strcat(buffer, "\r\n");
+ Platform::DebugDisplay(buffer);
+ abort();
+ }
}
//----------------------------------------------------------------------
#if wxUSE_UNICODE
+
+#include "UniConversion.h"
+
+// Convert using Scintilla's functions instead of wx's, Scintilla's are more
+// forgiving and won't assert...
+
wxString stc2wx(const char* str, size_t len)
{
- if (str[len] == 0)
- // It's already terminated correctly.
- return wxString(str, wxConvUTF8, len);
+ if (!len)
+ return wxEmptyString;
+
+ size_t wclen = UCS2Length(str, len);
+ wxWCharBuffer buffer(wclen+1);
+
+ size_t actualLen = UCS2FromUTF8(str, len, buffer.data(), wclen+1);
+ return wxString(buffer.data(), actualLen);
+}
- char *buffer=new char[len+1];
- strncpy(buffer, str, len);
- buffer[len]=0;
- wxString cstr(buffer, wxConvUTF8, len);
- delete[] buffer;
- return cstr;
+wxString stc2wx(const char* str)
+{
+ return stc2wx(str, strlen(str));
}
+
+
+const wxWX2MBbuf wx2stc(const wxString& str)
+{
+ const wchar_t* wcstr = str.c_str();
+ size_t wclen = str.length();
+ size_t len = UTF8Length(wcstr, wclen);
+
+ wxCharBuffer buffer(len+1);
+ UTF8FromUCS2(wcstr, wclen, buffer.data(), len);
+
+ // TODO check NULL termination!!
+
+ return buffer;
+}
+
#endif