Status/tootips additions: Gain, Bookmarks. Fix Bookmark mousewheel handling (for Windows <= 7) for the tree view

This commit is contained in:
vsonnier 2017-03-01 22:13:41 +01:00
parent b149da864a
commit 2760d3d12e
8 changed files with 57 additions and 24 deletions

View File

@ -28,6 +28,7 @@
#include <thread>
#include <wx/panel.h>
#include <wx/numformatter.h>
#ifdef __linux__
#include "CubicSDR.xpm"
@ -97,7 +98,7 @@ AppFrame::AppFrame() :
#endif
gainCanvas = new GainCanvas(demodPanel, attribList);
gainCanvas->setHelpTip("Tuner gains in dB. Click / use Mousewheel to change.");
gainSizerItem = demodTray->Add(gainCanvas, 0, wxEXPAND | wxALL, 0);
gainSizerItem->Show(false);
gainSpacerItem = demodTray->AddSpacer(1);
@ -182,7 +183,6 @@ AppFrame::AppFrame() :
demodWaterfallCanvas->getVisualDataQueue()->set_max_num_items(3);
demodWaterfallCanvas->setLinesPerSecond((int)(DEFAULT_DEMOD_WATERFALL_LINES_NB / DEMOD_WATERFALL_DURATION_IN_SECONDS));
demodVisuals->SetMinSize(wxSize(128,-1));
demodTray->Add(demodVisuals, 30, wxEXPAND | wxALL, 0);
@ -2568,3 +2568,25 @@ std::vector<std::string> str_explode(const std::string &seperator, const std::st
return vect_out;
}
void AppFrame::setStatusText(wxWindow* window, std::string statusText) {
GetStatusBar()->SetStatusText(statusText);
if (wxGetApp().getConfig()->getShowTips()) {
if (statusText != lastToolTip) {
wxToolTip::Enable(false);
window->SetToolTip(statusText);
lastToolTip = statusText;
wxToolTip::SetDelay(1000);
wxToolTip::Enable(true);
}
}
else {
window->SetToolTip("");
lastToolTip = "";
}
}
void AppFrame::setStatusText(std::string statusText, int value) {
GetStatusBar()->SetStatusText(
wxString::Format(statusText.c_str(), wxNumberFormatter::ToString((long)value, wxNumberFormatter::Style_WithThousandsSep)));
}

View File

@ -129,6 +129,9 @@ public:
#ifdef _WIN32
bool canFocus();
#endif
//set tooltip to window
void setStatusText(wxWindow* window, std::string statusText);
void AppFrame::setStatusText(std::string statusText, int value);
private:
void OnMenu(wxCommandEvent& event);
@ -215,6 +218,8 @@ private:
AboutDialog *aboutDlg;
std::string lastToolTip;
#ifdef USE_HAMLIB
void enableRig();
void disableRig();

View File

@ -89,6 +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_COMMAND_TREE_BEGIN_DRAG, wxTreeEventHandler( BookmarkPanel::onTreeBeginDrag ), NULL, this );
m_treeView->Connect( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, wxTreeEventHandler( BookmarkPanel::onTreeBeginLabelEdit ), NULL, this );

View File

@ -1429,10 +1429,12 @@ void BookmarkView::onEnterWindow( wxMouseEvent& event ) {
#ifdef _WIN32
if (wxGetApp().getAppFrame()->canFocus()) {
this->SetFocus();
//make mousewheel work in the tree view.
m_treeView->SetFocus();
}
#endif
setStatusText("You can mouse-drag a bookmark entry from one category to the next..etc. TODO: add more Bookmarks descriptions");
}
@ -1454,6 +1456,11 @@ void BookmarkView::onMotion( wxMouseEvent& event ) {
event.Skip();
}
void BookmarkView::setStatusText(std::string statusText) {
//make tooltips active on the tree view.
wxGetApp().getAppFrame()->setStatusText(m_treeView, statusText);
}
TreeViewItem *BookmarkView::itemToTVI(wxTreeItemId item) {
TreeViewItem* tvi = nullptr;

View File

@ -139,7 +139,6 @@ protected:
void onActivateRange( wxCommandEvent& event );
void onUpdateRange( wxCommandEvent& event );
TreeViewItem *itemToTVI(wxTreeItemId item);
MouseTracker mouseTracker;
@ -172,4 +171,6 @@ protected:
// Search
std::vector<std::wstring> searchKeywords;
void setStatusText(std::string statusText);
};

View File

@ -113,6 +113,11 @@ void GainCanvas::OnMouseMoved(wxMouseEvent& event) {
if (mouseTracker.mouseDown()) {
SetLevel();
}
else {
if (!helpTip.empty()) {
setStatusText(helpTip);
}
}
}
void GainCanvas::OnMouseDown(wxMouseEvent& event) {

View File

@ -159,24 +159,13 @@ void InteractiveCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
}
void InteractiveCanvas::setStatusText(std::string statusText) {
wxGetApp().getAppFrame()->GetStatusBar()->SetStatusText(statusText);
if (wxGetApp().getConfig()->getShowTips()) {
if (statusText != lastToolTip) {
wxToolTip::Enable(false);
this->SetToolTip(statusText);
lastToolTip = statusText;
wxToolTip::SetDelay(1000);
wxToolTip::Enable(true);
}
} else {
this->SetToolTip("");
lastToolTip = "";
}
wxGetApp().getAppFrame()->setStatusText(this, statusText);
}
void InteractiveCanvas::setStatusText(std::string statusText, int value) {
wxGetApp().getAppFrame()->GetStatusBar()->SetStatusText(
wxString::Format(statusText.c_str(), wxNumberFormatter::ToString((long) value, wxNumberFormatter::Style_WithThousandsSep)));
wxGetApp().getAppFrame()->setStatusText(statusText, value);
}
void InteractiveCanvas::OnMouseRightDown(wxMouseEvent& event) {

View File

@ -64,6 +64,5 @@ protected:
long long lastBandwidth;
bool isView;
std::string lastToolTip;
};