diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index 8bd6e4c74..4daada27f 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -38,109 +38,74 @@ using namespace std; CComponentsWindow::CComponentsWindow() { initVarWindow(); - - initCCWItems(); } -CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname) -{ - 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, +CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, neutrino_locale_t locale_caption, - const char* iconname, + const string& iconname, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - initVarWindow(); - - 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(); + 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); } -CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, - const std::string& caption, - const char* iconname, +CComponentsWindow::CComponentsWindow( 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) { - initVarWindow(); - - 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(); + initVarWindow(x_pos, y_pos, w, h, caption, iconname, has_shadow, color_frame, color_body, color_shadow); } -CComponentsWindow::~CComponentsWindow() -{ -#ifdef DEBUG_CC - printf("[~CComponentsWindow] [%s - %d] delete...\n", __func__, __LINE__); -#endif -} +CComponentsWindowMax::CComponentsWindowMax(const string& caption, const string& iconname) + :CComponentsWindow(0, 0, 0, 0, caption, iconname){}; -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 cc_item_type = CC_ITEMTYPE_FRM_WINDOW; - //using current screen settings for default dimensions - width = frameBuffer->getScreenWidth(); - height = frameBuffer->getScreenHeight(); - x=getScreenStartX(width); - y=getScreenStartY(height); + //using current screen settings for default dimensions, do centering if default values == 0 + width = w == 0 ? frameBuffer->getScreenWidth(true) : w; + height = h == 0 ? frameBuffer->getScreenHeight(true) : h; + x = x_pos == (CC_CENTERED || 0) ? getScreenStartX(width)/2 - width/2 : x_pos; + 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_body = NULL; ccw_footer = NULL; - ccw_caption = ""; - 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); + initCCWItems(); } 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->setIcon(ccw_icon_name); ccw_head->setCaption(ccw_caption, ccw_align_mode); - ccw_head->initCCItems(); +// ccw_head->initCCItems(); ccw_head->setDefaultButtons(ccw_buttons); } } diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 80e7e49f3..81c8c415b 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -65,7 +65,7 @@ class CComponentsWindow : public CComponentsForm ///property: alignment mode for header caption int ccw_align_mode; ///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() int ccw_buttons; ///property: value = true, let show footer, see showFooter() @@ -82,44 +82,40 @@ class CComponentsWindow : public CComponentsForm ///initialze all window objects at once void initCCWItems(); ///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: enum { CC_WINDOW_ITEM_HEADER = 0 }; - ///simple constructor for CComponentsWindow + ///simple constructor for CComponentsWindow, this shows a window over full screen 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, + ///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, + 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); - ///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, + ///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, + neutrino_locale_t locale_text = NONEXISTANT_LOCALE, + 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); - ///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 void addWindowItem(CComponentsItem* cc_Item); @@ -137,7 +133,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 char* iconname){ccw_icon_name = iconname;}; + void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname;}; ///set default header icon buttons, see also getHeaderObject() 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); }; +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 diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index ff7c64da0..4d980e519 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -181,7 +181,7 @@ void CImageInfo::ShowWindow() { CComponentsFooter *footer = 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); footer = cc_win->getFooterObject(); footer->setColorBody(COL_INFOBAR_SHADOW_PLUS_1); diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h index 81c588bc2..46e7615eb 100644 --- a/src/gui/imageinfo.h +++ b/src/gui/imageinfo.h @@ -64,7 +64,7 @@ class CImageInfo : public CMenuTarget void ShowWindow(); void ScrollLic(bool scrollDown); - CComponentsWindow *cc_win; + CComponentsWindowMax *cc_win; CComponentsForm *cc_info; CComponentsPIP *cc_tv; CComponentsInfoBox *cc_lic;