From e665ab18ab3ea586c16c12c701e10b97f2ca48c6 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 29 May 2013 10:20:03 +0200 Subject: [PATCH] CComponentsFooter: add new class CComponentsFooter --- src/gui/components/Makefile.am | 1 + src/gui/components/cc_frm.h | 17 ++++++- src/gui/components/cc_frm_footer.cpp | 74 ++++++++++++++++++++++++++++ src/gui/components/cc_types.h | 1 + src/gui/test_menu.cpp | 22 ++++++++- src/gui/test_menu.h | 1 + 6 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 src/gui/components/cc_frm_footer.cpp diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index 500d2b17a..aba665965 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -29,6 +29,7 @@ libneutrino_gui_components_a_SOURCES = \ cc_frm_button.cpp \ cc_frm.cpp \ cc_frm_clock.cpp \ + cc_frm_footer.cpp \ cc_frm_header.cpp \ cc_frm_icons.cpp \ cc_frm_window.cpp \ diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 6134bb745..57e9566f8 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -143,7 +143,7 @@ class CComponentsHeader : public CComponentsForm 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); - ~CComponentsHeader(); + virtual ~CComponentsHeader(); virtual void setCaption(const std::string& caption); @@ -158,7 +158,20 @@ class CComponentsHeader : public CComponentsForm virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;}; virtual void initCCItems(); - void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + 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); }; class CComponentsWindow : public CComponentsForm diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp new file mode 100644 index 000000000..0a07cbf5e --- /dev/null +++ b/src/gui/components/cc_frm_footer.cpp @@ -0,0 +1,74 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2013, 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, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_frm.h" + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsFooter inherit from CComponentsHeader +CComponentsFooter::CComponentsFooter() +{ + //CComponentsFooter + initVarFooter(); +} + +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(); + + 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; + + cch_buttons = buttons; + + initDefaultButtons(); + initCCItems(); +} + + +void CComponentsFooter::initVarFooter() +{ + //CComponentsHeader + initVarHeader(); + + cc_item_type = CC_ITEMTYPE_FOOTER; + corner_rad = RADIUS_LARGE; + corner_type = CORNER_BOTTOM; +} diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index a72b98cbc..02f8aed01 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -42,6 +42,7 @@ typedef enum CC_ITEMTYPE_FRM, CC_ITEMTYPE_FRM_CLOCK, CC_ITEMTYPE_FRM_HEADER, + CC_ITEMTYPE_FOOTER, CC_ITEMTYPE_FRM_ICONFORM, CC_ITEMTYPE_FRM_WINDOW, CC_ITEMTYPE_LABEL, diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index f860f5d83..d0037d7d8 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -68,6 +68,7 @@ CTestMenu::CTestMenu() form = NULL; txt = NULL; header = NULL; + footer = NULL; iconform = NULL; window = NULL; button = NULL; @@ -82,6 +83,7 @@ CTestMenu::~CTestMenu() delete form; delete txt; delete header; + delete footer; delete iconform; delete window; delete button; @@ -452,8 +454,8 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) header->setCaption("Test"); // add any other button icon -// header->addHeaderButton(NEUTRINO_ICON_BUTTON_BLUE); -// header->addHeaderButton(NEUTRINO_ICON_BUTTON_GREEN); +// header->addButton(NEUTRINO_ICON_BUTTON_BLUE); +// header->addButton(NEUTRINO_ICON_BUTTON_GREEN); // example to replace the text item with an image item // get text x position @@ -474,6 +476,21 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) header->hide(); return res; } + else if (actionKey == "footer"){ + int hh = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + if (footer == NULL){ + footer = new CComponentsFooter (100, 50, 500, hh, CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU, true); + CComponentsButtonRed * btnred = new CComponentsButtonRed(10, 0, 200, hh, "Red"); + btnred->doPaintBg(false); + + footer->addCCItem(btnred); + } + if (!footer->isPainted()) + footer->paint(); + else + footer->hide(); + return res; + } else if (actionKey == "iconform"){ if (iconform == NULL) iconform = new CComponentsIconForm(); @@ -609,6 +626,7 @@ void CTestMenu::showCCTests(CMenuWidget *widget) widget->addItem(new CMenuForwarderNonLocalized("Form", true, NULL, this, "form")); widget->addItem(new CMenuForwarderNonLocalized("Text", true, NULL, this, "text")); widget->addItem(new CMenuForwarderNonLocalized("Header", true, NULL, this, "header")); + widget->addItem(new CMenuForwarderNonLocalized("Footer", true, NULL, this, "footer")); widget->addItem(new CMenuForwarderNonLocalized("Icon-Form", true, NULL, this, "iconform")); widget->addItem(new CMenuForwarderNonLocalized("Window", true, NULL, this, "window")); } diff --git a/src/gui/test_menu.h b/src/gui/test_menu.h index 390106038..c393504c4 100644 --- a/src/gui/test_menu.h +++ b/src/gui/test_menu.h @@ -49,6 +49,7 @@ class CTestMenu : public CMenuTarget CComponentsForm *form; CComponentsText *txt; CComponentsHeader *header; + CComponentsHeader *footer; CComponentsIconForm *iconform; CComponentsWindow *window; CComponentsButton *button;