X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e1aae5288576cd0066d2cbbf92935a969110bcea..949cb163a78520153dbdb3cd2e2dbaab075be9ca:/src/motif/listbox.cpp?ds=sidebyside diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index ddcbd3fa2f..1ad6566347 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -9,7 +9,7 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "listbox.h" #endif @@ -23,6 +23,7 @@ #include "wx/dynarray.h" #include "wx/log.h" #include "wx/utils.h" +#include "wx/arrstr.h" #ifdef __VMS__ #pragma message disable nosimpint @@ -92,12 +93,11 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Widget parentWidget = (Widget) parent->GetClientWidget(); - XmFontList fontList = (XmFontList)NULL; + WXFontType fontType = (WXFontType)NULL; if( m_font.Ok() ) { - fontList = (XmFontList)m_font.GetFontList(1.0, - XtDisplay(parentWidget)); + fontType = m_font.GetFontType(XtDisplay(parentWidget)); } Arg args[4]; @@ -108,9 +108,9 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, ( m_windowStyle & wxLB_EXTENDED ) ? XmEXTENDED_SELECT : XmBROWSE_SELECT ); ++count; - if( fontList ) + if( fontType ) { - XtSetArg( args[count], XmNfontList, fontList ); + XtSetArg( args[count], (String)wxFont::GetFontTag(), fontType ); ++count; } if( m_windowStyle & wxLB_ALWAYS_SB ) @@ -119,8 +119,9 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, ++count; } - Widget listWidget = XmCreateScrolledList(parentWidget, - (char*)name.c_str(), args, count); + Widget listWidget = + XmCreateScrolledList(parentWidget, + wxConstCast(name.c_str(), char), args, count); m_mainWidget = (WXWidget) listWidget; @@ -149,7 +150,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, (XtCallbackProc) wxListBoxCallback, (XtPointer) this); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); @@ -158,6 +158,19 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, return TRUE; } +bool wxListBox::Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style, + const wxValidator& validator, + const wxString& name) +{ + wxCArrayString chs(choices); + return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(), + style, validator, name); +} + wxListBox::~wxListBox() { if( HasClientObjectData() ) @@ -257,7 +270,7 @@ void wxListBox::DoSetItems(const wxArrayString& items, void** clientData) XmString *text = new XmString[items.GetCount()]; size_t i; for (i = 0; i < items.GetCount(); ++i) - text[i] = XmStringCreateSimple ((char*)items[i].c_str()); + text[i] = wxStringToXmString (items[i]); if ( clientData ) for (i = 0; i < items.GetCount(); ++i) @@ -459,7 +472,7 @@ wxString wxDoGetStringInList( Widget listBox, int n ) XmNitemCount, &count, XmNitems, &strlist, NULL ); - if( n <= count && n >= 0 ) + if( n < count && n >= 0 ) return wxXmStringToString( strlist[n] ); else return wxEmptyString; @@ -487,12 +500,12 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) // Corrected by Sergey Krasnov from Steve Hammes' code #if XmVersion > 1001 for (i = 0; i < items.GetCount(); i++) - text[i] = XmStringCreateSimple((char*)items[i].c_str()); + text[i] = wxStringToXmString(items[i]); XmListAddItemsUnselected(listBox, text, items.GetCount(), pos+1); #else for (i = 0; i < items.GetCount(); i++) { - text[i] = XmStringCreateSimple((char*)items[i].c_str()); + text[i] = wxStringToXmString(items[i]); // Another Sergey correction XmListAddItemUnselected(listBox, text[i], pos+i+1); } @@ -619,8 +632,8 @@ void wxListBox::ChangeBackgroundColour() * function to change them (by default, taken from wxSystemSettings) */ wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); - DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); XtVaSetValues (hsb, XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)), @@ -630,7 +643,7 @@ void wxListBox::ChangeBackgroundColour() NULL); // MBN: why change parent's background? It looks really ugly. - // DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); + // wxDoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); } void wxListBox::ChangeForegroundColour() @@ -648,9 +661,9 @@ void wxListBox::ChangeForegroundColour() /* TODO: should scrollbars be affected? Should probably have separate function to change them (by default, taken from wxSystemSettings) - DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); - DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); - DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) parent, m_foregroundColour); */ }