mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
cc_extra: add short methode to paintIcon with optional text content
This commit is contained in:
@@ -122,3 +122,51 @@ bool paintImage( const std::string& Image,
|
||||
|
||||
return box.isPicPainted();
|
||||
}
|
||||
|
||||
bool paintIcon ( const std::string& filename,
|
||||
const int& x,
|
||||
const int& y,
|
||||
const int& dx,
|
||||
const int& dy,
|
||||
const std::string& text,
|
||||
const int& font_style,
|
||||
const fb_pixel_t& color_body,
|
||||
const fb_pixel_t& color_text)
|
||||
{
|
||||
int h = 0;
|
||||
int w = 0;
|
||||
CFrameBuffer::getInstance()->getIconSize(filename.c_str(), &w, &h);
|
||||
|
||||
CComponentsText box( x,
|
||||
y,
|
||||
dx < 1 ? w : dx,
|
||||
dy < 1 ? h : dy,
|
||||
text,
|
||||
CTextBox::CENTER,
|
||||
*CNeutrinoFonts::getInstance()->getDynFont(w, h, text),
|
||||
font_style,
|
||||
NULL,
|
||||
CC_SHADOW_OFF,
|
||||
color_text,
|
||||
COL_FRAME_PLUS_0,
|
||||
color_body);
|
||||
|
||||
box.setBodyBGImageName(filename);
|
||||
box.doPaintBg(true);
|
||||
box.enableTboxSaveScreen(false);
|
||||
box.setCorner(0, 0);
|
||||
box.paint(CC_SAVE_SCREEN_NO);
|
||||
|
||||
return box.isPainted();
|
||||
}
|
||||
|
||||
bool paintIcon ( const std::string& filename,
|
||||
const int& x,
|
||||
const int& y,
|
||||
const std::string& text,
|
||||
const int& font_style,
|
||||
const fb_pixel_t& color_body,
|
||||
const fb_pixel_t& color_text)
|
||||
{
|
||||
return paintIcon (filename, x, y, 0, 0, text, font_style, color_body, color_text);
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@
|
||||
/** Paint a box on screen.
|
||||
* @param[in] x position
|
||||
* @param[in] y position
|
||||
* @param[in] dx witdh
|
||||
* @param[in] dx width
|
||||
* @param[in] dy height
|
||||
* @param[in] color_body color of background, default = COL_MENUCONTENT_PLUS_0
|
||||
* @param[in] radius corner radius, default = 0
|
||||
@@ -137,7 +137,7 @@ bool paintBoxRel0( const int& x,
|
||||
* @param[in] std::string& text
|
||||
* @param[in] x position
|
||||
* @param[in] y position
|
||||
* @param[in] dx witdh
|
||||
* @param[in] dx width
|
||||
* @param[in] dy height
|
||||
* @param[in] *font pointer to font type object, default = NULL, sets g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO] as default font
|
||||
* @param[in] color_body color of box, default = COL_MENUCONTENT_PLUS_0
|
||||
@@ -214,7 +214,7 @@ bool paintTextBoxRel( const std::string& text,
|
||||
* @param[in] std::string& full path to image file or icon filename without file extension (e.g. .png)
|
||||
* @param[in] x position
|
||||
* @param[in] y position
|
||||
* @param[in] dx witdh, default = 0 (no scale)
|
||||
* @param[in] dx width, default = 0 (no scale)
|
||||
* @param[in] dy height, default = 0 (no scale)
|
||||
* @param[in] transparent image transparency mode
|
||||
* @li CFrameBuffer::TM_EMPTY
|
||||
@@ -276,4 +276,65 @@ bool paintImage( const std::string& Image,
|
||||
int shadow_mode = CC_SHADOW_OFF,
|
||||
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
/** Paints a box with icon and optional text as content on screen with defined position and dimensions.\n
|
||||
* If no dimensions are defined, this method will try to paint the box without any scale.\n
|
||||
* If an dimension is defined it will be try to scale the image.\n
|
||||
* Default behavior is paint an icon on screen like known method paintIcon() in class CFrameBuffer.
|
||||
* @param[in] std::string& icon filename without file extension (e.g. .png)
|
||||
* @param[in] x position
|
||||
* @param[in] y position
|
||||
* @param[in] dx width, default = 0 (no scale)
|
||||
* @param[in] dy height, default = 0 (no scale)
|
||||
* @param[in] std::string& text (default empty)
|
||||
* @param[in] font_style font style
|
||||
* @li CComponentsText::FONT_STYLE_REGULAR (default)
|
||||
* @li CComponentsText::FONT_STYLE_BOLD,
|
||||
* @li CComponentsText::FONT_STYLE_ITALIC
|
||||
* @param[in] color_body color of background, default = COL_MENUCONTENT_PLUS_0
|
||||
* @param[in] color_text color of text, default = COL_MENUCONTENT_TEXT
|
||||
*
|
||||
* @return
|
||||
* True if painted
|
||||
* @see
|
||||
* @li paintImage()
|
||||
*/
|
||||
bool paintIcon ( const std::string& filename,
|
||||
const int& x,
|
||||
const int& y,
|
||||
const int& dx,
|
||||
const int& dy,
|
||||
const std::string& text = std::string(),
|
||||
const int& font_style = CComponentsText::FONT_STYLE_REGULAR,
|
||||
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
|
||||
const fb_pixel_t& color_text = COL_MENUCONTENT_TEXT);
|
||||
|
||||
/** Overloaded version of paintIcon() without dimension parameters Paints a box with icon and optional text as content on screen with defined position.\n
|
||||
* If no dimensions are defined, this method will try to paint the box without any scale.\n
|
||||
* If an dimension is defined it will be try to scale the image.\n
|
||||
* Default behavior is paint an icon on screen like known method paintIcon() in class CFrameBuffer.
|
||||
* @param[in] std::string& icon filename without file extension (e.g. .png)
|
||||
* @param[in] x position
|
||||
* @param[in] y position
|
||||
* @param[in] std::string& text (default empty)
|
||||
* @param[in] font_style font style
|
||||
* @li CComponentsText::FONT_STYLE_REGULAR (default)
|
||||
* @li CComponentsText::FONT_STYLE_BOLD,
|
||||
* @li CComponentsText::FONT_STYLE_ITALIC
|
||||
* @param[in] color_body color of background, default = COL_MENUCONTENT_PLUS_0
|
||||
* @param[in] color_text color of text, default = COL_MENUCONTENT_TEXT
|
||||
*
|
||||
* @return
|
||||
* True if painted
|
||||
* @see
|
||||
* @li paintImage()
|
||||
* @li paintIcon()
|
||||
*/
|
||||
bool paintIcon ( const std::string& filename,
|
||||
const int& x,
|
||||
const int& y,
|
||||
const std::string& text = std::string(),
|
||||
const int& font_style = CComponentsText::FONT_STYLE_REGULAR,
|
||||
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
|
||||
const fb_pixel_t& color_text = COL_MENUCONTENT_TEXT);
|
||||
|
||||
#endif
|
||||
|
@@ -707,6 +707,13 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
|
||||
return res;
|
||||
}
|
||||
else if (actionKey == "icon") {
|
||||
int y = 100;
|
||||
for (int i = 0; i < 10; i++){
|
||||
paintIcon (NEUTRINO_ICON_BUTTON_BLUE, 100, y, to_string(i), CNeutrinoFonts::FONT_STYLE_BOLD, COL_MENUCONTENT_PLUS_0, COL_MENUCONTENT_TEXT);
|
||||
y += 30;
|
||||
}
|
||||
}
|
||||
else if (actionKey == "iconform"){
|
||||
if (iconform == NULL){
|
||||
iconform = new CComponentsIconForm();
|
||||
@@ -1239,6 +1246,7 @@ void CTestMenu::showCCTests(CMenuWidget *widget)
|
||||
widget->addItem(new CMenuForwarder("Blinking Extended Text", true, NULL, this, "blinking_text_ext"));
|
||||
widget->addItem(new CMenuForwarder("Scrollbar", true, NULL, this, "scrollbar"));
|
||||
widget->addItem(new CMenuForwarder("Record", true, NULL, this, "show_records"));
|
||||
widget->addItem(new CMenuForwarder("Icon", true, NULL, this, "icon"));
|
||||
}
|
||||
|
||||
void CTestMenu::showHWTests(CMenuWidget *widget)
|
||||
|
Reference in New Issue
Block a user