mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 21:58:37 -05:00
Fix the label editing issue :)
This commit is contained in:
parent
772e24fdb3
commit
243c744c0a
@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 23 2015)
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
@ -20,7 +20,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
|
||||
m_clearSearchButton = new wxButton( this, wxID_ANY, wxT("Clear Search"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer1->Add( m_clearSearchButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
m_treeView = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_EDIT_LABELS|wxTR_HAS_VARIABLE_ROW_HEIGHT|wxTR_HIDE_ROOT|wxTR_SINGLE );
|
||||
m_treeView = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_HAS_VARIABLE_ROW_HEIGHT|wxTR_HIDE_ROOT|wxTR_SINGLE );
|
||||
bSizer1->Add( m_treeView, 1, wxEXPAND, 5 );
|
||||
|
||||
m_propPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
@ -89,16 +89,11 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
|
||||
m_searchText->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( BookmarkPanel::onSearchTextFocus ), NULL, this );
|
||||
m_searchText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BookmarkPanel::onSearchText ), NULL, this );
|
||||
m_clearSearchButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onClearSearch ), NULL, this );
|
||||
|
||||
//VSO: Added m_treeView wxEVT_ENTER_WINDOW/wxEVT_LEAVE_WINDOW that was missing.
|
||||
m_treeView->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(BookmarkPanel::onEnterWindow), NULL, this);
|
||||
m_treeView->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(BookmarkPanel::onLeaveWindow), NULL, this);
|
||||
|
||||
m_treeView->Connect( wxEVT_MOTION, wxMouseEventHandler( BookmarkPanel::onMotion ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( BookmarkPanel::onEnterWindow ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( BookmarkPanel::onLeaveWindow ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_MOTION, wxMouseEventHandler( BookmarkPanel::onMotion ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_BEGIN_DRAG, wxTreeEventHandler( BookmarkPanel::onTreeBeginDrag ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, wxTreeEventHandler( BookmarkPanel::onTreeBeginLabelEdit ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_END_DRAG, wxTreeEventHandler( BookmarkPanel::onTreeEndDrag ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_END_LABEL_EDIT, wxTreeEventHandler( BookmarkPanel::onTreeEndLabelEdit ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( BookmarkPanel::onTreeActivate ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxTreeEventHandler( BookmarkPanel::onTreeCollapse ), NULL, this );
|
||||
m_treeView->Connect( wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxTreeEventHandler( BookmarkPanel::onTreeExpanded ), NULL, this );
|
||||
@ -121,16 +116,11 @@ BookmarkPanel::~BookmarkPanel()
|
||||
m_searchText->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( BookmarkPanel::onSearchTextFocus ), NULL, this );
|
||||
m_searchText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BookmarkPanel::onSearchText ), NULL, this );
|
||||
m_clearSearchButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BookmarkPanel::onClearSearch ), NULL, this );
|
||||
|
||||
//VSO: Added m_treeView wxEVT_ENTER_WINDOW/wxEVT_LEAVE_WINDOW that was missing.
|
||||
m_treeView->Disconnect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(BookmarkPanel::onEnterWindow), NULL, this);
|
||||
m_treeView->Disconnect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(BookmarkPanel::onLeaveWindow), NULL, this);
|
||||
|
||||
m_treeView->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( BookmarkPanel::onEnterWindow ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( BookmarkPanel::onLeaveWindow ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_MOTION, wxMouseEventHandler( BookmarkPanel::onMotion ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_BEGIN_DRAG, wxTreeEventHandler( BookmarkPanel::onTreeBeginDrag ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, wxTreeEventHandler( BookmarkPanel::onTreeBeginLabelEdit ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_END_DRAG, wxTreeEventHandler( BookmarkPanel::onTreeEndDrag ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_END_LABEL_EDIT, wxTreeEventHandler( BookmarkPanel::onTreeEndLabelEdit ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( BookmarkPanel::onTreeActivate ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxTreeEventHandler( BookmarkPanel::onTreeCollapse ), NULL, this );
|
||||
m_treeView->Disconnect( wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxTreeEventHandler( BookmarkPanel::onTreeExpanded ), NULL, this );
|
||||
|
@ -311,7 +311,7 @@
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxTR_DEFAULT_STYLE|wxTR_EDIT_LABELS|wxTR_HAS_VARIABLE_ROW_HEIGHT|wxTR_HIDE_ROOT|wxTR_SINGLE</property>
|
||||
<property name="style">wxTR_DEFAULT_STYLE|wxTR_HAS_VARIABLE_ROW_HEIGHT|wxTR_HIDE_ROOT|wxTR_SINGLE</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
@ -319,12 +319,12 @@
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEnterWindow">onEnterWindow</event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeaveWindow">onLeaveWindow</event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
@ -341,11 +341,11 @@
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnTreeBeginDrag">onTreeBeginDrag</event>
|
||||
<event name="OnTreeBeginLabelEdit">onTreeBeginLabelEdit</event>
|
||||
<event name="OnTreeBeginLabelEdit"></event>
|
||||
<event name="OnTreeBeginRDrag"></event>
|
||||
<event name="OnTreeDeleteItem"></event>
|
||||
<event name="OnTreeEndDrag">onTreeEndDrag</event>
|
||||
<event name="OnTreeEndLabelEdit">onTreeEndLabelEdit</event>
|
||||
<event name="OnTreeEndLabelEdit"></event>
|
||||
<event name="OnTreeGetInfo"></event>
|
||||
<event name="OnTreeItemActivated">onTreeActivate</event>
|
||||
<event name="OnTreeItemCollapsed">onTreeCollapse</event>
|
||||
|
@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 23 2015)
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
@ -57,9 +57,7 @@ class BookmarkPanel : public wxPanel
|
||||
virtual void onSearchText( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onClearSearch( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeBeginDrag( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeBeginLabelEdit( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeEndDrag( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeEndLabelEdit( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeActivate( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeCollapse( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void onTreeExpanded( wxTreeEvent& event ) { event.Skip(); }
|
||||
|
@ -499,72 +499,6 @@ void BookmarkView::doUpdateActiveList() {
|
||||
}
|
||||
|
||||
|
||||
void BookmarkView::onTreeBeginLabelEdit( wxTreeEvent& event ) {
|
||||
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(event.GetItem()));
|
||||
|
||||
//if edition do not work, m_treeView->GetEditControl() may be null...
|
||||
if (!tvi || (m_treeView->GetEditControl() == NULL)) {
|
||||
event.Veto();
|
||||
return;
|
||||
}
|
||||
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE ||
|
||||
tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT ||
|
||||
tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK ||
|
||||
tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP ||
|
||||
tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE)
|
||||
{
|
||||
event.Allow();
|
||||
editingLabel = true;
|
||||
} else {
|
||||
event.Veto();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BookmarkView::onTreeEndLabelEdit( wxTreeEvent& event ) {
|
||||
wxTreeItemId itm = event.GetItem();
|
||||
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));
|
||||
|
||||
//if edition do not work, m_treeView->GetEditControl() may be null...
|
||||
if (m_treeView->GetEditControl() == NULL) {
|
||||
event.Veto();
|
||||
return;
|
||||
}
|
||||
|
||||
std::wstring newText = m_treeView->GetEditControl()->GetValue().ToStdWstring();
|
||||
|
||||
editingLabel = false;
|
||||
|
||||
if (!tvi) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
tvi->demod->setDemodulatorUserLabel(newText);
|
||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
tvi->bookmarkEnt->label = newText;
|
||||
tvi->bookmarkEnt->node->child("user_label")->element()->set(newText);
|
||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
tvi->bookmarkEnt->label = newText;
|
||||
tvi->bookmarkEnt->node->child("user_label")->element()->set(newText);
|
||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
std::string newGroup = m_treeView->GetEditControl()->GetValue().ToStdString();
|
||||
wxGetApp().getBookmarkMgr().renameGroup(tvi->groupName, newGroup);
|
||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
std::wstring newName = m_treeView->GetEditControl()->GetValue().ToStdWstring();
|
||||
if (newName.length() != 0) {
|
||||
tvi->rangeEnt->label = newName;
|
||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
||||
|
||||
wxTreeItemId itm = event.GetItem();
|
||||
@ -811,7 +745,7 @@ void BookmarkView::updateBookmarkChoices() {
|
||||
|
||||
void BookmarkView::addBookmarkChoice(wxWindow *parent) {
|
||||
updateBookmarkChoices();
|
||||
bookmarkChoice = new wxChoice(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, bookmarkChoices, wxALL|wxEXPAND, wxDefaultValidator, "Bookmark");
|
||||
bookmarkChoice = new wxChoice(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, bookmarkChoices, wxEXPAND, wxDefaultValidator, "Bookmark");
|
||||
bookmarkChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&BookmarkView::onBookmarkChoice, nullptr, this);
|
||||
parent->GetSizer()->Add(bookmarkChoice, 0, wxALL | wxEXPAND);
|
||||
}
|
||||
|
@ -106,8 +106,6 @@ protected:
|
||||
//refresh / rebuild the whole tree item immediatly
|
||||
void doUpdateActiveList();
|
||||
|
||||
void onTreeBeginLabelEdit( wxTreeEvent& event );
|
||||
void onTreeEndLabelEdit( wxTreeEvent& event );
|
||||
void onTreeActivate( wxTreeEvent& event );
|
||||
void onTreeCollapse( wxTreeEvent& event );
|
||||
void onTreeExpanded( wxTreeEvent& event );
|
||||
|
Loading…
Reference in New Issue
Block a user