CImageInfo: Scroll license text if text box too small

Origin commit data
------------------
Branch: ni/coolstream
Commit: 801a15df7c
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
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
This commit is contained in:
Michael Liebmann
2013-03-20 21:48:51 +01:00
parent 152ddb0683
commit 21a5dba4fc
3 changed files with 30 additions and 3 deletions

View File

@@ -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(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 setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void removeLineBreaks(std::string& str); virtual void removeLineBreaks(std::string& str);
CTextBox* getCCItemTextBoxInst() { return ct_textbox; };
}; };
class CComponentsLabel : public CComponentsText class CComponentsLabel : public CComponentsText
@@ -223,7 +225,6 @@ class CComponentsInfoBox : public CComponentsText
{ {
private: private:
int x_text, x_offset; int x_text, x_offset;
CComponentsText * cctext;
CComponentsPicture * pic; CComponentsPicture * pic;
std::string pic_default_name; std::string pic_default_name;
@@ -232,6 +233,8 @@ class CComponentsInfoBox : public CComponentsText
std::string pic_name; std::string pic_name;
public: public:
CComponentsText * cctext;
CComponentsInfoBox(); CComponentsInfoBox();
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, 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, const char* info_text = NULL, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,

View File

@@ -59,6 +59,7 @@ CImageInfo::CImageInfo(): config ('\t')
void CImageInfo::Init(void) void CImageInfo::Init(void)
{ {
cc_win = NULL; cc_win = NULL;
cc_lic = NULL;
item_offset = 20; item_offset = 20;
item_top = item_offset; item_top = item_offset;
license_txt = ""; license_txt = "";
@@ -73,6 +74,21 @@ CImageInfo::~CImageInfo()
delete cc_win; 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 CImageInfo::exec(CMenuTarget* parent, const std::string &)
{ {
int res = menu_return::RETURN_REPAINT; int res = menu_return::RETURN_REPAINT;
@@ -98,6 +114,12 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &)
res = menu_return::RETURN_EXIT_ALL; res = menu_return::RETURN_EXIT_ALL;
break; 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){ else if (msg <= CRCInput::RC_MaxRC){
break; break;
} }
@@ -271,8 +293,8 @@ void CImageInfo::InitLicenseText()
} }
in.close(); in.close();
CComponentsInfoBox *cc_lic = new CComponentsInfoBox(item_offset, item_top, cc_win->getWidth()-2*item_offset, cc_win->getHeight()-item_top); 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->setText(license_txt, CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]);
//add text to container //add text to container
cc_win->addCCItem(cc_lic); cc_win->addCCItem(cc_lic);

View File

@@ -54,8 +54,10 @@ class CImageInfo : public CMenuTarget
void InitSupportInfos(); void InitSupportInfos();
void ShowWindow(); void ShowWindow();
void InitLicenseText(); void InitLicenseText();
void ScrollLic(bool scrollDown);
CComponentsWindow *cc_win; CComponentsWindow *cc_win;
CComponentsInfoBox *cc_lic;
CConfigFile config; CConfigFile config;
public: public: