mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponentsWindow: add possibilty to add sidebars in window objects
This allows to add objects in to window on left or right site. eg. for navigation icons or other similar stuff. Default this feature is disabled. to enable with methode enableSidebar(TYPE); With parameter CC_WINDOW_LEFT_SIDEBAR, CC_WINDOW_RIGHT_SIDEBAR or both. Width of sidebar can be changed with methode setWidthSidebar(int)
This commit is contained in:
@@ -32,6 +32,29 @@
|
||||
#include <system/debug.h>
|
||||
using namespace std;
|
||||
|
||||
/*
|
||||
scheme of window object
|
||||
|
||||
+x,y----------------------------------------------------------------+
|
||||
|+-----------------------------------------------------------------+|
|
||||
||header (ccw_head) ||
|
||||
|+---+-------------------------------------------------------+----+||
|
||||
||left |body (ccw_body) |right||
|
||||
||side | |side ||
|
||||
||bar | |bar ||
|
||||
|| | | ||
|
||||
|| | | ||
|
||||
|| | | ||
|
||||
|| | | ||
|
||||
|| | | ||
|
||||
|| | | ||
|
||||
|| | | ||
|
||||
|+-----+-----------------------------------------------------+-----+|
|
||||
||footer (ccw_footer) ||
|
||||
|+-----------------------------------------------------------------+|
|
||||
+-------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//sub class CComponentsWindow inherit from CComponentsForm
|
||||
CComponentsWindow::CComponentsWindow(CComponentsForm *parent)
|
||||
@@ -117,6 +140,8 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
|
||||
col_shadow = color_shadow;
|
||||
|
||||
ccw_head = NULL;
|
||||
ccw_left_sidebar= NULL;
|
||||
ccw_right_sidebar= NULL;
|
||||
ccw_body = NULL;
|
||||
ccw_footer = NULL;
|
||||
|
||||
@@ -124,6 +149,9 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
|
||||
ccw_show_footer = true;
|
||||
ccw_show_header = true;
|
||||
ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK;
|
||||
ccw_show_l_sideber = false;
|
||||
ccw_show_r_sideber = false;
|
||||
ccw_w_sidebar = 40;
|
||||
|
||||
initCCWItems();
|
||||
initParent(parent);
|
||||
@@ -187,6 +215,46 @@ void CComponentsWindow::initFooter()
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsWindow::initLeftSideBar()
|
||||
{
|
||||
if (ccw_left_sidebar== NULL)
|
||||
ccw_left_sidebar = new CComponentsFrmChain();
|
||||
//set side bar properties
|
||||
if (ccw_left_sidebar){
|
||||
ccw_left_sidebar->setCornerType(0);
|
||||
int h_footer = 0;
|
||||
int h_header = 0;
|
||||
if (ccw_footer)
|
||||
h_footer = ccw_footer->getHeight();
|
||||
if (ccw_head)
|
||||
h_header = ccw_head->getHeight();
|
||||
int h_sbar = height - h_header - h_footer - 2*fr_thickness;
|
||||
int w_sbar = ccw_w_sidebar;
|
||||
ccw_left_sidebar->setDimensionsAll(0, CC_APPEND, w_sbar, h_sbar);
|
||||
ccw_left_sidebar->doPaintBg(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsWindow::initRightSideBar()
|
||||
{
|
||||
if (ccw_right_sidebar== NULL)
|
||||
ccw_right_sidebar = new CComponentsFrmChain();
|
||||
//set side bar properties
|
||||
if (ccw_right_sidebar){
|
||||
ccw_right_sidebar->setCornerType(0);
|
||||
int h_footer = 0;
|
||||
int h_header = 0;
|
||||
if (ccw_footer)
|
||||
h_footer = ccw_footer->getHeight();
|
||||
if (ccw_head)
|
||||
h_header = ccw_head->getHeight();
|
||||
int h_sbar = height - h_header - h_footer - 2*fr_thickness;
|
||||
int w_sbar = ccw_w_sidebar;
|
||||
ccw_right_sidebar->setDimensionsAll(width - w_sbar, CC_APPEND, w_sbar, h_sbar);
|
||||
ccw_right_sidebar->doPaintBg(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsWindow::initBody()
|
||||
{
|
||||
if (ccw_body== NULL)
|
||||
@@ -195,14 +263,23 @@ void CComponentsWindow::initBody()
|
||||
//set body properties
|
||||
if (ccw_body){
|
||||
ccw_body->setCornerType(0);
|
||||
int fh = 0;
|
||||
int hh = 0;
|
||||
int h_footer = 0;
|
||||
int h_header = 0;
|
||||
int w_l_sidebar = 0;
|
||||
int w_r_sidebar = 0;
|
||||
if (ccw_footer)
|
||||
fh = ccw_footer->getHeight();
|
||||
h_footer = ccw_footer->getHeight();
|
||||
if (ccw_head)
|
||||
hh = ccw_head->getHeight();
|
||||
int h_body = height - hh - fh - 2*fr_thickness;
|
||||
ccw_body->setDimensionsAll(0, CC_APPEND, width-2*fr_thickness, h_body);
|
||||
h_header = ccw_head->getHeight();
|
||||
if (ccw_left_sidebar)
|
||||
w_l_sidebar = ccw_left_sidebar->getWidth();
|
||||
if (ccw_right_sidebar)
|
||||
w_r_sidebar = ccw_right_sidebar->getWidth();
|
||||
int h_body = height - h_header - h_footer - 2*fr_thickness;
|
||||
int x_body = w_l_sidebar;
|
||||
int w_body = width-2*fr_thickness - w_l_sidebar - w_r_sidebar;
|
||||
|
||||
ccw_body->setDimensionsAll(x_body, CC_APPEND, w_body, h_body);
|
||||
ccw_body->doPaintBg(false);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +307,28 @@ void CComponentsWindow::initCCWItems()
|
||||
ccw_footer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//add/remove left sidebar
|
||||
if (ccw_show_l_sideber){
|
||||
initLeftSideBar();
|
||||
}else{
|
||||
if (ccw_left_sidebar){
|
||||
removeCCItem(ccw_left_sidebar);
|
||||
ccw_left_sidebar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//add/remove right sidebar
|
||||
if (ccw_show_r_sideber){
|
||||
initRightSideBar();
|
||||
}else{
|
||||
if (ccw_right_sidebar){
|
||||
removeCCItem(ccw_right_sidebar);
|
||||
ccw_right_sidebar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//init window body core
|
||||
initBody();
|
||||
|
||||
//add header, body and footer items only one time
|
||||
@@ -244,6 +342,18 @@ void CComponentsWindow::initCCWItems()
|
||||
addCCItem(ccw_footer);
|
||||
}
|
||||
|
||||
void CComponentsWindow::enableSidebar(const int& sidbar_type)
|
||||
{
|
||||
ccw_show_l_sideber = ccw_show_r_sideber = false;
|
||||
|
||||
if (sidbar_type & CC_WINDOW_LEFT_SIDEBAR)
|
||||
ccw_show_l_sideber = true;
|
||||
if (sidbar_type & CC_WINDOW_RIGHT_SIDEBAR)
|
||||
ccw_show_r_sideber = true;
|
||||
|
||||
initCCWItems();
|
||||
}
|
||||
|
||||
void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item)
|
||||
{
|
||||
if (ccw_body)
|
||||
|
Reference in New Issue
Block a user