1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-10-22 11:55:27 -04:00
|
|
|
// Name: wx/msw/listbox.h
|
1998-05-20 10:12:05 -04:00
|
|
|
// Purpose: wxListBox class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 19:52:45 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 19:52:45 -04:00
|
|
|
#ifndef _WX_LISTBOX_H_
|
|
|
|
#define _WX_LISTBOX_H_
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if wxUSE_LISTBOX
|
|
|
|
|
1999-10-22 11:55:27 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// simple types
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1998-09-25 09:28:52 -04:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1998-05-20 10:12:05 -04:00
|
|
|
class WXDLLEXPORT wxOwnerDrawn;
|
|
|
|
|
|
|
|
// define the array of list box items
|
2002-06-01 07:48:26 -04:00
|
|
|
#include "wx/dynarray.h"
|
1998-11-22 17:32:53 -05:00
|
|
|
|
2003-10-08 18:13:14 -04:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn *, wxListBoxItemsArray);
|
1999-10-22 11:55:27 -04:00
|
|
|
#endif // wxUSE_OWNER_DRAWN
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1998-06-22 17:54:19 -04:00
|
|
|
// forward decl for GetSelections()
|
2004-07-15 16:51:44 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxArrayInt;
|
1998-06-22 17:54:19 -04:00
|
|
|
|
1999-10-22 11:55:27 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// List box control
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-10-22 11:55:27 -04:00
|
|
|
class WXDLLEXPORT wxListBox : public wxListBoxBase
|
1998-05-20 10:12:05 -04:00
|
|
|
{
|
1999-02-22 06:01:13 -05:00
|
|
|
public:
|
1999-10-22 11:55:27 -04:00
|
|
|
// ctors and such
|
1999-02-22 06:01:13 -05: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 08:49:22 -05:00
|
|
|
const wxString& name = wxListBoxNameStr)
|
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, n, choices, style, validator, name);
|
|
|
|
}
|
2004-01-31 13:21:45 -05: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 06:01:13 -05:00
|
|
|
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
1999-10-22 11:55:27 -04: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 13:21:45 -05: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 06:01:13 -05:00
|
|
|
|
1999-10-22 11:55:27 -04:00
|
|
|
virtual ~wxListBox();
|
1999-02-22 06:01:13 -05:00
|
|
|
|
1999-10-22 11:55:27 -04:00
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual void Clear();
|
2006-03-23 17:05:23 -05:00
|
|
|
virtual void Delete(unsigned int n);
|
1999-10-22 11:55:27 -04:00
|
|
|
|
2006-03-23 17:05:23 -05: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 12:54:43 -04:00
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const;
|
1999-10-22 11:55:27 -04:00
|
|
|
|
|
|
|
virtual bool IsSelected(int n) const;
|
|
|
|
virtual int GetSelection() const;
|
|
|
|
virtual int GetSelections(wxArrayInt& aSelections) const;
|
|
|
|
|
|
|
|
// wxCheckListBox support
|
1998-09-25 09:28:52 -04:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1999-02-22 06:01:13 -05:00
|
|
|
bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
|
|
|
|
bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-02-22 06:01:13 -05:00
|
|
|
// plug-in for derived classes
|
2002-12-04 09:11:26 -05:00
|
|
|
virtual wxOwnerDrawn *CreateLboxItem(size_t n);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-02-22 06:01:13 -05: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 10:35:51 -05:00
|
|
|
|
|
|
|
// get the index of the given item
|
|
|
|
int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
|
1999-02-22 06:01:13 -05:00
|
|
|
#endif // wxUSE_OWNER_DRAWN
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2006-07-12 17:44:34 -04: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 06:01:13 -05:00
|
|
|
virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-10-22 11:55:27 -04:00
|
|
|
// Windows callbacks
|
|
|
|
bool MSWCommand(WXUINT param, WXWORD id);
|
2006-02-08 16:47:09 -05: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 10:12:05 -04:00
|
|
|
|
2004-03-31 19:15:07 -05:00
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const
|
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
|
|
|
|
{
|
|
|
|
return GetCompositeControlsDefaultAttributes(variant);
|
|
|
|
}
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-02-22 06:01:13 -05:00
|
|
|
protected:
|
2006-02-08 16:47:09 -05:00
|
|
|
virtual void DoSetSelection(int n, bool select);
|
|
|
|
virtual int DoAppend(const wxString& item);
|
2006-03-23 17:05:23 -05:00
|
|
|
virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
|
2006-02-08 16:47:09 -05:00
|
|
|
virtual void DoSetItems(const wxArrayString& items, void **clientData);
|
|
|
|
virtual void DoSetFirstItem(int n);
|
2006-03-23 17:05:23 -05: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 07:48:52 -05:00
|
|
|
virtual int DoListHitTest(const wxPoint& point) const;
|
2004-03-31 19:15:07 -05:00
|
|
|
|
1999-10-23 19:40:55 -04:00
|
|
|
// free memory (common part of Clear() and dtor)
|
|
|
|
void Free();
|
|
|
|
|
2006-03-23 17:05:23 -05:00
|
|
|
unsigned int m_noItems;
|
1999-02-22 06:01:13 -05:00
|
|
|
int m_selected;
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-11-19 16:01:20 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
1999-07-19 18:17:40 -04:00
|
|
|
|
1998-09-25 09:28:52 -04:00
|
|
|
#if wxUSE_OWNER_DRAWN
|
1999-02-22 06:01:13 -05:00
|
|
|
// control items
|
|
|
|
wxListBoxItemsArray m_aItems;
|
1998-05-20 10:12:05 -04:00
|
|
|
#endif
|
1999-10-22 11:55:27 -04:00
|
|
|
|
|
|
|
private:
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox)
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // wxUSE_LISTBOX
|
|
|
|
|
1998-05-20 10:12:05 -04:00
|
|
|
#endif
|
1998-08-07 19:52:45 -04:00
|
|
|
// _WX_LISTBOX_H_
|