CComponents: rework position handling

The real position already used here, if item is bound to a parent.
(bound or embedded means: added with addCCItem() to a form)
This causes no separate calculation in paint methodes of embedded
sub items or sub forms and more nested sub forms.

CComponentsForm have also some new members
- exchangeCCItem() to exchange the order items
- setAppendOffset() to set an offset for auto append mode
 Autoappend is enabled if x or y have value -1 (defined also in CC_APPEND)
 x=horizontal, y=vertical
 Is this activated, no separate calculation of incremental offset
 is required.

However items with independent rendered parts, needs
a separate calculation. In some subclasses was this necessary.


Origin commit data
------------------
Commit: 04300f1874
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-06-16 (Sun, 16 Jun 2013)

Origin message was:
------------------
CComponents: rework position handling

The real position already used here, if item is bound to a parent.
(bound or embedded means: added with addCCItem() to a form)
This causes no separate calculation in paint methodes of embedded
sub items or sub forms and more nested sub forms.

CComponentsForm have also some new members
- exchangeCCItem() to exchange the order items
- setAppendOffset() to set an offset for auto append mode
 Autoappend is enabled if x or y have value -1 (defined also in CC_APPEND)
 x=horizontal, y=vertical
 Is this activated, no separate calculation of incremental offset
 is required.

However items with independent rendered parts, needs
a separate calculation. In some subclasses was this necessary.
This commit is contained in:
2013-06-16 00:19:51 +02:00
parent 72b897f920
commit d05f9843f7
5 changed files with 205 additions and 71 deletions

View File

@@ -41,6 +41,9 @@ class CComponentsForm : public CComponentsItem
std::vector<CComponentsItem*> v_cc_items;
void initVarForm();
void paintForm(bool do_save_bg);
int append_h_offset;
int append_v_offset;
public:
CComponentsForm();
@@ -55,11 +58,14 @@ class CComponentsForm : public CComponentsItem
virtual void removeCCItem(const uint& cc_item_id);
virtual void replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item);
virtual void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item);
virtual void exchangeCCItem(const uint& item_id_a, const uint& item_id_b);
virtual void exchangeCCItem(CComponentsItem* item_a, CComponentsItem* item_b);
virtual int getCCItemId(CComponentsItem* cc_Item);
virtual CComponentsItem* getCCItem(const uint& cc_item_id);
virtual void paintCCItems();
virtual void clearCCItems();
virtual void cleanCCForm();
virtual void setAppendOffset(const int &h_offset, const int& v_offset){append_h_offset = h_offset; append_v_offset = v_offset;};
///property: returns true, if item already added to form
virtual bool isAdded(CComponentsItem *cc_item);
};
@@ -176,19 +182,56 @@ class CComponentsFooter : public CComponentsHeader
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
};
//! Sub class of CComponentsForm. Shows a window with prepared items.
/*!
CComponentsWindow provides prepared items like header, footer and a container for
items like text, labels, pictures ...
*/
/*
x
y+-------------------------------------------------------+
|icon caption buttons |header (ccw_head)
+-x-----------------------------------------------------+
|cc_item0 |
|cc_item1 |body (ccw_body)
| add items here directly with |
| addWindowItem() or |
y with ccw_body->addCCItem() |
| Note: x/y related to body object |
| |
+-------------------------------------------------------+
| add cc_items with ccw_footer->addCCItem() |footer(ccw_footer)
+-------------------------------------------------------+
*/
class CComponentsWindow : public CComponentsForm
{
private:
///object: header object, to get access to header properties see also getHeaderObject()
CComponentsHeader * ccw_head;
///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(
CComponentsForm * ccw_footer;
///property: caption in header, see also getHeaderObject()
std::string ccw_caption;
///property: icon name in header, see also getHeaderObject()
const char* ccw_icon_name;
int ccw_start_y;
///property: assigned default icon buttons in header, see also getHeaderObject()
int ccw_buttons;
///initialze header object
void initHeader();
///initialze body object
void initBody();
///initialze footer object
void initFooter();
///initialze all window objects at once
void initCCWItems();
protected:
///initialize all attributes
void initVarWindow();
public:
@@ -196,17 +239,64 @@ class CComponentsWindow : public CComponentsForm
{
CC_WINDOW_ITEM_HEADER = 0
};
///simple constructor for CComponentsWindow
CComponentsWindow();
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
const std::string& caption,
const char* iconname = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
neutrino_locale_t locale_caption,
const char* iconname = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindow(const std::string& caption, const char* iconname = NULL);
///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname = NULL);
~CComponentsWindow();
///paint window
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///add item to body object, also usable is addCCItem() to add items to the windo object
void addWindowItem(CComponentsItem* cc_Item);
///set caption in header with string, see also getHeaderObject()
void setWindowCaption(const std::string& text){ccw_caption = text;};
///set caption in header from locales, see also getHeaderObject()
void setWindowCaption(neutrino_locale_t locale_text);
///set icon name in header, see also getHeaderObject()
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
///set default header icon buttons, see also getHeaderObject()
void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;};
///returns a pointer to the internal header object, use this to get access to header properities
CComponentsHeader* getHeaderObject(){return ccw_head;};
///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
CComponentsForm* getFooterObject(){return ccw_footer;};
int getStartY(); //y value for start of the area below header
};