mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
CComponents: split cc_base.cpp
It's easier to work with smaller files. Most files contain only one cc-class and their names are derived on the particular class that is contained therein.
This commit is contained in:
153
src/gui/components/cc_item.cpp
Normal file
153
src/gui/components/cc_item.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
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 <config.h>
|
||||
#endif
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//abstract sub class CComponentsItem from CComponents
|
||||
CComponentsItem::CComponentsItem()
|
||||
{
|
||||
//CComponentsItem
|
||||
initVarItem();
|
||||
cc_item_type = CC_ITEMTYPE_BASE;
|
||||
}
|
||||
|
||||
// y
|
||||
// x+------f-r-a-m-e-------+
|
||||
// | |
|
||||
// height body |
|
||||
// | |
|
||||
// +--------width---------+
|
||||
|
||||
void CComponentsItem::initVarItem()
|
||||
{
|
||||
//CComponents
|
||||
initVarBasic();
|
||||
cc_item_index = CC_NO_INDEX;
|
||||
}
|
||||
|
||||
// Paint container background in cc-items with shadow, background and frame.
|
||||
// This member must be called first in all paint() members before paint other items into the container.
|
||||
// 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();
|
||||
|
||||
if(!paint_bg)
|
||||
return;
|
||||
|
||||
int sw = shadow ? shadow_w : 0;
|
||||
int th = fr_thickness;
|
||||
|
||||
comp_fbdata_t fbdata[] =
|
||||
{
|
||||
{CC_FBDATA_TYPE_BGSCREEN, x, y, width+sw, height+sw, 0, 0, 0, NULL, NULL},
|
||||
{CC_FBDATA_TYPE_SHADOW, x+sw, y+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL},
|
||||
{CC_FBDATA_TYPE_FRAME, x, y, width, height, col_frame, corner_rad, th, NULL, NULL},
|
||||
{CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, corner_rad-th, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++)
|
||||
v_fbdata.push_back(fbdata[i]);
|
||||
#ifdef DEBUG_CC
|
||||
printf("[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __FUNCTION__, cc_item_type, cc_item_index, height, width);
|
||||
#endif
|
||||
paintFbItems(do_save_bg);
|
||||
}
|
||||
|
||||
//restore last saved screen behind form box,
|
||||
//Do use parameter 'no restore' to override temporarly the restore funtionality.
|
||||
//This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents.
|
||||
void CComponentsItem::hideCCItem(bool no_restore)
|
||||
{
|
||||
is_painted = false;
|
||||
|
||||
if (saved_screen.pixbuf) {
|
||||
frameBuffer->RestoreScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy, saved_screen.pixbuf);
|
||||
if (no_restore) {
|
||||
delete[] saved_screen.pixbuf;
|
||||
saved_screen.pixbuf = NULL;
|
||||
firstPaint = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsItem::hide(bool no_restore)
|
||||
{
|
||||
hideCCItem(no_restore);
|
||||
}
|
||||
|
||||
|
||||
//hide rendered objects
|
||||
void CComponentsItem::kill()
|
||||
{
|
||||
//save current colors
|
||||
fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
|
||||
c_tmp1 = col_body;
|
||||
c_tmp2 = col_shadow;
|
||||
c_tmp3 = col_frame;
|
||||
|
||||
//set background color
|
||||
col_body = col_frame = col_shadow = COL_BACKGROUND;
|
||||
|
||||
//paint with background and restore last used colors
|
||||
paint(CC_SAVE_SCREEN_NO);
|
||||
col_body = c_tmp1;
|
||||
col_shadow = c_tmp2;
|
||||
col_frame = c_tmp3;
|
||||
firstPaint = true;
|
||||
is_painted = false;
|
||||
}
|
||||
|
||||
//synchronize colors for forms
|
||||
//This is usefull if the system colors are changed during runtime
|
||||
//so you can ensure correct applied system colors in relevant objects with unchanged instances.
|
||||
void CComponentsItem::syncSysColors()
|
||||
{
|
||||
col_body = COL_MENUCONTENT_PLUS_0;
|
||||
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
|
||||
col_frame = COL_MENUCONTENT_PLUS_6;
|
||||
}
|
||||
|
||||
//returns current item element type, if no available, return -1 as unknown type
|
||||
int CComponentsItem::getItemType()
|
||||
{
|
||||
for(int i =0; i< (CC_ITEMTYPES) ;i++){
|
||||
if (i == cc_item_type)
|
||||
return i;
|
||||
}
|
||||
#ifdef DEBUG_CC
|
||||
printf("[CComponentsItem] %s: unknown item type requested...\n", __FUNCTION__);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
Reference in New Issue
Block a user