///////////////////////////////////////////////////////////////////////////////
-// Name: listbox.cpp
+// Name: src/motif/listbox.cpp
// Purpose: wxListBox
// Author: Julian Smart
// Modified by:
// 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
#include "wx/dynarray.h"
#include "wx/log.h"
#include "wx/utils.h"
+#include "wx/arrstr.h"
#ifdef __VMS__
#pragma message disable nosimpint
{
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;
( 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 )
(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()
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++)
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 );
}
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
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,
}
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
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
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
XmNitemCount, &count,
XmNitems, &strlist,
NULL );
- if( n <= count && n >= 0 )
+ if( n < count && n >= 0 )
return wxXmStringToString( strlist[n] );
else
return wxEmptyString;
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);
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 ) );
* 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)),
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()
/* 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);
*/
}
{
return wxDoGetListBoxBestSize( (Widget)m_mainWidget, this );
}
-