CComponentsWindow: rework constructors, add CComponentsWindowMax

Member initVarWindow() now used with parameters, so it's possible
to remove multiple code in constructors, but some class must be
renamed to CComponentsWindowMax.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 21e0321c53
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-01-24 (Fri, 24 Jan 2014)

Origin message was:
------------------
CComponentsWindow: rework constructors, add CComponentsWindowMax

Member initVarWindow() now used with parameters, so it's possible
to remove multiple code in constructors, but some class must be
renamed to CComponentsWindowMax.


------------------
This commit was generated by Migit
This commit is contained in:
2014-01-24 23:12:51 +01:00
parent 9585b49365
commit 7a48ff7df2
4 changed files with 70 additions and 97 deletions

View File

@@ -38,109 +38,74 @@ using namespace std;
CComponentsWindow::CComponentsWindow() CComponentsWindow::CComponentsWindow()
{ {
initVarWindow(); initVarWindow();
initCCWItems();
} }
CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname) CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
{
initVarWindow();
ccw_caption = caption;
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname)
{
initVarWindow();
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
neutrino_locale_t locale_caption, neutrino_locale_t locale_caption,
const char* iconname, const string& iconname,
bool has_shadow, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_frame,
fb_pixel_t color_body, fb_pixel_t color_body,
fb_pixel_t color_shadow) fb_pixel_t color_shadow)
{ {
initVarWindow(); string s_caption = locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : "";
initVarWindow(x_pos, y_pos, w, h, s_caption, iconname, has_shadow, color_frame, color_body, color_shadow);
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
initCCWItems();
} }
CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption, const string& caption,
const char* iconname, const string& iconname,
bool has_shadow, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_frame,
fb_pixel_t color_body, fb_pixel_t color_body,
fb_pixel_t color_shadow) fb_pixel_t color_shadow)
{ {
initVarWindow(); initVarWindow(x_pos, y_pos, w, h, caption, iconname, has_shadow, color_frame, color_body, color_shadow);
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccw_caption = caption;;
ccw_icon_name = iconname;
initCCWItems();
} }
CComponentsWindow::~CComponentsWindow() CComponentsWindowMax::CComponentsWindowMax(const string& caption, const string& iconname)
{ :CComponentsWindow(0, 0, 0, 0, caption, iconname){};
#ifdef DEBUG_CC
printf("[~CComponentsWindow] [%s - %d] delete...\n", __func__, __LINE__);
#endif
}
void CComponentsWindow::initVarWindow() CComponentsWindowMax::CComponentsWindowMax(neutrino_locale_t locale_caption, const string& iconname)
:CComponentsWindow(0, 0, 0, 0, locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : "", iconname){};
void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const string& caption,
const string& iconname,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{ {
//CComponentsForm //CComponentsForm
cc_item_type = CC_ITEMTYPE_FRM_WINDOW; cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
//using current screen settings for default dimensions //using current screen settings for default dimensions, do centering if default values == 0
width = frameBuffer->getScreenWidth(); width = w == 0 ? frameBuffer->getScreenWidth(true) : w;
height = frameBuffer->getScreenHeight(); height = h == 0 ? frameBuffer->getScreenHeight(true) : h;
x=getScreenStartX(width); x = x_pos == (CC_CENTERED || 0) ? getScreenStartX(width)/2 - width/2 : x_pos;
y=getScreenStartY(height); y = y_pos == (CC_CENTERED || 0) ? getScreenStartY(height)/2 - height/2 : y_pos;
ccw_caption = caption;
ccw_icon_name = iconname;
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] icon name = %s\n", __func__, __LINE__, ccw_icon_name.c_str());
#endif
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccw_head = NULL; ccw_head = NULL;
ccw_body = NULL; ccw_body = NULL;
ccw_footer = NULL; ccw_footer = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
ccw_buttons = 0; //no header buttons ccw_buttons = 0; //no header buttons
ccw_show_footer = true; ccw_show_footer = true;
ccw_show_header = true; ccw_show_header = true;
ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK; ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK;
setShadowOnOff(true); initCCWItems();
} }
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
@@ -163,7 +128,7 @@ void CComponentsWindow::initHeader()
// ccw_head->setPos(0, 0); // ccw_head->setPos(0, 0);
ccw_head->setIcon(ccw_icon_name); ccw_head->setIcon(ccw_icon_name);
ccw_head->setCaption(ccw_caption, ccw_align_mode); ccw_head->setCaption(ccw_caption, ccw_align_mode);
ccw_head->initCCItems(); // ccw_head->initCCItems();
ccw_head->setDefaultButtons(ccw_buttons); ccw_head->setDefaultButtons(ccw_buttons);
} }
} }

View File

@@ -65,7 +65,7 @@ class CComponentsWindow : public CComponentsForm
///property: alignment mode for header caption ///property: alignment mode for header caption
int ccw_align_mode; int ccw_align_mode;
///property: icon name in header, see also getHeaderObject() ///property: icon name in header, see also getHeaderObject()
const char* ccw_icon_name; std::string ccw_icon_name;
///property: assigned default icon buttons in header, see also getHeaderObject() ///property: assigned default icon buttons in header, see also getHeaderObject()
int ccw_buttons; int ccw_buttons;
///property: value = true, let show footer, see showFooter() ///property: value = true, let show footer, see showFooter()
@@ -82,44 +82,40 @@ class CComponentsWindow : public CComponentsForm
///initialze all window objects at once ///initialze all window objects at once
void initCCWItems(); void initCCWItems();
///initialize all attributes ///initialize all attributes
void initVarWindow(); void initVarWindow( const int& x_pos = CC_CENTERED, const int& y_pos = CC_CENTERED, const int& w = 0, const int& h = 0,
const std::string& caption = "",
const std::string& iconname = "",
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);
public: public:
enum enum
{ {
CC_WINDOW_ITEM_HEADER = 0 CC_WINDOW_ITEM_HEADER = 0
}; };
///simple constructor for CComponentsWindow ///simple constructor for CComponentsWindow, this shows a window over full screen
CComponentsWindow(); CComponentsWindow();
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string, x_pos or y_pos = 0 will center window
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption, const std::string& caption = "",
const char* iconname = NULL, const std::string& iconname = "",
bool has_shadow = CC_SHADOW_OFF, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_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 ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales, x_pos or y_pos = 0 will center window
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t locale_caption, neutrino_locale_t locale_text = NONEXISTANT_LOCALE,
const char* iconname = NULL, const std::string& iconname = "",
bool has_shadow = CC_SHADOW_OFF, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_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();
///add item to body object, also usable is addCCItem() to add items to the windo object ///add item to body object, also usable is addCCItem() to add items to the windo object
void addWindowItem(CComponentsItem* cc_Item); void addWindowItem(CComponentsItem* cc_Item);
@@ -137,7 +133,7 @@ class CComponentsWindow : public CComponentsForm
void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;}; void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;};
///set icon name in header, see also getHeaderObject() ///set icon name in header, see also getHeaderObject()
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;}; void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname;};
///set default header icon buttons, see also getHeaderObject() ///set default header icon buttons, see also getHeaderObject()
void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;}; void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;};
@@ -157,4 +153,16 @@ class CComponentsWindow : public CComponentsForm
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
}; };
class CComponentsWindowMax : public CComponentsWindow
{
public:
///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
CComponentsWindowMax(const std::string& caption, const std::string& iconname = "");
///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
CComponentsWindowMax(neutrino_locale_t locale_caption, const std::string& iconname = "");
};
#endif #endif

View File

@@ -181,7 +181,7 @@ void CImageInfo::ShowWindow()
{ {
CComponentsFooter *footer = NULL; CComponentsFooter *footer = NULL;
if (cc_win == NULL){ if (cc_win == NULL){
cc_win = new CComponentsWindow(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO); cc_win = new CComponentsWindowMax(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO);
cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT);
footer = cc_win->getFooterObject(); footer = cc_win->getFooterObject();
footer->setColorBody(COL_INFOBAR_SHADOW_PLUS_1); footer->setColorBody(COL_INFOBAR_SHADOW_PLUS_1);

View File

@@ -64,7 +64,7 @@ class CImageInfo : public CMenuTarget
void ShowWindow(); void ShowWindow();
void ScrollLic(bool scrollDown); void ScrollLic(bool scrollDown);
CComponentsWindow *cc_win; CComponentsWindowMax *cc_win;
CComponentsForm *cc_info; CComponentsForm *cc_info;
CComponentsPIP *cc_tv; CComponentsPIP *cc_tv;
CComponentsInfoBox *cc_lic; CComponentsInfoBox *cc_lic;