1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-10-22 15:55:27 +00:00
|
|
|
// Name: wx/msw/listbox.h
|
1998-05-20 14:12:05 +00:00
|
|
|
// Purpose: wxListBox class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 23:52:45 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
#ifndef _WX_LISTBOX_H_
|
|
|
|
#define _WX_LISTBOX_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_LISTBOX
|
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// simple types
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1998-05-20 14:12:05 +00:00
|
|
|
class WXDLLEXPORT wxOwnerDrawn;
|
|
|
|
|
|
|
|
// define the array of list box items
|
2002-06-01 11:48:26 +00:00
|
|
|
#include "wx/dynarray.h"
|
1998-11-22 22:32:53 +00:00
|
|
|
|
2003-10-08 22:13:14 +00:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn *, wxListBoxItemsArray);
|
1999-10-22 15:55:27 +00:00
|
|
|
#endif // wxUSE_OWNER_DRAWN
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1998-06-22 21:54:19 +00:00
|
|
|
// forward decl for GetSelections()
|
2004-07-15 20:51:44 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxArrayInt;
|
1998-06-22 21:54:19 +00:00
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// List box control
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
class WXDLLEXPORT wxListBox : public wxListBoxBase
|
1998-05-20 14:12:05 +00:00
|
|
|
{
|
1999-02-22 11:01:13 +00:00
|
|
|
public:
|
1999-10-22 15:55:27 +00:00
|
|
|
// ctors and such
|
1999-02-22 11:01:13 +00:00
|
|
|
wxListBox();
|
|
|
|
wxListBox(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0, const wxString choices[] = NULL,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2004-01-15 13:49:22 +00:00
|
|
|
const wxString& name = wxListBoxNameStr)
|
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, n, choices, style, validator, name);
|
|
|
|
}
|
2004-01-31 18:21:45 +00:00
|
|
|
wxListBox(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxListBoxNameStr)
|
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, choices, style, validator, name);
|
|
|
|
}
|
1999-02-22 11:01:13 +00:00
|
|
|
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
1999-10-22 15:55:27 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0, const wxString choices[] = NULL,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxListBoxNameStr);
|
2004-01-31 18:21:45 +00:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxListBoxNameStr);
|
1999-02-22 11:01:13 +00:00
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
virtual ~wxListBox();
|
1999-02-22 11:01:13 +00:00
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual void Clear();
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual void Delete(unsigned int n);
|
1999-10-22 15:55:27 +00:00
|
|
|
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual unsigned int GetCount() const;
|
|
|
|
virtual wxString GetString(unsigned int n) const;
|
|
|
|
virtual void SetString(unsigned int n, const wxString& s);
|
2005-09-27 16:54:43 +00:00
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const;
|
1999-10-22 15:55:27 +00:00
|
|
|
|
|
|
|
virtual bool IsSelected(int n) const;
|
|
|
|
virtual int GetSelection() const;
|
|
|
|
virtual int GetSelections(wxArrayInt& aSelections) const;
|
|
|
|
|
|
|
|
// wxCheckListBox support
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1999-02-22 11:01:13 +00:00
|
|
|
bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
|
|
|
|
bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
// plug-in for derived classes
|
2002-12-04 14:11:26 +00:00
|
|
|
virtual wxOwnerDrawn *CreateLboxItem(size_t n);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
// allows to get the item and use SetXXX functions to set it's appearance
|
|
|
|
wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
|
1999-02-28 15:35:51 +00:00
|
|
|
|
|
|
|
// get the index of the given item
|
|
|
|
int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
|
1999-02-22 11:01:13 +00:00
|
|
|
#endif // wxUSE_OWNER_DRAWN
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2006-07-12 21:44:34 +00:00
|
|
|
// Windows-specific code to update the horizontal extent of the listbox, if
|
|
|
|
// necessary. If s is non-empty, the horizontal extent is increased to the
|
|
|
|
// length of this string if it's currently too short, otherwise the maximum
|
|
|
|
// extent of all strings is used. In any case calls InvalidateBestSize()
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
// Windows callbacks
|
|
|
|
bool MSWCommand(WXUINT param, WXWORD id);
|
2006-02-08 21:47:09 +00:00
|
|
|
WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
|
|
|
|
|
|
|
// under XP when using "transition effect for menus and tooltips" if we
|
|
|
|
// return true for WM_PRINTCLIENT here then it causes noticable slowdown
|
|
|
|
virtual bool MSWShouldPropagatePrintChild()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2004-04-01 00:15:07 +00:00
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const
|
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
|
|
|
|
{
|
|
|
|
return GetCompositeControlsDefaultAttributes(variant);
|
|
|
|
}
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
protected:
|
2006-02-08 21:47:09 +00:00
|
|
|
virtual void DoSetSelection(int n, bool select);
|
|
|
|
virtual int DoAppend(const wxString& item);
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
|
2006-02-08 21:47:09 +00:00
|
|
|
virtual void DoSetItems(const wxArrayString& items, void **clientData);
|
|
|
|
virtual void DoSetFirstItem(int n);
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual void DoSetItemClientData(unsigned int n, void* clientData);
|
|
|
|
virtual void* DoGetItemClientData(unsigned int n) const;
|
|
|
|
virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
|
|
|
|
virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
|
2006-03-09 12:48:52 +00:00
|
|
|
virtual int DoListHitTest(const wxPoint& point) const;
|
2004-04-01 00:15:07 +00:00
|
|
|
|
1999-10-23 23:40:55 +00:00
|
|
|
// free memory (common part of Clear() and dtor)
|
|
|
|
void Free();
|
|
|
|
|
2006-03-23 22:05:23 +00:00
|
|
|
unsigned int m_noItems;
|
1999-02-22 11:01:13 +00:00
|
|
|
int m_selected;
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-19 21:01:20 +00:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
1999-07-19 22:17:40 +00:00
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1999-02-22 11:01:13 +00:00
|
|
|
// control items
|
|
|
|
wxListBoxItemsArray m_aItems;
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1999-10-22 15:55:27 +00:00
|
|
|
|
|
|
|
private:
|
2003-07-22 00:24:07 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox)
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#endif // wxUSE_LISTBOX
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1998-08-07 23:52:45 +00:00
|
|
|
// _WX_LISTBOX_H_
|