diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index b4b58ec39..1e618566b 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -34,6 +34,7 @@ libneutrino_gui_components_a_SOURCES = \ cc_frm_header.cpp \ cc_frm_ext_text.cpp \ cc_frm_icons.cpp \ + cc_frm_scrollbar.cpp \ cc_frm_signalbars.cpp \ cc_frm_slider.cpp \ cc_frm_window.cpp \ diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 3383752ec..d7f08650d 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -42,9 +42,10 @@ Basic attributes and member functions for component sub classes #include "cc_detailsline.h" +#include "cc_frm_scrollbar.h" #include "cc_frm.h" -#include "cc_frm_button.h" #include "cc_frm_chain.h" +#include "cc_frm_button.h" #include "cc_frm_clock.h" #include "cc_frm_ext_text.h" #include "cc_frm_header.h" diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index 973da83a0..2f04ae620 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -231,6 +231,9 @@ class CComponentsItem : public CComponents bool cc_item_enabled; ///property: default not selected bool cc_item_selected; + ///property: page number, this defines current item page location, means: this item is embedded in a parent container on page number n, see also setPageNumber() + ///default value is 0 for page one, any value > 0 causes handling for mutilple pages at parent container + uint8_t cc_page_number; ///Pointer to the form object in which this item is embedded. ///Is typically the type CComponentsForm or derived classes, default intialized with NULL @@ -291,6 +294,11 @@ class CComponentsItem : public CComponents ///To generate an index, use genIndex() virtual void setIndex(const int& index){cc_item_index = index;}; + ///sets page location of current item, parameter as uint8_t, see: cc_page_number + virtual void setPageNumber(const uint8_t& on_page_number){cc_page_number = on_page_number;}; + ///returns current number of page location of current item, see: cc_page_number + virtual u_int8_t getPageNumber(){return cc_page_number;}; + ///set screen x-position, parameter as uint8_t, percent x value related to current width of parent form or screen virtual void setXPosP(const uint8_t& xpos_percent); ///set screen y-position, parameter as uint8_t, percent y value related to current height of parent form or screen diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 2fe9b7b12..54964741c 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -67,11 +67,16 @@ CComponentsForm::CComponentsForm( const int x_pos, const int y_pos, const int w, append_x_offset = 0; append_y_offset = 0; + page_count = 1; + cur_page = 0; + sb = NULL; + w_sb = 15; } CComponentsForm::~CComponentsForm() { clear(); + delete sb; } @@ -234,22 +239,70 @@ void CComponentsForm::paint(bool do_save_bg) paintForm(do_save_bg); } +bool CComponentsForm::isPageChanged() +{ + for(size_t i=0; igetPageNumber() != cur_page) + return true; + } + return false; +} + +void CComponentsForm::paintPage(const u_int8_t& page_number, bool do_save_bg) +{ + cur_page = page_number; + paint(do_save_bg); +} void CComponentsForm::paintCCItems() { size_t items_count = v_cc_items.size(); //using of real x/y values to paint items if this text object is bound in a parent form - int this_x = x, auto_x = x, this_y = y, auto_y = y; + int this_x = x, auto_x = x, this_y = y, auto_y = y, this_w = width; if (cc_parent){ this_x = auto_x = cc_xr; this_y = auto_y = cc_yr; } + //init and handle scrollbar + getPageCount(); + int y_sb = this_y+1; + int x_sb = this_x + width - w_sb; + int h_sb = height-2; + if (sb == NULL){ + sb = new CComponentsScrollBar(x_sb, y_sb, w_sb, h_sb); + }else{ + //clean background, if dimension of scrollbar was changed + if (w_sb != sb->getWidth()) + sb->kill(col_body); + + //set current dimensions and position + sb->setDimensionsAll(x_sb, y_sb, w_sb, h_sb); + } + + if(page_count > 1){ + sb->setSegmentCount(page_count); + sb->setMarkID(cur_page); + this_w = width - w_sb; + sb->paint(false); + }else{ + if (sb->isPainted()) + sb->kill(col_body); + this_w = width; + } + + //detect if current page has changed, if true then kill items from screen + if(isPageChanged()){ + this->killCCItems(col_body, true); + } + for(size_t i=0; igetPageNumber(), this->cur_page); + //get current dimension of item int w_item = cc_item->getWidth(); int h_item = cc_item->getHeight(); @@ -259,10 +312,9 @@ void CComponentsForm::paintCCItems() int ypos = cc_item->getYPos(); //check item for corrupt position, skip current item if found problems - //TODO: need a solution with possibility for scrolling - if (ypos > height || xpos > width){ - dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined width=%d \ndefinied y=%d, defined height=%d \n", - __func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), xpos, width, ypos, height); + if (ypos > height || xpos > this_w){ + dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined this_w=%d \ndefinied y=%d, defined height=%d \n", + __func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), xpos, this_w, ypos, height); if (this->cc_item_type != CC_ITEMTYPE_FRM_CHAIN) continue; } @@ -276,7 +328,7 @@ void CComponentsForm::paintCCItems() } //positionize vertical centered else if (xpos == CC_CENTERED){ - auto_x = width/2 - w_item/2; + auto_x = this_w/2 - w_item/2; cc_item->setRealXPos(this_x + auto_x); } else{ @@ -301,12 +353,11 @@ void CComponentsForm::paintCCItems() auto_y = (cc_item->getRealYPos() + h_item); } - //These steps check whether the element can be painted into the container. //Is it too wide or too high, it will be shortened and displayed in the log. //This should be avoid! //checkwidth and adapt if required - int right_frm = (cc_parent ? cc_xr : x) + width - 2*fr_thickness; + int right_frm = (cc_parent ? cc_xr : x) + this_w - 2*fr_thickness; int right_item = cc_item->getRealXPos() + w_item; int w_diff = right_item - right_frm; int new_w = w_item - w_diff; @@ -314,7 +365,7 @@ void CComponentsForm::paintCCItems() right_item -= (new_w%2); w_item -= (new_w%2); if (right_item > right_frm){ - dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] width is too large, definied width=%d, possible width=%d \n", + dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] this_w is too large, definied width=%d, possible width=%d \n", __func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), w_item, new_w); cc_item->setWidth(new_w); } @@ -339,8 +390,9 @@ void CComponentsForm::paintCCItems() if (!this->cc_allow_paint) cc_item->allowPaint(false); - //finally paint current item - cc_item->paint(CC_SAVE_SCREEN_NO); + //finally paint current item, but only required contents of page + if (cc_item->getPageNumber() == cur_page) + cc_item->paint(CC_SAVE_SCREEN_NO); //restore defined old visibility mode of item after paint cc_item->allowPaint(item_visible); @@ -369,3 +421,26 @@ void CComponentsForm::killCCItems(const fb_pixel_t& bg_color, bool ignore_parent for(size_t i=0; ikill(bg_color, ignore_parent); } + +void CComponentsForm::setPageCount(const u_int8_t& pageCount) +{ + u_int8_t new_val = pageCount; + if (new_val < page_count) + dprintf(DEBUG_NORMAL, "[CComponentsForm] %s: current count (= %u) of pages higher than page_count (= %u) will be set, smaller value is ignored!\n", __func__, page_count, new_val) ; + page_count = max(new_val, page_count); +} + +u_int8_t CComponentsForm::getPageCount() +{ + u_int8_t num = 0; + for(size_t i=0; igetPageNumber(); + num = max(item_num, num); + } + + //convert type, possible -Wconversion warnings! + page_count = static_cast(num + 1); + + return page_count; +} + diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 6b526a4e2..79ba3ffb9 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -27,7 +27,7 @@ #include "config.h" #include - +#include "cc_frm_scrollbar.h" class CComponentsForm : public CComponentsItem { @@ -37,8 +37,21 @@ class CComponentsForm : public CComponentsItem ///generates next possible index for an item, see also cc_item_index, getIndex(), setIndex() int genIndex(); + ///scrollbar object + CComponentsScrollBar *sb; + int append_x_offset; int append_y_offset; + + ///property: count of pages of form + u_int8_t page_count; + ///property: id of current page, default = 0 for 1st page + u_int8_t cur_page; + ///scrollbar width + int w_sb; + ///returns true, if current page is changed, see also: setCurrentPage() + bool isPageChanged(); + public: CComponentsForm( const int x_pos = 0, const int y_pos = 0, const int w = 800, const int h = 600, CComponentsForm *parent = NULL, @@ -47,8 +60,10 @@ class CComponentsForm : public CComponentsItem fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); virtual ~CComponentsForm(); - + + ///paints current form on screen, for paint a page use paintPage() void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + ///hides current form, background will be restored, if parameter = false void hide(bool no_restore = false); ///same like CComponentsItem::kill(), but erases all embedded items inside of parent at once, this = parent @@ -83,7 +98,25 @@ class CComponentsForm : public CComponentsItem ///return reference to last item virtual CComponentsItem* back(){return v_cc_items.back();}; + ///sets alignment offset between items virtual void setAppendOffset(const int &x_offset, const int& y_offset){append_x_offset = x_offset; append_y_offset = y_offset;}; + + ///sets count of pages, parameter as u_int8_t + ///NOTE: page numbers are primary defined in items and this values have priority!! Consider that smaller values + ///than the current values can make problems and are not allowed, therefore smaller values than + ///current page count are ignored! + virtual void setPageCount(const u_int8_t& pageCount); + ///returns current count of pages, + ///NOTE: page number are primary defined in items and secondary in form variable 'page_count'. This function returns the maximal value from both! + virtual u_int8_t getPageCount(); + ///sets current page + virtual void setCurrentPage(const u_int8_t& current_page){cur_page = current_page;}; + ///get current page + virtual u_int8_t getCurrentPage(){return cur_page;}; + ///paint defined page number 0...n + virtual void paintPage(const u_int8_t& page_number, bool do_save_bg = CC_SAVE_SCREEN_NO); + ///set width of scrollbar + virtual void setScrollBarWidth(const int& scrollbar_width){w_sb = scrollbar_width;}; }; #endif diff --git a/src/gui/components/cc_frm_scrollbar.cpp b/src/gui/components/cc_frm_scrollbar.cpp new file mode 100644 index 000000000..eb880d6e2 --- /dev/null +++ b/src/gui/components/cc_frm_scrollbar.cpp @@ -0,0 +1,175 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Scrollbar class based up CComponentsFrmChain. + Copyright (C) 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 . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_frm_scrollbar.h" +#include "system/debug.h" + +using namespace std; + +/* base schema + x,y + +-----------------+ + |+---------------+| + ||sb_up_obj || + || || + |+---------------+| + |+---------------+| + ||sb_segments_obj|| + ||+-------------+|| + ||| segment ||| + ||| id 0 ||| + ||| ||| + ||+-------------+|| + ||| segment ||| + ||| id 1 ||| + ||| ||| + ||+-------------+|| + |+---------------+| + |+---------------+| + ||sb_up_obj || + || || + |+---------------+| + +-----------------+ +*/ + +//sub class CComponentsScrollBar inherit from CComponentsFrmChain +CComponentsScrollBar::CComponentsScrollBar( const int &x_pos, const int &y_pos, const int &w, const int &h, + const int& count, + CComponentsForm* parent, + bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) + :CComponentsFrmChain(x_pos, y_pos, w, h, NULL, CC_DIR_Y, parent, has_shadow, color_frame, color_body, color_shadow) +{ + initVarSbForm(count); +} + +void CComponentsScrollBar::initVarSbForm(const int& count) +{ + cc_item_type = CC_ITEMTYPE_FRM_SCROLLBAR; + fr_thickness = 0; + + append_x_offset = 0; + append_y_offset = 2; + + sb_up_obj = sb_down_obj = NULL; + sb_segments_obj = NULL; + sb_up_icon = frameBuffer->getIconBasePath() + NEUTRINO_ICON_BUTTON_TOP; + sb_up_icon += ".png"; + sb_down_icon = frameBuffer->getIconBasePath() + NEUTRINO_ICON_BUTTON_DOWN; + sb_down_icon += ".png"; + + sb_segments_count = count; + sb_mark_id = 0; + + initCCItems(); +} + +void CComponentsScrollBar::setSegmentCount(const int& segment_count, const int& mark_id) +{ + sb_segments_count = segment_count; + sb_mark_id = mark_id; + initSegments(); +} + + +void CComponentsScrollBar::initCCItems() +{ + initTopNaviIcon(); + initSegments(); + initBottomNaviIcon(); +} + +void CComponentsScrollBar::initTopNaviIcon() +{ + //initialize icon object + if (sb_up_obj == NULL){ + sb_up_obj = new CComponentsPicture(CC_CENTERED, fr_thickness, sb_up_icon, this); + sb_up_obj->doPaintBg(false); + } + sb_up_obj->setWidth(width-2*fr_thickness); +} + +void CComponentsScrollBar::initBottomNaviIcon() +{ + //initialize icon object + if (sb_down_obj == NULL){ + sb_down_obj = new CComponentsPicture(CC_CENTERED, CC_APPEND, sb_down_icon, this); + sb_down_obj->doPaintBg(false); + } + sb_down_obj->setWidth(width-2*fr_thickness); +} + +void CComponentsScrollBar::initSegments() +{ + //init dimensions for segments + int w_seg = width - 4*fr_thickness; + int h_seg = height - (sb_segments_count-1)*append_y_offset; + + //calculate height of segment container + int h_seg_obj = height - 2*sb_up_obj->getHeight() - 3*append_y_offset; + + //init segment container + if (sb_segments_obj == NULL){ + sb_segments_obj = new CComponentsFrmChain(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj, NULL, CC_DIR_Y, this, false); + sb_segments_obj->setFrameThickness(0,0); + sb_segments_obj->setAppendOffset(0, 3); + }else + sb_segments_obj->setDimensionsAll(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj); + + //set current color for segment container + sb_segments_obj->setColorBody(col_body); + + //clean up segment container before add new segments + sb_segments_obj->clear(); + + //set y position of 1st segment and set height of segments + int y_seg = 1+ append_y_offset; + h_seg = sb_segments_obj->getHeight()/sb_segments_count - append_y_offset; + + //create and add segments to segment container + for(u_int8_t i=0; igetCCItemId(item); + if (sb_mark_id > id){ + dprintf(DEBUG_NORMAL, "[CComponentsScrollBar] %s: sb_mark_id out of range current=%d allowed=%d\n", __func__, sb_mark_id, id); + } + + //set color for marked id + if (sb_mark_id == id) + item->setColorBody(COL_MENUCONTENTSELECTED_PLUS_0); + else + item->setColorBody(COL_MENUCONTENT_PLUS_1); + } + + //set corner types + sb_segments_obj->front()->setCorner(RADIUS_MIN, CORNER_TOP); + sb_segments_obj->back()->setCorner(RADIUS_MIN, CORNER_BOTTOM); +} diff --git a/src/gui/components/cc_frm_scrollbar.h b/src/gui/components/cc_frm_scrollbar.h new file mode 100644 index 000000000..55b93faaa --- /dev/null +++ b/src/gui/components/cc_frm_scrollbar.h @@ -0,0 +1,82 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Scrollbar class based up CComponentsFrmChain. + Copyright (C) 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_SCROLLBAR_H__ +#define __CC_FORM_SCROLLBAR_H__ + +#include "cc_frm_chain.h" +#include "cc_item_picture.h" + +class CComponentsScrollBar : public CComponentsFrmChain +{ + private: + ///scroll up navi icon object + CComponentsPicture *sb_up_obj; + ///scroll down navi icon object + CComponentsPicture *sb_down_obj; + ///container object for segments + CComponentsFrmChain *sb_segments_obj; + + ///names of navi icons + std::string sb_up_icon, sb_down_icon; + + ///count of segments + int sb_segments_count; + + ///mark id + int sb_mark_id; + + ///init top icon + void initTopNaviIcon(); + ///init bottom icon + void initBottomNaviIcon(); + + ///init segements + void initSegments(); + + ///init all items + void initCCItems(); + + void initVarSbForm( const int& count); + + public: + CComponentsScrollBar( const int &x_pos, const int &y_pos, const int &w = 15, const int &h = 40, + const int& count = 1, + CComponentsForm *parent = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_3, + fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); +// ~CComponentsScrollBar(); //inherited from CComponentsForm + + ///set marked segment, 1st = 0, 2nd = 1 ... + void setMarkID(const int& mark_id){sb_mark_id = mark_id; initSegments();}; + ///get current assigned marked id + int getMarkID(){return sb_mark_id;}; + + ///Sets count of scrollbar segments and is similar e.g. page count. Each segment is assigned to an id. Starting with id 0...n see also setMarkID(), getMarkID(). + void setSegmentCount(const int& segment_count, const int& mark_id = 0); + ///Get count of current scrollbar segments + int getSegmentCount(){return sb_segments_count;} +}; + +#endif diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index 149004cc2..570ae7485 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -360,6 +360,34 @@ void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item) ccw_body->addCCItem(cc_Item); } +void CComponentsWindow::setCurrentPage(const u_int8_t& current_page) +{ + ccw_body->setCurrentPage(current_page); +} + +u_int8_t CComponentsWindow::getCurrentPage() +{ + return ccw_body->getCurrentPage(); +} + +void CComponentsWindow::setScrollBarWidth(const int& scrollbar_width) +{ + ccw_body->setScrollBarWidth(scrollbar_width); +} + +void CComponentsWindow::paintCurPage(bool do_save_bg) +{ + if (is_painted) //ensure that we have painted already the parent form before paint body + ccw_body->paint(do_save_bg); + else + paint(do_save_bg); +} + +void CComponentsWindow::paintPage(const u_int8_t& page_number, bool do_save_bg) +{ + CComponentsWindow::setCurrentPage(page_number); + CComponentsWindow::paintCurPage(do_save_bg); +} void CComponentsWindow::paint(bool do_save_bg) { diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 3875c8015..8d86a9b38 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -183,11 +183,23 @@ class CComponentsWindow : public CComponentsForm ///sets width of sidebars void setWidthSidebar(const int& sidebar_width){ccw_w_sidebar = sidebar_width; initCCWItems();}; + ///sets current page, NOTE: this is simliar with setCurrentPage() known from basic class CComponentsForm, but here it is related only for window body object + void setCurrentPage(const u_int8_t& current_page); + ///get current page, NOTE: this is simliar with getCurrentPage() known from basic class CComponentsForm, but here it is related only for window body object + u_int8_t getCurrentPage(); + + ///paint window body items, this paints only the current page, body = page, current page is definied in body object, see setCurrentPage() + void paintCurPage(bool do_save_bg = CC_SAVE_SCREEN_NO); + ///paint defined page of body, parameter number 0...n + void paintPage(const u_int8_t& page_number, bool do_save_bg = CC_SAVE_SCREEN_NO); + ///set width of body scrollbar + void setScrollBarWidth(const int& scrollbar_width); + ///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); + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; class CComponentsWindowMax : public CComponentsWindow diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 01550c6b6..8a2a1312f 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -49,6 +49,7 @@ CComponentsItem::CComponentsItem(CComponentsForm* parent) cc_item_index = CC_NO_INDEX; cc_item_enabled = true; cc_item_selected = false; + cc_page_number = 0; initParent(parent); } diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index c8f23b386..7d03bcb97 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -33,6 +33,7 @@ class CComponentsForm; +class CComponentsScrollBar; ///cc item types typedef enum @@ -60,6 +61,7 @@ typedef enum CC_ITEMTYPE_BUTTON_YELLOW, CC_ITEMTYPE_BUTTON_BLUE, CC_ITEMTYPE_SLIDER, + CC_ITEMTYPE_FRM_SCROLLBAR, CC_ITEMTYPES }CC_ITEMTYPES_T; diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 25ac66c9b..f70275e0b 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -84,6 +84,7 @@ CTestMenu::CTestMenu() button = NULL; clock = clock_r = NULL; text_ext = NULL; + scrollbar = NULL; } CTestMenu::~CTestMenu() @@ -102,6 +103,7 @@ CTestMenu::~CTestMenu() delete clock_r; delete chnl_pic; delete text_ext; + delete scrollbar; } static int test_pos[4] = { 130, 192, 282, 360 }; @@ -566,6 +568,25 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) footer->hide(); return res; } + else if (actionKey == "scrollbar"){ + if (scrollbar == NULL) + scrollbar = new CComponentsScrollBar(50, 100, 20, 400, 1); + + if (scrollbar->isPainted()){ + if (scrollbar->getMarkID() == scrollbar->getSegmentCount()){ + scrollbar->hide(); + scrollbar->setSegmentCount(scrollbar->getSegmentCount()+1); + } + else{ + scrollbar->setMarkID(scrollbar->getMarkID()+1); + scrollbar->paint(); + } + } + else + scrollbar->paint(); + + return res; + } else if (actionKey == "iconform"){ if (iconform == NULL) iconform = new CComponentsIconForm(); @@ -607,8 +628,9 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) if (window == NULL){ window = new CComponentsWindow(); window->setWindowCaption("|.....................|"); - window->setDimensionsAll(50, 50, 1000, 500); + window->setDimensionsAll(50, 50, 500, 500); window->setWindowIcon(NEUTRINO_ICON_INFO); + window->setShadowOnOff(true); CComponentsShapeCircle *c10 = new CComponentsShapeCircle(0, 0, 28); CComponentsShapeCircle *c11 = new CComponentsShapeCircle(0, CC_APPEND, 28); @@ -618,25 +640,43 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) c11->setColorBody(COL_GREEN); c12->setColorBody(COL_YELLOW); c13->setColorBody(COL_BLUE); - + window->getBodyObject()->setAppendOffset(0,50); window->addWindowItem(c10); window->addWindowItem(c11); window->addWindowItem(c12); window->addWindowItem(c13); + + CComponentsShapeCircle *c14 = new CComponentsShapeCircle(20, 20, 100); + c14->setColorBody(COL_RED); + c14->setPageNumber(1); + window->addWindowItem(c14); } else{ window->setWindowIcon(NEUTRINO_ICON_LOCK); window->setWindowCaption("Test"); } - - - - if (!window->isPainted()) - window->paint(); - else +#if 0 + if (!window->isPainted()){ + window->paint(); //if no other page has been defined, 1st page always painted + } + else{ +#endif //or paint direct a defined page + if (window->getCurrentPage() == 1) + window->paintPage(0); + else + window->paintPage(1); +#if 0 + } +#endif + return res; + } + else if (actionKey == "window_close"){ + if (window){ window->hide(); - + delete window; + window = NULL; + } return res; } else if (actionKey == "running_clock"){ @@ -754,7 +794,9 @@ void CTestMenu::showCCTests(CMenuWidget *widget) widget->addItem(new CMenuForwarder("Footer", true, NULL, this, "footer")); widget->addItem(new CMenuForwarder("Icon-Form", true, NULL, this, "iconform")); widget->addItem(new CMenuForwarder("Window", true, NULL, this, "window")); + widget->addItem(new CMenuForwarder("Window-Close", true, NULL, this, "window_close")); widget->addItem(new CMenuForwarder("Text-Extended", true, NULL, this, "text_ext")); + widget->addItem(new CMenuForwarder("Scrollbar", true, NULL, this, "scrollbar")); } void CTestMenu::showHWTests(CMenuWidget *widget) diff --git a/src/gui/test_menu.h b/src/gui/test_menu.h index ee3693276..e7196d29f 100644 --- a/src/gui/test_menu.h +++ b/src/gui/test_menu.h @@ -53,6 +53,7 @@ class CTestMenu : public CMenuTarget CComponentsFrmClock *clock ,*clock_r; CComponentsChannelLogo* chnl_pic; CComponentsExtTextForm* text_ext; + CComponentsScrollBar* scrollbar; int width, selected; int showTestMenu();