2017-01-02 21:27:08 -05:00
|
|
|
// Copyright (c) Charles J. Cliffe
|
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
|
2016-09-13 22:59:21 -04:00
|
|
|
#pragma once
|
|
|
|
|
2016-11-20 23:26:38 -05:00
|
|
|
#include "wx/choice.h"
|
2016-12-16 22:05:25 -05:00
|
|
|
#include "wx/dialog.h"
|
2016-09-14 19:46:57 -04:00
|
|
|
|
2017-01-02 01:29:27 -05:00
|
|
|
#include "BookmarkPanel.h"
|
|
|
|
#include "BookmarkMgr.h"
|
2017-02-28 12:58:54 -05:00
|
|
|
#include "MouseTracker.h"
|
2017-01-02 01:29:27 -05:00
|
|
|
|
2016-10-10 22:28:48 -04:00
|
|
|
class TreeViewItem : public wxTreeItemData {
|
|
|
|
public:
|
2021-04-22 00:34:45 -04:00
|
|
|
enum class Type {
|
2016-10-10 22:28:48 -04:00
|
|
|
TREEVIEW_ITEM_TYPE_GROUP,
|
|
|
|
TREEVIEW_ITEM_TYPE_ACTIVE,
|
|
|
|
TREEVIEW_ITEM_TYPE_RECENT,
|
2016-12-27 00:06:25 -05:00
|
|
|
TREEVIEW_ITEM_TYPE_BOOKMARK,
|
|
|
|
TREEVIEW_ITEM_TYPE_RANGE
|
2016-10-10 22:28:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
TreeViewItem() {
|
|
|
|
demod = nullptr;
|
2017-03-02 16:10:17 -05:00
|
|
|
bookmarkEnt = nullptr;
|
|
|
|
rangeEnt = nullptr;
|
|
|
|
};
|
2017-03-04 05:22:29 -05:00
|
|
|
// copy constructor
|
|
|
|
TreeViewItem(const TreeViewItem& src) {
|
|
|
|
demod = src.demod;
|
|
|
|
bookmarkEnt = src.bookmarkEnt;
|
|
|
|
rangeEnt = src.rangeEnt;
|
|
|
|
type = src.type;
|
|
|
|
groupName = src.groupName;
|
|
|
|
};
|
2017-03-02 16:10:17 -05:00
|
|
|
|
2021-04-22 00:34:45 -04:00
|
|
|
~TreeViewItem() override = default;
|
2016-10-10 22:28:48 -04:00
|
|
|
|
2021-04-22 00:34:45 -04:00
|
|
|
TreeViewItem::Type type;
|
2017-03-02 16:10:17 -05:00
|
|
|
|
|
|
|
BookmarkEntryPtr bookmarkEnt;
|
2017-02-28 12:58:54 -05:00
|
|
|
BookmarkRangeEntryPtr rangeEnt;
|
2017-03-02 16:10:17 -05:00
|
|
|
|
2017-08-27 05:11:30 -04:00
|
|
|
DemodulatorInstancePtr demod;
|
2016-10-10 22:28:48 -04:00
|
|
|
std::string groupName;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-12-16 22:05:25 -05:00
|
|
|
class BookmarkViewVisualDragItem : public wxDialog {
|
|
|
|
public:
|
2021-04-04 22:15:10 -04:00
|
|
|
explicit BookmarkViewVisualDragItem(const wxString& labelValue = L"Popup");
|
2016-12-16 22:05:25 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-13 22:59:21 -04:00
|
|
|
class BookmarkView : public BookmarkPanel {
|
|
|
|
public:
|
2021-04-04 22:15:10 -04:00
|
|
|
explicit BookmarkView( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxTAB_TRAVERSAL );
|
2017-03-02 16:10:17 -05:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
~BookmarkView() override;
|
2016-09-13 22:59:21 -04:00
|
|
|
|
2017-03-04 05:22:29 -05:00
|
|
|
//order an asynchronous refresh/rebuild of the whole tree,
|
|
|
|
//will take effect at the next onUpdateTimer() occurence.
|
2016-09-13 22:59:21 -04:00
|
|
|
void updateActiveList();
|
2017-03-04 05:22:29 -05:00
|
|
|
|
|
|
|
//order asynchronous updates of the bookmarks,
|
|
|
|
//will take effect at the next onUpdateTimer() occurence.
|
2016-10-06 22:27:12 -04:00
|
|
|
void updateBookmarks();
|
2021-04-04 22:15:10 -04:00
|
|
|
void updateBookmarks(const std::string& group);
|
2017-03-04 05:22:29 -05:00
|
|
|
|
|
|
|
bool isKeywordMatch(std::wstring str, std::vector<std::wstring> &keywords);
|
|
|
|
|
2016-10-06 22:27:12 -04:00
|
|
|
wxTreeItemId refreshBookmarks();
|
2016-09-29 21:57:23 -04:00
|
|
|
void updateTheme();
|
2016-10-06 21:08:45 -04:00
|
|
|
void onMenuItem(wxCommandEvent& event);
|
2016-10-13 00:41:35 -04:00
|
|
|
bool isMouseInView();
|
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
bool getExpandState(const std::string& branchName);
|
|
|
|
void setExpandState(const std::string& branchName, bool state);
|
2016-12-27 13:01:19 -05:00
|
|
|
|
2017-02-28 12:58:54 -05:00
|
|
|
static BookmarkRangeEntryPtr makeActiveRangeEntry();
|
2017-01-24 23:14:39 -05:00
|
|
|
|
2016-09-13 22:59:21 -04:00
|
|
|
protected:
|
2021-04-04 22:15:10 -04:00
|
|
|
void activeSelection(const DemodulatorInstancePtr& dsel);
|
|
|
|
void bookmarkSelection(const BookmarkEntryPtr& bmSel);
|
|
|
|
void rangeSelection(const BookmarkRangeEntryPtr& re);
|
2017-03-04 05:22:29 -05:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
void activateBookmark(const BookmarkEntryPtr& bmEnt);
|
2017-03-04 05:22:29 -05:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
void activateRange(const BookmarkRangeEntryPtr& rangeEnt);
|
|
|
|
void recentSelection(const BookmarkEntryPtr& bmSel);
|
|
|
|
void groupSelection(const std::string& groupName);
|
2016-12-27 00:06:25 -05:00
|
|
|
void bookmarkBranchSelection();
|
|
|
|
void recentBranchSelection();
|
|
|
|
void rangeBranchSelection();
|
|
|
|
void activeBranchSelection();
|
2019-05-29 00:25:02 -04:00
|
|
|
|
|
|
|
void ensureSelectionInView();
|
|
|
|
void hideProps(bool hidePanel = true);
|
2016-11-14 23:16:08 -05:00
|
|
|
void showProps();
|
2016-09-28 20:37:39 -04:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
void onUpdateTimer( wxTimerEvent& event ) override;
|
2016-12-16 22:05:25 -05:00
|
|
|
|
2017-03-04 05:22:29 -05:00
|
|
|
//refresh / rebuild the whole tree item immediatly
|
2016-09-14 22:49:32 -04:00
|
|
|
void doUpdateActiveList();
|
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
void onKeyUp( wxKeyEvent& event ) override;
|
|
|
|
void onTreeActivate( wxTreeEvent& event ) override;
|
|
|
|
void onTreeCollapse( wxTreeEvent& event ) override;
|
|
|
|
void onTreeExpanded( wxTreeEvent& event ) override;
|
|
|
|
void onTreeItemMenu( wxTreeEvent& event ) override;
|
|
|
|
void onTreeSelect( wxTreeEvent& event ) override;
|
|
|
|
void onTreeSelectChanging( wxTreeEvent& event ) override;
|
|
|
|
void onLabelKillFocus(wxFocusEvent& event ) override;
|
|
|
|
void onLabelText( wxCommandEvent& event ) override;
|
|
|
|
void onDoubleClickFreq( wxMouseEvent& event ) override;
|
|
|
|
void onDoubleClickBandwidth( wxMouseEvent& event ) override;
|
|
|
|
void onTreeBeginDrag( wxTreeEvent& event ) override;
|
|
|
|
void onTreeEndDrag( wxTreeEvent& event ) override;
|
|
|
|
void onTreeItemGetTooltip( wxTreeEvent& event ) override;
|
|
|
|
void onEnterWindow( wxMouseEvent& event ) override;
|
|
|
|
void onLeaveWindow( wxMouseEvent& event ) override;
|
|
|
|
void onMotion( wxMouseEvent& event ) override;
|
|
|
|
|
|
|
|
void onSearchTextFocus( wxMouseEvent& event ) override;
|
|
|
|
void onSearchText( wxCommandEvent& event ) override;
|
|
|
|
void onClearSearch( wxCommandEvent& event ) override;
|
2016-11-08 01:35:34 -05:00
|
|
|
|
|
|
|
void clearButtons();
|
|
|
|
void showButtons();
|
2016-11-14 23:16:08 -05:00
|
|
|
void refreshLayout();
|
2016-11-08 01:35:34 -05:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
wxButton *makeButton(wxWindow *parent, const std::string& labelVal, wxObjectEventFunction handler);
|
|
|
|
wxButton *addButton(wxWindow *parent, const std::string& labelVal, wxObjectEventFunction handler);
|
2016-11-08 01:35:34 -05:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
void doBookmarkActive(const std::string& group, const DemodulatorInstancePtr& demod);
|
|
|
|
void doBookmarkRecent(const std::string& group, const BookmarkEntryPtr& be);
|
|
|
|
void doMoveBookmark(const BookmarkEntryPtr& be, const std::string& group);
|
|
|
|
void doRemoveActive(const DemodulatorInstancePtr& demod);
|
|
|
|
void doRemoveRecent(const BookmarkEntryPtr& be);
|
2016-12-17 21:14:13 -05:00
|
|
|
void doClearRecents();
|
|
|
|
|
2016-11-20 23:26:38 -05:00
|
|
|
void updateBookmarkChoices();
|
|
|
|
void addBookmarkChoice(wxWindow *parent);
|
|
|
|
void onBookmarkChoice( wxCommandEvent &event );
|
|
|
|
|
2016-11-08 01:35:34 -05:00
|
|
|
void onRemoveActive( wxCommandEvent& event );
|
2017-12-04 22:44:47 -05:00
|
|
|
void onStartRecording( wxCommandEvent& event );
|
|
|
|
void onStopRecording( wxCommandEvent& event );
|
2016-11-08 01:35:34 -05:00
|
|
|
void onRemoveBookmark( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void onActivateBookmark( wxCommandEvent& event );
|
|
|
|
void onActivateRecent( wxCommandEvent& event );
|
2016-12-17 21:14:13 -05:00
|
|
|
void onRemoveRecent ( wxCommandEvent& event );
|
|
|
|
void onClearRecents ( wxCommandEvent& event );
|
2016-11-08 01:35:34 -05:00
|
|
|
|
2016-11-10 20:43:01 -05:00
|
|
|
void onAddGroup( wxCommandEvent& event );
|
|
|
|
void onRemoveGroup( wxCommandEvent& event );
|
2016-12-27 00:06:25 -05:00
|
|
|
|
|
|
|
void onAddRange( wxCommandEvent& event );
|
|
|
|
void onRemoveRange( wxCommandEvent& event );
|
|
|
|
void onRenameRange( wxCommandEvent& event );
|
|
|
|
void onActivateRange( wxCommandEvent& event );
|
2017-01-24 23:14:39 -05:00
|
|
|
void onUpdateRange( wxCommandEvent& event );
|
2018-03-10 02:34:39 -05:00
|
|
|
|
2018-03-24 03:45:50 -04:00
|
|
|
bool skipEvents();
|
|
|
|
|
2016-12-15 21:53:51 -05:00
|
|
|
TreeViewItem *itemToTVI(wxTreeItemId item);
|
2017-03-02 16:10:17 -05:00
|
|
|
|
|
|
|
void SetTreeItemData(const wxTreeItemId& item, wxTreeItemData *data);
|
2017-02-28 12:58:54 -05:00
|
|
|
|
|
|
|
MouseTracker mouseTracker;
|
2016-09-14 19:46:57 -04:00
|
|
|
|
2016-12-27 00:06:25 -05:00
|
|
|
wxTreeItemId rootBranch, activeBranch, bookmarkBranch, recentBranch, rangeBranch;
|
2016-10-06 21:08:45 -04:00
|
|
|
|
2016-11-25 22:19:19 -05:00
|
|
|
std::map<std::string, bool> expandState;
|
|
|
|
|
2016-10-13 00:41:35 -04:00
|
|
|
TreeViewItem *dragItem;
|
|
|
|
wxTreeItemId dragItemId;
|
2016-12-16 22:05:25 -05:00
|
|
|
BookmarkViewVisualDragItem *visualDragItem;
|
2016-10-13 00:41:35 -04:00
|
|
|
|
2016-10-06 21:08:45 -04:00
|
|
|
// Bookmarks
|
2016-10-06 22:27:12 -04:00
|
|
|
std::atomic_bool doUpdateBookmarks;
|
|
|
|
std::set< std::string > doUpdateBookmarkGroup;
|
2016-09-29 20:47:38 -04:00
|
|
|
std::map<std::string, wxTreeItemId> groups;
|
2016-11-20 23:26:38 -05:00
|
|
|
wxArrayString bookmarkChoices;
|
|
|
|
wxChoice *bookmarkChoice;
|
2016-10-06 22:27:12 -04:00
|
|
|
|
2016-10-06 21:08:45 -04:00
|
|
|
// Active
|
2016-10-06 22:27:12 -04:00
|
|
|
std::atomic_bool doUpdateActive;
|
2016-12-17 20:47:32 -05:00
|
|
|
|
|
|
|
// Focus
|
2017-02-28 12:58:54 -05:00
|
|
|
BookmarkEntryPtr nextEnt;
|
|
|
|
BookmarkRangeEntryPtr nextRange;
|
2017-08-27 05:11:30 -04:00
|
|
|
DemodulatorInstancePtr nextDemod;
|
2017-03-30 22:26:11 -04:00
|
|
|
std::string nextGroup;
|
2016-12-26 21:56:19 -05:00
|
|
|
|
|
|
|
// Search
|
|
|
|
std::vector<std::wstring> searchKeywords;
|
2017-03-01 16:13:41 -05:00
|
|
|
|
2021-04-04 22:15:10 -04:00
|
|
|
void setStatusText(const std::string& statusText);
|
2018-03-24 03:45:50 -04:00
|
|
|
|
2016-10-10 22:28:48 -04:00
|
|
|
};
|