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
|
1999-10-23 23:40:55 +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
|
|
|
|
|
|
|
#ifdef __GNUG__
|
1999-10-23 23:40:55 +00:00
|
|
|
#pragma interface "listbox.h"
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
#include <wx/dynarray.h>
|
1998-11-22 22:32:53 +00:00
|
|
|
|
1999-10-12 23:57:40 +00:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY(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()
|
|
|
|
class wxArrayInt;
|
|
|
|
|
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,
|
|
|
|
const wxString& name = wxListBoxNameStr)
|
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, n, choices, style, validator, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
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();
|
|
|
|
virtual void Delete(int n);
|
|
|
|
|
|
|
|
virtual int GetCount() const;
|
|
|
|
virtual wxString GetString(int n) const;
|
|
|
|
virtual void SetString(int n, const wxString& s);
|
|
|
|
virtual int FindString(const wxString& s) const;
|
|
|
|
|
|
|
|
virtual bool IsSelected(int n) const;
|
|
|
|
virtual void SetSelection(int n, bool select = TRUE);
|
|
|
|
virtual int GetSelection() const;
|
|
|
|
virtual int GetSelections(wxArrayInt& aSelections) const;
|
|
|
|
|
|
|
|
virtual int DoAppend(const wxString& item);
|
|
|
|
virtual void DoInsertItems(const wxArrayString& items, int pos);
|
|
|
|
virtual void DoSetItems(const wxArrayString& items, void **clientData);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
virtual void DoSetFirstItem(int n);
|
|
|
|
|
1999-10-22 18:00:39 +00:00
|
|
|
virtual void DoSetItemClientData(int n, void* clientData);
|
|
|
|
virtual void* DoGetItemClientData(int n) const;
|
|
|
|
virtual void DoSetItemClientObject(int n, wxClientData* clientData);
|
|
|
|
virtual wxClientData* DoGetItemClientObject(int n) const;
|
1999-10-22 15:55:27 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
virtual wxOwnerDrawn *CreateItem(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
|
|
|
|
1999-10-22 15:55:27 +00:00
|
|
|
// Windows-specific code to set the horizontal extent of the listbox, if
|
|
|
|
// necessary. If s is non-NULL, it's used to calculate the horizontal
|
|
|
|
// extent. Otherwise, all strings are used.
|
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);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void SetupColours();
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
protected:
|
1999-10-22 15:55:27 +00:00
|
|
|
// do we have multiple selections?
|
|
|
|
bool HasMultipleSelection() const;
|
|
|
|
|
1999-10-23 23:40:55 +00:00
|
|
|
// free memory (common part of Clear() and dtor)
|
|
|
|
void Free();
|
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
int m_noItems;
|
|
|
|
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:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxListBox)
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-07 23:52:45 +00:00
|
|
|
// _WX_LISTBOX_H_
|