Find file
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (74 sloc) 2.38 KB
* Copyright (C) 2009, Alexander Stigsen,
* This software is licensed under the Open Company License as described
* in the file license.txt, which you should have received as part of this
* distribution. The terms are also available at
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
#ifndef __FINDCMDDLG_H__
#define __FINDCMDDLG_H__
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include "SearchListBox.h"
#include "tmAction.h"
#include <vector>
class FindCmdDlg : public wxDialog {
FindCmdDlg(wxWindow *parent, const std::vector<const tmAction*>& actions);
const tmAction* GetSelection() {return m_cmdList->GetSelectedAction();};
// Event handlers
void OnSearch(wxCommandEvent& event);
void OnAction(wxCommandEvent& event);
class ActionList : public SearchListBox {
ActionList(wxWindow* parent, wxWindowID id, const std::vector<const tmAction*>& actions);
void Find(const wxString& text);
const tmAction* GetSelectedAction();
void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
void SetAllItems();
class aItem {
aItem() : action(NULL), rank(0) {};
aItem(const tmAction* a, const std::vector<unsigned int>& hl);
bool operator<(const aItem& ai) const {
if (rank < ai.rank) return true;
if (rank > ai.rank) return false;
if (action && ai.action) return action->name < ai.action->name;
return false;
const tmAction* action;
std::vector<unsigned int> hlChars;
unsigned int rank;
const std::vector<const tmAction*>& m_actions;
std::vector<aItem> m_items;
wxFont m_unifont;
class SearchEvtHandler : public wxEvtHandler {
SearchEvtHandler(FindCmdDlg& parent, ActionList& alist)
: m_parent(parent), m_actionList(alist) {};
void OnChar(wxKeyEvent& event);
FindCmdDlg& m_parent;
ActionList& m_actionList;
// Member variables
const std::vector<const tmAction*>& m_actions;
wxTextCtrl* m_searchCtrl;
ActionList* m_cmdList;
#endif // __FINDCMDDLG_H_