From 21a5dba4fca67aed1b45ac775b222bab47d4b0b7 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 20 Mar 2013 21:48:51 +0100 Subject: [PATCH] CImageInfo: Scroll license text if text box too small Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/801a15df7cce49188ebf54e61c5e47e0ed4953cd Author: Michael Liebmann Date: 2013-03-20 (Wed, 20 Mar 2013) Origin message was: ------------------ * CImageInfo: Scroll license text if text box too small ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc.h | 5 ++++- src/gui/imageinfo.cpp | 26 ++++++++++++++++++++++++-- src/gui/imageinfo.h | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 4d49f9cf7..6e6da091a 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -201,6 +201,8 @@ class CComponentsText : public CComponentsItem virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void removeLineBreaks(std::string& str); + + CTextBox* getCCItemTextBoxInst() { return ct_textbox; }; }; class CComponentsLabel : public CComponentsText @@ -223,7 +225,6 @@ class CComponentsInfoBox : public CComponentsText { private: int x_text, x_offset; - CComponentsText * cctext; CComponentsPicture * pic; std::string pic_default_name; @@ -232,6 +233,8 @@ class CComponentsInfoBox : public CComponentsText std::string pic_name; public: + CComponentsText * cctext; + CComponentsInfoBox(); CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, const char* info_text = NULL, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL, diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 66ccfdca8..366b5cb5b 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -59,6 +59,7 @@ CImageInfo::CImageInfo(): config ('\t') void CImageInfo::Init(void) { cc_win = NULL; + cc_lic = NULL; item_offset = 20; item_top = item_offset; license_txt = ""; @@ -73,6 +74,21 @@ CImageInfo::~CImageInfo() delete cc_win; } +void CImageInfo::ScrollLic(bool scrollDown) +{ + if (cc_lic && (cc_lic->cctext)) { + CTextBox* ctb = cc_lic->cctext->getCCItemTextBoxInst(); + if (ctb) { + ctb->enableBackgroundPaint(true); + if (scrollDown) + ctb->scrollPageDown(1); + else + ctb->scrollPageUp(1); + ctb->enableBackgroundPaint(false); + } + } +} + int CImageInfo::exec(CMenuTarget* parent, const std::string &) { int res = menu_return::RETURN_REPAINT; @@ -98,6 +114,12 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) res = menu_return::RETURN_EXIT_ALL; break; } + else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_page_up)) { + ScrollLic(false); + } + else if ((msg == CRCInput::RC_down) || (msg == CRCInput::RC_page_down)) { + ScrollLic(true); + } else if (msg <= CRCInput::RC_MaxRC){ break; } @@ -271,8 +293,8 @@ void CImageInfo::InitLicenseText() } in.close(); - CComponentsInfoBox *cc_lic = new CComponentsInfoBox(item_offset, item_top, cc_win->getWidth()-2*item_offset, cc_win->getHeight()-item_top); - cc_lic->setText(license_txt, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); + cc_lic = new CComponentsInfoBox(item_offset, item_top, cc_win->getWidth()-2*item_offset, cc_win->getHeight()-item_top); + cc_lic->setText(license_txt, CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); //add text to container cc_win->addCCItem(cc_lic); diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h index f04a26a58..9591155cc 100644 --- a/src/gui/imageinfo.h +++ b/src/gui/imageinfo.h @@ -54,8 +54,10 @@ class CImageInfo : public CMenuTarget void InitSupportInfos(); void ShowWindow(); void InitLicenseText(); + void ScrollLic(bool scrollDown); CComponentsWindow *cc_win; + CComponentsInfoBox *cc_lic; CConfigFile config; public: