CComponents: add sub class CComponentsIconForm based upon CComponentsForm

Collects only icons.You can add icons step by step or
with a vector and paint the form at once.
Width and height are dynamic calculated if parameters
width or height are smaller then summary of lenght of all added icons.

It's also possible to manipulate the icon array with members:
- insertIcon()
- removeIcon()
- removeAllIcons()

TODO: support for resizable images
This commit is contained in:
2012-11-12 10:31:52 +01:00
parent 6ee87b95ec
commit 84fe7cf134
2 changed files with 167 additions and 3 deletions

View File

@@ -102,6 +102,7 @@ typedef struct comp_element_data_t
void* handler2;
}comp_element_data_struct_t;
#define CC_WIDTH_MIN 16
#define CC_HEIGHT_MIN 16
#define CC_SHADOW_ON true
@@ -478,4 +479,32 @@ class CComponentsHeader : public CComponentsForm
void setHeaderIcon(const char* icon_name);
};
class CComponentsIconForm : public CComponentsForm
{
private:
std::vector<std::string> v_icons;
int ccif_offset;
protected:
void initVarIconForm();
public:
CComponentsIconForm();
CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector<std::string> v_icon_names, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void initCCIcons();
void addIcon(const std::string& icon_name);
void addIcon(std::vector<std::string> icon_name);
void removeIcons(){v_icons.clear();};
void insertIcon(const uint& icon_id, const std::string& icon_name);
void removeIcon(const uint& icon_id);
void removeIcon(const std::string& icon_name);
void removeAllIcons();
int getIconId(const std::string& icon_name);
void setIconOffset(const int offset){ccif_offset = offset;};
};
#endif