2013-10-01 06:00:13 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
KeyView.h
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_WIDGETS_KEYVIEW__
|
|
|
|
#define __AUDACITY_WIDGETS_KEYVIEW__
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2019-03-11 02:05:37 +00:00
|
|
|
#include "audacity/Types.h"
|
2013-10-01 06:00:13 +00:00
|
|
|
|
2018-10-18 14:59:10 +00:00
|
|
|
#include <vector>
|
2019-03-23 18:28:37 +00:00
|
|
|
#include <wx/setup.h> // for wxUSE_* macros
|
|
|
|
#include <wx/defs.h>
|
2018-11-14 16:48:46 +00:00
|
|
|
#include <wx/vlbox.h> // to inherit wxVListBox
|
2013-10-01 06:00:13 +00:00
|
|
|
|
2018-10-18 12:58:23 +00:00
|
|
|
#include "../commands/Keyboard.h"
|
|
|
|
|
2013-10-01 06:00:13 +00:00
|
|
|
// Class holding all information about a node. Rather than a real tree
|
|
|
|
// we store these in an array and simulate a tree.
|
|
|
|
class KeyNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyNode()
|
|
|
|
{
|
|
|
|
index = -1;
|
|
|
|
line = -1;
|
2013-10-02 08:17:16 +00:00
|
|
|
depth = -1;
|
2013-10-01 06:00:13 +00:00
|
|
|
iscat = false;
|
|
|
|
ispfx = false;
|
|
|
|
isparent = false;
|
|
|
|
isopen = false;
|
|
|
|
}
|
2018-02-02 18:24:53 +00:00
|
|
|
KeyNode( const KeyNode & ) = default;
|
|
|
|
KeyNode &operator = ( const KeyNode & ) = default;
|
2018-02-22 17:26:20 +00:00
|
|
|
//KeyNode( KeyNode && ) = default;
|
|
|
|
//KeyNode &operator = ( KeyNode && ) = default;
|
2013-10-01 06:00:13 +00:00
|
|
|
|
|
|
|
public:
|
2019-03-11 02:05:37 +00:00
|
|
|
CommandID name;
|
2013-10-01 06:00:13 +00:00
|
|
|
wxString category;
|
|
|
|
wxString prefix;
|
|
|
|
wxString label;
|
2018-02-09 02:16:13 +00:00
|
|
|
NormalizedKeyString key;
|
2013-10-01 06:00:13 +00:00
|
|
|
int index;
|
|
|
|
int line;
|
2013-10-02 08:17:16 +00:00
|
|
|
int depth;
|
2013-10-01 06:00:13 +00:00
|
|
|
bool iscat;
|
|
|
|
bool ispfx;
|
|
|
|
bool isparent;
|
|
|
|
bool isopen;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Declare the KeyNode arrays
|
|
|
|
|
|
|
|
// Types of view currently supported
|
2019-03-30 19:22:43 +00:00
|
|
|
enum ViewByType : int
|
2013-10-01 06:00:13 +00:00
|
|
|
{
|
|
|
|
ViewByTree,
|
|
|
|
ViewByName,
|
|
|
|
ViewByKey
|
|
|
|
};
|
|
|
|
|
|
|
|
#if wxUSE_ACCESSIBILITY
|
|
|
|
class KeyViewAx;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// The KeyView class
|
2016-02-24 06:06:39 +00:00
|
|
|
class KeyView final : public wxVListBox
|
2013-10-01 06:00:13 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyView(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint & pos = wxDefaultPosition,
|
|
|
|
const wxSize & size = wxDefaultSize);
|
|
|
|
virtual ~KeyView();
|
2018-11-16 20:24:16 +00:00
|
|
|
wxString GetName() const override; // Gets the control name from the base class
|
2013-10-01 06:00:13 +00:00
|
|
|
|
2019-03-11 02:05:37 +00:00
|
|
|
void RefreshBindings(const CommandIDs & names,
|
2020-05-05 20:16:56 +00:00
|
|
|
const TranslatableStrings & categories,
|
2019-01-09 20:26:32 +00:00
|
|
|
const TranslatableStrings & prefixes,
|
2019-12-15 18:51:21 +00:00
|
|
|
const TranslatableStrings & labels,
|
2018-02-09 02:16:13 +00:00
|
|
|
const std::vector<NormalizedKeyString> & keys,
|
2017-05-25 14:45:47 +00:00
|
|
|
bool bSort);
|
2013-10-01 06:00:13 +00:00
|
|
|
|
2013-10-02 08:17:16 +00:00
|
|
|
int GetSelected() const;
|
|
|
|
|
|
|
|
wxString GetLabel(int index) const;
|
|
|
|
wxString GetFullLabel(int index) const;
|
|
|
|
|
2019-03-11 02:05:37 +00:00
|
|
|
int GetIndexByName(const CommandID & name) const;
|
|
|
|
CommandID GetName(int index) const;
|
|
|
|
CommandID GetNameByKey(const NormalizedKeyString & key) const;
|
2013-10-02 08:17:16 +00:00
|
|
|
|
2018-02-09 02:16:13 +00:00
|
|
|
int GetIndexByKey(const NormalizedKeyString & key) const;
|
|
|
|
NormalizedKeyString GetKey(int index) const;
|
2013-10-02 08:17:16 +00:00
|
|
|
bool CanSetKey(int index) const;
|
2018-02-09 02:16:13 +00:00
|
|
|
bool SetKey(int index, const NormalizedKeyString & key);
|
2019-03-11 02:05:37 +00:00
|
|
|
bool SetKeyByName(const CommandID & name, const NormalizedKeyString & key);
|
2013-10-01 06:00:13 +00:00
|
|
|
|
|
|
|
void SetView(ViewByType type);
|
2013-10-02 08:17:16 +00:00
|
|
|
|
2013-10-01 06:00:13 +00:00
|
|
|
void SetFilter(const wxString & filter);
|
|
|
|
|
2013-10-02 00:05:39 +00:00
|
|
|
void ExpandAll();
|
|
|
|
void CollapseAll();
|
|
|
|
|
2017-08-29 14:02:22 +00:00
|
|
|
void SelectNode(int index);
|
|
|
|
|
2013-10-01 06:00:13 +00:00
|
|
|
private:
|
2013-10-02 08:17:16 +00:00
|
|
|
void RecalcExtents();
|
|
|
|
void UpdateHScroll();
|
2017-05-25 14:45:47 +00:00
|
|
|
void RefreshLines(bool bSort = true);
|
2013-10-02 08:17:16 +00:00
|
|
|
|
|
|
|
int LineToIndex(int line) const;
|
|
|
|
int IndexToLine(int index) const;
|
|
|
|
|
2018-11-16 20:24:16 +00:00
|
|
|
void OnDrawBackground(wxDC & dc, const wxRect & rect, size_t line) const override;
|
|
|
|
void OnDrawItem(wxDC & dc, const wxRect & rect, size_t line) const override;
|
|
|
|
wxCoord OnMeasureItem(size_t line) const override;
|
2013-10-01 06:00:13 +00:00
|
|
|
|
|
|
|
void OnSelected(wxCommandEvent & event);
|
|
|
|
void OnSetFocus(wxFocusEvent & event);
|
|
|
|
void OnKillFocus(wxFocusEvent & event);
|
|
|
|
void OnSize(wxSizeEvent & event);
|
2013-10-02 08:17:16 +00:00
|
|
|
void OnScroll(wxScrollWinEvent & event);
|
|
|
|
void OnKeyDown(wxKeyEvent & event);
|
|
|
|
void OnLeftDown(wxMouseEvent & event);
|
2013-10-01 06:00:13 +00:00
|
|
|
|
2017-05-24 21:01:19 +00:00
|
|
|
|
2018-02-02 18:24:53 +00:00
|
|
|
static bool CmpKeyNodeByTree(KeyNode *n1, KeyNode *n2);
|
|
|
|
static bool CmpKeyNodeByName(KeyNode *n1, KeyNode *n2);
|
|
|
|
static bool CmpKeyNodeByKey(KeyNode *n1, KeyNode *n2);
|
2013-10-01 06:00:13 +00:00
|
|
|
|
|
|
|
#if wxUSE_ACCESSIBILITY
|
|
|
|
friend class KeyViewAx;
|
|
|
|
|
|
|
|
bool HasChildren(int line);
|
|
|
|
bool IsExpanded(int line);
|
|
|
|
wxCoord GetLineHeight(int line);
|
|
|
|
wxString GetValue(int line);
|
2013-10-30 20:44:22 +00:00
|
|
|
ViewByType GetViewType();
|
2013-10-01 06:00:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
2018-02-02 18:24:53 +00:00
|
|
|
std::vector<KeyNode> mNodes;
|
|
|
|
std::vector<KeyNode*> mLines;
|
2013-10-01 06:00:13 +00:00
|
|
|
|
|
|
|
ViewByType mViewType;
|
|
|
|
wxString mFilter;
|
|
|
|
|
|
|
|
wxCoord mScrollX;
|
|
|
|
wxCoord mWidth;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2013-10-01 06:00:13 +00:00
|
|
|
size_t mLineCount;
|
|
|
|
wxCoord mLineHeight;
|
|
|
|
wxCoord mKeyX;
|
|
|
|
int mCommandWidth;
|
|
|
|
wxCoord mKeyWidth;
|
|
|
|
|
|
|
|
#if wxUSE_ACCESSIBILITY
|
|
|
|
KeyViewAx *mAx;
|
|
|
|
#endif
|
|
|
|
|
2016-09-18 14:26:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2013-10-01 06:00:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|