#if wxUSE_LISTBOX
+#include "wx/listbox.h"
+
#ifndef WX_PRECOMP
#include "wx/dynarray.h"
+ #include "wx/log.h"
+ #include "wx/utils.h"
+ #include "wx/settings.h"
+ #include "wx/arrstr.h"
#endif
#ifdef __VMS
#define XtDisplay XTDISPLAY
#endif
-#include "wx/listbox.h"
-#include "wx/settings.h"
-#include "wx/log.h"
-#include "wx/utils.h"
-#include "wx/arrstr.h"
-
#ifdef __VMS__
#pragma message disable nosimpint
#endif
class wxSizeKeeper
{
int m_x, m_y;
- wxWindow* m_w;
+ int m_w, m_h;
+ wxWindow* m_wnd;
public:
wxSizeKeeper( wxWindow* w )
- : m_w( w )
+ : m_wnd( w )
{
- m_w->GetSize( &m_x, &m_y );
+ m_wnd->GetSize( &m_w, &m_h );
+ m_wnd->GetPosition( &m_x, &m_y );
}
void Restore()
{
int x, y;
- m_w->GetSize( &x, &y );
+ m_wnd->GetSize( &x, &y );
if( x != m_x || y != m_y )
- m_w->SetSize( -1, -1, m_x, m_y );
+ m_wnd->SetSize( m_x, m_y, m_w, m_h );
}
};
if( !wxControl::CreateControl( parent, id, pos, size, style,
validator, name ) )
return false;
+ PreCreation();
m_noItems = (unsigned int)n;
- m_backgroundColour = * wxWHITE;
Widget parentWidget = (Widget) parent->GetClientWidget();
Display* dpy = XtDisplay(parentWidget);
Widget listWidget =
XmCreateScrolledList(parentWidget,
- wxConstCast(name.c_str(), char), args, count);
+ wxConstCast(name.mb_str(), char), args, count);
m_mainWidget = (WXWidget) listWidget;
(XtCallbackProc) wxListBoxCallback,
(XtPointer) this);
+ PostCreation();
AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
pos.x, pos.y, best.x, best.y);
- ChangeBackgroundColour();
-
return true;
}
void wxListBox::Delete(unsigned int n)
{
- wxSizeKeeper sk( this );
Widget listBox = (Widget) m_mainWidget;
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
-
XmListDeletePos (listBox, n + 1);
- if (managed)
- XtManageChild (listBox);
-
- sk.Restore();
m_clientDataDict.Delete(n, HasClientObjectData());
m_noItems --;
}
int wxListBox::DoAppend(const wxString& item)
{
- wxSizeKeeper sk( this );
Widget listBox = (Widget) m_mainWidget;
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
int n;
XtVaGetValues (listBox, XmNitemCount, &n, NULL);
wxXmString text( item );
// selection policy!!
SetSelectionPolicy();
- if (managed)
- XtManageChild (listBox);
-
- sk.Restore();
m_noItems ++;
return GetCount() - 1;
void wxListBox::DoSetItems(const wxArrayString& items, void** clientData)
{
- wxSizeKeeper sk( this );
Widget listBox = (Widget) m_mainWidget;
if( HasClientObjectData() )
m_clientDataDict.DestroyData();
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
XmString *text = new XmString[items.GetCount()];
unsigned int i;
for (i = 0; i < items.GetCount(); ++i)
// selection policy!!
SetSelectionPolicy();
- if (managed)
- XtManageChild (listBox);
-
- sk.Restore();
-
m_noItems = items.GetCount();
}
bool success = XmListGetMatchPos (w, str(),
&positions, &no_positions);
- if (success)
+ if (success && positions)
{
int pos = positions[0];
- if (positions)
- XtFree ((char *) positions);
+ XtFree ((char *) positions);
return pos - 1;
}
else
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
{
- wxSizeKeeper sk( this );
Widget listBox = (Widget) m_mainWidget;
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild(listBox);
-
XmString *text = new XmString[items.GetCount()];
unsigned int i;
// Steve Hammes: Motif 1.1 compatibility
// selection policy!!
SetSelectionPolicy();
- if (managed)
- XtManageChild(listBox);
-
- sk.Restore();
-
m_noItems += items.GetCount();
}