From 171324fb95abeeb7a51093ff2584909b7aa6da95 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Jan 2014 21:10:42 +0100 Subject: [PATCH 01/24] dboxinfo: fix partition size display --- src/gui/dboxinfo.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index fdb1a7a87..4e8d292ee 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -4,14 +4,6 @@ Copyright (C) 2001 Steffen Hehn 'McClean' Homepage: http://dbox.cyberphoria.org/ - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - - License: GPL This program is free software; you can redistribute it and/or modify @@ -552,6 +544,7 @@ void CDBoxInfoWidget::paint() int rw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true); maxWidth[column] = std::max(maxWidth[column], rw); space = widths[column] - rw; + _w = rw; } if ((mpOffset + space + _w) > width) _w = width - (mpOffset + space); From 75e14b90e5b629d5a4f27c0eb56cad708ad0d394 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Jan 2014 18:53:23 +0100 Subject: [PATCH 02/24] dboxinfo: remove impossible case The kernel does (and has always) report memory in kib units, so there is no need to check this. --- src/gui/dboxinfo.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 4e8d292ee..973e8be2f 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -227,12 +227,8 @@ void CDBoxInfoWidget::paint() char buf[80], a[80]; long long unsigned v; while (fgets(buf, sizeof(buf), procmeminfo)) { - char unit[10]; - *unit = 0; - if ((3 == sscanf(buf, "%[^:]: %llu %s", a, &v, unit)) - || (2 == sscanf(buf, "%[^:]: %llu", a, &v))) { - if (*unit == 'k') - v <<= 10; + if (2 == sscanf(buf, "%[^:]: %llu", a, &v)) { + v <<= 10; if (!strcasecmp(a, "MemTotal")) memstat[MEMINFO_RAM][MEMINFO_TOTAL] += v; else if (!strcasecmp(a, "MemFree")) From 34a2d553854dd1ec4c04742512a67d215f2767b6 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Jan 2014 19:01:59 +0100 Subject: [PATCH 03/24] dboxinfo: avoid unnecessary 64bit math The kernel uses 'unsigned long' for those values anyway, so there is no need for 'long long' in userspace. --- src/gui/dboxinfo.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 973e8be2f..70abe36b1 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -220,15 +220,14 @@ void CDBoxInfoWidget::paint() #define MEMINFO_RAM 0 #define MEMINFO_SWAP 1 #define MEMINFO_ROWS 2 - unsigned long long memstat[MEMINFO_ROWS][MEMINFO_COLUMNS] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free + unsigned long memstat[MEMINFO_ROWS][MEMINFO_COLUMNS] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free const char *memtype[MEMINFO_ROWS] = { "RAM", "Swap" }; FILE *procmeminfo = fopen("/proc/meminfo", "r"); if (procmeminfo) { char buf[80], a[80]; - long long unsigned v; + unsigned long v; while (fgets(buf, sizeof(buf), procmeminfo)) { - if (2 == sscanf(buf, "%[^:]: %llu", a, &v)) { - v <<= 10; + if (2 == sscanf(buf, "%[^:]: %lu", a, &v)) { if (!strcasecmp(a, "MemTotal")) memstat[MEMINFO_RAM][MEMINFO_TOTAL] += v; else if (!strcasecmp(a, "MemFree")) @@ -453,13 +452,13 @@ void CDBoxInfoWidget::paint() tmp = memtype[row]; break; case 1: - tmp = bytes2string(memstat[row][MEMINFO_TOTAL]); + tmp = bytes2string(memstat[row][MEMINFO_TOTAL] << 10); break; case 2: - tmp = bytes2string(memstat[row][MEMINFO_USED]); + tmp = bytes2string(memstat[row][MEMINFO_USED] << 10); break; case 3: - tmp = bytes2string(memstat[row][MEMINFO_FREE]); + tmp = bytes2string(memstat[row][MEMINFO_FREE] << 10); break; case 4: tmp = to_string(memstat[row][MEMINFO_TOTAL] ? (memstat[row][MEMINFO_USED] * 100) / memstat[row][MEMINFO_TOTAL] : 0) + "%"; From 6a158066d066a169aa545c531e01d8e7643fd0fe Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 1 Jan 2014 14:42:42 +0100 Subject: [PATCH 04/24] fix sign --- src/gui/dboxinfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 70abe36b1..08bad63bb 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -294,9 +294,9 @@ void CDBoxInfoWidget::paint() int diff = frameBuffer->getScreenWidth() - width; if (diff < 0) { - width -= diff; - offsetw -= diff; - nameWidth -= diff; + width += diff; + offsetw += diff; + nameWidth += diff; } height = h_max(height, 0); x = getScreenStartX(width); From 88392567938a0c7e0045c8a8e7583279a7d04480 Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 6 Jan 2014 13:23:39 +0100 Subject: [PATCH 05/24] gui/dboxinfo: fix bytes2string() --- src/gui/dboxinfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 08bad63bb..b7d90ca5a 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -181,10 +181,10 @@ static std::string bytes2string(uint64_t bytes, bool binary) char result[80]; if (b < base) - snprintf(result, sizeof(result), "%d%s%02d ", (int)b, g_Locale->getText(LOCALE_UNIT_DECIMAL), - (int)((bytes - b * factor) * 100 / factor)); + snprintf(result, sizeof(result), "%llu%s%02llu ", b, g_Locale->getText(LOCALE_UNIT_DECIMAL), + (bytes - b * factor) * 100 / factor); else // no need for fractions for larger numbers - snprintf(result, sizeof(result), "%d ", (int)bytes); + snprintf(result, sizeof(result), "%llu ", b); std::string res(result); if (*unit) { From a0a4cc1355ff6837d91c3cd8508b4cc65bf954ce Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Jan 2014 00:58:02 +0100 Subject: [PATCH 06/24] CComponentsForm: avoid of height or width error due to odd values Some calculations can resulting odd values and can provocate unnecessary debug spam, but more lines should be repaired. --- src/gui/components/cc_frm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index bfa2839ae..4a474bbb3 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -355,6 +355,9 @@ void CComponentsForm::paintCCItems() int right_item = cc_item->getRealXPos() + w_item; int w_diff = right_item - right_frm; int new_w = w_item - w_diff; + //avoid of width error due to odd values (1 line only) + right_item -= (new_w%2); + w_item -= (new_w%2); if (right_item > right_frm){ printf("[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] width is too large, definied width=%d, possible width=%d \n", __func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), w_item, new_w); @@ -366,6 +369,9 @@ void CComponentsForm::paintCCItems() int bottom_item = cc_item->getRealYPos() + h_item; int h_diff = bottom_item - bottom_frm; int new_h = h_item - h_diff; + //avoid of height error due to odd values (1 line only) + bottom_item -= (new_h%2); + h_item -= (new_h%2); if (bottom_item > bottom_frm){ printf("[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] height is too large, definied height=%d, possible height=%d \n", __func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), h_item, new_h); From a08a418d886d0fa694af7599c769baf5ef6e92b1 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Jan 2014 00:59:04 +0100 Subject: [PATCH 07/24] CComponentsExtTextForm: use inherited class for localized version Removed simple constructor and used default values in constructor has same effect, this reduces some code parts. Usage is unchanged. --- src/gui/components/cc_frm.h | 38 ++++++++++++----------- src/gui/components/cc_frm_ext_text.cpp | 43 ++++++++++---------------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 183ca728f..b82816dd6 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -364,27 +364,17 @@ class CComponentsExtTextForm : public CComponentsForm protected: ///initialize basic variables - void initVarExtTextForm(const int x_pos = 1, const int y_pos = 1, const int w = 300, const int h = 27, - bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, - fb_pixel_t text_color = COL_MENUCONTENT_TEXT, - 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); + void initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& label_text, const std::string& text, + bool has_shadow, + fb_pixel_t label_color, + fb_pixel_t text_color, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow); public: - ///simple constructor for CComponentsExtTextForm - CComponentsExtTextForm(); - ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string - CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, - const std::string& label_text, const std::string& text, - bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, - fb_pixel_t text_color = COL_MENUCONTENT_TEXT, - 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 CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales - CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, - const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, + CComponentsExtTextForm( const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, + const std::string& label_text = "", const std::string& text = "", bool has_shadow = CC_SHADOW_OFF, fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, fb_pixel_t text_color = COL_MENUCONTENT_TEXT, @@ -421,4 +411,16 @@ class CComponentsExtTextForm : public CComponentsForm void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; +class CComponentsExtTextFormLocalized : public CComponentsExtTextForm +{ + public: + ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales + CComponentsExtTextFormLocalized(const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, + const neutrino_locale_t& locale_label_text = NONEXISTANT_LOCALE, const neutrino_locale_t& locale_text = NONEXISTANT_LOCALE, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, + fb_pixel_t text_color = COL_MENUCONTENT_TEXT, + 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); +}; + #endif diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index d44c940d0..197dc5c49 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -34,44 +34,33 @@ #define DEF_HEIGHT 27 #define DEF_LABEL_WIDTH_PERCENT 30 -#define DEF_WIDTH 300 using namespace std; -CComponentsExtTextForm::CComponentsExtTextForm() -{ - initVarExtTextForm(); - initCCTextItems(); -} - -CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, +CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& label_text, const std::string& text, bool has_shadow, fb_pixel_t label_color, fb_pixel_t text_color, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); - ccx_label_text = label_text; - ccx_text = text; + initVarExtTextForm(x_pos, y_pos, w, h, label_text, text, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); initCCTextItems(); } -CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, - const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, - bool has_shadow, - fb_pixel_t label_color, - fb_pixel_t text_color, - fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) -{ - initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); - ccx_label_text = g_Locale->getText(locale_label_text); - ccx_text = g_Locale->getText(locale_text); +CComponentsExtTextFormLocalized::CComponentsExtTextFormLocalized(const int& x_pos, const int& y_pos, const int& w, const int& h, + const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, + bool has_shadow, + fb_pixel_t label_color, + fb_pixel_t text_color, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) + : CComponentsExtTextForm( x_pos, y_pos, w, h, + g_Locale->getText(locale_label_text), g_Locale->getText(locale_text), + has_shadow, + label_color, text_color, color_frame, color_body, color_shadow){}; - initCCTextItems(); -} - -void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos, const int w, const int h, +void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& label_text, const std::string& text, bool has_shadow, fb_pixel_t label_color, fb_pixel_t text_color, @@ -90,8 +79,8 @@ void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos height = h; - ccx_label_text = ""; - ccx_text = ""; + ccx_label_text = label_text; + ccx_text = text; shadow = has_shadow; ccx_label_color = label_color; ccx_text_color = text_color; From d2991b49c865100491eccbb21957903542d0f4cc Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Jan 2014 14:04:26 +0100 Subject: [PATCH 08/24] CComponentsForm: update license text --- src/gui/components/cc_frm.cpp | 8 +++----- src/gui/components/cc_frm.h | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 4a474bbb3..10296634b 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, 2013, 2014 Thilo Graf 'dbt' Copyright (C) 2012, Michael Liebmann 'micha-bbg' License: GPL @@ -18,10 +18,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 . */ #ifdef HAVE_CONFIG_H diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index b82816dd6..f769e5c8a 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, 2013, 2014, Thilo Graf 'dbt' License: GPL @@ -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 . */ #ifndef __CC_FORM_H__ From 04574fc6ebdac2ff3693fbbd8ad3e3d3d817bcc1 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Jan 2014 22:27:59 +0100 Subject: [PATCH 09/24] CComponents: split some header files Should bring more overview and less susceptibility to conflicts (merge etc) License texts updated. --- src/gui/components/cc.h | 5 +- src/gui/components/cc_frm.h | 354 ------------------------- src/gui/components/cc_frm_ext_text.cpp | 11 +- src/gui/components/cc_frm_ext_text.h | 128 +++++++++ src/gui/components/cc_frm_header.cpp | 12 +- src/gui/components/cc_frm_header.h | 117 ++++++++ src/gui/components/cc_frm_icons.cpp | 10 +- src/gui/components/cc_frm_icons.h | 67 +++++ src/gui/components/cc_frm_window.cpp | 16 +- src/gui/components/cc_frm_window.h | 160 +++++++++++ 10 files changed, 496 insertions(+), 384 deletions(-) create mode 100644 src/gui/components/cc_frm_ext_text.h create mode 100644 src/gui/components/cc_frm_header.h create mode 100644 src/gui/components/cc_frm_icons.h create mode 100644 src/gui/components/cc_frm_window.h diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 54e612954..3383752ec 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -46,9 +46,12 @@ Basic attributes and member functions for component sub classes #include "cc_frm_button.h" #include "cc_frm_chain.h" #include "cc_frm_clock.h" +#include "cc_frm_ext_text.h" +#include "cc_frm_header.h" +#include "cc_frm_icons.h" #include "cc_frm_signalbars.h" #include "cc_frm_slider.h" - +#include "cc_frm_window.h" #endif /*__N_COMPONENTS__*/ diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index f769e5c8a..8f9fbabef 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -27,10 +27,6 @@ #include "config.h" #include -#include -#include -#include -#include class CComponentsForm : public CComponentsItem @@ -71,354 +67,4 @@ class CComponentsForm : public CComponentsItem virtual void setAppendOffset(const int &h_offset, const int& v_offset){append_h_offset = h_offset; append_v_offset = v_offset;}; }; -class CComponentsIconForm : public CComponentsForm -{ - private: - std::vector v_icons; - int ccif_offset, ccif_icon_align; - void initMaxHeight(int *pheight); - - protected: - void initVarIconForm(); - - public: - CComponentsIconForm(); - CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector &v_icon_names, 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); -// ~CComponentsIconForm(); //inherited from CComponentsForm - - void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); - void initCCIcons(); - void addIcon(const std::string& icon_name); - void addIcon(std::vector icon_name); - void removeIcons(){v_icons.clear();}; - void insertIcon(const uint& icon_id, const std::string& icon_name); - void removeIcon(const uint& icon_id); - void removeIcon(const std::string& icon_name); - void removeAllIcons(); - void setIconOffset(const int offset){ccif_offset = offset;}; - - enum //alignements - { - CC_ICONS_FRM_ALIGN_RIGHT , - CC_ICONS_FRM_ALIGN_LEFT - }; - void setIconAlign(int alignment){ccif_icon_align = alignment;}; - - int getIconId(const std::string& icon_name); -}; - - - -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 v_cch_btn; - int cch_size_mode; - int cch_caption_align; - bool userHeight; - - void initIcon(); - void initCaption(); - void initButtons(); - void initDefaultButtons(); - void initButtonFormSize(); - - public: - enum - { - CC_BTN_HELP = 0x02, - CC_BTN_INFO = 0x04, - CC_BTN_MENU = 0x40, - CC_BTN_EXIT = 0x80 - - }; - - enum - { - CC_HEADER_ITEM_ICON = 0, - CC_HEADER_ITEM_TEXT = 1, - CC_HEADER_ITEM_BUTTONS = 2 - }; - - 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(); - - - 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;}; - virtual void initCCItems(); - virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;}; - virtual CComponentsText* getTextObject(){return cch_text_obj;}; - virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); -}; - - -class CComponentsFooter : public CComponentsHeader -{ - protected: - void initVarFooter(); - public: - CComponentsFooter(); - 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); -}; - -//! Sub class of CComponentsForm. Shows a window with prepared items. -/*! -CComponentsWindow provides prepared items like header, footer and a container for -items like text, labels, pictures ... -*/ -/* - x - y+-------------------------------------------------------+ - |icon caption buttons |header (ccw_head) - +-x-----------------------------------------------------+ - |cc_item0 | - |cc_item1 |body (ccw_body) - | add items here directly with | - | addWindowItem() or | - y with ccw_body->addCCItem() | - | Note: x/y related to body object | - | | - +-------------------------------------------------------+ - | add cc_items with ccw_footer->addCCItem() |footer(ccw_footer) - +-------------------------------------------------------+ - -*/ - -class CComponentsWindow : public CComponentsForm -{ - protected: - ///object: header object, to get access to header properties see also getHeaderObject() - CComponentsHeader * ccw_head; - ///object: body object, this is the container for all needed items, to add with addWindowItem() - CComponentsForm * ccw_body; - ///object: footer object, to get access to header properties see also getFooterObject( - CComponentsFooter * ccw_footer; - ///property: caption in header, see also getHeaderObject() - std::string ccw_caption; - ///property: alignment mode for header caption - int ccw_align_mode; - ///property: icon name in header, see also getHeaderObject() - const char* ccw_icon_name; - ///property: assigned default icon buttons in header, see also getHeaderObject() - int ccw_buttons; - ///property: value = true, let show footer, see showFooter() - bool ccw_show_footer; - ///property: value = true, let show header, see showHeader() - bool ccw_show_header; - - ///initialze header object - void initHeader(); - ///initialze body object - void initBody(); - ///initialze footer object - void initFooter(); - ///initialze all window objects at once - void initCCWItems(); - ///initialize all attributes - void initVarWindow(); - - public: - enum - { - CC_WINDOW_ITEM_HEADER = 0 - }; - ///simple constructor for CComponentsWindow - 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, - 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, - 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); - - ///allow/disallow paint a footer, default true, see also ccw_show_footer, showHeader() - void showFooter(bool show = true){ccw_show_footer = show; initCCWItems();}; - ///allow/disallow paint a header, default true, see also ccw_show_header, showFooter() - void showHeader(bool show = true){ccw_show_header = show; initCCWItems();}; - - ///set caption in header with string, see also getHeaderObject() - void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;}; - - ///set caption in header from locales, see also getHeaderObject() - void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); - ///set caption alignment - 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;}; - - ///set default header icon buttons, see also getHeaderObject() - void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;}; - - ///returns a pointer to the internal header object, use this to get access to header properities - CComponentsHeader* getHeaderObject(){return ccw_head;}; - - ///returns a pointer to the internal body object, use this to get access to body properities - CComponentsForm* getBodyObject(){return ccw_body;}; - ///returns a pointer to the internal footer object, use this to get access to footer properities - CComponentsFooter* getFooterObject(){return ccw_footer;}; - - ///refresh position and dimension and reinitialize elemenatary properties - void Refresh(){initCCWItems();}; - - ///paint all window items, this overwriting paint() from CComponentsForm - virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); -}; - - -class CComponentsExtTextForm : public CComponentsForm -{ - private: - ///property: content of label, see also setLabelAndText() - std::string ccx_label_text; - ///property: content of text, see also setLabelAndText() - std::string ccx_text; - ///property: color of label text, see also setLabelAndTextColor() - fb_pixel_t ccx_label_color; - ///property: color of text, see also setLabelAndTextColor() - fb_pixel_t ccx_text_color; - ///property: mode of label text, see also setTextModes() - int ccx_label_align; - ///property: mode of text, see also setTextModes() - int ccx_text_align; - ///property: width of label, see also setLabelWidthPercent() - int ccx_label_width; - ///property: width of text, see also setLabelWidthPercent() - int ccx_text_width; - ///property: font type of both items (label and text), see also setLabelAndText() - Font* ccx_font; - ///property: percentage val of label width related to full width, causes fit of text automatically into the available remaining size of item, see also setLabelWidthPercent() - uint8_t ccx_percent_label_w; - - ///object: label object - CComponentsLabel *ccx_label_obj; - ///object: text object - CComponentsText *ccx_text_obj; - - ///initialize of properties for all objects - void initCCTextItems(); - ///initialize the label object - void initLabel(); - ///initialize the text object - void initText(); - - protected: - ///initialize basic variables - void initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h, - const std::string& label_text, const std::string& text, - bool has_shadow, - fb_pixel_t label_color, - fb_pixel_t text_color, - fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow); - - public: - ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string - CComponentsExtTextForm( const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, - const std::string& label_text = "", const std::string& text = "", - bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, - fb_pixel_t text_color = COL_MENUCONTENT_TEXT, - 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); -// ~CComponentsExtTextForm(); //inherited from CComponentsForm - - ///assigns texts for label and text, parameter as string, parameter Font is optional for required font type, default font is dependently from defined item height - void setLabelAndText(const std::string& label_text, const std::string& text, Font* font_text = NULL); - ///assigns texts for label and text, parameter as neutrino_locale_t, parameter Font is optional for required font type, default font is dependently from defined item height - void setLabelAndText(const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, Font* font_text = NULL); - ///assigns text Font type - void setLabelAndTextFont(Font* font); - - ///assigns texts for label and text, parameter as struct (locale_ext_txt_t), parameters provide the same properties like setLabelAndText() - void setLabelAndTexts(const locale_ext_txt_t& texts); - ///assigns texts for label and text, parameter as struct (string_ext_txt_t), parameters provide the same properties like setLabelAndText() - void setLabelAndTexts(const string_ext_txt_t& locale_texts); - - ///assigns colors for text for label text, parameter as fb_pixel_t - void setLabelAndTextColor(const fb_pixel_t label_color , const fb_pixel_t text_color); - - ///assigns width of label and text related to width, parameter as uint8_t in percent of width, fits text automatically into the available remaining size of item - void setLabelWidthPercent(const uint8_t& percent_val); - - ///returns a pointer to the internal label object, use this to get access to its most properties - CComponentsLabel*getLabelObject(){return ccx_label_obj;}; - ///returns a pointer to the internal text object, use this to get access to its most properties - CComponentsText*getTextObject(){return ccx_text_obj;}; - - ///sets the text modes (mainly text alignment) to the label and text object, see /gui/widget/textbox.h for possible modes - void setTextModes(const int& label_mode, const int& text_mode); - - ///paint this item/form - void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); -}; - -class CComponentsExtTextFormLocalized : public CComponentsExtTextForm -{ - public: - ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales - CComponentsExtTextFormLocalized(const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, - const neutrino_locale_t& locale_label_text = NONEXISTANT_LOCALE, const neutrino_locale_t& locale_text = NONEXISTANT_LOCALE, - bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, - fb_pixel_t text_color = COL_MENUCONTENT_TEXT, - 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); -}; - #endif diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 197dc5c49..05196bd78 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013, 2014 Thilo Graf 'dbt' License: GPL @@ -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 . */ #ifdef HAVE_CONFIG_H @@ -29,8 +27,7 @@ #include #include - -#include "cc_frm.h" +#include "cc_frm_ext_text.h" #define DEF_HEIGHT 27 #define DEF_LABEL_WIDTH_PERCENT 30 diff --git a/src/gui/components/cc_frm_ext_text.h b/src/gui/components/cc_frm_ext_text.h new file mode 100644 index 000000000..59a837b97 --- /dev/null +++ b/src/gui/components/cc_frm_ext_text.h @@ -0,0 +1,128 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2013, 2014, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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, see . +*/ + +#ifndef __CC_FORM_EXT_TEXT_H__ +#define __CC_FORM_EXT_TEXT_H__ + +#include "cc_frm.h" +#include "cc_item_text.h" + + +class CComponentsExtTextForm : public CComponentsForm +{ + private: + ///property: content of label, see also setLabelAndText() + std::string ccx_label_text; + ///property: content of text, see also setLabelAndText() + std::string ccx_text; + ///property: color of label text, see also setLabelAndTextColor() + fb_pixel_t ccx_label_color; + ///property: color of text, see also setLabelAndTextColor() + fb_pixel_t ccx_text_color; + ///property: mode of label text, see also setTextModes() + int ccx_label_align; + ///property: mode of text, see also setTextModes() + int ccx_text_align; + ///property: width of label, see also setLabelWidthPercent() + int ccx_label_width; + ///property: width of text, see also setLabelWidthPercent() + int ccx_text_width; + ///property: font type of both items (label and text), see also setLabelAndText() + Font* ccx_font; + ///property: percentage val of label width related to full width, causes fit of text automatically into the available remaining size of item, see also setLabelWidthPercent() + uint8_t ccx_percent_label_w; + + ///object: label object + CComponentsLabel *ccx_label_obj; + ///object: text object + CComponentsText *ccx_text_obj; + + ///initialize of properties for all objects + void initCCTextItems(); + ///initialize the label object + void initLabel(); + ///initialize the text object + void initText(); + + protected: + ///initialize basic variables + void initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& label_text, const std::string& text, + bool has_shadow, + fb_pixel_t label_color, + fb_pixel_t text_color, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow); + + public: + ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string + CComponentsExtTextForm( const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, + const std::string& label_text = "", const std::string& text = "", + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, + fb_pixel_t text_color = COL_MENUCONTENT_TEXT, + 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); +// ~CComponentsExtTextForm(); //inherited from CComponentsForm + + ///assigns texts for label and text, parameter as string, parameter Font is optional for required font type, default font is dependently from defined item height + void setLabelAndText(const std::string& label_text, const std::string& text, Font* font_text = NULL); + ///assigns texts for label and text, parameter as neutrino_locale_t, parameter Font is optional for required font type, default font is dependently from defined item height + void setLabelAndText(const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, Font* font_text = NULL); + ///assigns text Font type + void setLabelAndTextFont(Font* font); + + ///assigns texts for label and text, parameter as struct (locale_ext_txt_t), parameters provide the same properties like setLabelAndText() + void setLabelAndTexts(const locale_ext_txt_t& texts); + ///assigns texts for label and text, parameter as struct (string_ext_txt_t), parameters provide the same properties like setLabelAndText() + void setLabelAndTexts(const string_ext_txt_t& locale_texts); + + ///assigns colors for text for label text, parameter as fb_pixel_t + void setLabelAndTextColor(const fb_pixel_t label_color , const fb_pixel_t text_color); + + ///assigns width of label and text related to width, parameter as uint8_t in percent of width, fits text automatically into the available remaining size of item + void setLabelWidthPercent(const uint8_t& percent_val); + + ///returns a pointer to the internal label object, use this to get access to its most properties + CComponentsLabel*getLabelObject(){return ccx_label_obj;}; + ///returns a pointer to the internal text object, use this to get access to its most properties + CComponentsText*getTextObject(){return ccx_text_obj;}; + + ///sets the text modes (mainly text alignment) to the label and text object, see /gui/widget/textbox.h for possible modes + void setTextModes(const int& label_mode, const int& text_mode); + + ///paint this item/form + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +class CComponentsExtTextFormLocalized : public CComponentsExtTextForm +{ + public: + ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales + CComponentsExtTextFormLocalized(const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, + const neutrino_locale_t& locale_label_text = NONEXISTANT_LOCALE, const neutrino_locale_t& locale_text = NONEXISTANT_LOCALE, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, + fb_pixel_t text_color = COL_MENUCONTENT_TEXT, + 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); +}; + +#endif diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 0270fe618..d1f14e5fd 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -1,9 +1,9 @@ /* - Based up Neutrino-GUI - Tuxbox-Project + Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, 2013, 2014 Thilo Graf 'dbt' Copyright (C) 2012, Michael Liebmann 'micha-bbg' License: GPL @@ -18,10 +18,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 . */ #ifdef HAVE_CONFIG_H @@ -30,7 +28,7 @@ #include #include -#include "cc_frm.h" +#include "cc_frm_header.h" using namespace std; diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h new file mode 100644 index 000000000..d681b57b5 --- /dev/null +++ b/src/gui/components/cc_frm_header.h @@ -0,0 +1,117 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, 2014, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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, see . +*/ + +#ifndef __CC_FORM_HEADER_H__ +#define __CC_FORM_HEADER_H__ + + +#include "cc_frm.h" +#include "cc_item_picture.h" +#include "cc_item_text.h" +#include "cc_frm_icons.h" + +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 v_cch_btn; + int cch_size_mode; + int cch_caption_align; + bool userHeight; + + void initIcon(); + void initCaption(); + void initButtons(); + void initDefaultButtons(); + void initButtonFormSize(); + + public: + enum + { + CC_BTN_HELP = 0x02, + CC_BTN_INFO = 0x04, + CC_BTN_MENU = 0x40, + CC_BTN_EXIT = 0x80 + + }; + + enum + { + CC_HEADER_ITEM_ICON = 0, + CC_HEADER_ITEM_TEXT = 1, + CC_HEADER_ITEM_BUTTONS = 2 + }; + + 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(); + + + 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;}; + virtual void initCCItems(); + virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;}; + virtual CComponentsText* getTextObject(){return cch_text_obj;}; + virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + + +class CComponentsFooter : public CComponentsHeader +{ + protected: + void initVarFooter(); + public: + CComponentsFooter(); + 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); +}; + +#endif diff --git a/src/gui/components/cc_frm_icons.cpp b/src/gui/components/cc_frm_icons.cpp index 4bb19468a..e83707320 100644 --- a/src/gui/components/cc_frm_icons.cpp +++ b/src/gui/components/cc_frm_icons.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, 2013, 2014 Thilo Graf 'dbt' Copyright (C) 2012, Michael Liebmann 'micha-bbg' License: GPL @@ -18,10 +18,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 . */ #ifdef HAVE_CONFIG_H @@ -30,7 +28,7 @@ #include #include -#include "cc_frm.h" +#include "cc_frm_icons.h" using namespace std; diff --git a/src/gui/components/cc_frm_icons.h b/src/gui/components/cc_frm_icons.h new file mode 100644 index 000000000..c33755719 --- /dev/null +++ b/src/gui/components/cc_frm_icons.h @@ -0,0 +1,67 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, 2014, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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, see . +*/ + +#ifndef __CC_FORM_ICONS_H__ +#define __CC_FORM_ICONS_H__ + +#include "cc_frm.h" +#include "cc_frm_icons.h" + +class CComponentsIconForm : public CComponentsForm +{ + private: + std::vector v_icons; + int ccif_offset, ccif_icon_align; + void initMaxHeight(int *pheight); + + protected: + void initVarIconForm(); + + public: + CComponentsIconForm(); + CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector &v_icon_names, 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); +// ~CComponentsIconForm(); //inherited from CComponentsForm + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void initCCIcons(); + void addIcon(const std::string& icon_name); + void addIcon(std::vector icon_name); + void removeIcons(){v_icons.clear();}; + void insertIcon(const uint& icon_id, const std::string& icon_name); + void removeIcon(const uint& icon_id); + void removeIcon(const std::string& icon_name); + void removeAllIcons(); + void setIconOffset(const int offset){ccif_offset = offset;}; + + enum //alignements + { + CC_ICONS_FRM_ALIGN_RIGHT , + CC_ICONS_FRM_ALIGN_LEFT + }; + void setIconAlign(int alignment){ccif_icon_align = alignment;}; + + int getIconId(const std::string& icon_name); +}; + +#endif diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index fd24999cf..8bd6e4c74 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -1,9 +1,9 @@ /* - Based up Neutrino-GUI - Tuxbox-Project + Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, 2013, 2014 Thilo Graf 'dbt' Copyright (C) 2012, Michael Liebmann 'micha-bbg' License: GPL @@ -18,10 +18,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 . */ #ifdef HAVE_CONFIG_H @@ -30,7 +28,7 @@ #include #include -#include "cc_frm.h" +#include "cc_frm_window.h" #include using namespace std; @@ -47,7 +45,7 @@ CComponentsWindow::CComponentsWindow() CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname) { initVarWindow(); - + ccw_caption = caption; ccw_icon_name = iconname; @@ -57,7 +55,7 @@ CComponentsWindow::CComponentsWindow(const std::string& caption, const char* ico CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname) { initVarWindow(); - + ccw_caption = g_Locale->getText(locale_caption); ccw_icon_name = iconname; diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h new file mode 100644 index 000000000..80e7e49f3 --- /dev/null +++ b/src/gui/components/cc_frm_window.h @@ -0,0 +1,160 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, 2014, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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, see . +*/ + +#ifndef __CC_FORM_WINDOW_H__ +#define __CC_FORM_WINDOW_H__ + +#include "cc_frm.h" +#include "cc_frm_icons.h" +#include "cc_frm_header.h" + +//! Sub class of CComponentsForm. Shows a window with prepared items. +/*! +CComponentsWindow provides prepared items like header, footer and a container for +items like text, labels, pictures ... +*/ +/* + x + y+-------------------------------------------------------+ + |icon caption buttons |header (ccw_head) + +-x-----------------------------------------------------+ + |cc_item0 | + |cc_item1 |body (ccw_body) + | add items here directly with | + | addWindowItem() or | + y with ccw_body->addCCItem() | + | Note: x/y related to body object | + | | + +-------------------------------------------------------+ + | add cc_items with ccw_footer->addCCItem() |footer(ccw_footer) + +-------------------------------------------------------+ + +*/ + +class CComponentsWindow : public CComponentsForm +{ + protected: + ///object: header object, to get access to header properties see also getHeaderObject() + CComponentsHeader * ccw_head; + ///object: body object, this is the container for all needed items, to add with addWindowItem() + CComponentsForm * ccw_body; + ///object: footer object, to get access to header properties see also getFooterObject( + CComponentsFooter * ccw_footer; + ///property: caption in header, see also getHeaderObject() + std::string ccw_caption; + ///property: alignment mode for header caption + int ccw_align_mode; + ///property: icon name in header, see also getHeaderObject() + const char* ccw_icon_name; + ///property: assigned default icon buttons in header, see also getHeaderObject() + int ccw_buttons; + ///property: value = true, let show footer, see showFooter() + bool ccw_show_footer; + ///property: value = true, let show header, see showHeader() + bool ccw_show_header; + + ///initialze header object + void initHeader(); + ///initialze body object + void initBody(); + ///initialze footer object + void initFooter(); + ///initialze all window objects at once + void initCCWItems(); + ///initialize all attributes + void initVarWindow(); + + public: + enum + { + CC_WINDOW_ITEM_HEADER = 0 + }; + ///simple constructor for CComponentsWindow + 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, + 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, + 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); + + ///allow/disallow paint a footer, default true, see also ccw_show_footer, showHeader() + void showFooter(bool show = true){ccw_show_footer = show; initCCWItems();}; + ///allow/disallow paint a header, default true, see also ccw_show_header, showFooter() + void showHeader(bool show = true){ccw_show_header = show; initCCWItems();}; + + ///set caption in header with string, see also getHeaderObject() + void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;}; + + ///set caption in header from locales, see also getHeaderObject() + void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); + ///set caption alignment + 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;}; + + ///set default header icon buttons, see also getHeaderObject() + void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;}; + + ///returns a pointer to the internal header object, use this to get access to header properities + CComponentsHeader* getHeaderObject(){return ccw_head;}; + + ///returns a pointer to the internal body object, use this to get access to body properities + CComponentsForm* getBodyObject(){return ccw_body;}; + ///returns a pointer to the internal footer object, use this to get access to footer properities + CComponentsFooter* getFooterObject(){return ccw_footer;}; + + ///refresh position and dimension and reinitialize elemenatary properties + void Refresh(){initCCWItems();}; + + ///paint all window items, this overwriting paint() from CComponentsForm + virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +#endif From ed7a2fd625723a1232ead22826f07d2760124315 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 7 Jan 2014 09:41:06 +0100 Subject: [PATCH 10/24] CComponents: replace clear() with clearFbData(), remove cleanCCForm() clear() replaces now clearCCItems() and cleanCCForm() is superfluous. --- src/gui/components/cc_base.cpp | 8 ++++---- src/gui/components/cc_base.h | 2 +- src/gui/components/cc_detailsline.cpp | 2 +- src/gui/components/cc_frm.cpp | 14 ++------------ src/gui/components/cc_frm.h | 6 +++--- src/gui/components/cc_frm_clock.cpp | 2 +- src/gui/components/cc_frm_icons.cpp | 2 +- src/gui/components/cc_item.cpp | 2 +- 8 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index 4684ceb28..8b30596b9 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -44,7 +44,7 @@ CComponents::~CComponents() { hide(); clearSavedScreen(); - clear(); + clearFbData(); } void CComponents::clearSavedScreen() @@ -196,7 +196,7 @@ inline void CComponents::hide() } } - clear(); + clearFbData(); is_painted = false; } @@ -205,13 +205,13 @@ void CComponents::kill() { for(size_t i =0; i< v_fbdata.size() ;i++) frameBuffer->paintBackgroundBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy); - clear(); + clearFbData(); firstPaint = true; is_painted = false; } //clean old screen buffer -inline void CComponents::clear() +inline void CComponents::clearFbData() { for(size_t i =0; i< v_fbdata.size() ;i++) if (v_fbdata[i].pixbuf) diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index bf2eeb5cd..37c38a71f 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -105,7 +105,7 @@ class CComponents void paintFbItems(bool do_save_bg = true); ///clean up old screen buffer saved in v_fbdata - virtual void clear(); + virtual void clearFbData(); ///container: contains saved pixel buffer with position and dimensions comp_screen_data_t saved_screen; diff --git a/src/gui/components/cc_detailsline.cpp b/src/gui/components/cc_detailsline.cpp index 8eab8b047..6a032d454 100644 --- a/src/gui/components/cc_detailsline.cpp +++ b/src/gui/components/cc_detailsline.cpp @@ -85,7 +85,7 @@ CComponentsDetailLine::~CComponentsDetailLine() //paint details line with current parameters void CComponentsDetailLine::paint(bool do_save_bg) { - clear(); + clearFbData(); int y_mark_top = y-h_mark_top/2+thickness/2; int y_mark_down = y_down-h_mark_down/2+thickness/2; diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 10296634b..7ae3f9490 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -64,21 +64,11 @@ CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, CComponentsForm::~CComponentsForm() { - cleanCCForm(); -} - -void CComponentsForm::cleanCCForm() -{ -#ifdef DEBUG_CC - printf("[CComponentsForm] [%s - %d] clean up...\n", __func__, __LINE__); -#endif - - clearCCItems(); + clear(); } - -void CComponentsForm::clearCCItems() +void CComponentsForm::clear() { if (v_cc_items.empty()) return; diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 8f9fbabef..7e37a6698 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -34,7 +34,7 @@ class CComponentsForm : public CComponentsItem private: void initVarForm(); protected: - std::vector v_cc_items; + std::vector v_cc_items; void paintForm(bool do_save_bg); ///generates next possible index for an item, see also cc_item_index, getIndex(), setIndex() int genIndex(); @@ -62,8 +62,8 @@ class CComponentsForm : public CComponentsItem virtual int getCCItemId(CComponentsItem* cc_Item); virtual CComponentsItem* getCCItem(const uint& cc_item_id); virtual void paintCCItems(); - virtual void clearCCItems(); - virtual void cleanCCForm(); + ///clean up and deallocate existant items from v_cc_items at once + virtual void clear(); virtual void setAppendOffset(const int &h_offset, const int& v_offset){append_h_offset = h_offset; append_v_offset = v_offset;}; }; diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 6802476d3..b921ee47b 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -135,7 +135,7 @@ void CComponentsFrmClock::initCCLockItems() if (v_cc_items.size() != s_time.size()){ //clean up possible old items before add new items - clearCCItems(); + clear(); //create new empty label objects, set some general properties and add to container for (size_t i = 0; i < s_time.size(); i++){ diff --git a/src/gui/components/cc_frm_icons.cpp b/src/gui/components/cc_frm_icons.cpp index e83707320..1092491f2 100644 --- a/src/gui/components/cc_frm_icons.cpp +++ b/src/gui/components/cc_frm_icons.cpp @@ -108,7 +108,7 @@ int CComponentsIconForm::getIconId(const std::string& icon_name) //to remove old items before add new icons, otherwise icons will be appended. void CComponentsIconForm::removeAllIcons() { - clearCCItems(); + clear(); v_icons.clear(); } diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 9a3ecdb86..08902596b 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -63,7 +63,7 @@ void CComponentsItem::initVarItem() // If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this! void CComponentsItem::paintInit(bool do_save_bg) { - clear(); + clearFbData(); int th = fr_thickness; fb_pixel_t col_frame_cur = col_frame; From a6c2518017c0c8520940053da391bf2f6492d852 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 7 Jan 2014 09:42:54 +0100 Subject: [PATCH 11/24] CBuildInfo: remove destructor CBuildInfo using already inherited destructor from CComponentsForm. --- src/gui/buildinfo.cpp | 7 +------ src/gui/buildinfo.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/gui/buildinfo.cpp b/src/gui/buildinfo.cpp index 02523b66f..1b9fbff2d 100644 --- a/src/gui/buildinfo.cpp +++ b/src/gui/buildinfo.cpp @@ -55,11 +55,6 @@ void CBuildInfo::initVarBuildInfo() shadow = true; } -CBuildInfo::~CBuildInfo() -{ - cleanCCForm(); -} - int CBuildInfo::exec(CMenuTarget* parent, const string & /*actionKey*/) { @@ -172,7 +167,7 @@ void CBuildInfo::InitInfoItems() return; //ensure a clean body - ccw_body->clearCCItems(); + ccw_body->clear(); //define size and position int x_info = 10; diff --git a/src/gui/buildinfo.h b/src/gui/buildinfo.h index 4a091506c..14a341232 100644 --- a/src/gui/buildinfo.h +++ b/src/gui/buildinfo.h @@ -70,7 +70,7 @@ class CBuildInfo : public CMenuTarget, public CComponentsWindow }; CBuildInfo(); - ~CBuildInfo(); + ///assigns text Font type void setFontType(Font* font_text); build_info_t getInfo(const info_type_id_t& type_id); From 12fd92e3e4d469c164b8c2b3c9609e7945ff2a54 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 7 Jan 2014 09:44:40 +0100 Subject: [PATCH 12/24] CInfoClock: remove call of missing members, replace with simplified clear() --- src/gui/infoclock.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index f9a08f8ad..0a96fad82 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -83,10 +83,8 @@ void CInfoClock::Init() int x_old = x, y_old = y, width_old = width, height_old = height; CVolumeHelper::getInstance()->refresh(cl_font); CVolumeHelper::getInstance()->getInfoClockDimensions(&x, &y, &width, &height); - if ((x_old != x) || (y_old != y) || (width_old != width) || (height_old != height)) { - cleanCCForm(); - clearCCItems(); - } + if ((x_old != x) || (y_old != y) || (width_old != width) || (height_old != height)) + clear(); // set corner radius depending on clock height corner_rad = (g_settings.rounded_corners) ? std::max(height/10, CORNER_RADIUS_SMALL) : 0; From 7403aa2d46540f1eaa8bd72c95cf6a9049ba6e62 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 7 Jan 2014 11:53:02 +0100 Subject: [PATCH 13/24] CTimeOSD: use class konform member names CTimeOSD is inherited from CComponentsForm/Item. Therefore, it is usual to keep the functional layout. Overwritable virtual members should be used with same functionality. kill() is similar with paintBackground() known from CFrameBuffer, hide(bool) do restore saved background and expects a parameter. TODO: It works, but class layout of CTimeOSD is currently not conform with Components, because the functionalities are partially undermined and must be reworked. For Example: timescale and clock object not used as sub objects in a parent form object. --- src/gui/movieplayer.cpp | 6 +++--- src/gui/timeosd.cpp | 32 ++++++++++++++++++-------------- src/gui/timeosd.h | 5 +++-- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 01e975edf..eb6d10895 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -648,7 +648,7 @@ void CMoviePlayerGui::PlayFile(void) } if (time_forced) { time_forced = false; - FileTime.hide(); + FileTime.kill(); } } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { if (playstate == CMoviePlayerGui::PAUSE) { @@ -752,7 +752,7 @@ void CMoviePlayerGui::PlayFile(void) //showHelpTS(); } else if(timeshift && (msg == CRCInput::RC_text || msg == CRCInput::RC_epg || msg == NeutrinoMessages::SHOW_EPG)) { bool restore = FileTime.IsVisible(); - FileTime.hide(); + FileTime.kill(); if( msg == CRCInput::RC_epg ) g_EventList->exec(CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID(), CNeutrinoApp::getInstance()->channelList->getActiveChannelName()); @@ -833,7 +833,7 @@ void CMoviePlayerGui::PlayFile(void) } } - FileTime.hide(); + FileTime.kill(); clearSubtitle(); playback->SetSpeed(1); diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index a6312102a..e08164061 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -63,10 +63,8 @@ void CTimeOSD::Init() int x_old = x, y_old = y, width_old = width, height_old = height; CVolumeHelper::getInstance()->refresh(cl_font); CVolumeHelper::getInstance()->getTimeDimensions(&x, &y, &width, &height); - if ((x_old != x) || (y_old != y) || (width_old != width) || (height_old != height)) { - cleanCCForm(); - clearCCItems(); - } + if ((x_old != x) || (y_old != y) || (width_old != width) || (height_old != height)) + clear(); // set corner radius depending on clock height corner_rad = (g_settings.rounded_corners) ? std::max(height/10, CORNER_RADIUS_SMALL) : 0; @@ -74,10 +72,13 @@ void CTimeOSD::Init() initCCLockItems(); } +#if 0 //if hide() or kill() required, it's recommended to use it separately CTimeOSD::~CTimeOSD() { - hide(); + CComponents::kill(); + clear(); } +#endif void CTimeOSD::initTimeString() { @@ -134,12 +135,10 @@ void CTimeOSD::switchMode(int position, int duration) break; case MODE_DESC: m_mode = MODE_BAR; - kill(); + CComponents::kill(); break; case MODE_BAR: - m_mode = MODE_HIDE; - timescale.kill(); - timescale.reset(); + KillAndResetTimescale(); frameBuffer->blit(); return; default: @@ -149,13 +148,18 @@ void CTimeOSD::switchMode(int position, int duration) update(position, duration); } -void CTimeOSD::hide(void) +void CTimeOSD::kill() { if (m_mode != MODE_HIDE) { - m_mode = MODE_HIDE; - timescale.kill(); - timescale.reset(); - kill(); + KillAndResetTimescale(); + CComponents::kill(); frameBuffer->blit(); } } + +void CTimeOSD::KillAndResetTimescale() +{ + m_mode = MODE_HIDE; + timescale.kill(); + timescale.reset(); +} diff --git a/src/gui/timeosd.h b/src/gui/timeosd.h index 3f98bf47e..3b030a861 100644 --- a/src/gui/timeosd.h +++ b/src/gui/timeosd.h @@ -48,12 +48,13 @@ class CTimeOSD : public CComponentsFrmClock void Init(); void initTimeString(); void updatePos(int position, int duration); + void KillAndResetTimescale(); public: CTimeOSD(); - ~CTimeOSD(); +// ~CTimeOSD(); is inherited void show(time_t time_show, bool force = true); - void hide(); + void kill(); bool IsVisible() {return m_mode != MODE_HIDE;} void update(int position, int duration); void switchMode(int position, int duration); From 2191fded3862a997973a52112f77bd6508d67fd4 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Jan 2014 08:06:39 +0100 Subject: [PATCH 14/24] CComponentsForm: add members to get count of items --- src/gui/components/cc_frm.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 7e37a6698..bbd60e263 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -62,8 +62,14 @@ class CComponentsForm : public CComponentsItem virtual int getCCItemId(CComponentsItem* cc_Item); virtual CComponentsItem* getCCItem(const uint& cc_item_id); virtual void paintCCItems(); + ///clean up and deallocate existant items from v_cc_items at once virtual void clear(); + ///return true, if no items available + virtual bool empty(){return v_cc_items.empty();}; + ///return size (count) of available items + virtual size_t size(){return v_cc_items.size();}; + virtual void setAppendOffset(const int &h_offset, const int& v_offset){append_h_offset = h_offset; append_v_offset = v_offset;}; }; From 8828e279683eb91e2ce62c18941f880546028dd7 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Jan 2014 11:20:18 +0100 Subject: [PATCH 15/24] CComponentsFrmClock: update license text --- src/gui/components/cc_frm_clock.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index b921ee47b..ab7323424 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Generic GUI-related component. - Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013, 2014 Thilo Graf 'dbt' License: GPL @@ -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 . */ #ifdef HAVE_CONFIG_H From 4e1caf8afe3a9f74abb4319ab31973a50bef5be8 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Jan 2014 10:14:26 +0100 Subject: [PATCH 16/24] CComponentsFrmClock: fix shaodow warning size is a member name of CComponentsForm --- src/gui/components/cc_frm_clock.cpp | 4 ++-- src/gui/components/cc_frm_clock.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index ab7323424..c3d6e6bfe 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -353,10 +353,10 @@ void CComponentsFrmClock::paint(bool do_save_bg) paintForm(do_save_bg); } -void CComponentsFrmClock::setClockFontSize(int size) +void CComponentsFrmClock::setClockFontSize(int font_size) { int tmp_w = 0; - dyn_font_size = size; + dyn_font_size = font_size; cl_font = CNeutrinoFonts::getInstance()->getDynFont(tmp_w, dyn_font_size, "", CNeutrinoFonts::FONT_STYLE_BOLD, CNeutrinoFonts::FONT_ID_INFOCLOCK); } diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index d08336310..f9065f877 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -100,7 +100,7 @@ class CComponentsFrmClock : public CComponentsForm ///set font type or font size for segments virtual void setClockFont(int font); - virtual void setClockFontSize(int size); + virtual void setClockFontSize(int font_size); ///set text color virtual void setTextColor(fb_pixel_t color_text){ cl_col_text = color_text;}; From 44d2eabedee4126f66856b47e2c6127a9275d802 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Jan 2014 12:12:01 +0100 Subject: [PATCH 17/24] CMoviePlayerGui: disable time display for REW, FF-modes time display in combination with REW and FF is broken, needs rework included CTimeOSD see also: http://www.dbox2world.net/board293-cst-coolstream/board314-cst-coolstream-development/12017-einblendungen-im-movieplayer/ --- src/gui/movieplayer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index eb6d10895..bfa8fa890 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -705,11 +705,12 @@ void CMoviePlayerGui::PlayFile(void) if (!timeshift) callInfoViewer(/*duration, position*/); - +#if 0 //FIXME, time display in combination with REW and FF is broken if (!FileTime.IsVisible()) { FileTime.show(position); time_forced = true; } +#endif } else if (msg == CRCInput::RC_1) { // Jump Backwards 1 minute clearSubtitle(); playback->SetPosition(-60 * 1000); From 468a8df8f45e6c80d7e53fbfa523346bdb5ce218 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sun, 29 Dec 2013 14:16:46 +0400 Subject: [PATCH 18/24] gui/scan_setup.cpp: fix separator between sat and cable scan option --- src/gui/scan_setup.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index bd0b6b297..3cc6ccd67 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -431,13 +431,11 @@ int CScanSetup::showScanMenu() mf->setHint("", LOCALE_MENU_HINT_SCAN_FAST); settings->addItem(mf); #endif + settings->addItem(GenericMenuSeparatorLine); } if (CFEManager::getInstance()->haveCable()) { r_system = DVB_C; - //-------------------------------------------------------------- - //settings->addItem(GenericMenuSeparatorLine); - //-------------------------------------------------------------- //tune timeout if(CFEManager::getInstance()->getFrontendCount() <= 1) { CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_ZAPIT_FE_TIMEOUT, (int *)&zapitCfg.feTimeout, true, 6, 100); @@ -471,8 +469,8 @@ int CScanSetup::showScanMenu() CMenuForwarder * fcableScan = new CMenuDForwarder(LOCALE_SATSETUP_CABLE, true, NULL, cableScan, "", have_sat ? CRCInput::convertDigitToKey(shortcut++) : CRCInput::RC_yellow, have_sat ? NULL : NEUTRINO_ICON_BUTTON_YELLOW); fcableScan->setHint("", LOCALE_MENU_HINT_SCAN_CABLE_SIMPLE); settings->addItem(fcableScan); + settings->addItem(GenericMenuSeparatorLine); } - settings->addItem(GenericMenuSeparatorLine); //service select mode mc = new CMenuOptionChooser(LOCALE_ZAPIT_SCANTYPE, (int *)&scansettings.scanType, SCANTS_ZAPIT_SCANTYPE, SCANTS_ZAPIT_SCANTYPE_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++), "", true); mc->setHint("", LOCALE_MENU_HINT_SCAN_SCANTYPE); From 911e41627c8a5f3c37e477091ee47a1204d1bd61 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 8 Jan 2014 16:34:25 +0400 Subject: [PATCH 19/24] gui/movieplayer.cpp: re-enable and fix auto-time display for REW, FF-modes --- src/gui/movieplayer.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index bfa8fa890..84d050bdf 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -637,6 +637,10 @@ void CMoviePlayerGui::PlayFile(void) } else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) { playstate = CMoviePlayerGui::STOPPED; } else if (msg == (neutrino_msg_t) g_settings.mpkey_play) { + if (time_forced) { + time_forced = false; + FileTime.kill(); + } if (playstate > CMoviePlayerGui::PLAY) { playstate = CMoviePlayerGui::PLAY; speed = 1; @@ -646,10 +650,6 @@ void CMoviePlayerGui::PlayFile(void) if (!timeshift) callInfoViewer(/*duration, position*/); } - if (time_forced) { - time_forced = false; - FileTime.kill(); - } } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { if (playstate == CMoviePlayerGui::PAUSE) { playstate = CMoviePlayerGui::PLAY; @@ -703,14 +703,12 @@ void CMoviePlayerGui::PlayFile(void) } //update_lcd = true; - if (!timeshift) - callInfoViewer(/*duration, position*/); -#if 0 //FIXME, time display in combination with REW and FF is broken - if (!FileTime.IsVisible()) { - FileTime.show(position); + if (!FileTime.IsVisible() && !time_forced) { + FileTime.switchMode(position, duration); time_forced = true; } -#endif + if (!timeshift) + callInfoViewer(/*duration, position*/); } else if (msg == CRCInput::RC_1) { // Jump Backwards 1 minute clearSubtitle(); playback->SetPosition(-60 * 1000); From 341b75ccd937f112e266d67b99748f557d7bf737 Mon Sep 17 00:00:00 2001 From: martii Date: Tue, 7 Jan 2014 02:00:56 +0100 Subject: [PATCH 20/24] gui/dboxinfo: minor clean-up --- src/gui/dboxinfo.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index b7d90ca5a..3b203415f 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -490,19 +490,16 @@ void CDBoxInfoWidget::paint() int ypos_mnt_head = ypos; ypos += mheight; + int width_i = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("i", true); + for (std::map::iterator it = mounts.begin(); it != mounts.end(); ++it) { struct statfs s; if (::statfs((*it).first.c_str(), &s) == 0) { if (s.f_blocks > 0) { - int percent_used; - uint64_t bytes_total; - uint64_t bytes_used; - uint64_t bytes_free; - bytes_total = s.f_blocks * s.f_bsize; - bytes_free = s.f_bfree * s.f_bsize; - bytes_used = bytes_total - bytes_free; - percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total; - int width_i = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("i", true); + uint64_t bytes_total = s.f_blocks * s.f_bsize; + uint64_t bytes_free = s.f_bfree * s.f_bsize; + uint64_t bytes_used = bytes_total - bytes_free; + int percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total; //paint mountpoints for (int column = 0; column < headSize; column++) { std::string tmp; From 4c797ec3ec3c92a21b4b1a1f1d86f8d02b0d1fac Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sun, 12 Jan 2014 10:42:59 +0100 Subject: [PATCH 21/24] Disable infoclock when user menu activ --- src/gui/user_menue.cpp | 7 +++++++ src/neutrino.cpp | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 34e8fdad3..3758d1fad 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -55,6 +55,7 @@ #include "dboxinfo.h" #include "cam_menu.h" #include "pluginlist.h" +#include "infoclock.h" #include #include @@ -69,6 +70,7 @@ extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ // extern CPlugins * g_PluginList; extern CCAMMenuHandler * g_CamHandler; +extern CInfoClock * InfoClock; // #include @@ -85,6 +87,8 @@ CUserMenu::~CUserMenu() // USERMENU bool CUserMenu::showUserMenu(int button) { + InfoClock->enableInfoClock(false); + // set width width = w_max (40, 10); @@ -427,6 +431,9 @@ bool CUserMenu::showUserMenu(int button) if (games) delete games; if (scripts) delete scripts; if (menu) delete menu; + + InfoClock->enableInfoClock(true); + return 0; } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index e40ccbb37..3ef60554f 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2243,11 +2243,9 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) // eventlist if (g_settings.personalize[SNeutrinoSettings::P_MAIN_RED_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED)// EventList Menu - Personalization Check { - InfoClock->enableInfoClock(false); StopSubtitles(); usermenu.showUserMenu(SNeutrinoSettings::BUTTON_RED); StartSubtitles(); - InfoClock->enableInfoClock(true); } else ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); From 2ca246a30d151cefca4811fd9c97daaf585229fd Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 12 Jan 2014 13:50:28 +0100 Subject: [PATCH 22/24] CComponentsSlider: fix debug output --- src/gui/components/cc_frm_slider.cpp | 16 ++++++++++++---- src/gui/components/cc_frm_slider.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gui/components/cc_frm_slider.cpp b/src/gui/components/cc_frm_slider.cpp index 50b5f5fbd..69934b114 100644 --- a/src/gui/components/cc_frm_slider.cpp +++ b/src/gui/components/cc_frm_slider.cpp @@ -97,7 +97,6 @@ void CComponentsSlider::setValueScale(const int& min_value, const int& max_value void CComponentsSlider::initCCSlBody() { if (!csl_body_icon.empty()){ - printf("[CComponentsSlider] [%s] missing or undefinied slider body icon %s\n", __func__, csl_body_icon.c_str()); if (csl_body_obj == NULL){ csl_body_obj = new CComponentsPicture(0, 0, 0, height, csl_body_icon); csl_body_obj->doPaintBg(false); @@ -106,8 +105,10 @@ void CComponentsSlider::initCCSlBody() else csl_body_obj->setPicture(csl_body_icon); } - else + else{ + printf("[CComponentsSlider] [%s] missing or undefinied slider body icon %s\n", __func__, csl_body_icon.c_str()); return; + } //get first icon dimensions int icon_w = csl_body_obj->getWidth(); @@ -127,7 +128,6 @@ void CComponentsSlider::initCCSlBody() void CComponentsSlider::initCCSlSlider() { if (!csl_slider_icon.empty()){ - printf("[CComponentsSlider] [%s] missing or undefinied slider icon %s\n", __func__, csl_slider_icon.c_str()); if (csl_slider_obj == NULL){ csl_slider_obj = new CComponentsPicture(0, 0, 0, 0, csl_slider_icon); csl_slider_obj->doPaintBg(false); @@ -136,8 +136,10 @@ void CComponentsSlider::initCCSlSlider() else csl_slider_obj->setPicture(csl_slider_icon); } - else + else{ + printf("[CComponentsSlider] [%s] missing or undefinied slider icon %s\n", __func__, csl_slider_icon.c_str()); return; + } //get first icon dimensions int slider_w = csl_slider_obj->getWidth(); @@ -157,6 +159,12 @@ void CComponentsSlider::initCCSlItems() initCCSlSlider(); } +void CComponentsSlider::setSliderIcon(const std::string &icon_name) +{ + csl_slider_icon = icon_name; + initCCSlSlider(); +} + // void CComponentsSlider::paint(bool do_save_bg) // { // //prepare items before paint diff --git a/src/gui/components/cc_frm_slider.h b/src/gui/components/cc_frm_slider.h index 9f6672f9d..9241dc49c 100644 --- a/src/gui/components/cc_frm_slider.h +++ b/src/gui/components/cc_frm_slider.h @@ -85,6 +85,7 @@ class CComponentsSlider : public CComponentsForm void setValuePos(const int& current_value); void setValueScale(const int& min_value, const int& max_value); + void setSliderIcon(const std::string &icon_name); // void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; From f6d7352dca9f1087b83f1af5b97c8ac3621d6621 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 12 Jan 2014 13:51:24 +0100 Subject: [PATCH 23/24] CComponents: add member to set color for selected items --- src/gui/components/cc_base.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index 37c38a71f..a726361a8 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -166,6 +166,8 @@ class CComponents ///set frame color inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;}; + ///set selected frame color + inline virtual void setColorFrameSel(fb_pixel_t color){col_frame_sel = color;}; ///set body color inline virtual void setColorBody(fb_pixel_t color){col_body = color;}; ///set shadow color From 72cb72695f57707e10844c320045466b7d3f848e Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 12 Jan 2014 13:54:55 +0100 Subject: [PATCH 24/24] CComponentsSlider: fix vertical arrangement for slider body Centering was broken. --- src/gui/components/cc_frm_slider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/components/cc_frm_slider.cpp b/src/gui/components/cc_frm_slider.cpp index 69934b114..f61b37fa6 100644 --- a/src/gui/components/cc_frm_slider.cpp +++ b/src/gui/components/cc_frm_slider.cpp @@ -98,7 +98,7 @@ void CComponentsSlider::initCCSlBody() { if (!csl_body_icon.empty()){ if (csl_body_obj == NULL){ - csl_body_obj = new CComponentsPicture(0, 0, 0, height, csl_body_icon); + csl_body_obj = new CComponentsPicture(0, 0, 0, 0, csl_body_icon); csl_body_obj->doPaintBg(false); addCCItem(csl_body_obj); }