CHintBox/CMsgBox: use frames as default for better highlighting

This commit is contained in:
2019-10-27 16:24:47 +01:00
parent c82d1a9b27
commit 9234f67d98
4 changed files with 133 additions and 29 deletions

View File

@@ -67,14 +67,18 @@ CHintBox::CHintBox( const neutrino_locale_t Caption,
const char * const Picon, const char * const Picon,
const int& header_buttons, const int& header_buttons,
const int& text_mode, const int& text_mode,
const int& indent): CComponentsWindow( 0, 0, Width, const int& indent,
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, Width,
HINTBOX_MIN_HEIGHT, HINTBOX_MIN_HEIGHT,
Caption, Caption,
string(Icon == NULL ? "" : Icon), string(Icon == NULL ? "" : Icon),
NULL, NULL,
CC_SHADOW_ON) CC_SHADOW_ON)
{ {
init(Text, Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); init(Text, Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent, color_frame, color_body, color_shadow, frame_width);
} }
CHintBox::CHintBox( const char * const Caption, CHintBox::CHintBox( const char * const Caption,
@@ -84,14 +88,18 @@ CHintBox::CHintBox( const char * const Caption,
const char * const Picon, const char * const Picon,
const int& header_buttons, const int& header_buttons,
const int& text_mode, const int& text_mode,
const int& indent):CComponentsWindow( 0, 0, Width, const int& indent,
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, Width,
HINTBOX_MIN_HEIGHT, HINTBOX_MIN_HEIGHT,
Caption, Caption,
string(Icon == NULL ? "" : Icon), string(Icon == NULL ? "" : Icon),
NULL, NULL,
CC_SHADOW_ON) CC_SHADOW_ON)
{ {
init(string(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); init(string(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent, color_frame, color_body, color_shadow, frame_width);
} }
CHintBox::CHintBox( const neutrino_locale_t Caption, CHintBox::CHintBox( const neutrino_locale_t Caption,
@@ -101,14 +109,18 @@ CHintBox::CHintBox( const neutrino_locale_t Caption,
const char * const Picon, const char * const Picon,
const int& header_buttons, const int& header_buttons,
const int& text_mode, const int& text_mode,
const int& indent):CComponentsWindow( 0, 0, Width, const int& indent,
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, Width,
HINTBOX_MIN_HEIGHT, HINTBOX_MIN_HEIGHT,
Caption, Caption,
string(Icon == NULL ? "" : Icon), string(Icon == NULL ? "" : Icon),
NULL, NULL,
CC_SHADOW_ON) CC_SHADOW_ON)
{ {
init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent, color_frame, color_body, color_shadow, frame_width);
} }
CHintBox::CHintBox( const char * const Caption, CHintBox::CHintBox( const char * const Caption,
@@ -118,24 +130,42 @@ CHintBox::CHintBox( const char * const Caption,
const char * const Picon, const char * const Picon,
const int& header_buttons, const int& header_buttons,
const int& text_mode, const int& text_mode,
const int& indent):CComponentsWindow( 0, 0, Width, const int& indent,
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, Width,
HINTBOX_MIN_HEIGHT, HINTBOX_MIN_HEIGHT,
Caption, Caption,
string(Icon == NULL ? "" : Icon), string(Icon == NULL ? "" : Icon),
NULL, NULL,
CC_SHADOW_ON) CC_SHADOW_ON)
{ {
init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent, color_frame, color_body, color_shadow, frame_width);
} }
void CHintBox::init(const std::string& Text, const int& Width, const std::string& Picon, const int& header_buttons, const int& text_mode, const int& indent) void CHintBox::init( const std::string& Text,
const int& Width,
const std::string& Picon,
const int& header_buttons,
const int& text_mode,
const int& indent,
const fb_pixel_t& color_frame,
const fb_pixel_t& color_body,
const fb_pixel_t& color_shadow,
const int& frame_width)
{ {
cc_item_type.name = "wg.hintbox"; cc_item_type.name = "wg.hintbox";
int _Width = frameBuffer->scale2Res(Width); int _Width = frameBuffer->scale2Res(Width);
timeout = HINTBOX_DEFAULT_TIMEOUT; timeout = HINTBOX_DEFAULT_TIMEOUT;
w_indentation = indent; w_indentation = indent;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
fr_thickness = frame_width;
hb_font = MSG_FONT; hb_font = MSG_FONT;
enable_txt_scroll = false; enable_txt_scroll = false;

View File

@@ -43,6 +43,7 @@
#define W_FRAME OFFSET_INNER_MID #define W_FRAME OFFSET_INNER_MID
//frame color around hint/message box //frame color around hint/message box
#define HINTBOX_DEFAULT_FRAME_COLOR COL_FRAME #define HINTBOX_DEFAULT_FRAME_COLOR COL_FRAME
#define HINTBOX_DEFAULT_FRAME_WIDTH OFFSET_INNER_SMALL
#define TIMEOUT_BAR_HEIGHT OFFSET_SHADOW/2 #define TIMEOUT_BAR_HEIGHT OFFSET_SHADOW/2
#define DEFAULT_HINTBOX_TEXT_MODE (CTextBox::CENTER) #define DEFAULT_HINTBOX_TEXT_MODE (CTextBox::CENTER)
@@ -82,7 +83,11 @@ class CHintBox : public CComponentsWindow
const std::string& Picon, const std::string& Picon,
const int& header_buttons, const int& header_buttons,
const int& text_mode, const int& text_mode,
const int& indent); const int& indent,
const fb_pixel_t& color_frame,
const fb_pixel_t& color_body,
const fb_pixel_t& color_shadow,
const int& frame_width);
virtual void ReSize(); virtual void ReSize();
void showTimeOutBar(){enableTimeOutBar();} void showTimeOutBar(){enableTimeOutBar();}
@@ -127,7 +132,11 @@ class CHintBox : public CComponentsWindow
const char * const Picon = NULL, const char * const Picon = NULL,
const int& header_buttons = 0, const int& header_buttons = 0,
const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE, const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE,
const int& indent = W_FRAME); const int& indent = W_FRAME,
const fb_pixel_t& color_frame = HINTBOX_DEFAULT_FRAME_COLOR,
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0,
const int& frame_width = HINTBOX_DEFAULT_FRAME_WIDTH);
/**CHintBox Constructor /**CHintBox Constructor
* @param[in] Caption * @param[in] Caption
@@ -141,7 +150,11 @@ class CHintBox : public CComponentsWindow
const char * const Picon = NULL, const char * const Picon = NULL,
const int& header_buttons = 0, const int& header_buttons = 0,
const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE, const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE,
const int& indent = W_FRAME); const int& indent = W_FRAME,
const fb_pixel_t& color_frame = HINTBOX_DEFAULT_FRAME_COLOR,
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0,
const int& frame_width = HINTBOX_DEFAULT_FRAME_WIDTH);
/**CHintBox Constructor /**CHintBox Constructor
* @param[in] Caption * @param[in] Caption
@@ -157,7 +170,11 @@ class CHintBox : public CComponentsWindow
const char * const Picon = NULL, const char * const Picon = NULL,
const int& header_buttons = 0, const int& header_buttons = 0,
const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE, const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE,
const int& indent = W_FRAME); const int& indent = W_FRAME,
const fb_pixel_t& color_frame = HINTBOX_DEFAULT_FRAME_COLOR,
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0,
const int& frame_width = HINTBOX_DEFAULT_FRAME_WIDTH);
/**CHintBox Constructor /**CHintBox Constructor
* @param[in] Caption * @param[in] Caption
@@ -173,7 +190,11 @@ class CHintBox : public CComponentsWindow
const char * const Picon = NULL, const char * const Picon = NULL,
const int& header_buttons = 0, const int& header_buttons = 0,
const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE, const int& text_mode = DEFAULT_HINTBOX_TEXT_MODE,
const int& indent = W_FRAME); const int& indent = W_FRAME,
const fb_pixel_t& color_frame = HINTBOX_DEFAULT_FRAME_COLOR,
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0,
const int& frame_width = HINTBOX_DEFAULT_FRAME_WIDTH);
virtual ~CHintBox(); virtual ~CHintBox();
/** /**

View File

@@ -51,7 +51,11 @@ CMsgBox::CMsgBox( const char* Text,
const int& Height, const int& Height,
const int& ShowButtons, const int& ShowButtons,
const msg_result_t& Default_result, const msg_result_t& Default_result,
const int& Text_mode) : CHintBox( Title, const int& Text_mode,
const fb_pixel_t& color_frame,
const fb_pixel_t& color_body,
const fb_pixel_t& color_shadow,
const int& frame_width) : CHintBox( Title,
Text, Text,
Width, Width,
Icon, Icon,
@@ -59,7 +63,7 @@ CMsgBox::CMsgBox( const char* Text,
0, 0,
Text_mode) Text_mode)
{ {
init(Height, ShowButtons, Default_result); init(Height, ShowButtons, Default_result, color_frame, color_body, color_shadow, frame_width);
} }
CMsgBox::CMsgBox( const char* Text, CMsgBox::CMsgBox( const char* Text,
@@ -70,7 +74,11 @@ CMsgBox::CMsgBox( const char* Text,
const int& Height, const int& Height,
const int& ShowButtons, const int& ShowButtons,
const msg_result_t& Default_result, const msg_result_t& Default_result,
const int& Text_mode) : CHintBox( locale_Title, const int& Text_mode,
const fb_pixel_t& color_frame,
const fb_pixel_t& color_body,
const fb_pixel_t& color_shadow,
const int& frame_width) : CHintBox( locale_Title,
Text, Text,
Width, Width,
Icon, Icon,
@@ -78,18 +86,32 @@ CMsgBox::CMsgBox( const char* Text,
0, 0,
Text_mode) Text_mode)
{ {
init(Height, ShowButtons, Default_result); init(Height, ShowButtons, Default_result, color_frame, color_body, color_shadow, frame_width);
} }
void CMsgBox::init(const int& Height, const int& ShowButtons, const msg_result_t& Default_result) void CMsgBox::init( const int& Height,
const int& ShowButtons,
const msg_result_t& Default_result,
const fb_pixel_t& color_frame,
const fb_pixel_t& color_body,
const fb_pixel_t& color_shadow,
const int& frame_width)
{ {
cc_item_type.name = "msgbox"; cc_item_type.name = "msgbox";
initTimeOut(); initTimeOut();
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
fr_thickness = frame_width;
//enable footer and add its height //enable footer and add its height
showFooter(true); showFooter(true);
#if 0
ccw_h_footer = ccw_footer->getHeight()+OFFSET_INNER_MID; ccw_h_footer = ccw_footer->getHeight()+OFFSET_INNER_MID;
ccw_footer->setHeight(ccw_h_footer); ccw_footer->setHeight(ccw_h_footer);
#endif
btn_enable_bg = true; btn_enable_bg = true;
ccw_col_footer = ccw_body->getColorBody(); ccw_col_footer = ccw_body->getColorBody();
ccw_footer->doPaintBg(false); ccw_footer->doPaintBg(false);
@@ -421,15 +443,15 @@ int ShowMsg2UTF( const char * const Title,
MSGBOX_MIN_HEIGHT, MSGBOX_MIN_HEIGHT,
ShowButtons, ShowButtons,
Default, Default,
Text_mode); Text_mode,
color_frame,
if (color_frame != HINTBOX_DEFAULT_FRAME_COLOR){ COL_MENUCONTENT_PLUS_0,
msgBox.setFrameThickness(OFFSET_INNER_SMALL); COL_SHADOW_PLUS_0
msgBox.setColorFrame(color_frame); );
}
msgBox.enableDefaultResultOnTimeOut(returnDefaultOnTimeout); msgBox.enableDefaultResultOnTimeOut(returnDefaultOnTimeout);
msgBox.setTimeOut(Timeout); msgBox.setTimeOut(Timeout);
msgBox.paint(); msgBox.paint();
msgBox.exec(); msgBox.exec();
int res = msgBox.getResult(); int res = msgBox.getResult();

View File

@@ -96,7 +96,13 @@ class CMsgBox : public CHintBox
}; };
private: private:
void init(const int& Height = -1, const int& ShowButtons = -1, const msg_result_t& Default_result = mbrNone); void init( const int& Height,
const int& ShowButtons,
const msg_result_t& Default_result,
const fb_pixel_t& color_frame,
const fb_pixel_t& color_body,
const fb_pixel_t& color_shadow,
const int& frame_width);
void refreshFoot(void); void refreshFoot(void);
int mb_show_button; int mb_show_button;
@@ -160,6 +166,14 @@ class CMsgBox : public CHintBox
* NO_AUTO_LINEBREAK * NO_AUTO_LINEBREAK
* AUTO_LINEBREAK_NO_BREAKCHARS * AUTO_LINEBREAK_NO_BREAKCHARS
* NOTE: default parameter to find in macro DEFAULT_MSGBOX_TEXT_MODE * NOTE: default parameter to find in macro DEFAULT_MSGBOX_TEXT_MODE
* @param[in] color_frame
* @li optional: expects type fb_pixel_t, defines frame color, default = HINTBOX_DEFAULT_FRAME_COLOR
* @param[in] color_body
* @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
* *
* @see class CHintBox() * @see class CHintBox()
*/ */
@@ -171,7 +185,12 @@ class CMsgBox : public CHintBox
const int& Height = MSGBOX_MIN_HEIGHT, const int& Height = MSGBOX_MIN_HEIGHT,
const int& ShowButtons = mbCancel, const int& ShowButtons = mbCancel,
const msg_result_t& Default_result = mbrNone, const msg_result_t& Default_result = mbrNone,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
const fb_pixel_t& color_frame = HINTBOX_DEFAULT_FRAME_COLOR,
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0,
const int& frame_width = HINTBOX_DEFAULT_FRAME_WIDTH
);
/**CMsgBox Constructor /**CMsgBox Constructor
* @param[in] Text * @param[in] Text
@@ -213,7 +232,14 @@ class CMsgBox : public CHintBox
* NO_AUTO_LINEBREAK * NO_AUTO_LINEBREAK
* AUTO_LINEBREAK_NO_BREAKCHARS * AUTO_LINEBREAK_NO_BREAKCHARS
* NOTE: default parameter to find in macro DEFAULT_MSGBOX_TEXT_MODE * NOTE: default parameter to find in macro DEFAULT_MSGBOX_TEXT_MODE
* * @param[in] color_frame
* @li optional: expects type fb_pixel_t, defines frame color, default = HINTBOX_DEFAULT_FRAME_COLOR
* @param[in] color_body
* @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
* @see class CHintBox() * @see class CHintBox()
*/ */
CMsgBox(const char* Text, CMsgBox(const char* Text,
@@ -224,7 +250,12 @@ class CMsgBox : public CHintBox
const int& Height = MSGBOX_MIN_HEIGHT, const int& Height = MSGBOX_MIN_HEIGHT,
const int& ShowButtons = mbCancel, const int& ShowButtons = mbCancel,
const msg_result_t& Default_result = mbrNone, const msg_result_t& Default_result = mbrNone,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
const fb_pixel_t& color_frame = HINTBOX_DEFAULT_FRAME_COLOR,
const fb_pixel_t& color_body = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0,
const int& frame_width = HINTBOX_DEFAULT_FRAME_WIDTH
);
virtual ~CMsgBox(){}; virtual ~CMsgBox(){};
/** /**