From dde298b1b72f11c67df276672e3860971b2896e9 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 4 Apr 2016 21:57:17 +0200 Subject: [PATCH] CMsgBox: rework msgbox classes with Window class implementation Replacing messagebox, hintbox_ext and some derivated parts with basic class hintbox and derivated class CMsgBox. This should unify window handling and avoids maintain of multiple classes with quasi same purpose and adds more functionality. TODO: fix and optimize details --- data/locale/deutsch.locale | 1 + data/locale/english.locale | 1 + data/locale/nederlands.locale | 1 + src/driver/moviecut.cpp | 4 +- src/driver/record.cpp | 10 +- src/driver/screenshot.cpp | 2 +- src/gui/audioplayer.cpp | 6 +- src/gui/bedit/bouqueteditor_bouquets.cpp | 12 +- src/gui/bedit/bouqueteditor_channels.cpp | 4 +- src/gui/bookmarkmanager.cpp | 2 +- src/gui/bouquetlist.cpp | 6 +- src/gui/buildinfo.cpp | 2 +- src/gui/channellist.cpp | 12 +- src/gui/components/cc_frm.cpp | 59 +- src/gui/components/cc_frm.h | 27 +- src/gui/components/cc_frm_button.cpp | 18 +- src/gui/components/cc_frm_button.h | 27 +- src/gui/components/cc_frm_footer.cpp | 53 +- src/gui/components/cc_frm_footer.h | 38 +- src/gui/components/cc_frm_window.h | 5 + src/gui/components/cc_signals.h | 2 +- src/gui/components/cc_types.h | 4 +- src/gui/epgplus.cpp | 6 +- src/gui/epgview.cpp | 12 +- src/gui/eventlist.cpp | 6 +- src/gui/favorites.cpp | 8 +- src/gui/filebrowser.cpp | 4 +- src/gui/hdd_menu.cpp | 16 +- src/gui/keybind_setup.cpp | 4 +- src/gui/lua/lua_hintbox.cpp | 2 +- src/gui/lua/lua_menue.cpp | 2 +- src/gui/lua/lua_messagebox.cpp | 36 +- src/gui/lua/lua_messagebox.h | 2 +- src/gui/lua/lua_misc.cpp | 2 +- src/gui/lua/lua_video.cpp | 2 +- src/gui/miscsettings_menu.cpp | 4 +- src/gui/motorcontrol.cpp | 4 +- src/gui/moviebrowser/mb.cpp | 30 +- src/gui/moviebrowser/mb_help.h | 40 +- src/gui/movieplayer.cpp | 4 +- src/gui/network_setup.cpp | 28 +- src/gui/opkg_manager.cpp | 16 +- src/gui/personalize.cpp | 16 +- src/gui/pictureviewer.cpp | 57 +- src/gui/pipsetup.cpp | 2 +- src/gui/pluginlist.cpp | 6 +- src/gui/rc_lock.cpp | 9 +- src/gui/record_setup.cpp | 4 +- src/gui/scan.cpp | 4 +- src/gui/scan_setup.cpp | 2 +- src/gui/screensetup.cpp | 4 +- src/gui/settings_manager.cpp | 8 +- src/gui/start_wizard.cpp | 6 +- src/gui/test_menu.cpp | 171 +++- src/gui/test_menu.h | 2 +- src/gui/themes.cpp | 4 +- src/gui/timerlist.cpp | 14 +- src/gui/update.cpp | 34 +- src/gui/update_ext.cpp | 8 +- src/gui/upnpbrowser.cpp | 8 +- src/gui/user_menue_setup.cpp | 2 +- src/gui/videosettings.cpp | 4 +- src/gui/widget/Makefile.am | 2 - src/gui/widget/colorchooser.cpp | 4 +- src/gui/widget/helpbox.cpp | 216 ++-- src/gui/widget/helpbox.h | 111 +- src/gui/widget/hintbox.cpp | 615 ++++++----- src/gui/widget/hintbox.h | 220 ++-- src/gui/widget/keyboard_input.cpp | 4 +- src/gui/widget/messagebox.cpp | 38 +- src/gui/widget/messagebox.h | 2 + src/gui/widget/msgbox.cpp | 1176 ++++++++-------------- src/gui/widget/msgbox.h | 336 ++++--- src/gui/widget/shellwindow.cpp | 2 +- src/gui/widget/stringinput.cpp | 4 +- src/gui/widget/stringinput_ext.cpp | 10 +- src/neutrino.cpp | 40 +- src/neutrino_menue.h | 1 + src/system/locals.h | 1 + src/system/locals_intern.h | 1 + src/system/setting_helpers.cpp | 6 +- 81 files changed, 1981 insertions(+), 1697 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 7f9468a2a..b9b67613b 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -780,6 +780,7 @@ hdd_statfs_recording nur während Aufnahme hdd_umount Aushängen hdd_umount_warn Laufwerk aushängen hdd_umounted Laufwerk entfernt +help_box_title Hilfe imageinfo.api API: imageinfo.creator Ersteller: imageinfo.date Datum: diff --git a/data/locale/english.locale b/data/locale/english.locale index b9bd319b0..acf01b734 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -780,6 +780,7 @@ hdd_statfs_recording while recording only hdd_umount Unmount hdd_umount_warn unmount device hdd_umounted Device removed +help_box_title Help imageinfo.api API: imageinfo.creator Creator: imageinfo.date Date: diff --git a/data/locale/nederlands.locale b/data/locale/nederlands.locale index 0deb34b3c..5c81c018d 100644 --- a/data/locale/nederlands.locale +++ b/data/locale/nederlands.locale @@ -725,6 +725,7 @@ hdd_statfs_recording alleen tijdens opname hdd_umount Unmount hdd_umount_warn Apparaat ontkoppelen hdd_umounted Device verwijderd +help_box_title Help imageinfo.api API: imageinfo.creator Ontwikkelaar: imageinfo.date Datum: diff --git a/src/driver/moviecut.cpp b/src/driver/moviecut.cpp index a4f8890cf..749053023 100644 --- a/src/driver/moviecut.cpp +++ b/src/driver/moviecut.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -295,7 +295,7 @@ int CMovieCut::getInput() int retval = 0; g_RCInput->getMsg(&msg, &data, 1, false); if (msg == CRCInput::RC_home) { - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIECUT_CANCEL, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIECUT_CANCEL, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) retval |= 4; } if (msg != CRCInput::RC_timeout) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 7dd3183ab..042cf1ad4 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -1385,7 +1385,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_ASK_STOP_ALL)); snprintf(rec_msg, sizeof(rec_msg)-1, rec_msg1, records); if(ShowMsg(LOCALE_SHUTDOWN_RECORDING_QUERY, rec_msg, - CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) + CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30) == CMsgBox::mbrYes) { snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_INFO_STOP_ALL)); @@ -1418,7 +1418,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) inst->GetRecordString(title, duration); title += duration; tostart = (ShowMsg(LOCALE_RECORDING_IS_RUNNING, title.c_str(), - CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes); + CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30) == CMsgBox::mbrYes); } if (tostart) { CRecordManager::getInstance()->Record(live_channel_id); @@ -1565,7 +1565,7 @@ bool CRecordManager::AskToStop(const t_channel_id channel_id, const int recid) return false; if(ShowMsg(LOCALE_SHUTDOWN_RECORDING_QUERY, title.c_str(), - CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { + CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30) == CMsgBox::mbrYes) { mutex.lock(); if (recid) inst = FindInstanceID(recid); @@ -1858,7 +1858,7 @@ bool CRecordManager::MountDirectory(const char *recordingDir) strcat(msg,recordingDir); ShowMsg(LOCALE_MESSAGEBOX_ERROR, msg, - CMessageBox::mbrBack, CMessageBox::mbBack,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8 + CMsgBox::mbrBack, CMsgBox::mbBack,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8 ret = false; } break; diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index 5b32b1e7a..e438f924b 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 1561a8616..c96652ac9 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include #include @@ -2653,8 +2653,8 @@ bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG), filename.c_str()); bool res = (ShowMsg(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, - msg,CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo) - == CMessageBox::mbrYes); + msg,CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo) + == CMsgBox::mbrYes); this->paint(); return res; } diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 4138c987d..28223aa4a 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include @@ -245,19 +245,19 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* { if (bouquetsChanged) { - int result = ShowMsg(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll); + int result = ShowMsg(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMsgBox::mbrYes, CMsgBox::mbYesNoCancel, NULL, 600); switch( result ) { - case CMessageBox::mbrYes : + case CMsgBox::mbrYes : loop=false; saveChanges(); break; - case CMessageBox::mbrNo : + case CMsgBox::mbrNo : loop=false; discardChanges(); break; - case CMessageBox::mbrCancel : + case CMsgBox::mbrCancel : paintHead(); paint(); paintFoot(); @@ -394,7 +394,7 @@ void CBEBouquetWidget::deleteBouquet() if (selected >= Bouquets->size()) /* Bouquets->size() might be 0 */ return; - if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMsgBox::mbrNo, CMsgBox::mbYes|CMsgBox::mbNo)!=CMsgBox::mbrYes) return; g_bouquetManager->deleteBouquet(selected); diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 874096dd7..38310c319 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -28,7 +28,7 @@ #include #endif -#include +#include #include "bouqueteditor_channels.h" #include @@ -470,7 +470,7 @@ void CBEChannelWidget::deleteChannel() if (selected >= Channels->size()) /* Channels.size() might be 0 */ return; - if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Channels)[selected]->getName(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Channels)[selected]->getName(), CMsgBox::mbrNo, CMsgBox::mbYes|CMsgBox::mbNo)!=CMsgBox::mbrYes) return; g_bouquetManager->Bouquets[bouquet]->removeService((*Channels)[selected]->getChannelID()); diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index cad6d739d..8d7f21453 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 6570b0cb3..49c0cbd1b 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -346,8 +346,8 @@ int CBouquetList::doMenu() if(select >= 0) { old_selected = select; - int result = ShowMsg ( LOCALE_BOUQUETEDITOR_DELETE, Bouquets[selected]->channelList->getName(), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); - if(result != CMessageBox::mbrYes) + int result = ShowMsg ( LOCALE_BOUQUETEDITOR_DELETE, Bouquets[selected]->channelList->getName(), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo ); + if(result != CMsgBox::mbrYes) return 0; if (zapitBouquet) { diff --git a/src/gui/buildinfo.cpp b/src/gui/buildinfo.cpp index f89f933d3..3cc94094a 100644 --- a/src/gui/buildinfo.cpp +++ b/src/gui/buildinfo.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include using namespace std; diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index c6c9bafa3..176f34315 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -59,10 +59,14 @@ #include #include #include -#include -#include #include #include +#if 0 +#include +#include +#else +#include +#endif #include #include @@ -2627,7 +2631,7 @@ void CChannelList::deleteChannel(bool ask) if (!bouquet || !bouquet->zapitBouquet) return; - if (ask && ShowMsg(LOCALE_FILEBROWSER_DELETE, (*chanlist)[selected]->getName(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ask && ShowMsg(LOCALE_FILEBROWSER_DELETE, (*chanlist)[selected]->getName(), CMsgBox::mbrNo, CMsgBox::mbYes|CMsgBox::mbNo)!=CMsgBox::mbrYes) return; bouquet->zapitBouquet->removeService((*chanlist)[selected]->getChannelID()); @@ -2718,7 +2722,7 @@ bool CChannelList::addChannelToBouquet() } } } else { - ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, LOCALE_EXTRA_CHALREADYINBQ, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, LOCALE_EXTRA_CHALREADYINBQ, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); return false; } } diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 69d1fb7d3..29ab9ba9e 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -57,6 +57,10 @@ CComponentsForm::CComponentsForm( const int x_pos, const int y_pos, const int w, corner_type = CORNER_ALL; cc_item_index = 0; + //add default exit keys for exec handler + v_exit_keys.push_back(CRCInput::RC_home); + v_exit_keys.push_back(CRCInput::RC_setup); + v_cc_items.clear(); append_x_offset = 0; @@ -69,7 +73,7 @@ CComponentsForm::CComponentsForm( const int x_pos, const int y_pos, const int w, page_scroll_mode = PG_SCROLL_M_UP_DOWN_KEY; //connect page scroll slot - sigc::slot3 sl = sigc::mem_fun(*this, &CComponentsForm::execPageScroll); + sigc::slot4 sl = sigc::mem_fun(*this, &CComponentsForm::execPageScroll); this->OnExec.connect(sl); } @@ -91,74 +95,65 @@ CComponentsForm::~CComponentsForm() int CComponentsForm::exec() { dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] \n", __func__, __LINE__); - OnBeforeExec(); + + //basic values neutrino_msg_t msg; neutrino_msg_data_t data; - int res = menu_return::RETURN_REPAINT; - uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(-1); - //required exit keys - msg_list_t exit_keys[2]; - exit_keys[0].msg = CRCInput::RC_setup; - exit_keys[1].msg = CRCInput::RC_home; + //allow exec loop + bool cancel_exec = false; - bool exit_loop = false; - while (!exit_loop) + //signal before exec + OnBeforeExec(); + + while (!cancel_exec) { g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); //execute connected slots - OnExec(msg, data, res); - + OnExec(msg, data, res, cancel_exec); //exit loop - execExit(msg, data, res, exit_loop, exit_keys, 2); + execExit(msg, data, res, cancel_exec, v_exit_keys); if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { dprintf(DEBUG_INFO, "[CComponentsForm] [%s - %d] messages_return::cancel_all\n", __func__, __LINE__); res = menu_return::RETURN_EXIT_ALL; - exit_loop = EXIT; + cancel_exec = EXIT; } } + //signal after exec OnAfterExec(); + return res; } -void CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const struct msg_list_t * const msg_list, const size_t& key_count, bool force_exit) -{ - for(size_t i = 0; i < key_count; i++){ - if (execKey(msg, data, res, exit_loop, msg_list[i].msg, force_exit)){ - break; - } - } -} - -void CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const std::vector& v_msg_list, bool force_exit) +void CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec, const std::vector& v_msg_list, bool force_exit) { for(size_t i = 0; i < v_msg_list.size(); i++){ - if (execKey(msg, data, res, exit_loop, v_msg_list[i], force_exit)){ + if (execKey(msg, data, res, cancel_exec, v_msg_list[i], force_exit)){ break; } } } -inline bool CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const neutrino_msg_t& msg_val, bool force_exit) +inline bool CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec, const neutrino_msg_t& msg_val, bool force_exit) { if (msg == msg_val){ OnExecMsg(msg, data, res); if (force_exit) - exit_loop = EXIT; + cancel_exec = EXIT; return true; } return false; } -void CComponentsForm::execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& /*data*/, int& /*res*/) +void CComponentsForm::execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& /*data*/, int& /*res*/, bool& /*cancel_exec*/) { if (page_scroll_mode == PG_SCROLL_M_OFF) return; @@ -178,9 +173,9 @@ void CComponentsForm::execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& / } } -void CComponentsForm::execExit(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const struct msg_list_t * const msg_list, const size_t& key_count) +void CComponentsForm::execExit(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec, const std::vector& v_msg_list) { - execKey(msg, data, res, exit_loop, msg_list, key_count, true); + execKey(msg, data, res, cancel_exec, v_msg_list, true); } @@ -558,14 +553,14 @@ void CComponentsForm::setPageCount(const u_int8_t& pageCount) u_int8_t CComponentsForm::getPageCount() { - u_int8_t num = 1; + u_int8_t num = 0; for(size_t i=0; igetPageNumber(); num = max(item_num, num); } //convert type, possible -Wconversion warnings! - page_count = static_cast(num); + page_count = static_cast(num+1); return page_count; } diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 2efc89bf5..82a1a4df2 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -56,6 +56,9 @@ class CComponentsForm : public CComponentsItem ///enable/disable page scrolling, default enabled with page scroll mode up/down keys, see also enablePageScroll() int page_scroll_mode; + ///container for exit keys, default exit keys are CRCInput::RC_home and CRCInput::RC_setup + std::vector v_exit_keys; + ///initialize basic properties virtual void Init( const int& x_pos, const int& y_pos, const int& w, const int& h, const fb_pixel_t& color_frame, @@ -149,6 +152,11 @@ class CComponentsForm : public CComponentsItem ///exec main method, see also sub exec methods virtual int exec(); + ///adds additional exec key to current collection, default exit keys are CRCInput::RC_home and CRCInput::RC_setup + virtual void addExitKey(const neutrino_msg_t& key){v_exit_keys.push_back(key);} + ///remove all current exec keys from current collection, NOTE: use addExitKey() if new exec key is required + virtual void removeExitKeys(){v_exit_keys.clear();} + ///enum exec loop control enum { @@ -156,38 +164,29 @@ class CComponentsForm : public CComponentsItem EXIT = 1 }; ///execKey() methods handle events for defined neutrino messages, see class CRCInput::, this methodes contains a signal handler named OnExecMsg, so it is possible to connect with any common function or method - ///exec sub method for pressed keys, parameters1/2 by rev, parameter3 msg_list as struct contains a list of possible RC-messages for defined message, parameter4 defines size of struct, parameter5 force_exit default = false - virtual void execKey( neutrino_msg_t& msg, - neutrino_msg_data_t& data, - int& res, - bool& exit_loop, - const struct msg_list_t * const msg_list, - const size_t& key_count, - bool force_exit = false); ///exec sub method for pressed keys, parameters1/2 by rev, parameter3 msg_list as vector contains a list of possible RC-messages for defined message, parameter4 force_exit default = false virtual void execKey( neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, - bool& exit_loop, + bool& cancel_exec, const std::vector& msg_list, bool force_exit = false); ///exec sub method for pressed key, parameters1/2 by rev, parameter3 force_exit default = false virtual bool execKey( neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, - bool& exit_loop, + bool& cancel_exec, const neutrino_msg_t& msg_val, bool force_exit = false); ///exec sub method for page scroll, parameter1 neutrino_msg_t by rev - virtual void execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res); + virtual void execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec); ///exec sub method for exit loop, parameters by rev virtual void execExit( neutrino_msg_t& msg, neutrino_msg_data_t& data, - int& res, bool& exit_loop, - const struct msg_list_t * const msg_list, - const size_t& key_count); + int& res, bool& cancel_exec, + const std::vector& v_msg_list); ///enum scroll direction enum diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index b5fd5ddef..5986bf888 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -124,7 +124,8 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const cc_btn_font = NULL; cc_btn_icon = icon_name; cc_btn_capt = caption; - cc_btn_msg = CRCInput::RC_nokey; + cc_directKey = CRCInput::RC_nokey; + cc_directKeyAlt = cc_directKey; cc_btn_result = -1; cc_btn_alias = -1; @@ -187,12 +188,13 @@ void CComponentsButton::initCaption() } //set basic properties + int w_frame = max(fr_thickness, fr_thickness_sel); if (cc_btn_capt_obj){ //position and size - int x_cap = fr_thickness; + int x_cap = w_frame; x_cap += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() : 0; - int w_cap = width - fr_thickness - append_x_offset - x_cap - fr_thickness; + int w_cap = width - w_frame - append_x_offset - x_cap - w_frame; int h_cap = height*65/100 /*- 2*fr_thickness*/; /*NOTE: @@ -201,7 +203,7 @@ void CComponentsButton::initCaption() but text render isn't wrong here, because capitalized chars or long chars like e. 'q', 'y' are considered! Therefore we here need other icons or a hack, that considers some different height values. */ - int y_cap = height/2 - h_cap/2 + fr_thickness/2; + int y_cap = height/2 - h_cap/2 + w_frame/2; cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap); @@ -216,14 +218,14 @@ void CComponentsButton::initCaption() cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? cc_btn_capt_col : cc_btn_capt_disable_col); //corner of text item - cc_btn_capt_obj->setCorner(corner_rad-fr_thickness, corner_type); + cc_btn_capt_obj->setCorner(corner_rad-w_frame, corner_type); } //handle common position of icon and text inside container required for alignment - int w_required = fr_thickness + append_x_offset; + int w_required = w_frame + append_x_offset; w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + append_x_offset : 0; w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_capt) : 0; - w_required += append_x_offset + fr_thickness; + w_required += append_x_offset + w_frame; //dynamic width if (w_required > width){ @@ -235,7 +237,7 @@ void CComponentsButton::initCaption() int x_icon = width/2 - w_required/2 /*+ fr_thickness + append_x_offset*/; int w_icon = 0; if (cc_btn_icon_obj){ - x_icon += fr_thickness + append_x_offset; + x_icon += w_frame + append_x_offset; cc_btn_icon_obj->setXPos(x_icon); w_icon = cc_btn_icon_obj->getWidth(); /*in case of dynamic changed height of caption or button opbject itself, diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 1b9123b41..80653e2be 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -70,8 +70,10 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen ///property: icon name, only icons supported, to find in gui/widget/icons.h std::string cc_btn_icon; - ///property: assigned event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonEventMsg(), getButtonEventMsg() - neutrino_msg_t cc_btn_msg; + ///property: assigned event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKey(), getButtonDirectKey() + neutrino_msg_t cc_directKey; + ///property: assigned an alternate event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKeyAlt(), getButtonDirectKeyAlt() + neutrino_msg_t cc_directKeyAlt; ///property: assigned return value, see also setButtonResult(), getButtonResult(), default value = -1 (not defined) int cc_btn_result; ///property: assigned alias value, see also setButtonAlias(), getButtonAlias(), default value = -1 (not defined) @@ -133,7 +135,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); ///set text color - virtual void setButtonTextColor(fb_pixel_t text_color, fb_pixel_t text_color_disabled = COL_MENUCONTENTINACTIVE_TEXT){cc_btn_capt_col = text_color; cc_btn_capt_disable_col = text_color_disabled;} + inline virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;}; /**Member to modify background behavior of embeded caption object. * @param[in] mode @@ -162,9 +164,9 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen virtual void setCaption(const neutrino_locale_t locale_text); ///get caption, type as std::string - virtual std::string getCaptionString(){return cc_btn_capt;}; + inline virtual std::string getCaptionString(){return cc_btn_capt;}; ///get loacalized caption id, type = neutrino_locale_t - virtual neutrino_locale_t getCaptionLocale(){return cc_btn_capt_locale;}; + inline virtual neutrino_locale_t getCaptionLocale(){return cc_btn_capt_locale;}; ///property: set font for label caption, parameter as font object, value NULL causes usaage of dynamic font virtual void setButtonFont(Font* font){cc_btn_font = font; initCCBtnItems();}; @@ -176,17 +178,21 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); ///assigns an event msg value to button object, parameter1 as neutrino_msg_t, see driver/rcinput.h for possible values - virtual void setButtonEventMsg(const neutrino_msg_t& msg){cc_btn_msg = msg;}; - ///return an event msg value to button object, see driver/rcinput.h for possible values - inline virtual neutrino_msg_t getButtonEventMsg(){return cc_btn_msg;}; + inline virtual void setButtonDirectKey(const neutrino_msg_t& msg){cc_directKey = msg;}; + ///assigns an alternate event msg value to button object, parameter1 as neutrino_msg_t, see driver/rcinput.h for possible values + inline virtual void setButtonDirectKeyA(const neutrino_msg_t& msg){cc_directKeyAlt = msg;}; + ///returns an event msg value to button object, see driver/rcinput.h for possible values + inline virtual neutrino_msg_t getButtonDirectKey(){return cc_directKey;}; + ///returns an alternate event msg value to button object, but returns the primary direct key if no key was defined, see driver/rcinput.h for possible values + inline virtual neutrino_msg_t getButtonDirectKeyA(){return cc_directKeyAlt != CRCInput::RC_nokey ? cc_directKeyAlt : cc_directKey ;}; ///assigns an return value to button object, parameter1 as int - virtual void setButtonResult(const int& result_value){cc_btn_result = result_value;}; + inline virtual void setButtonResult(const int& result_value){cc_btn_result = result_value;}; ///returns current result value of button object inline virtual int getButtonResult(){return cc_btn_result;}; ///assigns an alias value to button object, parameter1 as int, e.g. previous known as mbYes, mbNo... from message boxes - virtual void setButtonAlias(const int& alias_value){cc_btn_alias = alias_value;}; + inline virtual void setButtonAlias(const int& alias_value){cc_btn_alias = alias_value;}; ///returns an alias value from button object, see also cc_btn_alias inline virtual int getButtonAlias(){return cc_btn_alias;}; }; @@ -239,6 +245,7 @@ class CComponentsButtonGreen : public CComponentsButton :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_GREEN; + }; CComponentsButtonGreen( const int& x_pos, const int& y_pos, const int& w, const int& h, const neutrino_locale_t& caption_locale, diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 0eec2443c..5b6da399e 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -144,9 +144,8 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont CComponentsButton *btn = new CComponentsButton(0, CC_CENTERED, w_btn_min, (btn_contour ? height-2*fr_thickness : height), txt, icon_name); btn->setButtonFont(ccf_btn_font); btn->doPaintBg(btn_contour); - btn->enableFrame(btn_contour); - btn->setButtonTextColor(COL_MENUFOOT_TEXT); - btn->setButtonEventMsg(content[i].btn_msg); + btn->setButtonDirectKey(content[i].directKey); + btn->setButtonDirectKeyA(content[i].directKeyAlt); btn->setButtonResult(content[i].btn_result); btn->setButtonAlias(content[i].btn_alias); @@ -164,6 +163,9 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont btn->setColorFrame(f_col); } + if (btn_contour) + btn->setFrameThickness(3, 3); + chain->addCCItem(btn); //set x position of next button object @@ -200,7 +202,8 @@ void CComponentsFooter::setButtonLabels(const struct button_label_l * const cont for (size_t i= 0; i< label_count; i++){ buttons[i].button = content[i].button; buttons[i].text = content[i].locale != NONEXISTANT_LOCALE ? g_Locale->getText(content[i].locale) : ""; - buttons[i].btn_msg = content[i].btn_msg; + buttons[i].directKey = content[i].directKey; + buttons[i].directKeyAlt = content[i].directKeyAlt; buttons[i].btn_result = content[i].btn_result; buttons[i].btn_alias = content[i].btn_alias; } @@ -217,7 +220,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label * const conten buttons[i].locale = content[i].locale; //NOTE: here are used default values, because old button label struct don't know about this, //if it possible, don't use this methode! - buttons[i].btn_msg = CRCInput::RC_nokey; + buttons[i].directKey = buttons[i].directKeyAlt = CRCInput::RC_nokey; buttons[i].btn_result = -1; buttons[i].btn_alias = -1; } @@ -232,7 +235,8 @@ void CComponentsFooter::setButtonLabels(const vector &v_content, for (size_t i= 0; i< label_count; i++){ buttons[i].button = v_content[i].button; buttons[i].locale = v_content[i].locale; - buttons[i].btn_msg = v_content[i].btn_msg; + buttons[i].directKey = v_content[i].directKey; + buttons[i].directKeyAlt = v_content[i].directKeyAlt; buttons[i].btn_result = v_content[i].btn_result; buttons[i].btn_alias = v_content[i].btn_alias; } @@ -248,7 +252,8 @@ void CComponentsFooter::setButtonLabels(const vector &v_content, for (size_t i= 0; i< label_count; i++){ buttons[i].button = v_content[i].button; buttons[i].text = v_content[i].text; - buttons[i].btn_msg = v_content[i].btn_msg; + buttons[i].directKey = v_content[i].directKey; + buttons[i].directKeyAlt = v_content[i].directKeyAlt; buttons[i].btn_result = v_content[i].btn_result; buttons[i].btn_alias = v_content[i].btn_alias; } @@ -256,24 +261,39 @@ void CComponentsFooter::setButtonLabels(const vector &v_content, setButtonLabels(buttons, label_count, chain_width, label_width); } -void CComponentsFooter::setButtonLabel(const char *button_icon, const std::string& text, const int& chain_width, const int& label_width, const neutrino_msg_t& msg, const int& result_value, const int& alias_value) +void CComponentsFooter::setButtonLabel( const char *button_icon, + const std::string& text, + const int& chain_width, + const int& label_width, + const neutrino_msg_t& msg, + const int& result_value, + const int& alias_value, + const neutrino_msg_t& directKeyAlt) { button_label_s button[1]; button[0].button = button_icon; button[0].text = text; - button[0].btn_msg = msg; + button[0].directKey = msg; + button[0].directKeyAlt = directKeyAlt; button[0].btn_result = result_value; button[0].btn_alias = alias_value; setButtonLabels(button, 1, chain_width, label_width); } -void CComponentsFooter::setButtonLabel(const char *button_icon, const neutrino_locale_t& locale, const int& chain_width, const int& label_width, const neutrino_msg_t& msg, const int& result_value, const int& alias_value) +void CComponentsFooter::setButtonLabel( const char *button_icon, + const neutrino_locale_t& locale, + const int& chain_width, + const int& label_width, + const neutrino_msg_t& msg, + const int& result_value, + const int& alias_value, + const neutrino_msg_t& directKeyAlt) { string txt = locale != NONEXISTANT_LOCALE ? g_Locale->getText(locale) : ""; - setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value); + setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value, directKeyAlt); } void CComponentsFooter::showButtonContour(bool show) @@ -325,3 +345,14 @@ void CComponentsFooter::paintButtons(const int& x_pos, this->paint(do_save_bg); } + +void CComponentsFooter::setButtonText(const uint& btn_id, const std::string& text) +{ + CComponentsItem *item = getButtonChainObject()->getCCItem(btn_id); + if (item){ + CComponentsButton *button = static_cast(item); + button->setCaption(text); + } + else + dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] Error: can't set button text, possible wrong btn_id=%u, item=%p...\n", __func__, __LINE__, btn_id, item); +} diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h index bf9a16e2a..053a6d3da 100644 --- a/src/gui/components/cc_frm_footer.h +++ b/src/gui/components/cc_frm_footer.h @@ -34,7 +34,8 @@ typedef struct button_label_s { const char * button; std::string text; - neutrino_msg_t btn_msg; + neutrino_msg_t directKey; + neutrino_msg_t directKeyAlt; int btn_result; int btn_alias; } button_label_s_struct; @@ -43,7 +44,8 @@ typedef struct button_label_l { const char * button; neutrino_locale_t locale; - neutrino_msg_t btn_msg; + neutrino_msg_t directKey; + neutrino_msg_t directKeyAlt; int btn_result; int btn_alias; } button_label_l_struct; @@ -106,9 +108,23 @@ class CComponentsFooter : public CComponentsHeader void setButtonLabels(const struct button_label * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0); ///add single button label with string label type as content, chain_width as int, label width as int - void setButtonLabel(const char *button_icon, const std::string& text, const int& chain_width = 0, const int& label_width = 0, const neutrino_msg_t& msg = CRCInput::RC_nokey, const int& result_value = -1, const int& alias_value = -1); + void setButtonLabel( const char *button_icon, + const std::string& text, + const int& chain_width = 0, + const int& label_width = 0, + const neutrino_msg_t& msg = CRCInput::RC_nokey, + const int& result_value = -1, + const int& alias_value = -1, + const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey); ///add single button label with locale label type as content, chain_width as int, label width as int - void setButtonLabel(const char *button_icon, const neutrino_locale_t& locale, const int& chain_width = 0, const int& label_width = 0, const neutrino_msg_t& msg = CRCInput::RC_nokey, const int& result_value = -1, const int& alias_value = -1); + void setButtonLabel( const char *button_icon, + const neutrino_locale_t& locale, + const int& chain_width = 0, + const int& label_width = 0, + const neutrino_msg_t& msg = CRCInput::RC_nokey, + const int& result_value = -1, + const int& alias_value = -1, + const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey); ///causes show/hide countour of button frame and background, parameter bool show, default= true void showButtonContour(bool show = true); @@ -120,12 +136,26 @@ class CComponentsFooter : public CComponentsHeader ///returns selected button object, return value as pointer to object, NULL means nothing is selected CComponentsButton* getSelectedButtonObject(); + /*! + Sets a new text to an already predefined button. + 1st parameter 'btn_id' accepts current id of an already defined button. 2nd parameter sets the new text as std::string + Usage: + Buttons come with any text eg. 'Ok', 'No', 'Yes' ...whatever and this member allows to manipulate the text via button id. + Button id means the showed button begins from the left position of button chain, starts with value=0, also to get via getButtonChainObject()->getCCItemId([CComponentsButton*]) + example: 1st buttons text is 'Hello', 2nd Button's text is 'You!', + Now we want to change the text of 2nd button to 'World", so we must do this: + setButtonText(1, "World"); + Wrong id's will be ignored. + */ + void setButtonText(const uint& btn_id, const std::string& text); + ///property: set font for label caption, parameter as font object, value NULL causes usage of dynamic font void setButtonFont(Font* font){ccf_btn_font = font;}; ///returns pointer to internal button container CComponentsFrmChain* getButtonChainObject(){return chain;}; + ///this is a nearly methode similar with the older button handler find in gui/widget/buttons.h, some parameters are different, but require minimalized input ///this member sets some basic parameters and will paint concurrently on execute, explicit call of paint() is not required void paintButtons( const int& x_pos, diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 212db8ef7..6d1807798 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -222,6 +222,11 @@ class CComponentsWindow : public CComponentsForm ///paint all window items, this overwriting paint() from CComponentsForm void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + + ///adds additional exec key to current collection, default exit keys are CRCInput::RC_home and CRCInput::RC_setup + virtual void addExitKey(const neutrino_msg_t& key){getBodyObject()->addExitKey(key);} + ///remove all current exec keys from current collection, NOTE: use addExitKey() if new exec key is required + virtual void removeExitKeys(){getBodyObject()->removeExitKeys();} }; class CComponentsWindowMax : public CComponentsWindow diff --git a/src/gui/components/cc_signals.h b/src/gui/components/cc_signals.h index feee1ef67..da6a6d8b2 100644 --- a/src/gui/components/cc_signals.h +++ b/src/gui/components/cc_signals.h @@ -102,7 +102,7 @@ class CComponentsSignals : public sigc::trackable sigc::signal OnAfterExec; ///signal on execute of CComponentsForm::exec() - sigc::signal OnExec; + sigc::signal OnExec; ///signal on received message in CComponentsForm::execKey() sigc::signal OnExecMsg; diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 549bf2c30..6a3490a6a 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -125,9 +125,9 @@ typedef struct cc_screen_data_t //combination of rc messages with related icon typedef struct msg_list_t { - neutrino_msg_t msg; + neutrino_msg_t directKey; const char* icon; -} key_list_t; +} msg_list_struct_t; //align types enum diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 4cd2ef8a3..9b2f2026b 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include "bouquetlist.h" @@ -1293,7 +1293,7 @@ int EpgPlus::MenuTargetAddReminder::exec (CMenuTarget * /*parent*/, const std::s g_Timerd->addZaptoTimerEvent (this->epgPlus->selectedChannelEntry->channel->getChannelID(), (*It)->channelEvent.startTime - (g_settings.zapto_pre_time * 60), (*It)->channelEvent.startTime - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, (*It)->channelEvent.eventID, (*It)->channelEvent.startTime, 0); ShowMsg (LOCALE_TIMER_EVENTTIMED_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTTIMED_MSG) - , CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + , CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else printf ("timerd not available\n"); } @@ -1330,7 +1330,7 @@ int EpgPlus::MenuTargetAddRecordTimer::exec (CMenuTarget * /*parent*/, const std printf("already found in moviebrowser: %s\n", rec_title); char message[1024]; snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_RECORDING_ALREADY_FOUND), rec_title); - doRecord = (ShowMsg(LOCALE_RECORDING_ALREADY_FOUND_CHECK, message, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes); + doRecord = (ShowMsg(LOCALE_RECORDING_ALREADY_FOUND_CHECK, message, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes); } } if (g_Timerd->isTimerdAvailable() && doRecord) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 521d9b3d7..9133b56bd 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -1101,7 +1101,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start printf("already found in moviebrowser: %s\n", rec_title); char message[1024]; snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_RECORDING_ALREADY_FOUND), rec_title); - doRecord = (ShowMsg(LOCALE_RECORDING_ALREADY_FOUND_CHECK, message, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes); + doRecord = (ShowMsg(LOCALE_RECORDING_ALREADY_FOUND_CHECK, message, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes); } } if (doRecord && !call_fromfollowlist) @@ -1131,11 +1131,11 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgData.eventID, epgData.epg_times.startzeit, epgData.epg_times.startzeit - (ANNOUNCETIME + 120 ), TIMERD_APIDS_CONF, true, epgData.epg_times.startzeit - (ANNOUNCETIME + 120) > time(NULL), recDir, true); - ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } else { - ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } @@ -1165,7 +1165,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start stars = tmdb->getStars(); showText(showPos, sy + toph, tmdb_active); } else { - ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NODETAILED, CMessageBox::mbrOk , CMessageBox::mbrOk); + ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NODETAILED, CMsgBox::mbrOk , CMsgBox::mbrOk); } delete tmdb; } else { @@ -1194,7 +1194,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgData.epg_times.startzeit - (g_settings.zapto_pre_time * 60), epgData.epg_times.startzeit - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, epgData.eventID, epgData.epg_times.startzeit, 0); - ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index ddb63f8cb..9ebeeba47 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include @@ -475,7 +475,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna printf("already found in moviebrowser: %s\n", rec_title); char message[1024]; snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_RECORDING_ALREADY_FOUND), rec_title); - doRecord = (ShowMsg(LOCALE_RECORDING_ALREADY_FOUND_CHECK, message, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes); + doRecord = (ShowMsg(LOCALE_RECORDING_ALREADY_FOUND_CHECK, message, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes); } } t_channel_id used_id = IS_WEBTV(channel_id) ? channel_id : evtlist[selected].channelID; @@ -511,7 +511,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna evtlist[selected].startTime - (g_settings.zapto_pre_time * 60), evtlist[selected].startTime - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, evtlist[selected].eventID, evtlist[selected].startTime, 0); - //ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + //ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(evtlist[selected].channelID ); diff --git a/src/gui/favorites.cpp b/src/gui/favorites.cpp index c3d978f99..041cf35d1 100644 --- a/src/gui/favorites.cpp +++ b/src/gui/favorites.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -122,7 +122,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) #if 0 if (!bouquetList) { - ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); return res; } #endif @@ -147,7 +147,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) { if (status & 2) str += g_Locale->getText(LOCALE_EXTRA_CHADDED); else str += g_Locale->getText(LOCALE_EXTRA_CHALREADYINBQ); - ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else { @@ -155,7 +155,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) if (status & 2) str += g_Locale->getText(LOCALE_FAVORITES_CHADDED); else str += g_Locale->getText(LOCALE_FAVORITES_CHALREADYINBQ); if (status) str += g_Locale->getText(LOCALE_FAVORITES_FINALHINT); - ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 8a0f84f26..736fc6b0f 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -800,7 +800,7 @@ bool CFileBrowser::exec(const char * const dirname) _msg << filelist[selected].getFileName(); _msg << " " << g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if (ShowMsg(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMsgBox::mbrNo, CMsgBox::mbYes|CMsgBox::mbNo)==CMsgBox::mbrYes) { std::string n = filelist[selected].Name; recursiveDelete(n.c_str()); diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index a8afb2431..dcb79167e 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -375,8 +375,8 @@ void CHDDMenuHandler::setRecordPath(std::string &dev) } bool old_menu = in_menu; in_menu = false; - int res = ShowMsg(LOCALE_RECORDINGMENU_DEFDIR, LOCALE_HDD_SET_RECDIR, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); - if(res == CMessageBox::mbrYes) { + int res = ShowMsg(LOCALE_RECORDINGMENU_DEFDIR, LOCALE_HDD_SET_RECDIR, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo); + if(res == CMsgBox::mbrYes) { g_settings.network_nfs_recordingdir = newpath; CRecordManager::getInstance()->SetDirectory(g_settings.network_nfs_recordingdir); if(g_settings.timeshiftdir.empty()) @@ -426,8 +426,8 @@ int CHDDMenuHandler::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t dat if (added && !mounted && tmp != "sr") { std::string message = dev + ": " + g_Locale->getText(LOCALE_HDD_MOUNT_FAILED); message += std::string(" ") + g_Locale->getText(LOCALE_HDD_FORMAT) + std::string(" ?"); - int res = ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); - if(res == CMessageBox::mbrYes) { + int res = ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo); + if(res == CMsgBox::mbrYes) { unsigned char * p = new unsigned char[dev.size() + 1]; if (p) { sprintf((char *)p, "%s", dev.c_str()); @@ -778,7 +778,7 @@ _show_menu: void CHDDMenuHandler::showError(neutrino_locale_t err) { - ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(err), CMessageBox::mbrOk, CMessageBox::mbOk); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(err), CMsgBox::mbrOk, CMsgBox::mbOk); } int CHDDMenuHandler::formatDevice(std::string dev) @@ -809,8 +809,8 @@ int CHDDMenuHandler::formatDevice(std::string dev) std::string mkfscmd = devtool->mkfs + " " + devtool->mkfs_options + " " + partname; printf("mkfs cmd: [%s]\n", mkfscmd.c_str()); - res = ShowMsg(LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); - if(res != CMessageBox::mbrYes) + res = ShowMsg(LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo ); + if(res != CMsgBox::mbrYes) return menu_return::RETURN_REPAINT; bool srun = my_system(3, "killall", "-9", "smbd"); diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 3db50e64c..4985536fa 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -330,7 +330,7 @@ int CKeybindSetup::showKeySetup() strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART2)); strcat(RC_HW_msg, RC_HW_str[g_settings.remote_control_hardware]); strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART3)); - if(ShowMsg(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMessageBox::mbrNo) { + if(ShowMsg(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO, 450, 15) == CMsgBox::mbrNo) { g_settings.remote_control_hardware = org_remote_control_hardware; g_RCInput->CRCInput::set_rc_hw(); } diff --git a/src/gui/lua/lua_hintbox.cpp b/src/gui/lua/lua_hintbox.cpp index cfa25f203..eec52f441 100644 --- a/src/gui/lua/lua_hintbox.cpp +++ b/src/gui/lua/lua_hintbox.cpp @@ -149,7 +149,7 @@ int CLuaInstHintbox::HintboxExec(lua_State *L) res = messages_return::cancel_info; else if (msg == CRCInput::RC_home) res = messages_return::cancel_all; - else if ((D->b->has_scrollbar()) && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))) { + else if (/*(D->b->has_scrollbar()) &&*/ ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))) { if (msg == CRCInput::RC_up) D->b->scroll_up(); else diff --git a/src/gui/lua/lua_menue.cpp b/src/gui/lua/lua_menue.cpp index b704b56c8..c8f0fbf5c 100644 --- a/src/gui/lua/lua_menue.cpp +++ b/src/gui/lua/lua_menue.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/gui/lua/lua_messagebox.cpp b/src/gui/lua/lua_messagebox.cpp index 303db0541..9611a1254 100644 --- a/src/gui/lua/lua_messagebox.cpp +++ b/src/gui/lua/lua_messagebox.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include "luainstance.h" @@ -74,10 +74,10 @@ int CLuaInstMessagebox::MessageboxExec(lua_State *L) std::string tmp; if (tableLookup(L, "align", tmp)) { table_key mb[] = { - { "center1", CMessageBox::mbBtnAlignCenter1 }, - { "center2", CMessageBox::mbBtnAlignCenter2 }, - { "left", CMessageBox::mbBtnAlignLeft }, - { "right", CMessageBox::mbBtnAlignRight }, + { "center1", CMsgBox::mbBtnAlignCenter1 }, + { "center2", CMsgBox::mbBtnAlignCenter2 }, + { "left", CMsgBox::mbBtnAlignLeft }, + { "right", CMsgBox::mbBtnAlignRight }, { NULL, 0 } }; for (int i = 0; mb[i].name; i++) @@ -93,12 +93,12 @@ int CLuaInstMessagebox::MessageboxExec(lua_State *L) lua_pushvalue(L, -2); const char *val = lua_tostring(L, -2); table_key mb[] = { - { "yes", CMessageBox::mbYes }, - { "no", CMessageBox::mbNo }, - { "cancel", CMessageBox::mbCancel }, - { "all", CMessageBox::mbAll }, - { "back", CMessageBox::mbBack }, - { "ok", CMessageBox::mbOk }, + { "yes", CMsgBox::mbYes }, + { "no", CMsgBox::mbNo }, + { "cancel", CMsgBox::mbCancel }, + { "all", CMsgBox::mbAll }, + { "back", CMsgBox::mbBack }, + { "ok", CMsgBox::mbOk }, { NULL, 0 } }; for (int i = 0; mb[i].name; i++) @@ -109,14 +109,14 @@ int CLuaInstMessagebox::MessageboxExec(lua_State *L) } lua_pop(L, 1); if ((show_buttons & 0xFF) == 0) - show_buttons |= CMessageBox::mbAll; + show_buttons |= CMsgBox::mbAll; table_key mbr[] = { - { "yes", CMessageBox::mbrYes }, - { "no", CMessageBox::mbrNo }, - { "cancel", CMessageBox::mbrCancel }, - { "back", CMessageBox::mbrBack }, - { "ok", CMessageBox::mbrOk }, + { "yes", CMsgBox::mbrYes }, + { "no", CMsgBox::mbrNo }, + { "cancel", CMsgBox::mbrCancel }, + { "back", CMsgBox::mbrBack }, + { "ok", CMsgBox::mbrOk }, { NULL, 0 } }; if (tableLookup(L, "default", tmp)) { @@ -127,7 +127,7 @@ int CLuaInstMessagebox::MessageboxExec(lua_State *L) } } - int res = ShowMsg(name, text, (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); + int res = ShowMsg(name, text, (CMsgBox::msg_result_t) default_button, (CMsgBox::button_define_t) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); tmp = "cancel"; for (int i = 0; mbr[i].name; i++) diff --git a/src/gui/lua/lua_messagebox.h b/src/gui/lua/lua_messagebox.h index 83d2114e2..1269f8332 100644 --- a/src/gui/lua/lua_messagebox.h +++ b/src/gui/lua/lua_messagebox.h @@ -25,7 +25,7 @@ class CLuaMessagebox { public: - CMessageBox *b; + CMsgBox *b; CLuaMessagebox(); ~CLuaMessagebox(); }; diff --git a/src/gui/lua/lua_misc.cpp b/src/gui/lua/lua_misc.cpp index 9b965ae5d..739f7a568 100644 --- a/src/gui/lua/lua_misc.cpp +++ b/src/gui/lua/lua_misc.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/gui/lua/lua_video.cpp b/src/gui/lua/lua_video.cpp index dfef5c7e5..9e1b6774c 100644 --- a/src/gui/lua/lua_video.cpp +++ b/src/gui/lua/lua_video.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index b76adc465..0adee6672 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -125,7 +125,7 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey) unsigned num = CEitManager::getInstance()->getEventsCount(); char str[128]; sprintf(str, "Event count: %d", num); - ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMsgBox::mbrBack, CMsgBox::mbBack); return menu_return::RETURN_REPAINT; } else if(actionKey == "energy") diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index 50a5ed1f8..438e3eebe 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -230,7 +230,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) buf += " "; buf += satname; buf += " ?"; - store = (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + store = (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf,CMsgBox::mbrNo,CMsgBox::mbNo|CMsgBox::mbYes) == CMsgBox::mbrYes); } } if(store) diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 11f4c5156..147db2845 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include #include @@ -798,7 +798,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) else if (actionKey == "copy_onefile" || actionKey == "copy_several") { bool onefile = (actionKey == "copy_onefile"); - if ((show_mode == MB_SHOW_RECORDS) && (ShowMsg(LOCALE_MESSAGEBOX_INFO, onefile ? LOCALE_MOVIEBROWSER_COPY : LOCALE_MOVIEBROWSER_COPIES, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) + if ((show_mode == MB_SHOW_RECORDS) && (ShowMsg(LOCALE_MESSAGEBOX_INFO, onefile ? LOCALE_MOVIEBROWSER_COPY : LOCALE_MOVIEBROWSER_COPIES, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_COPYING); hintBox->paint(); @@ -810,7 +810,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) bool res = mc.copyMovie(m_movieSelectionHandler, onefile); //g_RCInput->clearRCMsg(); if (res == 0) - ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_COPY_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_COPY_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); else m_doLoadMovies = true; m_doRefresh = true; @@ -820,10 +820,10 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) { #if 0 if ((m_movieSelectionHandler == playing_info) && (NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode())) - ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Impossible to cut playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Impossible to cut playing movie.", CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); else #endif - if ((show_mode == MB_SHOW_RECORDS) && (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_CUT, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) + if ((show_mode == MB_SHOW_RECORDS) && (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_CUT, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_CUTTING); hintBox->paint(); @@ -835,7 +835,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) bool res = mc.cutMovie(m_movieSelectionHandler); //g_RCInput->clearRCMsg(); if (!res) - ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_CUT_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_CUT_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); else m_doLoadMovies = true; m_doRefresh = true; @@ -846,12 +846,12 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) if ((show_mode == MB_SHOW_RECORDS) && m_movieSelectionHandler != NULL) { if ((m_movieSelectionHandler == playing_info) && (NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode())) - ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED_PLAYING, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED_PLAYING, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); else if (m_movieSelectionHandler->bookmarks.end == 0) - ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_BOOK_NO_END, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_BOOK_NO_END, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); else { - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_TRUNCATE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_TRUNCATE, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_TRUNCATING); hintBox->paint(); @@ -861,7 +861,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) delete hintBox; g_RCInput->clearRCMsg(); if (!res) - ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); else m_doLoadMovies = true; m_doRefresh = true; @@ -1745,7 +1745,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) if (!fname.empty()) { //delete Cover - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_DELETE_SCREENSHOT, CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_DELETE_SCREENSHOT, CMsgBox::mbrNo, CMsgBox:: mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) { unlink(fname.c_str()); refresh(); @@ -2169,7 +2169,7 @@ bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk) int msgBoxWidth = 450; std::string msg = formatDeleteMsg(movieinfo, msgFont, msgBoxWidth); - if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo, NULL, msgBoxWidth)==CMessageBox::mbrYes)) + if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMsgBox::mbrYes, CMsgBox::mbYes|CMsgBox::mbNo, NULL, msgBoxWidth)==CMsgBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); hintBox->paint(); @@ -2245,7 +2245,7 @@ bool CMovieBrowser::onDelete(bool cursor_only) char buf1[1024]; snprintf(buf1, sizeof(buf1), g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str()); if (ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, - CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) + CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30, false) == CMsgBox::mbrNo) toDelete = false; else { CTimerd::RecordingStopInfo recinfo; @@ -2266,7 +2266,7 @@ bool CMovieBrowser::onDelete(bool cursor_only) if (!dellist.empty()) { bool skipAsk = false; if (dellist_cnt > 1) - skipAsk = (ShowMsg(LOCALE_FILEBROWSER_DELETE, LOCALE_MOVIEBROWSER_DELETE_ALL, CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes); + skipAsk = (ShowMsg(LOCALE_FILEBROWSER_DELETE, LOCALE_MOVIEBROWSER_DELETE_ALL, CMsgBox::mbrNo, CMsgBox:: mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes); for (dellist_it = dellist.begin(); dellist_it != dellist.end(); ++dellist_it) result |= onDeleteFile((MI_MOVIE_INFO *)&(*dellist_it), skipAsk); dellist.clear(); @@ -3608,7 +3608,7 @@ int CYTCacheSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & ac cYTCache::getInstance()->remove(&movieBrowser->yt_completed[selected - movieBrowser->yt_completed_offset]); } else if (actionKey.empty()) { if (movieBrowser->yt_pending_offset && selected >= movieBrowser->yt_pending_offset && selected < movieBrowser->yt_pending_end) { - if (ShowMsg (LOCALE_MOVIEBROWSER_YT_CACHE, g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CANCEL_TRANSFER), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) + if (ShowMsg (LOCALE_MOVIEBROWSER_YT_CACHE, g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CANCEL_TRANSFER), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]); else return menu_return::RETURN_NONE; diff --git a/src/gui/moviebrowser/mb_help.h b/src/gui/moviebrowser/mb_help.h index dc77e86d1..b16a1dd47 100644 --- a/src/gui/moviebrowser/mb_help.h +++ b/src/gui/moviebrowser/mb_help.h @@ -51,21 +51,31 @@ class CMovieHelp : public CMenuTarget int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) { - Helpbox helpbox; - helpbox.addLine(NEUTRINO_ICON_BUTTON_RED, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_RED)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_GREEN, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_GREEN)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_YELLOW, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_YELLOW)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_BLUE, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_BLUE)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_MENU_SMALL,g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_MENU)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_PLAY, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_PLAY)); - helpbox.addLine(""); - helpbox.addLine(NEUTRINO_ICON_BUTTON_OKAY, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_OKAY)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_MUTE_SMALL,g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_MUTE)); - helpbox.addLine(""); - helpbox.addLine(NEUTRINO_ICON_BUTTON_LEFT, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_LEFT)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_RIGHT, g_Locale->getText(LOCALE_MOVIEBROWSER_HELP_BUTTON_RIGHT)); - helpbox.show(LOCALE_MESSAGEBOX_INFO); - return(0); + Helpbox helpbox(g_Locale->getText(LOCALE_HELP_BOX_TITLE)); + helpbox.addLine("Standard functions", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 10, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]); + helpbox.addSeparatorLine(); + helpbox.addLine(NEUTRINO_ICON_BUTTON_RED, "Change sort", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addLine(NEUTRINO_ICON_BUTTON_GREEN, "Show filter window", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addLine(NEUTRINO_ICON_BUTTON_YELLOW, "Changing the active window", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addLine(NEUTRINO_ICON_BUTTON_BLUE, "Reload recording info", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addLine(NEUTRINO_ICON_BUTTON_MENU, "Open Moviebrowser menue", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addLine("+/- Change view", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addSeparator(); +#if 0 + helpbox.addPagebreak(); +#endif + helpbox.addLine("During playback", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 10, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]); + helpbox.addSeparatorLine(); + helpbox.addLine(NEUTRINO_ICON_BUTTON_BLUE, "Marking menu", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + helpbox.addLine(NEUTRINO_ICON_BUTTON_0, "Not perform marking action", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, 35, 30); + + helpbox.addExitKey(CRCInput::RC_ok); + + helpbox.show(); + int ret = helpbox.exec(); + helpbox.hide(); + + return ret; } }; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 12e74be70..960022af5 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -2187,7 +2187,7 @@ void CMoviePlayerGui::UpdatePosition() void CMoviePlayerGui::showHelpTS() { - Helpbox helpbox; + Helpbox helpbox(g_Locale->getText(LOCALE_MESSAGEBOX_INFO)); helpbox.addLine(NEUTRINO_ICON_BUTTON_RED, g_Locale->getText(LOCALE_MOVIEPLAYER_TSHELP1)); helpbox.addLine(NEUTRINO_ICON_BUTTON_GREEN, g_Locale->getText(LOCALE_MOVIEPLAYER_TSHELP2)); helpbox.addLine(NEUTRINO_ICON_BUTTON_YELLOW, g_Locale->getText(LOCALE_MOVIEPLAYER_TSHELP3)); @@ -2200,7 +2200,7 @@ void CMoviePlayerGui::showHelpTS() helpbox.addLine(NEUTRINO_ICON_BUTTON_7, g_Locale->getText(LOCALE_MOVIEPLAYER_TSHELP10)); helpbox.addLine(NEUTRINO_ICON_BUTTON_9, g_Locale->getText(LOCALE_MOVIEPLAYER_TSHELP11)); helpbox.addLine(g_Locale->getText(LOCALE_MOVIEPLAYER_TSHELP12)); - helpbox.show(LOCALE_MESSAGEBOX_INFO); + helpbox.show(); } void CMoviePlayerGui::selectChapter() diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index 717ee4098..a3b652e36 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include @@ -132,13 +132,13 @@ int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey=="restore") { - int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo, - CMessageBox::mbYes | - CMessageBox::mbNo , + int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMsgBox::mbrNo, + CMsgBox::mbYes | + CMsgBox::mbNo , NEUTRINO_ICON_QUESTION, width); - if (result == CMessageBox::mbrYes) { + if (result == CMsgBox::mbrYes) { restoreNetworkSettings(); } return res; @@ -552,7 +552,7 @@ bool CNetworkSetup::checkForIP() printf("[network setup] empty address %s\n", g_Locale->getText(n_settings[i].addr_name)); char msg[64]; snprintf(msg, 64, g_Locale->getText(LOCALE_NETWORKMENU_ERROR_NO_ADDRESS), g_Locale->getText(n_settings[i].addr_name)); - ShowMsg(LOCALE_MAINSETTINGS_NETWORK, msg, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR, width); + ShowMsg(LOCALE_MAINSETTINGS_NETWORK, msg, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_ERROR, width); return false; } } @@ -595,21 +595,21 @@ void CNetworkSetup::applyNetworkSettings() int CNetworkSetup::saveChangesDialog() { // Save the settings after changes, if user wants to! - int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW), CMessageBox::mbrYes, - CMessageBox::mbYes | - CMessageBox::mbNo , + int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW), CMsgBox::mbrYes, + CMsgBox::mbYes | + CMsgBox::mbNo , NEUTRINO_ICON_QUESTION, width); switch(result) { - case CMessageBox::mbrYes: + case CMsgBox::mbrYes: if (!checkForIP()) return menu_return::RETURN_REPAINT; return exec(NULL, "networkapply"); break; - case CMessageBox::mbrNo: //no + case CMsgBox::mbrNo: //no return exec(NULL, "restore"); break; } @@ -694,7 +694,7 @@ void CNetworkSetup::showCurrentNetworkSettings() + g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ": " + nameserver + '\n' + g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY ) + ": " + router; } - ShowMsg(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_NETWORKMENU_SHOW, text, CMsgBox::mbrBack, CMsgBox::mbBack); // UTF-8 } const char * CNetworkSetup::mypinghost(std::string &host) @@ -790,7 +790,7 @@ void CNetworkSetup::testNetworkSettings() } } - ShowMsg(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_NETWORKMENU_TEST, text, CMsgBox::mbrBack, CMsgBox::mbBack); // UTF-8 } int CNetworkSetup::showWlanList() @@ -804,7 +804,7 @@ int CNetworkSetup::showWlanList() bool found = get_wlan_list(g_settings.ifname, networks); hintBox.hide(); if (!found) { - ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMsgBox::mbrBack, CMsgBox::mbBack); // UTF-8 return res; } diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index a0605f430..b3df893e8 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -158,7 +158,7 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) char loc[200]; snprintf(loc, sizeof(loc), g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_REMOVE), pkg_vec[selected]->name.c_str()); - if (ShowMsg(LOCALE_OPKG_TITLE, loc, CMessageBox::mbrCancel, CMessageBox::mbYes | CMessageBox::mbCancel) != CMessageBox::mbrCancel) { + if (ShowMsg(LOCALE_OPKG_TITLE, loc, CMsgBox::mbrCancel, CMsgBox::mbYes | CMsgBox::mbCancel) != CMsgBox::mbrCancel) { if (parent) parent->hide(); execCmd(pkg_types[OM_REMOVE] + pkg_vec[selected]->name, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE_EVENT); @@ -239,7 +239,7 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) char l[200]; snprintf(l, sizeof(l), g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_REINSTALL), actionKey.c_str()); l[sizeof(l) - 1] = 0; - if (ShowMsg(LOCALE_OPKG_TITLE, l, CMessageBox::mbrCancel, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel) + if (ShowMsg(LOCALE_OPKG_TITLE, l, CMsgBox::mbrCancel, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel) return res; force = "--force-reinstall "; } @@ -577,11 +577,11 @@ int COPKGManager::showMenu() */ //restart neutrino: user decision if(!access( "/tmp/.restart", F_OK)){ - int msg = ShowMsg(LOCALE_OPKG_TITLE, g_Locale->getText(LOCALE_OPKG_SUCCESS_INSTALL), CMessageBox::mbrNo, - CMessageBox::mbYes | CMessageBox::mbNo, + int msg = ShowMsg(LOCALE_OPKG_TITLE, g_Locale->getText(LOCALE_OPKG_SUCCESS_INSTALL), CMsgBox::mbrNo, + CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_QUESTION, width); - if (msg == CMessageBox::mbrYes) + if (msg == CMsgBox::mbrYes) exit_action = "restart"; } //restart neutrino: forced @@ -971,8 +971,8 @@ bool COPKGManager::installPackage(const string& pkg_name, string options, bool f DisplayErrorMessage("Can't download package. Check network!"); break; case OM_UNSATISFIED_DEPS_ERR:{ - int msgRet = ShowMsg("Installation", "Unsatisfied deps while installation! Try to repeat to force dependencies!", CMessageBox::mbrCancel, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 600, -1); - if (msgRet == CMessageBox::mbrYes) + int msgRet = ShowMsg("Installation", "Unsatisfied deps while installation! Try to repeat to force dependencies!", CMsgBox::mbrCancel, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 600, -1); + if (msgRet == CMsgBox::mbrYes) return installPackage(pkg_name, "--force-depends"); break; } diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index ff36b8ef7..243f1584e 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -170,7 +170,7 @@ #include #include #include -#include "widget/messagebox.h" +#include "widget/msgbox.h" #include "widget/hintbox.h" #include "widget/keychooser.h" #include "color.h" @@ -734,13 +734,15 @@ bool CPersonalizeGui::changeNotify(const neutrino_locale_t locale, void *data) //shows a short help message void CPersonalizeGui::ShowHelpPersonalize() { - Helpbox helpbox; + Helpbox helpbox(g_Locale->getText(LOCALE_PERSONALIZE_HELP)); for (int i = (int)LOCALE_PERSONALIZE_HELP_LINE1; i<= (int)LOCALE_PERSONALIZE_HELP_LINE8; i++) - helpbox.addLine(g_Locale->getText((neutrino_locale_t)i)); + helpbox.addLine(g_Locale->getText((neutrino_locale_t)i), CTextBox::CENTER); - - helpbox.show(LOCALE_PERSONALIZE_HELP); + helpbox.addExitKey(CRCInput::RC_ok); + helpbox.show(); + helpbox.exec(); + helpbox.hide(); } void CPersonalizeGui::ApplySettings() @@ -763,7 +765,7 @@ void CPersonalizeGui::SaveAndExit() ApplySettings(); return; } - if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_QUESTION) == CMsgBox::mbrYes) { CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8 hintBox.paint(); @@ -772,7 +774,7 @@ void CPersonalizeGui::SaveAndExit() } else { - if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_MESSAGEBOX_DISCARD), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_MESSAGEBOX_DISCARD), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_QUESTION) == CMsgBox::mbrYes) exec(NULL, "restore"); } } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index dc4344012..d7cc78419 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -56,7 +56,7 @@ #include #include #include -#include +#include // remove this #include @@ -845,7 +845,7 @@ void CPictureViewerGui::endView() void CPictureViewerGui::deletePicFile(unsigned int index, bool mode) { CVFD::getInstance()->showMenuText(0, playlist[index].Name.c_str()); - if (ShowMsg(LOCALE_FILEBROWSER_DELETE, playlist[index].Filename, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, playlist[index].Filename, CMsgBox::mbrNo, CMsgBox::mbYes|CMsgBox::mbNo)==CMsgBox::mbrYes) { unlink(playlist[index].Filename.c_str()); printf("[ %s ] delete file: %s\r\n",__FUNCTION__,playlist[index].Filename.c_str()); @@ -860,7 +860,7 @@ void CPictureViewerGui::deletePicFile(unsigned int index, bool mode) void CPictureViewerGui::showHelp() { - Helpbox helpbox; + Helpbox helpbox(g_Locale->getText(LOCALE_MESSAGEBOX_INFO)); helpbox.addLine(g_Locale->getText(LOCALE_PICTUREVIEWER_HELP1)); helpbox.addLine(NEUTRINO_ICON_BUTTON_OKAY, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP2)); helpbox.addLine(NEUTRINO_ICON_BUTTON_5, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP3)); @@ -871,30 +871,29 @@ void CPictureViewerGui::showHelp() helpbox.addLine(NEUTRINO_ICON_BUTTON_RIGHT, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP7)); helpbox.addLine(NEUTRINO_ICON_BUTTON_5, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP3)); helpbox.addLine(NEUTRINO_ICON_BUTTON_HOME, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP8)); - helpbox.addPagebreak(); - helpbox.addLine(g_Locale->getText(LOCALE_PICTUREVIEWER_HELP9)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_OKAY, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP10)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_LEFT, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP11)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_RIGHT, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP12)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_1, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP13)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_3, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP14)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_2, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP15)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_4, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP16)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_6, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP17)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_8, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP18)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_5, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP3)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_0, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP19)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_HOME, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP8)); - if(audioplayer) - { - helpbox.addPagebreak(); - helpbox.addLine(g_Locale->getText(LOCALE_PICTUREVIEWER_HELP30)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_PLAY, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP31)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_PAUSE, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP32)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_STOP, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP33)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_FORWARD, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP34)); - helpbox.addLine(NEUTRINO_ICON_BUTTON_BACKWARD, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP35)); - } - hide(); - helpbox.show(LOCALE_MESSAGEBOX_INFO); +// helpbox.addPagebreak(); +// helpbox.addLine(g_Locale->getText(LOCALE_PICTUREVIEWER_HELP9)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_OKAY, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP10)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_LEFT, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP11)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_RIGHT, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP12)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_1, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP13)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_3, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP14)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_2, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP15)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_4, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP16)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_6, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP17)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_8, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP18)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_5, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP3)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_0, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP19)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_HOME, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP8)); +// if(audioplayer) +// { +// helpbox.addPagebreak(); +// helpbox.addLine(g_Locale->getText(LOCALE_PICTUREVIEWER_HELP30)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_PLAY, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP31)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_PAUSE, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP32)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_STOP, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP33)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_FORWARD, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP34)); +// helpbox.addLine(NEUTRINO_ICON_BUTTON_BACKWARD, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP35)); +// } + helpbox.show(); } diff --git a/src/gui/pipsetup.cpp b/src/gui/pipsetup.cpp index 6be220ec7..d6120cec2 100644 --- a/src/gui/pipsetup.cpp +++ b/src/gui/pipsetup.cpp @@ -3,7 +3,7 @@ #endif #include -#include +#include #include #include diff --git a/src/gui/pluginlist.cpp b/src/gui/pluginlist.cpp index 4e5dcaabc..18db834ec 100644 --- a/src/gui/pluginlist.cpp +++ b/src/gui/pluginlist.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -77,7 +77,7 @@ int CPluginList::run() g_PluginList->startPlugin(number); if (!g_PluginList->getScriptOutput().empty()) { hide(); - ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL); } return menu_return::RETURN_REPAINT; } @@ -168,7 +168,7 @@ int CPluginsExec::exec(CMenuTarget* parent, const std::string & actionKey) g_PluginList->startPlugin(sel); if (!g_PluginList->getScriptOutput().empty()) - ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL); if (g_PluginList->getIntegration(sel) == CPlugins::I_TYPE_DISABLED) return menu_return::RETURN_EXIT; diff --git a/src/gui/rc_lock.cpp b/src/gui/rc_lock.cpp index 354a89caa..add7f0463 100644 --- a/src/gui/rc_lock.cpp +++ b/src/gui/rc_lock.cpp @@ -31,7 +31,8 @@ #include #include -#include +#include + const std::string CRCLock::NO_USER_INPUT = "NO_USER_INPUT"; @@ -74,15 +75,15 @@ int CRCLock::exec(CMenuTarget* parent, const std::string &actionKey) char lock_msg[1024]; snprintf(lock_msg, sizeof(lock_msg)-1, g_Locale->getText(LOCALE_RCLOCK_LOCKMSG), key_unlock.c_str()); - if (ShowMsg(LOCALE_RCLOCK_TITLE, lock_msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel, - NEUTRINO_ICON_INFO, 450, no_input ? 5 : -1, no_input) == CMessageBox::mbrCancel) + if (ShowMsg(LOCALE_RCLOCK_TITLE, lock_msg, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel, + NEUTRINO_ICON_INFO, 450, no_input ? 5 : -1, no_input) == CMsgBox::mbrCancel) return menu_return::RETURN_EXIT_ALL; locked = true; lockRC(); locked = false; - ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack, + ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO, 450, no_input ? 5 : -1); return menu_return::RETURN_EXIT_ALL; } diff --git a/src/gui/record_setup.cpp b/src/gui/record_setup.cpp index 89a5c714d..00ef84383 100644 --- a/src/gui/record_setup.cpp +++ b/src/gui/record_setup.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include #include @@ -85,7 +85,7 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey == "help_recording") { - ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack); return res; } else if(actionKey == "recordingdir") diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index f3b48ea68..e22733be7 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -327,7 +327,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) else if(msg == CRCInput::RC_home) { if(manual && !scansettings.scan_nit_manual) continue; - if (ShowMsg(LOCALE_SCANTS_ABORT_HEADER, LOCALE_SCANTS_ABORT_BODY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_SCANTS_ABORT_HEADER, LOCALE_SCANTS_ABORT_BODY, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) { g_Zapit->stopScan(); } } diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 5ad95d794..6cfb80c05 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -371,7 +371,7 @@ int CScanSetup::exec(CMenuTarget* parent, const std::string &actionKey) else if(actionKey == "reloadchannels") { printf("[neutrino] CScanSetup::%s reloadchannels...\n", __FUNCTION__); - CHintBox chb(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RELOAD_HINT)); + CHint chb(LOCALE_SERVICEMENU_RELOAD_HINT); chb.paint(); /* save if changed, to make sure NEW/REMOVED/... flags are updated */ CServiceManager::getInstance()->SaveServices(true, true); diff --git a/src/gui/screensetup.cpp b/src/gui/screensetup.cpp index 9b446f0cd..b1327fed2 100644 --- a/src/gui/screensetup.cpp +++ b/src/gui/screensetup.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -136,7 +136,7 @@ int CScreenSetup::exec(CMenuTarget* parent, const std::string &) ( g_settings.screen_EndX != x_coord[1] ) || ( g_settings.screen_StartY != y_coord[0] ) || ( g_settings.screen_EndY != y_coord[1] ) ) && - (ShowMsg(LOCALE_VIDEOMENU_SCREENSETUP, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(LOCALE_VIDEOMENU_SCREENSETUP, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) break; case CRCInput::RC_timeout: diff --git a/src/gui/settings_manager.cpp b/src/gui/settings_manager.cpp index ebb1d8515..5c5ff7a4f 100644 --- a/src/gui/settings_manager.cpp +++ b/src/gui/settings_manager.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -116,7 +116,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) my_system(2, backup_sh, fileBrowser.getSelectedFile()->Name.c_str()); } else - ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_ERROR); } return res; } @@ -126,8 +126,8 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Filter = &fileFilter; if (fileBrowser.exec("/media") == true) { - int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); - if(result == CMessageBox::mbrYes) + int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo); + if(result == CMsgBox::mbrYes) { const char restore_sh[] = "/bin/restore.sh"; printf("restore: executing [%s %s]\n", restore_sh, fileBrowser.getSelectedFile()->Name.c_str()); diff --git a/src/gui/start_wizard.cpp b/src/gui/start_wizard.cpp index dddbc7ece..ffe812ca8 100644 --- a/src/gui/start_wizard.cpp +++ b/src/gui/start_wizard.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include #include @@ -92,7 +92,7 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) CSettingsManager settingsManager(SNeutrinoSettings::WIZARD_START); settingsManager.exec(NULL, ""); - if(ShowMsg (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) + if(ShowMsg (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbrCancel) == CMsgBox::mbrYes) { int advanced = 1; #ifdef ENABLE_FASTSCAN @@ -132,7 +132,7 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) if(advanced && init_settings && (res != menu_return::RETURN_EXIT_ALL)) { if (ShowMsg(LOCALE_WIZARD_INITIAL_SETTINGS, g_Locale->getText(LOCALE_WIZARD_INSTALL_SETTINGS), - CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { + CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30) == CMsgBox::mbrYes) { system("/bin/cp " CONFIGDIR "/initial/* " CONFIGDIR "/zapit/"); CFEManager::getInstance()->loadSettings(); CFEManager::getInstance()->saveSettings(); diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 8769c4120..332489810 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -47,13 +48,13 @@ #include #include -#include +#include #include #include #include #include #include -#include + #include #include #include @@ -145,7 +146,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) text[12*len] = 0; CVFD::getInstance()->ShowText(text); - ShowMsg(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); CVFD::getInstance()->Clear(); return res; @@ -185,7 +186,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) close(fd); - ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -196,17 +197,17 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) switch(ret) { case 0: - ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMsgBox::mbrBack, CMsgBox::mbBack, "info.raw"); break; case -1: - ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMsgBox::mbrBack, CMsgBox::mbBack, "info"); break; case -2: - ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMsgBox::mbrBack, CMsgBox::mbBack, "info"); break; default: case -3: - ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMsgBox::mbrBack, CMsgBox::mbBack, "info"); break; } @@ -219,17 +220,17 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) switch(ret) { case 0: - ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMsgBox::mbrBack, CMsgBox::mbBack, "info.raw"); break; case -1: - ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMsgBox::mbrBack, CMsgBox::mbBack, "info"); break; case -2: - ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMsgBox::mbrBack, CMsgBox::mbBack, "info"); break; default: case -3: - ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMsgBox::mbrBack, CMsgBox::mbBack, "info"); break; } @@ -252,7 +253,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) sprintf(buffer, "HDD: /dev/sda1 is %s", mounted ? "mounted" : "NOT mounted"); printf("%s\n", buffer); - ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -273,7 +274,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) sprintf(buffer, "MMC: /dev/mmcblk0p1 is %s", mounted ? "mounted" : "NOT mounted"); printf("%s\n", buffer); - ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -631,10 +632,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) else if (actionKey == "window"){ if (window == NULL){ window = new CComponentsWindow(); - window->setWindowCaption("|.....................|"); + window->setWindowCaption("|........HEADER........|", CTextBox::CENTER); window->setDimensionsAll(50, 50, 500, 500); window->setWindowIcon(NEUTRINO_ICON_INFO); window->enableShadow(); + window->getFooterObject()->setCaption("|........FOOTER........|", CTextBox::CENTER); CComponentsShapeCircle *c10 = new CComponentsShapeCircle(0, 0, 28); CComponentsShapeCircle *c11 = new CComponentsShapeCircle(0, CC_APPEND, 28); @@ -655,10 +657,20 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) c14->setColorBody(COL_RED); c14->setPageNumber(1); window->addWindowItem(c14); - } - else{ - window->setWindowIcon(NEUTRINO_ICON_LOCK); - window->setWindowCaption("Test"); + + CComponentsExtTextForm *text_1 = new CComponentsExtTextForm(); + text_1->setDimensionsAll(10, CC_CENTERED, 380, 48); + text_1->setLabelAndText("Page", "Number 1", g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]); + text_1->setFrameThickness(2); + text_1->setPageNumber(0); + window->addWindowItem(text_1); + + CComponentsExtTextForm *text_2 = new CComponentsExtTextForm(); + text_2->setDimensionsAll(10, 200, 380, 48); + text_2->setLabelAndText("Page", "Number 2", g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]); + text_2->setFrameThickness(2); + text_2->setPageNumber(1); + window->addWindowItem(text_2); } #if 0 if (!window->isPainted()){ @@ -666,10 +678,12 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) } else{ #endif //or paint direct a defined page - if (window->getCurrentPage() == 1) - window->paintPage(0); - else - window->paintPage(1); +// if (window->getCurrentPage() == 1) + window->enablePageScroll(CComponentsWindow::PG_SCROLL_M_UP_DOWN_KEY | CComponentsWindow::PG_SCROLL_M_LEFT_RIGHT_KEY); + window->enableSidebar(); + window->paint(); + window->getBodyObject()->exec(); + window->hide(); #if 0 } #endif @@ -711,17 +725,104 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) } return res; } + else if (actionKey == "hintbox_test") + { + ShowHint("Testmenu: Hintbox popup test", "Test for HintBox,\nPlease press any key or wait some seconds! ...", 700, 10, NULL, NEUTRINO_ICON_HINT_IMAGEINFO, CComponentsHeader::CC_BTN_EXIT); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_test_yes_no") + { + int msgRet = ShowMsg("Testmenu: MsgBox test", "Test for MsgBox,\nPlease press key! ...", CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 500, -1); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgRet); + ShowHint("MsgBox test returns", msg_txt.c_str()); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_test_cancel"){ + CMsgBox * msgBox = new CMsgBox("Testmenu: MsgBox exit test", "Please press key"); +// msgBox->setTimeOut(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR]); + msgBox->paint(); + res = msgBox->exec(); + msgBox->hide(); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgBox->getResult()); + delete msgBox; + + ShowHint("MsgBox test returns", msg_txt.c_str(), 700, 10, NULL, NULL, CComponentsHeader::CC_BTN_EXIT); + + return res; + } + else if (actionKey == "msgbox_test_all"){ + int msgRet = ShowMsg("Testmenu: MsgBox test", "Test for MsgBox,\nPlease press key! ...", CMsgBox::mbrOk, CMsgBox::mbAll, NULL, 700, -1); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgRet); + ShowHint("MsgBox test returns", msg_txt.c_str()); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_test_yes_no_cancel"){ + int msgRet = ShowMsg("Testmenu: MsgBox test", "Test for MsgBox,\nPlease press key! ...", CMsgBox::mbrCancel, CMsgBox::mbYes | CMsgBox::mbNo | CMsgBox::mbCancel, NULL, 500, -1); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgRet); + ShowHint("MsgBox test returns", msg_txt.c_str()); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_test_ok_cancel"){ + int msgRet = ShowMsg("Testmenu: MsgBox test", "Test for MsgBox,\nPlease press key! ...", CMsgBox::mbrOk, CMsgBox::mbOk | CMsgBox::mbCancel, NULL, 500, -1); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgRet); + ShowHint("MsgBox test returns", msg_txt.c_str()); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_test_ok"){ + int msgRet = ShowMsg("Testmenu: MsgBox test", "Test for MsgBox,\nPlease press ok key! ...", CMsgBox::mbrOk, CMsgBox::mbOk, NULL, 500, -1); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgRet); + ShowHint("MsgBox test returns", msg_txt.c_str()); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_test_cancel_timeout"){ + int msgRet = ShowMsg("Testmenu: MsgBox test", "Test for MsgBox,\nPlease press ok key or wait! ...", CMsgBox::mbrCancel, CMsgBox::mbOKCancel, NULL, 500, 6, true); + + std::string msg_txt = "Return value of MsgBox test is "; + msg_txt += to_string(msgRet); + ShowHint("MsgBox test returns", msg_txt.c_str()); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_error"){ + DisplayErrorMessage("Error Test!"); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "msgbox_info"){ + DisplayInfoMessage("Info Test!"); + return menu_return::RETURN_REPAINT; + } else if (actionKey == "footer_key"){ neutrino_msg_t msg; neutrino_msg_data_t data; - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Footer-Key pressed. Press EXIT to return"); + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Footer-Key pressed. Press EXIT to return", 350, NULL, NULL, CComponentsHeader::CC_BTN_EXIT); + + //optional: it is also possible to add more items into the hint box + //here some examples: + hintBox->addHintItem(new CComponentsShapeSquare(CC_CENTERED, CC_APPEND, 330, 2, NULL, false, COL_MENUCONTENT_PLUS_6, COL_RED)); + hintBox->addHintItem("- text with left icon", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, NEUTRINO_ICON_HINT_INFO); + hintBox->addHintItem("- text right without an icon", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::RIGHT); + hintBox->addHintItem("- text right with an icon", CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::RIGHT, NEUTRINO_ICON_HINT_INFO); + hintBox->paint(); while (1) { g_RCInput->getMsg(&msg, &data, 100); if (msg == CRCInput::RC_home) + hintBox->hide(); break; } + hintBox->hide(); delete hintBox; return res; @@ -760,6 +861,11 @@ int CTestMenu::showTestMenu() f_bi->setHint(NEUTRINO_ICON_HINT_IMAGEINFO, LOCALE_MENU_HINT_BUILDINFO); w_test.addItem(f_bi); + //msg/hintbox + CMenuWidget * w_msg = new CMenuWidget("MsgBox/Hint-Tests", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_HINT_MSG_TESTS); + w_test.addItem(new CMenuForwarder(w_msg->getName(), true, NULL, w_msg)); + showMsgTests(w_msg); + //footer buttons static const struct button_label footerButtons[2] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_COLORCHOOSER_RED }, @@ -852,3 +958,20 @@ void CTestMenu::showHWTests(CMenuWidget *widget) CFEManager::getInstance()->linkFrontends(true); #endif } + +void CTestMenu::showMsgTests(CMenuWidget *widget) +{ + widget->addIntroItems(); + widget->addItem(new CMenuForwarder("HintBox test!", true, NULL, this, "hintbox_test")); + widget->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, "MsgBox")); + widget->addItem(new CMenuForwarder("cancel on timeout", true, NULL, this, "msgbox_test_cancel_timeout")); + widget->addItem(new CMenuForwarder("yes no", true, NULL, this, "msgbox_test_yes_no")); + widget->addItem(new CMenuForwarder("cancel", true, NULL, this, "msgbox_test_cancel")); + widget->addItem(new CMenuForwarder("ok", true, NULL, this, "msgbox_test_ok")); + widget->addItem(new CMenuForwarder("ok cancel", true, NULL, this, "msgbox_test_ok_cancel")); + widget->addItem(new CMenuForwarder("yes no cancel", true, NULL, this, "msgbox_test_yes_no_cancel")); + widget->addItem(new CMenuForwarder("all", true, NULL, this, "msgbox_test_all")); + widget->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, "Error/Info")); + widget->addItem(new CMenuForwarder("Error Message!", true, NULL, this, "msgbox_error")); + widget->addItem(new CMenuForwarder("Info Message!", true, NULL, this, "msgbox_info")); +} diff --git a/src/gui/test_menu.h b/src/gui/test_menu.h index e7196d29f..1b09192b0 100644 --- a/src/gui/test_menu.h +++ b/src/gui/test_menu.h @@ -59,7 +59,7 @@ class CTestMenu : public CMenuTarget int showTestMenu(); void showHWTests(CMenuWidget *widget); void showCCTests(CMenuWidget *widget); - + void showMsgTests(CMenuWidget *widget); public: CTestMenu(); ~CTestMenu(); diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index cd611c9a0..eba23ef63 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -182,7 +182,7 @@ int CThemes::Show() } if (hasThemeChanged) { - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMsgBox::mbrYes) rememberOldTheme( false ); else hasThemeChanged = false; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 70d603a02..7500f3267 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include #include @@ -679,7 +679,7 @@ bool CTimerList::remoteChanExists(t_channel_id channel_id) if (r_url == "false") ShowMsg(LOCALE_REMOTEBOX_CHANNEL_NA, convertChannelId2String(channel_id), - CMessageBox::mbrOk, CMessageBox::mbOk, NULL, 450, 30, false); + CMsgBox::mbrOk, CMsgBox::mbOk, NULL, 450, 30, false); return (r_url == "true"); } @@ -879,7 +879,7 @@ int CTimerList::show() title = "(" + epgdata.title + ")\n"; snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_TIMERLIST_ASK_TO_DELETE), title.c_str()); if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, - CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) { + CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30) == CMsgBox::mbrNo) { killTimer = false; update = false; } @@ -1529,7 +1529,7 @@ int CTimerList::modifyTimer() } if (modified) { - if (ShowMsg(LOCALE_TIMERLIST_SAVE, LOCALE_PERSONALIZE_APPLY_SETTINGS, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 20, true) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_TIMERLIST_SAVE, LOCALE_PERSONALIZE_APPLY_SETTINGS, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 20, true) == CMsgBox::mbrYes) exec(NULL, "modifytimer"); } @@ -1729,8 +1729,8 @@ bool CTimerList::askUserOnRemoteTimerConflict(time_t announceTime, time_t stopTi struct tm *sTime = localtime(&(it->stopTime)); timerbuf += strftime("%d.%m. %H:%M\n",sTime); } - if (overlappingTimers.size() > 0) - return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + if (!overlappingTimers.empty()) + return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMsgBox::mbrNo,CMsgBox::mbNo|CMsgBox::mbYes) == CMsgBox::mbrYes); else return true; } @@ -1787,7 +1787,7 @@ bool askUserOnTimerConflict(time_t announceTime, time_t stopTime, t_channel_id c // todo: localize message //g_Locale->getText(TIMERLIST_OVERLAPPING_MESSAGE); - return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMsgBox::mbrNo,CMsgBox::mbNo|CMsgBox::mbYes) == CMsgBox::mbrYes); } else return true; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 0d0aa41fc..503b6be55 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include @@ -300,14 +300,16 @@ bool CFlashUpdate::selectHttpImage(void) if (urls.empty()) { - ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR), CMessageBox::mbrOk, CMessageBox::mbOk); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR), CMsgBox::mbrOk, CMsgBox::mbOk); // UTF-8 return false; } if (notify) { - if(newfound) - ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_FOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + if(!newfound) + ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_FOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6 ); +#if 0 else - ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_NOTFOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_NOTFOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6); +#endif } menu_ret = SelectionWidget.exec(NULL, ""); @@ -385,7 +387,7 @@ printf("[update] mode is %d\n", softupdate_mode); if(fileType < '3') { if ((strncmp(RELEASE_CYCLE, versionInfo->getReleaseCycle(), 2) != 0) && - (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) + (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)) { delete versionInfo; //ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE)); // UTF-8 @@ -393,8 +395,8 @@ printf("[update] mode is %d\n", softupdate_mode); } if ((strcmp("Release", versionInfo->getType()) != 0) && - //(ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) // UTF-8 - (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) + //(ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE), CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)) // UTF-8 + (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)) { delete versionInfo; return false; @@ -445,8 +447,8 @@ printf("[update] mode is %d\n", softupdate_mode); if (file_selected->getType() == CFile::FILE_PKG_PACKAGE){ COPKGManager opkg; if (opkg.hasOpkgSupport()){ - int msgres = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_WARNING_3RDPARTY_PACKAGES, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE, 700); // UTF-8 - if (msgres == CMessageBox::mbrYes){ + int msgres = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_WARNING_3RDPARTY_PACKAGES, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE, 700); // UTF-8 + if (msgres == CMsgBox::mbrYes){ if (!opkg.installPackage(UpdatesBrowser.getSelectedFile()->Name)) DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL)); } @@ -476,7 +478,7 @@ printf("[update] mode is %d\n", softupdate_mode); strcpy(msg, g_Locale->getText(LOCALE_FLASHUPDATE_NOVERSION)); //never read msg_body = LOCALE_FLASHUPDATE_MSGBOX_MANUAL; } - return (ShowMsg(LOCALE_MESSAGEBOX_INFO, msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes); // UTF-8 + return (ShowMsg(LOCALE_MESSAGEBOX_INFO, msg, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) == CMsgBox::mbrYes); // UTF-8 } int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) @@ -540,7 +542,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) return menu_return::RETURN_REPAINT; } if(softupdate_mode==1) { //internet-update - if ( ShowMsg(LOCALE_MESSAGEBOX_INFO, (fileType < '3') ? LOCALE_FLASHUPDATE_INSTALL_IMAGE : LOCALE_FLASHUPDATE_INSTALL_PACKAGE, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 + if ( ShowMsg(LOCALE_MESSAGEBOX_INFO, (fileType < '3') ? LOCALE_FLASHUPDATE_INSTALL_IMAGE : LOCALE_FLASHUPDATE_INSTALL_PACKAGE, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes) // UTF-8 { hide(); return menu_return::RETURN_REPAINT; @@ -556,7 +558,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) //flash it... #ifndef BOXMODEL_APOLLO if (g_settings.apply_settings) { - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) == CMsgBox::mbrYes) if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE)) { hide(); return menu_return::RETURN_REPAINT; @@ -593,7 +595,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) fread(buffer, (uint32_t)filesize, 1, fd); fclose(fd); buffer[filesize] = 0; - ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMsgBox::mbrBack, CMsgBox::mbBack); // UTF-8 free(buffer); } } @@ -861,7 +863,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber) FILESYSTEM_ENCODING_TO_UTF8_STRING(filename).c_str(), CMTDInfo::getInstance()->getMTDName(mtdNumber).c_str()); - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes) // UTF-8 return; #ifdef VFD_UPDATE CVFD::getInstance()->showProgressBar2(0,"checking",0,"Update Neutrino"); @@ -1051,7 +1053,7 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey) // create image warning const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank"; snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box); - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE, 600) != CMsgBox::mbrYes) skipImage = true; } if (!skipImage) { diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index 3e6246d36..f92df2c7d 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -549,7 +549,7 @@ bool CExtUpdate::checkSpecialFolders(std::string line, bool copy) neutrino_locale_t msg = (copy) ? LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED : LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED; snprintf(buf, sizeof(buf), g_Locale->getText(msg), line.c_str()); WRITE_UPDATE_LOG("%s%s", buf, "\n"); - ShowMsg(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buf, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO); return true; } return false; @@ -719,13 +719,13 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) memset(buf1, '\0', sizeof(buf1)); if (free3 <= flashError) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total); - ShowMsg(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, buf1, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_ERROR); flashErrorFlag = true; return false; } else if (free3 <= flashWarning) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total); - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf1, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO) != CMsgBox::mbrYes) { flashErrorFlag = true; return false; } diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index faf85ed8b..f6c34630a 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -254,13 +254,13 @@ bool CUpnpBrowserGui::discoverDevices() catch (std::runtime_error error) { delete scanBox; - ShowMsg(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + DisplayErrorMessage(error.what()); return false; } delete scanBox; if (m_devices.empty()) { - ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_UPNPBROWSER_NOSERVERS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + DisplayInfoMessage(g_Locale->getText(LOCALE_UPNPBROWSER_NOSERVERS)); return false; } return true; @@ -288,7 +288,7 @@ bool CUpnpBrowserGui::getResults(std::string id, unsigned int start, unsigned in } catch (std::runtime_error error) { - ShowMsg(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + DisplayErrorMessage(error.what()); return false; } return true; diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index ac39d1393..8db4e8306 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include diff --git a/src/gui/videosettings.cpp b/src/gui/videosettings.cpp index 144d6bfa1..5bfeeabe4 100644 --- a/src/gui/videosettings.cpp +++ b/src/gui/videosettings.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -419,7 +419,7 @@ void CVideoSettings::setupVideoSystem(bool do_ask) if (prev_video_mode != g_settings.video_Mode) { frameBuffer->paintBackground(); - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO) != CMsgBox::mbrYes) { g_settings.video_Mode = prev_video_mode; videoDecoder->SetVideoSystem(g_settings.video_Mode); diff --git a/src/gui/widget/Makefile.am b/src/gui/widget/Makefile.am index 0788d0319..17a932b04 100644 --- a/src/gui/widget/Makefile.am +++ b/src/gui/widget/Makefile.am @@ -20,14 +20,12 @@ libneutrino_gui_widget_a_SOURCES = \ drawable.cpp \ helpbox.cpp \ hintbox.cpp \ - hintboxext.cpp \ keychooser.cpp \ keyboard_input.cpp \ listbox.cpp \ listframe.cpp \ listhelpers.cpp \ menue.cpp \ - messagebox.cpp \ mountchooser.cpp \ msgbox.cpp \ shellwindow.cpp \ diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index a1eef250c..f7b90b371 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include @@ -218,7 +218,7 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) } case CRCInput::RC_home: if (((*value[VALUE_R] != r_alt) || (*value[VALUE_G] != g_alt) || (*value[VALUE_B] != b_alt) || ((value[VALUE_ALPHA]) && (*(value[VALUE_ALPHA]) != a_alt))) && - (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) break; // sonst abbruch... diff --git a/src/gui/widget/helpbox.cpp b/src/gui/widget/helpbox.cpp index 43a854915..8d963e8e9 100644 --- a/src/gui/widget/helpbox.cpp +++ b/src/gui/widget/helpbox.cpp @@ -1,32 +1,24 @@ /* - Neutrino-GUI - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + Implement CComponent-Windowclass. + Copyright (C) 2015 Thilo Graf 'dbt' License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ @@ -34,78 +26,172 @@ #include #endif -#include -#include -#include #include #include +#include -Helpbox::Helpbox() +using namespace std; + +Helpbox::Helpbox( const string& Title, + const string& Default_Text, + const int& text_mode, + const int& line_space, + Font* default_font_text, + const char* Icon): + CComponentsWindowMax( Title, + Icon, + NULL, + CC_SHADOW_ON, + COL_MENUCONTENT_PLUS_6, + COL_MENUCONTENT_PLUS_0, + COL_MENUCONTENTDARK_PLUS_0) { + page = 0; + hbox_y = 1; + setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); + ccw_footer->setButtonLabel(NEUTRINO_ICON_BUTTON_HOME, LOCALE_MESSAGEBOX_BACK, 0, 150); + + hbox_font = default_font_text; + if (default_font_text == NULL) + hbox_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]; + + if (!Default_Text.empty()) + addLine(Default_Text.c_str(), Default_Text, text_mode, line_space, HELPBOX_DEFAULT_LINE_INDENT ,hbox_font); + + //ensure hided channellist, because shared RC_ok + CNeutrinoApp::getInstance()->allowChannelList(false); } -Helpbox::~Helpbox() + +void Helpbox::addLine(const std::string& icon, const std::string& text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text) { - for (ContentLines::iterator it = m_lines.begin(); - it != m_lines.end(); ++it) - { - for (std::vector::iterator it2 = it->begin(); - it2 != it->end(); ++it2) - { - delete *it2; - } - } + CComponentsItem *pre_item = !ccw_body->empty() ? ccw_body->back() : NULL; //get the last current item + + if (pre_item){ + if (pre_item->getPageNumber() == page) + hbox_y = pre_item->getYPos() + pre_item->getHeight(); + } + + int h_line = line_space; + Font* font = hbox_font; + if (font_text){ + h_line = max(h_line, font_text->getHeight()); + font = font_text; + } + + CComponentsFrmChain *line = new CComponentsFrmChain(line_indent, hbox_y, 0, h_line); + if ((hbox_y + h_line)>ccw_body->getHeight()){ + addPagebreak(); + line->setYPos(hbox_y); + } + line->setPageNumber(page); + + int w_body = ccw_body->getWidth(); + line->setWidth(w_body - line_indent - 40); + line->setXPos(line_indent); + line->setColorBody(ccw_body->getColorBody()); + + CComponentsPicture *picon = NULL; + int w_picon = 0; + if (!icon.empty()){ + picon = new CComponentsPicture (0, 0, icon); + w_picon = picon->getHeight(); + picon->setYPos(line->getHeight()/2 - w_picon/2); + line->addCCItem(picon); + } + + if (!text.empty()){ + int x_text = w_picon + (picon ? 10 : 0); + CComponentsText * txt = new CComponentsText(x_text, 0, line->getWidth()-x_text, line_space, text, text_mode, font); +#if 0 //"contrast agent", if you want to see where the text items are drawn. + txt->setColorBody(COL_RED); + txt->doPaintBg(true); +#endif + line->addCCItem(txt); + } + addWindowItem(line); } -void Helpbox::show(const neutrino_locale_t Caption, const int Width, int timeout) -{ - CMessageBox msgBox(Caption, m_lines, Width, NEUTRINO_ICON_INFO, CMessageBox::mbrBack,CMessageBox::mbBack); - msgBox.exec(timeout); + + +void Helpbox::addSeparatorLine(const int& line_space, const int& line_indent, bool enable_gradient) +{ + CComponentsItem *pre_item = !ccw_body->empty() ? ccw_body->back() : NULL; //get the last current item + + if (pre_item){ + if (pre_item->getPageNumber() == page) + hbox_y = pre_item->getYPos() + pre_item->getHeight(); + } + + int h_line = line_space; + + CComponentsFrmChain *line = new CComponentsFrmChain(line_indent, hbox_y, 0, h_line); + line->setPageNumber(page); + + int w_body = ccw_body->getWidth(); + line->setWidth(w_body - line_indent - 40); + line->setXPos(line_indent); + line->setColorBody(ccw_body->getColorBody()); + + CComponentsShapeSquare *sepline = new CComponentsShapeSquare (0, 0, line->getWidth(), 2); + sepline->setYPos(line->getHeight()/2 - sepline->getHeight()/2); + sepline->setColorBody(COL_MENUCONTENTINACTIVE_TEXT); + sepline->enableColBodyGradient(enable_gradient); + sepline->setColBodyGradient(CColorGradient::gradientLight2Dark, CFrameBuffer::gradientHorizontal, CColorGradient::light); + + line->addCCItem(sepline); + + addWindowItem(line); } -void Helpbox::addLine(const char *text) +void Helpbox::addSeparator(const int& line_space) { - std::vector v; - Drawable *d = new DText(text); - v.push_back(d); - m_lines.push_back(v); + CComponentsItem *pre_item = !ccw_body->empty() ? ccw_body->back() : NULL; //get the last current item + + if (pre_item){ + if (pre_item->getPageNumber() == page) + hbox_y = pre_item->getYPos() + pre_item->getHeight(); + } + + CComponentsFrmChain *line = new CComponentsFrmChain(0, hbox_y, 0, line_space); + line->setPageNumber(page); + + int w_body = ccw_body->getWidth(); + line->setWidth(w_body - 40); + line->setColorBody(ccw_body->getColorBody()); + + addWindowItem(line); } -void Helpbox::addLine(std::string& text) + + + + +void Helpbox::addLine(const char *icon, const char *text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text) { - std::vector v; - Drawable *d = new DText(text); - v.push_back(d); - m_lines.push_back(v); + addLine(icon, std::string(text), text_mode, line_space, line_indent, font_text); + } -void Helpbox::addLine(const char *icon, const char *text) + +void Helpbox::addLine(const char *text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text) { - std::vector v; - Drawable *di = new DIcon(icon); - Drawable *dt = new DText(text); - v.push_back(di); - v.push_back(dt); - m_lines.push_back(v); + addLine("", std::string(text), text_mode, line_space, line_indent, font_text); } -void Helpbox::addLine(std::string& icon, std::string& text) +void Helpbox::addLine(const std::string& text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text) { - std::vector v; - Drawable *di = new DIcon(icon); - Drawable *dt = new DText(text); - v.push_back(di); - v.push_back(dt); - m_lines.push_back(v); + addLine("", text, text_mode, line_space, line_indent, font_text); } + + void Helpbox::addPagebreak(void) { - std::vector v; - Drawable *p = new DPagebreak(); - v.push_back(p); - m_lines.push_back(v); + page ++; + setPageCount(page); + hbox_y = 1; } diff --git a/src/gui/widget/helpbox.h b/src/gui/widget/helpbox.h index a1d4d3c22..86a5aed4b 100644 --- a/src/gui/widget/helpbox.h +++ b/src/gui/widget/helpbox.h @@ -1,64 +1,95 @@ /* - Neutrino-GUI - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + Implement CComponent-Windowclass. + Copyright (C) 2015 Thilo Graf 'dbt' License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifndef __helpbox__ #define __helpbox__ -#include +#include +#include +#include -#include +#define HELPBOX_DEFAULT_LINE_HEIGHT 35 +#define HELPBOX_DEFAULT_LINE_INDENT 10 -#include -#include - -class Helpbox +class Helpbox : public CComponentsWindowMax { -public: - - Helpbox(); - ~Helpbox(); - - void show(const neutrino_locale_t Caption, const int Width = 450, int timeout = -1); - - void addLine(std::string& text); - void addLine(const char *text); - void addLine(std::string& icon, std::string& text); - void addLine(const char *icon, const char *text); - void addPagebreak(); -protected: - private: + uint8_t page; + //start position of items on page + int hbox_y; - ContentLines m_lines; + ///default font + Font* hbox_font; +public: + Helpbox( const std::string& Title, + const std::string& Default_Text = std::string(), + const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, + const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT, + Font* font_text = NULL, + const char* Icon = NEUTRINO_ICON_INFO); + + ///show = paint, for compatibility + void show(bool do_save_bg = true){ paint(do_save_bg) ;} + + void addLine( const std::string& text, + const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, + const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT, + const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT, + Font* font_text = NULL); + + void addLine( const char *text, + const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, + const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT, + const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT, + Font* font_text = NULL); + + void addLine( const std::string& icon, + const std::string& text, + const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, + const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT, + const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT, + Font* font_text = NULL); + + void addLine( const char *icon, + const char *text, + const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, + const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT, + const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT, + Font* font_text = NULL); + + ///adds a separator as horizontal line, arg 'line_space' defines the space of full separator height, the separator line itself has a defined height of 2px and is centered within line space. + ///arg 'line_indent' defines begin of line from left border within body object. + ///arg 'enable_gradient' enable/disable gradient, Note: default = true, but gradient is only effected, if global/theme gradient settings are enabled! + void addSeparatorLine( const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT, + const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT, + bool enable_gradient = true); + ///adds a simple empty separator as horizontal space, arg 'line_space' defines the space of full separator height + void addSeparator( const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT); + + void addPagebreak(); + + int exec(){return ccw_body->exec();} }; #endif diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index febb0f5fa..8e669af40 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -1,24 +1,29 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ + Hintbox based up initial code by + Copyright (C) 2003 Ralf Gandy 'thegoodguy' + Copyright (C) 2004 Sven Traenkle 'zwen' Copyright (C) 2008-2009, 2011, 2013 Stefan Seyfried + Implementation of CComponent Window class. + Copyright (C) 2014-2015 Thilo Graf 'dbt' + License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . */ @@ -26,250 +31,139 @@ #include #endif -#include - #include #include - -#define borderwidth 4 +#include "hintbox.h" +#include -#define HINTBOX_MAX_HEIGHT 420 -CHintBox::CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon) +/* + x w + y+-ccw_head----------------------------------------------+ + |icon | caption | buttons |header (ccw_head) + +-ccw_body----------------------------------------------+ + |+-obj_content-----------------------------------------+| + ||+-obj_hint 0----------------------------------------+||body (ccw_body) + h||| obj_picon | obj_text ||| | + ||+---------------------------------------------------+|| +-contents (obj_content) + |+-----------------------------------------------------+| | + +-------------------------------------------------------+ +-hint 0 (obj_hint) default added with new instance of CHintBox + | + | + +-hint n optional added with addHintItem() +*/ + +using namespace std; + + +CHintBox::CHintBox( const neutrino_locale_t Caption, + const char * const Text, + const int Width, + const char * const Icon, + const char * const Picon, + const int& header_buttons, + const int& text_mode, + const int& indent): CComponentsWindow( 1, 1, width, + HINTBOX_MIN_HEIGHT, + Caption, + string(Icon == NULL ? "" : Icon), + NULL, + CC_SHADOW_ON) { - const char * caption_tmp = g_Locale->getText(Caption); - init(caption_tmp, Text, Width, Icon); + init(Text, Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); } -CHintBox::CHintBox(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, const char * const Icon) +CHintBox::CHintBox( const char * const Caption, + const char * const Text, + const int Width, + const char * const Icon, + const char * const Picon, + const int& header_buttons, + const int& text_mode, + const int& indent):CComponentsWindow( 1, 1, width, + HINTBOX_MIN_HEIGHT, + Caption, + string(Icon == NULL ? "" : Icon), + NULL, + CC_SHADOW_ON) { - const char * caption_tmp = g_Locale->getText(Caption); - const char * text_tmp = g_Locale->getText(Text); - init(caption_tmp, text_tmp, Width, Icon); + init(string(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); } -CHintBox::CHintBox(const char * const Caption, const char * const Text, const int Width, const char * const Icon) +CHintBox::CHintBox( const neutrino_locale_t Caption, + const neutrino_locale_t Text, + const int Width, + const char * const Icon, + const char * const Picon, + const int& header_buttons, + const int& text_mode, + const int& indent):CComponentsWindow( 1, 1, width, + HINTBOX_MIN_HEIGHT, + Caption, + string(Icon == NULL ? "" : Icon), + NULL, + CC_SHADOW_ON) { - init(Caption, Text, Width, Icon); + init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); } -CHintBox::CHintBox(const char * const Caption, const neutrino_locale_t Text, const int Width, const char * const Icon) +CHintBox::CHintBox( const char * const Caption, + const neutrino_locale_t Text, + const int Width, + const char * const Icon, + const char * const Picon, + const int& header_buttons, + const int& text_mode, + const int& indent):CComponentsWindow( 1, 1, width, + HINTBOX_MIN_HEIGHT, + Caption, + string(Icon == NULL ? "" : Icon), + NULL, + CC_SHADOW_ON) { - const char * text_tmp = g_Locale->getText(Text); - init(Caption, text_tmp, Width, Icon); -} -void CHintBox::init(const char * const Caption, const char * const Text, const int Width, const char * const Icon) -{ - char * begin; - char * pos; - int nw; - int scrollWidth = 0; - int maxLineWidth = 0; - - message = strdup(Text); - - width = Width; - - theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - height = theight + fheight; - textStartX = 0; - - caption = Caption; - - begin = message; - - while (true) - { - height += fheight; - if (height > HINTBOX_MAX_HEIGHT) - height -= fheight; - - line.push_back(begin); - pos = strchr(begin, '\n'); - if (pos != NULL) - { - *pos = 0; - begin = pos + 1; - } - else - break; - } - if (fheight != 0) - entries_per_page = ((height - theight) / fheight) - 1; - else /* avoid division by zero */ - entries_per_page = 1; - current_page = 0; - - unsigned int additional_width; - - if (entries_per_page < line.size()) - scrollWidth = 15; - else - scrollWidth = 0; - additional_width = 20 + scrollWidth; - - if (Icon != NULL) - { - iconfile = Icon; - additional_width += 30; - } - else - iconfile = ""; - - nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(caption); - - if (nw > width) - width = nw; - - for (std::vector::const_iterator it = line.begin(); it != line.end(); ++it) - { - int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it); - maxLineWidth = std::max(maxLineWidth, w); - nw = additional_width + w; - if (nw > width) - width = nw; - } - - /* make sure we don't overflow the usable area */ - if (nw > (int)CFrameBuffer::getInstance()->getScreenWidth()) - width = CFrameBuffer::getInstance()->getScreenWidth(); - textStartX = (width - scrollWidth - maxLineWidth) / 2; - - window = NULL; + init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); } -CHintBox::~CHintBox(void) +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) { - hide(); - free(message); + lines = 0; + timeout = HINTBOX_DEFAULT_TIMEOUT; + w_indentation = indent; + + //set required window width and basic height + width = max(HINTBOX_MIN_WIDTH, Width); + height = max(HINTBOX_MIN_HEIGHT, height); + + ccw_buttons = header_buttons; + + //enable shadow + shadow = true; + + //disable disable header if no title has been defined + if (ccw_caption.empty()) + showHeader(false); + + //disable footer for default + showFooter(false); + + //add the content container, contains the hint objects + obj_content = new CComponentsFrmChain(CC_CENTERED, CC_CENTERED, ccw_body->getWidth(), ccw_body->getHeight(), NULL, CC_DIR_X, ccw_body); + obj_content->doPaintBg(false); + + y_hint_obj = 0; + h_hint_obj = obj_content->getHeight(); + + if (!Text.empty()) + addHintItem(Text, text_mode, Picon); } -void CHintBox::paint(void) -{ - if (window != NULL) - { - /* - * do not paint stuff twice: - * => thread safety needed by movieplayer.cpp: - * one thread calls our paint method, the other one our hide method - * => no memory leaks - */ - return; - } - - CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); - window = new CFBWindow(frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width ) >> 1), - frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >> 2), - width + borderwidth, - height + borderwidth); - refresh(); -} - -void CHintBox::refresh(void) -{ - if (window == NULL) - { - return; - } - - //window->paintBoxRel(borderwidth, height, width, borderwidth, COL_SHADOW_PLUS_0); - //window->paintBoxRel(width, borderwidth, borderwidth, height - borderwidth, COL_SHADOW_PLUS_0); - window->paintBoxRel(width - 20, borderwidth, borderwidth + 20, height - borderwidth - 20, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_TOP); // right - window->paintBoxRel(borderwidth, height-20, width, borderwidth+20, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); // bottom - - CComponentsHeader header(window->x, window->y, width, theight, caption, iconfile); - header.paint(CC_SAVE_SCREEN_NO); - -#if 0 - //window->paintBoxRel(0, 0, width, theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0); - window->paintBoxRel(0, 0, width, theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);//round - - if (!iconfile.empty()) - { - int iw, ih; - CFrameBuffer::getInstance()->getIconSize(iconfile.c_str(), &iw, &ih); - //window->paintIcon(iconfile.c_str(), 8, 5); - window->paintIcon(iconfile.c_str(), 10, 0, theight); - //window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], iw+20, theight, width - 20-iw, g_Locale->getText(caption), COL_MENUHEAD_TEXT); - window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], iw+20, theight, width - 20-iw, caption, COL_MENUHEAD_TEXT); - } - else - window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], 10, theight, width - 10, caption, COL_MENUHEAD_TEXT); -#endif - //window->paintBoxRel(0, theight, width, (entries_per_page + 1) * fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0); - window->paintBoxRel(0, theight, width, (entries_per_page + 1) * fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);//round - - int count = entries_per_page; - int ypos = theight + (fheight >> 1); - - for (std::vector::const_iterator it = line.begin() + (entries_per_page * current_page); ((it != line.end()) && (count > 0)); ++it, count--) - window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU], textStartX, (ypos += fheight), width, *it, COL_MENUCONTENT_TEXT); - - if (entries_per_page < line.size()) - { - ypos = theight + (fheight >> 1); - window->paintBoxRel(width - 15, ypos, 15, entries_per_page * fheight, COL_SCROLLBAR_PASSIVE_PLUS_0); - unsigned int marker_size = (entries_per_page * fheight) / ((line.size() + entries_per_page - 1) / entries_per_page); - window->paintBoxRel(width - 13, ypos + current_page * marker_size, 11, marker_size, COL_SCROLLBAR_ACTIVE_PLUS_0); - } -} - -bool CHintBox::has_scrollbar(void) -{ - return (entries_per_page < line.size()); -} - -void CHintBox::scroll_up(void) -{ - if (current_page > 0) - { - current_page--; - refresh(); - } -} - -void CHintBox::scroll_down(void) -{ - if ((entries_per_page * (current_page + 1)) <= line.size()) - { - current_page++; - refresh(); - } -} - -void CHintBox::hide(void) -{ - if (window != NULL) - { - delete window; - window = NULL; - } -} - -int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon) -{ - const char * caption = g_Locale->getText(Caption); - - return ShowHint(caption, Text, Width, timeout, Icon); -} - -int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon) +int CHintBox::exec() { neutrino_msg_t msg; neutrino_msg_data_t data; - - CHintBox * hintBox = new CHintBox(Caption, Text, Width, Icon); - hintBox->paint(); - - if ( timeout == -1 ) - timeout = 5; /// default timeout 5 sec - //timeout = g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR]; - - uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); - int res = messages_return::none; + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) ) { @@ -283,21 +177,21 @@ int ShowHint(const char * const Caption, const char * const Text, const int Widt { res = messages_return::cancel_all; } - else if ((hintBox->has_scrollbar()) && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))) + else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)) { if (msg == CRCInput::RC_up) - hintBox->scroll_up(); + this->scroll_up(); else - hintBox->scroll_down(); - } - else if (CNeutrinoApp::getInstance()->listModeKey(msg)) { - // do nothing + this->scroll_down(); } + else if (CNeutrinoApp::getInstance()->listModeKey(msg)){ + // do nothing //TODO: if passed rc messages are ignored rc messaages: has no effect here too!! + } else if(msg == CRCInput::RC_mode) { res = messages_return::handled; break; } - else if((msg == (neutrino_msg_t) g_settings.key_switchformat) || (msg == (neutrino_msg_t) g_settings.key_next43mode)) { + else if((msg == CRCInput::RC_next) || (msg == CRCInput::RC_prev)) { res = messages_return::cancel_all; g_RCInput->postMsg(msg, data); } @@ -306,26 +200,257 @@ int ShowHint(const char * const Caption, const char * const Text, const int Widt res = CNeutrinoApp::getInstance()->handleMsg(msg, data); if (res & messages_return::unhandled) { - // leave here and handle above... g_RCInput->postMsg(msg, data); res = messages_return::cancel_all; } } } - - hintBox->hide(); - delete hintBox; return res; } -int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) +void CHintBox::addHintItem(const std::string& Text, const int& text_mode, const std::string& Picon, const u_int8_t& at_page_number, const fb_pixel_t& color_text, Font* font_text) { - return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon); + dprintf(DEBUG_INFO, "[CHintBox] [%s - %d] add new hint '%s' %s\n", __func__, __LINE__, Text.c_str(), Picon.c_str()); + + //set required font and line size + Font* font = font_text == NULL ? g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO] : font_text; + int h_line = font->getHeight(); + + //init side picon object + CComponentsPicture *obj_picon = new CComponentsPicture(0, 0, Picon); + obj_picon->doPaintBg(false); + int w_picon = obj_picon->getWidth(); + + //init text item object + int x_text_obj = (w_picon > 0) ? (w_picon + w_indentation) : 0; + int w_text_obj = obj_content->getWidth() - w_picon - w_indentation; + int h_text_obj = max(h_line, obj_picon->getHeight()); + CComponentsText *obj_text = new CComponentsText(x_text_obj, + 0, + w_text_obj, + h_text_obj, + Text, + text_mode, + font); + + //provide the internal textbox object + CTextBox *textbox = obj_text->getCTextBoxObject(); + int lines_count = textbox->getLines(); + + //get required height of text object related to lines count and height of head and footer, if available + int h_required = lines_count * h_line + (ccw_head ? ccw_head->getHeight() : 0) + (ccw_footer ? ccw_footer->getHeight() : 0); + + //set minimal required height + height = max(height, min(HINTBOX_MAX_HEIGHT, max(HINTBOX_MIN_HEIGHT, h_required))); + + //if have no pre defined text mode: + //more than 1 line or a picon is defined, then do not center text and allow scroll if > 1 lines + if (text_mode == 0){ + if (lines_count == 1) + obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER); + if (w_picon > 1) + obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH); + if (lines_count > 1) + obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | (h_required > HINTBOX_MAX_HEIGHT ? CTextBox::SCROLL : CTextBox::AUTO_HIGH)); + if (lines_count > 1 && w_picon == 0) + obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER | (h_required > HINTBOX_MAX_HEIGHT ? CTextBox::SCROLL : CTextBox::AUTO_HIGH)); + } + else + obj_text->setTextMode(text_mode); + + //text item object: don't paint background + obj_text->doPaintBg(false); + obj_text->setCorner(corner_rad, corner_type); + + //set text color + obj_text->setTextColor(color_text); + + //calculate height of hint object + if (obj_content->size() == 0){ + if (lines_count == 1){ + h_hint_obj = max(h_hint_obj, h_text_obj); + obj_text->setYPos(CC_CENTERED); + } + else + h_hint_obj = max(h_hint_obj, h_line*lines_count); + } + else{ + if (lines_count == 1){ + h_hint_obj = h_text_obj; + obj_text->setYPos(CC_CENTERED); + } + else + h_hint_obj = h_line*lines_count; + } + + //init hint container object + if (isPageChanged()) + y_hint_obj = 0; + CComponentsFrmChain *obj_hint = new CComponentsFrmChain( 0+w_indentation, + y_hint_obj, + obj_content->getWidth()-2*w_indentation, + h_hint_obj, + NULL, + CC_DIR_X, + obj_content); + + //don't paint background for hint container + obj_hint->doPaintBg(false); + obj_hint->setCorner(corner_rad, corner_type); + obj_hint->setPageNumber(at_page_number); + + //add the created items to obj_hint + obj_hint->addCCItem(obj_picon); + obj_hint->addCCItem(obj_text); + + //text object obtains the full height of its parent object + obj_text->setHeightP(100); + + //if we have only one line and a defined picon, then do centering picon to text on the left site + if (lines_count == 1) + obj_picon->setYPos(CC_CENTERED); + + //set next y pos for the next hint object + y_hint_obj += h_hint_obj; + + + //recalculate new hintbox height + ReSize(); + + //set hint box position general to center and refresh window + setCenterPos(); + Refresh(); + + lines += lines_count; } -int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) +void CHintBox::setMsgText(const std::string& Text, const uint& hint_id, const int& mode, Font* font_text, const fb_pixel_t& color_text, const int& style) { - return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon); + uint id = hint_id; + if (hint_id+1 > obj_content->size()){ + id = 0; + dprintf(DEBUG_NORMAL, "[CHintBox] [%s - %d] mismatching hint_id [%u]...\n", __func__, __LINE__, id); + } + + CComponentsFrmChain *obj_hint = static_cast(obj_content->getCCItem(id)); + CComponentsText *obj_text = static_cast(obj_hint->getCCItem(1)); + + //set required font and line size + Font* font = font_text == NULL ? g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO] : font_text; + if (obj_text) + obj_text->setText(Text, mode, font, color_text, style); } +void CHintBox::ReSize() +{ + int h_content_old = obj_content->getHeight(); + int h_content_new = 0; + for (size_t i= 0; i< obj_content->size(); i++){ + CComponentsItem *item = obj_content->getCCItem(i); + h_content_new += item->getHeight(); + } + int h_content_diff = h_content_new - h_content_old; + + obj_content->setHeight(h_content_new); + setHeight(height+h_content_diff); +} + + +void CHintBox::Scroll(bool down, const uint& hint_id) +{ + uint id = hint_id; + if (hint_id+1 > obj_content->size()){ + id = 0; + dprintf(DEBUG_NORMAL, "[CHintBox] [%s - %d] mismatching hint_id [%u]...\n", __func__, __LINE__, id); + } + + CComponentsFrmChain *obj_hint = static_cast(obj_content->getCCItem(id)); + CComponentsText *obj_text = static_cast(obj_hint->getCCItem(1)); + + if (obj_text) { + dprintf(DEBUG_INFO, "[CHintBox] [%s - %d] try to scroll %s hint_id [%u]...Text= %s\n", __func__, __LINE__, down ? "down" : "up", id, obj_text->getText().c_str()); + CTextBox* textbox = obj_text->getCTextBoxObject(); + if (textbox) { + textbox->enableBackgroundPaint(true); + if (down) + textbox->scrollPageDown(1); + else + textbox->scrollPageUp(1); + textbox->enableBackgroundPaint(false); + } + } +} + +void CHintBox::scroll_up(const uint& hint_id) +{ + Scroll(false, hint_id); +} + +void CHintBox::scroll_down(const uint& hint_id) +{ + Scroll(true, hint_id); +} + + +int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons) +{ + int res = messages_return::none; + + CHintBox hintBox(Caption, Text, Width, Icon, Picon, header_buttons); + hintBox.setTimeOut(timeout); + hintBox.paint(); + res = hintBox.exec(); + hintBox.hide(); + + return res; +} + +int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons) +{ + const char * caption = g_Locale->getText(Caption); + return ShowHint(caption, Text, Width, timeout, Icon, Picon, header_buttons); +} + +int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons) +{ + return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon, Picon, header_buttons); +} + +int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons) +{ + return ShowHint(Caption, g_Locale->getText(Text),Width,timeout, Icon, Picon, header_buttons); +} + + +CHint::CHint(const char * const Text, bool show_background) : CHintBox("" , Text) +{ + paint_bg = show_background; + ccw_show_header = false; + ccw_show_footer = false; +} + +CHint::CHint(const neutrino_locale_t Text, bool show_background) : CHintBox("" , g_Locale->getText(Text)) +{ + paint_bg = show_background; + ccw_show_header = false; + ccw_show_footer = false; +} + +int ShowHintS(const char * const Text, int timeout, bool show_background) +{ + int res = messages_return::none; + + CHint hint(Text, show_background); + hint.setTimeOut(timeout); + hint.paint(); + res = hint.exec(); + hint.hide(); + + return res; +} + +int ShowHintS(const neutrino_locale_t Text, int timeout, bool show_background) +{ + return ShowHintS(g_Locale->getText(Text), timeout, show_background); +} diff --git a/src/gui/widget/hintbox.h b/src/gui/widget/hintbox.h index 460d9f556..a071824ae 100644 --- a/src/gui/widget/hintbox.h +++ b/src/gui/widget/hintbox.h @@ -1,88 +1,194 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. + Hintbox based up initial code by + Copyright (C) 2003 Ralf Gandy 'thegoodguy' + Copyright (C) 2004 Sven Traenkle 'zwen' + Copyright (C) 2008-2009, 2011, 2013 Stefan Seyfried + Implementation of CComponent Window class. + Copyright (C) 2014-2015 Thilo Graf 'dbt' License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ -#ifndef __hintbox__ -#define __hintbox__ +#ifndef __C_HINTBOX__ +#define __C_HINTBOX__ -#include -#include -#include +#include -#include -#include +#define HINTBOX_MIN_WIDTH 600 +#define HINTBOX_MIN_HEIGHT 125 +#define HINTBOX_MAX_HEIGHT 420 +#define HINTBOX_DEFAULT_TIMEOUT 5 +//frame around hint container as indent +#define W_FRAME 15 +//frame color around hint/message box +#define HINTBOX_DEFAULT_FRAME_COLOR COL_MENUCONTENT_PLUS_6 -class CHintBox +//! Sub class of CComponentsWindow. Shows a window as a hintbox with text and optional icon beside of text. +/*! +CHintBox provides a small window with header and a text item, +optional you can add an icon in the header and/or beside left of +text and context buttons on the right site of header. +*/ + +class CHintBox : public CComponentsWindow { - protected: + protected: + int y_hint_obj; + int h_hint_obj; + int w_indentation; - CFBWindow * window; + ///global count of lines + uint lines; - unsigned int entries_per_page; - unsigned int current_page; + ///timeout value, see also setTimeOut() + int timeout; - int width; - int height; - int textStartX; + ///content container object, contains the hint objects, it's a child of body object + CComponentsFrmChain *obj_content; - int fheight; - int theight; - const char * caption; - char * message; - std::vector line; - std::string iconfile; - void init(const char * const Caption, const char * const Text, const int Width, const char * const Icon); - void refresh(void); + ///scroll handler, default down and for the 1st hint item (=0), NOTE: exec() must be called! see also scroll_down()/scroll_up() + void Scroll(bool down, const uint& hint_id = 0); - public: - // Text is UTF-8 encoded - CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); - CHintBox(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); - CHintBox(const char * const Caption, const char * const Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); - CHintBox(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); - ~CHintBox(void); + ///main init handler + void init( const std::string& Text, + const int& Width, + const std::string& Picon, + const int& header_buttons, + const int& text_mode, + const int& indent); - bool has_scrollbar(void); - void scroll_up(void); - void scroll_down(void); + void ReSize(); - void paint(void); - void hide(void); + public: + // Text is UTF-8 encoded + CHintBox( const neutrino_locale_t Caption, + const char * const Text, + const int Width = HINTBOX_MIN_WIDTH, + const char * const Icon = NULL, + const char * const Picon = NULL, + const int& header_buttons = 0, + const int& text_mode = 0, + const int& indent = W_FRAME); + + CHintBox( const char * const Caption, + const char * const Text, + const int Width = HINTBOX_MIN_WIDTH, + const char * const Icon = NULL, + const char * const Picon = NULL, + const int& header_buttons = 0, + const int& text_mode = 0, + const int& indent = W_FRAME); + + CHintBox( const neutrino_locale_t Caption, + const neutrino_locale_t Text, + const int Width = HINTBOX_MIN_WIDTH, + const char * const Icon = NULL, + const char * const Picon = NULL, + const int& header_buttons = 0, + const int& text_mode = 0, + const int& indent = W_FRAME); + + CHintBox( const char * const Caption, + const neutrino_locale_t Text, + const int Width = HINTBOX_MIN_WIDTH, + const char * const Icon = NULL, + const char * const Picon = NULL, + const int& header_buttons = 0, + const int& text_mode = 0, + const int& indent = W_FRAME); + + //~CHintBox(); //inherited + int exec(); + + ///define timeout, timeout is enabled if parameter1 > -1 + virtual void setTimeOut(const int& Timeout){timeout = Timeout;}; + + ///scroll handler for text objects: NOTE: exec() must be called ! see also Scroll() + ///scroll up handler, default for the 1st hint item (=0), item id arises from the order of added items with addHintItem(), default we have minimal one item with id=0 + void scroll_up(const uint& hint_id = 0); + ///scroll down handler, default for the 1st hint item (=0), item id arises from the order of added items with addHintItem(), default we have minimal one item with id=0 + void scroll_down(const uint& hint_id = 0); + + ///specialized member to add a hint item, parameter1: UTF8 text that will be showed, parameter2: (optional) textmode, see gui/widget/textbox.h for possible modes, parameter3: (optional) = an icon that will be showed left beside of text + void addHintItem( const std::string& Text, + const int& text_mode = 0, + const std::string& Picon = std::string(), + const u_int8_t& at_page_number = 0, + const fb_pixel_t& color_text = COL_MENUCONTENT_TEXT, + Font* font_text = NULL); + ///add any cc-item to body object, also usable is addWindowItem() to add items to the window body object + void addHintItem(CComponentsItem* cc_Item){obj_content->addCCItem(cc_Item);} + + /*! + * Sets a new text to a hint item, + 2nd parameter expects an item number, default = 0 (1st item). Mostly this should be the only one, but if more than one items are exist, it's possible to select a target item. + 3rd parameter expects modes from CTextBox (default = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER) + AUTO_WIDTH + AUTO_HIGH + SCROLL + CENTER + RIGHT + TOP + BOTTOM + NO_AUTO_LINEBREAK + AUTO_LINEBREAK_NO_BREAKCHARS + 4th parameter font_text expects a font object, if default value = NULL, then g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO] is used + 5th parameter expects value from /gui/color.h or compatible color numbers + 6th parameter expects + FONT_STYLE_REGULAR (default) + FONT_STYLE_BOLD + FONT_STYLE_ITALIC + */ + void setMsgText(const std::string& Text, + const uint& hint_id = 0, + const int& mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER, + Font* font_text = NULL, + const fb_pixel_t& color_text = COL_MENUCONTENT_TEXT, + const int& style = CComponentsText::FONT_STYLE_REGULAR); }; // Text is UTF-8 encoded -int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowHint(const char * const Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0); +int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0); +int ShowHint(const char * const Caption, const char * const Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0); +int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0); + + + +//! Sub class of CHintBox. Shows a simplified hint as a text hint without header and footer. +/*! +CHint provides a text without header and footer, +optional disable/enable background +*/ + +class CHint : public CHintBox +{ + public: + CHint(const char * const Text, bool show_background = true); + CHint(const neutrino_locale_t Text, bool show_background = true); +}; + +//methods to show simplified hints +int ShowHintS(const neutrino_locale_t Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); +int ShowHintS(const char * const Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); #endif diff --git a/src/gui/widget/keyboard_input.cpp b/src/gui/widget/keyboard_input.cpp index 72cd73dfc..d6e7341cf 100644 --- a/src/gui/widget/keyboard_input.cpp +++ b/src/gui/widget/keyboard_input.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -601,7 +601,7 @@ int CKeyboardInput::exec(CMenuTarget* parent, const std::string &) else if ((msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout)) { if ((inputString->getValue() != oldval) && - (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) { + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) { timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); continue; } diff --git a/src/gui/widget/messagebox.cpp b/src/gui/widget/messagebox.cpp index bf6d22730..ea416384c 100644 --- a/src/gui/widget/messagebox.cpp +++ b/src/gui/widget/messagebox.cpp @@ -338,32 +338,12 @@ int ShowMsg(const std::string &Caption, const std::string & Text, const CMessage return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); } -void DisplayErrorMessage(const char * const ErrorMsg) -{ - ShowMsg(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); -} - -void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t Caption) -{ - ShowMsg(Caption, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); -} - -void DisplayErrorMessage(const char * const ErrorMsg, const std::string &Caption) -{ - ShowMsg(Caption, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); -} - -void DisplayInfoMessage(const char * const InfoMsg) -{ - ShowMsg(LOCALE_MESSAGEBOX_INFO, InfoMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); -} - -void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t Caption) -{ - ShowMsg(Caption, InfoMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); -} - -void DisplayInfoMessage(const char * const InfoMsg, const std::string &Caption) -{ - ShowMsg(Caption, InfoMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); -} +// void DisplayErrorMessage(const char * const ErrorMsg) +// { +// ShowMsg(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); +// } +// +// void DisplayInfoMessage(const char * const ErrorMsg) +// { +// ShowMsg(LOCALE_MESSAGEBOX_INFO, ErrorMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); +// } diff --git a/src/gui/widget/messagebox.h b/src/gui/widget/messagebox.h index b06892259..8604efe76 100644 --- a/src/gui/widget/messagebox.h +++ b/src/gui/widget/messagebox.h @@ -107,11 +107,13 @@ int ShowMsg(const std::string &Caption, const char * const Text, const CMessageB int ShowMsg(const std::string &Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +#if 0 void DisplayErrorMessage(const char * const ErrorMsg); // UTF-8 void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t Caption); // UTF-8 void DisplayErrorMessage(const char * const ErrorMsg, const std::string &Caption); // UTF-8 void DisplayInfoMessage(const char * const InfoMsg); // UTF-8 void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t Caption); // UTF-8 void DisplayInfoMessage(const char * const InfoMsg, const std::string &Caption); // UTF-8 +#endif #endif diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index f6ca7e428..65a926475 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -1,47 +1,28 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. + Initial implementation as an interface of the CMsgBox class + Copyright (C) 2005 Günther + Günther@tuxbox.berlios.org + Implementation of CComponent Window class. + Copyright (C) 2014-2015 Thilo Graf 'dbt' License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - *********************************************************** - - Module Name: msgbox.cpp: . - - Description: Implementation of the CMsgBox class - This class provides a message box using CTextBox. - - Date: Nov 2005 - - Author: Gnther@tuxbox.berlios.org - based on code of Steffen Hehn 'McClean' - - Revision History: - Date Author Change Description - Nov 2005 Gnther initial implementation + along with this program. If not, see . */ #ifdef HAVE_CONFIG_H @@ -49,16 +30,10 @@ #endif #include - -#include "msgbox.h" - -#include #include -#define WINDOW_FRAME_BORDER_WIDTH 4 -#define ADD_FOOT_HEIGHT 20 -#define TEXT_BORDER_WIDTH 8 -#define TITLE_ICON_WIDTH (40 - TEXT_BORDER_WIDTH) +#include "msgbox.h" +#include #define MAX_WINDOW_WIDTH (g_settings.screen_EndX - g_settings.screen_StartX ) #define MAX_WINDOW_HEIGHT (g_settings.screen_EndY - g_settings.screen_StartY - 40) @@ -66,818 +41,481 @@ #define MIN_WINDOW_WIDTH (MAX_WINDOW_WIDTH>>1) #define MIN_WINDOW_HEIGHT 40 -#define DEFAULT_TITLE_FONT g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE] -#define DEFAULT_FOOT_FONT g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT] - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -// Function Name: CMsgBox -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -CMsgBox::CMsgBox( const char * text, - Font* fontText, - const int _mode, - const CBox* position, - const char * title, - Font* fontTitle, - const char * icon, - int return_button , - const result_ default_result) +CMsgBox::CMsgBox( const char* Text, + const char* Title, + const char* Icon, + const char* Picon, + const int& Width, + const int& Height, + const int& ShowButtons, + const msg_result_t& Default_result, + const int& Text_mode) : CHintBox( Title, + Text, + Width, + Icon, + Picon, + 0, + Text_mode) { - //TRACE("->CMsgBox::CMsgBox\r\n"); - initVar(); - - if(title != NULL) m_cTitle = title; - if(fontTitle != NULL) m_pcFontTitle = fontTitle; - if(icon != NULL) m_cIcon = icon; - if(position != NULL) m_cBoxFrame = *position; - m_nMode = _mode; - //TRACE(" CMsgBox::cText: %d ,m_cTitle %d,m_nMode %d\t\r\n",strlen(text),m_cTitle.size(),m_nMode); - - if(m_nMode & BORDER) - m_nWindowFrameBorderWidth = WINDOW_FRAME_BORDER_WIDTH; - else - m_nWindowFrameBorderWidth = 0; - - //TRACE(" Mode: "); - //if(_mode & BORDER) TRACE("BORDER "); - //if(_mode & TITLE) TRACE("TITLE "); - //if(_mode & FOOT) TRACE("FOOT "); - //if(_mode & CENTER) TRACE("CENTER"); - //TRACE("\r\n"); - - //TRACE_1(" m_nWindowFrameBorderWidth: \t%d\r\n",m_nWindowFrameBorderWidth); - - - /* Initialise the window frames first */ - initFramesRel(); - - m_pcTextBox = new CTextBox( text, - fontText, - _mode, - &m_cBoxFrameText); - - if(_mode & AUTO_WIDTH || _mode & AUTO_HIGH) - { - /* window might changed in size ...*/ - m_cBoxFrameText = m_pcTextBox->getWindowsPos(); - - m_cBoxFrame.iWidth = m_cBoxFrameText.iWidth + m_nWindowFrameBorderWidth; - m_cBoxFrame.iHeight = m_cBoxFrameText.iHeight + m_cBoxFrameFootRel.iHeight + m_cBoxFrameTitleRel.iHeight + m_nWindowFrameBorderWidth; - - initFramesRel(); - } - - if(_mode & CENTER) - { - m_cBoxFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - m_cBoxFrame.iWidth) >>1); - m_cBoxFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - m_cBoxFrame.iHeight) >>2); - } - - m_nResult = default_result; - m_nFootButtons = return_button; + init(Height, ShowButtons, Default_result); } -////////////////////////////////////////////////////////////////////// -// Function Name: CMsgBox -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -CMsgBox::CMsgBox(const char * text) +CMsgBox::CMsgBox( const char* Text, + const neutrino_locale_t locale_Title, + const char* Icon, + const char* Picon, + const int& Width, + const int& Height, + const int& ShowButtons, + const msg_result_t& Default_result, + const int& Text_mode) : CHintBox( locale_Title, + Text, + Width, + Icon, + Picon, + 0, + Text_mode) { - initVar(); - - m_pcTextBox = new CTextBox( text); - /* Initialise the window frames first */ - initFramesRel(); + init(Height, ShowButtons, Default_result); } -////////////////////////////////////////////////////////////////////// -// Function Name: CMsgBox -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -CMsgBox::CMsgBox() +void CMsgBox::init(const int& Height, const int& ShowButtons, const msg_result_t& Default_result) { - m_pcTextBox = NULL; + dprintf(DEBUG_NORMAL, "[CMsgBox] [%s - %d] \n", __func__, __LINE__); - initVar(); - initFramesRel(); + initTimeOut(); + + //enable footer and add its height + showFooter(true); + ccw_footer->doPaintBg(false); + int h_current = height; + h_current += ccw_footer->getHeight(); + height = max(max(MSGBOX_MIN_HEIGHT, Height), h_current); + + //ensure matching height for screen + height = min(MAX_WINDOW_HEIGHT, height); + width = min(MAX_WINDOW_WIDTH, width); + + //set result + if (Default_result != mbrNone) + result = default_result = Default_result; + + //add and initialize footer buttons with required buttons and basic properties + if (ShowButtons > -1) + mb_show_button = ShowButtons; + initButtons(); } -////////////////////////////////////////////////////////////////////// -// Function Name: ~CMsgBox -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -CMsgBox::~CMsgBox() +void CMsgBox::initTimeOut() { - if (m_pcWindow != NULL) - { - delete m_pcWindow; - m_pcWindow = NULL; - } - - if (m_pcTextBox != NULL) - { - delete m_pcTextBox; - m_pcTextBox = NULL; - } - + timeout = -1; + enable_timeout_result = false; } -////////////////////////////////////////////////////////////////////// -// Function Name: InitVar -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::initVar(void) +void CMsgBox::initButtons() { - //TRACE("->CMsgBox::InitVar\r\n"); - m_nResult = mbrYes; - m_cTitle = ""; - m_cIcon = ""; - m_nMode = SCROLL | TITLE | BORDER ; + button_label_s btn; + vector v_buttons; - // set the title varianles - m_pcFontTitle = DEFAULT_TITLE_FONT; - m_nFontTitleHeight = m_pcFontTitle->getHeight(); + //evaluate combinations + if (mb_show_button & mbAll) + mb_show_button = (mbOk|mbYes|mbNo|mbCancel|mbBack); //stupid! only demo + if (mb_show_button & mbOKCancel) + mb_show_button = (mbOk|mbCancel); + if (mb_show_button & mbYesNoCancel) + mb_show_button = (mbYes|mbNo|mbCancel); + if (mb_show_button & mbYesNo) + mb_show_button = (mbYes|mbNo); - // set the foot variables - m_pcFontFoot = DEFAULT_FOOT_FONT; - m_nFontFootHeight = m_pcFontFoot->getHeight(); - m_nFootButtons = 0; - - // set the main frame border width - if(m_nMode & BORDER) - m_nWindowFrameBorderWidth = WINDOW_FRAME_BORDER_WIDTH; - else - m_nWindowFrameBorderWidth = 0; - - // set the main frame to default - m_cBoxFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1); - m_cBoxFrame.iWidth = MIN_WINDOW_WIDTH; - m_cBoxFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>2); - m_cBoxFrame.iHeight = MIN_WINDOW_HEIGHT; - - m_pcWindow = NULL; - - //TRACE_1(" m_nWindowFrameBorderWidth: \t%d\r\n",m_nWindowFrameBorderWidth); -} - -////////////////////////////////////////////////////////////////////// -// Function Name: InitFramesRel -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::initFramesRel(void) -{ - //TRACE("->CMsgBox::InitFramesRel\r\n"); - // init the title frame - if(m_nMode & TITLE) - { - m_cBoxFrameTitleRel.iX = 0; - m_cBoxFrameTitleRel.iY = 0; - m_cBoxFrameTitleRel.iWidth = m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth; - m_cBoxFrameTitleRel.iHeight = m_nFontTitleHeight + 2; + //assign button text, result values, direct keys and alternate keys + if (mb_show_button & mbOk){ + btn.button = NEUTRINO_ICON_BUTTON_OKAY; + btn.text = BTN_TEXT(mbOk); + btn.directKey = CRCInput::RC_ok; + btn.btn_result = mbrOk; + btn.btn_alias = mbOk; + v_buttons.push_back(btn); } - else - { - m_cBoxFrameTitleRel.iX = 0; - m_cBoxFrameTitleRel.iY = 0; - m_cBoxFrameTitleRel.iHeight = 0; - m_cBoxFrameTitleRel.iWidth = 0; + if (mb_show_button & mbYes){ + btn.button = NEUTRINO_ICON_BUTTON_GREEN; + btn.text = BTN_TEXT(mbYes); + btn.directKey = CRCInput::RC_green; + btn.directKeyAlt = CRCInput::RC_ok; + btn.btn_result = mbrYes; + btn.btn_alias = mbYes; + v_buttons.push_back(btn); + } + if (mb_show_button & mbNo){ + btn.button = NEUTRINO_ICON_BUTTON_RED; + btn.text = BTN_TEXT(mbNo); + btn.directKey = CRCInput::RC_red; + btn.directKeyAlt = CRCInput::RC_home; + btn.btn_result = mbrNo; + btn.btn_alias = mbNo; + v_buttons.push_back(btn); + } + if (mb_show_button & mbCancel){ + btn.button = NEUTRINO_ICON_BUTTON_HOME; + btn.text = BTN_TEXT(mbCancel); + btn.directKey = CRCInput::RC_home; + btn.directKeyAlt = CRCInput::RC_setup; + btn.btn_result = mbrCancel; + btn.btn_alias = mbCancel; + v_buttons.push_back(btn); + } + if (mb_show_button & mbBack){ + btn.button = NEUTRINO_ICON_BUTTON_HOME; + btn.text = BTN_TEXT(mbBack); + btn.directKey = CRCInput::RC_home; + btn.btn_result = mbrBack; + btn.btn_alias = mbBack; + v_buttons.push_back(btn); } - // init the foot frame - if(m_nMode & FOOT) - { - m_cBoxFrameFootRel.iX = 0; - m_cBoxFrameFootRel.iY = m_cBoxFrame.iHeight - m_nFontFootHeight - m_nWindowFrameBorderWidth - ADD_FOOT_HEIGHT; - m_cBoxFrameFootRel.iWidth = m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth; - m_cBoxFrameFootRel.iHeight = m_nFontFootHeight + ADD_FOOT_HEIGHT; - } - else - { - m_cBoxFrameFootRel.iX = 0; - m_cBoxFrameFootRel.iY = 0; - m_cBoxFrameFootRel.iHeight = 0; - m_cBoxFrameFootRel.iWidth = 0; - } + ccw_footer->setButtonLabels(v_buttons, 0, 125); - // init the text frame - m_cBoxFrameText.iY = m_cBoxFrame.iY + m_cBoxFrameTitleRel.iY + m_cBoxFrameTitleRel.iHeight; - m_cBoxFrameText.iX = m_cBoxFrame.iX + m_cBoxFrameTitleRel.iX; - m_cBoxFrameText.iHeight = m_cBoxFrame.iHeight - m_cBoxFrameTitleRel.iHeight - m_cBoxFrameFootRel.iHeight - m_nWindowFrameBorderWidth; - m_cBoxFrameText.iWidth = m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth; -#if 0 - TRACE_1("Frames\r\n\tScren:\t%3d,%3d,%3d,%3d\r\n\tMain:\t%3d,%3d,%3d,%3d\r\n\tText:\t%3d,%3d,%3d,%3d \r\n\tTitle:\t%3d,%3d,%3d,%3d \r\n\tFoot:\t%3d,%3d,%3d,%3d\r\n\r\n", - g_settings.screen_StartX, - g_settings.screen_StartY, - g_settings.screen_EndX, - g_settings.screen_EndY, - m_cBoxFrame.iX, - m_cBoxFrame.iY, - m_cBoxFrame.iWidth, - m_cBoxFrame.iHeight, - m_cBoxFrameText.iX, - m_cBoxFrameText.iY, - m_cBoxFrameText.iWidth, - m_cBoxFrameText.iHeight, - m_cBoxFrameTitleRel.iX, - m_cBoxFrameTitleRel.iY, - m_cBoxFrameTitleRel.iWidth, - m_cBoxFrameTitleRel.iHeight, - m_cBoxFrameFootRel.iX, - m_cBoxFrameFootRel.iY, - m_cBoxFrameFootRel.iWidth, - m_cBoxFrameFootRel.iHeight - ); -#endif -} + //show buttons with frame and background + ccw_footer->showButtonContour(true); -////////////////////////////////////////////////////////////////////// -// Function Name: RefreshFoot -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::refreshFoot(void) -{ - uint32_t color, bgcolor; - if( !(m_nMode & FOOT)) return; + //set position of meassage window and refresh window properties + setCenterPos(); + Refresh(); - // draw the background first - m_pcWindow->paintBoxRel( m_cBoxFrameFootRel.iX+m_cBoxFrame.iX, - m_cBoxFrameFootRel.iY+m_cBoxFrame.iY, - m_cBoxFrameFootRel.iWidth, - m_cBoxFrameFootRel.iHeight, - (CFBWindow::color_t)COL_MENUHEAD_PLUS_0, - RADIUS_LARGE, CORNER_BOTTOM); + //set the 1st button as default selected button + ccw_footer->setSelectedButton(0); - //const char* text; - - int MaxButtonTextWidth = m_pcFontFoot->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL)); - int ButtonWidth = 20 + 33 + MaxButtonTextWidth; - int ButtonSpacing = (m_cBoxFrameFootRel.iWidth - 20- (ButtonWidth*3) ) / 2; - int xpos = m_cBoxFrameFootRel.iX; - - // draw Button mbYes - if (m_nFootButtons & mbYes) - { - if (m_nResult == mbrYes) - { - color = COL_MENUCONTENTSELECTED_TEXT; - bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; + //define default selected button from default_result + if (v_buttons.size() > 1){ + for (size_t i = 0; i< v_buttons.size(); i++){ + if (v_buttons[i].btn_result == result){ + ccw_footer->setSelectedButton(i); + break; + } } - else - { - color = COL_MENUCONTENTINACTIVE_TEXT; - bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; - } - m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX + OFFSET_SHADOW, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY + OFFSET_SHADOW, ButtonWidth, m_nFontFootHeight + 4, COL_SHADOW_PLUS_0, RADIUS_MID); - m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, (CFBWindow::color_t)bgcolor, RADIUS_MID); - m_pcWindow->paintBoxFrame(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, 1, COL_SHADOW_PLUS_0, RADIUS_MID); - m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_RED, xpos + 14+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY); - /*m_pcWindow->RenderString(*/ - m_pcFontFoot->RenderString(xpos + 43+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + m_nFontFootHeight + 4 + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth - 53, g_Locale->getText(LOCALE_MESSAGEBOX_YES), (CFBWindow::color_t)color); - } - - xpos += ButtonWidth + ButtonSpacing; - - // draw Button mbNo - if (m_nFootButtons & mbNo) - { - if (m_nResult == mbrNo) - { - color = COL_MENUCONTENTSELECTED_TEXT; - bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; - } - else - { - color = COL_MENUCONTENTINACTIVE_TEXT; - bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; - } - m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX + OFFSET_SHADOW, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY + OFFSET_SHADOW, ButtonWidth, m_nFontFootHeight + 4, COL_SHADOW_PLUS_0, RADIUS_MID); - m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, (CFBWindow::color_t)bgcolor, RADIUS_MID); - m_pcWindow->paintBoxFrame(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, 1, COL_SHADOW_PLUS_0, RADIUS_MID); - m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, xpos + 14+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY); - /*m_pcWindow->RenderString(*/ - m_pcFontFoot->RenderString(xpos + 43+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + m_nFontFootHeight + 4 + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth- 53, g_Locale->getText(LOCALE_MESSAGEBOX_NO), (CFBWindow::color_t)color); - } - - xpos += ButtonWidth + ButtonSpacing; - - // draw Button mbCancel - if (m_nFootButtons & (mbCancel | mbBack)) - { - if (m_nResult >= mbrCancel) - { - color = COL_MENUCONTENTSELECTED_TEXT; - bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; - } - else - { - color = COL_MENUCONTENTINACTIVE_TEXT; - bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; - } - m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX + OFFSET_SHADOW, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY + OFFSET_SHADOW, ButtonWidth, m_nFontFootHeight + 4, COL_SHADOW_PLUS_0, RADIUS_MID); - m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, (CFBWindow::color_t)bgcolor, RADIUS_MID); - m_pcWindow->paintBoxFrame(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, 1, COL_SHADOW_PLUS_0, RADIUS_MID); - m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_HOME, xpos+10+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY); - /*m_pcWindow->RenderString(*/ - m_pcFontFoot->RenderString(xpos + 43+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + m_nFontFootHeight + 2 + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth- 53, g_Locale->getText((m_nFootButtons & mbCancel) ? LOCALE_MESSAGEBOX_CANCEL : LOCALE_MESSAGEBOX_BACK), (CFBWindow::color_t)color); } } -////////////////////////////////////////////////////////////////////// -// Function Name: RefreshTitle -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::refreshTitle(void) + + +void CMsgBox::enableDefaultResultOnTimeOut(bool enable) { - // first check if title is configured - if( !(m_nMode & TITLE)) return; - - CComponentsHeader header(m_cBoxFrameTitleRel.iX+m_cBoxFrame.iX, - m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY, - m_cBoxFrameTitleRel.iWidth, - m_cBoxFrameTitleRel.iHeight, m_cTitle, m_cIcon); - header.paint(CC_SAVE_SCREEN_NO); -#if 0 - // draw the background - m_pcWindow->paintBoxRel( m_cBoxFrameTitleRel.iX+m_cBoxFrame.iX, - m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY, - m_cBoxFrameTitleRel.iWidth, - m_cBoxFrameTitleRel.iHeight, - (CFBWindow::color_t)COL_MENUHEAD_PLUS_0, - RADIUS_LARGE, CORNER_TOP); - - if (!m_cIcon.empty()) - { - // draw icon and title text - m_pcWindow->paintIcon(m_cIcon.c_str(), m_cBoxFrameTitleRel.iX + 8+m_cBoxFrame.iX, m_cBoxFrameTitleRel.iY + 5+m_cBoxFrame.iY); - /*m_pcWindow->RenderString(*/ - m_pcFontTitle->RenderString( - m_cBoxFrameTitleRel.iX + TITLE_ICON_WIDTH + TEXT_BORDER_WIDTH+m_cBoxFrame.iX, - m_cBoxFrameTitleRel.iHeight+3+m_cBoxFrame.iY, - m_cBoxFrameTitleRel.iWidth - TITLE_ICON_WIDTH + TEXT_BORDER_WIDTH, - m_cTitle.c_str(), - COL_MENUHEAD_TEXT); - } - else - { - // no icon available, just draw the title text - /*m_pcWindow->RenderString(*/ - m_pcFontTitle->RenderString( - m_cBoxFrameTitleRel.iX + TEXT_BORDER_WIDTH+m_cBoxFrame.iX, - m_cBoxFrameTitleRel.iHeight+3+m_cBoxFrame.iY, - m_cBoxFrameTitleRel.iWidth - TEXT_BORDER_WIDTH, - m_cTitle.c_str(), - COL_MENUHEAD_TEXT); - } -#endif + enable_timeout_result = enable; } -////////////////////////////////////////////////////////////////////// -// Function Name: RefreshBorder -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::refreshBorder(void) +int CMsgBox::exec() { - if( !(m_nMode & BORDER && m_nWindowFrameBorderWidth > 0)) return; - - //draw bottom shadow - m_pcWindow->paintBoxRel( m_nWindowFrameBorderWidth+m_cBoxFrame.iX, - m_cBoxFrame.iHeight - m_nWindowFrameBorderWidth+m_cBoxFrame.iY - RADIUS_LARGE, - m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth - RADIUS_LARGE, - m_nWindowFrameBorderWidth + RADIUS_LARGE, - COL_SHADOW_PLUS_0, - RADIUS_LARGE, CORNER_BOTTOM_LEFT); - - //draw right shadow - m_pcWindow->paintBoxRel( m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth+m_cBoxFrame.iX - RADIUS_LARGE, - m_nWindowFrameBorderWidth+m_cBoxFrame.iY, - m_nWindowFrameBorderWidth + RADIUS_LARGE, - m_cBoxFrame.iHeight - m_nWindowFrameBorderWidth, - COL_SHADOW_PLUS_0, - RADIUS_LARGE, CORNER_RIGHT); -} - -////////////////////////////////////////////////////////////////////// -// global Functions -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -// Function Name: Hide -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -bool CMsgBox::hide(void) -{ - //TRACE("->CMsgBox::Hide\r\n"); - - if (m_pcWindow == NULL) - { - TRACE(" return -> window does not exists\r\n"); - return (false); - } - if(m_pcTextBox != NULL) - { - m_pcTextBox->hide(); - } - - // delete window - // delete m_pcWindow; - m_pcWindow->paintBackgroundBoxRel(m_cBoxFrame.iX, m_cBoxFrame.iY, m_cBoxFrame.iWidth, m_cBoxFrame.iHeight); - m_pcWindow = NULL; - return (true); -} - -////////////////////////////////////////////////////////////////////// -// Function Name: ScrollPageDown -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::scrollPageDown(const int pages) -{ - // send scroll up event to text box if there is one - if(m_pcTextBox != NULL) - { - m_pcTextBox->scrollPageDown(pages); - } - -} - -////////////////////////////////////////////////////////////////////// -// Function Name: ScrollPageUp -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::scrollPageUp(const int pages) -{ - // send scroll up event to text box if there is one - if(m_pcTextBox != NULL) - { - m_pcTextBox->scrollPageUp(pages); - } -} - -////////////////////////////////////////////////////////////////////// -// Function Name: Paint -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -bool CMsgBox::paint(void) -{ - /* - * do not paint stuff twice: - * => thread safety needed by movieplayer.cpp: - * one thread calls our paint method, the other one our hide method - * => no memory leaks - */ - //TRACE("->CMsgBox::Paint\r\n"); - - if (m_pcWindow != NULL) - { - TRACE(" return -> window already exists\r\n"); - return (false); - } - - // create new window - //m_pcWindow = new CFBWindow( m_cBoxFrame.iX, m_cBoxFrame.iY, m_cBoxFrame.iWidth, m_cBoxFrame.iHeight); - m_pcWindow = CFrameBuffer::getInstance(); - refresh(); - if(m_pcTextBox != NULL) - { - m_pcTextBox->paint(); - } - return (true); -} - -////////////////////////////////////////////////////////////////////// -// Function Name: Refresh -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -void CMsgBox::refresh(void) -{ - //TRACE("->CMsgBox::Refresh\r\n"); - - if (m_pcWindow == NULL) - { - TRACE(" return -> no window\r\n"); - return; - } - - //re-draw message box window - refreshBorder(); - refreshTitle(); - refreshFoot(); - - //draw body - m_pcWindow->paintBoxRel( m_cBoxFrameText.iX, - m_cBoxFrameText.iY, - m_cBoxFrameText.iWidth, - m_cBoxFrameText.iHeight, - COL_MENUCONTENT_PLUS_0); - - // rep-draw textbox if there is one - if(m_pcTextBox != NULL) - { - //m_pcTextBox->refresh(); - } -} - -////////////////////////////////////////////////////////////////////// -// Function Name: Exec -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -int CMsgBox::exec( int timeout, int returnDefaultOnTimeout) -{ - //TRACE("->CMsgBox::exec\r\n"); -#ifdef VC - int res = 1; - -#else neutrino_msg_t msg; neutrino_msg_data_t data; - int return_button = m_nFootButtons; int res = menu_return::RETURN_REPAINT; - // show message box - paint(); - if (m_pcWindow == NULL) - { - return res; /* out of memory */ - } + ccw_footer->getSelectedButtonObject()->setButtonAlias(mb_show_button); + int selected = ccw_footer->getSelectedButton(); - if ( timeout == -1 ) - timeout = g_settings.timing[SNeutrinoSettings::TIMING_EPG]; - uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); + dprintf(DEBUG_NORMAL, "[CMsgBox] [%s - %d] getSelectedButton()= %d\n", __func__, __LINE__,ccw_footer->getSelectedButton()); - bool loop=true; + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout); + + bool loop = true; while (loop) { g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); - if (msg == CRCInput::RC_timeout && returnDefaultOnTimeout) + + //***timeout result*** + if (msg == CRCInput::RC_timeout && timeout > 0) { - // return default + result = enable_timeout_result ? default_result : mbrTimeout; loop = false; } - else if ( ((msg == CRCInput::RC_timeout) || - (msg == (neutrino_msg_t)g_settings.key_channelList_cancel)) && - (return_button & (mbCancel | mbBack))) +#if 0 + else if (((msg == CRCInput::RC_timeout && timeout > 0) || + (msg == (neutrino_msg_t)g_settings.key_channelList_cancel)) && + (mb_show_button & (mbCancel | mbBack))) { - m_nResult = (return_button & mbCancel) ? mbrCancel : mbrBack; + result = (mb_show_button & mbCancel) ? mbrCancel : (mb_show_button & mbOk) ? mbrOk: mbrBack; loop = false; } - else if ((msg == CRCInput::RC_green) && (return_button & mbNo)) - { - m_nResult = mbrNo; - loop = false; - } - else if ((msg == CRCInput::RC_red) && (return_button & mbYes)) - { - m_nResult = mbrYes; - loop = false; - } - else if(msg==CRCInput::RC_right) - { - bool ok = false; - while (!ok) - { - m_nResult = (CMsgBox::result_)((m_nResult + 1) & 3); - ok = m_nFootButtons & (1 << m_nResult); - } - - refreshFoot(); - } +#endif + //***navi buttons for scroll*** else if (msg == CRCInput::RC_up ) { - scrollPageUp(1); + scroll_up(); } else if (msg == CRCInput::RC_down) { - scrollPageDown(1); + scroll_down(); } - else if(msg==CRCInput::RC_left) - { - bool ok = false; - while (!ok) + else if (msg){ + //***navi buttons for button selection*** + if(msg==CRCInput::RC_right || msg==CRCInput::RC_left) { - m_nResult = (CMsgBox::result_)((m_nResult - 1) & 3); - ok = return_button & (1 << m_nResult); - } + if(msg==CRCInput::RC_right){ + ccw_footer->setSelectedButton(selected+1); + mb_show_button = ccw_footer->getSelectedButtonObject()->getButtonAlias(); + } + if(msg==CRCInput::RC_left){ + ccw_footer->setSelectedButton(selected-1); + mb_show_button = ccw_footer->getSelectedButtonObject()->getButtonAlias(); + } + dprintf(DEBUG_INFO, "[CMsgBox] [%s - %d] result = %d, mb_show_button = %d\n", __func__, __LINE__, result, mb_show_button); + selected = ccw_footer->getSelectedButton(); + refreshFoot(); - refreshFoot(); - } - else if(msg == CRCInput::RC_ok) - { - loop = false; - } - else if (CNeutrinoApp::getInstance()->listModeKey(msg)) - { - // do nothing + //refresh timeout on any pressed navi key! This resets current timeout end to the initial value + if (timeout > 0) + timeoutEnd = CRCInput::calcTimeoutEnd(timeout); + } + //***action buttons without preselection*** + for (size_t i = 0; i< ccw_footer->getButtonChainObject()->size(); i++){ + CComponentsButton* btn_action = static_cast(ccw_footer->getButtonChainObject()->getCCItem(i)); + if (msg == btn_action->getButtonDirectKey() || msg == btn_action->getButtonDirectKeyA()){ + result = (msg_result_t)btn_action->getButtonResult(); + dprintf(DEBUG_INFO, "[CMsgBox] [%s - %d] result = %d, mb_show_button = %d\n", __func__, __LINE__, result, mb_show_button); + loop = false; + } + } + //***action button ok with preselected button*** + if ((msg == CRCInput::RC_ok) && (ccw_footer->getSelectedButtonObject()->getButtonAlias() == mb_show_button)){ + result = (msg_result_t)ccw_footer->getSelectedButtonObject()->getButtonResult(); + loop = false; + } + //***ignore*** + else if (CNeutrinoApp::getInstance()->listModeKey(msg)){ + // do nothing //TODO: if passed rc messages are ignored rc messaages: has no effect here too!! + } } else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { + dprintf(DEBUG_INFO, "[CMsgBox] [%s - %d] messages_return::cancel_all\n", __func__, __LINE__); res = menu_return::RETURN_EXIT_ALL; loop = false; } - } - hide(); -#endif //VC - return res; } -////////////////////////////////////////////////////////////////////// -// Function Name: SetText -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -bool CMsgBox::setText(const std::string* newText) + +void CMsgBox::refreshFoot(void) { - bool lresult = false; - // update text in textbox if there is one - if(m_pcTextBox != NULL && newText != NULL) + ccw_footer->paint(false); +} + + +void CMsgBox::setButtonText(const int& showed_button, const std::string& text) +{ + switch (showed_button) { - if(m_nMode & AUTO_WIDTH || m_nMode & AUTO_HIGH) - { - /* window might changed in size ...*/ - m_cBoxFrameText = m_pcTextBox->getWindowsPos(); + case mbYes: + btn_text_yes = text; + break; + case mbNo: + btn_text_no = text; + break; + case mbCancel: + btn_text_cancel = text; + break; + case mbBack: + btn_text_back = text; + break; + case mbOk: + btn_text_ok = text; + break; + default: + return; + break; + } + initButtons(); +} - m_cBoxFrame.iWidth = m_cBoxFrameText.iWidth + m_nWindowFrameBorderWidth; - m_cBoxFrame.iHeight = m_cBoxFrameText.iHeight + m_cBoxFrameFootRel.iHeight + m_cBoxFrameTitleRel.iHeight + m_nWindowFrameBorderWidth; +inline std::string CMsgBox::BTN_TEXT(const int& showed_button) +{ + string ret = ""; - initFramesRel(); - - // since the frames size has changed, we have to recenter the window again */ - if(m_nMode & CENTER) - { - m_cBoxFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - m_cBoxFrame.iWidth) >>1); - m_cBoxFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - m_cBoxFrame.iHeight) >>1); - } - } - - lresult = m_pcTextBox->setText(newText); + switch (showed_button) + { + case mbYes: + ret = btn_text_yes.empty() ? g_Locale->getText(LOCALE_MESSAGEBOX_YES) : btn_text_yes; + break; + case mbNo: + ret = btn_text_no.empty() ? g_Locale->getText(LOCALE_MESSAGEBOX_NO) : btn_text_no; + break; + case mbCancel: + ret = btn_text_cancel.empty() ? g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL) : btn_text_cancel; + break; + case mbBack: + ret = btn_text_back.empty() ? g_Locale->getText(LOCALE_MESSAGEBOX_BACK) : btn_text_back; + break; + case mbOk: + ret = btn_text_ok.empty() ? g_Locale->getText(LOCALE_MESSAGEBOX_OK) : btn_text_ok; + break; + default: + break; } - return(lresult); + return ret; } -////////////////////////////////////////////////////////////////////// -// Function Name: SetText -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -int CMsgBox::result(void) +int ShowMsg2UTF( const char * const Title, + const char * const Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) { - return m_nResult; + CMsgBox msgBox (Text, + Title, + Icon, + NULL, + Width, + MSGBOX_MIN_HEIGHT, + ShowButtons, + Default, + Text_mode); + + if (color_frame != HINTBOX_DEFAULT_FRAME_COLOR){ + msgBox.setFrameThickness(4); + msgBox.setColorFrame(color_frame); + } + + msgBox.enableDefaultResultOnTimeOut(returnDefaultOnTimeout); + msgBox.setTimeOut(Timeout); + msgBox.paint(); + msgBox.exec(); + int res = msgBox.getResult(); + msgBox.hide(); + return res; } -////////////////////////////////////////////////////////////////////// -// Function Name: ShowMsg2UTF -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -int ShowMsg2UTF( const neutrino_locale_t Caption, - const char * const Text, - const CMsgBox::result_ Default, - const uint32_t ShowButtons, - const char * const Icon, - const int Width, - const int timeout, - bool returnDefaultOnTimeout) +int ShowMsg2UTF( const neutrino_locale_t Title, + const char * const Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) { - //TRACE("->CMsgBox::ShowTextUTF \r\n"); - - int result = ShowMsg2UTF( g_Locale->getText(Caption), - Text, - Default, - ShowButtons, - Icon, - Width, - timeout, - returnDefaultOnTimeout); + int result = ShowMsg( g_Locale->getText(Title), Text, Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame); return (result); - } -////////////////////////////////////////////////////////////////////// -// Function Name: ShowMsg2UTF -// Description: -// Parameters: -// Data IN/OUT: -// Return: -// Notes: -////////////////////////////////////////////////////////////////////// -int ShowMsg2UTF( const char * const Title, - const char * const Text, - const CMsgBox::result_ Default, - const uint32_t ShowButtons, - const char * const Icon, - const int /*Width*/, - const int timeout, - bool returnDefaultOnTimeout) +//for compatibility +int ShowMsg( const neutrino_locale_t Title, + const char * const Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) { - int mode = CMsgBox::SCROLL | - CMsgBox::TITLE | - CMsgBox::FOOT | - CMsgBox::BORDER;// | - //CMsgBox::NO_AUTO_LINEBREAK | - //CMsgBox::CENTER | - //CMsgBox::AUTO_WIDTH | - //CMsgBox::AUTO_HIGH; - CBox position ( g_settings.screen_StartX+30, - g_settings.screen_StartY+30, - g_settings.screen_EndX - g_settings.screen_StartX-60, - g_settings.screen_EndY - g_settings.screen_StartY-60); + int result = ShowMsg2UTF(Title, Text, Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame); - //TRACE("\r\n->ShowTextUTF %s\r\n",Text); - CMsgBox* msgBox = new CMsgBox( Text, - g_Font[SNeutrinoSettings::FONT_TYPE_MENU], - mode, - &position, - Title, - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], - Icon, - ShowButtons, - Default); - - msgBox->exec( timeout, returnDefaultOnTimeout); - - int res = msgBox->result(); - - delete msgBox; - - return res; + return (result); +} + +int ShowMsg( const char * const Title, + const char * const Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) +{ + int result = ShowMsg2UTF(Title, Text, Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame); + + return (result); +} + +int ShowMsg( const neutrino_locale_t Title, + const std::string & Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) +{ + int result = ShowMsg2UTF(Title, Text.c_str(), Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame); + + return (result); +} + +int ShowMsg( const neutrino_locale_t Title, + const neutrino_locale_t Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) +{ + int result = ShowMsg2UTF(g_Locale->getText(Title), g_Locale->getText(Text), Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame); + + return (result); +} + +int ShowMsg( const std::string & Title, + const std::string & Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon, + const int Width, + const int Timeout, + bool returnDefaultOnTimeout, + const int& Text_mode, + fb_pixel_t color_frame) +{ + int result = ShowMsg2UTF(Title.c_str(), Text.c_str(), Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame); + + return (result); +} + +void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int& Text_mode) +{ + ShowMsg(caption, ErrorMsg, CMsgBox::mbrCancel, CMsgBox::mbBack, NEUTRINO_ICON_ERROR, 500, -1, false, Text_mode, COL_RED); +} + +void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int& Text_mode) +{ + ShowMsg(caption, ErrorMsg, CMsgBox::mbrCancel, CMsgBox::mbBack, NEUTRINO_ICON_ERROR, 500, -1, false, Text_mode, COL_RED); +} + +void DisplayErrorMessage(const char * const ErrorMsg, const int& Text_mode) +{ + DisplayErrorMessage(ErrorMsg, LOCALE_MESSAGEBOX_ERROR, Text_mode); +} + +void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Text_mode, fb_pixel_t color_frame) +{ + ShowMsg(caption, InfoMsg, CMsgBox::mbrBack, CMsgBox::mbOk, NEUTRINO_ICON_INFO, 500, -1, false, Text_mode, color_frame); +} + +void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Text_mode, fb_pixel_t color_frame) +{ + ShowMsg(caption, InfoMsg, CMsgBox::mbrBack, CMsgBox::mbOk, NEUTRINO_ICON_INFO, 500, -1, false, Text_mode, color_frame); +} + +void DisplayInfoMessage(const char * const InfoMsg, const int& Text_mode, fb_pixel_t color_frame) +{ + DisplayInfoMessage(InfoMsg, LOCALE_MESSAGEBOX_INFO, Text_mode, color_frame); } diff --git a/src/gui/widget/msgbox.h b/src/gui/widget/msgbox.h index a30186389..46c9fbd75 100644 --- a/src/gui/widget/msgbox.h +++ b/src/gui/widget/msgbox.h @@ -1,170 +1,272 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. + Initial implementation as an interface of the CMsgBox class + Copyright (C) 2005 Günther + Günther@tuxbox.berlios.org + Implementation of CComponent Window class. + Copyright (C) 2014-2015 Thilo Graf 'dbt' License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - *********************************************************** - - Module Name: msgbox.h . - - Description: interface of the CMsgBox class - - Date: Nov 2005 - - Author: Günther@tuxbox.berlios.org - based on code of Steffen Hehn 'McClean' - - Revision History: - Date Author Change Description - Nov 2005 Günther initial implementation - + along with this program. If not, see . */ -#if !defined(MSGBOX_H) -#define MSGBOX_H +#ifndef __C_MSGBOX__ +#define __C_MSGBOX__ #ifdef HAVE_CONFIG_H #include #endif -#include -#include "textbox.h" +#include "hintbox.h" +#include -#include +#define MSGBOX_MIN_WIDTH HINTBOX_MIN_WIDTH +#define MSGBOX_MIN_HEIGHT HINTBOX_MIN_HEIGHT + 75 -class CMsgBox + +//! Sub class of CHintBox. Shows a window as a messagebox +/*! +CMsgBox provides a small window with header, text and footer +with predefined buttons. +Optional you can add an icon in the header and/or beside left of +text and context buttons on the right site of header. +CMsgBox objects return predefined result values of type msg_result_t. +Button combinations are defined with button_define_t +*/ +class CMsgBox : public CHintBox { public: /* enum definition */ - enum result_ + enum msg_result_t { mbrYes = 0, mbrNo = 1, mbrCancel = 2, - mbrBack = 3 + mbrBack = 3, + mbrOk = 4, + mbrTimeout = 5, + + mbrNone = -1 }; - enum buttons_ + enum button_define_t { - mbYes = 0x01, - mbNo = 0x02, - mbCancel = 0x04, - mbAll = 0x07, - mbBack = 0x08 + mbYes = 0x01, + mbNo = 0x02, + mbCancel = 0x04, + mbBack = 0x08, + mbOk = 0x10, + mbOKCancel = 0x20, + mbYesNoCancel = 0x40, + mbYesNo = 0x80, + mbAll = 0x100, + //unused allign stuff, only for compatibility + mbBtnAlignCenter1 = 0x0400, /* centered, large distances */ + mbBtnAlignCenter2 = 0x0800, /* centered, small distances */ + mbBtnAlignLeft = 0x1000, + mbBtnAlignRight = 0x2000 }; - enum modes + + enum modes //TODO { - AUTO_WIDTH = 0x01, - AUTO_HIGH = 0x02, - SCROLL = 0x04, - TITLE = 0x08, - FOOT = 0x10, - BORDER = 0x20, - CENTER = 0x40, - NO_AUTO_LINEBREAK= 0x80 + AUTO_WIDTH = CTextBox::AUTO_WIDTH, + AUTO_HIGH = CTextBox::AUTO_HIGH, + SCROLL = CTextBox::SCROLL, +// TITLE = 0x08, +// FOOT = 0x10, +// BORDER = 0x20, + CENTER = CTextBox::CENTER, + NO_AUTO_LINEBREAK = CTextBox::NO_AUTO_LINEBREAK }; private: - /* Functions */ - void initVar(void); - void initFramesRel(void); + void init(const int& Height = -1, const int& ShowButtons = -1, const msg_result_t& Default_result = mbrNone); void refreshFoot(void); - void refreshTitle(void); - void refreshText(void); - void refreshBorder(void); + int mb_show_button; - /* Variables */ - std::string m_cIcon; - std::string m_cTitle; + ///current result value of selected button, see also getResult() + msg_result_t result; + ///defined default result, independently from current selected button result, see also setDefaultResult(), getDefaultResult() + msg_result_t default_result; + ///enable/disable default result on timeout + bool enable_timeout_result; + ///initialize basic timeout + void initTimeOut(); - CBox m_cBoxFrame; - CBox m_cBoxFrameText; - CBox m_cBoxFrameTitleRel; - CBox m_cBoxFrameFootRel; + ///alternate button text + std::string btn_text_ok, btn_text_yes, btn_text_no, btn_text_cancel, btn_text_back; + ///assigned button captions + std::string BTN_TEXT(const int& showed_button); - int m_nMode; - - int m_nWindowFrameBorderWidth; - - Font* m_pcFontTitle; - int m_nFontTitleHeight; - - Font* m_pcFontFoot; - int m_nFontFootHeight; - int m_nFootButtons; - - CTextBox* m_pcTextBox; - //CFBWindow* m_pcWindow; - CFrameBuffer * m_pcWindow; - - result_ m_nResult; + void initButtons(); public: /* Constructor */ - virtual ~CMsgBox(); - CMsgBox(); - CMsgBox(const char * text); - CMsgBox( const char * text, - Font* fontText, - const int mode, - const CBox* position, - const char * title, - Font* fontTitle, - const char * icon, - int return_button = mbCancel, - const result_ default_result = mbrCancel); + CMsgBox(const char* Text, + const char* Title = NULL, + const char* Icon = NULL, + const char* Picon = NULL, + const int& Width = MSGBOX_MIN_WIDTH, + const int& Height = MSGBOX_MIN_HEIGHT, + const int& ShowButtons = mbCancel, + const msg_result_t& Default_result = mbrCancel, + const int& Text_mode = CMsgBox::CENTER | CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::SCROLL); - /* Functions */ - bool paint(void); - bool hide(void); - int exec(int timeout,int returnDefaultOnTimeout = false); - void refresh(void); - void scrollPageDown(const int pages); - void scrollPageUp(const int pages); - int result(void); + CMsgBox(const char* Text, + const neutrino_locale_t locale_Title = NONEXISTANT_LOCALE, + const char* Icon = NULL, + const char* Picon = NULL, + const int& Width = MSGBOX_MIN_WIDTH, + const int& Height = MSGBOX_MIN_HEIGHT, + const int& ShowButtons = mbCancel, + const msg_result_t& Default_result = mbrCancel, + const int& Text_mode = CMsgBox::CENTER | CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::SCROLL); - bool setText(const std::string* newText); +// ~CMsgBox(); //inherited + int exec(); + + ///returns current result as msg_result_t, result corresponds to the current result value of selected button + msg_result_t getResult(){return result;}; + ///returns current default result as msg_result_t, independently from current selected button result + msg_result_t getDefaultResult(){return default_result;}; + ///sets current default result as msg_result_t, independently from current selected button result + void setDefaultResult(const msg_result_t& Default_result){default_result = Default_result;} + + /*! + Sets the displayed buttons. + This member allows to set and overrides already defined buttons from constructor, + parameter ''ShowButtons'' accepts given types, find under button_define_t enumeration + mbYes + mbNo + mbCancel + mbBack + mbOk + mbOKCancel + mbYesNoCancel + mbYesNo + mbAll + */ + void setShowedButtons(const int& ShowButtons){mb_show_button = ShowButtons; initButtons();} + + ///define timeout, timeout is enabled if parmeter 1 > -1, otherwise it will be disabled, + void setTimeOut(const int& Timeout){timeout = Timeout;}; + ///enable/disable defined timeout, otherwise it will be ignored, parameter 1: bool default = true + void enableDefaultResultOnTimeOut(bool enable = true); + + /*! + Default defined button text is already predefiend with parameter 'ShowButtons' from constructor. + This member allows to define an alternate text for an already defined button, + 1st parameter ''showed button'' accepts + mbYes + mbNo + mbCancel + mbBack + mbOk + others will be ignored! + 2nd parameter sets the new text for button as std::string. + Result values are not touched! + */ + void setButtonText(const int& showed_button, const std::string& text); + +// bool setText(const std::string* newText); }; -extern int ShowMsg2UTF( const neutrino_locale_t Caption, +#define DEFAULT_TEXT_MODE (CMsgBox::CENTER | CMsgBox::AUTO_WIDTH | CMsgBox::AUTO_HIGH) + +int ShowMsg2UTF( const neutrino_locale_t Title, const char * const Text, - const CMsgBox::result_ Default, + const CMsgBox::msg_result_t Default, const uint32_t ShowButtons, const char * const Icon = NULL, - const int Width = 450, - const int timeout = -1, - bool returnDefaultOnTimeout = false); // UTF-8 + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 -extern int ShowMsg2UTF( const char * const Title, +int ShowMsg2UTF( const char * const Title, const char * const Text, - const CMsgBox::result_ Default, + const CMsgBox::msg_result_t Default, const uint32_t ShowButtons, const char * const Icon = NULL, - const int Width = 450, - const int timeout = -1, - bool returnDefaultOnTimeout = false); // UTF-8 - + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 +int ShowMsg( const neutrino_locale_t Title, + const char * const Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon = NULL, + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 + +int ShowMsg( const char * const Title, + const char * const Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon = NULL, + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 + +int ShowMsg( const neutrino_locale_t Title, + const std::string & Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon = NULL, + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 + +int ShowMsg( const neutrino_locale_t Title, + const neutrino_locale_t Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon = NULL, + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 + +int ShowMsg( const std::string & Title, + const std::string & Text, + const CMsgBox::msg_result_t Default, + const uint32_t ShowButtons, + const char * const Icon = NULL, + const int Width = MSGBOX_MIN_WIDTH, + const int Timeout = -1, + bool returnDefaultOnTimeout = false, + const int& Text_mode = DEFAULT_TEXT_MODE, + fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 + +void DisplayErrorMessage(const char * const ErrorMsg, const int& Text_mode = DEFAULT_TEXT_MODE); // UTF-8 +void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int& Text_mode = DEFAULT_TEXT_MODE); // UTF-8 +void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int& Text_mode = DEFAULT_TEXT_MODE); // UTF-8 +void DisplayInfoMessage(const char * const InfoMsg, const int& Text_mode = DEFAULT_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 +void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Text_mode = DEFAULT_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 +void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Text_mode = DEFAULT_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 #endif diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index a0602a68d..78fa6d23e 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index b47a99c4e..748683900 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -38,7 +38,7 @@ #include #include -#include +#include #include @@ -485,7 +485,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { if ((*valueString != oldval) && - (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) { + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) { timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); continue; } diff --git a/src/gui/widget/stringinput_ext.cpp b/src/gui/widget/stringinput_ext.cpp index 4b4923e00..859fc9588 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -35,7 +35,7 @@ #include -#include +#include #include #include @@ -235,19 +235,19 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { if(*valueString != oldval){ - int erg = ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel); - if(erg==CMessageBox::mbrYes){ + int erg = ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbNo | CMsgBox::mbYes | CMsgBox::mbCancel); + if(erg==CMsgBox::mbrYes){ *valueString = oldval; loop=false; if(cancel != NULL) *cancel = true; } - else if(erg==CMessageBox::mbrNo){ + else if(erg==CMsgBox::mbrNo){ loop=false; if(cancel != NULL) *cancel = false; } - else if(erg==CMessageBox::mbrCancel){ + else if(erg==CMsgBox::mbrCancel){ timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); } } else { diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 07187bda3..6ac3c30cf 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -98,7 +98,7 @@ #include "gui/widget/hintbox.h" #include "gui/widget/icons.h" #include "gui/widget/menue.h" -#include "gui/widget/messagebox.h" +#include "gui/widget/msgbox.h" #include "gui/infoclock.h" #include "gui/parentallock_setup.h" #ifdef ENABLE_PIP @@ -2314,7 +2314,7 @@ void CNeutrinoApp::RealRun() #endif g_PluginList->startPlugin("startup"); if (!g_PluginList->getScriptOutput().empty()) { - ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL); } g_RCInput->clearRCMsg(); @@ -3240,14 +3240,14 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } else if( msg == NeutrinoMessages::ANNOUNCE_SLEEPTIMER) { if( mode != mode_scart && mode != mode_standby) - skipSleepTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + skipSleepTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30, true) == CMsgBox::mbrYes); return messages_return::handled; } else if( msg == NeutrinoMessages::SLEEPTIMER) { if(data) {//INACTIVITY SLEEPTIMER skipShutdownTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, - CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME + CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30, true) == CMsgBox::mbrYes);//FIXME if(skipShutdownTimer) { printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); skipShutdownTimer = false; @@ -3301,7 +3301,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } else if( msg == NeutrinoMessages::ANNOUNCE_SHUTDOWN) { if( mode != mode_scart ) - skipShutdownTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 5) == CMessageBox::mbrYes); + skipShutdownTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 5) == CMsgBox::mbrYes); } else if( msg == NeutrinoMessages::SHUTDOWN ) { if(!skipShutdownTimer) { @@ -3319,21 +3319,21 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) { if (mode != mode_scart && mode != mode_standby) { - std::string timeout="-1"; + int timeout = HINTBOX_DEFAULT_TIMEOUT; std::string text = (char*)data; std::string::size_type pos; pos = text.find("&timeout=", 0); if (pos != std::string::npos) { - timeout = text.substr( pos+9, text.length()+1 ); + std::string tmp = text.substr( pos+9, text.length()+1 ); text[pos] = '\0'; + timeout = atoi(tmp.c_str()); } if (msg == NeutrinoMessages::EVT_POPUP) - ShowHint(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); + ShowHint(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, timeout); else if (msg == NeutrinoMessages::EVT_EXTMSG) - ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); - + ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO, 500, timeout); } delete[] (unsigned char*) data; return messages_return::handled; @@ -3354,7 +3354,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) text[pos] = '\n'; } if( mode != mode_scart ) - ShowMsg(LOCALE_TIMERLIST_TYPE_REMIND, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_TIMERLIST_TYPE_REMIND, text, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 delete[] (unsigned char*) data; return messages_return::handled; } @@ -3426,7 +3426,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) else if (msg == NeutrinoMessages::EVT_START_PLUGIN) { g_PluginList->startPlugin((const char *)data); if (!g_PluginList->getScriptOutput().empty()) { - ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMsgBox::mbrBack,CMsgBox::mbBack,NEUTRINO_ICON_SHELL); } delete[] (unsigned char*) data; @@ -3440,7 +3440,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } return messages_return::handled; // ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EXTRA_ZAPIT_SDT_CHANGED), -// CMessageBox::mbrBack,CMessageBox::mbBack, NEUTRINO_ICON_INFO); +// CMsgBox::mbrBack,CMsgBox::mbBack, NEUTRINO_ICON_INFO); } else if (msg == NeutrinoMessages::EVT_HDMI_CEC_VIEW_ON) { if(g_settings.hdmi_cec_view_on) @@ -3480,8 +3480,8 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) CRecordManager::getInstance()->StopAutoRecord(); if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive()) { do_shutdown = - (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMessageBox::mbrNo, - CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo, + CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 30, true) == CMsgBox::mbrYes); } if(do_shutdown) { @@ -3957,7 +3957,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) int returnval = menu_return::RETURN_REPAINT; if(actionKey == "help_recording") { - ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack); } else if(actionKey=="shutdown") { ExitRun(true, 1); @@ -4051,8 +4051,8 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) if (recordingstatus) DisplayErrorMessage(g_Locale->getText(LOCALE_SERVICEMENU_RESTART_REFUSED_RECORDING)); else { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RESTART_HINT)); - hintBox->paint(); + CHint * hint = new CHint(LOCALE_SERVICEMENU_RESTART_HINT); + hint->paint(); saveSetup(NEUTRINO_SETTINGS_FILE); @@ -4063,7 +4063,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) delete g_fontRenderer; delete g_dynFontRenderer; - delete hintBox; + delete hint; stop_daemons(true); stop_video(); @@ -4104,7 +4104,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) parent->hide(); std::string text = "Easy menu switched " + string(g_settings.easymenu?"OFF":"ON") + string(", when restart box.\nRestart now?"); - if (ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 0) == CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO, 0) == CMsgBox::mbrYes) { g_settings.easymenu = (g_settings.easymenu == 0) ? 1 : 0; INFO("change easymenu to %d\n", g_settings.easymenu); g_RCInput->postMsg(NeutrinoMessages::REBOOT, 0); diff --git a/src/neutrino_menue.h b/src/neutrino_menue.h index 809466545..a1e37f4d9 100644 --- a/src/neutrino_menue.h +++ b/src/neutrino_menue.h @@ -186,6 +186,7 @@ enum MN_WIDGET_ID MN_WIDGET_ID_TESTMENU, MN_WIDGET_ID_TESTMENU_HARDWARE, MN_WIDGET_ID_TESTMENU_COMPONENTS, + MN_WIDGET_ID_TESTMENU_HINT_MSG_TESTS, //network services MN_WIDGET_ID_NETWORKSETUP_SERVICES, diff --git a/src/system/locals.h b/src/system/locals.h index f66030446..a12ed3ced 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -807,6 +807,7 @@ typedef enum LOCALE_HDD_UMOUNT, LOCALE_HDD_UMOUNT_WARN, LOCALE_HDD_UMOUNTED, + LOCALE_HELP_BOX_TITLE, LOCALE_IMAGEINFO_API, LOCALE_IMAGEINFO_CREATOR, LOCALE_IMAGEINFO_DATE, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 2439efe55..85e4049a1 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -807,6 +807,7 @@ const char * locale_real_names[] = "hdd_umount", "hdd_umount_warn", "hdd_umounted", + "help_box_title", "imageinfo.api", "imageinfo.creator", "imageinfo.date", diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index b27faff65..08d3af362 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -59,7 +59,7 @@ #include // obsolete #include -#include +#include #include #include @@ -518,8 +518,8 @@ int CDataResetNotifier::exec(CMenuTarget* /*parent*/, const std::string& actionK /* no need to confirm if we only remove deleted channels */ if (!delete_removed) { - int result = ShowMsg(msg, g_Locale->getText(LOCALE_RESET_CONFIRM), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); - if (result != CMessageBox::mbrYes) + int result = ShowMsg(msg, g_Locale->getText(LOCALE_RESET_CONFIRM), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo); + if (result != CMsgBox::mbrYes) return true; }