CComponentsInfoBox: add possibility for scalable picons

This commit is contained in:
2017-12-09 23:49:37 +01:00
parent 1d0545e19c
commit 2a2d51d255
2 changed files with 21 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2012-2014, Thilo Graf 'dbt'
Copyright (C) 2012-2017, Thilo Graf 'dbt'
Copyright (C) 2012, Michael Liebmann 'micha-bbg'
License: GPL
@@ -70,6 +70,8 @@ CComponentsInfoBox::CComponentsInfoBox( const int& x_pos,
pic = NULL;
cctext = NULL;
pic_name = "";
pic_height = 0;
pic_width = 0;
x_offset = OFFSET_INNER_MID;
initParent(parent);
}
@@ -80,22 +82,25 @@ CComponentsInfoBox::~CComponentsInfoBox()
delete cctext;
}
void CComponentsInfoBox::setPicture(const std::string& picture_name)
void CComponentsInfoBox::setPicture(const std::string& picture_name, const int& dx, const int& dy)
{
pic_name = picture_name;
pic_name = picture_name;
if (!pic_name.empty()){
int w, h;
frameBuffer->getIconSize(pic_name.c_str(), &w, &h);
height = max(h, height);
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
if (dx > -1)
pic_width = dx;
if (dy > -1)
pic_height = dy;
height = max(pic_height, height);
}
}
void CComponentsInfoBox::setPicture(const char* picture_name)
void CComponentsInfoBox::setPicture(const char* picture_name, const int& dx, const int& dy)
{
string s_tmp = "";
if (picture_name)
s_tmp = string(picture_name);
setPicture(s_tmp);
setPicture(s_tmp, dx, dy);
}
void CComponentsInfoBox::paintPicture()
@@ -115,7 +120,8 @@ void CComponentsInfoBox::paintPicture()
int y_pic = (cc_parent ? cc_yr : y) + fr_thickness;
//init pic object and set icon paint position
pic = new CComponentsPicture(x_pic+x_offset, y_pic, 0, min(48, height-2*fr_thickness), pic_name); //NOTE: icons do not scale!
string image = frameBuffer->getIconPath(pic_name);
pic = new CComponentsPicture(x_pic+x_offset, y_pic, pic_width, min(pic_height, height-2*fr_thickness), image); //NOTE: icons do not scale!
pic->setColorBody(col_body);

View File

@@ -3,7 +3,7 @@
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2012-2014, Thilo Graf 'dbt'
Copyright (C) 2012-2017, Thilo Graf 'dbt'
License: GPL
@@ -57,6 +57,8 @@ class CComponentsInfoBox : public CComponentsText
///property: path or name of displayed image
std::string pic_name;
int pic_height, pic_width;
public:
///object: internal used CTextBox object
CComponentsText * cctext;
@@ -80,9 +82,9 @@ class CComponentsInfoBox : public CComponentsText
///set property: space around fram and beetween picture and textbox
void setSpaceOffset(const int offset){x_offset = offset;};
///set property: path or name of displayed image, parameter as string
void setPicture(const std::string& picture_name);
void setPicture(const std::string& picture_name, const int& dx = -1, const int& dy = -1);
///set property: path or name of displayed image, parameter as const char*
void setPicture(const char* picture_name);
void setPicture(const char* picture_name, const int& dx = -1, const int& dy = -1);
///retur internal picture object
CComponentsPicture * getPictureObject(){return pic;}
///paint item