Code::Blocks
SVN r11506
include
incremental_select_helper.h
Go to the documentation of this file.
1
2
/*
3
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
4
* http://www.gnu.org/licenses/lgpl-3.0.html
5
*/
6
7
#ifndef INCREMENTALSELECTLISTBASE_H
8
#define INCREMENTALSELECTLISTBASE_H
9
10
#include "
settings.h
"
11
#include <
wx/dialog.h
>
12
#include <
wx/string.h
>
13
#include <
wx/event.h
>
14
#include <vector>
15
16
#ifndef CB_PRECOMP
17
#include <
wx/listctrl.h
>
18
#endif // CB_PRECOMP
19
20
class
wxCommandEvent
;
21
class
wxKeyEvent
;
22
class
wxListEvent
;
23
class
wxTextCtrl
;
24
25
26
class
DLLIMPORT
IncrementalSelectIterator
27
{
28
public
:
29
virtual
~
IncrementalSelectIterator
();
30
31
virtual
int
GetFilteredCount()
const
= 0;
32
virtual
void
Reset() = 0;
33
virtual
void
AddIndex(
int
index) = 0;
34
virtual
int
GetUnfilteredIndex(
int
index)
const
= 0;
35
36
virtual
int
GetTotalCount()
const
= 0;
37
virtual
const
wxString
& GetItemFilterString(
int
index)
const
= 0;
38
virtual
wxString
GetDisplayText(
int
index,
int
column)
const
= 0;
39
40
virtual
int
GetColumnWidth(
int
column)
const
;
41
virtual
void
CalcColumnWidth(
wxListCtrl
&list);
42
43
};
44
45
class
DLLIMPORT
IncrementalSelectIteratorIndexed
:
public
IncrementalSelectIterator
46
{
47
public
:
48
~IncrementalSelectIteratorIndexed
()
override
{}
49
50
int
GetFilteredCount
()
const override
;
51
void
Reset
()
override
;
52
void
AddIndex
(
int
index)
override
;
53
int
GetUnfilteredIndex
(
int
index)
const override
;
54
protected
:
55
std::vector<int>
m_indices
;
56
};
57
58
class
DLLIMPORT
IncrementalSelectHandler
:
public
wxEvtHandler
59
{
60
public
:
61
IncrementalSelectHandler
(
wxDialog
* parent,
IncrementalSelectIterator
*iterator);
62
~
IncrementalSelectHandler
()
override
;
63
64
void
Init(
wxListCtrl
*list,
wxTextCtrl
*text);
65
void
DeInit(
wxWindow
*window);
66
void
FilterItems();
67
int
GetSelection();
68
69
private
:
70
void
OnKeyDown(
wxKeyEvent
&event);
71
void
OnTextChanged(
wxCommandEvent
&event);
72
void
OnItemActivated(
wxListEvent
&event);
73
74
private
:
75
wxDialog
*
m_parent
;
76
wxListCtrl
*
m_list
;
77
wxTextCtrl
*
m_text
;
78
IncrementalSelectIterator
*
m_iterator
;
79
};
80
82
class
DLLIMPORT
IncrementalListCtrl
:
public
wxListCtrl
83
{
84
public
:
85
IncrementalListCtrl
(
wxWindow
*parent,
wxWindowID
winid =
wxID_ANY
,
const
wxPoint
& pos =
wxDefaultPosition
,
86
const
wxSize
& size =
wxDefaultSize
,
long
style =
wxLC_ICON
,
87
const
wxValidator
&validator =
wxDefaultValidator
,
88
const
wxString
&name = wxListCtrlNameStr);
89
90
wxString
OnGetItemText
(
long
item,
long
column)
const override
;
91
void
SetIterator(
IncrementalSelectIterator
*iterator);
92
private
:
93
IncrementalSelectIterator
*
m_Iterator
;
94
};
95
97
class
DLLIMPORT
IncrementalSelectArrayIterator
:
public
IncrementalSelectIteratorIndexed
98
{
99
public
:
100
IncrementalSelectArrayIterator
(
const
wxArrayString
&items);
101
102
int
GetTotalCount
()
const override
;
103
const
wxString
&
GetItemFilterString
(
int
index)
const override
;
104
wxString
GetDisplayText
(
int
index,
int
column)
const override
;
105
int
GetColumnWidth
(
int
column)
const override
;
106
void
CalcColumnWidth
(
wxListCtrl
&list)
override
;
107
private
:
108
const
wxArrayString
&
m_items
;
109
int
m_columnWidth
;
110
};
111
114
class
DLLIMPORT
IncrementalSelectDialog
:
public
wxDialog
115
{
116
public
:
117
IncrementalSelectDialog
(
wxWindow
* parent,
IncrementalSelectIterator
*iterator,
const
wxString
&title,
118
const
wxString
&message);
119
~
IncrementalSelectDialog
()
override
;
120
121
int
GetSelection();
122
private
:
123
IncrementalSelectHandler
m_handler
;
124
private
:
125
IncrementalListCtrl
*
m_resultList
;
126
wxTextCtrl
*
m_text
;
127
protected
:
128
void
BuildContent(
wxWindow
* parent,
IncrementalSelectIterator
*iterator,
const
wxString
&title,
129
const
wxString
&message);
130
131
DECLARE_EVENT_TABLE()
132
};
133
134
#endif // INCREMENTALSELECTLISTBASE_H
135
IncrementalSelectIterator::GetItemFilterString
virtual const wxString & GetItemFilterString(int index) const =0
IncrementalSelectIterator::GetFilteredCount
virtual int GetFilteredCount() const =0
IncrementalSelectIterator::GetUnfilteredIndex
virtual int GetUnfilteredIndex(int index) const =0
listctrl.h
IncrementalSelectDialog::m_handler
IncrementalSelectHandler m_handler
Definition:
incremental_select_helper.h:123
wxDefaultValidator
const wxValidator wxDefaultValidator
IncrementalListCtrl::m_Iterator
IncrementalSelectIterator * m_Iterator
Definition:
incremental_select_helper.h:93
string.h
IncrementalSelectIterator::GetColumnWidth
virtual int GetColumnWidth(int column) const
Definition:
incremental_select_helper.cpp:22
wxValidator
IncrementalSelectArrayIterator::m_items
const wxArrayString & m_items
Definition:
incremental_select_helper.h:108
IncrementalSelectIteratorIndexed::~IncrementalSelectIteratorIndexed
~IncrementalSelectIteratorIndexed() override
Definition:
incremental_select_helper.h:48
IncrementalSelectIterator::AddIndex
virtual void AddIndex(int index)=0
IncrementalSelectIterator::GetDisplayText
virtual wxString GetDisplayText(int index, int column) const =0
event.h
IncrementalSelectHandler::m_text
wxTextCtrl * m_text
Definition:
incremental_select_helper.h:77
wxListCtrl
wxCommandEvent
IncrementalSelectHandler::m_parent
wxDialog * m_parent
Definition:
incremental_select_helper.h:75
wxTextCtrl
DLLIMPORT
#define DLLIMPORT
Definition:
settings.h:16
IncrementalSelectIterator::Reset
virtual void Reset()=0
wxListEvent
IncrementalSelectArrayIterator::m_columnWidth
int m_columnWidth
Definition:
incremental_select_helper.h:109
IncrementalSelectIteratorIndexed::m_indices
std::vector< int > m_indices
Definition:
incremental_select_helper.h:55
IncrementalSelectIterator::GetTotalCount
virtual int GetTotalCount() const =0
dialog.h
settings.h
wxString
IncrementalSelectIterator
Definition:
incremental_select_helper.h:26
wxDefaultSize
const wxSize wxDefaultSize
wxDefaultPosition
const wxPoint wxDefaultPosition
wxDialog
wxLC_ICON
#define wxLC_ICON
wxID_ANY
IncrementalSelectIteratorIndexed
Definition:
incremental_select_helper.h:45
wxKeyEvent
IncrementalListCtrl
Class that implements a virtual list control that uses an IncrementalSelectIterator to populate the l...
Definition:
incremental_select_helper.h:82
wxListCtrl::OnGetItemText
virtual wxString OnGetItemText(long item, long column) const
wxSize
IncrementalSelectIterator::CalcColumnWidth
virtual void CalcColumnWidth(wxListCtrl &list)
Definition:
incremental_select_helper.cpp:27
IncrementalSelectDialog::m_text
wxTextCtrl * m_text
Definition:
incremental_select_helper.h:126
IncrementalSelectHandler::m_iterator
IncrementalSelectIterator * m_iterator
Definition:
incremental_select_helper.h:78
wxEvtHandler
IncrementalSelectArrayIterator
Simple iterator that uses wxArrayString as data source.
Definition:
incremental_select_helper.h:97
IncrementalSelectDialog
Simple incremental select dialog that shows a single column and doesn't have much ui elements...
Definition:
incremental_select_helper.h:114
wxArrayString
IncrementalSelectHandler::m_list
wxListCtrl * m_list
Definition:
incremental_select_helper.h:76
wxWindowID
int wxWindowID
wxWindow
IncrementalSelectHandler
Definition:
incremental_select_helper.h:58
IncrementalSelectDialog::m_resultList
IncrementalListCtrl * m_resultList
Definition:
incremental_select_helper.h:125
wxPoint
Generated by
1.8.13