From c82d1a9b277831bfcf8a8a741a00d9a669d71dbf Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 27 Oct 2019 16:24:47 +0100 Subject: [PATCH] cc_frm_window: add paramter for frame width into constructors setFrameThickness() has no effect --- src/gui/components/cc_frm_window.cpp | 58 +++++++++++++++------------- src/gui/components/cc_frm_window.h | 44 +++++++++++++-------- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index cd2af2258..f741587e9 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -59,7 +59,7 @@ using namespace std; //sub class CComponentsWindow inherit from CComponentsForm CComponentsWindow::CComponentsWindow(CComponentsForm *parent) { - init(0, 0, 800, 600, "", "", parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); + init(0, 0, 800, 600, "", "", parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0, 0); } CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, @@ -67,12 +67,13 @@ CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const const string& iconname, CComponentsForm *parent, int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow) + const fb_pixel_t& color_frame, + const fb_pixel_t& color_body, + const fb_pixel_t& color_shadow, + const int& frame_width) { string s_caption = locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : ""; - init(x_pos, y_pos, w, h, s_caption, iconname, parent, shadow_mode, color_frame, color_body, color_shadow); + init(x_pos, y_pos, w, h, s_caption, iconname, parent, shadow_mode, color_frame, color_body, color_shadow, frame_width); } CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, @@ -80,22 +81,24 @@ CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const const string& iconname, CComponentsForm *parent, int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow) + const fb_pixel_t& color_frame, + const fb_pixel_t& color_body, + const fb_pixel_t& color_shadow, + const int& frame_width) { - init(x_pos, y_pos, w, h, caption, iconname, parent, shadow_mode, color_frame, color_body, color_shadow); + init(x_pos, y_pos, w, h, caption, iconname, parent, shadow_mode, color_frame, color_body, color_shadow, frame_width); } CComponentsWindowMax::CComponentsWindowMax( const string& caption, const string& iconname, CComponentsForm *parent, int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow) + const fb_pixel_t& color_frame, + const fb_pixel_t& color_body, + const fb_pixel_t& color_shadow, + const int& frame_width) :CComponentsWindow(0, 0, 0, 0, caption, - iconname, parent, shadow_mode, color_frame, color_body, color_shadow) + iconname, parent, shadow_mode, color_frame, color_body, color_shadow, frame_width) { cc_item_type.id = CC_ITEMTYPE_FRM_WINDOW_MAX; cc_item_type.name = "cc_window_max"; @@ -105,12 +108,13 @@ CComponentsWindowMax::CComponentsWindowMax( neutrino_locale_t locale_caption, const string& iconname, CComponentsForm *parent, int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow) + const fb_pixel_t& color_frame, + const fb_pixel_t& color_body, + const fb_pixel_t& color_shadow, + const int& frame_width) :CComponentsWindow(0, 0, 0, 0, locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : "", - iconname, parent, shadow_mode, color_frame, color_body, color_shadow) + iconname, parent, shadow_mode, color_frame, color_body, color_shadow, frame_width) { cc_item_type.id = CC_ITEMTYPE_FRM_WINDOW_MAX; cc_item_type.name = "cc_window_max_localized"; @@ -120,10 +124,11 @@ void CComponentsWindow::init( const int& x_pos, const int& y_pos, const int& w, const string& caption, const string& iconname, CComponentsForm *parent, - int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow) + const int& shadow_mode, + const fb_pixel_t& color_frame, + const fb_pixel_t& color_body, + const fb_pixel_t& color_shadow, + const int& frame_width) { //CComponentsForm cc_item_type.id = CC_ITEMTYPE_FRM_WINDOW; @@ -135,6 +140,7 @@ void CComponentsWindow::init( const int& x_pos, const int& y_pos, const int& w, y = y_pos; width = w; height = h; + fr_thickness = fr_thickness_old = frame_width; ccw_h_footer = 0; //auto initWindowSize(); initWindowPos(); @@ -215,12 +221,13 @@ void CComponentsWindow::initHeader() //set header properties //TODO: assigned properties with internal header objekt have no effect! if (ccw_head){ ccw_head->setWidth(width-2*fr_thickness); - ccw_head->setPos(fr_thickness, fr_thickness); + ccw_head->setPos(0, 0); ccw_head->setIcon(ccw_icon_name); ccw_head->setCaption(ccw_caption, ccw_align_mode, ccw_col_head_text); ccw_head->setContextButton(ccw_buttons); ccw_head->setCorner(corner_rad, CORNER_TOP); ccw_head->setColorBody(ccw_col_head); + ccw_h_footer = ccw_head->getHeight(); } } @@ -233,9 +240,8 @@ void CComponentsWindow::initFooter() if (ccw_footer){ if (ccw_h_footer) ccw_footer->setHeight(ccw_h_footer); - ccw_footer->setPos(cc_xr + fr_thickness, cc_yr + height - ccw_footer->getHeight()- fr_thickness); - ccw_footer->setWidth(width/*-2*fr_thickness*/); - ccw_footer->enableShadow(false/*shadow*/); + ccw_footer->setPos(0, cc_yr + height - ccw_footer->getHeight()- 2*fr_thickness); + ccw_footer->setWidth(width-2*fr_thickness); ccw_footer->setCorner(corner_rad, CORNER_BOTTOM); ccw_footer->setButtonFont(ccw_button_font); ccw_footer->setColorBody(ccw_col_footer); @@ -305,7 +311,7 @@ void CComponentsWindow::initBody() w_l_sidebar = ccw_left_sidebar->getWidth(); if (ccw_right_sidebar) w_r_sidebar = ccw_right_sidebar->getWidth(); - int h_body = height - h_header - h_footer - fr_thickness; + int h_body = height - h_header - h_footer - 2*fr_thickness; int x_body = w_l_sidebar; int w_body = width-2*fr_thickness - w_l_sidebar - w_r_sidebar; diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 07ebed2f3..968da1fd4 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -31,6 +31,7 @@ #define CCW_PERCENT - //placeholder for negative sign '-', used for discret dimensions parameters + //! Sub class of CComponentsForm. Shows a window with prepared items. /*! CComponentsWindow provides prepared items like header, footer and a container for @@ -113,10 +114,12 @@ class CComponentsWindow : public CComponentsForm, CCHeaderTypes const std::string& caption, const std::string& iconname, CComponentsForm *parent, - int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow); + const int& shadow_mode, + const fb_pixel_t& color_frame, + const fb_pixel_t& color_body, + const fb_pixel_t& color_shadow, + const int& frame_width + ); ///initialize width and height void initWindowSize(); ///initialize position @@ -125,6 +128,7 @@ class CComponentsWindow : public CComponentsForm, CCHeaderTypes ///returns true, if current page is changed, see also: setCurrentPage() bool isPageChanged(); + public: enum { @@ -171,6 +175,8 @@ class CComponentsWindow : public CComponentsForm, CCHeaderTypes * @li optional: expects type fb_pixel_t, defines color color, default = COL_MENUCONTENT_PLUS_0 * @param[in] color_shadow * @li optional: expects type fb_pixel_t, defines shadow color, default = COL_SHADOW_PLUS_0 + * @param[in] frame_width + * @li optional: expects type int, defines frame width around, default = 0 * * @note Discret dimensions parameters: values < 0 to -100 will be interpreted as percent values related to screen. * For better readability please use placeholder 'CCW_PERCENT' as negative sign '-' \n @@ -185,9 +191,10 @@ class CComponentsWindow : public CComponentsForm, CCHeaderTypes const std::string& iconname = "", CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_FRAME_PLUS_0, - fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + const fb_pixel_t& color_frame = COL_FRAME_PLUS_0, + const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0, + const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0, + const int& frame_width = 0); /** * advanced constructor for CComponentsWindow, provides parameters for the most required properties @@ -200,9 +207,10 @@ class CComponentsWindow : public CComponentsForm, CCHeaderTypes const std::string& iconname = "", CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_FRAME_PLUS_0, - fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + const fb_pixel_t& color_frame = COL_FRAME_PLUS_0, + const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0, + const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0, + const int& frame_width = 0); virtual ~CComponentsWindow(){}; @@ -415,7 +423,7 @@ class CComponentsWindow : public CComponentsForm, CCHeaderTypes /** * Reinit position and dimensions and reinitialize mostly elemenatary properties */ - void Refresh(){initCCWItems();}; + void Refresh(){initCCWItems();} /** * Paint window @@ -458,9 +466,10 @@ class CComponentsWindowMax : public CComponentsWindow CComponentsWindowMax( const std::string& caption, const std::string& iconname = "", CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_FRAME_PLUS_0, - fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + const fb_pixel_t& color_frame = COL_FRAME_PLUS_0, + const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0, + const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0, + const int& frame_width = 0); /** * Simple constructor for CComponentsWindow, this shows only a centered window based up current screen settings @@ -472,9 +481,10 @@ class CComponentsWindowMax : public CComponentsWindow CComponentsWindowMax( neutrino_locale_t locale_caption, const std::string& iconname = "", CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_FRAME_PLUS_0, - fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + const fb_pixel_t& color_frame = COL_FRAME_PLUS_0, + const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0, + const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0, + const int& frame_width = 0); }; #endif