diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am
index 0089ac8a1..e43158b13 100644
--- a/src/gui/components/Makefile.am
+++ b/src/gui/components/Makefile.am
@@ -18,6 +18,7 @@ noinst_LIBRARIES = libneutrino_gui_components.a
libneutrino_gui_components_a_SOURCES = \
cc_base.cpp \
+ cc_button_select.cpp \
cc_detailsline.cpp \
cc_draw.cpp \
cc_extra.cpp \
diff --git a/src/gui/components/cc_button_select.cpp b/src/gui/components/cc_button_select.cpp
new file mode 100644
index 000000000..95dfcbefc
--- /dev/null
+++ b/src/gui/components/cc_button_select.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) 2017, 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 .
+*/
+
+#include "config.h"
+#include "cc_button_select.h"
+
+CCButtonSelect::CCButtonSelect(CComponentsFrmChain *chain_obj)
+{
+ chain = chain_obj;
+}
+
+CComponentsFrmChain* CCButtonSelect::getButtonChainObject()
+{
+ return chain;
+}
+
+CComponentsButton* CCButtonSelect::getSelectedButtonObject()
+{
+ CComponentsButton* ret = static_cast(chain->getSelectedItemObject());
+ return ret;
+}
+
+int CCButtonSelect::getSelectedButton()
+{
+ if (chain)
+ return chain->getSelectedItem();
+ return -1;
+}
+
+void CCButtonSelect::setSelectedButton(size_t item_id,
+ const fb_pixel_t& fr_col,
+ const fb_pixel_t& sel_fr_col,
+ const fb_pixel_t& bg_col,
+ const fb_pixel_t& sel_bg_col,
+ const fb_pixel_t& text_col,
+ const fb_pixel_t& sel_text_col,
+ const int& frame_width,
+ const int& sel_frame_width)
+{
+ if (chain){
+ for (size_t i= 0; i< chain->size(); i++){
+ CComponentsButton *btn = static_cast(chain->getCCItem(i));
+ btn->setButtonTextColor(text_col);
+ }
+ fb_pixel_t sel_col = fr_col;
+ if (chain->size() > 1)
+ sel_col = sel_fr_col; //TODO: make it configurable
+ chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
+
+ getSelectedButtonObject()->setButtonTextColor(sel_text_col);
+ }
+}
+
+
diff --git a/src/gui/components/cc_button_select.h b/src/gui/components/cc_button_select.h
new file mode 100644
index 000000000..c122e1479
--- /dev/null
+++ b/src/gui/components/cc_button_select.h
@@ -0,0 +1,81 @@
+/*
+ Based up Neutrino-GUI - Tuxbox-Project
+ Copyright (C) 2001 by Steffen Hehn 'McClean'
+
+ Classes for generic GUI-related components.
+ Copyright (C) 2017, 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_BTN_SEL_H__
+#define __CC_BTN_SEL_H__
+
+
+#include "cc_frm_button.h"
+
+/*!
+Class for inheritation of button select handling inside other CComponentsForm objects and their derivations
+*/
+class CCButtonSelect
+{
+ protected:
+ CComponentsFrmChain *chain;
+
+ public:
+ CCButtonSelect(CComponentsFrmChain *chain_obj = NULL);
+
+ ///returns selected button object, return value as pointer to object, NULL means nothing is selected
+ CComponentsButton* getSelectedButtonObject();
+
+ ///returns pointer to internal button container
+ CComponentsFrmChain* getButtonChainObject();
+
+ ///returns id of select button, return value as int, -1 = nothing is selected
+ int getSelectedButton();
+
+ /**Select a definied button inside button chain object
+ * @param[in] item_id
+ * @li optional: expects type size_t
+ * @param[in] fr_col
+ * @li optional: expects type fb_pixel_t, as default frame color
+ * @param[in] sel_fr_col
+ * @li optional: expects type fb_pixel_t, as selected frame color
+ * @param[in] bg_col
+ * @li optional: expects type fb_pixel_t, as default background color
+ * @param[in] sel_bg_col
+ * @li optional: expects type fb_pixel_t, as selected background color
+ * @param[in] text_col
+ * @li optional: expects type fb_pixel_t, as default text color
+ * @param[in] sel_text_col
+ * @li optional: expects type fb_pixel_t, as selected text color
+ * @param[in] frame_width
+ * @li optional: expects type int, default = 1
+ * @param[in] sel_frame_width
+ * @li optional: expects type int, default = 1
+ */
+ void setSelectedButton(size_t item_id,
+ const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2,
+ const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0,
+ const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0,
+ const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0,
+ const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT,
+ const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT,
+ const int& frame_width = 1,
+ const int& sel_frame_width = 1);
+};
+
+#endif //__CC_BTN_SEL_H__
diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h
index f1aba0a9c..0b7b74401 100644
--- a/src/gui/components/cc_frm.h
+++ b/src/gui/components/cc_frm.h
@@ -28,7 +28,7 @@
#include "config.h"
#include "cc_base.h"
#include "cc_item.h"
-#include "cc_frm_scrollbar.h"
+
class CComponentsForm : public CComponentsItem
{
diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp
index 3532e05f3..31fc2c5c9 100644
--- a/src/gui/components/cc_frm_footer.cpp
+++ b/src/gui/components/cc_frm_footer.cpp
@@ -35,7 +35,7 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsFooter inherit from CComponentsHeader
-CComponentsFooter::CComponentsFooter(CComponentsForm* parent)
+CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect()
{
//CComponentsFooter
initVarFooter(1, 1, 0, 0, 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUFOOT_PLUS_0, COL_SHADOW_PLUS_0);
@@ -47,7 +47,7 @@ CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
- fb_pixel_t color_shadow )
+ fb_pixel_t color_shadow ):CCButtonSelect()
{
//CComponentsFooter
initVarFooter(x_pos, y_pos, w, h, buttons, parent, shadow_mode, color_frame, color_body, color_shadow);
@@ -95,7 +95,6 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
corner_type = CORNER_BOTTOM;
ccf_enable_button_bg = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment
- chain = NULL;
addContextButton(buttons);
initCCItems();
@@ -323,43 +322,6 @@ void CComponentsFooter::enableButtonBg(bool enable)
}
}
-void CComponentsFooter::setSelectedButton(size_t item_id,
- const fb_pixel_t& fr_col, const fb_pixel_t& sel_fr_col,
- const fb_pixel_t& bg_col, const fb_pixel_t& sel_bg_col,
- const fb_pixel_t& text_col, const fb_pixel_t& sel_text_col,
- const int& frame_width,
- const int& sel_frame_width)
-{
- if (chain){
- for (size_t i= 0; i< chain->size(); i++){
- CComponentsButton *btn = static_cast(chain->getCCItem(i));
- btn->setButtonTextColor(text_col);
- }
- fb_pixel_t sel_col = fr_col;
- if (chain->size() > 1)
- sel_col = sel_fr_col; //TODO: make it configurable
- chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
-
- getSelectedButtonObject()->setButtonTextColor(sel_text_col);
- }
-}
-
-int CComponentsFooter::getSelectedButton()
-{
- int ret = -1;
- if (chain)
- ret = chain->getSelectedItem();
-
- return ret;
-}
-
-CComponentsButton* CComponentsFooter::getSelectedButtonObject()
-{
- CComponentsButton* ret = static_cast(chain->getSelectedItemObject());
- return ret;
-}
-
-
void CComponentsFooter::paintButtons(const int& x_pos,
const int& y_pos,
const int& w,
diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h
index 852faaae1..2586d1772 100644
--- a/src/gui/components/cc_frm_footer.h
+++ b/src/gui/components/cc_frm_footer.h
@@ -26,6 +26,8 @@
#include "cc_frm_header.h"
#include "cc_frm_button.h"
+#include "cc_button_select.h"
+
#include
#include //for compatibility with 'button_label' type
@@ -39,7 +41,7 @@ to add button labels known by older button handler, to find in gui/widget/button
functionality. Why limited ?: old parameter 'struct button_label' doesn't provide newer parameters.
Missing parameters are filled with default values and must be assigned afterward, if required.
*/
-class CComponentsFooter : public CComponentsHeader
+class CComponentsFooter : public CComponentsHeader, public CCButtonSelect
{
private:
void initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
@@ -67,9 +69,6 @@ class CComponentsFooter : public CComponentsHeader
///init default fonts for size modes
virtual void initDefaultFonts();
- ///container for button objects
- CComponentsFrmChain *chain;
-
public:
CComponentsFooter(CComponentsForm *parent = NULL);
CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
@@ -114,40 +113,6 @@ class CComponentsFooter : public CComponentsHeader
///disables background of buttons
void disableButtonBg(){enableButtonBg(false);}
- /**Select a definied button inside button chain object
- * @param[in] item_id
- * @li optional: exepts type size_t
- * @param[in] fr_col
- * @li optional: exepts type fb_pixel_t, as default frame color
- * @param[in] sel_fr_col
- * @li optional: exepts type fb_pixel_t, as selected frame color
- * @param[in] bg_col
- * @li optional: exepts type fb_pixel_t, as default background color
- * @param[in] sel_bg_col
- * @li optional: exepts type fb_pixel_t, as selected background color
- * @param[in] text_col
- * @li optional: exepts type fb_pixel_t, as default text color
- * @param[in] sel_text_col
- * @li optional: exepts type fb_pixel_t, as selected text color
- * @param[in] frame_width
- * @li optional: exepts type int, default = 1
- * @param[in] sel_frame_width
- * @li optional: exepts type int, default = 2
- */
- void setSelectedButton(size_t item_id,
- const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2,
- const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0,
- const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0,
- const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0,
- const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT,
- const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT,
- const int& frame_width = 1,
- const int& sel_frame_width = 1);
- ///returns id of select button, return value as int, -1 = nothing is selected
- int getSelectedButton();
- ///returns selected button object, return value as pointer to object, NULL means nothing is selected
- CComponentsButton* getSelectedButtonObject();
-
/*!
Sets a new text to an already predefined button.
1st parameter 'btn_id' accepts current id of an already defined button. 2nd parameter sets the new text as std::string
@@ -164,10 +129,6 @@ class CComponentsFooter : public CComponentsHeader
///property: set font for label caption, parameter as font object, value NULL causes usage of dynamic font
void setButtonFont(Font* font){ccf_btn_font = font;};
- ///returns pointer to internal button container
- CComponentsFrmChain* getButtonChainObject(){return chain;};
-
-
///this is a nearly methode similar with the older button handler find in gui/widget/buttons.h, some parameters are different, but require minimalized input
///this member sets some basic parameters and will paint concurrently on execute, explicit call of paint() is not required
void paintButtons( const int& x_pos,
@@ -196,4 +157,6 @@ class CComponentsFooter : public CComponentsHeader
void disbaleButtonShadow(){enableButtonShadow(CC_SHADOW_OFF);}
};
+
+
#endif
diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h
index 1db5ed7aa..e24f5cc03 100644
--- a/src/gui/components/cc_types.h
+++ b/src/gui/components/cc_types.h
@@ -34,6 +34,7 @@ struct gradientData_t;
class Font;
class CComponentsForm;
class CComponentsScrollBar;
+class CCButtonSelect;
///cc item types
typedef enum