// 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
#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();
-
- XmFontList fontList = (XmFontList)NULL;
-
- if( m_font.Ok() )
- {
- fontList = (XmFontList)m_font.GetFontList(1.0,
- XtDisplay(parentWidget));
- }
+ Display* dpy = XtDisplay(parentWidget);
Arg args[4];
int count = 0;
( m_windowStyle & wxLB_EXTENDED ) ? XmEXTENDED_SELECT :
XmBROWSE_SELECT );
++count;
- if( fontList )
+ if( m_font.Ok() )
{
- XtSetArg( args[count], XmNfontList, fontList );
+ XtSetArg( args[count],
+ (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) );
++count;
}
if( m_windowStyle & wxLB_ALWAYS_SB )
++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;
(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()
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)
- 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++)
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;
// 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);
}
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);
*/
}