From fbbb0ac57dacad101ac59059a0ca3df373a5f7aa Mon Sep 17 00:00:00 2001 From: martii Date: Wed, 18 Dec 2013 17:07:47 +0100 Subject: [PATCH] gui/components: CSignalBox: allow for horizontal arrangement; add methods to retrieve current value Signed-off-by: Thilo Graf --- src/gui/components/cc_frm_signalbars.cpp | 17 ++++++++++++----- src/gui/components/cc_frm_signalbars.h | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index a7f94baec..a046e10da 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -257,9 +257,10 @@ void CSignalNoiseRatioBar::Refresh() //********************************************************************************************************************** -CSignalBox::CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref) +CSignalBox::CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref, const bool vert) { initVarSigBox(); + vertical = vert; sbx_frontend = frontend_ref; x = xpos; @@ -267,14 +268,19 @@ CSignalBox::CSignalBox(const int& xpos, const int& ypos, const int& w, const int width = w; height = h; - sbx_bar_height = height/2; - sbx_bar_width = width-2*corner_rad; + if (vertical) { + sbx_bar_height = height/2; + sbx_bar_width = width-2*corner_rad; + } else { + sbx_bar_height = height; + sbx_bar_width = width/2-2*corner_rad; + } sbar = new CSignalBar(sbx_bar_x, 0, sbx_bar_width, sbx_bar_height, sbx_frontend); sbar->doPaintBg(false); addCCItem(sbar); - snrbar = new CSignalNoiseRatioBar(sbx_bar_x, CC_APPEND, sbx_bar_width, sbx_bar_height, sbx_frontend); + snrbar = new CSignalNoiseRatioBar(vertical ? sbx_bar_x : CC_APPEND, vertical ? CC_APPEND : 0, sbx_bar_width, sbx_bar_height, sbx_frontend); snrbar->doPaintBg(false); addCCItem(snrbar); @@ -293,6 +299,7 @@ void CSignalBox::initVarSigBox() sbx_bar_x = corner_rad; sbx_caption_color = COL_INFOBAR_TEXT; sbx_scale_w_percent = 60; + vertical = true; } void CSignalBox::initSignalItems() @@ -314,7 +321,7 @@ void CSignalBox::initSignalItems() sbar->setScaleHeight(scale_h); sbar->setScaleWidth(sbx_scale_w_percent); - snrbar->setDimensionsAll(sbar_x, CC_APPEND, sbar_w, sbar_h); + snrbar->setDimensionsAll(vertical ? sbar_x : CC_APPEND, vertical ? CC_APPEND : fr_thickness, sbar_w, sbar_h); snrbar->setFrontEnd(sbx_frontend); snrbar->setCorner(0); snrbar->setScaleHeight(scale_h); diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index 3945cdbb8..846e0707e 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -139,6 +139,9 @@ class CSignalBar : public CComponentsForm ///paint this items virtual void paint(bool do_save_bg); + + //returns the current signal value + uint16_t getValue(void) { return sb_signal; } }; /// Sub class of CSignalBar() @@ -256,6 +259,9 @@ class CSignalBox : public CComponentsForm ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value short sbx_scale_w_percent; + // true if vertical arrangement, false if horizontal + bool vertical; + ///initialize all needed basic attributes and objects void initVarSigBox(); ///initialize general properties of signal items @@ -266,7 +272,7 @@ class CSignalBox : public CComponentsForm public: ///class constructor for signal noise ratio. - CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref); + CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref, const bool vertical = true); ///returns the signal object, type = CSignalBar* CSignalBar* getScaleObject(){return sbar;}; @@ -283,6 +289,14 @@ class CSignalBox : public CComponentsForm ///paint items void paint(bool do_save_bg); + + ///return current signal value + uint16_t getSignalValue(void) { return sbar->getValue();} + + ///return current snr value + uint16_t getSNRValue(void) { return snrbar->getValue();} + + ///return current snr value }; #endif