X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3a80c922c7f0932f0b3985846e58ef48e3a6da7..ebef1625fa59c555e45d2aa278de0ff5674d6142:/src/motif/listbox.cpp diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index dc8cf4c10a..0f5deaca4d 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: listbox.cpp +// Name: src/motif/listbox.cpp // Purpose: wxListBox // Author: Julian Smart // Modified by: @@ -9,9 +9,8 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ - #pragma implementation "listbox.h" -#endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" #ifdef __VMS #define XtParent XTPARENT @@ -23,6 +22,7 @@ #include "wx/dynarray.h" #include "wx/log.h" #include "wx/utils.h" +#include "wx/arrstr.h" #ifdef __VMS__ #pragma message disable nosimpint @@ -85,19 +85,13 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, { if( !wxControl::CreateControl( parent, id, pos, size, style, validator, name ) ) - return FALSE; + return false; m_noItems = n; m_backgroundColour = * wxWHITE; Widget parentWidget = (Widget) parent->GetClientWidget(); - - WXFontType fontType = (WXFontType)NULL; - - if( m_font.Ok() ) - { - fontType = m_font.GetFontType(XtDisplay(parentWidget)); - } + Display* dpy = XtDisplay(parentWidget); Arg args[4]; int count = 0; @@ -107,9 +101,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, ( m_windowStyle & wxLB_EXTENDED ) ? XmEXTENDED_SELECT : XmBROWSE_SELECT ); ++count; - if( fontType ) + if( m_font.Ok() ) { - XtSetArg( args[count], (String)wxFont::GetFontTag(), fontType ); + XtSetArg( args[count], + (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) ); ++count; } if( m_windowStyle & wxLB_ALWAYS_SB ) @@ -149,13 +144,25 @@ 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); ChangeBackgroundColour(); - return TRUE; + 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() @@ -261,7 +268,7 @@ void wxListBox::DoSetItems(const wxArrayString& items, void** clientData) if ( clientData ) for (i = 0; i < items.GetCount(); ++i) - m_clientDataDict.Set(i, (wxClientData*)clientData[i], FALSE); + m_clientDataDict.Set(i, (wxClientData*)clientData[i], false); XmListAddItems (listBox, text, items.GetCount(), 0); for (i = 0; i < items.GetCount(); i++) @@ -299,8 +306,10 @@ int wxDoFindStringInList(Widget w, const wxString& s) return -1; } -int wxListBox::FindString(const wxString& s) const +int wxListBox::FindString(const wxString& s, bool WXUNUSED(bCase)) const { + // FIXME: back to base class for not supported value of bCase + return wxDoFindStringInList( (Widget)m_mainWidget, s ); } @@ -321,9 +330,9 @@ void wxListBox::Clear() m_noItems = 0; } -void wxListBox::SetSelection(int N, bool select) +void wxListBox::DoSetSelection(int N, bool select) { - m_inSetValue = TRUE; + m_inSetValue = true; if (select) { #if 0 @@ -342,9 +351,9 @@ void wxListBox::SetSelection(int N, bool select) int i; for (i = 0; i < n; i++) XmListSelectPos ((Widget) m_mainWidget, - selections[i] + 1, FALSE); + selections[i] + 1, False); - XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE); + XmListSelectPos ((Widget) m_mainWidget, N + 1, False); XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, @@ -352,13 +361,13 @@ void wxListBox::SetSelection(int N, bool select) } else #endif // 0 - XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE); + XmListSelectPos ((Widget) m_mainWidget, N + 1, False); } else XmListDeselectPos ((Widget) m_mainWidget, N + 1); - m_inSetValue = FALSE; + m_inSetValue = false; } bool wxListBox::IsSelected(int N) const @@ -367,20 +376,20 @@ bool wxListBox::IsSelected(int N) const wxArrayInt theSelections; int count = GetSelections (theSelections); if (count == 0) - return FALSE; + return false; else { int j; for (j = 0; j < count; j++) if (theSelections[j] == N) - return TRUE; + return true; } - return FALSE; + return false; } void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData) { - m_clientDataDict.Set(n, clientData, FALSE); + m_clientDataDict.Set(n, clientData, false); } wxClientData* wxListBox::DoGetItemClientObject(int n) const @@ -395,7 +404,7 @@ void *wxListBox::DoGetItemClientData(int N) const void wxListBox::DoSetItemClientData(int N, void *Client_data) { - m_clientDataDict.Set(N, (wxClientData*)Client_data, FALSE); + m_clientDataDict.Set(N, (wxClientData*)Client_data, false); } // Return number of selections and an array of selected integers @@ -459,7 +468,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; @@ -530,11 +539,11 @@ void wxListBox::SetString(int N, const wxString& s) void wxListBox::Command (wxCommandEvent & event) { - if (event.m_extraLong) - SetSelection (event.m_commandInt); + if (event.GetExtraLong()) + SetSelection (event.GetInt()); else { - Deselect (event.m_commandInt); + Deselect (event.GetInt()); return; } ProcessCommand (event); @@ -561,8 +570,8 @@ void wxListBoxCallback (Widget WXUNUSED(w), XtPointer clientData, event.SetClientObject( item->GetClientObject(n) ); else if ( item->HasClientUntypedData() ) event.SetClientData( item->GetClientData(n) ); - event.m_commandInt = n; - event.m_extraLong = TRUE; + event.SetInt(n); + event.SetExtraLong(true); event.SetEventObject(item); event.SetString( item->GetString( n ) ); @@ -619,8 +628,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 +639,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 +657,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); */ } @@ -705,4 +714,3 @@ wxSize wxListBox::DoGetBestSize() const { return wxDoGetListBoxBestSize( (Widget)m_mainWidget, this ); } -