]> git.saurik.com Git - wxWidgets.git/blame - include/wx/listbox.h
Add a Get and Set for an OS/2 PS
[wxWidgets.git] / include / wx / listbox.h
CommitLineData
2ee3ee1b
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/listbox.h
3// Purpose: wxListBox class interface
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 22.10.99
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
6c8a980f 9// Licence: wxWindows licence
2ee3ee1b
VZ
10///////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_LISTBOX_H_BASE_
13#define _WX_LISTBOX_H_BASE_
c801d85f 14
2ee3ee1b
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#ifdef __GNUG__
20 #pragma interface "listboxbase.h"
21#endif
22
23#include "wx/defs.h"
24
25#if wxUSE_LISTBOX
26
6c8a980f 27#include "wx/ctrlsub.h" // base class
2ee3ee1b
VZ
28
29// forward declarations are enough here
30class WXDLLEXPORT wxArrayInt;
31class WXDLLEXPORT wxArrayString;
32
33// ----------------------------------------------------------------------------
34// global data
35// ----------------------------------------------------------------------------
36
37WXDLLEXPORT_DATA(extern const wxChar*) wxListBoxNameStr;
38
39// ----------------------------------------------------------------------------
40// wxListBox interface is defined by the class wxListBoxBase
41// ----------------------------------------------------------------------------
42
6c8a980f 43class WXDLLEXPORT wxListBoxBase : public wxControlWithItems
2ee3ee1b
VZ
44{
45public:
6c8a980f
VZ
46 // all generic methods are in wxControlWithItems, except for the following
47 // ones which are not yet implemented by wxChoice/wxCombobox
2ee3ee1b
VZ
48
49 void Insert(const wxString& item, int pos)
50 { DoInsert(item, pos); }
51 void Insert(const wxString& item, int pos, void *clientData)
52 { DoInsert(item, pos); SetClientData(pos, clientData); }
53 void Insert(const wxString& item, int pos, wxClientData *clientData)
54 { DoInsert(item, pos); SetClientObject(pos, clientData); }
55
56 void InsertItems(int nItems, const wxString *items, int pos);
57 void InsertItems(const wxArrayString& items, int pos)
58 { DoInsertItems(items, pos); }
59
60 void Set(int n, const wxString* items, void **clientData = NULL);
61 void Set(const wxArrayString& items, void **clientData = NULL)
62 { DoSetItems(items, clientData); }
63
6c8a980f 64 // multiple selection logic
2ee3ee1b
VZ
65 virtual bool IsSelected(int n) const = 0;
66 virtual void SetSelection(int n, bool select = TRUE) = 0;
6c8a980f 67 virtual void Select(int n) { SetSelection(n, TRUE); }
2ee3ee1b
VZ
68 void Deselect(int n) { SetSelection(n, FALSE); }
69
6c8a980f 70 virtual bool SetStringSelection(const wxString& s, bool select = TRUE);
2ee3ee1b 71
6c8a980f
VZ
72 // works for single as well as multiple selection listboxes (unlike
73 // GetSelection which only works for listboxes with single selection)
74 virtual int GetSelections(wxArrayInt& aSelections) const = 0;
2ee3ee1b
VZ
75
76 // Set the specified item at the first visible item or scroll to max
77 // range.
78 void SetFirstItem(int n) { DoSetFirstItem(n); }
79 void SetFirstItem(const wxString& s);
80
6c8a980f
VZ
81 // emulate selecting or deselecting the item event.GetInt() (depending on
82 // event.GetExtraLong())
83 void Command(wxCommandEvent& event);
2ee3ee1b
VZ
84
85 // compatibility - these functions are deprecated, use the new ones
86 // instead
87 bool Selected(int n) const { return IsSelected(n); }
2ee3ee1b
VZ
88
89protected:
90 // NB: due to wxGTK implementation details, DoInsert() is implemented
91 // using DoInsertItems() and not the other way round
92 void DoInsert(const wxString& item, int pos)
93 { InsertItems(1, &item, pos); }
94
95 // to be implemented in derived classes
2ee3ee1b
VZ
96 virtual void DoInsertItems(const wxArrayString& items, int pos) = 0;
97 virtual void DoSetItems(const wxArrayString& items, void **clientData) = 0;
98
99 virtual void DoSetFirstItem(int n) = 0;
2ee3ee1b
VZ
100};
101
102// ----------------------------------------------------------------------------
103// include the platform-specific class declaration
104// ----------------------------------------------------------------------------
105
2049ba38 106#if defined(__WXMSW__)
2ee3ee1b 107 #include "wx/msw/listbox.h"
2049ba38 108#elif defined(__WXMOTIF__)
2ee3ee1b 109 #include "wx/motif/listbox.h"
2049ba38 110#elif defined(__WXGTK__)
2ee3ee1b 111 #include "wx/gtk/listbox.h"
b4e76e0d 112#elif defined(__WXQT__)
2ee3ee1b 113 #include "wx/qt/listbox.h"
34138703 114#elif defined(__WXMAC__)
2ee3ee1b 115 #include "wx/mac/listbox.h"
1777b9bb 116#elif defined(__WXPM__)
2ee3ee1b 117 #include "wx/os2/listbox.h"
34138703 118#elif defined(__WXSTUBS__)
2ee3ee1b 119 #include "wx/stubs/listbox.h"
c801d85f
KB
120#endif
121
2ee3ee1b
VZ
122#endif // wxUSE_LISTBOX
123
c801d85f 124#endif
34138703 125 // _WX_LISTBOX_H_BASE_