X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a8680e3e0e5066d35a8f4fd43294ba4bfcaf4ba7..2296fe5018d42d4e0bf9df07c37d31f60d972b32:/src/motif/listbox.cpp diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index e28473f615..4219682a39 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -9,10 +9,13 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "listbox.h" #endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + #ifdef __VMS #define XtParent XTPARENT #define XtDisplay XTDISPLAY @@ -23,6 +26,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 +89,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 +105,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 ) @@ -154,7 +153,20 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, 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() @@ -260,7 +272,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++) @@ -320,9 +332,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 @@ -341,9 +353,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, @@ -351,13 +363,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 @@ -366,20 +378,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 @@ -394,7 +406,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 @@ -529,11 +541,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); @@ -560,8 +572,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 ) ); @@ -618,8 +630,8 @@ void wxListBox::ChangeBackgroundColour() * function to change them (by default, taken from wxSystemSettings) */ wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); - wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, true); + wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, true); XtVaSetValues (hsb, XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)), @@ -629,7 +641,7 @@ void wxListBox::ChangeBackgroundColour() NULL); // MBN: why change parent's background? It looks really ugly. - // wxDoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); + // wxDoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, true); } void wxListBox::ChangeForegroundColour()