/* 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, Michael Liebmann 'micha-bbg' License: GPL This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; 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.h" using namespace std; //------------------------------------------------------------------------------------------------------- //sub class CComponentsForm from CComponentsItem CComponentsForm::CComponentsForm() { //CComponentsForm initVarForm(); } CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { //CComponentsForm initVarForm(); //CComponents 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; } CComponentsForm::~CComponentsForm() { cleanCCForm(); } void CComponentsForm::cleanCCForm() { #ifdef DEBUG_CC printf("[CComponents] calling %s...\n", __FUNCTION__); #endif hide(); clearSavedScreen(); clearCCItems(); clear(); } void CComponentsForm::clearCCItems() { if (v_cc_items.empty()) return; #ifdef DEBUG_CC printf("[CComponentsForm] %s... cleanup %d form cc-items\n", __FUNCTION__, v_cc_items.size()); #endif for(size_t i=0; igetDimensions(&x_item, &y_item, &w_item, &h_item); int xy_ref = 0+fr_thickness; //allowed minimal x and y start position if (x_item < xy_ref){ #ifdef DEBUG_CC printf("[CComponentsForm] %s: item %d position is out of form dimensions\ndefinied x=%d\nallowed x>=%d\n", __FUNCTION__, i, x_item, xy_ref); #endif x_item = xy_ref; } if (y_item < xy_ref){ #ifdef DEBUG_CC printf("[CComponentsForm] %s: item %d position is out of form dimensions\ndefinied y=%d\nallowed y>=%d\n", __FUNCTION__, i, y_item, xy_ref); #endif y_item = xy_ref; } //set adapted position onto form v_cc_items[i]->setXPos(x_frm_left+x_item); v_cc_items[i]->setYPos(y_frm_top+y_item); //watch horizontal x dimensions of items int x_item_right = v_cc_items[i]->getXPos()+w_item; //right item border if (x_item_right > x_frm_right){ v_cc_items[i]->setWidth(w_item-(x_item_right-x_frm_right)); #ifdef DEBUG_CC printf("[CComponentsForm] %s: item %d too large, definied width=%d, possible width=%d \n", __FUNCTION__, i, w_item, v_cc_items[i]->getWidth()); #endif } //watch vertical y dimensions int y_item_bottom = v_cc_items[i]->getYPos()+h_item; //bottom item border if (y_item_bottom > y_frm_bottom){ v_cc_items[i]->setHeight(h_item-(y_item_bottom-y_frm_bottom)); #ifdef DEBUG_CC printf("[CComponentsForm] %s: item %d too large, definied height=%d, possible height=%d \n", __FUNCTION__, i, h_item, v_cc_items[i]->getHeight()); #endif } //paint element without saved screen! v_cc_items[i]->paint(CC_SAVE_SCREEN_NO); //restore dimensions and position v_cc_items[i]->setDimensionsAll(x_item, y_item, w_item, h_item); } } void CComponentsForm::hide(bool no_restore) { //hide body hideCCItem(no_restore); }