Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

90 lines (74 sloc) 2.439 kb
/*******************************************************************************
*
* Copyright (C) 2009, Alexander Stigsen, e-texteditor.com
*
* 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 http://opencompany.org/license.
*
* 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>
#endif
#include "SearchListBox.h"
#include "tmAction.h"
#include <vector>
class FindCmdDlg : public wxDialog {
public:
FindCmdDlg(wxWindow *parent, const std::vector<const tmAction*>& actions);
~FindCmdDlg();
const tmAction* GetSelection() {return m_cmdList->GetSelectedAction();};
private:
// Event handlers
void OnSearch(wxCommandEvent& event);
void OnAction(wxCommandEvent& event);
DECLARE_EVENT_TABLE();
class ActionList : public SearchListBox {
public:
ActionList(wxWindow* parent, wxWindowID id, const std::vector<const tmAction*>& actions);
void Find(const wxString& text);
const tmAction* GetSelectedAction();
private:
void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
void SetAllItems();
class aItem {
public:
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 {
public:
SearchEvtHandler(FindCmdDlg& parent, ActionList& alist)
: m_parent(parent), m_actionList(alist) {};
private:
void OnChar(wxKeyEvent& event);
DECLARE_EVENT_TABLE();
FindCmdDlg& m_parent;
ActionList& m_actionList;
};
// Member variables
const std::vector<const tmAction*>& m_actions;
wxTextCtrl* m_searchCtrl;
ActionList* m_cmdList;
};
#endif // __FINDCMDDLG_H_
Jump to Line
Something went wrong with that request. Please try again.