mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +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)
Origin commit data
------------------
Commit: f21c119517
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-06-01 (Sun, 01 Jun 2014)
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)
|
||||
|
@@ -57,6 +57,10 @@ class CComponentsWindow : public CComponentsForm
|
||||
protected:
|
||||
///object: header object, to get access to header properties see also getHeaderObject()
|
||||
CComponentsHeader * ccw_head;
|
||||
///object: left sidebar chain object, this is a container that contains sidebar items
|
||||
CComponentsFrmChain * ccw_left_sidebar;
|
||||
///object: right sidebar chain object, this is a container that contains sidebar items
|
||||
CComponentsFrmChain * ccw_right_sidebar;
|
||||
///object: body object, this is the container for all needed items, to add with addWindowItem()
|
||||
CComponentsForm * ccw_body;
|
||||
///object: footer object, to get access to header properties see also getFooterObject(
|
||||
@@ -73,9 +77,19 @@ class CComponentsWindow : public CComponentsForm
|
||||
bool ccw_show_footer;
|
||||
///property: value = true, let show header, see showHeader()
|
||||
bool ccw_show_header;
|
||||
///property: value = true, let show left sidebar, see enableSideBar()
|
||||
bool ccw_show_l_sideber;
|
||||
///property: value = true, let show right sidebar, see enableSidebar()
|
||||
bool ccw_show_r_sideber;
|
||||
///width of sidebars
|
||||
int ccw_w_sidebar;
|
||||
|
||||
///initialze header object
|
||||
void initHeader();
|
||||
///initialze left sidebar object
|
||||
void initLeftSideBar();
|
||||
///initialze right sidebar object
|
||||
void initRightSideBar();
|
||||
///initialze body object
|
||||
void initBody();
|
||||
///initialze footer object
|
||||
@@ -132,6 +146,14 @@ class CComponentsWindow : public CComponentsForm
|
||||
///allow/disallow paint a header, default true, see also ccw_show_header, showFooter()
|
||||
void showHeader(bool show = true){ccw_show_header = show; initCCWItems();};
|
||||
|
||||
enum
|
||||
{
|
||||
CC_WINDOW_LEFT_SIDEBAR = 1,
|
||||
CC_WINDOW_RIGHT_SIDEBAR = 2
|
||||
};
|
||||
///allow/disallow paint a sidebar, default are enabled
|
||||
void enableSidebar(const int& sidbar_type = CC_WINDOW_LEFT_SIDEBAR | CC_WINDOW_RIGHT_SIDEBAR);
|
||||
|
||||
///set caption in header with string, see also getHeaderObject()
|
||||
void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;};
|
||||
|
||||
@@ -141,7 +163,7 @@ class CComponentsWindow : public CComponentsForm
|
||||
void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;};
|
||||
|
||||
///set icon name in header, see also getHeaderObject()
|
||||
void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname;};
|
||||
void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname; initHeader();};
|
||||
|
||||
///set default header icon buttons, see also getHeaderObject()
|
||||
void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;};
|
||||
@@ -154,6 +176,13 @@ class CComponentsWindow : public CComponentsForm
|
||||
///returns a pointer to the internal footer object, use this to get access to footer properities
|
||||
CComponentsFooter* getFooterObject(){return ccw_footer;};
|
||||
|
||||
///returns a pointer to the internal left side bar object, use this to get access to left sidebar properities
|
||||
CComponentsFrmChain* getLeftSidebarObject(){return ccw_left_sidebar;};
|
||||
///returns a pointer to the internal right side bar object, use this to get access to right sidebar properities
|
||||
CComponentsFrmChain* getRightSidebarObject(){return ccw_right_sidebar;};
|
||||
|
||||
void setWidthSidebar(const int& sidebar_width){ccw_w_sidebar = sidebar_width; initCCWItems();};
|
||||
|
||||
///refresh position and dimension and reinitialize elemenatary properties
|
||||
void Refresh(){initCCWItems();};
|
||||
|
||||
|
Reference in New Issue
Block a user