Merge branch 'check/next-cc'

Compiles on most platforms, starts. Not really tested.
This commit is contained in:
Stefan Seyfried
2013-11-10 16:55:53 +01:00
114 changed files with 7292 additions and 1585 deletions

View File

@@ -3,7 +3,7 @@
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
Copyright (C) 2013, Thilo Graf 'dbt'
License: GPL
@@ -23,255 +23,30 @@
Boston, MA 02110-1301, USA.
*/
#ifndef __COMPONENTS__
#define __COMPONENTS__
#include "cc_types.h"
#include <gui/widget/textbox.h>
#include <vector>
#include <string>
#include <driver/pictureviewer/pictureviewer.h>
//#define DEBUG_CC
/// Basic component class.
/// Basic CComponent class header.
/*!
Basic attributes and member functions for component sub classes
*/
class CComponents
{
private:
///pixel buffer handling, returns pixel buffer depends of given parameters
fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
protected:
///object: framebuffer object, usable in all sub classes
CFrameBuffer * frameBuffer;
///container: for frambuffer properties and pixel buffer
std::vector<comp_fbdata_t> v_fbdata;
#ifndef __N_COMPONENTS__
#define __N_COMPONENTS__
///property: x-position on screen, to alter with setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
int x;
///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
int y;
///property: contains real x-position on screen
int cc_xr;
///property: contains real y-position on screen
int cc_yr;
///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll()
int height;
///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll()
int width;
///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
int corner_type;
///property: defined radius of corner, without effect, if corner_type=0
int corner_rad;
///property: color of body
fb_pixel_t col_body;
///property: color of shadow
fb_pixel_t col_shadow;
///property: color of frame
fb_pixel_t col_frame;
///property: color of frame if component is selected, Note: fr_thickness_sel must be set
fb_pixel_t col_frame_sel;
#include "cc_base.h"
#include "cc_types.h"
///property: true=component has shadow
bool shadow;
///property: width of shadow
int shadow_w;
#include "cc_item_infobox.h"
#include "cc_item_picture.h"
#include "cc_item_progressbar.h"
#include "cc_item_shapes.h"
#include "cc_item_tvpic.h"
///property: frame thickness
int fr_thickness;
///property: frame thickness of selected component
int fr_thickness_sel;
#include "cc_detailsline.h"
///status: true=component was painted for 1st time
bool firstPaint;
///status: true=component was rendered
bool is_painted;
///mode: true=activate rendering of basic elements (frame, shadow and body)
bool paint_bg;
#include "cc_frm.h"
#include "cc_frm_button.h"
#include "cc_frm_clock.h"
#include "cc_frm_signalbars.h"
///initialize of basic attributes, no parameters required
void initVarBasic();
///rendering of framebuffer elements at once,
///elements are contained in v_fbdata, presumes added frambuffer elements with paintInit(),
///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
void paintFbItems(bool do_save_bg = true);
///clean up old screen buffer saved in v_fbdata
virtual void clear();
///container: contains saved pixel buffer with position and dimensions
comp_screen_data_t saved_screen;
///cleans saved pixel buffer
void clearSavedScreen();
public:
///basic component class constructor.
CComponents();
virtual~CComponents();
///set screen x-position
inline virtual void setXPos(const int& xpos){x = xpos;};
///set screen y-position,
inline virtual void setYPos(const int& ypos){y = ypos;};
///set x and y position
///Note: position of bound components (items) means position related within parent form, not for screen!
///to set the real screen position, look at setRealPos()
inline virtual void setPos(const int& xpos, const int& ypos){x = xpos; y = ypos;};
///sets real x position on screen. Use this, if item is added to a parent form
virtual void setRealXPos(const int& xr){cc_xr = xr;};
///sets real y position on screen. Use this, if item is added to a parent form
virtual void setRealYPos(const int& yr){cc_yr = yr;};
///sets real x and y position on screen at once. Use this, if item is added to a parent form
virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;};
///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
virtual int getRealXPos(){return cc_xr;};
///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
virtual int getRealYPos(){return cc_yr;};
///set height of component on screen
inline virtual void setHeight(const int& h){height = h;};
///set width of component on screen
inline virtual void setWidth(const int& w){width = w;};
///set all positions and dimensions of component at once
inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
///return screen x-position of component
///Note: position of bound components (items) means position related within parent form, not for screen!
///to get the real screen position, use getRealXPos(), to find in CComponentsItem sub classes
inline virtual int getXPos(){return x;};
///return screen y-position of component
///Note: position of bound components (items) means position related within parent form, not for screen!
///to get the real screen position, use getRealYPos(), to find in CComponentsItem sub classes
inline virtual int getYPos(){return y;};
///return height of component
inline virtual int getHeight(){return height;};
///return width of component
inline virtual int getWidth(){return width;};
///return of frame thickness
inline virtual int getFrameThickness(){return fr_thickness;};
///return/set (pass through) width and height of component
inline virtual void getSize(int* w, int* h){*w=width; *h=height;};
///return/set (pass through) position and dimensions of component at once
inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
///set frame color
inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
///set body color
inline virtual void setColorBody(fb_pixel_t color){col_body = color;};
///set shadow color
inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
///set all basic framebuffer element colors at once
///Note: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
///get frame color
inline virtual fb_pixel_t getColorFrame(){return col_frame;};
///get body color
inline virtual fb_pixel_t getColorBody(){return col_body;};
///get shadow color
inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
///set corner types
///Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h)
///Note: default values are given from settings
inline virtual void setCornerType(const int& type){corner_type = type;};
///set corner radius and type
inline virtual void setCorner(const int& radius, const int& type = CORNER_ALL){corner_rad = radius; corner_type = type;};
///get corner types
inline virtual int getCornerType(){return corner_type;};
///get corner radius
inline virtual int getCornerRadius(){return corner_rad;};
///set frame thickness
inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
///switch shadow on/off
///Note: it's recommended to use #defines: CC_SHADOW_ON=true or CC_SHADOW_OFF=false as parameter, see also cc_types.h
inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
///hide current screen and restore background
virtual void hide();
///erase current screen without restore of background, it's similar to paintBackgroundBoxRel() from CFrameBuffer
virtual void kill();
///returns paint mode, true=item was painted
virtual bool isPainted(){return is_painted;}
///allows paint of elementary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
};
class CComponentsItem : public CComponents
{
protected:
///property: define of item type, see cc_types.h for possible types
int cc_item_type;
///property: define of item index, all bound items get an index,
///default: CC_NO_INDEX as identifer for not embedded item and default index=0 for form as main parent
///see also getIndex(), setIndex()
int cc_item_index;
///property: default enabled
bool cc_item_enabled;
///property: default not selected
bool cc_item_selected;
///Pointer to the form object in which this item is embedded.
///Is typically the type CComponentsForm or derived classes, default intialized with NULL
CComponentsItem *cc_parent;
///hides item, arg: no_restore=true causes no restore of background, but clean up pixel buffer if required
void hideCCItem(bool no_restore = false);
///initialze of basic framebuffer elements with shadow, background and frame.
///must be called first in all paint() members before paint any item,
///If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
///arg do_save_bg=false avoids using of unnecessary pixel memory, eg. if no hide with restore is provided. This is mostly the case whenever
///an item will be hide or overpainted with other methods, or it's embedded (bound) in a parent form.
void paintInit(bool do_save_bg);
///initialize all required attributes
void initVarItem();
public:
CComponentsItem();
///sets pointer to the form object in which this item is embedded.
virtual void setParent(CComponentsItem *parent){cc_parent = parent;};
///returns pointer to the form object in which this item is embedded.
virtual CComponentsItem * getParent(){return cc_parent;};
///property: returns true if item is added to a form
virtual bool isAdded();
///abstract: paint item, arg: do_save_bg see paintInit() above
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
///hides item, arg: no_restore see hideCCItem() above
virtual void hide(bool no_restore = false);
///get the current item type, see attribute cc_item_type above
virtual int getItemType();
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
virtual void syncSysColors();
///set select mode, see also col_frame_sel
virtual void setSelected(bool selected){cc_item_selected = selected;};
///set enable mode, see also cc_item_enabled
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
///get select mode, see also setSelected() above
virtual bool isSelected(){return cc_item_selected;};
///get enable mode, see also setEnable() above
virtual bool isEnabled(){return cc_item_enabled;};
///get current index of item, see also attribut cc_item_index
virtual int getIndex(){return cc_item_index;};
///set an index to item, see also attribut cc_item_index.
///To generate an index, use genIndex()
virtual void setIndex(const int& index){cc_item_index = index;};
};
#endif
#endif /*__N_COMPONENTS__*/

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_base.h"
using namespace std;

View File

@@ -0,0 +1,278 @@
/*
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'
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, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __COMPONENTS__
#define __COMPONENTS__
#include "cc_types.h"
#include <gui/widget/textbox.h>
#include <vector>
#include <string>
#include <driver/pictureviewer/pictureviewer.h>
#include <gui/widget/icons.h>
//#define DEBUG_CC
/// Basic component class.
/*!
Basic attributes and member functions for component sub classes
*/
class CComponents
{
private:
///pixel buffer handling, returns pixel buffer depends of given parameters
fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
protected:
///object: framebuffer object, usable in all sub classes
CFrameBuffer * frameBuffer;
///container: for frambuffer properties and pixel buffer
std::vector<comp_fbdata_t> v_fbdata;
///property: x-position on screen, to alter with setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
int x;
///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
int y;
///property: contains real x-position on screen
int cc_xr;
///property: contains real y-position on screen
int cc_yr;
///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll()
int height;
///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll()
int width;
///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
int corner_type;
///property: defined radius of corner, without effect, if corner_type=0
int corner_rad;
///property: color of body
fb_pixel_t col_body;
///property: color of shadow
fb_pixel_t col_shadow;
///property: color of frame
fb_pixel_t col_frame;
///property: color of frame if component is selected, Note: fr_thickness_sel must be set
fb_pixel_t col_frame_sel;
///property: true=component has shadow
bool shadow;
///property: width of shadow
int shadow_w;
///property: frame thickness
int fr_thickness;
///property: frame thickness of selected component
int fr_thickness_sel;
///status: true=component was painted for 1st time
bool firstPaint;
///status: true=component was rendered
bool is_painted;
///mode: true=activate rendering of basic elements (frame, shadow and body)
bool paint_bg;
///initialize of basic attributes, no parameters required
void initVarBasic();
///rendering of framebuffer elements at once,
///elements are contained in v_fbdata, presumes added frambuffer elements with paintInit(),
///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
void paintFbItems(bool do_save_bg = true);
///clean up old screen buffer saved in v_fbdata
virtual void clear();
///container: contains saved pixel buffer with position and dimensions
comp_screen_data_t saved_screen;
///cleans saved pixel buffer
void clearSavedScreen();
public:
///basic component class constructor.
CComponents();
virtual~CComponents();
///set screen x-position
inline virtual void setXPos(const int& xpos){x = xpos;};
///set screen y-position,
inline virtual void setYPos(const int& ypos){y = ypos;};
///set x and y position
///Note: position of bound components (items) means position related within parent form, not for screen!
///to set the real screen position, look at setRealPos()
inline virtual void setPos(const int& xpos, const int& ypos){x = xpos; y = ypos;};
///sets real x position on screen. Use this, if item is added to a parent form
virtual void setRealXPos(const int& xr){cc_xr = xr;};
///sets real y position on screen. Use this, if item is added to a parent form
virtual void setRealYPos(const int& yr){cc_yr = yr;};
///sets real x and y position on screen at once. Use this, if item is added to a parent form
virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;};
///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
virtual int getRealXPos(){return cc_xr;};
///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
virtual int getRealYPos(){return cc_yr;};
///set height of component on screen
inline virtual void setHeight(const int& h){height = h;};
///set width of component on screen
inline virtual void setWidth(const int& w){width = w;};
///set all positions and dimensions of component at once
inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
///return screen x-position of component
///Note: position of bound components (items) means position related within parent form, not for screen!
///to get the real screen position, use getRealXPos(), to find in CComponentsItem sub classes
inline virtual int getXPos(){return x;};
///return screen y-position of component
///Note: position of bound components (items) means position related within parent form, not for screen!
///to get the real screen position, use getRealYPos(), to find in CComponentsItem sub classes
inline virtual int getYPos(){return y;};
///return height of component
inline virtual int getHeight(){return height;};
///return width of component
inline virtual int getWidth(){return width;};
///return of frame thickness
inline virtual int getFrameThickness(){return fr_thickness;};
///return/set (pass through) width and height of component
inline virtual void getSize(int* w, int* h){*w=width; *h=height;};
///return/set (pass through) position and dimensions of component at once
inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
///set frame color
inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
///set body color
inline virtual void setColorBody(fb_pixel_t color){col_body = color;};
///set shadow color
inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
///set all basic framebuffer element colors at once
///Note: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
///get frame color
inline virtual fb_pixel_t getColorFrame(){return col_frame;};
///get body color
inline virtual fb_pixel_t getColorBody(){return col_body;};
///get shadow color
inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
///set corner types
///Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h)
///Note: default values are given from settings
inline virtual void setCornerType(const int& type){corner_type = type;};
///set corner radius and type
inline virtual void setCorner(const int& radius, const int& type = CORNER_ALL){corner_rad = radius; corner_type = type;};
///get corner types
inline virtual int getCornerType(){return corner_type;};
///get corner radius
inline virtual int getCornerRadius(){return corner_rad;};
///set frame thickness
inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
///switch shadow on/off
///Note: it's recommended to use #defines: CC_SHADOW_ON=true or CC_SHADOW_OFF=false as parameter, see also cc_types.h
inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
///hide current screen and restore background
virtual void hide();
///erase current screen without restore of background, it's similar to paintBackgroundBoxRel() from CFrameBuffer
virtual void kill();
///returns paint mode, true=item was painted
virtual bool isPainted(){return is_painted;}
///allows paint of elementary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
};
class CComponentsItem : public CComponents
{
protected:
///property: define of item type, see cc_types.h for possible types
int cc_item_type;
///property: define of item index, all bound items get an index,
///default: CC_NO_INDEX as identifer for not embedded item and default index=0 for form as main parent
///see also getIndex(), setIndex()
int cc_item_index;
///property: default enabled
bool cc_item_enabled;
///property: default not selected
bool cc_item_selected;
///Pointer to the form object in which this item is embedded.
///Is typically the type CComponentsForm or derived classes, default intialized with NULL
CComponentsItem *cc_parent;
///hides item, arg: no_restore=true causes no restore of background, but clean up pixel buffer if required
void hideCCItem(bool no_restore = false);
///initialze of basic framebuffer elements with shadow, background and frame.
///must be called first in all paint() members before paint any item,
///If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
///arg do_save_bg=false avoids using of unnecessary pixel memory, eg. if no hide with restore is provided. This is mostly the case whenever
///an item will be hide or overpainted with other methods, or it's embedded (bound) in a parent form.
void paintInit(bool do_save_bg);
///initialize all required attributes
void initVarItem();
public:
CComponentsItem();
///sets pointer to the form object in which this item is embedded.
virtual void setParent(CComponentsItem *parent){cc_parent = parent;};
///returns pointer to the form object in which this item is embedded.
virtual CComponentsItem * getParent(){return cc_parent;};
///property: returns true if item is added to a form
virtual bool isAdded();
///abstract: paint item, arg: do_save_bg see paintInit() above
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
///hides item, arg: no_restore see hideCCItem() above
virtual void hide(bool no_restore = false);
///get the current item type, see attribute cc_item_type above
virtual int getItemType();
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
virtual void syncSysColors();
///set select mode, see also col_frame_sel
virtual void setSelected(bool selected){cc_item_selected = selected;};
///set enable mode, see also cc_item_enabled
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
///get select mode, see also setSelected() above
virtual bool isSelected(){return cc_item_selected;};
///get enable mode, see also setEnable() above
virtual bool isEnabled(){return cc_item_enabled;};
///get current index of item, see also attribut cc_item_index
virtual int getIndex(){return cc_item_index;};
///set an index to item, see also attribut cc_item_index.
///To generate an index, use genIndex()
virtual void setIndex(const int& index){cc_item_index = index;};
};
#endif

View File

@@ -30,7 +30,7 @@
#include <config.h>
#endif
#include "cc.h"
#include "cc_base.h"
//! Sub class of CComponents. Shows a connectline with given dimensions and color on screen.
/*!

View File

@@ -28,7 +28,7 @@
#include "config.h"
#include <gui/components/cc.h>
#include <gui/components/cc_base.h>
#include <gui/components/cc_item_text.h>
#include <gui/components/cc_item_picture.h>
#include <vector>
@@ -123,6 +123,7 @@ class CComponentsHeader : public CComponentsForm
int cch_items_y, cch_icon_x, cch_icon_w, cch_text_x, cch_buttons, cch_buttons_w, cch_buttons_h, cch_buttons_space, cch_offset;
std::vector<std::string> v_cch_btn;
int cch_size_mode;
int cch_caption_align;
void initIcon();
void initCaption();
@@ -162,8 +163,9 @@ class CComponentsHeader : public CComponentsForm
virtual ~CComponentsHeader();
virtual void setCaption(const std::string& caption);
virtual void setCaption(neutrino_locale_t caption_locale);
virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;};
virtual void setCaptionFont(Font* font_name);
virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;};
virtual void setOffset(const int offset){cch_offset = offset;};
@@ -174,7 +176,7 @@ class CComponentsHeader : public CComponentsForm
virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;};
virtual void initCCItems();
virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;};
virtual CComponentsText* getTextObject(){return cch_text_obj;};
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
@@ -225,12 +227,16 @@ class CComponentsWindow : public CComponentsForm
CComponentsFooter * ccw_footer;
///property: caption in header, see also getHeaderObject()
std::string ccw_caption;
///property: alignment mode for header caption
int ccw_align_mode;
///property: icon name in header, see also getHeaderObject()
const char* ccw_icon_name;
///property: assigned default icon buttons in header, see also getHeaderObject()
int ccw_buttons;
///property: value = true, let show footer
///property: value = true, let show footer, see showFooter()
bool ccw_show_footer;
///property: value = true, let show header, see showHeader()
bool ccw_show_header;
///initialze header object
void initHeader();
@@ -285,14 +291,18 @@ class CComponentsWindow : public CComponentsForm
///add item to body object, also usable is addCCItem() to add items to the windo object
void addWindowItem(CComponentsItem* cc_Item);
///
///allow/disallow paint a footer, default true, see also ccw_show_footer, showHeader()
void showFooter(bool show = true){ccw_show_footer = show;};
///allow/disallow paint a header, default true, see also ccw_show_header, showFooter()
void showHeader(bool show = true){ccw_show_header = show;};
///set caption in header with string, see also getHeaderObject()
void setWindowCaption(const std::string& text){ccw_caption = text;};
void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;};
///set caption in header from locales, see also getHeaderObject()
void setWindowCaption(neutrino_locale_t locale_text);
void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
///set caption alignment
void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;};
///set icon name in header, see also getHeaderObject()
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
@@ -305,7 +315,6 @@ class CComponentsWindow : public CComponentsForm
///returns a pointer to the internal body object, use this to get access to body properities
CComponentsForm* getBodyObject(){return ccw_body;};
///returns a pointer to the internal footer object, use this to get access to footer properities
CComponentsFooter* getFooterObject(){return ccw_footer;};

View File

@@ -27,7 +27,7 @@
#define __CC_BUTTONS_H__
#include <config.h>
#include "cc.h"
#include "cc_base.h"
#include "cc_frm.h"
#include <string>
#include <driver/neutrinofonts.h>

View File

@@ -31,7 +31,7 @@
#include <config.h>
#endif
#include "cc.h"
#include "cc_base.h"
#include "cc_frm.h"

View File

@@ -109,6 +109,7 @@ void CComponentsHeader::initVarHeader()
cch_btn_obj = NULL;
cch_text = "";
cch_col_text = COL_MENUHEAD_TEXT;
cch_caption_align = CTextBox::NO_AUTO_LINEBREAK;
cch_items_y = 0;
cch_offset = 8;
cch_icon_x = cch_offset;
@@ -130,14 +131,16 @@ CComponentsHeader::~CComponentsHeader()
cleanCCForm();
}
void CComponentsHeader::setCaption(const std::string& caption)
void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode)
{
cch_text = caption;
cch_text = caption;
cch_caption_align = align_mode;
}
void CComponentsHeader::setCaption(neutrino_locale_t caption_locale)
void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int& align_mode)
{
cch_text = g_Locale->getText(caption_locale);
cch_text = g_Locale->getText(caption_locale);
cch_caption_align = align_mode;
}
void CComponentsHeader::setCaptionFont(Font* font_name)
@@ -168,10 +171,12 @@ void CComponentsHeader::initIcon()
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __FUNCTION__, __LINE__, cch_icon_name);
#endif
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name);
//add item only one time
addCCItem(cch_icon_obj); //icon
}
//add item only one time
if (!cch_icon_obj->isAdded())
addCCItem(cch_icon_obj); //icon
//get dimensions of header icon
int iw, ih;
frameBuffer->getIconSize(cch_icon_name, &iw, &ih);
@@ -242,6 +247,10 @@ void CComponentsHeader::initButtonFormSize()
{
cch_buttons_w = 0;
cch_buttons_h = 0;
if (cch_btn_obj == NULL)
return;
for(size_t i=0; i<v_cch_btn.size(); i++){
int bw, bh;
frameBuffer->getIconSize(v_cch_btn[i].c_str(), &bw, &bh);
@@ -254,9 +263,13 @@ void CComponentsHeader::initButtonFormSize()
void CComponentsHeader::initButtons()
{
//exit if no button defined
if (v_cch_btn.empty())
if (v_cch_btn.empty()){
if (cch_btn_obj)
delete cch_btn_obj;
cch_btn_obj = NULL;
return;
}
initButtonFormSize();
if (cch_btn_obj == NULL){
@@ -264,10 +277,12 @@ void CComponentsHeader::initButtons()
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header buttons...\n", __FUNCTION__, __LINE__);
#endif
//add button form
addCCItem(cch_btn_obj); //buttons
}
//add button form only one time
if (!cch_btn_obj->isAdded())
addCCItem(cch_btn_obj); //buttons
//set button form properties
if (cch_btn_obj){
cch_btn_obj->setDimensionsAll(width-cch_offset-cch_buttons_w, cch_items_y, cch_buttons_w, cch_buttons_h);
@@ -300,12 +315,13 @@ void CComponentsHeader::initButtons()
void CComponentsHeader::initCaption()
{
//recalc header text position if header icon is defined
int cc_text_w = 0;
if (cch_icon_name != NULL){
cch_text_x = cch_icon_x+cch_icon_w+cch_offset;
}
//calc width of text object in header
int cc_text_w = width-cch_text_x-cch_offset;
cc_text_w = width-cch_text_x-cch_offset;
if (cch_buttons_w)
cc_text_w -= cch_buttons_w-cch_offset;
@@ -315,15 +331,20 @@ void CComponentsHeader::initCaption()
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s [ x %d w %d ]\n", __FUNCTION__, __LINE__, cch_text.c_str(), cch_text_x, cc_text_w);
#endif
cch_text_obj = new CComponentsText();
//add text item
addCCItem(cch_text_obj); //text
}
//add text item
if (!cch_text_obj->isAdded())
addCCItem(cch_text_obj); //text
//set header text properties
if (cch_text_obj){
//set alignment of text item in dependency from text alignment
if (cch_caption_align == CTextBox::CENTER)
cch_text_x = CC_CENTERED;
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
cch_text_obj->doPaintBg(false);
cch_text_obj->setText(cch_text, CTextBox::TOP | CTextBox::NO_AUTO_LINEBREAK, cch_font);
cch_text_obj->setText(cch_text, cch_caption_align, cch_font);
cch_text_obj->forceTextPaint(); //here required
cch_text_obj->setTextColor(cch_col_text);
cch_text_obj->setColorBody(col_body);

View File

@@ -31,8 +31,8 @@
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
// #include <global.h>
// #include <neutrino.h>
#include <gui/components/cc_frm.h>
#include <gui/components/cc_item_progressbar.h>
#include <gui/components/cc_item_text.h>

View File

@@ -141,13 +141,16 @@ void CComponentsWindow::initVarWindow()
ccw_icon_name = NULL;
ccw_buttons = 0; //no header buttons
ccw_show_footer = true;
ccw_show_header = true;
ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK;
setShadowOnOff(true);
}
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text)
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
{
ccw_caption = g_Locale->getText(locale_text);
ccw_align_mode = align_mode;
}
void CComponentsWindow::initHeader()
@@ -158,12 +161,12 @@ void CComponentsWindow::initHeader()
//add of header item happens initCCWItems()
}
//set header properties
//set header properties //TODO: assigned properties with internal header objekt have no effect!
if (ccw_head){
ccw_head->setPos(0, 0);
ccw_head->setWidth(width-2*fr_thickness);
// ccw_head->setPos(0, 0);
ccw_head->setIcon(ccw_icon_name);
ccw_head->setCaption(ccw_caption);
ccw_head->setCaption(ccw_caption, ccw_align_mode);
ccw_head->initCCItems();
ccw_head->setDefaultButtons(ccw_buttons);
}
@@ -181,9 +184,11 @@ void CComponentsWindow::initBody()
if (ccw_body){
ccw_body->setCornerType(0);
int fh = 0;
int hh = 0;
if (ccw_footer)
fh = ccw_footer->getHeight();
int hh = ccw_head->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);
ccw_body->doPaintBg(false);
@@ -193,7 +198,6 @@ void CComponentsWindow::initBody()
void CComponentsWindow::initFooter()
{
if (ccw_footer== NULL){
ccw_footer= new CComponentsFooter();
initFooter();
//add of footer item happens initCCWItems()
@@ -218,22 +222,31 @@ void CComponentsWindow::initCCWItems()
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] init items...\n", __FUNCTION__, __LINE__);
#endif
initHeader();
//add header if required
if (ccw_show_header){
initHeader();
}else{
if (ccw_head){
removeCCItem(ccw_head);
ccw_head = NULL;
}
}
//add footer if required
if (ccw_show_footer){
initFooter();
}else{
if (ccw_footer != NULL){
if (ccw_footer){
removeCCItem(ccw_footer);
ccw_footer = NULL;
}
}
initBody();
//add header, body and footer items only one time
if (!ccw_head->isAdded())
addCCItem(ccw_head);
if (ccw_head)
if (!ccw_head->isAdded())
addCCItem(ccw_head);
if (!ccw_body->isAdded())
addCCItem(ccw_body);
if (ccw_footer)

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_base.h"
using namespace std;

View File

@@ -31,7 +31,7 @@
#include <config.h>
#endif
#include "cc.h"
#include "cc_base.h"
#include <string>
#include <driver/pictureviewer/pictureviewer.h>

View File

@@ -50,7 +50,7 @@
#define __CC_PROGRESSBAR_H__
#include "config.h"
#include <gui/components/cc.h>
#include <gui/components/cc_base.h>
#include <string>
class CProgressBar : public CComponentsItem

View File

@@ -30,7 +30,7 @@
#include <config.h>
#endif
#include "cc.h"
#include "cc_base.h"
//! Sub class of CComponentsItem. Shows a shape with given dimensions and color on screen.
/*!

View File

@@ -273,3 +273,18 @@ string CComponentsText::iToString(int int_val)
string i_string(i_str.str());
return i_string;
}
//helper, get lines per textbox page
int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode)
{
CComponentsText box;
box.iX = 0;
box.iY = 0;
box.iWidth = textWidth;
box.iHeight = textMaxHeight;
CTextBox tb(ct_text.c_str(), ct_font, mode, &box);
int ret = tb.getLinesPerPage();
return ret;
}

View File

@@ -26,7 +26,7 @@
#ifndef __CC_ITEM_TEXT_H__
#define __CC_ITEM_TEXT_H__
#include "cc.h"
#include "cc_base.h"
#include <gui/widget/textbox.h>
#include <string>
@@ -100,6 +100,8 @@ class CComponentsText : public CComponentsItem, public CBox
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
///set text color
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
///get text color
virtual inline fb_pixel_t getTextColor(){return ct_col_text;};
///set text alignment, also see textbox.h for possible alignment modes
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
///set text border width
@@ -131,6 +133,9 @@ class CComponentsText : public CComponentsItem, public CBox
///gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties
virtual CTextBox* getCTextBoxObject() { return ct_textbox; };
///returns count of lines from a text box page
virtual int getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode);
};

View File

@@ -30,7 +30,7 @@
#include <config.h>
#endif
#include "cc.h"
#include "cc_base.h"
#include <string>
//! Sub class of CComponentsItem. Shows a mini tv box, similar to a PIP-Feature with current tv-channel.

View File

@@ -28,7 +28,7 @@
#define __CC_MISC__
#include "config.h"
#include <gui/components/cc.h>
#include <gui/components/cc_base.h>
#include <vector>
#include <string>