Merge remote-tracking branch 'check/next-cc-fixed'

This commit is contained in:
Stefan Seyfried
2014-01-26 00:33:08 +01:00
26 changed files with 444 additions and 309 deletions

View File

@@ -90,8 +90,18 @@ void CComponents::paintFbItems(bool do_save_bg)
if (firstPaint && do_save_bg) {
for(size_t i=0; i<v_fbdata.size(); i++){
if (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN){
if ((v_fbdata[i].x <= 0) || (v_fbdata[i].y <= 0))
printf("\33[31m\t[CComponents] WARNING! Position <= 0 [%s - %d], x = %d y = %d\n\033[37m", __func__, __LINE__, v_fbdata[i].x, v_fbdata[i].y);
#ifdef DEBUG_CC
printf(" [CComponents]\n [%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n", __func__, __LINE__, firstPaint, v_fbdata[i].fbdata_type);
printf("\t[CComponents]\n\t[%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n",
__func__,
__LINE__,
firstPaint,
v_fbdata[i].fbdata_type,
v_fbdata[i].x,
v_fbdata[i].y,
v_fbdata[i].dx,
v_fbdata[i].dy);
#endif
saved_screen.x = v_fbdata[i].x;
saved_screen.y = v_fbdata[i].y;
@@ -109,18 +119,21 @@ void CComponents::paintFbItems(bool do_save_bg)
// Don't paint if dx or dy are 0
if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0)){
#ifdef DEBUG_CC
printf(" [CComponents] WARNING: [%s - %d], dx = %d dy = %d\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy);
printf("\t[CComponents] WARNING: [%s - %d], dx = %d dy = %d\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy);
#endif
continue;
}
if ((v_fbdata[i].x == 0) || (v_fbdata[i].y == 0)){
printf(" [CComponents] WARNING: [%s - %d], x = %d y = %d\n", __func__, __LINE__, v_fbdata[i].x, v_fbdata[i].y);
}
int fbtype = v_fbdata[i].fbdata_type;
#ifdef DEBUG_CC
printf(" [CComponents]\n [%s - %d], fbdata_[%d] \n x = %d\n y = %d\n dx = %d\n dy = %d\n", __func__, __LINE__, (int)i, v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
printf("\t[CComponents]\n\t[%s - %d], fbdata_[%d]\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n",
__func__,
__LINE__,
(int)i,
v_fbdata[i].x,
v_fbdata[i].y,
v_fbdata[i].dx,
v_fbdata[i].dy);
#endif
//some elements can be assembled from lines and must be handled as one unit (see details line),
//so all individual backgrounds of boxes must be saved and painted in "firstpaint mode"

View File

@@ -17,10 +17,8 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -38,34 +36,50 @@ using namespace std;
CComponentsFooter::CComponentsFooter()
{
//CComponentsFooter
initVarFooter();
initVarFooter(1, 1, 0, 0);
}
CComponentsFooter::CComponentsFooter( const int x_pos, const int y_pos, const int w, const int h, const int buttons, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow )
CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
const int& buttons,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow )
{
//CComponentsFooter
initVarFooter();
initVarFooter(x_pos, y_pos, w, h, buttons, has_shadow, color_frame, color_body, color_shadow);
}
x = x_pos;
y = y_pos;
width = w;
height = h;
void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
const int& buttons,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow )
{
cc_item_type = CC_ITEMTYPE_FOOTER;
x = x_pos;
y = y_pos;
//init footer width
width = w == 0 ? frameBuffer->getScreenWidth(true) : w;
//init header height
cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
if (h > 0)
height = h;
else
height = cch_font->getHeight();
cch_buttons = buttons;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
cch_buttons = buttons;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_BOTTOM;
initDefaultButtons();
initCCItems();
}
void CComponentsFooter::initVarFooter()
{
cc_item_type = CC_ITEMTYPE_FOOTER;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_BOTTOM;
}

View File

@@ -37,80 +37,73 @@ using namespace std;
CComponentsHeader::CComponentsHeader()
{
//CComponentsHeader
initVarHeader();
initVarHeader(1, 1, 0, 0, "", "", 0);
}
CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, const std::string& caption, const char* icon_name, const int buttons, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption,
const std::string& icon_name,
const int& buttons,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
//CComponentsHeader
initVarHeader();
initVarHeader(x_pos, y_pos, w, h, caption, icon_name, buttons, has_shadow, color_frame, color_body, color_shadow);
}
CComponentsHeaderLocalized::CComponentsHeaderLocalized( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t caption_locale,
const std::string& icon_name,
const int& buttons,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
:CComponentsHeader( x_pos, y_pos, w, h,
g_Locale->getText(caption_locale),
icon_name, buttons,
has_shadow,
color_frame, color_body, color_shadow){};
void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption,
const std::string& icon_name,
const int& buttons,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
cc_item_type = CC_ITEMTYPE_FRM_HEADER;
x = x_pos;
y = y_pos;
//init header width
width = w == 0 ? frameBuffer->getScreenWidth(true) : w;
//init header default height
height = max(h, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight());
cch_size_mode = CC_HEADER_SIZE_LARGE;
initCaptionFont(); //sets cch_font and calculate height if required;
x = x_pos;
y = y_pos;
width = w;
if (h > 0) {
userHeight = true;
height = h;
}
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
col_body = COL_MENUHEAD_PLUS_0;
cch_text = caption;
cch_icon_name = icon_name;
cch_buttons = buttons;
initDefaultButtons();
initCCItems();
}
CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsHeader
initVarHeader();
x = x_pos;
y = y_pos;
width = w;
if (h > 0) {
userHeight = true;
height = h;
}
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
cch_text = g_Locale->getText(caption_locale);
cch_icon_name = icon_name;
cch_buttons = buttons;
corner_rad = RADIUS_LARGE,
corner_type = CORNER_TOP;
initDefaultButtons();
initCCItems();
}
void CComponentsHeader::initVarHeader()
{
cc_item_type = CC_ITEMTYPE_FRM_HEADER;
col_body = COL_MENUHEAD_PLUS_0;
corner_rad = RADIUS_LARGE,
corner_type = CORNER_TOP;
//init header height
cch_size_mode = CC_HEADER_SIZE_LARGE;
cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
height = cch_font->getHeight();
userHeight = false;
//CComponentsHeader
cch_icon_obj = NULL;
cch_text_obj = NULL;
cch_icon_name = NULL;
cch_btn_obj = NULL;
cch_text = "";
cch_col_text = COL_MENUHEAD_TEXT;
cch_caption_align = CTextBox::NO_AUTO_LINEBREAK;
cch_items_y = 0;
@@ -118,11 +111,12 @@ void CComponentsHeader::initVarHeader()
cch_icon_x = cch_offset;
cch_icon_w = 0;
cch_text_x = cch_offset;
cch_buttons = 0;
cch_buttons_w = 0;
cch_buttons_h = 0;
cch_buttons_space = cch_offset;
v_cch_btn.clear();
initDefaultButtons();
initCCItems();
}
CComponentsHeader::~CComponentsHeader()
@@ -145,13 +139,42 @@ void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int&
cch_caption_align = align_mode;
}
void CComponentsHeader::setCaptionFont(Font* font_name)
void CComponentsHeader::setCaptionFont(Font* font)
{
cch_font = font_name;
height = std::max(height, cch_font->getHeight());
initCaptionFont(font); //cch_font = font
}
void CComponentsHeader::initCaptionFont(Font* font)
{
Font *l_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
Font *s_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU];
if (font == NULL){
cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? l_font : s_font);
//select matching height
if (cch_size_mode == CC_HEADER_SIZE_LARGE)
height = std::max(height, l_font->getHeight());
else
height = std::min(height, s_font->getHeight());
}
else{
cch_font = font;
height = std::max(height, cch_font->getHeight());
}
}
void CComponentsHeader::setIcon(const char* icon_name)
{
if (icon_name){
string s_icon = static_cast<string>(icon_name);
setIcon(s_icon);
}
else
setIcon("");
}
void CComponentsHeader::setIcon(const std::string& icon_name)
{
cch_icon_name = icon_name;
}
@@ -159,18 +182,19 @@ void CComponentsHeader::setIcon(const char* icon_name)
void CComponentsHeader::initIcon()
{
//init cch_icon_obj only if an icon available
if (cch_icon_name == NULL) {
if (cch_icon_name.empty()) {
cch_icon_w = 0;
if (cch_icon_obj)
if (cch_icon_obj){
delete cch_icon_obj;
cch_icon_obj = NULL;
cch_icon_obj = NULL;
}
return;
}
//create instance for cch_icon_obj
if (cch_icon_obj == NULL){
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __func__, __LINE__, cch_icon_name);
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __func__, __LINE__, cch_icon_name.c_str());
#endif
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name);
}
@@ -179,12 +203,14 @@ void CComponentsHeader::initIcon()
if (!cch_icon_obj->isAdded())
addCCItem(cch_icon_obj); //icon
//get dimensions of header icon
int iw, ih;
frameBuffer->getIconSize(cch_icon_name, &iw, &ih);
//set properties for icon object
if (cch_icon_obj){
//get dimensions of header icon
int iw = 0;
int ih = 0;
cch_icon_obj->getPictureSize(&iw, &ih);
cch_icon_obj->setWidth(iw);
cch_icon_obj->setHeight(ih);
cch_icon_obj->doPaintBg(false);
@@ -318,7 +344,7 @@ void CComponentsHeader::initCaption()
{
//recalc header text position if header icon is defined
int cc_text_w = 0;
if (cch_icon_name != NULL){
if (!cch_icon_name.empty()){
cch_text_x = cch_icon_x+cch_icon_w+cch_offset;
}
@@ -365,11 +391,8 @@ void CComponentsHeader::initCaption()
void CComponentsHeader::initCCItems()
{
//set size
if (!userHeight) {
cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE] : g_Font[SNeutrinoSettings::FONT_TYPE_MENU]);
height = cch_font->getHeight();
}
initCaptionFont();
//init icon
initIcon();

View File

@@ -30,31 +30,122 @@
#include "cc_item_text.h"
#include "cc_frm_icons.h"
//! Sub class of CComponentsForm. Shows a header with prepared items.
/*!
CComponentsHeader provides prepared items like icon, caption and context button icons
*/
class CComponentsHeader : public CComponentsForm
{
private:
void initVarHeader();
protected:
CComponentsPicture * cch_icon_obj;
CComponentsText * cch_text_obj;
CComponentsIconForm * cch_btn_obj;
std::string cch_text;
const char* cch_icon_name;
fb_pixel_t cch_col_text;
Font* cch_font;
int cch_items_y, cch_icon_x, cch_icon_w, cch_text_x, cch_buttons, cch_buttons_w, cch_buttons_h, cch_buttons_space, cch_offset;
std::vector<std::string> v_cch_btn;
int cch_size_mode;
int cch_caption_align;
bool userHeight;
///member: init genaral variables, parameters for mostly used properties
void initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
const std::string& caption = "header",
const std::string& = "",
const int& buttons = 0,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
protected:
///object: icon object, see also setIcon()
CComponentsPicture * cch_icon_obj;
///object: caption object, see also setCaption()
CComponentsText * cch_text_obj;
///object: context button object, see also addButtonIcon(), removeButtonIcons()
CComponentsIconForm * cch_btn_obj;
///property: caption text, see also setCaption()
std::string cch_text;
///property: icon name, see also setIcon()
std::string cch_icon_name;
///property: caption text color, see also setCaptionColor()
fb_pixel_t cch_col_text;
///property: caption font, see also setCaptionFont()
Font* cch_font;
///property: internal y-position for all items
int cch_items_y;
///property: internal x-position for icon object
int cch_icon_x;
///property: internal width for icon object
int cch_icon_w;
///property: internal x-position for caption object
int cch_text_x;
///property: internal context button definition button icons, see modes CC_BTN_HELP, CC_BTN_INFO, CC_BTN_MENU, CC_BTN_EXIT
int cch_buttons;
///property: internal width for context button object
int cch_buttons_w;
///property: internal height for context button object
int cch_buttons_h;
///property: internal offset of context button icons within context button object
int cch_buttons_space;
///property: internal offset for header items
int cch_offset;
///property: internal container of icon names for context button object, see also addButtonIcon()
std::vector<std::string> v_cch_btn;
///property: size of header, possible values are CC_HEADER_SIZE_LARGE, CC_HEADER_SIZE_SMALL
int cch_size_mode;
///property: alignment of caption within header, see also setCaptionAlignment(), possible values are CTextBox::CENTER, default = CTextBox::NO_AUTO_LINEBREAK (left)
int cch_caption_align;
///init font object and recalculates height if required
void initCaptionFont(Font* font = NULL);
///sub: init icon object
void initIcon();
///sub: init caption object
void initCaption();
///sub: init context button object
void initButtons();
///sub: init default buttons for context button object
void initDefaultButtons();
///sub: init default buttons for context button object
void initButtonFormSize();
public:
enum
{
CC_HEADER_ITEM_ICON = 0,
CC_HEADER_ITEM_TEXT = 1,
CC_HEADER_ITEM_BUTTONS = 2
};
CComponentsHeader();
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
const std::string& caption = "",
const std::string& = "",
const int& buttons = 0,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual ~CComponentsHeader();
///set caption text, parameters: string, int align_mode (default left)
virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
///set caption text, parameters: loacle, int align_mode (default left)
virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
///set alignment of caption within header, possible paramters are CTextBox::CENTER, CTextBox::NO_AUTO_LINEBREAK
virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;};
///set text font object for caption
virtual void setCaptionFont(Font* font);
///set text color for caption
virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;};
///set offset between items
virtual void setOffset(const int offset){cch_offset = offset;};
///set name of icon
virtual void setIcon(const char* icon_name);
///set name of icon
virtual void setIcon(const std::string& icon_name);
///add separate button icons to context button object
virtual void addButtonIcon(const std::string& button_name);
///remove button icons from context button object
virtual void removeButtonIcons();
enum
{
CC_BTN_HELP = 0x02,
@@ -63,55 +154,68 @@ class CComponentsHeader : public CComponentsForm
CC_BTN_EXIT = 0x80
};
enum
{
CC_HEADER_ITEM_ICON = 0,
CC_HEADER_ITEM_TEXT = 1,
CC_HEADER_ITEM_BUTTONS = 2
};
///set internal context button icons, possible modes CC_BTN_HELP, CC_BTN_INFO, CC_BTN_MENU, CC_BTN_EXIT
virtual void setDefaultButtons(const int buttons);
///set offset between icons within context button object
virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;};
enum
{
CC_HEADER_SIZE_LARGE = 0,
CC_HEADER_SIZE_SMALL = 1
};
CComponentsHeader();
CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, const std::string& caption = "header", const char* icon_name = NULL, const int buttons = 0, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, const char* icon_name = NULL, const int buttons = 0,bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual ~CComponentsHeader();
///set size of header, possible values are CC_HEADER_SIZE_LARGE, CC_HEADER_SIZE_SMALL
virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode; initCCItems();};
virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;};
virtual void setCaptionFont(Font* font_name);
virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;};
virtual void setOffset(const int offset){cch_offset = offset;};
virtual void setIcon(const char* icon_name);
virtual void addButtonIcon(const std::string& button_name);
virtual void removeButtonIcons();
virtual void setDefaultButtons(const int buttons);
virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;};
///init all items within header object
virtual void initCCItems();
virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;};
///returns the text object
virtual CComponentsText* getTextObject(){return cch_text_obj;};
///paint header
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
//! Sub class of CComponentsHeader. Shows a header with prepared items.
/*!
CComponentsHeaderLocalized provides prepared items like icon, caption and context button icons
Caption is defined with locales.
*/
class CComponentsHeaderLocalized : public CComponentsHeader
{
public:
CComponentsHeaderLocalized( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
neutrino_locale_t caption_locale = NONEXISTANT_LOCALE,
const std::string& = "",
const int& buttons = 0,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
};
/*!
CComponentsFooter provides prepared container for footer
Is mostly usable like a header but without caption, and context button icons.
*/
class CComponentsFooter : public CComponentsHeader
{
protected:
void initVarFooter();
void initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
const int& buttons = 0,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
public:
CComponentsFooter();
CComponentsFooter( const int x_pos, const int y_pos, const int w, const int h = 0,
const int buttons = 0,
CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
const int& buttons = 0,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
};
#endif

View File

@@ -38,109 +38,81 @@ using namespace std;
CComponentsWindow::CComponentsWindow()
{
initVarWindow();
initCCWItems();
}
CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname)
{
initVarWindow();
ccw_caption = caption;
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname)
{
initVarWindow();
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t locale_caption,
const char* iconname,
const string& iconname,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
initVarWindow();
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
initCCWItems();
string s_caption = locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : "";
initVarWindow(x_pos, y_pos, w, h, s_caption, iconname, has_shadow, color_frame, color_body, color_shadow);
}
CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
const std::string& caption,
const char* iconname,
CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const string& caption,
const string& iconname,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
initVarWindow();
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccw_caption = caption;;
ccw_icon_name = iconname;
initCCWItems();
initVarWindow(x_pos, y_pos, w, h, caption, iconname, has_shadow, color_frame, color_body, color_shadow);
}
CComponentsWindow::~CComponentsWindow()
{
#ifdef DEBUG_CC
printf("[~CComponentsWindow] [%s - %d] delete...\n", __func__, __LINE__);
#endif
}
CComponentsWindowMax::CComponentsWindowMax(const string& caption, const string& iconname)
:CComponentsWindow(0, 0, 0, 0, caption, iconname){};
void CComponentsWindow::initVarWindow()
CComponentsWindowMax::CComponentsWindowMax(neutrino_locale_t locale_caption, const string& iconname)
:CComponentsWindow(0, 0, 0, 0, locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : "", iconname){};
void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const string& caption,
const string& iconname,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
//CComponentsForm
cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
//using current screen settings for default dimensions
width = frameBuffer->getScreenWidth();
height = frameBuffer->getScreenHeight();
x=getScreenStartX(width);
y=getScreenStartY(height);
//using current screen settings for default dimensions, do use full screen if default values for width/height = 0
int w_tmp = frameBuffer->getScreenWidth(w == 0 ? true : false);
int h_tmp = frameBuffer->getScreenHeight(h == 0 ? true : false);
width = w == 0 ? w_tmp : w;
height = h == 0 ? h_tmp : h;
x = x_pos;
y = y_pos;
ccw_caption = caption;
ccw_icon_name = iconname;
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] icon name = %s\n", __func__, __LINE__, ccw_icon_name.c_str());
#endif
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccw_head = NULL;
ccw_body = NULL;
ccw_footer = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
ccw_buttons = 0; //no header buttons
ccw_show_footer = true;
ccw_show_header = true;
ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK;
setShadowOnOff(true);
initCCWItems();
}
void CComponentsWindow::doCenter(){
x = cc_parent ? cc_parent->getWidth() - width/2 : frameBuffer->getScreenWidth(true)/2 - width/2;
y = cc_parent ? cc_parent->getHeight() - height/2 : frameBuffer->getScreenHeight(true)/2 -height/2;
}
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
@@ -151,31 +123,39 @@ void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const in
void CComponentsWindow::initHeader()
{
if (ccw_head == NULL){
if (ccw_head == NULL)
ccw_head = new CComponentsHeader();
initHeader();
//add of header item happens initCCWItems()
}
//add of header item happens initCCWItems()
//set header properties //TODO: assigned properties with internal header objekt have no effect!
if (ccw_head){
ccw_head->setWidth(width-2*fr_thickness);
// ccw_head->setPos(0, 0);
ccw_head->setIcon(ccw_icon_name);
ccw_head->setCaption(ccw_caption, ccw_align_mode);
ccw_head->initCCItems();
ccw_head->setDefaultButtons(ccw_buttons);
ccw_head->setCorner(corner_rad, CORNER_TOP);
}
}
void CComponentsWindow::initFooter()
{
if (ccw_footer== NULL)
ccw_footer= new CComponentsFooter();
//add of footer item happens initCCWItems()
//set footer properties
if (ccw_footer){
ccw_footer->setPos(0, CC_APPEND);
ccw_footer->setWidth(width-2*fr_thickness);
ccw_footer->setShadowOnOff(shadow);
ccw_footer->setCorner(corner_rad, CORNER_BOTTOM);
}
}
void CComponentsWindow::initBody()
{
if (ccw_body== NULL){
if (ccw_body== NULL)
ccw_body = new CComponentsForm();
initBody();
//add of body item happens initCCWItems()
}
//add of body item happens initCCWItems()
//set body properties
if (ccw_body){
ccw_body->setCornerType(0);
@@ -191,34 +171,16 @@ void CComponentsWindow::initBody()
}
}
void CComponentsWindow::initFooter()
{
if (ccw_footer== NULL){
ccw_footer= new CComponentsFooter();
initFooter();
//add of footer item happens initCCWItems()
}
//set footer properties
if (ccw_footer){
ccw_footer->setPos(0, CC_APPEND);
ccw_footer->setWidth(width-2*fr_thickness);
ccw_footer->setShadowOnOff(shadow);
}
}
void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item)
{
if (ccw_body)
ccw_body->addCCItem(cc_Item);
}
void CComponentsWindow::initCCWItems()
{
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] init items...\n", __func__, __LINE__);
#endif
//add header if required
initHeader();
initFooter();
initBody();
//add/remove header if required
if (ccw_show_header){
initHeader();
}else{
@@ -228,7 +190,7 @@ void CComponentsWindow::initCCWItems()
}
}
//add footer if required
//add/remove footer if required
if (ccw_show_footer){
initFooter();
}else{
@@ -237,7 +199,6 @@ void CComponentsWindow::initCCWItems()
ccw_footer = NULL;
}
}
initBody();
//add header, body and footer items only one time
if (ccw_head)
@@ -250,6 +211,13 @@ void CComponentsWindow::initCCWItems()
addCCItem(ccw_footer);
}
void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item)
{
if (ccw_body)
ccw_body->addCCItem(cc_Item);
}
void CComponentsWindow::paint(bool do_save_bg)
{
//prepare items before paint

View File

@@ -65,7 +65,7 @@ class CComponentsWindow : public CComponentsForm
///property: alignment mode for header caption
int ccw_align_mode;
///property: icon name in header, see also getHeaderObject()
const char* ccw_icon_name;
std::string ccw_icon_name;
///property: assigned default icon buttons in header, see also getHeaderObject()
int ccw_buttons;
///property: value = true, let show footer, see showFooter()
@@ -82,44 +82,42 @@ class CComponentsWindow : public CComponentsForm
///initialze all window objects at once
void initCCWItems();
///initialize all attributes
void initVarWindow();
void initVarWindow( const int& x_pos = CC_CENTERED, const int& y_pos = CC_CENTERED, const int& w = 0, const int& h = 0,
const std::string& caption = "",
const std::string& iconname = "",
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///allow centering of window on screen, mostly senseful for window object without parent
void doCenter();
public:
enum
{
CC_WINDOW_ITEM_HEADER = 0
};
///simple constructor for CComponentsWindow
///simple constructor for CComponentsWindow, this shows a window over full screen
CComponentsWindow();
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
const std::string& caption,
const char* iconname = NULL,
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string, x_pos or y_pos = 0 will center window
CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption = "",
const std::string& iconname = "",
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
neutrino_locale_t locale_caption,
const char* iconname = NULL,
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales, x_pos or y_pos = 0 will center window
CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t locale_text = NONEXISTANT_LOCALE,
const std::string& iconname = "",
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindow(const std::string& caption, const char* iconname = NULL);
///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname = NULL);
~CComponentsWindow();
///add item to body object, also usable is addCCItem() to add items to the windo object
void addWindowItem(CComponentsItem* cc_Item);
@@ -137,7 +135,7 @@ class CComponentsWindow : public CComponentsForm
void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;};
///set icon name in header, see also getHeaderObject()
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname;};
///set default header icon buttons, see also getHeaderObject()
void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;};
@@ -157,4 +155,16 @@ class CComponentsWindow : public CComponentsForm
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsWindowMax : public CComponentsWindow
{
public:
///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindowMax(const std::string& caption, const std::string& iconname = "");
///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindowMax(neutrino_locale_t locale_caption, const std::string& iconname = "");
};
#endif