diff --git a/configure.ac b/configure.ac index 5e526d360..56a829062 100644 --- a/configure.ac +++ b/configure.ac @@ -208,6 +208,7 @@ data/iso-codes/Makefile data/lcd/Makefile data/lcd/icons/Makefile data/lcd/clock/Makefile +data/license/Makefile data/locale/Makefile data/scripts/Makefile data/themes/Makefile diff --git a/data/Makefile.am b/data/Makefile.am index 40fb1f63b..062019037 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = fonts icons inetradio iso-codes locale scripts themes +SUBDIRS = fonts icons inetradio iso-codes license locale scripts themes if BOXTYPE_TRIPLE SUBDIRS += lcd diff --git a/data/license/Makefile.am b/data/license/Makefile.am new file mode 100644 index 000000000..d8d198554 --- /dev/null +++ b/data/license/Makefile.am @@ -0,0 +1,5 @@ +installdir = $(DATADIR)/neutrino/license + +install_DATA = \ + deutsch.license \ + english.license diff --git a/data/license/deutsch.license b/data/license/deutsch.license new file mode 100644 index 000000000..a1ae108d3 --- /dev/null +++ b/data/license/deutsch.license @@ -0,0 +1,5 @@ +Dieses Programm ist freie Software. Sie können es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation veröffentlicht, weitergeben und/oder modifizieren, entweder gemäß Version 2 der Lizenz oder (nach Ihrer Option) jeder späteren Version. + +Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. + +Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software Foundation, Inc, 51 Franklin St, Fifth Floor, Boston, MA 02110, USA. diff --git a/data/license/english.license b/data/license/english.license new file mode 100644 index 000000000..1388ffb16 --- /dev/null +++ b/data/license/english.license @@ -0,0 +1,5 @@ +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. + +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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 8dd7b7a42..597c20241 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -319,6 +319,8 @@ eventfinder.search_within_epg Suche innerhalb EPG-Daten eventfinder.search_within_list Suche innerhalb Text eventfinder.searching Suche... eventfinder.start_search Suche starten +eventlist.additional Zusatzinformationen +eventlist.name Eventliste eventlistbar.channelswitch Umschalten eventlistbar.eventsort Sortieren eventlistbar.recordevent Aufnehmen @@ -530,6 +532,7 @@ fontsize.epg_info1 EPG Info 1 fontsize.epg_info2 EPG Info 2 fontsize.epg_title EPG Titel fontsize.eventlist_datetime Datum/Zeit +fontsize.eventlist_event Event Info fontsize.eventlist_itemlarge Groß fontsize.eventlist_itemsmall Klein fontsize.eventlist_title Titel @@ -578,6 +581,7 @@ imageinfo.forum Forum: imageinfo.head Image Info: imageinfo.homepage Homepage: imageinfo.image Image: +imageinfo.kernel Kernel: imageinfo.license Lizenz: imageinfo.version Version: inetradio.name Internetradio @@ -765,7 +769,9 @@ menu.hint_epg_old_events Veraltete EPG-Daten werden nach dieser Zeit (in Stunden menu.hint_epg_save Speichert die EPG-Daten auf einem externen Datenträger und läd es von dort nach einen Neustart menu.hint_epg_save_standby Speichert die EPG-Daten auch im Standby-Modus menu.hint_event_textcolor Ändern Sie die Farbe für farbige Events in der Kanalliste und der Infobar +menu.hint_eventlist_additional Definiert, ob zusätzliche Informationen im Hauptfenster angezeigt werden sollen menu.hint_eventlist_fonts Ändern Sie die Schriftgröße in der Event-Liste +menu.hint_eventlist_setup Wählen Sie die Anzeigeoptionen für die Event-Liste menu.hint_extended Energiespar-, EPG-Speicher- und Lade-Optionen, HDMI-CEC, Startkanal und mehr menu.hint_factory Zurücksetzen der Box auf Werkseinstellungen.\nDie Box wird danach neu gestartet menu.hint_fade Bei aktivierter Funktion werden die Menüfenster 'weich' ein- bzw. ausgeblendet @@ -1139,6 +1145,13 @@ miscsettings.infobar_disp_5 Logo/Signalbalken miscsettings.infobar_disp_6 Logo+Kanalnummer/Signalbalken miscsettings.infobar_disp_log Logo miscsettings.infobar_logo_hdd_dir Logo-Verz. +miscsettings.infobar_sat_display Kabel-/Satellitenanbieter +miscsettings.infobar_show Info bei EPG Änderungen +miscsettings.infobar_show_dd_available DD-Verfügbarkeit anzeigen +miscsettings.infobar_show_res Auflösung anzeigen +miscsettings.infobar_show_res_simple einfach +miscsettings.infobar_show_sysfs_hdd Füllstandanzeige (sysFS & hdd) +miscsettings.infobar_show_tuner Aktiven Tuner anzeigen miscsettings.progressbar Fortschrittsbalken miscsettings.progressbar_color Farbe miscsettings.progressbar_design Design @@ -1151,13 +1164,6 @@ miscsettings.progressbar_infobar_position_0 Standard miscsettings.progressbar_infobar_position_1 unterhalb Kanalname miscsettings.progressbar_infobar_position_2 unterhalb Kanalname (schmal) miscsettings.progressbar_infobar_position_3 zwischen EPG-Events (schmal) -miscsettings.infobar_sat_display Kabel-/Satellitenanbieter -miscsettings.infobar_show Info bei EPG Änderungen -miscsettings.infobar_show_dd_available DD-Verfügbarkeit anzeigen -miscsettings.infobar_show_res Auflösung anzeigen -miscsettings.infobar_show_res_simple einfach -miscsettings.infobar_show_sysfs_hdd Füllstandanzeige (sysFS & hdd) -miscsettings.infobar_show_tuner Aktiven Tuner anzeigen miscsettings.radiotext Radiotext miscsettings.shutdown_count Komplett ausschalten nach miscsettings.shutdown_count_hint1 Zeit (in Minuten), nach der vom Standby in diff --git a/data/locale/english.locale b/data/locale/english.locale index 63d8d2571..aeb9989c6 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -321,6 +321,8 @@ eventfinder.search_within_epg Search within eventfinder.search_within_list Search within eventfinder.searching Search for keyword in EPG... eventfinder.start_search Start Search +eventlist.additional Additional informations +eventlist.name Eventlist eventlistbar.channelswitch schedule eventlistbar.eventsort sorting eventlistbar.recordevent record @@ -535,6 +537,7 @@ fontsize.epg_info1 EPG Info 1 fontsize.epg_info2 EPG Info 2 fontsize.epg_title EPG Title fontsize.eventlist_datetime Date / Time +fontsize.eventlist_event Event Info fontsize.eventlist_itemlarge Large fontsize.eventlist_itemsmall Small fontsize.eventlist_title Title @@ -583,6 +586,7 @@ imageinfo.forum Forum: imageinfo.head Image info: imageinfo.homepage Home page: imageinfo.image Image: +imageinfo.kernel Kernel: imageinfo.license License: imageinfo.version Version: inetradio.name Internetradio @@ -770,7 +774,9 @@ menu.hint_epg_old_events Hours after event end time to consider\nevent old and r menu.hint_epg_save Save cached EPG to harddisk or usb flash\nand load it after boot menu.hint_epg_save_standby Save EPG on soft standby mode menu.hint_event_textcolor Change event color for colored-event options\nin channel list and infobar +menu.hint_eventlist_additional Show additional informations\nin main box menu.hint_eventlist_fonts Change event list font sizes +menu.hint_eventlist_setup Configure event list GUI options menu.hint_extended Power saving, EPG save/load options\nHDMI-CEC, Start channel, zap options menu.hint_factory Reset box to factory state\nBox will reboot after reset menu.hint_fade Fade GUI windows @@ -1154,6 +1160,13 @@ miscsettings.infobar_disp_5 Logo+signal miscsettings.infobar_disp_6 Logo+channel number+signal miscsettings.infobar_disp_log Logo miscsettings.infobar_logo_hdd_dir Logo dir +miscsettings.infobar_sat_display Satellite display on infobar +miscsettings.infobar_show show Info on EPG change +miscsettings.infobar_show_dd_available show DD availability +miscsettings.infobar_show_res show resolution on infobar +miscsettings.infobar_show_res_simple simple +miscsettings.infobar_show_sysfs_hdd Fill level (sysFS & hdd) +miscsettings.infobar_show_tuner Display active tuner miscsettings.progressbar Progressbar miscsettings.progressbar_color Color miscsettings.progressbar_design Design @@ -1166,13 +1179,6 @@ miscsettings.progressbar_infobar_position_0 standard miscsettings.progressbar_infobar_position_1 below channel name miscsettings.progressbar_infobar_position_2 small below channel name miscsettings.progressbar_infobar_position_3 narrow between EPG-Events -miscsettings.infobar_sat_display Satellite display on infobar -miscsettings.infobar_show show Info on EPG change -miscsettings.infobar_show_dd_available show DD availability -miscsettings.infobar_show_res show resolution on infobar -miscsettings.infobar_show_res_simple simple -miscsettings.infobar_show_sysfs_hdd Fill level (sysFS & hdd) -miscsettings.infobar_show_tuner Display active tuner miscsettings.radiotext Radiotext miscsettings.shutdown_count In standby, switch off after miscsettings.shutdown_count_hint1 time (in minutes) to switch from standby diff --git a/src/Makefile.am b/src/Makefile.am index 2a5edfda2..91444eafc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,7 +52,6 @@ endif neutrino_LDADD = \ daemonc/libneutrino_daemonc.a \ gui/bedit/libneutrino_gui_bedit.a \ - gui/components/libneutrino_gui_components.a \ gui/libtimerlist.a \ gui/libneutrino_gui.a \ gui/widget/libneutrino_gui_widget.a \ @@ -61,6 +60,7 @@ neutrino_LDADD = \ system/libneutrino_system.a \ gui/movieinfo.o \ gui/libneutrino_gui2.a \ + gui/components/libneutrino_gui_components.a \ eitd/libsectionsd.a \ driver/libneutrino_driver.a \ driver/audiodec/libneutrino_driver_audiodec.a \ diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index 662e3968a..f0d0220db 100644 --- a/src/driver/fontrenderer.cpp +++ b/src/driver/fontrenderer.cpp @@ -432,8 +432,20 @@ void Font::RenderString(int x, int y, const int width, const char *text, const u static fb_pixel_t oldbgcolor = 0, oldfgcolor = 0; static fb_pixel_t colors[256]={0}; - fb_pixel_t bgcolor = frameBuffer->realcolor[color]; - fb_pixel_t fgcolor = frameBuffer->realcolor[(((((int)color) + 2) | 7) - 2)]; + // fb_pixel_t bgcolor = frameBuffer->realcolor[color]; + uint8_t fgindex = color; /* index of font color in the palette */ + if (color > COL_BLACK0 && color < 254) /* bigger than 254 would result in > 255 */ + fgindex = ((((int)color) + 2) | 7) - 2; /* no idea what this does exactly... */ + fb_pixel_t fgcolor = frameBuffer->realcolor[fgindex]; +#ifndef USE_NEVIS_GXA + /* the GXA seems to do it's job asynchonously, so we need to wait until + it's ready, otherwise the font will sometimes "be overwritten" with + background color or bgcolor will be wrong */ + frameBuffer->waitForIdle(); +#endif + /* fetch bgcolor from framebuffer, using lower left edge of the font... */ + fb_pixel_t bgcolor = *(frameBuffer->getFrameBufferPointer() + x + + y * frameBuffer->getStride() / sizeof(fb_pixel_t)); if((oldbgcolor != bgcolor) || (oldfgcolor != fgcolor)) { @@ -478,12 +490,6 @@ void Font::RenderString(int x, int y, const int width, const char *text, const u spread_by = 1; } - /* the GXA seems to do it's job asynchonously, so we need to wait until - it's ready, otherwise the font will sometimes "be overwritten" with - background color */ -#ifndef USE_NEVIS_GXA - frameBuffer->waitForIdle(); -#endif for (; *text; text++) { FTC_SBit glyph; diff --git a/src/driver/pictureviewer/gif.cpp b/src/driver/pictureviewer/gif.cpp index a37238772..4b0a3b23e 100644 --- a/src/driver/pictureviewer/gif.cpp +++ b/src/driver/pictureviewer/gif.cpp @@ -59,8 +59,13 @@ int fh_gif_load(const char *name,unsigned char **buffer,int* /*xp*/,int* /*yp*/) GifRecordType rt; ColorMapObject *cmap; int cmaps; +#if GIFLIB_MAJOR >= 5 + int error; + gft=DGifOpenFileName(name, &error); +#else gft=DGifOpenFileName(name); +#endif if(gft==NULL) gflush; do { @@ -128,8 +133,13 @@ int fh_gif_getsize(const char *name,int *x,int *y, int /*wanted_width*/, int /*w GifByteType *extension; int extcode; GifRecordType rt; +#if GIFLIB_MAJOR >= 5 + int error; + gft=DGifOpenFileName(name, &error); +#else gft=DGifOpenFileName(name); +#endif if(gft==NULL) gflush; do { diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp index d2b3e65fa..052c58fa1 100644 --- a/src/driver/volume.cpp +++ b/src/driver/volume.cpp @@ -40,7 +40,7 @@ #include #if HAVE_COOL_HARDWARE -#include +#include #endif extern CRemoteControl * g_RemoteControl; @@ -106,12 +106,14 @@ void CVolume::Init() vbar_w = spacer + icon_w + spacer + progress_w + spacer; if (paintDigits) { digit_w = g_Font[VolumeFont]->getRenderWidth("100"); - progress_h = std::max(icon_h, digit_h) - 2*pB; + progress_h = std::max(icon_h, digit_h); vbar_w += digit_w; } if (volscale) delete volscale; - volscale = new CProgressBar(true, progress_w, progress_h, 50, 100, 80, true); + volscale = new CProgressBar(progress_x, progress_y, progress_w, progress_h, colFrame, colBar, colShadow, COL_MENUCONTENT_PLUS_3, COL_MENUCONTENT_PLUS_1, true); + volscale->setInvert(); + volscale->setFrameThickness(2); // mute icon mute_icon_dx = 0; @@ -250,8 +252,6 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa frameBuffer->paintBoxRel(x+ShadowOffset , y+ShadowOffset , (paintDigits) ? vbar_w - vbar_h : vbar_w + 1, vbar_h, colShadow, ROUNDED, (paintDigits) ? CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT : CORNER_ALL); // volumebar frameBuffer->paintBoxRel(x , y , (paintDigits) ? vbar_w - vbar_h : vbar_w + 1, vbar_h, colBar, ROUNDED, (paintDigits) ? CORNER_TOP_LEFT | CORNER_BOTTOM_LEFT : CORNER_ALL); - // frame for progress - frameBuffer->paintBoxRel(progress_x-pB, progress_y-pB, progress_w+pB*2, progress_h+pB*2, colFrame); // volume icon frameBuffer->paintIcon(NEUTRINO_ICON_VOLUME, icon_x, icon_y, 0, colBar); @@ -343,8 +343,6 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa void CVolume::refreshVolumebar(int current_volume) { - // progressbar - volscale->paintProgressBar2(progress_x, progress_y, current_volume); if (paintDigits) { // shadow for erase digits if (paintShadow) @@ -356,6 +354,9 @@ void CVolume::refreshVolumebar(int current_volume) snprintf(buff, 4, "%3d", current_volume); g_Font[VolumeFont]->RenderString(digit_x, digit_y, digit_w, buff, colContent); } + // progressbar + volscale->setValues(current_volume, 100); + volscale->paint(); } bool CVolume::changeNotify(const neutrino_locale_t OptionName, void * data) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index b3ece39e2..3597915ff 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1798,13 +1798,13 @@ void CAudioPlayerGui::paintInfo() if (!m_show_playlist) { // no playlist -> smaller Info-Box - m_frameBuffer->paintBoxFrame(m_x, m_y, m_width, m_title_height - 10 - m_fheight,2, COL_MENUCONTENT_PLUS_6, c_rad_mid); - m_frameBuffer->paintBoxRel(m_x + 2, m_y + 2 , m_width - 4, m_title_height - 14 - m_fheight, COL_MENUCONTENTSELECTED_PLUS_0, c_rad_mid); + m_frameBuffer->paintBoxRel(m_x + 1, m_y + 1 , m_width - 2, m_title_height - 12 - m_fheight, COL_MENUCONTENTSELECTED_PLUS_0, c_rad_mid); + m_frameBuffer->paintBoxFrame(m_x, m_y, m_width, m_title_height - 10 - m_fheight, 2, COL_MENUCONTENT_PLUS_6, c_rad_mid); } else { - m_frameBuffer->paintBoxFrame(m_x, m_y, m_width, m_title_height - 10,2, COL_MENUCONTENT_PLUS_6, c_rad_mid); - m_frameBuffer->paintBoxRel(m_x + 2, m_y + 2 , m_width - 4, m_title_height - 14, COL_MENUCONTENTSELECTED_PLUS_0, c_rad_mid); + m_frameBuffer->paintBoxRel(m_x + 1, m_y + 1 , m_width - 2, m_title_height - 12, COL_MENUCONTENTSELECTED_PLUS_0, c_rad_mid); + m_frameBuffer->paintBoxFrame(m_x, m_y, m_width, m_title_height - 10, 2, COL_MENUCONTENT_PLUS_6, c_rad_mid); } // first line (Track number) @@ -1927,9 +1927,10 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos) // paint id3 infobox if (ibox == NULL) - ibox = new CComponentsInfoBox(m_x, ypos2, m_width, m_info_height, false); + ibox = new CComponentsInfoBox(m_x, ypos2, m_width, m_info_height); + ibox->setCornerRadius(RADIUS_LARGE); ibox->setYPos(ypos2); - ibox->paint(false, true); + ibox->paint(false); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + 10, ypos2 + 2 + 1*m_fheight, m_width- 80, m_playlist[m_selected].MetaData.title, COL_MENUCONTENTDARK, 0, true); // UTF-8 diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 99aa51b1b..deee867bb 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -106,7 +106,7 @@ void CBEChannelWidget::paintItem(int pos) bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; if(current < Channels->size()) { - paintItem2DetailsLine (pos, current); + initItem2DetailsLine (pos, current); paintDetails(current); } @@ -184,58 +184,83 @@ void CBEChannelWidget::paintFoot() ::paintButtons(x, y + (height-footerHeight), width, 4, CBEChannelWidgetButtons, width, footerHeight); } -void CBEChannelWidget::paintDetails(int index) +std::string CBEChannelWidget::getInfoText(int index) { + std::string res = ""; + std::string satname = CServiceManager::getInstance()->GetSatelliteName((*Channels)[index]->getSatellitePosition()); transponder t; CServiceManager::getInstance()->GetTransponder((*Channels)[index]->getTransponderId(), t); std::string desc = t.description(); if((*Channels)[index]->pname) desc = desc + " (" + std::string((*Channels)[index]->pname) + ")"; - else + else desc = desc + " (" + satname + ")"; - - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ fheight+INFO_BOX_Y_OFFSET, width - 30, satname.c_str(), COL_MENUCONTENTDARK, 0, true); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2*fheight+INFO_BOX_Y_OFFSET, width - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); + + res = satname + "\n" + desc; + + return res; } -void CBEChannelWidget::paintItem2DetailsLine (int pos, int /*ch_index*/) +void CBEChannelWidget::paintDetails(int index) +{ + //details line + dline->paint(); + + std::string str = getInfoText(index); + + //info box + ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]); + ibox->paint(CC_SAVE_SCREEN_YES); +} + +void CBEChannelWidget::initItem2DetailsLine (int pos, int /*ch_index*/) { int xpos = x - ConnectLineBox_Width; int ypos1 = y + theight+0 + pos*fheight; int ypos2 = y + height + INFO_BOX_Y_OFFSET; int ypos1a = ypos1 + (fheight/2)-2; int ypos2a = ypos2 + (info_height/2)-2; - - clearItem2DetailsLine(); - - // paint Line if detail info (and not valid list pos) + + if (dline) + dline->kill(); //kill details line + + // init Line if detail info (and not valid list pos) if (pos >= 0) { if (dline == NULL) dline = new CComponentsDetailLine(xpos, ypos1a, ypos2a, fheight/2+1, info_height-RADIUS_LARGE*2); dline->setYPos(ypos1a); - dline->paint(); - + //infobox if (ibox == NULL) - ibox = new CComponentsInfoBox(x, ypos2, width, info_height, false); + ibox = new CComponentsInfoBox(); + + if (ibox->isPainted()) + ibox->hide(CC_SAVE_SCREEN_NO); + + ibox->setDimensionsAll(x, ypos2, width, info_height); + ibox->setFrameThickness(2); +#if 0 ibox->paint(false,true); +#endif + ibox->setCornerRadius(RADIUS_LARGE); + ibox->setShadowOnOff(CC_SHADOW_OFF); } } void CBEChannelWidget::clearItem2DetailsLine() { - if (dline != NULL) - dline->hide(); - if (ibox != NULL) - ibox->hide(); + if (dline) + dline->kill(); //kill details line + if (ibox) + ibox->kill(); //kill info box } void CBEChannelWidget::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, width,height+footerHeight+info_height); - clearItem2DetailsLine (); + frameBuffer->paintBackgroundBoxRel(x,y, width,height+footerHeight); + clearItem2DetailsLine (); } void CBEChannelWidget::updateSelection(unsigned int newpos) diff --git a/src/gui/bedit/bouqueteditor_channels.h b/src/gui/bedit/bouqueteditor_channels.h index d3132af0d..90d4d03d4 100644 --- a/src/gui/bedit/bouqueteditor_channels.h +++ b/src/gui/bedit/bouqueteditor_channels.h @@ -84,7 +84,7 @@ class CBEChannelWidget : public CMenuTarget void paintItem(int pos); void paintDetails(int index); - void paintItem2DetailsLine (int pos, int ch_index); + void initItem2DetailsLine (int pos, int ch_index); void clearItem2DetailsLine (); void paint(); void paintHead(); @@ -99,6 +99,7 @@ class CBEChannelWidget : public CMenuTarget void cancelMoveChannel(); void internalMoveChannel( unsigned int fromPosition, unsigned int toPosition); + std::string getInfoText(int index); public: CBEChannelWidget( const std::string & Caption, unsigned int Bouquet); ~CBEChannelWidget(); diff --git a/src/gui/bedit/bouqueteditor_chanselect.cpp b/src/gui/bedit/bouqueteditor_chanselect.cpp index befe9ae41..48f5c22bd 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -72,18 +72,12 @@ CBEChannelSelectWidget::CBEChannelSelectWidget(const std::string & Caption, unsi liststart = 0; bouquetChannels = NULL; dline = NULL; - ibox = NULL; + ibox = new CComponentsInfoBox(); } CBEChannelSelectWidget::~CBEChannelSelectWidget() { - // clear details line - if (dline != NULL) - dline->hide(); delete dline; - // clear infobox - if (ibox != NULL) - ibox->hide(); delete ibox; } @@ -119,7 +113,7 @@ void CBEChannelSelectWidget::paintItem(uint32_t itemNr, int paintNr, bool pselec bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; if(itemNr < getItemCount()) { - paintItem2DetailsLine (paintNr, itemNr); + initItem2DetailsLine (paintNr, itemNr); paintDetails(itemNr); } @@ -210,8 +204,10 @@ void CBEChannelSelectWidget::paintFoot() #endif } -void CBEChannelSelectWidget::paintDetails(int index) +std::string CBEChannelSelectWidget::getInfoText(int index) { + std::string res = ""; + std::string satname = CServiceManager::getInstance()->GetSatelliteName(Channels[index]->getSatellitePosition()); transponder t; CServiceManager::getInstance()->GetTransponder(Channels[index]->getTransponderId(), t); @@ -220,12 +216,25 @@ void CBEChannelSelectWidget::paintDetails(int index) desc = desc + " (" + std::string(Channels[index]->pname) + ")"; else desc = desc + " (" + satname + ")"; - - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ fheight+INFO_BOX_Y_OFFSET, width - 30, satname.c_str(), COL_MENUCONTENTDARK, 0, true); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2*fheight+INFO_BOX_Y_OFFSET, width - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); + + res = satname + "\n" + desc; + + return res; } -void CBEChannelSelectWidget::paintItem2DetailsLine (int pos, int /*ch_index*/) +void CBEChannelSelectWidget::paintDetails(int index) +{ + //details line + dline->paint(); + + std::string str = getInfoText(index); + + //info box + ibox->setText(str, CTextBox::AUTO_WIDTH | CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]); + ibox->paint(false); +} + +void CBEChannelSelectWidget::initItem2DetailsLine (int pos, int /*ch_index*/) { int xpos = x - ConnectLineBox_Width; int ypos1 = y + theight+0 + pos*fheight; @@ -233,26 +242,23 @@ void CBEChannelSelectWidget::paintItem2DetailsLine (int pos, int /*ch_index*/) int ypos1a = ypos1 + (fheight/2)-2; int ypos2a = ypos2 + (info_height/2)-2; - // clear details line - if (dline != NULL) - dline->hide(); + if (dline) + dline->kill(); //kill details line - // clear infobox - if (ibox != NULL) - ibox->hide(); - - // paint Line if detail info (and not valid list pos) + // init Line if detail info (and not valid list pos) if (pos >= 0) { if (dline == NULL) dline = new CComponentsDetailLine(xpos, ypos1a, ypos2a, fheight/2+1, info_height-RADIUS_LARGE*2); dline->setYPos(ypos1a); - dline->paint(false); //infobox - if (ibox == NULL) - ibox = new CComponentsInfoBox(x, ypos2, width, info_height, false); - ibox->paint(false,true); + if (ibox){ + ibox->setDimensionsAll(x, ypos2, width, info_height); + ibox->setFrameThickness(2); + ibox->setCornerRadius(RADIUS_LARGE); + ibox->setShadowOnOff(CC_SHADOW_OFF); + } } } diff --git a/src/gui/bedit/bouqueteditor_chanselect.h b/src/gui/bedit/bouqueteditor_chanselect.h index 58ad2ebf3..729c3d7af 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.h +++ b/src/gui/bedit/bouqueteditor_chanselect.h @@ -54,13 +54,14 @@ class CBEChannelSelectWidget : public CListBox uint getItemCount(); void paintItem(uint32_t itemNr, int paintNr, bool selected); void paintDetails(int index); - void paintItem2DetailsLine (int pos, int ch_index); + void initItem2DetailsLine (int pos, int ch_index); void paintFoot(); void onOkKeyPressed(); int footerHeight; int info_height; - + + std::string getInfoText(int index); public: ZapitChannelList Channels; ZapitChannelList * bouquetChannels; diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 7f08a50ea..df98a21b9 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include @@ -112,8 +112,11 @@ CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vl footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; //initial height value for buttonbar theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); + fdescrheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight(); + previous_channellist_additional = -1; eventFont = SNeutrinoSettings::FONT_TYPE_CHANNELLIST_EVENT; + dline = NULL; //printf("************ NEW LIST %s : %x\n", name.c_str(), (int) this);fflush(stdout); } @@ -121,6 +124,7 @@ CChannelList::~CChannelList() { //printf("************ DELETE LIST %s : %x\n", name.c_str(), this);fflush(stdout); chanlist.clear(); + delete dline; } void CChannelList::ClearList(void) @@ -488,6 +492,8 @@ void CChannelList::calcSize() // recalculate theight, fheight and footerHeight for a possilble change of fontsize factor theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); + fdescrheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight(); + if (fheight == 0) fheight = 1; /* avoid div-by-zero crash on invalid font */ footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; @@ -500,7 +506,7 @@ void CChannelList::calcSize() width = full_width; // calculate height (the infobox below mainbox is handled outside height) - info_height = 2*fheight + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10; + info_height = 2*fheight + fdescrheight + 10; height = frameBuffer->getScreenHeightRel() - info_height; // calculate x position @@ -529,6 +535,9 @@ void CChannelList::calcSize() // calculate max entrys in mainbox listmaxshow = (height - theight - footerHeight) / fheight; + // calculate max entrys in mainbox + listmaxshow = (height - theight - footerHeight) / fheight; + // recalculate height to avoid spaces between last entry in mainbox and footer height = theight + listmaxshow*fheight + footerHeight; @@ -634,9 +643,9 @@ int CChannelList::show() } else loop=false; } - else if( msg == CRCInput::RC_record) { //start direct recording from channellist + else if( msg == CRCInput::RC_record) { //start direct recording from channellist #if 0 - if(!CRecordManager::getInstance()->RecordingStatus(chanlist[selected]->channel_id)) + if(!CRecordManager::getInstance()->RecordingStatus(chanlist[selected]->channel_id)) { printf("[neutrino channellist] start direct recording...\n"); hide(); @@ -648,10 +657,10 @@ int CChannelList::show() loop=false; } else - DisplayInfoMessage(g_Locale->getText(LOCALE_CHANNELLIST_RECORDING_NOT_POSSIBLE)); // UTF-8 + DisplayInfoMessage(g_Locale->getText(LOCALE_CHANNELLIST_RECORDING_NOT_POSSIBLE)); // UTF-8 } - - } + + } #endif if((g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) && SameTP()) { printf("[neutrino channellist] start direct recording...\n"); @@ -661,7 +670,7 @@ int CChannelList::show() paint(); } else loop=false; - + } } else if( msg == CRCInput::RC_stop ) { //stopp recording @@ -754,6 +763,8 @@ int CChannelList::show() } else if (msg == (neutrino_msg_t)g_settings.key_bouquet_up || msg == (neutrino_msg_t)g_settings.key_bouquet_down) { + if (dline) + dline->kill(); //kill details line on change to next page if (!bouquetList->Bouquets.empty()) { bool found = true; int dir = msg == (neutrino_msg_t)g_settings.key_bouquet_up ? 1 : -1; @@ -810,7 +821,7 @@ int CChannelList::show() zapOnExit = true; loop = false; } - else if(g_settings.sms_channel) { + else if(g_settings.sms_channel) { unsigned char smsKey = 0; SMSKeyInput smsInput; smsInput.setTimeout(CHANNEL_SMSKEY_TIMEOUT); @@ -1448,7 +1459,7 @@ CZapitChannel* CChannelList::getPrevNextChannel(int key, unsigned int &sl) bactive--; bouquetList->activateBouquet(bactive, false); cactive = bouquetList->Bouquets[bactive]->channelList->getSize() - 1; - } else + } else --cactive; } else if ((key == g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) { @@ -1632,12 +1643,12 @@ void CChannelList::paintDetails(int index) } } #endif - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ xstart, y+ height+ 5+ 2* fheight, full_width- xstart- 30- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ xstart, y+ height+ 5+ fdescrheight+ fheight, full_width- xstart- 30- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); } g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ fheight, full_width - 30 - seit_len, text1, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- seit_len, y+ height+ 5+ fheight, seit_len, cSeit, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- noch_len, y+ height+ 5+ 2* fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- noch_len, y+ height+ 5+ fdescrheight+ fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 } if(g_settings.channellist_foot == 0) { transponder t; @@ -1649,7 +1660,7 @@ void CChannelList::paintDetails(int index) else desc = desc + " (" + CServiceManager::getInstance()->GetSatelliteName(chanlist[index]->getSatellitePosition()) + ")"; - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, full_width - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2*fheight +fdescrheight, full_width - 30, desc.c_str(), COL_MENUCONTENTDARK, 0, true); } else if( !displayNext && g_settings.channellist_foot == 1) { // next Event char buf[128] = {0}; @@ -1662,8 +1673,8 @@ void CChannelList::paintDetails(int index) snprintf(buf, sizeof(buf), "%s", CurrentNext.next_name.c_str()); int from_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cFrom, true); // UTF-8 - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 3*fheight, full_width - 30 - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST :COL_MENUCONTENTDARK, 0, true); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- from_len, y+ height+ 5+ 3*fheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, y+ height+ 5+ 2*fheight+ fdescrheight, full_width - 30 - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST :COL_MENUCONTENTDARK, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- from_len, y+ height+ 5+ 2*fheight+ fdescrheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTDARK, 0, true); // UTF-8 } } if ((g_settings.channellist_additional) && (p_event != NULL)) @@ -1683,17 +1694,24 @@ void CChannelList::paintItem2DetailsLine (int pos) int ypos1a = ypos1 + (fheight/2)-2; int ypos2a = ypos2 + (info_height/2)-2; fb_pixel_t col1 = COL_MENUCONTENT_PLUS_6; - // Clear - frameBuffer->paintBackgroundBoxRel(xpos,y, ConnectLineBox_Width, height+info_height + 1); + + if (dline){ + dline->kill(); //kill details line + delete dline; + dline = NULL; + } +// // Clear +// frameBuffer->paintBackgroundBoxRel(xpos,y, ConnectLineBox_Width, height+info_height + 1); // paint Line if detail info (and not valid list pos) if (pos >= 0) { //pos >= 0 && chanlist[ch_index]->currentEvent.description != "") { if(1) // FIXME why -> ? (!g_settings.channellist_extended) { //details line - CComponentsDetailLine details_line(xpos, ypos1a, ypos2a, fheight/2+1, info_height-RADIUS_LARGE*2); - details_line.paint(); - + if (dline == NULL) + dline = new CComponentsDetailLine(xpos, ypos1a, ypos2a, fheight/2+1, info_height-RADIUS_LARGE*2); + dline->paint(); + //info box frame frameBuffer->paintBoxFrame(x, ypos2, full_width, info_height, 2, col1, RADIUS_LARGE); } @@ -1913,7 +1931,7 @@ void CChannelList::paintItem(int pos) //record check rec_mode = CRecordManager::getInstance()->GetRecordMode(chanlist[curr]->channel_id); - + //set recording icon std::string rec_icon; if (rec_mode & CRecordManager::RECMODE_REC) @@ -1928,28 +1946,27 @@ void CChannelList::paintItem(int pos) ChannelList_Rec += 8; } #endif - //calculating icons int icon_x = (x+width-15-2) - RADIUS_LARGE/2; int r_icon_w=0; int s_icon_h=0; int s_icon_w=0; frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &s_icon_w, &s_icon_h); r_icon_w = ChannelList_Rec; int r_icon_x = icon_x; - + //paint scramble icon if(chan->scrambled) if (frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, icon_x - s_icon_w, ypos, fheight))//ypos + (fheight - 16)/2); r_icon_x = r_icon_x - s_icon_w; - + //paint recording icon //if (rec_mode != CRecordManager::RECMODE_OFF) if (!rec_icon.empty()) frameBuffer->paintIcon(rec_icon, r_icon_x - r_icon_w, ypos, fheight);//ypos + (fheight - 16)/2); - + //paint buttons if (paintbuttons) paintButtonBar(iscurrent); - + int icon_space = r_icon_w+s_icon_w; //number @@ -1962,8 +1979,9 @@ void CChannelList::paintItem(int pos) else l = snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->getName().c_str()); - CProgressBar pb(false); /* never colored */ int pb_space = prg_offset - title_offset; + CProgressBar pb(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2); /* never colored */ + pb.setFrameThickness(2); int pb_max = pb_space - 4; if (!(p_event->description.empty())) { snprintf(nameAndDescription+l, sizeof(nameAndDescription)-l,g_settings.channellist_epgtext_align_right ? " ":" - "); @@ -1973,7 +1991,7 @@ void CChannelList::paintItem(int pos) int max_desc_len = width - numwidth - prg_offset - ch_name_len - 15 - 20; // 15 = scrollbar, 20 = spaces if (chan->scrambled || (g_settings.channellist_extended ||g_settings.channellist_epgtext_align_right)) max_desc_len -= icon_space; /* do we need space for the lock/rec icon? */ - + if (max_desc_len < 0) max_desc_len = 0; if ((int) ch_desc_len > max_desc_len) @@ -2004,15 +2022,12 @@ void CChannelList::paintItem(int pos) runningPercent = pb_max; // later on which can be fatal... } - int pb_activeCol , pb_passiveCol; - if (liststart + pos != selected) { - pb_activeCol = COL_MENUCONTENT_PLUS_3; - pb_passiveCol = COL_MENUCONTENT_PLUS_1; - } else { - pb_activeCol = COL_MENUCONTENTSELECTED_PLUS_2; - pb_passiveCol = COL_MENUCONTENTSELECTED_PLUS_0; - } - pb.paintProgressBar(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2, runningPercent, pb_max, pb_activeCol, pb_passiveCol, pb_activeCol); + if (liststart + pos != selected) + pb.setStatusColors(COL_MENUCONTENT_PLUS_3, COL_MENUCONTENT_PLUS_1); + else + pb.setStatusColors(COL_MENUCONTENTSELECTED_PLUS_2, COL_MENUCONTENTSELECTED_PLUS_0); + pb.setValues(runningPercent, pb_max); + pb.paint(); } } @@ -2028,15 +2043,13 @@ void CChannelList::paintItem(int pos) } else { if(g_settings.channellist_extended) { - int pbz_activeCol, pbz_passiveCol; - if (liststart + pos != selected) { - pbz_activeCol = COL_MENUCONTENT_PLUS_1; - pbz_passiveCol = COL_MENUCONTENT_PLUS_0; - } else { - pbz_activeCol = COL_MENUCONTENTSELECTED_PLUS_2; - pbz_passiveCol = COL_MENUCONTENTSELECTED_PLUS_0; - } - pb.paintProgressBar(x+5+numwidth + title_offset, ypos + fheight/4, pb_space + 2, fheight/2, 0, pb_max, pbz_activeCol, pbz_passiveCol, pbz_activeCol, 0, NULL, 0, NULL, true); + if (liststart + pos != selected) + pb.setStatusColors(COL_MENUCONTENT_PLUS_2, COL_MENUCONTENT_PLUS_1); + else + pb.setStatusColors(COL_MENUCONTENTSELECTED_PLUS_2, COL_MENUCONTENTSELECTED_PLUS_0); + pb.setValues(0, pb_max); + pb.setZeroLine(); + pb.paint(); } //name g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10+prg_offset, ypos+ fheight, width- numwidth- 40- 15-prg_offset, nameAndDescription, color, 0, true); // UTF-8 @@ -2260,7 +2273,7 @@ void CChannelList::paint_events(int index) } while ( dif > 0 ); } - if (e == evtlist.end()) + if (e == evtlist.end()) break; //Display the remaining events diff --git a/src/gui/channellist.h b/src/gui/channellist.h index 0b2b64f1b..cf694fa43 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -67,6 +68,7 @@ private: int new_zap_mode; int fheight; // Fonthoehe Channellist-Inhalt int theight; // Fonthoehe Channellist-Titel + int fdescrheight; int footerHeight; int eventFont; int ffheight; @@ -74,7 +76,8 @@ private: std::string name; ZapitChannelList chanlist; CZapProtection* zapProtection; - + CComponentsDetailLine *dline; + int full_width; int width; int height; diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index 243346a56..c650d933b 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -24,4 +24,17 @@ noinst_LIBRARIES = libneutrino_gui_components.a libneutrino_gui_components_a_SOURCES = \ - components.cpp + cc_base.cpp \ + cc_detailsline.cpp \ + cc_frm.cpp \ + cc_frm_header.cpp \ + cc_frm_icons.cpp \ + cc_frm_window.cpp \ + cc_item.cpp \ + cc_item_box.cpp \ + cc_item_infobox.cpp \ + cc_item_picture.cpp \ + cc_item_progressbar.cpp \ + cc_item_shapes.cpp \ + cc_item_text.cpp \ + cc_item_tvpic.cpp diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 522146dfc..472347923 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -2,23 +2,23 @@ Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 by Steffen Hehn 'McClean' - Classes for generic for GUI-related components. + Classes for generic GUI-related components. Copyright (C) 2012, 2013, Thilo Graf 'dbt' License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 - Library General Public License for more details. + General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ @@ -26,85 +26,308 @@ #ifndef __COMPONENTS__ #define __COMPONENTS__ -#include -#include -#include +#include "cc_types.h" +#include #include +#include +#include -//required typedefs -typedef struct comp_fbdata_t -{ - int x; - int y; - int dx; - int dy; - fb_pixel_t color; - int r; - void * data; - fb_pixel_t* pixbuf; - bool is_frame; - int frame_thickness; -} comp_fbdata_struct_t; +// #define DEBUG_CC class CComponents { + private: + bool allowPaint(const int& i); protected: - int x, y, height, width, sw; + int x, y, height, width, corner_type, shadow_w; + int corner_rad, fr_thickness, fr_thickness_sel; CFrameBuffer * frameBuffer; - std::vector v_screen_val; - - void paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg = true); - fb_pixel_t* saveScreen(int ax, int ay, int dx, int dy); - void clear(); + std::vector v_fbdata; + fb_pixel_t col_body, col_shadow, col_frame, col_frame_sel; + bool firstPaint, shadow, is_painted, paint_bg; + + void initVarBasic(); + void paintFbItems(bool do_save_bg = true); + virtual fb_pixel_t* getScreen(int ax, int ay, int dx, int dy); + comp_screen_data_t saved_screen; + void clearSavedScreen(); + virtual void clear(); public: - CComponents(const int x_pos = 0, const int y_pos = 0, const int h = 0, const int w = 0); + CComponents(); virtual~CComponents(); - virtual void setXPos(const int& xpos){x = xpos;}; - virtual void setYPos(const int& ypos){y = ypos;}; - virtual void setHeight(const int& h){height = h;}; - virtual void setWidth(const int& w){width = w;}; - virtual void restore(); + inline virtual void setXPos(const int& xpos){x = xpos;}; + inline virtual void setYPos(const int& ypos){y = ypos;}; + inline virtual void setHeight(const int& h){height = h;}; + inline virtual void setWidth(const int& w){width = w;}; + inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;}; + + inline virtual int getXPos(){return x;}; + inline virtual int getYPos(){return y;}; + inline virtual int getHeight(){return height;}; + inline virtual int getWidth(){return width;}; + inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;}; + +/// set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h" + inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;}; + inline virtual void setColorBody(fb_pixel_t color){col_body = color;}; + inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;}; + inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;}; +/// get colors + inline virtual fb_pixel_t getColorFrame(){return col_frame;}; + inline virtual fb_pixel_t getColorBody(){return col_body;}; + inline virtual fb_pixel_t getColorShadow(){return col_shadow;}; + +/// set corner types: Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h). + inline virtual void setCornerType(const int& type){corner_type = type;}; + inline virtual void setCornerRadius(const int& radius){corner_rad = radius;}; +/// get corner types: + inline virtual int getCornerType(){return corner_type;}; + inline virtual int getCornerRadius(){return corner_rad;}; + + inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;}; + inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;}; + + virtual void hide(); + virtual bool isPainted(){return is_painted;} + virtual void doPaintBg(bool do_paint){paint_bg = do_paint;}; }; +class CComponentsItem : public CComponents +{ + protected: + int cc_item_type; + int cc_item_index; + bool cc_item_enabled, cc_item_selected; + + ///Pointer to the form object in which this item is embedded. + ///Is typically the type CComponentsForm or derived classes, default intialized with NULL + CComponents *cc_parent; + + ///contains real position and dimensions on screen, + int cc_item_xr, cc_item_yr; + + void hideCCItem(bool no_restore = false); + void paintInit(bool do_save_bg); + void initVarItem(); + + public: + CComponentsItem(); + + ///sets pointer to the form object in which this item is embedded. + virtual void setParent(CComponents *parent){cc_parent = parent;}; + + ///sets real position on screen. Use this, if item contains own render methods and item is added to a form + virtual void setRealPos(const int& xr, const int& yr){cc_item_xr = xr; cc_item_yr = yr;}; + virtual int getRealXPos(){return cc_item_xr;}; + virtual int getRealYPos(){return cc_item_yr;}; + + virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0; + virtual void hide(bool no_restore = false); + virtual void kill(); + virtual int getItemType(); + virtual void syncSysColors(); + + ///setters for item select stats + virtual void setSelected(bool selected){cc_item_selected = selected;}; + virtual void setEnable(bool enabled){cc_item_enabled = enabled;}; + ///getters for item enable stats + virtual bool isSelected(){return cc_item_selected;}; + virtual bool isEnabled(){return cc_item_enabled;}; +}; + +class CComponentsPicture : public CComponentsItem +{ + private: + enum + { + CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled + CC_PIC_IMAGE_MODE_ON = 1, //paint pictures in image mode, paint scaled if required + CC_PIC_IMAGE_MODE_AUTO = 2 + }; + + std::string pic_name; + unsigned char pic_offset; + bool pic_paint, pic_paintBg, pic_painted, do_paint; + int pic_align, pic_x, pic_y, pic_width, pic_height; + int pic_max_w, pic_max_h, pic_paint_mode; + + void initVarPicture(); + void init( const int x_pos, const int y_pos, const std::string& image_name, const int alignment, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow); + + public: + CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h, + const std::string& image_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + inline void setPictureOffset(const unsigned char offset){pic_offset = offset;}; + inline void setPicturePaint(bool paint_p){pic_paint = paint_p;}; + inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;}; + void setPicture(const std::string& picture_name); + void setPictureAlign(const int alignment); + + inline bool isPicPainted(){return pic_painted;}; + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void hide(bool no_restore = false); + inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;}; + void setMaxWidth(const int w_max){pic_max_w = w_max;}; + void setMaxHeight(const int h_max){pic_max_h = h_max;}; +}; + +class CComponentsText : public CComponentsItem +{ + protected: + CTextBox * ct_textbox; + CBox * ct_box; + Font * ct_font; + + fb_pixel_t ct_col_text; + int ct_text_mode; //see textbox.h for possible modes + const char* ct_text; + bool ct_text_sent, ct_paint_textbg; + + std::string iToString(int int_val); //helper to convert int to string + + void initVarText(); + void clearCCText(); + void initCCText(); + void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES); + public: + CComponentsText(); + CComponentsText( const int x_pos, const int y_pos, const int w, const int h, + const char* text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + virtual ~CComponentsText(); + + void hide(bool no_restore = false); + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + + virtual inline void setTextFont(Font* font_text){ct_font = font_text;}; + virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;}; + virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes + virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;}; + virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); + virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); + virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); + virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); + virtual void removeLineBreaks(std::string& str); + + //get a Text Box object, so it's possible to get access directly to its methods + virtual CTextBox* getCTextBoxObject() { return ct_textbox; }; +}; + +class CComponentsLabel : public CComponentsText +{ + public: + CComponentsLabel( const int x_pos, const int y_pos, const int w, const int h, + const char* text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_text = COL_MENUCONTENTINACTIVE, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + :CComponentsText(x_pos, y_pos, w, h, text, mode, font_text, has_shadow, color_text, color_frame, color_body, color_shadow) + { + cc_item_type = CC_ITEMTYPE_LABEL; + }; + CComponentsLabel():CComponentsText() + { + initVarText(); + cc_item_type = CC_ITEMTYPE_LABEL; + ct_col_text = COL_MENUCONTENTINACTIVE; + }; +}; + +#define INFO_BOX_Y_OFFSET 2 +class CComponentsInfoBox : public CComponentsText +{ + private: + int x_text, x_offset; + CComponentsPicture * pic; + std::string pic_default_name; + + void paintPicture(); + void initVarInfobox(); + std::string pic_name; + + public: + CComponentsText * cctext; + + CComponentsInfoBox(); + CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, + const char* info_text = NULL, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + ~CComponentsInfoBox(); + + inline void setSpaceOffset(const int offset){x_offset = offset;}; + inline void setPicture(const std::string& picture_name){pic_name = picture_name;}; + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + + +class CComponentsShapeCircle : public CComponentsItem +{ + private: + int d; + public: + CComponentsShapeCircle( const int x_pos, const int y_pos, const int diam, bool has_shadow = CC_SHADOW_ON, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + inline void setDiam(const int& diam){d=width=height=diam, corner_rad=d/2;}; + inline int getDiam(){return d;}; + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +class CComponentsShapeSquare : public CComponentsItem +{ + public: + CComponentsShapeSquare( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +class CComponentsPIP : public CComponentsItem +{ + private: + int screen_w, screen_h; + std::string pic_name; //alternate picture if is no tv picture available + public: + CComponentsPIP( const int x_pos, const int y_pos, const int percent = 30, bool has_shadow = CC_SHADOW_OFF); + ~CComponentsPIP(); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void hide(bool no_restore = false); + void setScreenWidth(int screen_width){screen_w = screen_width;}; + void setScreenHeight(int screen_heigth){screen_h = screen_heigth;}; + void setPicture(const std::string& image){pic_name = image;}; +}; + + class CComponentsDetailLine : public CComponents { private: int thickness, y_down, h_mark_top, h_mark_down; - fb_pixel_t col_line, col_shadow; + + void initVarDline(); public: + CComponentsDetailLine(); CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down, - const int h_mark_up =16 , const int h_mark_down = 16, + const int h_mark_up = CC_HEIGHT_MIN , const int h_mark_down = CC_HEIGHT_MIN, fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ~CComponentsDetailLine(); - void paint(bool do_save_bg = false); - void hide(); - void setColor(fb_pixel_t color_line, fb_pixel_t color_shadow){col_line = color_line; col_shadow = color_shadow;}; - void setYPosDown(const int& y_pos_down){y_down = y_pos_down;}; - void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;}; -}; - -#define INFO_BOX_Y_OFFSET 2 -class CComponentsInfoBox : public CComponents -{ - private: - int rad,fr_thickness; - bool shadow; - fb_pixel_t col_frame, col_body, col_shadow; - bool firstPaint; - std::vector v_infobox_val; - - public: - CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = true, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENTDARK_PLUS_0,fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - - void paint(bool do_save_bg = false, bool fullPaint = false); - void hide(); - void restore(bool clear_ = true); - void setColor(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;}; + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void kill(); + inline void setColors(fb_pixel_t color_line, fb_pixel_t color_shadow){col_body = color_line; col_shadow = color_shadow;}; + void syncSysColors(); + inline void setYPosDown(const int& y_pos_down){y_down = y_pos_down;}; + inline void setHMarkTop(const int& h_mark_top_){h_mark_top = h_mark_top_;}; + inline void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;}; }; #endif diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp new file mode 100644 index 000000000..f9d7bf9c9 --- /dev/null +++ b/src/gui/components/cc_base.cpp @@ -0,0 +1,180 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" + +using namespace std; + +//abstract basic class CComponents +CComponents::CComponents() +{ + initVarBasic(); +} + +CComponents::~CComponents() +{ + hide(); + clearSavedScreen(); + clear(); +} + +void CComponents::clearSavedScreen() +{ + if (saved_screen.pixbuf) + delete[] saved_screen.pixbuf; + saved_screen.pixbuf = NULL; +} + +void CComponents::initVarBasic() +{ + x = saved_screen.x = 0; + y = saved_screen.y = 0; + height = saved_screen.dy = CC_HEIGHT_MIN; + width = saved_screen.dx = CC_WIDTH_MIN; + + col_body = COL_MENUCONTENT_PLUS_0; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + col_frame = COL_MENUCONTENT_PLUS_6; + col_frame_sel = COL_MENUCONTENTSELECTED_PLUS_0; + corner_type = CORNER_ALL; + corner_rad = 0; + shadow = CC_SHADOW_OFF; + shadow_w = SHADOW_OFFSET; + fr_thickness = 0; + fr_thickness_sel = 3; + + firstPaint = true; + is_painted = false; + paint_bg = true; + frameBuffer = CFrameBuffer::getInstance(); + v_fbdata.clear(); + saved_screen.pixbuf = NULL; +} + +bool CComponents::allowPaint(const int& i) +{ + if(v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX) + return true; + + + if (v_fbdata[CC_FBDATA_TYPE_BOX].x != v_fbdata[i].x) + return true; + else if (v_fbdata[CC_FBDATA_TYPE_BOX].y != v_fbdata[i].y) + return true; + else if (v_fbdata[CC_FBDATA_TYPE_BOX].dx != v_fbdata[i].dx) + return true; + else if (v_fbdata[CC_FBDATA_TYPE_BOX].dy != v_fbdata[i].dy) + return true; + + return false; +} + +//paint framebuffer stuff and fill buffer +void CComponents::paintFbItems(bool do_save_bg) +{ + if (firstPaint && do_save_bg) { + for(size_t i=0; isave screen: %d, fbdata_type: %d\n", __FUNCTION__, __LINE__, firstPaint, v_fbdata[i].fbdata_type); +#endif + saved_screen.x = v_fbdata[i].x; + saved_screen.y = v_fbdata[i].y; + saved_screen.dx = v_fbdata[i].dx; + saved_screen.dy = v_fbdata[i].dy; + clearSavedScreen(); + saved_screen.pixbuf = getScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy); + firstPaint = false; + break; + } + } + } + + for(size_t i=0; i< v_fbdata.size() ;i++){ + int fbtype = v_fbdata[i].fbdata_type; +#ifdef DEBUG_CC + printf(" [CComponents]\n [%s - %d], fbdata_[%d] \n x = %d\n y = %d\n dx = %d\n dy = %d\n", __FUNCTION__, __LINE__, i, v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy); +#endif + if (firstPaint){ + + if (do_save_bg && fbtype == CC_FBDATA_TYPE_LINE) + v_fbdata[i].pixbuf = getScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy); + + //ensure painting of all line fb items with saved screens + if (fbtype == CC_FBDATA_TYPE_LINE) + firstPaint = true; + else + firstPaint = false; + } + if (fbtype != CC_FBDATA_TYPE_BGSCREEN){ + if (fbtype == CC_FBDATA_TYPE_FRAME && v_fbdata[i].frame_thickness > 0) + frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].frame_thickness, v_fbdata[i].color, v_fbdata[i].r); + else if (fbtype == CC_FBDATA_TYPE_BACKGROUND) + frameBuffer->paintBackgroundBoxRel(x, y, v_fbdata[i].dx, v_fbdata[i].dy); + else if( allowPaint(i) ) + frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, corner_type); + } + } + + is_painted = true; +} + +//screen area save +inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy) +{ + fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; + frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); + return pixbuf; +} + +//restore screen from buffer +inline void CComponents::hide() +{ + for(size_t i =0; i< v_fbdata.size() ;i++) { + if (v_fbdata[i].pixbuf != NULL){ + frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf); + delete[] v_fbdata[i].pixbuf; + v_fbdata[i].pixbuf = NULL; + } + } + v_fbdata.clear(); + is_painted = false; +} + +//clean old screen buffer +inline void CComponents::clear() +{ + for(size_t i =0; i< v_fbdata.size() ;i++) + if (v_fbdata[i].pixbuf != NULL) + delete[] v_fbdata[i].pixbuf; + v_fbdata.clear(); +} diff --git a/src/gui/components/cc_detailsline.cpp b/src/gui/components/cc_detailsline.cpp new file mode 100644 index 000000000..bae3e163b --- /dev/null +++ b/src/gui/components/cc_detailsline.cpp @@ -0,0 +1,168 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" + +using namespace std; + +//sub class CComponentsDetailLine from CComponents +CComponentsDetailLine::CComponentsDetailLine() +{ + initVarDline(); + + //CComponents + x = 0; + y = 0; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + col_body = COL_MENUCONTENT_PLUS_6; + + //CComponentsDetailLine + y_down = 0; + h_mark_top = CC_HEIGHT_MIN; + h_mark_down = CC_HEIGHT_MIN; +} + +CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow) +{ + initVarDline(); + + //CComponents + x = x_pos; + y = y_pos_top; + col_shadow = color_shadow; + col_body = color_line; + + //CComponentsDetailLine + y_down = y_pos_down; + h_mark_top = h_mark_top_; + h_mark_down = h_mark_down_; +} + +void CComponentsDetailLine::initVarDline() +{ + //CComponents + initVarBasic(); + + shadow_w = 1; + + //CComponentsDetailLine + thickness = 4; +} + +CComponentsDetailLine::~CComponentsDetailLine() +{ + hide(); //restore background + clear(); +} + +// y_top (=y) +// xpos +--|h_mark_up +// | +// | +// | +// | +// | +// | +// | +// | +// | +// +--|h_mark_down +// y_down + + +//paint details line with current parameters +void CComponentsDetailLine::paint(bool do_save_bg) +{ + clear(); + + int y_mark_top = y-h_mark_top/2+thickness/2; + int y_mark_down = y_down-h_mark_down/2+thickness/2; + + int sw = shadow_w; + + comp_fbdata_t fbdata[] = + { + /* vertical item mark | */ + {CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_body, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_top, sw, h_mark_top, col_shadow, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_top+h_mark_top, thickness+sw, sw , col_shadow, 0, 0, NULL, NULL}, + + /* horizontal item line - */ + {CC_FBDATA_TYPE_LINE, x, y, width-thickness-sw, thickness, col_body, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x+thickness, y+thickness, width-2*thickness-sw, sw, col_shadow, 0, 0, NULL, NULL}, + + /* vertical connect line [ */ + {CC_FBDATA_TYPE_LINE, x, y+thickness, thickness, y_down-y-thickness, col_body, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x+thickness, y+thickness+sw, sw, y_down-y-thickness-sw, col_shadow, 0, 0, NULL, NULL}, + + /* horizontal info line - */ + {CC_FBDATA_TYPE_LINE, x, y_down, width-thickness-sw, thickness, col_body, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x, y_down+thickness, width-thickness-sw, sw, col_shadow, 0, 0, NULL, NULL}, + + /* vertical info mark | */ + {CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_body, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_down, sw, h_mark_down, col_shadow, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_down+h_mark_down,thickness+sw, sw, col_shadow, 0, 0, NULL, NULL}, + }; + + for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) + v_fbdata.push_back(fbdata[i]); + + paintFbItems(do_save_bg); +} + +//remove painted fb items from screen +void CComponentsDetailLine::kill() +{ + //save current colors + fb_pixel_t c_tmp1, c_tmp2; + c_tmp1 = col_body; + c_tmp2 = col_shadow; + + //set background color + col_body = col_shadow = COL_BACKGROUND; + + //paint with background and restore, set last used colors + paint(CC_SAVE_SCREEN_NO); + col_body = c_tmp1; + col_shadow = c_tmp2; + firstPaint = true; +} + +//synchronize colors for details line +//This is usefull if the system colors are changed during runtime +//so you can ensure correct applied system colors in relevant objects with unchanged instances. +void CComponentsDetailLine::syncSysColors() +{ + col_body = COL_MENUCONTENT_PLUS_6; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; +} diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp new file mode 100644 index 000000000..34c1e4d25 --- /dev/null +++ b/src/gui/components/cc_frm.cpp @@ -0,0 +1,301 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_frm.h" + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsForm from CComponentsItem +CComponentsForm::CComponentsForm() +{ + //CComponentsForm + initVarForm(); +} + +CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsForm + initVarForm(); + + //CComponents + x = x_pos; + y = y_pos; + width = w; + height = h; + + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; +} + +CComponentsForm::~CComponentsForm() +{ + cleanCCForm(); +} + +void CComponentsForm::cleanCCForm() +{ +#ifdef DEBUG_CC + printf("[CComponentsForm] [%s - %d] clean up...\n", __FUNCTION__, __LINE__); +#endif +// hide(); + clearCCItems(); + clearSavedScreen(); + clear(); +} + + + +void CComponentsForm::clearCCItems() +{ + if (v_cc_items.empty()) + return; +#ifdef DEBUG_CC + printf(" [CComponentsForm] %s... delete %d cc-item(s) \n", __FUNCTION__, v_cc_items.size()); +#endif + + for(size_t i=0; igetItemType()); +#endif + delete v_cc_items[i]; + v_cc_items[i] = NULL; + } + } + v_cc_items.clear(); +} + + +void CComponentsForm::initVarForm() +{ + //CComponentsItem + initVarItem(); + + + //simple default dimensions + x = 0; + y = 0; + width = 150; + height = 150; + shadow = CC_SHADOW_OFF; + shadow_w = SHADOW_OFFSET; + col_frame = COL_MENUCONTENT_PLUS_6; + col_body = COL_MENUCONTENT_PLUS_0; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + corner_rad = RADIUS_LARGE; + corner_type = CORNER_ALL; + + //CComponentsForm + v_cc_items.clear(); + +} + +void CComponentsForm::addCCItem(CComponentsItem* cc_Item) +{ + if (cc_Item){ +#ifdef DEBUG_CC + printf(" [CComponentsForm] %s-%d add cc_Item [type %d] [current count %d] \n", __FUNCTION__, __LINE__, cc_Item->getItemType(), v_cc_items.size()); +#endif + cc_Item->setParent(this); + v_cc_items.push_back(cc_Item); + } +#ifdef DEBUG_CC + else + printf(" [CComponentsForm] %s-%d tried to add an empty or invalide cc_item !!!\n", __FUNCTION__, __LINE__); +#endif +} + +int CComponentsForm::getCCItemId(CComponentsItem* cc_Item) +{ + for (size_t i= 0; i< v_cc_items.size(); i++) + if (v_cc_items[i] == cc_Item) + return i; + return -1; +} + +CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) +{ + if (v_cc_items[cc_item_id]) + return v_cc_items[cc_item_id]; + return NULL; +} + +void CComponentsForm::replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item) +{ + if (!v_cc_items.empty()){ + if (v_cc_items[cc_item_id]){ + delete v_cc_items[cc_item_id]; + v_cc_items[cc_item_id] = NULL; + v_cc_items[cc_item_id] = new_cc_Item; + } + } +#ifdef DEBUG_CC + else + printf("[CComponentsForm] %s replace cc_Item not possible, v_cc_items is empty\n", __FUNCTION__); +#endif + +} + +void CComponentsForm::replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item) +{ + replaceCCItem(getCCItemId(old_cc_Item), new_cc_Item); +} + +void CComponentsForm::insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item) +{ + + if (cc_Item == NULL){ +#ifdef DEBUG_CC + printf("[CComponentsForm] %s parameter: cc_Item = %p...\n", __func__, cc_Item); +#endif + return; + } + + if (v_cc_items.empty()){ + v_cc_items.push_back(cc_Item); +#ifdef DEBUG_CC + printf("[CComponentsForm] %s insert cc_Item not possible, v_cc_items is empty, cc_Item added\n", __FUNCTION__); +#endif + }else + v_cc_items.insert(v_cc_items.begin()+cc_item_id, cc_Item); +} + +void CComponentsForm::removeCCItem(const uint& cc_item_id) +{ + if (!v_cc_items.empty()){ + if (v_cc_items[cc_item_id]) { + delete v_cc_items[cc_item_id]; + v_cc_items[cc_item_id] = NULL; + v_cc_items.erase(v_cc_items.begin()+cc_item_id); + } + } +#ifdef DEBUG_CC + else + printf("[CComponentsForm] %s removing cc_Item not possible, v_cc_items is empty...\n", __FUNCTION__); +#endif +} + +void CComponentsForm::paintForm(bool do_save_bg) +{ + //paint body + paintInit(do_save_bg); + + //paint + paintCCItems(); +} + +void CComponentsForm::paint(bool do_save_bg) +{ + paintForm(do_save_bg); +} + +void CComponentsForm::paintCCItems() +{ + size_t items_count = v_cc_items.size(); + int x_frm_left = x+fr_thickness; //left form border + int y_frm_top = y+fr_thickness; //top form border + int x_frm_right = x+width-fr_thickness; //right form border + int y_frm_bottom = y+height-fr_thickness; //bottom form border + + for(size_t i=0; igetDimensions(&x_item, &y_item, &w_item, &h_item); + + int xy_ref = 0+fr_thickness; //allowed minimal x and y start position + if (x_item < xy_ref){ +#ifdef DEBUG_CC + printf("[CComponentsForm] %s: item %d position is out of form dimensions\ndefinied x=%d\nallowed x>=%d\n", __FUNCTION__, i, x_item, xy_ref); +#endif + x_item = xy_ref; + } + if (y_item < xy_ref){ +#ifdef DEBUG_CC + printf("[CComponentsForm] %s: item %d position is out of form dimensions\ndefinied y=%d\nallowed y>=%d\n", __FUNCTION__, i, y_item, xy_ref); +#endif + y_item = xy_ref; + } + + //set adapted position onto form + v_cc_items[i]->setXPos(x_frm_left+x_item); + v_cc_items[i]->setYPos(y_frm_top+y_item); + + //watch horizontal x dimensions of items + int x_item_right = v_cc_items[i]->getXPos()+w_item; //right item border + if (x_item_right > x_frm_right){ + v_cc_items[i]->setWidth(w_item-(x_item_right-x_frm_right)); +#ifdef DEBUG_CC + printf("[CComponentsForm] %s: item %d too large, definied width=%d, possible width=%d \n", __FUNCTION__, i, w_item, v_cc_items[i]->getWidth()); +#endif + } + + //watch vertical y dimensions + int y_item_bottom = v_cc_items[i]->getYPos()+h_item; //bottom item border + if (y_item_bottom > y_frm_bottom){ + v_cc_items[i]->setHeight(h_item-(y_item_bottom-y_frm_bottom)); +#ifdef DEBUG_CC + printf("[CComponentsForm] %s: item %d too large, definied height=%d, possible height=%d \n", __FUNCTION__, i, h_item, v_cc_items[i]->getHeight()); +#endif + } + + //set real position dimension to item + int real_x = v_cc_items[i]->getXPos(); + int real_y = v_cc_items[i]->getYPos(); + v_cc_items[i]->setRealPos(real_x, real_y); + + //paint element without saved screen! + v_cc_items[i]->paint(CC_SAVE_SCREEN_NO); + + //restore dimensions and position + v_cc_items[i]->setDimensionsAll(x_item, y_item, w_item, h_item); + } +} + +void CComponentsForm::hide(bool no_restore) +{ + // hack: ensure hiding of minitv during hide of forms and inherited classes, + // because the handling of minitv items are different to other item types + // and need an explizit call of hide() + for(size_t i=0; igetItemType() == CC_ITEMTYPE_PIP){ + v_cc_items[i]->hide(); + break; + } + } + + //hide body + hideCCItem(no_restore); +} diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h new file mode 100644 index 000000000..f5b41de3f --- /dev/null +++ b/src/gui/components/cc_frm.h @@ -0,0 +1,194 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __CC_FORM_H__ +#define __CC_FORM_H__ + + +#include "config.h" +#include +#include +#include + + +class CComponentsForm : public CComponentsItem +{ + protected: + std::vector v_cc_items; + void initVarForm(); + void paintForm(bool do_save_bg); + public: + + CComponentsForm(); + CComponentsForm(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + virtual ~CComponentsForm(); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void hide(bool no_restore = false); + virtual void addCCItem(CComponentsItem* cc_Item); + virtual void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item); + virtual void removeCCItem(const uint& cc_item_id); + virtual void replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item); + virtual void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item); + virtual int getCCItemId(CComponentsItem* cc_Item); + virtual CComponentsItem* getCCItem(const uint& cc_item_id); + virtual void paintCCItems(); + virtual void clearCCItems(); + virtual void cleanCCForm(); +}; + +class CComponentsIconForm : public CComponentsForm +{ + private: + std::vector v_icons; + int ccif_offset, ccif_icon_align; + void initMaxHeight(int *pheight); + + protected: + void initVarIconForm(); + + public: + CComponentsIconForm(); + CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector v_icon_names, bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); +// ~CComponentsIconForm(); //inherited from CComponentsForm + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void initCCIcons(); + void addIcon(const std::string& icon_name); + void addIcon(std::vector icon_name); + void removeIcons(){v_icons.clear();}; + void insertIcon(const uint& icon_id, const std::string& icon_name); + void removeIcon(const uint& icon_id); + void removeIcon(const std::string& icon_name); + void removeAllIcons(); + void setIconOffset(const int offset){ccif_offset = offset;}; + + enum //alignements + { + CC_ICONS_FRM_ALIGN_RIGHT , + CC_ICONS_FRM_ALIGN_LEFT + }; + void setIconAlign(int alignment){ccif_icon_align = alignment;}; + + int getIconId(const std::string& icon_name); +}; + + + +class CComponentsHeader : public CComponentsForm +{ + private: + CComponentsPicture * cch_icon_obj; + CComponentsText * cch_text_obj; + CComponentsIconForm * cch_btn_obj; + std::string cch_text; + const char* cch_icon_name; + neutrino_locale_t cch_locale_text; + fb_pixel_t cch_col_text; + Font* cch_font; + int cch_icon_x, cch_items_y, cch_text_x, ccif_width, cch_icon_w, cch_buttons, cch_btn_offset; + std::vector v_cch_btn; + + void initCCHeaderIcon(); + void initCCHeaderText(); + void initCCHeaderButtons(); + void initCCHDefaultButtons(); + void initCCButtonFormSize(); + + protected: + void initVarHeader(); + + public: + enum + { + CC_BTN_HELP = 0x02, + CC_BTN_INFO = 0x04, + CC_BTN_MENU = 0x40, + CC_BTN_EXIT = 0x80 + + }; + + enum + { + CC_HEADER_ITEM_ICON = 0, + CC_HEADER_ITEM_TEXT = 1, + CC_HEADER_ITEM_BUTTONS = 2 + }; + CComponentsHeader(); + CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, const std::string& caption = "header", const char* icon_name = NULL, const int buttons = 0, bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, const char* icon_name = NULL, const int buttons = 0,bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + ~CComponentsHeader(); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void setHeaderText(const std::string& caption); + void setHeaderText(neutrino_locale_t caption_locale); + void setColorHeaderBody(fb_pixel_t text_color){cch_col_text = text_color;}; + void setHeaderButtonOffset(const int offset){cch_btn_offset = offset;}; + void setHeaderIcon(const char* icon_name); + void addHeaderButton(const std::string& button_name); + void removeHeaderButtons(); + void setHeaderDefaultButtons(const int buttons); + void initCCHeaderItems(); +}; + +class CComponentsWindow : public CComponentsForm +{ + private: + CComponentsHeader * ccw_head; + std::string ccw_caption; + const char* ccw_icon_name; + int ccw_start_y; + int ccw_buttons; + + void initHeader(); + void initCCWItems(); + + protected: + void initVarWindow(); + + public: + enum + { + CC_WINDOW_ITEM_HEADER = 0 + }; + CComponentsWindow(); + CComponentsWindow(const std::string& caption, const char* iconname = NULL); + CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname = NULL); + ~CComponentsWindow(); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void setWindowCaption(const std::string& text){ccw_caption = text;}; + void setWindowCaption(neutrino_locale_t locale_text); + void setWindowIcon(const char* iconname){ccw_icon_name = iconname;}; + void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;}; + + int getStartY(); //y value for start of the area below header +}; + +#endif diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp new file mode 100644 index 000000000..5deb2c086 --- /dev/null +++ b/src/gui/components/cc_frm_header.cpp @@ -0,0 +1,322 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_frm.h" + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsHeader inherit from CComponentsForm +CComponentsHeader::CComponentsHeader() +{ + //CComponentsHeader + initVarHeader(); +} + +CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, const std::string& caption, const char* icon_name, const int buttons, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsHeader + initVarHeader(); + + x = x_pos; + y = y_pos; + width = w; + height = h > 0 ? h : g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + cch_text = caption; + cch_icon_name = icon_name; + cch_buttons = buttons; + initCCHDefaultButtons(); + initCCHeaderItems(); +} + +CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsHeader + initVarHeader(); + + x = x_pos; + y = y_pos; + width = w; + height = h; + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + cch_locale_text = caption_locale; + cch_icon_name = icon_name; + cch_buttons = buttons; + + initCCHDefaultButtons(); + initCCHeaderItems(); +} + +void CComponentsHeader::initVarHeader() +{ + //CComponentsForm + initVarForm(); + cc_item_type = CC_ITEMTYPE_FRM_HEADER; + col_body = COL_MENUHEAD_PLUS_0; + corner_rad = RADIUS_LARGE, + corner_type = CORNER_TOP; + + //init header height + cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; + height = cch_font->getHeight(); + + //CComponentsHeader + cch_icon_obj = NULL; + cch_text_obj = NULL; + cch_icon_name = NULL; + cch_btn_obj = NULL; + cch_text = "header"; + cch_locale_text = NONEXISTANT_LOCALE; + cch_col_text = COL_MENUHEAD; + cch_items_y = 0; + cch_icon_x = 0; + cch_icon_w = 5; + cch_text_x = 0; + ccif_width = 0; + cch_buttons = 0; + cch_btn_offset = 8; + v_cch_btn.clear(); + + +} + +CComponentsHeader::~CComponentsHeader() +{ +#ifdef DEBUG_CC + printf("[~CComponentsHeader] [%s - %d] delete...\n", __FUNCTION__, __LINE__); +#endif + v_cch_btn.clear(); + cleanCCForm(); +} + +void CComponentsHeader::setHeaderText(const std::string& caption) +{ + cch_text = caption; +} + +void CComponentsHeader::setHeaderText(neutrino_locale_t caption_locale) +{ + cch_text = g_Locale->getText(caption_locale); +} + +void CComponentsHeader::setHeaderIcon(const char* icon_name) +{ + cch_icon_name = icon_name; +} + +void CComponentsHeader::initCCHeaderIcon() +{ + //reset cch_icon_w + cch_icon_w = cch_btn_offset; + + //init cch_icon_obj only if an icon available + if (cch_icon_name == NULL) { + cch_icon_w = cch_btn_offset; + if (cch_icon_obj) + delete cch_icon_obj; + cch_icon_obj = NULL; + return; + } + + //create instance for cch_icon_obj + if (cch_icon_obj == NULL){ +#ifdef DEBUG_CC + printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __FUNCTION__, __LINE__, cch_icon_name); +#endif + cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name); + //add item only one time + addCCItem(cch_icon_obj); //icon + } + + //set properties for icon object + if (cch_icon_obj){ + cch_icon_obj->setWidth(height-2*fr_thickness); + cch_icon_obj->setHeight(height); + cch_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); + cch_icon_obj->doPaintBg(false); + + //set corner mode of icon item + cch_icon_obj->setCornerRadius(corner_rad-fr_thickness); + int cc_icon_corner_type = corner_type; + if (corner_type == CORNER_TOP_LEFT || corner_type == CORNER_TOP) + cc_icon_corner_type = CORNER_TOP_LEFT; + else + cc_icon_corner_type = CORNER_LEFT; + cch_icon_obj->setCornerType(cc_icon_corner_type); + + //set width of icon object + cch_icon_w = cch_icon_obj->getWidth(); + + //adapt height + height = max(height, cch_icon_obj->getHeight()); + } +} + +void CComponentsHeader::addHeaderButton(const std::string& button_name) +{ + v_cch_btn.push_back(button_name); + initCCHeaderButtons(); +} + +void CComponentsHeader::removeHeaderButtons() +{ + v_cch_btn.clear(); + cch_btn_obj->removeAllIcons(); + initCCHeaderButtons(); + +} + +void CComponentsHeader::initCCHDefaultButtons() +{ + if (cch_buttons & CC_BTN_EXIT) + v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HOME); + if (cch_buttons & CC_BTN_HELP) + v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HELP); + if (cch_buttons & CC_BTN_INFO) + v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_INFO); + if (cch_buttons & CC_BTN_MENU) + v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_MENU); +#ifdef DEBUG_CC + printf("[CComponentsHeader] %s added %d default buttons...\n", __FUNCTION__, v_cch_btn.size()); +#endif +} + +void CComponentsHeader::setHeaderDefaultButtons(const int buttons) +{ + cch_buttons = buttons; + v_cch_btn.clear(); + initCCHDefaultButtons(); +} + +// calculate minimal width of icon form +void CComponentsHeader::initCCButtonFormSize() +{ + ccif_width = 0; + for(size_t i=0; igetIconSize(v_cch_btn[i].c_str(), &bw, &bh); + ccif_width += (bw + cch_btn_offset); + } +} + +void CComponentsHeader::initCCHeaderButtons() +{ + //exit if no button defined + if (v_cch_btn.empty()) + return; + + initCCButtonFormSize(); + + if (cch_btn_obj == NULL){ + cch_btn_obj = new CComponentsIconForm(); +#ifdef DEBUG_CC + printf(" [CComponentsHeader]\n [%s - %d] init header buttons...\n", __FUNCTION__, __LINE__); +#endif + //add button form + addCCItem(cch_btn_obj); //buttons + } + + //set button form properties + if (cch_btn_obj){ + cch_btn_obj->setDimensionsAll(0+width-ccif_width, 0, ccif_width-cch_btn_offset, height); + cch_btn_obj->doPaintBg(false); + cch_btn_obj->setIconOffset(cch_btn_offset); + cch_btn_obj->setIconAlign(CComponentsIconForm::CC_ICONS_FRM_ALIGN_RIGHT); + cch_btn_obj->removeAllIcons(); + cch_btn_obj->addIcon(v_cch_btn); + height = max(height, cch_btn_obj->getHeight()); + } +} + +void CComponentsHeader::initCCHeaderText() +{ + //reset header text position first + cch_text_x = cch_icon_x+cch_icon_w; + + //create cch_text_obj and add to collection + if (cch_text_obj == NULL){ +#ifdef DEBUG_CC + printf(" [CComponentsHeader]\n [%s - %d] init header text: %s\n", __FUNCTION__, __LINE__, cch_text.c_str()); +#endif + cch_text_obj = new CComponentsText(); + //add text item + addCCItem(cch_text_obj); //text + } + + //set header text properties + if (cch_text_obj){ + cch_text_obj->setText(cch_text, CTextBox::AUTO_WIDTH, cch_font); + cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, width-cch_icon_w-fr_thickness, height-2*fr_thickness); + cch_text_obj->setTextColor(cch_col_text); + cch_text_obj->setColorBody(col_body); + cch_text_obj->doPaintBg(false); + + //corner of text item + cch_text_obj->setCornerRadius(corner_rad-fr_thickness); + cch_text_obj->setCornerType(corner_type); + + //get height + height = max(height, cch_text_obj->getHeight()); + } +} + +void CComponentsHeader::initCCHeaderItems() +{ + //init icon + initCCHeaderIcon(); + + //init text + initCCHeaderText(); + + //init buttons + initCCHeaderButtons(); +} + +void CComponentsHeader::paint(bool do_save_bg) +{ + //prepare items + initCCHeaderItems(); + + //paint form contents + paintForm(do_save_bg); +} diff --git a/src/gui/components/cc_frm_icons.cpp b/src/gui/components/cc_frm_icons.cpp new file mode 100644 index 000000000..9ee4f431b --- /dev/null +++ b/src/gui/components/cc_frm_icons.cpp @@ -0,0 +1,197 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_frm.h" + +using namespace std; + +//sub class CComponentsIconForm inherit from CComponentsForm +CComponentsIconForm::CComponentsIconForm() +{ + initVarIconForm(); +} + + +CComponentsIconForm::CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector v_icon_names, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + initVarIconForm(); + + x = x_pos; + y = y_pos; + width = w; + height = h; + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + v_icons = v_icon_names; +} + +void CComponentsIconForm::initVarIconForm() +{ + //CComponentsForm + initVarForm(); + cc_item_type = CC_ITEMTYPE_FRM_ICONFORM; + + //set default width and height to 0, this causes a dynamic adaptation of width and height of form + width = 0; + height = 0; + + v_icons.clear(); + ccif_offset = 2; + ccif_icon_align = CC_ICONS_FRM_ALIGN_LEFT; +} + +void CComponentsIconForm::addIcon(const std::string& icon_name) +{ + v_icons.push_back(icon_name); +} + +void CComponentsIconForm::addIcon(std::vector icon_name) +{ + for (size_t i= 0; i< icon_name.size(); i++) + v_icons.push_back(icon_name[i]); +} + +void CComponentsIconForm::insertIcon(const uint& icon_id, const std::string& icon_name) +{ + v_icons.insert(v_icons.begin()+icon_id, icon_name); +} + +void CComponentsIconForm::removeIcon(const uint& icon_id) +{ + v_icons.erase(v_icons.begin()+icon_id); +} + +void CComponentsIconForm::removeIcon(const std::string& icon_name) +{ + int id = getIconId(icon_name); + removeIcon(id); +} + +int CComponentsIconForm::getIconId(const std::string& icon_name) +{ + for (size_t i= 0; i< v_icons.size(); i++) + if (v_icons[i] == icon_name) + return i; + return -1; +} + +//For existing instances it's recommended +//to remove old items before add new icons, otherwise icons will be appended. +void CComponentsIconForm::removeAllIcons() +{ + clearCCItems(); + v_icons.clear(); +} + +//get maximal form height depends of biggest icon height, but don't touch defined form height +void CComponentsIconForm::initMaxHeight(int *pheight) +{ + for (size_t i= 0; i< v_icons.size(); i++){ + int dummy, htmp; + frameBuffer->getIconSize(v_icons[i].c_str(), &dummy, &htmp); + *pheight = max(htmp, height)/*+2*fr_thickness*/; + } +} + +void CComponentsIconForm::initCCIcons() +{ + int ccp_y = 0; + int ccp_h = 0; + int ccp_w = 0; + //calculate start pos of first icon + int ccp_x = 0 + fr_thickness; //CC_ICONS_FRM_ALIGN_LEFT; + + if (ccif_icon_align == CC_ICONS_FRM_ALIGN_RIGHT) + ccp_x += (width - fr_thickness); + + //get width of first icon + frameBuffer->getIconSize(v_icons[0].c_str(), &ccp_w, &ccp_h); + + //get maximal form height + int h = 0; + initMaxHeight(&h); + + //set xpos of first icon with right alignment, icon must positionized on the right border reduced with icon width + if (ccif_icon_align == CC_ICONS_FRM_ALIGN_RIGHT) + ccp_x -= ccp_w; + + //init and add item objects + size_t i_cnt = v_icons.size(); //icon count + + for (size_t i= 0; i< i_cnt; i++){ + //create new cc-picture item object + CComponentsPicture *ccp = new CComponentsPicture(ccp_x, ccp_y, ccp_w, h, v_icons[i]); + ccp->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); + ccp->doPaintBg(false); + //add item to form + addCCItem(ccp); + + //reset current width for next object + ccp_w = 0; + //get next icon size if available + size_t next_i = i+1; + if (next_i != i_cnt) + frameBuffer->getIconSize(v_icons[next_i].c_str(), &ccp_w, &ccp_h); + + //set next icon position + int tmp_offset = ( igetWidth() + tmp_offset); + if (ccif_icon_align == CC_ICONS_FRM_ALIGN_RIGHT) + ccp_x -= (ccp_w + tmp_offset); + } + + //calculate width and height of form + int w_tmp = 0; + int h_tmp = 0; + for (size_t i= 0; i< i_cnt; i++){ + w_tmp += v_cc_items[i]->getWidth()+ccif_offset+fr_thickness; + h_tmp = max(h_tmp, v_cc_items[i]->getHeight()+2*fr_thickness); + + } + width = max(w_tmp, width); + height = max(h_tmp, height); +} + +void CComponentsIconForm::paint(bool do_save_bg) +{ + //init and add icons + initCCIcons(); + + //paint form contents + paintForm(do_save_bg); +} diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp new file mode 100644 index 000000000..05a6e222d --- /dev/null +++ b/src/gui/components/cc_frm_window.cpp @@ -0,0 +1,138 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_frm.h" +#include + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsWindow inherit from CComponentsForm +CComponentsWindow::CComponentsWindow() +{ + initVarWindow(); +} + +CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname) +{ + initVarWindow(); + + ccw_caption = caption; + ccw_icon_name = iconname; +} + +CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname) +{ + initVarWindow(); + + ccw_caption = g_Locale->getText(locale_caption); + ccw_icon_name = iconname; +} + +CComponentsWindow::~CComponentsWindow() +{ +#ifdef DEBUG_CC + printf("[~CComponentsWindow] [%s - %d] delete...\n", __FUNCTION__, __LINE__); +#endif + cleanCCForm(); +} + +void CComponentsWindow::initVarWindow() +{ + //CComponentsForm + initVarForm(); + cc_item_type = CC_ITEMTYPE_FRM_WINDOW; + + //using current screen settings for default dimensions + width = frameBuffer->getScreenWidth(); + height = frameBuffer->getScreenHeight(); + x=getScreenStartX(width); + y=getScreenStartY(height); + + ccw_head = NULL; + ccw_caption = ""; + ccw_icon_name = NULL; + ccw_start_y = 0; + ccw_buttons = 0; //no header buttons + + setShadowOnOff(true); +} + +void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text) +{ + ccw_caption = g_Locale->getText(locale_text); +} + +void CComponentsWindow::initHeader() +{ + if (ccw_head == NULL){ + ccw_head = new CComponentsHeader(); + initHeader(); + //add header item only one time + addCCItem(ccw_head); + } + + //set header properties + if (ccw_head){ + ccw_head->setXPos(0); + ccw_head->setYPos(0); + ccw_head->setWidth(width); + ccw_head->setHeaderIcon(ccw_icon_name); + ccw_head->setHeaderText(ccw_caption); + ccw_head->initCCHeaderItems(); + ccw_start_y = ccw_head->getHeight(); + ccw_head->setHeaderDefaultButtons(ccw_buttons); + } +} + +int CComponentsWindow::getStartY() +{ + initHeader(); + return ccw_start_y; +} + +void CComponentsWindow::initCCWItems() +{ +#ifdef DEBUG_CC + printf("[CComponentsWindow] [%s - %d] init items...\n", __FUNCTION__, __LINE__); +#endif + initHeader(); +} + +void CComponentsWindow::paint(bool do_save_bg) +{ + //prepare items before paint + initCCWItems(); + + //paint form contents + paintForm(do_save_bg); +} diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp new file mode 100644 index 000000000..15b5970a0 --- /dev/null +++ b/src/gui/components/cc_item.cpp @@ -0,0 +1,163 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" + +using namespace std; + +//abstract sub class CComponentsItem from CComponents +CComponentsItem::CComponentsItem() +{ + //CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_BASE; +} + +// y +// x+------f-r-a-m-e-------+ +// | | +// height body | +// | | +// +--------width---------+ + +void CComponentsItem::initVarItem() +{ + //CComponents + initVarBasic(); + cc_item_index = CC_NO_INDEX; + cc_item_xr = cc_item_yr = -1; + cc_item_enabled = true; + cc_item_selected = false; + cc_parent = NULL; +} + +// Paint container background in cc-items with shadow, background and frame. +// This member must be called first in all paint() members before paint other items into the container. +// If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this! +void CComponentsItem::paintInit(bool do_save_bg) +{ + clear(); + + if(!paint_bg) + return; + + int sw = shadow ? shadow_w : 0; + int th = fr_thickness; + fb_pixel_t col_frame_cur = col_frame; + + if (cc_item_selected){ + col_frame_cur = col_frame_sel; + th = max(fr_thickness_sel, fr_thickness); + } + + comp_fbdata_t fbdata[] = + { + {CC_FBDATA_TYPE_BGSCREEN, x, y, width+sw, height+sw, 0, 0, 0, NULL, NULL}, + {CC_FBDATA_TYPE_SHADOW, x+sw, y+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL}, + {CC_FBDATA_TYPE_FRAME, x, y, width, height, col_frame_cur, corner_rad, th, NULL, NULL}, + {CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, corner_rad-th, 0, NULL, NULL}, + }; + + for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) + v_fbdata.push_back(fbdata[i]); +#ifdef DEBUG_CC + printf("[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __FUNCTION__, cc_item_type, cc_item_index, height, width); +#endif + paintFbItems(do_save_bg); +} + +//restore last saved screen behind form box, +//Do use parameter 'no restore' to override temporarly the restore funtionality. +//This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents. +void CComponentsItem::hideCCItem(bool no_restore) +{ + is_painted = false; + + if (saved_screen.pixbuf) { + frameBuffer->RestoreScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy, saved_screen.pixbuf); + if (no_restore) { + delete[] saved_screen.pixbuf; + saved_screen.pixbuf = NULL; + firstPaint = true; + } + } +} + +void CComponentsItem::hide(bool no_restore) +{ + hideCCItem(no_restore); +} + + +//hide rendered objects +void CComponentsItem::kill() +{ + //save current colors + fb_pixel_t c_tmp1, c_tmp2, c_tmp3; + c_tmp1 = col_body; + c_tmp2 = col_shadow; + c_tmp3 = col_frame; + + //set background color + col_body = col_frame = col_shadow = COL_BACKGROUND; + + //paint with background and restore last used colors + paint(CC_SAVE_SCREEN_NO); + col_body = c_tmp1; + col_shadow = c_tmp2; + col_frame = c_tmp3; + firstPaint = true; + is_painted = false; +} + +//synchronize colors for forms +//This is usefull if the system colors are changed during runtime +//so you can ensure correct applied system colors in relevant objects with unchanged instances. +void CComponentsItem::syncSysColors() +{ + col_body = COL_MENUCONTENT_PLUS_0; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; + col_frame = COL_MENUCONTENT_PLUS_6; +} + +//returns current item element type, if no available, return -1 as unknown type +int CComponentsItem::getItemType() +{ + for(int i =0; i< (CC_ITEMTYPES) ;i++){ + if (i == cc_item_type) + return i; + } +#ifdef DEBUG_CC + printf("[CComponentsItem] %s: unknown item type requested...\n", __FUNCTION__); +#endif + return -1; +} diff --git a/src/gui/components/cc_item_box.cpp b/src/gui/components/cc_item_box.cpp new file mode 100644 index 000000000..48809f34e --- /dev/null +++ b/src/gui/components/cc_item_box.cpp @@ -0,0 +1,615 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc_misc.h" + +using namespace std; + +//sub class CComponentsItemBox from CComponentsItem +CComponentsItemBox::CComponentsItemBox() +{ + //CComponentsItemBox + initVarItemBox(); +} + +CComponentsItemBox::~CComponentsItemBox() +{ + hide(); + clearElements(); + clearSavedScreen(); + clear(); +} + +void CComponentsItemBox::initVarItemBox() +{ + //CComponents, CComponentsItem + initVarItem(); + + //CComponentsItemBox + it_col_text = COL_MENUCONTENT; + hSpacer = 2; + hOffset = 4; + vOffset = 1; + digit_h = 0; + digit_offset = 0; + font_text = NULL; + paintElements = true; + hMax = 0; + has_TextElement = false; + firstElementLeft = FIRST_ELEMENT_INIT; + firstElementRight = FIRST_ELEMENT_INIT; + prevElementLeft = 0; + prevElementRight = 0; + onlyOneTextElement = false; + isCalculated = false; + v_element_data.clear(); +} + +int CComponentsItemBox::getHeight() +{ + if (!isCalculated) + calculateElements(); + return height; +} + +void CComponentsItemBox::clearElements() +{ + for(size_t i = 0; i < v_element_data.size(); i++) { + switch (v_element_data[i].type) { + case CC_ITEMBOX_ICON: + case CC_ITEMBOX_PICTURE: + if (v_element_data[i].handler1 != NULL) + delete static_cast(v_element_data[i].handler1); + break; + case CC_ITEMBOX_TEXT: + if (v_element_data[i].handler1 != NULL) + delete static_cast(v_element_data[i].handler1); + if (v_element_data[i].handler2 != NULL) + delete static_cast(v_element_data[i].handler2); + break; + default: + break; + } + } + isCalculated = false; + v_element_data.clear(); +} +extern CPictureViewer * g_PicViewer; +bool CComponentsItemBox::addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index) +{ + comp_element_data_t data; + int dx=0, dy=0; + + data.align = align; + data.x = x; + data.y = y; + data.width = 0; + data.height = 0; + data.handler1 = NULL; + data.handler2 = NULL; + + g_PicViewer->getSize(logo.c_str(), &dx, &dy); + if ((dx != 0) && (dy != 0)) { + // logo OK + data.type = CC_ITEMBOX_PICTURE; + data.element = logo; + } + else { + // no logo + if ((text == "") || ((onlyOneTextElement) && (has_TextElement))) + return false; + else + has_TextElement = true; + if (font_text != NULL) + data.height = font_text->getHeight(); + data.type = CC_ITEMBOX_TEXT; + data.element = text; + } + + v_element_data.push_back(data); + if (index != NULL) + *index = v_element_data.size()-1; + isCalculated = false; + return true; +} + +void CComponentsItemBox::addText(const std::string& s_text, const int align, size_t *index) +{ + addElement(align, CC_ITEMBOX_TEXT, s_text, index); +} + +void CComponentsItemBox::addText(neutrino_locale_t locale_text, const int align, size_t *index) +{ + addElement(align, CC_ITEMBOX_TEXT, g_Locale->getText(locale_text), index); +} + +void CComponentsItemBox::addIcon(const std::string& s_icon_name, const int align, size_t *index) +{ + addElement(align, CC_ITEMBOX_ICON, s_icon_name, index); +} + +void CComponentsItemBox::addPicture(const std::string& s_picture_path, const int align, size_t *index) +{ + addElement(align, CC_ITEMBOX_PICTURE, s_picture_path, index); +} + +void CComponentsItemBox::addClock(const int align, size_t *index) +{ + addElement(align, CC_ITEMBOX_CLOCK, "", index); +} + +bool CComponentsItemBox::addElement(int align, int type, const std::string& element, size_t *index) +{ + comp_element_data_t data; + int dx=0, dy=0; + + switch (type) + { + case CC_ITEMBOX_ICON: + frameBuffer->getIconSize(element.c_str(), &dx, &dy); + if ((dx == 0) || (dy == 0)) + return false; + break; + case CC_ITEMBOX_TEXT: + if ((element == "") || ((onlyOneTextElement) && (has_TextElement))) + return false; + else + has_TextElement = true; + break; + default: + break; + } + + data.type = type; + data.align = align; + data.element = element; + data.x = x; + data.y = y; + data.width = 0; + data.height = 0; + data.handler1 = NULL; + data.handler2 = NULL; + + v_element_data.push_back(data); + if (index != NULL) + *index = v_element_data.size()-1; + isCalculated = false; + return true; +} + +void CComponentsItemBox::refreshElement(size_t index, const std::string& element) +{ + CComponentsPicture* pic = NULL; + switch (v_element_data[index].type) { + case CC_ITEMBOX_PICTURE: + pic = static_cast(v_element_data[index].handler1); + if (pic != NULL) { + pic->hide(); + delete pic; + } + v_element_data[index].element = element; + v_element_data[index].x = x; + v_element_data[index].y = y; + v_element_data[index].width = 0; + v_element_data[index].height = 0; + v_element_data[index].handler1 = NULL; + v_element_data[index].handler2 = NULL; + break; + default: + break; + } + calculateElements(); +} + +//paint image into item box +void CComponentsItemBox::paintImage(size_t index, bool newElement) +{ + CComponentsPicture* pic = NULL; + pic = static_cast(v_element_data[index].handler1); + + int pw = 0, ph = 0; + + if ((newElement) || (pic == NULL)) { + if (pic != NULL) { + pic->hide(); + delete pic; + pic = NULL; + } + if ((v_element_data[index].type) == CC_ITEMBOX_PICTURE) + pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, v_element_data[index].width, + v_element_data[index].height, v_element_data[index].element); + else + pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, 0, 0, v_element_data[index].element); + v_element_data[index].handler1 = (void*)pic; + } + + pic->getPictureSize(&pw, &ph); + pic->setHeight(ph); + pic->setWidth(pw); + pic->setColorBody(col_body); + pic->paint(); +} + +//paint text into item box +void CComponentsItemBox::paintText(size_t index, bool newElement) +{ + //prepare textbox dimension instances + CBox* box = NULL; + box = static_cast(v_element_data[index].handler1); + + if ((newElement) || (box == NULL)) { + if (box != NULL) { + delete box; + box = NULL; + } + box = new CBox(); + v_element_data[index].handler1 = (void*)box; + } + + box->iX = v_element_data[index].x; + box->iY = v_element_data[index].y; + box->iWidth = v_element_data[index].width; + box->iHeight = v_element_data[index].height; + + + //prepare text + CTextBox* textbox = NULL; + textbox = static_cast(v_element_data[index].handler2); + + if ((newElement) || (textbox == NULL)) { + if (textbox != NULL) { + textbox->hide(); + delete textbox; + textbox = NULL; + } + textbox = new CTextBox(v_element_data[index].element.c_str(), font_text, CTextBox::AUTO_WIDTH|CTextBox::AUTO_HIGH, box, col_body); + v_element_data[index].handler2 = (void*)textbox; + } + + textbox->setTextBorderWidth(0); + textbox->enableBackgroundPaint(false); + textbox->setTextFont(font_text); + textbox->movePosition(box->iX, box->iY); + textbox->setTextColor(it_col_text); + + if (textbox->setText(&v_element_data[index].element)) + textbox->paint(); +} + + +//paint available elements at one task +void CComponentsItemBox::paintElement(size_t index, bool newElement) +{ + switch (v_element_data[index].type) { + case CC_ITEMBOX_ICON: + case CC_ITEMBOX_PICTURE: + paintImage(index,newElement); + break; + case CC_ITEMBOX_TEXT: + paintText(index,newElement); + break; + case CC_ITEMBOX_CLOCK: + font_text->RenderString(v_element_data[index].x, v_element_data[index].y, v_element_data[index].width, + v_element_data[index].element.c_str(), it_col_text); + break; + default: + break; + } +} + +void CComponentsItemBox::calSizeOfElements() +{ + size_t i; + + // Set element size + for (i = 0; i < v_element_data.size(); i++) { + switch (v_element_data[i].type) + { + case CC_ITEMBOX_ICON: + frameBuffer->getIconSize(v_element_data[i].element.c_str(), &v_element_data[i].width, &v_element_data[i].height); + break; + case CC_ITEMBOX_PICTURE: + g_PicViewer->getSize(v_element_data[i].element.c_str(), &v_element_data[i].width, &v_element_data[i].height); + break; + case CC_ITEMBOX_TEXT: + if (font_text != NULL) + v_element_data[i].height = font_text->getHeight(); + break; + case CC_ITEMBOX_CLOCK: { + if (!g_Sectionsd->getIsTimeSet()) + break; + if (font_text != NULL) { + char timestr[10] = {0}; + time_t now = time(NULL); + struct tm *tm = localtime(&now); + strftime(timestr, sizeof(timestr)-1, "%H:%M", tm); + + digit_h = font_text->getDigitHeight(); + digit_offset = font_text->getDigitOffset(); + v_element_data[i].height = digit_h + (int)((float)digit_offset*1.5); +// v_element_data[i].width = font_text->getRenderWidth(widest_number)*4 + font->getRenderWidth(":"); + v_element_data[i].width = font_text->getRenderWidth(timestr); + v_element_data[i].element = timestr; + } + } + break; + default: + break; + } + } + + // Calculate largest height without CC_ITEMBOX_PICTURE + firstElementLeft = FIRST_ELEMENT_INIT; + firstElementRight = FIRST_ELEMENT_INIT; + for (i = 0; i < v_element_data.size(); i++) { + if ((firstElementLeft == FIRST_ELEMENT_INIT) && (v_element_data[i].align == CC_ALIGN_LEFT)) + firstElementLeft = i; + if ((firstElementRight == FIRST_ELEMENT_INIT) && (v_element_data[i].align == CC_ALIGN_RIGHT)) + firstElementRight = i; + if (v_element_data[i].type != CC_ITEMBOX_PICTURE) + hMax = max(v_element_data[i].height, hMax); + } +} + +void CComponentsItemBox::calPositionOfElements() +{ + size_t i; + + // Calculate y-positions + height = hMax + 2*vOffset; + for (i = 0; i < v_element_data.size(); i++) { + v_element_data[i].y = y + (height - v_element_data[i].height) / 2; + if (v_element_data[i].type == CC_ITEMBOX_CLOCK) + v_element_data[i].y += v_element_data[i].height + digit_offset/4; + } + + // Calculate x-positions + for (i = 0; i < v_element_data.size(); i++) { + if (firstElementLeft == i){ + prevElementLeft = i; + v_element_data[i].x = x + hOffset + corner_rad/2; + } + else if (firstElementRight == i){ + prevElementRight = i; + v_element_data[i].x = x + width - v_element_data[i].width - hOffset - corner_rad/2; + } + else { + if (v_element_data[i].align == CC_ALIGN_LEFT) { + // left elements + v_element_data[i].x = v_element_data[prevElementLeft].x + v_element_data[prevElementLeft].width + hSpacer; + prevElementLeft = i; + } + else { + // right elements + v_element_data[i].x = v_element_data[prevElementRight].x - v_element_data[i].width - hSpacer; + prevElementRight = i; + } + } + } +} + +void CComponentsItemBox::calculateElements() +{ + if (v_element_data.empty()) + return; + + size_t i; + + calSizeOfElements(); + + // hMax correction if no text element. + if (!has_TextElement) + hMax = max(font_text->getHeight(), hMax); + + // Calculate logo + for (i = 0; i < v_element_data.size(); i++) { + if (v_element_data[i].type == CC_ITEMBOX_PICTURE) { + if ((v_element_data[i].width > LOGO_MAX_WIDTH) || (v_element_data[i].height > hMax)) + g_PicViewer->rescaleImageDimensions(&v_element_data[i].width, &v_element_data[i].height, LOGO_MAX_WIDTH, hMax); + } + } + + // Calculate text width + int allWidth = 0; + for (i = 0; i < v_element_data.size(); i++) { + if (v_element_data[i].type != CC_ITEMBOX_TEXT) + allWidth += v_element_data[i].width + hSpacer; + } + for (i = 0; i < v_element_data.size(); i++) { + if (v_element_data[i].type == CC_ITEMBOX_TEXT) { + v_element_data[i].width = width - (allWidth + 2*hSpacer); + // If text is too long, number of rows = 2 + if (font_text->getRenderWidth(v_element_data[i].element) > v_element_data[i].width) { + v_element_data[i].height = font_text->getHeight() * 2; + hMax = max(v_element_data[i].height, hMax); + } + break; + } + } + + calPositionOfElements(); + isCalculated = true; +} + +void CComponentsItemBox::paintItemBox(bool do_save_bg) +{ + // paint background + paintInit(do_save_bg); + + if ((v_element_data.empty()) || (!paintElements)) + return; + + // paint elements + for (size_t i = 0; i < v_element_data.size(); i++) + paintElement(i); +} + +void CComponentsItemBox::clearTitlebar() +{ + clearElements(); + paintElements = false; + paint(false); + paintElements = true; +} + + + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsTitleBar from CComponentsItemBox +CComponentsTitleBar::CComponentsTitleBar() +{ + //CComponentsTitleBar + initVarTitleBar(); +} + +void CComponentsTitleBar::initVarTitleBar() +{ + //CComponentsItemBox + initVarItemBox(); + onlyOneTextElement = true; + + font_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; + it_col_text = COL_MENUHEAD; + + //CComponents + x = 0; + y = 0; + height = font_text->getHeight() + 2*hSpacer; + width = frameBuffer->getScreenWidth(true);; + col_body = COL_MENUHEAD_PLUS_0; + corner_type = CORNER_TOP; + corner_rad = RADIUS_LARGE; + + //CComponentsTitleBar + tb_text_align = CC_ALIGN_LEFT; + tb_icon_align = CC_ALIGN_LEFT; + tb_c_text = NULL; + tb_s_text = ""; + tb_locale_text = NONEXISTANT_LOCALE; + tb_icon_name = ""; +} + +CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, const char* c_text, const std::string& s_icon, + fb_pixel_t color_text, fb_pixel_t color_body) +{ + //CComponentsItemBox + initVarTitleBar(); + it_col_text = color_text; + + //CComponents + x = x_pos; + y = y_pos; + height = h; + width = w; + col_body = color_body; + + //CComponentsTitleBar + tb_c_text = c_text; + tb_icon_name = s_icon; + + initElements(); +} + +CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, const string& s_text, const std::string& s_icon, + fb_pixel_t color_text, fb_pixel_t color_body) +{ + //CComponentsItemBox + initVarTitleBar(); + it_col_text = color_text; + + //CComponents + x = x_pos; + y = y_pos; + height = h; + width = w; + col_body = color_body; + + //CComponentsTitleBar + tb_s_text = s_text; + tb_icon_name = s_icon; + + initElements(); +} + +CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text, const std::string& s_icon, + fb_pixel_t color_text, fb_pixel_t color_body) +{ + //CComponentsItemBox + initVarTitleBar(); + it_col_text = color_text; + + //CComponents + x = x_pos; + y = y_pos; + height = h; + width = w; + col_body = color_body; + + //CComponentsTitleBar + tb_locale_text = locale_text; + tb_s_text = g_Locale->getText(tb_locale_text); + tb_icon_name = s_icon; + + initElements(); +} + +///basic init methodes for constructors *************************************** +void CComponentsTitleBar::initIcon() +{ + if (!tb_icon_name.empty()) + addElement (tb_icon_align, CC_ITEMBOX_ICON, tb_icon_name); +} + +void CComponentsTitleBar::initText() +{ + if (tb_c_text){ + addElement (tb_text_align, CC_ITEMBOX_TEXT, tb_c_text); + return; + } + else if (!tb_s_text.empty()){ + addElement (tb_text_align, CC_ITEMBOX_TEXT, tb_s_text); + return; + } +} + +void CComponentsTitleBar::initElements() +{ + initIcon(); + initText(); +} +///***************************************************************************** + +void CComponentsTitleBar::paint(bool do_save_bg) +{ + calculateElements(); + paintItemBox(do_save_bg); +} diff --git a/src/gui/components/cc_item_infobox.cpp b/src/gui/components/cc_item_infobox.cpp new file mode 100644 index 000000000..fb8eaa9c0 --- /dev/null +++ b/src/gui/components/cc_item_infobox.cpp @@ -0,0 +1,141 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" + +using namespace std; + +//sub class CComponentsInfoBox from CComponentsItem +CComponentsInfoBox::CComponentsInfoBox() +{ + //CComponentsInfoBox + initVarInfobox(); +} + +CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, + const char* info_text, const int mode, Font* font_text, + bool has_shadow, + fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsInfoBox + initVarInfobox(); + + x = x_pos; + y = y_pos; + width = w; + height = h; + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + ct_text = info_text; + ct_text_mode = mode; + ct_font = font_text; + ct_col_text = color_text; +} + +CComponentsInfoBox::~CComponentsInfoBox() +{ + hide(); + clearSavedScreen(); + clearCCText(); + delete pic; + delete cctext; + clear(); +} + +void CComponentsInfoBox::initVarInfobox() +{ + //CComponents, CComponentsItem, CComponentsText + initVarText(); + cc_item_type = CC_ITEMTYPE_TEXT_INFOBOX; + + //CComponentsInfoBox + pic = NULL; + cctext = NULL; + pic_name = ""; + x_offset = 10; + x_text = x+fr_thickness+x_offset;; + +} + +void CComponentsInfoBox::paintPicture() +{ + //ensure empty pic object + if (pic) + delete pic; + pic = NULL; + + //exit if no image definied + if (pic_name == "") + return; + + //init pic object and set icon paint position + pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, 0, 0, ""); + + //define icon + pic->setPicture(pic_name); + + //fit icon into infobox + pic->setHeight(height-2*fr_thickness); + pic->setColorBody(col_body); + + pic->paint(CC_SAVE_SCREEN_NO); +} + +void CComponentsInfoBox::paint(bool do_save_bg) +{ + paintInit(do_save_bg); + paintPicture(); + + //define text x position + x_text = x+fr_thickness+x_offset; + + //set text to the left border if picture is not painted + if ((pic) && (pic->isPicPainted())){ + int pic_w = pic->getWidth(); + x_text += pic_w+x_offset; + } + + //set text and paint text lines + if (ct_text){ + if (cctext) + delete cctext; + + cctext = new CComponentsText(); + cctext->setText(ct_text, ct_text_mode, ct_font); + cctext->doPaintTextBoxBg(false); + cctext->setDimensionsAll(x_text, y+fr_thickness, width-(x_text-x+x_offset+fr_thickness), height-2*fr_thickness); + cctext->paint(CC_SAVE_SCREEN_NO); + } +} diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp new file mode 100644 index 000000000..215039324 --- /dev/null +++ b/src/gui/components/cc_item_picture.cpp @@ -0,0 +1,193 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" +#include + +extern CPictureViewer * g_PicViewer; + +using namespace std; + + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsPicture from CComponentsItem +CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h, + const std::string& image_name, const int alignment, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) +{ + init(x_pos, y_pos, image_name, alignment, has_shadow, color_frame, color_background, color_shadow); + + width = w; + height = h; + pic_paint_mode = CC_PIC_IMAGE_MODE_AUTO, + + initVarPicture(); +} + +void CComponentsPicture::init( int x_pos, int y_pos, const string& image_name, const int alignment, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) +{ + //CComponents, CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_PICTURE; + + //CComponentsPicture + pic_name = image_name; + pic_align = alignment; + pic_offset = 1; + pic_paint = true; + pic_paintBg = false; + pic_painted = false; + do_paint = false; + pic_max_w = 0; + pic_max_h = 0; + if (pic_name.empty()) + pic_width = pic_height = 0; + + //CComponents + x = pic_x = x_pos; + y = pic_y = y_pos; + height = 0; + width = 0; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_background; + col_shadow = color_shadow; +} + +void CComponentsPicture::setPicture(const std::string& picture_name) +{ + pic_name = picture_name; + initVarPicture(); +} + + +void CComponentsPicture::setPictureAlign(const int alignment) +{ + pic_align = alignment; + initVarPicture(); +} + + +void CComponentsPicture::initVarPicture() +{ + pic_width = pic_height = 0; + pic_painted = false; + do_paint = false; + + if (pic_name == "") + return; + + if (pic_max_w == 0) + pic_max_w = width-2*fr_thickness; + + if (pic_max_h == 0) + pic_max_h = height-2*fr_thickness; + + //set the image mode depends of name syntax, icon names contains no path, + //so we can detect the required image mode + if (pic_paint_mode == CC_PIC_IMAGE_MODE_AUTO){ + if (!access(pic_name.c_str(), F_OK )) + pic_paint_mode = CC_PIC_IMAGE_MODE_ON; + else + pic_paint_mode = CC_PIC_IMAGE_MODE_OFF; + } + + if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF){ + frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height); +#if 0 + pic_width = max(pic_width, pic_max_w); + pic_height = max(pic_height, pic_max_h); +#endif + } + + if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON) { + g_PicViewer->getSize(pic_name.c_str(), &pic_width, &pic_height); + if((pic_width > pic_max_w) || (pic_height > pic_max_h)) + g_PicViewer->rescaleImageDimensions(&pic_width, &pic_height, pic_max_w, pic_max_h); + } + +#ifdef DEBUG_CC + if (pic_width == 0 || pic_height == 0) + printf("[CComponentsPicture] %s file: %s, no icon dimensions found! width = %d, height = %d\n", __FUNCTION__, pic_name.c_str(), pic_width, pic_height); +#endif + + pic_x += fr_thickness; + pic_y += fr_thickness; + + if (pic_height>0 && pic_width>0){ + if (pic_align & CC_ALIGN_LEFT) + pic_x = x+fr_thickness; + if (pic_align & CC_ALIGN_RIGHT) + pic_x = x+width-pic_width-fr_thickness; + if (pic_align & CC_ALIGN_TOP) + pic_y = y+fr_thickness; + if (pic_align & CC_ALIGN_BOTTOM) + pic_y = y+height-pic_height-fr_thickness; + if (pic_align & CC_ALIGN_HOR_CENTER) + pic_x = x+width/2-pic_width/2; + if (pic_align & CC_ALIGN_VER_CENTER) + pic_y = y+height/2-pic_height/2; + + do_paint = true; + } + + int sw = (shadow ? shadow_w :0); + width = max(max(pic_width, pic_max_w), width) + sw ; + height = max(max(pic_height, pic_max_h), height) + sw ; +} + +void CComponentsPicture::paint(bool do_save_bg) +{ + initVarPicture(); + paintInit(do_save_bg); + pic_painted = false; + +#ifdef DEBUG_CC + printf(" [CComponentsPicture] %s: paint image: %s (do_paint=%d)\n", __FUNCTION__, pic_name.c_str(), do_paint); +#endif + + if (do_paint){ + if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF) + pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0 /*pic_max_h*/, pic_offset, pic_paint, pic_paintBg, col_body); + else if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON) + pic_painted = g_PicViewer->DisplayImage(pic_name, pic_x, pic_y, pic_width, pic_height); + do_paint = false; + } +} + +void CComponentsPicture::hide(bool no_restore) +{ + hideCCItem(no_restore); + pic_painted = false; +} diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp new file mode 100644 index 000000000..c589b5953 --- /dev/null +++ b/src/gui/components/cc_item_progressbar.cpp @@ -0,0 +1,272 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + (C) 2008, 2013 by Thilo Graf + (C) 2009,2010,2013 Stefan Seyfried + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "cc_item_progressbar.h" + +#define ITEMW 4 +#define POINT 2 + +#define RED 0xFF0000 +#define GREEN 0x00FF00 +#define YELLOW 0xFFFF00 + +CProgressBar::CProgressBar() +{ + initVarProgressbar(); +} + +CProgressBar::CProgressBar( const int x_pos, const int y_pos, const int w, const int h, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow, + const fb_pixel_t active_col, const fb_pixel_t passive_col, + const bool blinkenlights, + const int r, const int g, const int b, + const bool inv) +{ + initVarProgressbar(); + + //CComponents + x = x_pos; + y = y_pos; + width = w; + height = h; + + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + pb_blink = blinkenlights; + pb_invert = inv; + pb_red = r; + pb_green = g; + pb_yellow = b; + pb_active_col = active_col; + pb_passive_col = passive_col; +} + + +void CProgressBar::initVarProgressbar() +{ + //CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_PROGRESSBAR; + + //CProgressBar + pb_blink = false; + pb_invert = false; + pb_bl_changed = g_settings.progressbar_color; + pb_last_width = -1; + pb_red = 40; + pb_green = 100; + pb_yellow = 70; + pb_active_col = COL_INFOBAR_PLUS_7; + pb_passive_col = COL_INFOBAR_PLUS_3; + pb_value = 0; + pb_max_value = 0; + pb_paint_zero = false; + + // init start positions x/y active bar + pb_x = x + fr_thickness; + pb_y = y + fr_thickness; + pb_active_width = 0; + pb_max_width = width - 2*fr_thickness; + pb_height = 0; + pb_start_x_passive = 0; + pb_passive_width = width; +} + +//calculate bar dimensions +void CProgressBar::initDimensions() +{ + //prevent stupid callers, can give invalid values like "-1"... + if (pb_value < 0) + pb_value = 0; + if (pb_value > pb_max_value) + pb_max_value = pb_value; + + // start positions x/y active bar + pb_x = (cc_item_xr > -1 ? cc_item_xr : x) + fr_thickness; + pb_y = (cc_item_yr > -1 ? cc_item_yr : y) + fr_thickness; + + // width for active bar with current value + pb_active_width = max(0, pb_last_width); + if (pb_max_value) + pb_active_width = (width - 2*fr_thickness) * pb_value / pb_max_value; + + // max width active/passive bar + pb_max_width = width - 2*fr_thickness; + + // max height of active/passive bar + pb_height = height - 2*fr_thickness; + + pb_start_x_passive = pb_x + pb_active_width; + + pb_passive_width = pb_max_width - pb_active_width; + + // background = frame + if ( col_frame == 0 ) + col_frame = pb_active_col; +} + + +void CProgressBar::paintSimple() +{ + // progress value + if (pb_active_width != pb_last_width){ + frameBuffer->paintBoxRel(pb_x, pb_y, pb_active_width, pb_height, pb_active_col); // active bar + frameBuffer->paintBoxRel(pb_start_x_passive, pb_y, pb_passive_width, pb_height, pb_passive_col); // passive bar + } + + if (pb_paint_zero && pb_value == 0) + frameBuffer->paintLine(pb_x , pb_y, pb_x+width-3, pb_y+height-3, pb_active_col); // zero line +} + +void CProgressBar::paintAdvanced() +{ + int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT; + if(g_settings.progressbar_color){ + switch ((pb_color_t)g_settings.progressbar_design){ + default: + case PB_MATRIX: // ::::: matrix + break; + case PB_LINES_V: // ||||| vert. lines + itemh = pb_height; + pointy = pb_height; + break; + case PB_LINES_H: // ===== horiz. lines + itemw = POINT; + break; + case PB_COLOR: // filled color + itemw = POINT; + itemh = pb_height; + pointy = pb_height; + break; + } + } + + const int spc = itemh - pointy; /* space between horizontal lines / points */ + int hcnt = (pb_height + spc) / itemh; /* how many POINTs is the bar high */ + int yoff = (pb_height + spc - itemh * hcnt) / 2; + + //printf("height: %d itemh: %d hcnt: %d yoff: %d spc: %d\n", height, itemh, hcnt, yoff, spc); + /* red, yellow, green are given in percent */ + int rd = pb_red * pb_max_width / (100 * itemw); /* how many POINTs red */ + int yw = pb_yellow * pb_max_width / (100 * itemw); /* how many POINTs yellow */ + int gn = pb_green * pb_max_width / (100 * itemw); /* how many POINTs green */ + + int maxi = pb_active_width / itemw; /* how many POINTs is the active bar */ + int total = pb_max_width / itemw; /* total number of POINTs */ + + uint32_t rgb; + fb_pixel_t color; + + if (pb_active_width != pb_last_width) { + int i, j; + const int py = pb_y + yoff; + if (pb_active_width > pb_last_width) { + int step, off; + int b = 0; + uint8_t diff = 0; + for (i = 0; (i < rd) && (i < maxi); i++) { + diff = i * 255 / rd; + if (pb_invert) + rgb = GREEN + (diff << 16); // adding red + else + rgb = RED + (diff << 8); // adding green + color = make16color(rgb); + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color); + } + step = yw - rd - 1; + if (step < 1) + step = 1; + for (; (i < yw) && (i < maxi); i++) { + diff = b++ * 255 / step / 2; + if (pb_invert) + rgb = YELLOW - (diff << 8); // removing green + else + rgb = YELLOW - (diff << 16); // removing red + color = make16color(rgb); + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color); + } + off = diff; + b = 0; + step = gn - yw - 1; + if (step < 1) + step = 1; + for (; (i < gn) && (i < maxi); i++) { + diff = b++ * 255 / step / 2 + off; + if (pb_invert) + rgb = YELLOW - (diff << 8); // removing green + else + rgb = YELLOW - (diff << 16); // removing red + color = make16color(rgb); + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color); + } + } + for(i = maxi; i < total; i++) { + for (j = 0; j < hcnt; j++) + frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, pb_passive_col); //fill passive + } + } +} + + +void CProgressBar::paintProgress(bool do_save_bg) +{ + if(pb_bl_changed != g_settings.progressbar_color) { + pb_bl_changed = g_settings.progressbar_color; + reset(); + } + + initDimensions(); + + //body + if (pb_last_width == -1 && col_body != 0) /* first paint */ + paintInit(do_save_bg); + + //progress + if (!pb_blink || !g_settings.progressbar_color) + paintSimple(); + else + paintAdvanced(); + + if (is_painted) + pb_last_width = pb_active_width; +} + + +void CProgressBar::paint(bool do_save_bg) +{ + paintProgress(do_save_bg); +} diff --git a/src/gui/components/cc_item_progressbar.h b/src/gui/components/cc_item_progressbar.h new file mode 100644 index 000000000..36bb4d26c --- /dev/null +++ b/src/gui/components/cc_item_progressbar.h @@ -0,0 +1,162 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + (C) 2008, 2013 by Thilo Graf + (C) 2009,2010,2013 Stefan Seyfried + + 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +/// +/*! + description of parameters: + + position of progressbar: + x_pos > start position on screen x + y_pos > start position on screen y + pb_width > with of progressbar + pb_height > height of progressbar + + definitions of values: + value > value, you will display + max_value > maximal value that you will display + + appearance: + activebar_col > color of inner bar that shows the current value + passivebar_col > color of passive bar + frame_col > general frame color of progressbar, set 0 for no frame + shadowbar_col color > shadow behind progressbar, set 0 for no shadow + + paintZero > optional, if set to true and value = 0, then paints a diagonal line instead of active bar as symbolic for a zero value +*/ + +#ifndef __CC_PROGRESSBAR_H__ +#define __CC_PROGRESSBAR_H__ + +#include "config.h" +#include +#include + +class CProgressBar : public CComponentsItem +{ + protected: + void initVarProgressbar(); + + private: + ///colors of active and passive bar area, active means the displayed value, passive the neutral area + fb_pixel_t pb_active_col, pb_passive_col; + + int pb_last_width; + + ///width of progress + int pb_active_width, pb_passive_width; + + ///maximal width,heigth of progress + int pb_max_width, pb_height; + + ///start position of bars + int pb_start_x_passive; + + ///color values + int pb_red, pb_green, pb_yellow; + + ///start position of activ/passiv area + int pb_x, pb_y; + + bool pb_blink, pb_invert, pb_bl_changed; + + ///causes a diagonal line as a sign for 0 value instead of an empty bar + bool pb_paint_zero; + + ///to evaluate values, these will be convert to the graph + int pb_value, pb_max_value; + + ///paint simple version of progressbar with simple color modifications + void paintSimple(); + ///paint version of progressbar with color and advanced display modifications + void paintAdvanced(); + + void initDimensions(); + + ///paints graph + void paintProgress(bool do_save_bg = CC_SAVE_SCREEN_NO); + + static inline unsigned int make16color(__u32 rgb){return 0xFF000000 | rgb;}; + + public: + ///parameters: + ///x_pos, y_pos, w, h: position and dimension in pixel + ///blinkenlights: true if you want code to follow progressbar_color. needed, no default. + ///w, h: width / height of bar. Can later be set with paintProgressbar. + ///r, g, b: percentage of the bar where red/green/yellow is used, only used if blinkenlights (colored) == true. + ///inv: false => red on the left side, true: red on right side. + ///active_col, passive_col: sets colors for displayed values, activ_col means the the displayed progress + ///color_frame, color_body, color_shadow: colores of progressbar for frame, body and shadow, Note: color of frame is ineffective on fr_thickness = 0 + CProgressBar(); + CProgressBar( const int x_pos, const int y_pos, + const int w = -1, const int h = -1, + fb_pixel_t color_frame = 0, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0, + const fb_pixel_t active_col = COL_INFOBAR_PLUS_7, const fb_pixel_t passive_col = COL_INFOBAR_PLUS_3, + const bool blinkenlights = false, + const int r = 40, const int g = 100, const int b =70, + const bool inv = false ); + + + ///set up to display available values + void setValue(const int val){ pb_value = val;}; + void setMaxValue(const int max_val){pb_max_value = max_val;}; + ///set up booth values to display at once + void setValues(const int val, const int max_val){pb_value = val; pb_max_value = max_val;}; + + ///causes painting a diagonal line if value = 0, Note: ineffective in colored mode + void setZeroLine(bool paint_zero_line = true){pb_paint_zero = paint_zero_line;}; + + ///setters for status colors + void setActiveColor(fb_pixel_t active_color) {pb_active_col = active_color;}; + void setPassiveColor(fb_pixel_t passive_color) {pb_passive_col = passive_color;}; + ///set up booth status colors at once + void setStatusColors(fb_pixel_t active_color, fb_pixel_t passive_color) {pb_passive_col = passive_color; pb_active_col = active_color;}; + + ///invert: false => red on the left side, true: red on right side. + void setInvert(bool inverted = true){pb_invert = inverted;}; + + ///blinkenlights: true (default) if you want code to follow progressbar_color. + void setBlink(bool blinkenlights = true){pb_blink = blinkenlights;}; + ///r, g, b: percentage of the bar where red/green/yellow is used, only used if blinkenlights (colored) == true. + void setRgb(const int r, const int g, const int b){pb_red = r; pb_green = g; pb_yellow = b;}; + + ///x, y, width, height, value, max_value: set most wanted parameters at once + void setProgress(const int x_pos, const int y_pos, + const int w, const int h, + const int val, const int max_val){x=x_pos; y=y_pos; width=w; height=h; pb_value=val; pb_max_value=max_val;}; + + ///force update on next paint + void reset() { pb_last_width = -1; } + void paint(bool do_save_bg = CC_SAVE_SCREEN_NO); + + enum pb_color_t { + PB_MATRIX = 0, /* 0 */ + PB_LINES_V, /* 1 */ + PB_LINES_H, /* 2 */ + PB_COLOR /* 3 */ + }; + +}; + +#endif /* __CC_PROGRESSBAR_H__ */ diff --git a/src/gui/components/cc_item_shapes.cpp b/src/gui/components/cc_item_shapes.cpp new file mode 100644 index 000000000..abe5826d2 --- /dev/null +++ b/src/gui/components/cc_item_shapes.cpp @@ -0,0 +1,101 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" + +using namespace std; + +//sub class CComponentsShapeSquare from CComponentsItem +CComponentsShapeSquare::CComponentsShapeSquare(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_SHAPE_SQUARE; + + x = x_pos; + y = y_pos; + width = w; + height = h; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; +} + +void CComponentsShapeSquare::paint(bool do_save_bg) +{ + paintInit(do_save_bg); +} + + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsShapeCircle from CComponentsItem +CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponents, CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_SHAPE_CIRCLE; + + //CComponents + x = x_pos; + y = y_pos; + //width = height = d = diam; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + //CComponentsShapeCircle + width = height = d = diam; + + //CComponentsItem + corner_rad = d/2; +} + +// y +// x+ - + +// +// +// +// |----d-i-a-m----| +// +// +// +// + - + + +void CComponentsShapeCircle::paint(bool do_save_bg) +{ + paintInit(do_save_bg); +} diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp new file mode 100644 index 000000000..580a10f16 --- /dev/null +++ b/src/gui/components/cc_item_text.cpp @@ -0,0 +1,232 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" +#include + +using namespace std; + +//sub class CComponentsText from CComponentsItem +CComponentsText::CComponentsText() +{ + //CComponentsText + initVarText(); +} + +CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, const int h, + const char* text, const int mode, Font* font_text, + bool has_shadow, + fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + //CComponentsText + initVarText(); + + //CComponents + x = x_pos, + y = y_pos, + width = w; + height = h; + + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + shadow = has_shadow; + + ct_font = font_text; + ct_text = text; + ct_text_mode = mode; + ct_col_text = color_text; +} + + + +CComponentsText::~CComponentsText() +{ + hide(); + clearSavedScreen(); + clearCCText(); + clear(); +} + + +void CComponentsText::initVarText() +{ + //CComponents, CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_TEXT; + + //CComponentsText + ct_font = NULL; + ct_box = NULL; + ct_textbox = NULL; + ct_text = NULL; + ct_text_mode = CTextBox::AUTO_WIDTH; + ct_col_text = COL_MENUCONTENT; + ct_text_sent = false; + ct_paint_textbg = true; +} + + +void CComponentsText::initCCText() +{ + //set default font, if is no font definied + if (ct_font == NULL) + ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]; + + //define height from font size + height = max(height, ct_font->getHeight()); + + //text box dimensions + if (ct_box== NULL){ + //ensure that we have a new instance + delete ct_box; + ct_box = NULL; + } + ct_box = new CBox(); + ct_box->iX = x+fr_thickness; + ct_box->iY = y+fr_thickness; + ct_box->iWidth = width-2*fr_thickness; + ct_box->iHeight = height-2*fr_thickness; + + //init textbox + if (ct_textbox == NULL) + ct_textbox = new CTextBox(); + + //set text box properties + ct_textbox->setTextFont(ct_font); + ct_textbox->setTextMode(ct_text_mode); + ct_textbox->setWindowPos(ct_box); + ct_textbox->setTextBorderWidth(0); + ct_textbox->enableBackgroundPaint(ct_paint_textbg); + ct_textbox->setBackGroundColor(col_body); + ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type); + ct_textbox->setTextColor(ct_col_text); + ct_textbox->setWindowMaxDimensions(ct_box->iWidth, ct_box->iHeight); + ct_textbox->setWindowMinDimensions(ct_box->iWidth, ct_box->iHeight); + + //set text + string new_text = static_cast (ct_text); + ct_text_sent = ct_textbox->setText(&new_text, ct_box->iWidth); +#ifdef DEBUG_CC + printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, h %d, w %d]\n", __FUNCTION__, __LINE__, ct_text, ct_box->iX, ct_box->iY, height, width); +#endif +} + +void CComponentsText::clearCCText() +{ + if (ct_box) + delete ct_box; + ct_box = NULL; + + if (ct_textbox) + delete ct_textbox; + ct_textbox = NULL; +} + +void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text) +{ + ct_text = g_Locale->getText(locale_text); + ct_text_mode = mode; + ct_font = font_text; +#ifdef DEBUG_CC + printf(" [CComponentsText] [%s - %d] ct_text: %s \n", __FUNCTION__, __LINE__, ct_text); +#endif +} + +void CComponentsText::setText(const char* ctext, const int mode, Font* font_text) +{ + ct_text = ctext; + ct_text_mode = mode; + ct_font = font_text; +#ifdef DEBUG_CC + printf(" [CComponentsText] [%s - %d] text: %s \n", __FUNCTION__, __LINE__, ctext); +#endif +} + +void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text) +{ + setText(stext.c_str(), mode, font_text); +#ifdef DEBUG_CC + printf(" [CComponentsText] [%s - %d] ct_text: %s \n", __FUNCTION__, __LINE__, ct_text); +#endif +} + +void CComponentsText::setText(const int digit, const int mode, Font* font_text) +{ + string s_digit = iToString(digit); + setText(s_digit, mode, font_text); +#ifdef DEBUG_CC + printf(" [CComponentsText] [%s - %d] ct_text: %s \n", __FUNCTION__, __LINE__, ct_text); +#endif +} + +void CComponentsText::paintText(bool do_save_bg) +{ + paintInit(do_save_bg); + initCCText(); + if (ct_text_sent) + ct_textbox->paint(); + ct_text_sent = false; +} + +void CComponentsText::paint(bool do_save_bg) +{ + paintText(do_save_bg); +} + +void CComponentsText::hide(bool no_restore) +{ + + if (ct_textbox) + ct_textbox->hide(); + hideCCItem(no_restore); +} + +//small helper to remove excessiv linbreaks +void CComponentsText::removeLineBreaks(std::string& str) +{ + std::string::size_type spos = str.find_first_of("\r\n"); + while (spos != std::string::npos) { + str.replace(spos, 1, " "); + spos = str.find_first_of("\r\n"); + } +} + + +//helper, converts int to string +string CComponentsText::iToString(int int_val) +{ + ostringstream i_str; + i_str << int_val; + string i_string(i_str.str()); + return i_string; +} diff --git a/src/gui/components/cc_item_tvpic.cpp b/src/gui/components/cc_item_tvpic.cpp new file mode 100644 index 000000000..eedc4e65e --- /dev/null +++ b/src/gui/components/cc_item_tvpic.cpp @@ -0,0 +1,99 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012, Michael Liebmann 'micha-bbg' + + 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "cc.h" + +#include + +extern cVideo * videoDecoder; + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsPIP from CComponentsItem +CComponentsPIP::CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow) +{ + //CComponents, CComponentsItem + initVarItem(); + cc_item_type = CC_ITEMTYPE_PIP; + + //CComponentsPIP + screen_w = frameBuffer->getScreenWidth(true); + screen_h = frameBuffer->getScreenHeight(true); + pic_name = DATADIR; + pic_name += "/neutrino/icons/start.jpg"; + + //CComponents + x = x_pos; + y = y_pos; + width = percent*screen_w/100; + height = percent*screen_h/100; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = COL_BACKGROUND; + col_body = COL_BACKGROUND; + col_shadow = COL_MENUCONTENTDARK_PLUS_0; +} + +CComponentsPIP::~CComponentsPIP() +{ + hide(); + videoDecoder->Pig(-1, -1, -1, -1); + clearSavedScreen(); + clear(); +} + +void CComponentsPIP::paint(bool do_save_bg) +{ + int pig_x = x+fr_thickness; + int pig_y = y+fr_thickness; + int pig_w = width-2*fr_thickness; + int pig_h = height-2*fr_thickness; + + paintInit(do_save_bg); + + if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv){ + videoDecoder->Pig(pig_x+2, pig_y, pig_w, pig_h, screen_w, screen_h); + } + else{ //paint an alternate image if no tv mode available + CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, CC_ALIGN_LEFT); + pic.paint(CC_SAVE_SCREEN_NO); + } + +} + + +void CComponentsPIP::hide(bool no_restore) +{ + videoDecoder->Pig(-1, -1, -1, -1); + hideCCItem(no_restore); +} diff --git a/src/gui/components/cc_misc.h b/src/gui/components/cc_misc.h new file mode 100644 index 000000000..728019abc --- /dev/null +++ b/src/gui/components/cc_misc.h @@ -0,0 +1,113 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Experimental Classes for generic GUI-related components. Not really used. + Copyright (C) 2012, Michael Liebmann 'micha-bbg + Copyright (C) 2012, 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 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. + + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __CC_MISC__ +#define __CC_MISC__ + +#include "config.h" +#include +#include +#include + + +#define FIRST_ELEMENT_INIT 10000 +#define LOGO_MAX_WIDTH width/4 +class CComponentsItemBox : public CComponentsItem +{ + protected: + int hSpacer; + int hOffset; + int vOffset; + int digit_offset, digit_h; + bool paintElements; + bool onlyOneTextElement; + fb_pixel_t it_col_text; + Font* font_text; + int hMax; + bool has_TextElement; + size_t firstElementLeft; + size_t firstElementRight; + size_t prevElementLeft; + size_t prevElementRight; + std::vector v_element_data; + bool isCalculated; + + void clearElements(); + void initVarItemBox(); + void calSizeOfElements(); + void calPositionOfElements(); + void paintItemBox(bool do_save_bg = CC_SAVE_SCREEN_YES); + void calculateElements(); + bool addElement(int align, int type, const std::string& element="", size_t *index=NULL); + void paintImage(size_t index, bool newElement); + void paintText(size_t index, bool newElement); + + public: + CComponentsItemBox(); + virtual ~CComponentsItemBox(); + + inline virtual void setTextFont(Font* font){font_text = font;}; + inline virtual void setTextColor(fb_pixel_t color_text){ it_col_text = color_text;}; + + virtual void refreshElement(size_t index, const std::string& element); + virtual void paintElement(size_t index, bool newElement= false); + virtual bool addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index=NULL); + virtual void clearTitlebar(); + virtual void addText(const std::string& s_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL); + virtual void addText(neutrino_locale_t locale_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL); + virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL); + virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL); + virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL); + virtual int getHeight(); +}; + +class CComponentsTitleBar : public CComponentsItemBox +{ + private: + const char* tb_c_text; + std::string tb_s_text, tb_icon_name; + neutrino_locale_t tb_locale_text; + int tb_text_align, tb_icon_align; + + void initText(); + void initIcon(); + void initElements(); + void initVarTitleBar(); + + public: + CComponentsTitleBar(); + CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const char* c_text = NULL, const std::string& s_icon ="", + fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0); + CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const std::string& s_text ="", const std::string& s_icon ="", + fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0); + CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text = NONEXISTANT_LOCALE, const std::string& s_icon ="", + fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0); + + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + +}; + +#endif /*__CC_MISC__*/ diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h new file mode 100644 index 000000000..3ba4d1c14 --- /dev/null +++ b/src/gui/components/cc_types.h @@ -0,0 +1,133 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2012, 2013, 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 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 + Library 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __CC_TYPES__ +#define __CC_TYPES__ + +#include +#include + +///cc item types +typedef enum +{ + CC_ITEMTYPE_BASE, + CC_ITEMTYPE_PICTURE, + CC_ITEMTYPE_TEXT, + CC_ITEMTYPE_TEXT_INFOBOX, + CC_ITEMTYPE_SHAPE_SQUARE, + CC_ITEMTYPE_SHAPE_CIRCLE, + CC_ITEMTYPE_PIP, + CC_ITEMTYPE_FRM, + CC_ITEMTYPE_FRM_HEADER, + CC_ITEMTYPE_FRM_ICONFORM, + CC_ITEMTYPE_FRM_WINDOW, + CC_ITEMTYPE_LABEL, + CC_ITEMTYPE_PROGRESSBAR, + + CC_ITEMTYPES +}CC_ITEMTYPES_T; + +//required typedefs +typedef struct comp_fbdata_t +{ + int fbdata_type; + int x; + int y; + int dx; + int dy; + fb_pixel_t color; + int r; + int frame_thickness; + fb_pixel_t* pixbuf; + void * data; +} comp_fbdata_struct_t; + +//fb data object types +typedef enum +{ + CC_FBDATA_TYPE_BGSCREEN, + CC_FBDATA_TYPE_SHADOW, + CC_FBDATA_TYPE_BOX, + CC_FBDATA_TYPE_FRAME, + CC_FBDATA_TYPE_LINE, + CC_FBDATA_TYPE_BACKGROUND, + + CC_FBDATA_TYPES +}FBDATA_TYPES; + +typedef struct comp_screen_data_t +{ + int x; + int y; + int dx; + int dy; + fb_pixel_t* pixbuf; +} comp_screen_data_struct_t; + +//align types +enum +{ + CC_ALIGN_RIGHT = 0, + CC_ALIGN_LEFT = 1, + CC_ALIGN_TOP = 2, + CC_ALIGN_BOTTOM = 4, + CC_ALIGN_HOR_CENTER = 8, + CC_ALIGN_VER_CENTER = 16 +}; + +enum +{ + CC_ITEMBOX_ICON, + CC_ITEMBOX_PICTURE, + CC_ITEMBOX_TEXT, + CC_ITEMBOX_CLOCK +}; + +typedef struct comp_element_data_t +{ + int type; + int align; + std::string element; + int x; + int y; + int width; + int height; + void* handler1; + void* handler2; +}comp_element_data_struct_t; + + +#define CC_WIDTH_MIN 16 +#define CC_HEIGHT_MIN 16 +#define CC_SHADOW_ON true +#define CC_SHADOW_OFF false +#define CC_SAVE_SCREEN_YES true +#define CC_SAVE_SCREEN_NO false + +#define CC_NO_INDEX -1 + + + +#endif diff --git a/src/gui/components/components.cpp b/src/gui/components/components.cpp deleted file mode 100644 index 63893826f..000000000 --- a/src/gui/components/components.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - Based up Neutrino-GUI - Tuxbox-Project - Copyright (C) 2001 by Steffen Hehn 'McClean' - - Classes for generic for GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' - Copyright (C) 2012, Michael Liebmann 'micha-bbg' - - License: GPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include "cc.h" - - - - - -//basic class CComponents -CComponents::CComponents(const int x_pos, const int y_pos, const int h, const int w) -{ - x = x_pos; - y = y_pos; - height = h; - width = w; - sw = 0; //shadow width - frameBuffer = CFrameBuffer::getInstance(); - v_screen_val.clear(); -} - -CComponents::~CComponents() -{ - clear(); -} - -//paint framebuffer stuff and fill buffer -void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg) -{ - int i; - for(i=0; i< items_count ;i++){ - if (do_save_bg) - fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy); - v_screen_val.push_back(fbdata[i]); - } - - for(i=0; i< items_count ;i++){ - if (fbdata[i].is_frame) - frameBuffer->paintBoxFrame(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].frame_thickness, fbdata[i].color, fbdata[i].r); - else - frameBuffer->paintBoxRel(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].color, fbdata[i].r); - } -} - -//screen area save -inline fb_pixel_t* CComponents::saveScreen(int ax, int ay, int dx, int dy) -{ - fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; - frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); - return pixbuf; -} - -//restore screen -inline void CComponents::restore() -{ - for(size_t i =0; i< v_screen_val.size() ;i++) { - if (v_screen_val[i].pixbuf != NULL){ - frameBuffer->RestoreScreen(v_screen_val[i].x, v_screen_val[i].y, v_screen_val[i].dx, v_screen_val[i].dy, v_screen_val[i].pixbuf); - delete[] v_screen_val[i].pixbuf; - } - } - v_screen_val.clear(); -} - -//clean old screen buffer -inline void CComponents::clear() -{ - for(size_t i =0; i< v_screen_val.size() ;i++) - if (v_screen_val[i].pixbuf != NULL) - delete[] v_screen_val[i].pixbuf; - v_screen_val.clear(); -} - -//------------------------------------------------------------------------------------------------------- -//sub class CComponentsDetailLine -CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow) -{ - x = x_pos; - width = 16; - thickness = 4; - sw = 1; //shadow width - y = y_pos_top; - y_down = y_pos_down; - h_mark_top = h_mark_top_; - h_mark_down = h_mark_down_; - col_line = color_line; - col_shadow = color_shadow; -} - -CComponentsDetailLine::~CComponentsDetailLine() -{ - clear(); -} - -// y_top (=y) -// xpos +--|h_mark_up -// | -// | -// | -// | -// | -// | -// | -// | -// | -// +--|h_mark_down -// y_down - - -#define DLINE_ITEMS_COUNT 12 -//paint details line with current parameters -void CComponentsDetailLine::paint(bool do_save_bg) -{ - clear(); - - int y_mark_top = y-h_mark_top/2+thickness/2; - int y_mark_down = y_down-h_mark_down/2+thickness/2; - - comp_fbdata_t fbdata[DLINE_ITEMS_COUNT] = - { - /* vertical item mark | */ - {x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_line, 0, NULL, NULL, false, 0}, - {x+width-sw, y_mark_top, sw, h_mark_top, col_shadow, 0, NULL, NULL, false, 0}, - {x+width-thickness-sw, y_mark_top+h_mark_top, thickness+sw, sw , col_shadow, 0, NULL, NULL, false, 0}, - - /* horizontal item line - */ - {x, y, width-thickness-sw, thickness, col_line, 0, NULL, NULL, false, 0}, - {x+thickness, y+thickness, width-2*thickness-sw, sw, col_shadow, 0, NULL, NULL, false, 0}, - - /* vertical connect line [ */ - {x, y+thickness, thickness, y_down-y-thickness, col_line, 0, NULL, NULL, false, 0}, - {x+thickness, y+thickness+sw, sw, y_down-y-thickness-sw, col_shadow, 0, NULL, NULL, false, 0}, - - /* horizontal info line - */ - {x, y_down, width-thickness-sw, thickness, col_line, 0, NULL, NULL, false, 0}, - {x, y_down+thickness, width-thickness-sw, sw, col_shadow, 0, NULL, NULL, false, 0}, - - /* vertical info mark | */ - {x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_line, 0, NULL, NULL, false, 0}, - {x+width-sw, y_mark_down, sw, h_mark_down, col_shadow, 0, NULL, NULL, false, 0}, - {x+width-thickness-sw, y_mark_down+h_mark_down,thickness+sw, sw, col_shadow, 0, NULL, NULL, false, 0}, - }; - - paintFbItems(fbdata, DLINE_ITEMS_COUNT, do_save_bg); -} - -//remove painted lines from screen -void CComponentsDetailLine::hide() -{ - //caching current colors - fb_pixel_t c_tmp1, c_tmp2; - c_tmp1 = col_line; - c_tmp2 = col_shadow; - - //set background color - col_line = col_shadow = COL_BACKGROUND; - - //paint with background and restore, set last used colors - paint(false); - col_line = c_tmp1; - col_shadow = c_tmp2; -} - - -//------------------------------------------------------------------------------------------------------- -//sub class CComponentsInfoBox -CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) -{ - x = x_pos; - y = y_pos; - width = w; - height = h; - rad = 0; - shadow = has_shadow; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; - fr_thickness = 2; - firstPaint = true; - v_infobox_val.clear(); -} - -#define INFOBOX_ITEMS_COUNT 3 -void CComponentsInfoBox::paint(bool do_save_bg, bool fullPaint) -{ - clear(); - rad = RADIUS_LARGE; - - comp_fbdata_t fbdata[INFOBOX_ITEMS_COUNT] = - { - {x+SHADOW_OFFSET, y+SHADOW_OFFSET, width, height, col_shadow, rad, NULL, NULL, false, 0}, - {x, y, width, height, col_frame, rad, NULL, NULL, false, 0}, - {x+fr_thickness, y+fr_thickness, width-2*fr_thickness, height-2*fr_thickness, col_body, rad, NULL, NULL, false, 0}, - }; - - int start = (shadow) ? 0 : 1; - if (firstPaint) { - if (do_save_bg) { - v_infobox_val.clear(); - for(int i = start; i < INFOBOX_ITEMS_COUNT; i++) { - fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy); - v_infobox_val.push_back(fbdata[i]); - fbdata[i].pixbuf = NULL; - } - } - // paint infobox full - paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false); - firstPaint = false; - } - else { - if (fullPaint) - // paint infobox full - paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false); - else - // paint body only - paintFbItems((comp_fbdata_t*)&fbdata[INFOBOX_ITEMS_COUNT - 1], 1, false); - } -} - -//restore infobox -void CComponentsInfoBox::restore(bool clear_) -{ - if (!v_infobox_val.empty()) { - for(size_t i =0; i< v_infobox_val.size() ;i++) { - if (v_infobox_val[i].pixbuf != NULL) { - frameBuffer->RestoreScreen(v_infobox_val[i].x, v_infobox_val[i].y, v_infobox_val[i].dx, v_infobox_val[i].dy, v_infobox_val[i].pixbuf); - if (clear_) - delete[] v_infobox_val[i].pixbuf; - } - } - if (clear_) { - v_infobox_val.clear(); - firstPaint = true; - } - } -} - -void CComponentsInfoBox::hide() -{ - //caching current colors - fb_pixel_t c_tmp1, c_tmp2, c_tmp3; - c_tmp1 = col_body; - c_tmp2 = col_shadow; - c_tmp3 = col_frame; - - //set background color - col_body = col_frame = col_shadow = COL_BACKGROUND; - - //paint with background and restore, set last used colors - paint(false, true); - col_body = c_tmp1; - col_shadow = c_tmp2; - col_frame = c_tmp3; -} diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index e00db49e7..7da5b5cba 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -442,8 +442,11 @@ void CDBoxInfoWidget::paint() //fprintf(stderr, "width: %d offsetw: %d pbw: %d\n", width, offsetw, pbw); if (pbw > 8) /* smaller progressbar is not useful ;) */ { - CProgressBar pb(true, -1, -1, 30, 100, 70, true); - pb.paintProgressBarDefault(x+offsetw, ypos+3, pbw, mheight-10, percent_used, 100); + CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10); + pb.setBlink(); + pb.setInvert(); + pb.setValues(percent_used, 100); + pb.paint(false); } ypos+= mheight; } diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index c7f28069f..41b1105c3 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -642,8 +642,11 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if ( epg_done!= -1 ) { int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); - CProgressBar pb(true, -1, -1, 30, 100, 70, true); - pb.paintProgressBarDefault(pbx, sy+oy-height, 104, height-6, epg_done, 100); + CProgressBar pb(pbx, sy+oy-height, 104, height-6); + pb.setBlink(); + pb.setRgb(0, 100, 70); + pb.setValues(epg_done, 100); + pb.paint(false); } GetPrevNextEPGData( epgData.eventID, &epgData.epg_times.startzeit ); @@ -684,9 +687,12 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if (data == g_InfoViewer->getUpdateTimer()) { GetEPGData(channel_id, id, &startzeit, false); if ( epg_done!= -1 ) { - CProgressBar pb(true, -1, -1, 30, 100, 70, true); - int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); - pb.paintProgressBarDefault(pbx, sy+oy-height, 104, height-6, epg_done, 100); + int pbx = sx + 10 + widthl + 10 + ((ox-104-widthr-widthl-10-10-20)>>1); + CProgressBar pb(pbx, sy+oy-height, 104, height-6); + pb.setBlink(); + pb.setRgb(0, 100, 70); + pb.setValues(epg_done, 100); + pb.paint(false); } } if(data == fader.GetTimer()) { diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 1d9d461e2..de61970b7 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -4,13 +4,6 @@ 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. - License: GPL @@ -104,16 +97,18 @@ CNeutrinoEventList::CNeutrinoEventList() m_search_channel_id = 1; m_search_bouquet_id= 1; - fw = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getWidth(); //font width - fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); //font height - width = w_max (62 * fw, 40); - height = h_max (23 * fh, 20); + full_width = width = fw = 0; + height = fh = 0; - x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; - y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2; + x = y = 0; + cc_infozone = NULL; + infozone_text = ""; item_event_ID = 0; FunctionBarHeight = 0; + oldIndex = -1; + oldEventID = -1; + bgRightBoxPaint = false; } CNeutrinoEventList::~CNeutrinoEventList() @@ -247,6 +242,19 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c showfollow = false; // Calculate iheight struct button_label tmp_button[1] = { { NEUTRINO_ICON_BUTTON_RED, NONEXISTANT_LOCALE } }; + + fw = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getWidth(); //font width + fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); //font height + + full_width = frameBuffer->getScreenWidthRel(); + x = getScreenStartX(full_width); + + if (g_settings.eventlist_additional) + width = full_width / 3 * 2; + else + width = full_width; + height = frameBuffer->getScreenHeightRel(); + iheight = ::paintButtons(0, 0, 0, 1, tmp_button, 0, 0, "", false, COL_INFOBAR_SHADOW, NULL, 0, false); if(iheight < fh) iheight = fh; @@ -269,9 +277,16 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c fwidth1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth("DDD, 00:00, "); fwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth("[999 min] "); - listmaxshow = (height-theight-iheight-0)/fheight; height = theight+iheight+0+listmaxshow*fheight; // recalc height + y = getScreenStartY(height); + + // calculate width of right info_zone + infozone_width = full_width - width; + + // init right info_zone + if (g_settings.eventlist_additional) + cc_infozone = new CComponentsText(x+width+10, y+theight, infozone_width-20, listmaxshow*fheight); int res = menu_return::RETURN_REPAINT; //printf("CNeutrinoEventList::exec: channel_id %llx\n", channel_id); @@ -355,6 +370,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c selected -= step; if((prev_selected-step) < 0) // because of uint selected = evtlist.size() - 1; + paintDescription(selected); } else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown) { @@ -368,6 +384,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c else selected = ((step == (int)listmaxshow) && (selected < (((evtlist.size() / listmaxshow) + 1) * listmaxshow))) ? (evtlist.size() - 1) : 0; } + paintDescription(selected); } paintItem(prev_selected - liststart, channel_id); unsigned int oldliststart = liststart; @@ -588,6 +605,9 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c g_Timerd->getTimerList (timerlist); paintHead(channel_id, channelname); + oldIndex = -1; + oldEventID = -1; + bgRightBoxPaint = false; paint(channel_id); showFunctionBar(true, channel_id); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); @@ -625,6 +645,9 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c timerlist.clear(); g_Timerd->getTimerList (timerlist); paintHead(channel_id,in_search ? search_head_name: channelname); + oldIndex = -1; + oldEventID = -1; + bgRightBoxPaint = false; paint(channel_id); showFunctionBar(true, channel_id); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); @@ -633,6 +656,9 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c } else if (!showfollow && ( msg==CRCInput::RC_green )) { + oldIndex = -1; + oldEventID = -1; + bgRightBoxPaint = false; in_search = findEvents(); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } @@ -651,6 +677,13 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c } } + if (cc_infozone) + delete cc_infozone; + cc_infozone = NULL; + oldIndex = -1; + oldEventID = -1; + bgRightBoxPaint = false; + hide(); fader.Stop(); return res; @@ -658,7 +691,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c void CNeutrinoEventList::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, width,height); + frameBuffer->paintBackgroundBoxRel(x,y, full_width,height); showFunctionBar (false, 0); } @@ -783,22 +816,53 @@ void CNeutrinoEventList::paintItem(unsigned int pos, t_channel_id channel_idI) // paint 2nd line text g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->RenderString(x+10+iw, ypos+ fheight, width- 25- 20 -iw, evtlist[curpos].description, color, 0, true); - - } } + +void CNeutrinoEventList::paintDescription(int index) +{ + if (!g_settings.eventlist_additional) + return; + + if (evtlist[index].eventID == oldEventID) { + if (oldEventID == 0) { + if (index == oldIndex) + return; + } + else + return; + } + oldEventID = evtlist[index].eventID; + oldIndex = index; + + CEPGData epgData; + if ( evtlist[index].eventID != 0 ) + CEitManager::getInstance()->getEPGid(evtlist[index].eventID, evtlist[index].startTime, &epgData); + else + CEitManager::getInstance()->getActualEPGServiceKey(evtlist[index].channelID, &epgData ); + + if(!epgData.info2.empty()) + infozone_text = epgData.info2.c_str(); + else + infozone_text = g_Locale->getText(LOCALE_EPGLIST_NOEVENTS); + + cc_infozone->setText(infozone_text, CTextBox::TOP, g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_EVENT]); + cc_infozone->doPaintBg(false); + cc_infozone->paint(CC_SAVE_SCREEN_NO); +} + void CNeutrinoEventList::paintHead(std::string _channelname, std::string _channelname_prev, std::string _channelname_next) { const short font_h = 8; int iw = 0, ih = 0; frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_INFO, &iw, &ih); - frameBuffer->paintBoxRel(x,y, width,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); - int name_width =((width-8-iw)/3); + frameBuffer->paintBoxRel(x,y, full_width,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); + int name_width =((full_width-8-iw)/3); short prev_len = g_Font[font_h]->getRenderWidth(_channelname_prev.c_str(),true); short next_len = g_Font[font_h]->getRenderWidth(_channelname_next.c_str(),true); short middle_len = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getRenderWidth(_channelname.c_str(),true); - short middle_offset = (width- next_len- prev_len- middle_len-iw-8)/2; + short middle_offset = (full_width- next_len- prev_len- middle_len-iw-8)/2; if(middle_offset < 0){ int fw_h = g_Font[font_h]->getWidth(); int newsize = abs(middle_offset / fw_h) + 1; @@ -810,28 +874,28 @@ void CNeutrinoEventList::paintHead(std::string _channelname, std::string _channe middle_offset = 0; } - g_Font[font_h]->RenderString(x+4,y+theight+1, width, _channelname_prev.c_str(), COL_INFOBAR, 0, true); // UTF-8 - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->RenderString(x+prev_len+middle_offset,y+theight+1, width, _channelname.c_str(), COL_MENUHEAD, 0, true); // UTF-8 - g_Font[font_h]->RenderString(x+(name_width*3)- next_len,y+theight+1, width, _channelname_next.c_str(), COL_INFOBAR, 0, true); // UTF-8 + g_Font[font_h]->RenderString(x+4,y+theight+1, full_width, _channelname_prev.c_str(), COL_INFOBAR, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->RenderString(x+prev_len+middle_offset,y+theight+1, full_width, _channelname.c_str(), COL_MENUHEAD, 0, true); // UTF-8 + g_Font[font_h]->RenderString(x+(name_width*3)- next_len,y+theight+1, full_width, _channelname_next.c_str(), COL_INFOBAR, 0, true); // UTF-8 } void CNeutrinoEventList::paintHead(t_channel_id _channel_id, std::string _channelname) { bool logo_ok = false; - frameBuffer->paintBoxRel(x,y, width,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); + frameBuffer->paintBoxRel(x,y, full_width,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); std::string lname; int logo_w = 0; int logo_h = 0; - int logo_w_max = width / 4; + int logo_w_max = full_width / 4; if(g_settings.infobar_show_channellogo && g_PicViewer->GetLogoName(_channel_id, _channelname, lname, &logo_w, &logo_h)){ if((logo_h > theight) || (logo_w > logo_w_max)) g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, logo_w_max, theight); logo_ok = g_PicViewer->DisplayImage(lname, x+10, y+(theight-logo_h)/2, logo_w, logo_h); } else - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->RenderString(x+15+(logo_ok? 5+logo_w:0),y+theight+1, width, _channelname.c_str(), COL_MENUHEAD, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->RenderString(x+15+(logo_ok? 5+logo_w:0),y+theight+1, full_width, _channelname.c_str(), COL_MENUHEAD, 0, true); // UTF-8 } void CNeutrinoEventList::paint(t_channel_id channel_id) @@ -841,15 +905,23 @@ void CNeutrinoEventList::paint(t_channel_id channel_id) int iw = 0, ih = 0; if (evtlist[0].eventID != 0) { frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_INFO, &iw, &ih); - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_INFO, x+ width - 4 - iw, y, theight); + frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_INFO, x+ full_width - 4 - iw, y, theight); } + // paint background for right box + if (g_settings.eventlist_additional && !bgRightBoxPaint) { + frameBuffer->paintBoxRel(x+width,y+theight,infozone_width,listmaxshow*fheight,COL_MENUCONTENT_PLUS_0); + bgRightBoxPaint = true; + } for(unsigned int count=0;countpaintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); @@ -891,7 +963,7 @@ void CNeutrinoEventList::showFunctionBar (bool show, t_channel_id channel_id) { int border_space = 4; int bx = x + 2*border_space; - int bw = width - 16; + int bw = full_width - 16; int bh = iheight; int by = y + height-iheight; @@ -902,7 +974,7 @@ void CNeutrinoEventList::showFunctionBar (bool show, t_channel_id channel_id) int btn_cnt = 0; bh = std::max(FunctionBarHeight, bh); - frameBuffer->paintBackgroundBoxRel(x,by,width,bh); + frameBuffer->paintBackgroundBoxRel(x,by,full_width,bh); // -- hide only? if (! show) return; @@ -910,7 +982,7 @@ void CNeutrinoEventList::showFunctionBar (bool show, t_channel_id channel_id) frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h); // int fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); - frameBuffer->paintBoxRel(x, by, width, iheight, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_MID, CORNER_BOTTOM); + frameBuffer->paintBoxRel(x, by, full_width, iheight, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_MID, CORNER_BOTTOM); int tID = -1; //any value, not NULL CTimerd::CTimerEventTypes is_timer = isScheduled(channel_id, &evtlist[selected], &tID); @@ -1298,4 +1370,3 @@ bool CEventFinderMenu::changeNotify(const neutrino_locale_t OptionName, void *) return false; } - diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 41a128cfa..530b69e8d 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -4,13 +4,6 @@ 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. - License: GPL @@ -41,6 +34,7 @@ #include #include #include +#include #include "color.h" #include "infoviewer.h" @@ -78,6 +72,9 @@ class CNeutrinoEventList t_bouquet_id m_search_bouquet_id; bool m_showChannel; int FunctionBarHeight; + int oldIndex; + event_id_t oldEventID; + bool bgRightBoxPaint; bool findEvents(void); // Eventfinder end @@ -100,14 +97,17 @@ class CNeutrinoEventList int key; std::string search_head_name; - int width, fw; - int height, fh; + int full_width, width, infozone_width, fw; + int height, infozone_height, fh; int x; int y; + std::string infozone_text; int sort_mode; event_id_t item_event_ID; + CComponentsText *cc_infozone; void paintItem(unsigned pos, t_channel_id channel_id = 0); + void paintDescription(int index); void paint(t_channel_id channel_id = 0); void paintHead(t_channel_id channel_id, std::string name); void paintHead(std::string _channelname, std::string _channelname_prev, std::string _channelname_next); diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 9748d3f57..b1cf1f160 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -1,6 +1,9 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + Implementation of component classes + Copyright (C) 2013, Thilo Graf 'dbt' License: GPL @@ -14,9 +17,10 @@ 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. + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H @@ -28,84 +32,46 @@ #include #include -#include #include -#include #include - +#include +#include +#include #include - #include -#include #include "git_version.h" #define GIT_DESC "GIT Desc.:" #define GIT_REV "GIT Build:" -extern cVideo * videoDecoder; +#define LICENSEDIR DATADIR "/neutrino/license/" + +using namespace std; extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ -CImageInfo::CImageInfo() +CImageInfo::CImageInfo(): config ('\t') { Init(); } -static const neutrino_locale_t info_items[8] = -{ - LOCALE_IMAGEINFO_IMAGE, - LOCALE_IMAGEINFO_DATE, - LOCALE_IMAGEINFO_VERSION, - LOCALE_IMAGEINFO_CREATOR, - LOCALE_IMAGEINFO_HOMEPAGE, - LOCALE_IMAGEINFO_DOKUMENTATION, - LOCALE_IMAGEINFO_FORUM, - LOCALE_IMAGEINFO_LICENSE -}; - +//init all var members void CImageInfo::Init(void) { - frameBuffer = CFrameBuffer::getInstance(); - - font_head = SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME;; - font_small = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL; - font_info = SNeutrinoSettings::FONT_TYPE_MENU; - - hheight = g_Font[font_head]->getHeight(); - iheight = g_Font[font_info]->getHeight(); - sheight = g_Font[font_small]->getHeight(); - - max_width = frameBuffer->getScreenWidth(true); - max_height = frameBuffer->getScreenHeight(true); - - width = frameBuffer->getScreenWidth() - 10; - height = frameBuffer->getScreenHeight() - 10; - x=getScreenStartX( width ); - y=getScreenStartY( height ); - - // calculate max width of used LOCALES - offset = 0; - - for (int i = 0; i < 8; i++) { - int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText (info_items[i])); - if (tmpoffset > offset) { - offset = tmpoffset; - } - } -#ifdef GITVERSION - int off_tmp = g_Font[font_info]->getRenderWidth(GIT_DESC); -#else - int off_tmp = g_Font[font_info]->getRenderWidth(GIT_REV); -#endif - if(off_tmp > offset) - offset = off_tmp; - - offset = offset + 15; + cc_win = NULL; + cc_tv = NULL; + cc_lic = NULL; + item_offset = 20; + item_top = item_offset; + license_txt = ""; + v_info.clear(); + config.loadConfig("/.version"); } CImageInfo::~CImageInfo() { - videoDecoder->Pig(-1, -1, -1, -1); + //deallocate window object, deletes also added cc_items + delete cc_win; } int CImageInfo::exec(CMenuTarget* parent, const std::string &) @@ -114,18 +80,10 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) if (parent) parent->hide(); - width = frameBuffer->getScreenWidth() - 10; - height = frameBuffer->getScreenHeight() - 10; - x=getScreenStartX( width ); - y=getScreenStartY( height ); - - paint(); - - //paint_pig( width-170, y, 215, 170); - paint_pig (width - width/3 - 10, y + 10, width/3, height/3); + //init window object and add cc_items + ShowWindow(); neutrino_msg_t msg; - while (1) { neutrino_msg_data_t data; @@ -141,163 +99,209 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) res = menu_return::RETURN_EXIT_ALL; break; } - else if (msg <= CRCInput::RC_MaxRC) - { + else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_page_up)) { + ScrollLic(false); + } + else if ((msg == CRCInput::RC_down) || (msg == CRCInput::RC_page_down)) { + ScrollLic(true); + } + else if (msg <= CRCInput::RC_MaxRC){ break; } - if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout) - { + if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout){ CNeutrinoApp::getInstance()->handleMsg( msg, data ); } } - hide(); + //hide window + cc_win->hide(); + + //deallocate of the window object causes also deallocate added items, + delete cc_win; + //it's important to set here a null pointer + cc_win = NULL; return res; } -void CImageInfo::hide() +//contains all actions to init and add the window object and items +void CImageInfo::ShowWindow() { - //frameBuffer->paintBackgroundBoxRel(0,0, max_width,max_height); - frameBuffer->paintBackground(); - videoDecoder->Pig(-1, -1, -1, -1); -} - -void CImageInfo::paint_pig(int px, int py, int w, int h) -{ - //frameBuffer->paintBoxRel(px,py,w,h, COL_BACKGROUND); - frameBuffer->paintBackgroundBoxRel(px,py,w,h); - videoDecoder->Pig(px, py, w, h, frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); -} - -void CImageInfo::paintLine(int xpos, int font, const char* text) -{ - char buf[100]; - snprintf((char*) buf,sizeof(buf), "%s", text); - //g_Font[font]->RenderString(xpos, ypos, width-10, buf, COL_MENUCONTENT, 0, true); - g_Font[font]->RenderString(xpos, ypos, width-10, buf, COL_INFOBAR, 0, true); -} - -void CImageInfo::paint() -{ - const char * head_string; - char imagedate[18] = ""; - int xpos = x+10; - - ypos = y+5; - - head_string = g_Locale->getText(LOCALE_IMAGEINFO_HEAD); - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, head_string); - - //frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_MENUHEAD_PLUS_0); - frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_INFOBAR_PLUS_0); - g_Font[font_head]->RenderString(xpos, ypos+ hheight+1, width, head_string, COL_MENUHEAD, 0, true); - - ypos += hheight; - ypos += (iheight >>1); - - CConfigFile config('\t'); - config.loadConfig("/.version"); - - const char * imagename = config.getString("imagename", "Neutrino-HD").c_str(); - const char * homepage = config.getString("homepage", "n/a").c_str(); - const char * creator = config.getString("creator", "n/a").c_str(); - const char * version = config.getString("version", "no version").c_str(); - const char * docs = config.getString("docs", "http://wiki.neutrino-hd.de").c_str(); - const char * forum = config.getString("forum", "http://forum.tuxbox.org").c_str(); -#ifdef GITVERSION - const char * builddate = GITVERSION; -#else - const char * builddate = config.getString("builddate", BUILT_DATE).c_str(); -#endif - - static CFlashVersionInfo versionInfo(version); - const char * releaseCycle = versionInfo.getReleaseCycle(); - - struct utsname uts_info; - std::string Version_Kernel; - if( uname(&uts_info) < 0 ) { - Version_Kernel = releaseCycle; - Version_Kernel += " "; - Version_Kernel += versionInfo.getType(); - }else{ - Version_Kernel = releaseCycle; - Version_Kernel += " "; - Version_Kernel += versionInfo.getType(); - Version_Kernel += " - Kernel: "; - Version_Kernel += uts_info.release; + if (cc_win == NULL){ + cc_win = new CComponentsWindow(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO); + item_top = cc_win->getStartY() + item_offset; + cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); } - snprintf((char*) imagedate,sizeof(imagedate), "%s %s", versionInfo.getDate(), versionInfo.getTime()); + //prepare minitv: important! init the minitv object as first + InitMinitv(); - ypos += iheight; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_IMAGE)); - paintLine(xpos+offset, font_info, imagename); + //prepare infos + InitInfos(); - ypos += iheight; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_DATE)); - paintLine(xpos+offset, font_info, imagedate); + //prepare license text + InitLicenseText(); - ypos += iheight; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_VERSION)); - paintLine(xpos+offset, font_info, Version_Kernel.c_str()); - - ypos += iheight; -#ifdef GITVERSION - paintLine(xpos , font_info, GIT_DESC); -#else - paintLine(xpos , font_info, GIT_REV); -#endif - paintLine(xpos+offset, font_info, builddate ); - - ypos += iheight; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_CREATOR)); - paintLine(xpos+offset, font_info, creator); - - ypos += iheight+15; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_HOMEPAGE)); - paintLine(xpos+offset, font_info, homepage); - - ypos += iheight; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_DOKUMENTATION)); - paintLine(xpos+offset, font_info, docs); - - ypos += iheight; - paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_FORUM)); - paintLine(xpos+offset, font_info, forum); - - ypos += iheight+15; - paintLine(xpos, font_info,g_Locale->getText(LOCALE_IMAGEINFO_LICENSE)); - paintLine(xpos+offset, font_small, "This program is free software; you can redistribute it and/or modify"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "it under the terms of the GNU General Public License as published by"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "the Free Software Foundation; either version 2 of the License, or"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "(at your option) any later version."); - - ypos+= sheight+10; - paintLine(xpos+offset, font_small, "This program is distributed in the hope that it will be useful,"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "but WITHOUT ANY WARRANTY; without even the implied warranty of"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "See the GNU General Public License for more details."); - - ypos+= sheight+10; - paintLine(xpos+offset, font_small, "You should have received a copy of the GNU General Public License"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "along with this program; if not, write to the Free Software"); - - ypos+= sheight; - paintLine(xpos+offset, font_small, "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."); + //paint window + cc_win->paint(); +} + +//prepare minitv +void CImageInfo::InitMinitv() +{ + //init the minitv object + cc_tv = new CComponentsPIP (0, item_top); + + //init width and height + cc_tv->setWidth(cc_win->getWidth()/3); + cc_tv->setHeight(cc_win->getHeight()/3); + + //init x pos and use as parameter for setXPos + int cc_tv_x = (cc_win->getWidth() - cc_tv->getWidth()) - item_offset; + cc_tv->setXPos(cc_tv_x); + + //add minitv to container + cc_win->addCCItem(cc_tv); +} + +//prepare distribution infos +void CImageInfo::InitInfos() +{ + v_info.clear(); + +#ifdef GITVERSION + const char * builddate = GITVERSION; +#else + const char * builddate = config.getString("builddate", BUILT_DATE).c_str(); +#endif + + const char * _version = config.getString("version", "no version").c_str(); + static CFlashVersionInfo versionInfo(_version); + + std::string version_string; + version_string = versionInfo.getReleaseCycle(); + version_string += " "; + version_string += versionInfo.getType(); + + struct utsname uts_info; + + image_info_t imagename = {LOCALE_IMAGEINFO_IMAGE, config.getString("imagename", "Neutrino-HD")}; + v_info.push_back(imagename); + image_info_t date = {LOCALE_IMAGEINFO_DATE, builddate}; + v_info.push_back(date); + image_info_t version = {LOCALE_IMAGEINFO_VERSION, version_string}; + v_info.push_back(version); + if (uname(&uts_info) == 0) { + image_info_t kernel = {LOCALE_IMAGEINFO_KERNEL, uts_info.release}; + v_info.push_back(kernel); + } + image_info_t creator = {LOCALE_IMAGEINFO_CREATOR, config.getString("creator", "n/a")}; + v_info.push_back(creator); + image_info_t www = {LOCALE_IMAGEINFO_HOMEPAGE, config.getString("homepage", "n/a")}; + v_info.push_back(www); + image_info_t doc = {LOCALE_IMAGEINFO_DOKUMENTATION, config.getString("docs", "http://wiki.neutrino-hd.de")}; + v_info.push_back(doc); + image_info_t forum = {LOCALE_IMAGEINFO_FORUM, config.getString("forum", "http://forum.tuxbox.org")}; + v_info.push_back(forum); + image_info_t license = {LOCALE_IMAGEINFO_LICENSE, "GPL"}; + v_info.push_back(license); + + Font * item_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; + + //calculate max width of caption and info_text + int w_caption = 0, w_info_text = 0, w = 0; + for (size_t i = 0; i < v_info.size(); i++) { + w = item_font->getRenderWidth(g_Locale->getText(v_info[i].caption), true); + w_caption = std::max(w_caption, w); + + w = item_font->getRenderWidth(v_info[i].info_text.c_str(), true); + w_info_text = std::max(w_info_text, w); + } + + int x_caption = item_offset; + int x_info_text = x_caption + w_caption + item_offset; + int item_height = item_font->getHeight(); + + //recalc w_info_text to avoid an overlap with pip + w_info_text = std::min(w_info_text, cc_win->getWidth() - x_info_text - cc_tv->getWidth() - 2*item_offset); + + //create label and text items + for (size_t i = 0; i < v_info.size(); i++) { + // add an offset before homepage and license + if (v_info[i].caption == LOCALE_IMAGEINFO_HOMEPAGE || v_info[i].caption == LOCALE_IMAGEINFO_LICENSE) + item_top += item_offset; + + CComponentsLabel *cc_label = new CComponentsLabel(); + cc_label->setDimensionsAll(x_caption, item_top, w_caption, item_height); + cc_label->setText(v_info[i].caption, CTextBox::NO_AUTO_LINEBREAK, item_font); + + //add label to container + cc_win->addCCItem(cc_label); + + CComponentsText *cc_text = new CComponentsText(); + cc_text->setDimensionsAll(x_info_text, item_top, w_info_text, item_height); + cc_text->setText(v_info[i].info_text.c_str(), CTextBox::NO_AUTO_LINEBREAK, item_font); + + //add text to container + cc_win->addCCItem(cc_text); + + item_top += item_height; + } + + item_top += item_offset; +} + +//prepare license infos +void CImageInfo::InitLicenseText() +{ + license_txt = ""; + char line[1024]; + string file = LICENSEDIR; + file += g_settings.language; + file += ".license"; + ifstream in (file.c_str(), ios::in); + + if (!in){ + printf("[CImageInfo] [%s - %d] error while open %s -> %s\n", __FUNCTION__, __LINE__, file.c_str(), strerror(errno)); + return; + } + + while (in.getline (line, sizeof(line)-1)){ + string lline = (string)line; + license_txt += lline + '\n'; + } + in.close(); + + //calc y pos of license box to avoid an overlap with pip + int y_lic = std::max(item_top, cc_tv->getHeight() + 2*item_offset); + cc_lic = new CComponentsInfoBox(item_offset, y_lic, cc_win->getWidth()-2*item_offset, cc_win->getHeight()-item_top-item_offset); + cc_lic->setText(license_txt, CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); + + //add text to container + cc_win->addCCItem(cc_lic); +} + +//scroll licens text +void CImageInfo::ScrollLic(bool scrollDown) +{ + if (cc_lic && (cc_lic->cctext)) { + //get the textbox instance from infobox object and use CTexBbox scroll methods + CTextBox* ctb = cc_lic->cctext->getCTextBoxObject(); + if (ctb) { + ctb->enableBackgroundPaint(true); + if (scrollDown) + ctb->scrollPageDown(1); + else + ctb->scrollPageUp(1); + ctb->enableBackgroundPaint(false); + } + } +} + + + +void CImageInfo::hide() +{ + cc_win->hide(); } diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h index 8f50abe97..a26399fbf 100644 --- a/src/gui/imageinfo.h +++ b/src/gui/imageinfo.h @@ -1,6 +1,9 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + Implementation of component classes + Copyright (C) 2013, Thilo Graf 'dbt' License: GPL @@ -14,47 +17,47 @@ 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. + 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., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. */ #ifndef __imageinfo__ #define __imageinfo__ +#include +#include #include -#include -#include -#include +typedef struct image_info_t +{ + neutrino_locale_t caption; + std::string info_text; + +} image_info_struct_t; class CImageInfo : public CMenuTarget { private: - void Init(void); - CConfigFile * configfile; - CFrameBuffer *frameBuffer; - int x; - int y; - int ypos; - int width; - int height; - int hheight,iheight,sheight; // head/info/small font height + int item_offset; //distance between items and to boarder + int item_top; //start line in y below header + std::string license_txt; - int max_height; // Frambuffer 0.. max - int max_width; + std::vector v_info; - neutrino_locale_t name; - int offset; - - int font_head; - int font_info; - int font_small; - - void paint(); - void paint_pig(int x, int y, int w, int h); - void paintLine(int xpos, int font, const char* text); + void Init(); + void InitMinitv(); + void InitInfos(); + void InitLicenseText(); + void ShowWindow(); + void ScrollLic(bool scrollDown); + + CComponentsWindow *cc_win; + CComponentsPIP *cc_tv; + CComponentsInfoBox *cc_lic; + CConfigFile config; public: diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index b2cbc2b49..d97261679 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -217,19 +217,21 @@ void CInfoViewer::start () void CInfoViewer::changePB() { - const short red_bar = 40; - const short yellow_bar = 70; - const short green_bar = 100; - - if (sigscale != NULL) + if (sigscale) delete sigscale; - sigscale = new CProgressBar(true, bar_width, 10, red_bar, green_bar, yellow_bar); - if (snrscale != NULL) + sigscale = new CProgressBar(); + sigscale->setBlink(); + + if (snrscale) delete snrscale; - snrscale = new CProgressBar(true, bar_width, 10, red_bar, green_bar, yellow_bar); - if (timescale != NULL) + snrscale = new CProgressBar(); + snrscale->setBlink(); + + if (timescale) delete timescale; - timescale = new CProgressBar(true, -1, -1, 30, green_bar, yellow_bar, true); + timescale = new CProgressBar(); + timescale->setBlink(); + timescale->setRgb(0, 100, 70); } void CInfoViewer::paintTime (bool show_dot, bool firstPaint) @@ -1420,7 +1422,10 @@ void CInfoViewer::showSNR () lastsig = sig; posx = BoxStartX + (ChanWidth - (bar_width + 2 + (g_SignalFont->getWidth() * 4))) / 2; posy = freqStartY; - sigscale->paintProgressBar(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100, sig, 100); + sigscale->setDimensionsAll(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100); + sigscale->setColorBody(COL_INFOBAR_PLUS_0); + sigscale->setValues(sig, 100); + sigscale->paint(); snprintf (percent, sizeof(percent), "%d%%S", sig); posx = posx + bar_width + 2; sw = BoxStartX + ChanWidth - posx; @@ -1431,7 +1436,10 @@ void CInfoViewer::showSNR () lastsnr = snr; posx = BoxStartX + (ChanWidth - (bar_width + 2 + (g_SignalFont->getWidth() * 4))) / 2; posy = freqStartY + height - (2 * g_settings.screen_yres / 100); - snrscale->paintProgressBar(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100, snr, 100); + snrscale->setDimensionsAll(posx, posy+4, bar_width, 10 * g_settings.screen_yres / 100); + snrscale->setColorBody(COL_INFOBAR_PLUS_0); + snrscale->setValues(snr, 100); + snrscale->paint(); snprintf (percent, sizeof(percent), "%d%%Q", snr); posx = posx + bar_width + 2; sw = BoxStartX + ChanWidth - posx -4; @@ -1473,12 +1481,12 @@ void CInfoViewer::display_Info(const char *current, const char *next, int pb_h = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() - 4; switch(g_settings.infobar_progressbar) { - case 1: - case 2: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME_SMALL: CurrInfoY += (pb_h/3); NextInfoY += (pb_h/3); break; - case 3: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BETWEEN_EVENTS: CurrInfoY -= (pb_h/3); NextInfoY += (pb_h/3); break; @@ -1492,26 +1500,27 @@ void CInfoViewer::display_Info(const char *current, const char *next, int pb_startx = BoxEndX - pb_w - SHADOW_OFFSET; int pb_starty = ChanNameY - (pb_h + 10); int pb_shadow = COL_INFOBAR_SHADOW_PLUS_0; + timescale->setShadowOnOff(true); int pb_color = g_settings.progressbar_color ? COL_INFOBAR_SHADOW_PLUS_0 : COL_INFOBAR_PLUS_0; if(g_settings.infobar_progressbar){ pb_startx = xStart; pb_w = BoxEndX - 10 - xStart; pb_shadow = 0; + timescale->setShadowOnOff(false); } - switch(g_settings.infobar_progressbar) + switch(g_settings.infobar_progressbar) //set progressbar position { - case 1: - + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME: pb_starty = CurrInfoY - ((pb_h * 2) + (pb_h / 6)) ; pb_h = (pb_h/3); - pb_color = 0; +// pb_color = 0; break; - case 2: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME_SMALL: pb_starty = CurrInfoY - ((pb_h * 2) + (pb_h / 5)) ; pb_h = (pb_h/5); - pb_color = 0; +// pb_color = 0; break; - case 3: + case SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_BETWEEN_EVENTS: pb_starty = CurrInfoY + ((pb_h / 3)-(pb_h/5)) ; pb_h = (pb_h/5); break; @@ -1523,8 +1532,10 @@ void CInfoViewer::display_Info(const char *current, const char *next, if (pb_p > pb_w) pb_p = pb_w; - timescale->paintProgressBar(pb_startx, pb_starty, pb_w, pb_h, pb_p, pb_w, - 0, 0, pb_color, pb_shadow, "", COL_INFOBAR); + timescale->setDimensionsAll(pb_startx, pb_starty, pb_w, pb_h); + timescale->setColorAll(pb_color, pb_color, pb_shadow); + timescale->setValues(pb_p, pb_w); + timescale->paint(); //printf("paintProgressBar(%d, %d, %d, %d)\n", BoxEndX - pb_w - SHADOW_OFFSET, ChanNameY - (pb_h + 10) , pb_w, pb_h); } diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 9a0831132..206d76a96 100644 --- a/src/gui/infoviewer.h +++ b/src/gui/infoviewer.h @@ -42,7 +42,6 @@ #include #include "widget/menue.h" #include -#include #include #include diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 8750925a7..4d020dc42 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -649,17 +649,22 @@ void* CInfoViewerBB::hddperThread(void *arg) } void CInfoViewerBB::showBarSys(int percent) -{ - if (is_visible) - sysscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6, percent, 100); +{ + if (is_visible){ + sysscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6); + sysscale->setValues(percent, 100); + sysscale->paint(); + } } void CInfoViewerBB::showBarHdd(int percent) { if (is_visible) { - if (percent >= 0) - hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); - else { + if (percent >= 0){ + hddscale->setDimensionsAll(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6); + hddscale->setValues(percent, 100); + hddscale->paint(); + }else { frameBuffer->paintBoxRel(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, COL_INFOBAR_BUTTONS_BACKGROUND); hddscale->reset(); } @@ -818,12 +823,17 @@ void CInfoViewerBB::paintCA_bar(int left, int right) void CInfoViewerBB::changePB() { hddwidth = frameBuffer->getScreenWidth(true) * ((g_settings.screen_preset == 1) ? 10 : 8) / 128; /* 80(CRT)/100(LCD) pix if screen is 1280 wide */ - if (hddscale != NULL) + if (hddscale) delete hddscale; - hddscale = new CProgressBar(true, hddwidth, 6, 50, 100, 75, true); - if (sysscale != NULL) + hddscale = new CProgressBar(); + hddscale->setBlink(); + hddscale->setInvert(); + + if (sysscale) delete sysscale; - sysscale = new CProgressBar(true, hddwidth, 6, 50, 100, 75, true); + sysscale = new CProgressBar(); + sysscale->setBlink(); + sysscale->setInvert(); } void CInfoViewerBB::reset_allScala() diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index d5f4230c5..d47e64409 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -41,7 +41,7 @@ #include #include #include "widget/menue.h" -#include +#include #include class CInfoViewerBB diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index 51ed3e27b..acad895b6 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -99,8 +99,10 @@ void CMotorControl::Init(void) motorPosition = 1; satellitePosition = 0; stepDelay = 10; - sigscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); - snrscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); + sigscale = new CProgressBar(/*true, BAR_WIDTH, BAR_HEIGHT*/); + sigscale->setBlink(); + snrscale = new CProgressBar(/*true, BAR_WIDTH, BAR_HEIGHT*/); + snrscale->setBlink(); } int CMotorControl::exec(CMenuTarget* parent, const std::string &) @@ -717,7 +719,7 @@ void CMotorControl::showSNR() int barwidth = 100; uint16_t ssig, ssnr; int sig, snr; - int posx, posy; + int posx_sig, posx_snr, posy; int sw; @@ -732,29 +734,32 @@ void CMotorControl::showSNR() g_snr = snr; posy = y + height - mheight - 5; - + //TODO: move sig/snr display into its own class, similar or same code also to find in scan.cpp if (lastsig != sig) { lastsig = sig; - posx = x + 10; + posx_sig = x + 10; sprintf(percent, "%d%% SIG", sig); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SIG"); - sigscale->paintProgressBar2(posx-1, posy, sig); + sigscale->setProgress(posx_sig-1, posy, BAR_WIDTH, BAR_HEIGHT, sig, 100); + sigscale->paint(); - posx = posx + barwidth + 3; - frameBuffer->paintBoxRel(posx, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx+2, posy + mheight, sw, percent, COL_MENUCONTENT); + posx_sig += barwidth + 3; + frameBuffer->paintBoxRel(posx_sig, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx_sig+2, posy + mheight, sw, percent, COL_MENUCONTENT); } if (lastsnr != snr) { lastsnr = snr; - posx = x + 10 + 210; + posx_snr = x + 10 + 210; sprintf(percent, "%d%% SNR", snr); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100% SNR"); - snrscale->paintProgressBar2(posx-1, posy, snr); + + snrscale->setProgress(posx_snr-1, posy, BAR_WIDTH, BAR_HEIGHT, snr, 100); + snrscale->paint(); - posx = posx + barwidth + 3; - frameBuffer->paintBoxRel(posx, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx+2, posy + mheight, sw, percent, COL_MENUCONTENT); + posx_snr += barwidth + 3; + frameBuffer->paintBoxRel(posx_snr, posy - 2, sw+4, mheight, COL_MENUCONTENT_PLUS_0); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString (posx_snr+2, posy + mheight, sw, percent, COL_MENUCONTENT); } } diff --git a/src/gui/motorcontrol.h b/src/gui/motorcontrol.h index 7ef402417..b69ad427f 100644 --- a/src/gui/motorcontrol.h +++ b/src/gui/motorcontrol.h @@ -34,7 +34,7 @@ #define __motorcontrol__ #include -#include +#include #include #include #include diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 59c218958..dfab4bc28 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include @@ -1283,10 +1283,13 @@ void CMovieBrowser::info_hdd_level(bool paint_hdd) if(tmp_blocks_percent_used != blocks_percent_used || paint_hdd){ tmp_blocks_percent_used = blocks_percent_used; - CProgressBar pb(true, -1, -1, 30, 100, 70, true); const short pbw = 100; const short border = m_cBoxFrameTitleRel.iHeight/4; - pb.paintProgressBarDefault(m_cBoxFrame.iX+ m_cBoxFrameFootRel.iWidth - pbw - border, m_cBoxFrame.iY+m_cBoxFrameTitleRel.iY + border, pbw, m_cBoxFrameTitleRel.iHeight/2, blocks_percent_used, 100); + CProgressBar pb(m_cBoxFrame.iX+ m_cBoxFrameFootRel.iWidth - pbw - border, m_cBoxFrame.iY+m_cBoxFrameTitleRel.iY + border, pbw, m_cBoxFrameTitleRel.iHeight/2); + pb.setBlink(); + pb.setInvert(); + pb.setValues( blocks_percent_used, 100); + pb.paint(false); } } @@ -4017,12 +4020,14 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie) CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); if (! timescale) - timescale = new CProgressBar(g_settings.progressbar_color, 200, 15, 0, 100, 0); + timescale = new CProgressBar();//new CProgressBar(g_settings.progressbar_color, 200, 15, 0, 100, 0); + timescale->setBlink(); int dx = 256; int x = (((g_settings.screen_EndX- g_settings.screen_StartX)- dx) / 2) + g_settings.screen_StartX; int y = g_settings.screen_EndY - 50; - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); - timescale->paintProgressBar2(x + 41, y + 12, percent); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);//TODO: remove unneeded box paints + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); int len = minfo->length; off64_t size = minfo->file.Size; //off64_t secsize = len ? size/len/60 : 511040; @@ -4142,7 +4147,7 @@ printf("\ncut: reading from %" PRId64 " to %" PRId64 " (%" PRId64 ") want gop %d } if(msg) { timescale->reset(); - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);//TODO: remove unneeded box paints } size_t toread = (until-sdone) > BUF_SIZE ? BUF_SIZE : until - sdone; #if REAL_CUT @@ -4168,7 +4173,8 @@ if(buf[0] != 0x47) printf("cut: buffer not aligned at %" PRId64 "\n", sdone); sdone += r; spos += r - wptr; percent = (int) ((float)(spos)/(float)(newsize)*100.); - timescale->paintProgressBar2(x + 41, y + 12, percent); + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); #if REAL_CUT int wr = write(dstfd, &buf[wptr], r-wptr); if(wr < (r-wptr)) { @@ -4274,12 +4280,14 @@ printf("copy: len %d minute %" PRId64 " second %" PRId64 "\n", len, len ? size/l CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); if (! timescale) - timescale = new CProgressBar(true, 200, 15, 0, 100, 0); + timescale = new CProgressBar();//new CProgressBar(g_settings.progressbar_color, 200, 15, 0, 100, 0); + timescale->setBlink(); int dx = 256; int x = (((g_settings.screen_EndX- g_settings.screen_StartX)- dx) / 2) + g_settings.screen_StartX; int y = g_settings.screen_EndY - 50; - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); - timescale->paintProgressBar2(x + 41, y + 12, percent); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); //TODO: remove unneeded box paints + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); newsize = 0; for(int book_nr = 0; book_nr < MI_MOVIE_BOOK_USER_MAX; book_nr++) { @@ -4369,7 +4377,7 @@ printf("copy: read from %" PRId64 " to %" PRId64 " read size %d want gop %d\n", goto ret_err; } if(msg) { - frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0); + frameBuffer->paintBoxRel (x + 40, y+12, 200, 15, COL_INFOBAR_PLUS_0);//TODO: remove unneeded box paints timescale->reset(); } #if REAL_CUT @@ -4397,7 +4405,8 @@ if(buf[0] != 0x47) printf("copy: buffer not aligned at %" PRId64 "\n", sdone); spos += r - wptr; btotal += r; percent = (int) ((float)(btotal)/(float)(newsize)*100.); - timescale->paintProgressBar2(x + 41, y + 12, percent); + timescale->setProgress(x + 41, y + 12, 200, 15, percent, 200); + timescale->paint(); #if REAL_CUT int wr = write(dstfd, &buf[wptr], r-wptr); if(wr < (r-wptr)) { diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 7fffbf934..539bc1216 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -91,12 +91,13 @@ const SNeutrinoSettings::FONT_TYPES channellist_font_sizes[5] = SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP }; -const SNeutrinoSettings::FONT_TYPES eventlist_font_sizes[4] = +const SNeutrinoSettings::FONT_TYPES eventlist_font_sizes[5] = { SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE, SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE, SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL, SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME, + SNeutrinoSettings::FONT_TYPE_EVENTLIST_EVENT }; const SNeutrinoSettings::FONT_TYPES infobar_font_sizes[4] = @@ -134,7 +135,7 @@ font_sizes_groups font_sizes_groups[6] = { {LOCALE_FONTMENU_MENU , 5, other_font_sizes , "fontsize.doth", LOCALE_MENU_HINT_MENU_FONTS }, {LOCALE_FONTMENU_CHANNELLIST, 5, channellist_font_sizes, "fontsize.dcha", LOCALE_MENU_HINT_CHANNELLIST_FONTS }, - {LOCALE_FONTMENU_EVENTLIST , 4, eventlist_font_sizes , "fontsize.deve", LOCALE_MENU_HINT_EVENTLIST_FONTS }, + {LOCALE_FONTMENU_EVENTLIST , 5, eventlist_font_sizes , "fontsize.deve", LOCALE_MENU_HINT_EVENTLIST_FONTS }, {LOCALE_FONTMENU_EPG , 4, epg_font_sizes , "fontsize.depg", LOCALE_MENU_HINT_EPG_FONTS }, {LOCALE_FONTMENU_INFOBAR , 4, infobar_font_sizes , "fontsize.dinf", LOCALE_MENU_HINT_INFOBAR_FONTS }, {LOCALE_FONTMENU_GAMELIST , 2, gamelist_font_sizes , "fontsize.dgam", LOCALE_MENU_HINT_GAMELIST_FONTS } @@ -157,6 +158,7 @@ font_sizes_struct neutrino_font[SNeutrinoSettings::FONT_TYPE_COUNT] = {LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, 20, FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, 14, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_EVENTLIST_DATETIME , 16, FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_EVENTLIST_EVENT , 17, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_GAMELIST_ITEMLARGE , 20, FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_GAMELIST_ITEMSMALL , 16, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_CHANNELLIST , 20, FONT_STYLE_BOLD , 1}, @@ -447,10 +449,17 @@ int COsdSetup::showOsdSetup() mf->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SETUP); osd_menu->addItem(mf); + //eventlist + CMenuWidget osd_menu_eventlist(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_OSDSETUP_EVENTLIST); + showOsdEventlistSetup(&osd_menu_eventlist); + mf = new CMenuForwarder(LOCALE_EVENTLIST_NAME, true, NULL, &osd_menu_eventlist, NULL, CRCInput::RC_4); + mf->setHint("", LOCALE_MENU_HINT_EVENTLIST_SETUP); + osd_menu->addItem(mf); + //screenshot CMenuWidget osd_menu_screenshot(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_OSDSETUP_SCREENSHOT); showOsdScreenShotSetup(&osd_menu_screenshot); - mf = new CMenuForwarder(LOCALE_SCREENSHOT_MENU, true, NULL, &osd_menu_screenshot, NULL, CRCInput::RC_4); + mf = new CMenuForwarder(LOCALE_SCREENSHOT_MENU, true, NULL, &osd_menu_screenshot, NULL, CRCInput::RC_5); mf->setHint("", LOCALE_MENU_HINT_SCREENSHOT_SETUP); osd_menu->addItem(mf); @@ -834,6 +843,19 @@ void COsdSetup::showOsdChanlistSetup(CMenuWidget *menu_chanlist) menu_chanlist->addItem(mc); } +//eventlist +void COsdSetup::showOsdEventlistSetup(CMenuWidget *menu_eventlist) +{ + CMenuOptionChooser * mc; + + menu_eventlist->addIntroItems(LOCALE_EVENTLIST_NAME); + + // eventlist additional + mc = new CMenuOptionChooser(LOCALE_EVENTLIST_ADDITIONAL, &g_settings.eventlist_additional, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + mc->setHint("", LOCALE_MENU_HINT_EVENTLIST_ADDITIONAL); + menu_eventlist->addItem(mc); +} + bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) { if(ARE_LOCALES_EQUAL(OptionName, LOCALE_COLORMENU_CONTRAST_FONTS)) diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index e62f6f793..d3a84ce30 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -57,6 +57,7 @@ class COsdSetup : public CMenuTarget, public CChangeObserver void showOsdTimeoutSetup(CMenuWidget *menu_timeout); void showOsdInfobarSetup(CMenuWidget *menu_infobar); void showOsdChanlistSetup(CMenuWidget *menu_chanlist); + void showOsdEventlistSetup(CMenuWidget *menu_eventlist); void showOsdScreenShotSetup(CMenuWidget *menu_screenshot); void AddFontSettingItem(CMenuWidget &font_Settings, const SNeutrinoSettings::FONT_TYPES number_of_fontsize_entry); diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index d42abf8f9..4cebbb484 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -24,18 +24,18 @@ License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/personalize.h b/src/gui/personalize.h index b3c00ea97..9b6a452c4 100644 --- a/src/gui/personalize.h +++ b/src/gui/personalize.h @@ -24,18 +24,18 @@ License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 8d7fd37ba..75fec5699 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include @@ -81,9 +81,13 @@ CScanTs::CScanTs(int dtype) total = done = 0; freqready = 0; - sigscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); - snrscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); deltype = dtype; + sigscale = new CProgressBar(); + sigscale->setBlink(); + + snrscale = new CProgressBar(); + snrscale->setBlink(); + memset(&TP, 0, sizeof(TP)); // valgrind } CScanTs::~CScanTs() @@ -243,6 +247,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) CServiceScan::getInstance()->SetCableNID(scansettings.cable_nid); CZapitClient::commandSetScanSatelliteList sat; + memset(&sat, 0, sizeof(sat)); // valgrind CZapitClient::ScanSatelliteList satList; satList.clear(); if(fast) { @@ -573,13 +578,14 @@ void CScanTs::showSNR () sig = (ssig & 0xFFFF) * 100 / 65535; posy = y + height - mheight - 5; - - if (lastsig != sig) { + //TODO: move sig/snr display into its own class, similar or same code also to find in motorcontrol + if (lastsig != sig) { lastsig = sig; posx = x + 20; sprintf(percent, "%d%%", sig); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100%"); - sigscale->paintProgressBar2(posx - 1, posy+2, sig); + sigscale->setProgress(posx - 1, posy+2, BAR_WIDTH, BAR_HEIGHT, sig, 100); + sigscale->paint(); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy -1, sw, mheight-8, COL_MENUCONTENT_PLUS_0); @@ -594,7 +600,8 @@ void CScanTs::showSNR () posx = x + 20 + (20 * fw); sprintf(percent, "%d%%", snr); sw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth ("100%"); - snrscale->paintProgressBar2(posx - 1, posy+2, snr); + snrscale->setProgress(posx - 1, posy+2, BAR_WIDTH, BAR_HEIGHT, snr, 100); + snrscale->paint(); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy - 1, sw, mheight-8, COL_MENUCONTENT_PLUS_0, 0, true); diff --git a/src/gui/scan.h b/src/gui/scan.h index 3e820d28c..073ba4a4d 100644 --- a/src/gui/scan.h +++ b/src/gui/scan.h @@ -33,11 +33,11 @@ #define __scants__ #include -#include +#include #include #include #include - +#include class CScanTs : public CMenuTarget { diff --git a/src/gui/start_wizard.cpp b/src/gui/start_wizard.cpp index 0fc08c5cc..f0191dd56 100644 --- a/src/gui/start_wizard.cpp +++ b/src/gui/start_wizard.cpp @@ -14,17 +14,17 @@ License: GPL This software is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/start_wizard.h b/src/gui/start_wizard.h index 2fbafcb6a..4b8e51641 100644 --- a/src/gui/start_wizard.h +++ b/src/gui/start_wizard.h @@ -14,17 +14,17 @@ License: GPL This software is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index b7b89f368..5304134a8 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -56,7 +56,7 @@ extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */ CStreamInfo2::CStreamInfo2 () { frameBuffer = CFrameBuffer::getInstance (); - + pip = NULL; font_head = SNeutrinoSettings::FONT_TYPE_MENU_TITLE; font_info = SNeutrinoSettings::FONT_TYPE_MENU; font_small = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL; @@ -98,7 +98,7 @@ CStreamInfo2::CStreamInfo2 () CStreamInfo2::~CStreamInfo2 () { - videoDecoder->Pig(-1, -1, -1, -1); + delete pip; ts_close(); } @@ -120,8 +120,13 @@ int CStreamInfo2::doSignalStrengthLoop () #define BAR_WIDTH 150 #define BAR_HEIGHT 12 int res = menu_return::RETURN_REPAINT; - sigscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); - snrscale = new CProgressBar(true, BAR_WIDTH, BAR_HEIGHT); + + sigscale = new CProgressBar(); + sigscale->setBlink(); + + snrscale = new CProgressBar(); + snrscale->setBlink(); + lastsnr = lastsig = -1; neutrino_msg_t msg; @@ -252,17 +257,10 @@ int CStreamInfo2::doSignalStrengthLoop () void CStreamInfo2::hide () { - videoDecoder->Pig(-1, -1, -1, -1); + pip->hide(true); frameBuffer->paintBackgroundBoxRel (0, 0, max_width, max_height); } -void CStreamInfo2::paint_pig (int px, int py, int w, int h) -{ - frameBuffer->paintBackgroundBoxRel (px,py, w, h); - printf("CStreamInfo2::paint_pig x %d y %d w %d h %d\n", px, py, w, h); - videoDecoder->Pig(px, py, w, h, frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); -} - void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h) { int y1; @@ -425,7 +423,10 @@ void CStreamInfo2::paint (int /*mode*/) g_Font[font_head]->RenderString (xpos, ypos + hheight + 1, width, head_string, COL_MENUHEAD, 0, true); // UTF-8 ypos += hheight; - paint_pig (width - width/3 - 10, y + 10, width/3, height/3); + if (pip == NULL) + pip = new CComponentsPIP(width-width/3-10, y+10, 33); + pip->paint(); + paint_techinfo (xpos, ypos); paint_signal_fe_box (width - width/3 - 10, (y + 10 + height/3 + hheight), width/3, height/3 + hheight); } else { @@ -914,7 +915,8 @@ void CStreamInfo2::showSNR () posy = yypos + (mheight/2)-5; posx = x + 10; sprintf(percent, "%d%%", sig); - sigscale->paintProgressBar2(posx - 1, posy, sig); + sigscale->setProgress(posx - 1, posy, BAR_WIDTH, BAR_HEIGHT, sig, 100); + sigscale->paint(); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy -1, sw, mheight-8, COL_MENUHEAD_PLUS_0); @@ -926,7 +928,9 @@ void CStreamInfo2::showSNR () posy = yypos + mheight + 5; posx = x + 10; sprintf(percent, "%d%% SNR", snr); - snrscale->paintProgressBar2(posx - 1, posy+2, snr); + snrscale->setProgress(posx - 1, posy+2, BAR_WIDTH, BAR_HEIGHT, snr, 100); + snrscale->paint(); +// snrscale->paintProgressBar2(posx - 1, posy+2, snr); posx = posx + barwidth + 3; frameBuffer->paintBoxRel(posx, posy - 1, sw, mheight-8, COL_MENUHEAD_PLUS_0, 0, true); diff --git a/src/gui/streaminfo2.h b/src/gui/streaminfo2.h index e24c48ca4..2a3757ce9 100644 --- a/src/gui/streaminfo2.h +++ b/src/gui/streaminfo2.h @@ -26,7 +26,8 @@ #include #include -#include +#include +#include #include @@ -36,6 +37,7 @@ class CStreamInfo2 : public CMenuTarget CFrameBuffer *frameBuffer; CFrontend *frontend; + CComponentsPIP * pip; int x; int y; int width; @@ -90,7 +92,6 @@ class CStreamInfo2 : public CMenuTarget int ts_close(); void paint(int mode); - void paint_pig(int x, int y, int w, int h); void paint_techinfo(int x, int y); void paintCASystem(int xpos, int ypos); void paint_signal_fe_box(int x, int y, int w, int h); diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index a09d54661..adafdbd71 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -54,6 +54,7 @@ #include #include + extern int cs_test_card(int unit, char * str); #ifdef TEST_MENU @@ -61,10 +62,26 @@ CTestMenu::CTestMenu() { width = w_max (50, 10); selected = -1; + circle = NULL; + sq = NULL; + pic= NULL; + form = NULL; + txt = NULL; + header = NULL; + iconform = NULL; + window = NULL; } CTestMenu::~CTestMenu() { + delete sq; + delete circle; + delete pic; + delete form; + delete txt; + delete header; + delete iconform; + delete window; } int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) @@ -311,10 +328,191 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) delete scanTs; return res; } + else if (actionKey == "circle"){ + if (circle == NULL) + circle = new CComponentsShapeCircle (100, 100, 100, false); + if (!circle->isPainted()) + circle->paint(); + else + circle->hide(); + return res; + } + else if (actionKey == "square"){ + if (sq == NULL) + sq = new CComponentsShapeSquare (100, 220, 100, 100, false); + if (!sq->isPainted()) + sq->paint(); + else + sq->hide(); + return res; + } + else if (actionKey == "picture"){ + if (pic == NULL) + pic = new CComponentsPicture (100, 100, 200, 200, DATADIR "/neutrino/icons/mp3-5.jpg"); + + if (!pic->isPainted() && !pic->isPicPainted()) + pic->paint(); + else + pic->hide(); + return res; + } + else if (actionKey == "form"){ + if (form == NULL) + form = new CComponentsForm(); + form->setColorBody(COL_LIGHT_GRAY); + form->setDimensionsAll(100, 100, 250, 100); + form->setFrameThickness(2); + form->setColorFrame(COL_WHITE); + + CComponentsPicture *ptmp = new CComponentsPicture(0, 0, 0, 0, NEUTRINO_ICON_BUTTON_YELLOW); + ptmp->setWidth(28); + ptmp->setHeight(28); + ptmp->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); + ptmp->setColorBody(COL_BLUE); + ptmp->setCornerRadius(RADIUS_MID); + ptmp->setCornerType(CORNER_TOP_LEFT); + form->addCCItem(ptmp); + + CComponentsText *t1 = new CComponentsText(28, 0, 100, 28, "Text1", CTextBox::NO_AUTO_LINEBREAK); + form->addCCItem(t1); + + CComponentsText *t2 = new CComponentsText(t1->getXPos()+t1->getWidth(), 0, 200, 50, "Text2", CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT); + t2->setCornerRadius(RADIUS_MID); + t2->setCornerType(CORNER_TOP_RIGHT); + form->addCCItem(t2); + + CComponentsShapeCircle *c1 = new CComponentsShapeCircle(28, 40, 28); + c1->setColorBody(COL_RED); + form->addCCItem(c1); + +// form->removeCCItem(form->getCCItemId(t1)); +// form->insertCCItem(1, new CComponentsPicture(28, 0, 0, 0, NEUTRINO_ICON_BUTTON_RED)); + + + if (form->isPainted()) { + form->hide(); + delete form; + form = NULL; + } + else + form->paint(); + return res; + } + else if (actionKey == "text"){ + if (txt == NULL) + txt = new CComponentsText(); + txt->setDimensionsAll(100, 100, 250, 100); + txt->setText("This is a text for testing textbox", CTextBox::NO_AUTO_LINEBREAK); + + if (txt->isPainted()) + txt->hide(); + else + txt->paint(); + return res; + } + else if (actionKey == "header"){ + int hh = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + if (header == NULL){ + header = new CComponentsHeader (100, 50, 500, hh, "Test-Header", NEUTRINO_ICON_INFO, CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU); + header->addHeaderButton(NEUTRINO_ICON_BUTTON_RED); + } +// else //For existing instances it's recommended +// //to remove old button icons before add new buttons, otherwise icons will be appended. +// header->removeHeaderButtons(); + +// example to manipulate header items +// header->setFrameThickness(5); +// header->setColorFrame(COL_WHITE); +// header->setCornerType(CORNER_TOP); + +// change text of header + header->setHeaderText("Test"); + +// add any other button icon +// header->addHeaderButton(NEUTRINO_ICON_BUTTON_BLUE); +// header->addHeaderButton(NEUTRINO_ICON_BUTTON_GREEN); + +// example to replace the text item with an image item +// get text x position +// int logo_x = header->getCCItem(CComponentsHeader::CC_HEADER_ITEM_TEXT)->getXPos(); +// remove text item +// header->removeCCItem(CComponentsHeader::CC_HEADER_ITEM_TEXT); //then remove text item +// create picture object with the last x position of text +// CComponentsPicture *logo = new CComponentsPicture(logo_x, 0, 100, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(), "/share/tuxbox/neutrino/icons/hint_tvmode.png"); +// set the transparent background for picture item +// logo->doPaintBg(false); +// insert the ne object +// header->insertCCItem(1, logo); //replace text with logo + + + if (!header->isPainted()) + header->paint(); + else + header->hide(); + return res; + } + else if (actionKey == "iconform"){ + if (iconform == NULL) + iconform = new CComponentsIconForm(); + iconform->setColorBody(COL_LIGHT_GRAY); + iconform->setDimensionsAll(100, 100, 480, 60); + iconform->setFrameThickness(2); + iconform->setColorFrame(COL_WHITE); + iconform->setIconOffset(5); + iconform->setIconAlign(CComponentsIconForm::CC_ICONS_FRM_ALIGN_RIGHT); + //For existing instances it's recommended + //to remove old items before add new icons, otherwise icons will be appended. + iconform->removeAllIcons(); + + //you can... + //add icons step by step + iconform->addIcon(NEUTRINO_ICON_INFO); + iconform->addIcon(NEUTRINO_ICON_INFO); + iconform->addIcon(NEUTRINO_ICON_HINT_MEDIA); + //...or + //add icons with vector + std::vector v_icons; + v_icons.push_back(NEUTRINO_ICON_HINT_VIDEO); + v_icons.push_back(NEUTRINO_ICON_HINT_AUDIO); + iconform->addIcon(v_icons); + + //insert any icon, here as first (index = 0...n) + iconform->insertIcon(0, NEUTRINO_ICON_HINT_APLAY); +// iconform->setIconAlign(CComponentsIconForm::CC_ICONS_FRM_ALIGN_RIGHT); + + if (iconform->isPainted()) + iconform->hide(); + else{ + iconform->paint(); + } + return res; + } + else if (actionKey == "window"){ + if (window == NULL){ + window = new CComponentsWindow(); + window->setWindowCaption("|.....................|"); + window->setDimensionsAll(50, 50, 800, 480); + window->setWindowIcon(NEUTRINO_ICON_INFO); + } + else{ +// window->setDimensionsAll(50, 50, 800, 480); + window->setWindowIcon(NEUTRINO_ICON_LOCK); + window->setWindowCaption("Test"); + } + + if (!window->isPainted()) + window->paint(); + else + window->hide(); + + return res; + } + + showTestMenu(); - + return res; } @@ -322,49 +520,81 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) void CTestMenu::showTestMenu() { unsigned int system_rev = cs_get_revision(); - + //init char rev[255]; sprintf(rev, "Test menu, System revision %d %s", system_rev, system_rev == 0 ? "WARNING - INVALID" : ""); - CMenuWidget * TestMenu = new CMenuWidget(rev /*"Test menu"*/); - TestMenu->setSelected(selected); - TestMenu->addIntroItems(); - TestMenu->addItem(new CMenuForwarderNonLocalized("VFD", true, NULL, this, "vfd")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Network", true, NULL, this, "network")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard 1", true, NULL, this, "card0")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard 2", true, NULL, this, "card1")); - TestMenu->addItem(new CMenuForwarderNonLocalized("HDD", true, NULL, this, "hdd")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Buttons", true, NULL, this, "buttons")); + CMenuWidget w_test(rev /*"Test menu"*/, NEUTRINO_ICON_INFO, width); + w_test.addIntroItems(); + + //hardware + CMenuWidget * w_hw = new CMenuWidget("Hardware Test", NEUTRINO_ICON_INFO, width); + w_test.addItem(new CMenuForwarderNonLocalized(w_hw->getName().c_str(), true, NULL, w_hw)); + showHWTests(w_hw); + + //buttons + w_test.addItem(new CMenuForwarderNonLocalized("Buttons", true, NULL, this, "buttons")); + + //components + CMenuWidget * w_cc = new CMenuWidget("OSD-Components Demo", NEUTRINO_ICON_INFO, width); + w_test.addItem(new CMenuForwarderNonLocalized(w_cc->getName().c_str(), true, NULL, w_cc)); + showCCTests(w_cc); + //exit + w_test.exec(NULL, ""); + selected = w_test.getSelected(); +} + +void CTestMenu::showCCTests(CMenuWidget *widget) +{ + widget->setSelected(selected); + widget->addIntroItems(); + widget->addItem(new CMenuForwarderNonLocalized("Circle", true, NULL, this, "circle")); + widget->addItem(new CMenuForwarderNonLocalized("Square", true, NULL, this, "square")); + widget->addItem(new CMenuForwarderNonLocalized("Picture", true, NULL, this, "picture")); + widget->addItem(new CMenuForwarderNonLocalized("Form", true, NULL, this, "form")); + widget->addItem(new CMenuForwarderNonLocalized("Text", true, NULL, this, "text")); + widget->addItem(new CMenuForwarderNonLocalized("Header", true, NULL, this, "header")); + widget->addItem(new CMenuForwarderNonLocalized("Icon-Form", true, NULL, this, "iconform")); + widget->addItem(new CMenuForwarderNonLocalized("Window", true, NULL, this, "window")); +} + +void CTestMenu::showHWTests(CMenuWidget *widget) +{ + widget->setSelected(selected); + widget->addIntroItems(); + widget->addItem(new CMenuForwarderNonLocalized("VFD", true, NULL, this, "vfd")); + widget->addItem(new CMenuForwarderNonLocalized("Network", true, NULL, this, "network")); + widget->addItem(new CMenuForwarderNonLocalized("Smartcard 1", true, NULL, this, "card0")); + widget->addItem(new CMenuForwarderNonLocalized("Smartcard 2", true, NULL, this, "card1")); + widget->addItem(new CMenuForwarderNonLocalized("HDD", true, NULL, this, "hdd")); + //CFEManager::getInstance()->setMode(CFEManager::FE_MODE_ALONE); - + CServiceManager::getInstance()->InitSatPosition(130, NULL, true); CServiceManager::getInstance()->InitSatPosition(192, NULL, true); - + satellite_map_t satmap = CServiceManager::getInstance()->SatelliteList(); satmap[130].configured = 1; - + CFrontend * frontend = CFEManager::getInstance()->getFE(0); frontend->setSatellites(satmap); - + int count = CFEManager::getInstance()->getFrontendCount(); if (frontend->getInfo()->type == FE_QPSK) { - TestMenu->addItem(new CMenuForwarderNonLocalized("Tuner 1: Scan 12538000", true, NULL, this, "scan1")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz ON", true, NULL, this, "22kon1")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz OFF", true, NULL, this, "22koff1")); + widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: Scan 12538000", true, NULL, this, "scan1")); + widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz ON", true, NULL, this, "22kon1")); + widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz OFF", true, NULL, this, "22koff1")); if(count > 1) { satmap = CServiceManager::getInstance()->SatelliteList(); satmap[192].configured = 1; frontend = CFEManager::getInstance()->getFE(1); frontend->setSatellites(satmap); - - TestMenu->addItem(new CMenuForwarderNonLocalized("Tuner 2: Scan 12538000", true, NULL, this, "scan2")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz ON", true, NULL, this, "22kon2")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz OFF", true, NULL, this, "22koff2")); + + widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: Scan 12538000", true, NULL, this, "scan2")); + widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz ON", true, NULL, this, "22kon2")); + widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz OFF", true, NULL, this, "22koff2")); } } - TestMenu->exec(NULL, ""); - selected = TestMenu->getSelected(); - delete TestMenu; } #endif diff --git a/src/gui/test_menu.h b/src/gui/test_menu.h index b7f482bdc..b63ed911f 100644 --- a/src/gui/test_menu.h +++ b/src/gui/test_menu.h @@ -31,17 +31,28 @@ #include #include - -//#define TEST_MENU +#include +#include + #define TEST_MENU #include class CTestMenu : public CMenuTarget { private: + CComponentsShapeCircle * circle; + CComponentsShapeSquare* sq; + CComponentsPicture* pic; + CComponentsForm *form; + CComponentsText *txt; + CComponentsHeader *header; + CComponentsIconForm *iconform; + CComponentsWindow *window; int width, selected; void showTestMenu(); + void showHWTests(CMenuWidget *widget); + void showCCTests(CMenuWidget *widget); public: CTestMenu(); diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index ab761f283..48d32aea0 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -42,7 +42,7 @@ CTimeOSD::CTimeOSD() visible=false; m_mode=MODE_ASC; GetDimensions(); - timescale = new CProgressBar(true, BARLEN, m_height -5, 40, 100, 70, true); + timescale = new CProgressBar(); m_time_show = 0; } @@ -116,7 +116,10 @@ void CTimeOSD::updatePos(short runningPercent) if(runningPercent > 100 || runningPercent < 0) runningPercent = 0; - timescale->paintProgressBar2(m_xstart, m_y, runningPercent); + timescale->setProgress(m_xstart, m_y, BARLEN, m_height -5, runningPercent, 100); + timescale->setBlink(); + timescale->setRgb(0, 100, 70); + timescale->paint(); } void CTimeOSD::update(int position, int duration) diff --git a/src/gui/timeosd.h b/src/gui/timeosd.h index 66ed1fdda..078b723b7 100644 --- a/src/gui/timeosd.h +++ b/src/gui/timeosd.h @@ -27,7 +27,7 @@ #include #include -#include +#include class CTimeOSD { diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index 2b7d67824..cc5920007 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -9,18 +9,18 @@ License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/src/gui/update_ext.h b/src/gui/update_ext.h index d327fab24..fa196f658 100644 --- a/src/gui/update_ext.h +++ b/src/gui/update_ext.h @@ -9,18 +9,18 @@ License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/src/gui/update_menue.cpp b/src/gui/update_menue.cpp index c93a40ec5..55fe6ce46 100644 --- a/src/gui/update_menue.cpp +++ b/src/gui/update_menue.cpp @@ -24,7 +24,7 @@ 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 Library General Public + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/update_menue.h b/src/gui/update_menue.h index 8948a49f6..5daf34f38 100644 --- a/src/gui/update_menue.h +++ b/src/gui/update_menue.h @@ -23,7 +23,7 @@ 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 Library General Public + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/update_settings.cpp b/src/gui/update_settings.cpp index fecfa1912..7c7742194 100644 --- a/src/gui/update_settings.cpp +++ b/src/gui/update_settings.cpp @@ -22,7 +22,7 @@ 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 Library General Public + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/update_settings.h b/src/gui/update_settings.h index c58676774..65ffbb9db 100644 --- a/src/gui/update_settings.h +++ b/src/gui/update_settings.h @@ -22,7 +22,7 @@ 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 Library General Public + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 1318fe662..123066d18 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -14,18 +14,18 @@ License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/user_menue.h b/src/gui/user_menue.h index 05bec067e..701a25af7 100644 --- a/src/gui/user_menue.h +++ b/src/gui/user_menue.h @@ -12,18 +12,18 @@ License: GPL - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + 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 library is distributed in the hope that it will be useful, + 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 Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/src/gui/widget/Makefile.am b/src/gui/widget/Makefile.am index 957a30d2f..608af6216 100644 --- a/src/gui/widget/Makefile.am +++ b/src/gui/widget/Makefile.am @@ -38,7 +38,6 @@ libneutrino_gui_widget_a_SOURCES = \ messagebox.cpp \ mountchooser.cpp \ msgbox.cpp \ - progressbar.cpp \ stringinput.cpp \ stringinput_ext.cpp \ textbox.cpp diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index dbfe03047..230680296 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -322,9 +322,9 @@ void CMenuWidget::Init(const std::string & Icon, const int mwidth, const mn_widg mglobal = CMenuGlobal::getInstance(); //create CMenuGlobal instance only here frameBuffer = CFrameBuffer::getInstance(); iconfile = Icon; - details_line = NULL; - info_box = NULL; - + details_line = new CComponentsDetailLine(); + info_box = new CComponentsInfoBox(); + //handle select values if(w_index > MN_WIDGET_ID_MAX){ //error @@ -816,13 +816,14 @@ void CMenuWidget::calcSize() } hint_height = 0; if(g_settings.show_menu_hints && has_hints) { + hint_height = 60; //TODO: rework calculation of hint_height int fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); - hint_height = 10 + 2*fheight; + int h_tmp = 16 + 2*fheight; /* assuming all hint icons has the same size ! */ int iw, ih; frameBuffer->getIconSize(NEUTRINO_ICON_HINT_TVMODE, &iw, &ih); - if(hint_height < (ih+10)) - hint_height = ih+10; + h_tmp = std::max(h_tmp, ih+10); + hint_height = std::max(h_tmp, hint_height); } /* set the max height to 9/10 of usable screen height debatable, if the callers need a possibility to set this */ @@ -1070,16 +1071,16 @@ void CMenuWidget::paintHint(int pos) { if (!g_settings.show_menu_hints) return; - + if (pos < 0 && !hint_painted) return; - + int rad = RADIUS_LARGE; int xpos = x - ConnectLineBox_Width; int ypos2 = y + height + rad + SHADOW_OFFSET + INFO_BOX_Y_OFFSET; int iwidth = width+sb_width; - +#if 0 if (hint_painted) { /* clear detailsline line */ // TODO CComponents::hide with param restore ? or auto (if it have saved screens) ? @@ -1099,134 +1100,86 @@ void CMenuWidget::paintHint(int pos) } } hint_painted = false; +#endif + if (hint_painted) { + /* clear detailsline line */ + if (details_line) + details_line->hide(); + /* clear info box */ + if ((info_box) && (pos == -1)) + info_box->hide(true); + hint_painted = false; } if (pos < 0) return; - + CMenuItem* item = items[pos]; -//printf("paintHint: icon %s text %s\n", item->hintIcon.c_str(), g_Locale->getText(item->hint)); - + if (item->hintIcon.empty() && item->hint == NONEXISTANT_LOCALE) { +#if 0 if (info_box != NULL) { if (savescreen) +#endif + if (info_box) + info_box->hide(false); +#if 0 info_box->restore(); else info_box->hide(); } +#endif return; } - - hint_painted = true; - + + if (item->hint == NONEXISTANT_LOCALE) + return; + int iheight = item->getHeight(); - - //details line + + //init details line and infobox dimensions int ypos1 = item->getYPosition(); int ypos1a = ypos1 + (iheight/2)-2; int ypos2a = ypos2 + (hint_height/2) - INFO_BOX_Y_OFFSET; int markh = hint_height > rad*2 ? hint_height - rad*2 : hint_height; int imarkh = iheight/2+1; - if (details_line == NULL){ - details_line = new CComponentsDetailLine(xpos, ypos1a, ypos2a, imarkh, markh); - }else{ + //init details line + if (details_line){ details_line->setXPos(xpos); details_line->setYPos(ypos1a); details_line->setYPosDown(ypos2a); - details_line->setHMarkDown(markh); - details_line->setColor(COL_MENUCONTENT_PLUS_6, COL_MENUCONTENTDARK_PLUS_0); + details_line->setHMarkTop(imarkh); + details_line->setHMarkDown(markh); + details_line->syncSysColors(); } +#if 0 details_line->paint(savescreen); +#endif - if (info_box == NULL) - info_box = new CComponentsInfoBox(x, ypos2, iwidth, hint_height); - else { - info_box->setXPos(x); - info_box->setYPos(ypos2); - info_box->setWidth(iwidth); - info_box->setColor(COL_MENUCONTENT_PLUS_6, COL_MENUCONTENTDARK_PLUS_0, COL_MENUCONTENTDARK_PLUS_0); + //init infobox + std::string str = g_Locale->getText(item->hint); + if (info_box){ + info_box->setDimensionsAll(x, ypos2, iwidth, hint_height); + info_box->setFrameThickness(2); + info_box->removeLineBreaks(str); + info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); + info_box->setCornerRadius(RADIUS_LARGE); + info_box->syncSysColors(); + info_box->setShadowOnOff(CC_SHADOW_ON); + info_box->setPicture(item->hintIcon); } +#if 0 /* force full paint - menu-over i.e. option chooser with pulldown can overwrite */ info_box->paint(savescreen, true); +#endif - int offset = 10; - if (!item->hintIcon.empty()) { - int iw, ih; - frameBuffer->getIconSize(item->hintIcon.c_str(), &iw, &ih); - if (iw && ih) { - int ix = x + offset; - int iy = ypos2 + (hint_height - ih)/2; - frameBuffer->paintIcon(item->hintIcon.c_str(), ix, iy); - offset += iw + 10; - } - } - if (item->hint == NONEXISTANT_LOCALE) - return; - - int HintFont = SNeutrinoSettings::FONT_TYPE_MENU_HINT; - int fheight = g_Font[HintFont]->getHeight(); - - std::string str1, str2; - std::string str = g_Locale->getText(item->hint); - std::string::size_type spos = str.find_first_of("\n"); - if (spos != std::string::npos) { - str1 = str.substr(0, spos); - str2 = str.substr(spos+1); - } - else - str1 = str; - - if ((!str1.empty()) || (!str1.empty())) { - int wBox = iwidth - 6 - offset; - int wStr1 = 0, wStr2 = 0; - if (!str1.empty()) - wStr1 = g_Font[HintFont]->getRenderWidth(str1); - if (!str2.empty()) - wStr2 = g_Font[HintFont]->getRenderWidth(str2); - if ((wStr1 > wBox) || (wStr2 > wBox)) { - str = g_Locale->getText(item->hint); - // replace "\n" with " " - spos = str.find_first_of("\n"); - if (spos != std::string::npos) - str.replace(spos, 1, " "); - spos = str.length(); - if (spos >= 1) { - std::string BreakChars = "+-/"; - str1 = str; - wStr1 = g_Font[HintFont]->getRenderWidth(str1); - int count = 0; - std::string bChar; - while (wStr1 > wBox) { - spos = str1.find_last_of(BreakChars + " "); - if (spos != std::string::npos) { - str1 = str1.substr(0, spos+1); - // Last delimiter remember if it's not a whitespace - size_t len = str1.length(); - size_t spos2 = str1.find_last_of(BreakChars); - if (len == spos2+1) - bChar = str1.substr(spos2, spos2+1); - else - bChar = ""; - // Remove last delimiter - str1 = str1.substr(0, spos); - } - // Width of string with delimiter - wStr1 = g_Font[HintFont]->getRenderWidth(str1 + bChar); - count++; - if (count > 20) - break; - } - // Last delimiter append again - str1 += bChar; - str2 = str.substr(spos+1); - } - } - ypos2 += (hint_height-fheight*2)/2; - if (!str1.empty()) - g_Font[HintFont]->RenderString(x+offset, ypos2+fheight, wBox, str1, COL_MENUCONTENT, 0, true); // UTF-8 - if (!str2.empty()) - g_Font[HintFont]->RenderString(x+offset, ypos2+fheight*2, wBox, str2, COL_MENUCONTENT, 0, true); // UTF-8 - } + + //paint result + details_line->paint(); + info_box->paint(); + + hint_painted = true; + } //------------------------------------------------------------------------------------------------------------------------------- diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 5c76f7aa5..6f78bea21 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -425,6 +425,7 @@ class CMenuWidget : public CMenuTarget CMenuGlobal *mglobal; CComponentsDetailLine *details_line; CComponentsInfoBox *info_box; + int hint_height; protected: std::string nameString; @@ -448,7 +449,6 @@ class CMenuWidget : public CMenuTarget fb_pixel_t *background; int full_width, full_height; bool savescreen; - int hint_height; bool has_hints; // is any items has hints bool hint_painted; // is hint painted diff --git a/src/gui/widget/progressbar.cpp b/src/gui/widget/progressbar.cpp deleted file mode 100644 index 355eb0fbd..000000000 --- a/src/gui/widget/progressbar.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * (C) 2008 by dbt - * (C) 2009-2010, 2012-2013 Stefan Seyfried - * - * 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. - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "icons.h" -#include "progressbar.h" - -#define ITEMW 4 -#define POINT 2 - -#define RED 0xFF0000 -#define GREEN 0x00FF00 -#define YELLOW 0xFFFF00 - -CProgressBar::CProgressBar(const bool bl, const int w, const int h, - const int r, const int g, const int b, const bool inv) -{ - frameBuffer = CFrameBuffer::getInstance(); - font_pbar = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL; - // frame width around active bar - frame_widht = 2; - blink = bl; - invert = inv; - red = r; - green = g; - yellow = b; - width = w; - height = h; - last_width = -1; - bl_changed = g_settings.progressbar_color; -} - -CProgressBar::~CProgressBar() -{ -} - -static inline unsigned int make16color(__u32 rgb) -{ - return 0xFF000000 | rgb; -} - -void CProgressBar::paintProgressBar ( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t backgroundbar_col, - const fb_pixel_t shadowbar_col, - const char *upper_labeltext, - const uint8_t uppertext_col, - const char *iconfile, - bool paintZero) -{ - width = pb_width; - height = pb_height; - realpaint(pos_x, pos_y, value, max_value, - activebar_col, passivebar_col, backgroundbar_col, shadowbar_col, - upper_labeltext, uppertext_col, iconfile, paintZero); -} - -void CProgressBar::paintProgressBar2(const int pos_x, - const int pos_y, - const int value, - const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t frame_col, - const fb_pixel_t shadowbar_col, - const char * upper_labeltext, - const uint8_t uppertext_col, - const char * iconfile, - bool paintZero) -{ - if (height < 0 || width < 0) - { - fprintf(stderr, "CProgressBar::paintProgressBar2 height or width not set!\n"); - return; - } - realpaint(pos_x, pos_y, value, max_value, - activebar_col, passivebar_col, frame_col, shadowbar_col, - upper_labeltext, uppertext_col, iconfile, paintZero); -} - -void CProgressBar::realpaint(const int pos_x, const int pos_y, - const int val, const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t backgroundbar_col, - const fb_pixel_t shadowbar_col, - const char *upper_labeltext, - const uint8_t uppertext_col, - const char *iconfile, - bool paintZero) -{ - if(bl_changed != g_settings.progressbar_color) { - bl_changed = g_settings.progressbar_color; - reset(); - } - - /* stupid callers give invalid values like "-1"... */ - int value = val; - if (value < 0) - value = 0; - if (value > max_value) - value = max_value; - - // set colors - fb_pixel_t active_col = activebar_col != 0 ? activebar_col : COL_INFOBAR_PLUS_7; - fb_pixel_t passive_col = passivebar_col != 0 ? passivebar_col : COL_INFOBAR_PLUS_3; - - /* radius is 0 for now, since the rounded corner code is sufficiently - different from tuxbox.org's so that everything else looks 'strange' */ - const int c_rad = 0; - - /* if the bar is too small, do not draw the borders around it */ - if (height / 2 <= frame_widht || (blink && g_settings.progressbar_color) || backgroundbar_col == 0) - frame_widht = 0; - // get icon size - int icon_w = 0, icon_h = 0; - if(iconfile != NULL) - frameBuffer->getIconSize(iconfile, &icon_w, &icon_h); - - // start positions x/y active bar - int start_x = icon_w != 0 ? pos_x + icon_w + 2*frame_widht : pos_x + frame_widht; - int start_y = pos_y + frame_widht; - - // width active bar for current value - int active_pb_width; - if (max_value) - active_pb_width = (width - icon_w - 2 * frame_widht) * value / max_value; - else - active_pb_width = 0; - - // max width active/passive bar - int pb_max_width = icon_w != 0 ? (width - 2*frame_widht) - icon_w - frame_widht : width - 2*frame_widht; - - // max height progressbar bar, if icon height larger than pb_height then get height from icon - int pb_max_height = icon_h > height ? icon_h + 2* frame_widht : height; - - if (!blink || !g_settings.progressbar_color) - { - // max height of active/passive bar - int bar_height = pb_max_height - 2*frame_widht; - - int start_x_passive_bar = start_x + active_pb_width; - int width_passive_bar = pb_max_width - active_pb_width; - - // shadow - if (shadowbar_col != 0) - frameBuffer->paintBoxRel(pos_x + SHADOW_OFFSET, pos_y + SHADOW_OFFSET, - width, pb_max_height, shadowbar_col, c_rad); // shadow - - // background = frame - if (backgroundbar_col != 0) { - // we must paint background as frame, because of flicker effects at screen on fast changing values - frameBuffer->paintBoxRel(pos_x, pos_y, 10, pb_max_height, backgroundbar_col, c_rad, CORNER_LEFT); - frameBuffer->paintBoxRel(pos_x + width - 10, pos_y, 10, pb_max_height, backgroundbar_col, c_rad, CORNER_RIGHT); - frameBuffer->paintBoxRel(pos_x + 10, pos_y, width - 20, frame_widht, backgroundbar_col); - frameBuffer->paintBoxRel(pos_x + 10, pos_y + pb_max_height - frame_widht, width - 20, frame_widht, backgroundbar_col); - } - - frameBuffer->paintBoxRel(start_x, start_y, active_pb_width, bar_height, active_col); // active bar - frameBuffer->paintBoxRel(start_x_passive_bar, start_y, width_passive_bar, bar_height, passive_col); // passive bar - if (paintZero && value == 0) - frameBuffer->paintLine(pos_x+2 , pos_y+2, pos_x+width-3, pos_y+height-3, active_col); // zero line - } - else - { - int itemw = ITEMW, itemh = ITEMW, pointx = POINT, pointy = POINT; - if(g_settings.progressbar_color){ - switch ((pb_color_t)g_settings.progressbar_design){ - default: - case PB_MATRIX: /* matrix */ - break; - case PB_LINES_V: /* vert. lines */ - itemh = height; - pointy = height; - break; - case PB_LINES_H: /* horiz. lines */ - itemw = POINT; - break; - case PB_COLOR: /* filled color */ - itemw = POINT; - itemh = height; - pointy = height; - break; - } - } - const int spc = itemh - pointy; /* space between horizontal lines / points */ - int hcnt = (height + spc) / itemh; /* how many POINTs is the bar high */ - int yoff = (height + spc - itemh * hcnt) / 2; - //printf("height: %d itemh: %d hcnt: %d yoff: %d spc: %d\n", height, itemh, hcnt, yoff, spc); - /* red, yellow, green are given in percent */ - int rd = red * width / (100 * itemw); /* how many POINTs red */ - int yw = yellow * width / (100 * itemw); /* how many POINTs yellow */ - int gn = green * width / (100 * itemw); /* how many POINTs green */ - - int maxi = active_pb_width / itemw; /* how many POINTs is the active bar */ - int total = width / itemw; /* total number of POINTs */ - - uint32_t rgb; - fb_pixel_t color; - - if (last_width == -1 && backgroundbar_col != 0) /* first paint */ - { - frameBuffer->paintBoxRel(pos_x, pos_y, width, pb_max_height, backgroundbar_col); - if (shadowbar_col != 0) - frameBuffer->paintBoxRel(pos_x + SHADOW_OFFSET, pos_y + SHADOW_OFFSET, - width, pb_max_height, shadowbar_col, c_rad); // shadow - } - - if (active_pb_width != last_width) { - int i, j; - const int py = pos_y + yoff; - if (active_pb_width > last_width) { - int step, off; - int b = 0; - uint8_t diff = 0; - for (i = 0; (i < rd) && (i < maxi); i++) { - diff = i * 255 / rd; - if (invert) - rgb = GREEN + (diff << 16); // adding red - else - rgb = RED + (diff << 8); // adding green - color = make16color(rgb); - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, color); - } - step = yw - rd - 1; - if (step < 1) - step = 1; - for (; (i < yw) && (i < maxi); i++) { - diff = b++ * 255 / step / 2; - if (invert) - rgb = YELLOW - (diff << 8); // removing green - else - rgb = YELLOW - (diff << 16); // removing red - color = make16color(rgb); - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, color); - } - off = diff; - b = 0; - step = gn - yw - 1; - if (step < 1) - step = 1; - for (; (i < gn) && (i < maxi); i++) { - diff = b++ * 255 / step / 2 + off; - if (invert) - rgb = YELLOW - (diff << 8); // removing green - else - rgb = YELLOW - (diff << 16); // removing red - color = make16color(rgb); - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, color); - } - } - for(i = maxi; i < total; i++) { - for (j = 0; j < hcnt; j++) - frameBuffer->paintBoxRel(pos_x + i * itemw, py + j * itemh, - pointx, pointy, COL_INFOBAR_PLUS_3);//fill passive - } - last_width = active_pb_width; - } - } - - // paint icon if present - if (iconfile != NULL){ - int icon_y = pos_y + pb_max_height / 2 - icon_h / 2; - frameBuffer->paintIcon(iconfile, pos_x + frame_widht, icon_y); - } - - // upper text - int upper_labeltext_y = start_y - frame_widht; - if (upper_labeltext != NULL) { - g_Font[font_pbar]->RenderString(start_x +2, - upper_labeltext_y, - width, - upper_labeltext, - uppertext_col != 0 ? uppertext_col : COL_INFOBAR, - height, - true); // UTF8 - } -} - - -void CProgressBar::paintProgressBarDefault( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value) -{ - paintProgressBar (pos_x, pos_y, pb_width, pb_height, value, max_value, 0, 0, COL_INFOBAR_SHADOW_PLUS_1, 0, "", 0); -} diff --git a/src/gui/widget/progressbar.h b/src/gui/widget/progressbar.h deleted file mode 100644 index 1d2b6bf2e..000000000 --- a/src/gui/widget/progressbar.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * (C) 2008 by dbt - * (C) 2009,2010,2013 Stefan Seyfried - * - * 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. - * - * 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. - * - */ - -#ifndef __gui_widget_progressbar_h__ -#define __gui_widget_progressbar_h__ -#include "config.h" -#include -#include -#include -#include - -#include - -class CProgressBar -{ - private: - CFrameBuffer * frameBuffer; - int font_pbar; - int frame_widht; - int last_width; - int red, green, yellow; - bool blink, invert, bl_changed; - int width, height; - void realpaint(const int pos_x, const int pos_y, - const int value, const int max_value, - const fb_pixel_t activebar_col, - const fb_pixel_t passivebar_col, - const fb_pixel_t backgroundbar_col, - const fb_pixel_t shadowbar_col, - const char *upper_labeltext, - const uint8_t uppertext_col, - const char *iconfile, - bool paintZero); - - - public: - /* parameters: - blinkenligts: true if you want code to follow progressbar_color. needed, no default. - w, h: width / height of bar. Can later be set with paintProgressbar. - paintProgressBar2 can oly be used if w and h are set. - r, g, b: percentage of the bar where red/green/yellow is used. - only used if blinkenlights == true. - inv: false => red on the left side, true: red on right side. */ - CProgressBar(const bool blinkenlights, - const int w = -1, - const int h = -1, - const int r = 40, - const int g = 100, - const int b =70, - const bool inv = false); - ~CProgressBar(); - -/// void paintProgressBar(...) -/*! - description of parameters: - - position of progressbar: - pos_x > start position on screen x - pos_y > start position on screen y - pb_width > with of progressbar - pb_height > height of progressbar - - definitions of values: - value > value, you will display - max_value > maximal value that you will display - - appearance: - activebar_col > color of inner bar that shows the current value - passivebar_col > color of passive bar - frame_col > general frame color of progressbar, set 0 for no frame - shadowbar_col color > shadow behind progressbar, set 0 for no shadow - - upper_labeltext > optional, label text, will be painted upper/left the progressbar - uppertext_col > optional, but necessary with label text, color of label text - iconfile > optional, name of iconfile - paintZero > optional, if set to true and value = 0, then paints a diagonal line instead of active bar as symbolic for a zero value -*/ - void paintProgressBar ( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value, - const fb_pixel_t activebar_col = 0, - const fb_pixel_t passivebar_col = 0, - const fb_pixel_t frame_col = 0, - const fb_pixel_t shadowbar_col = 0, - const char * upper_labeltext = NULL, - const uint8_t uppertext_col = 0, - const char * iconfile = NULL, - bool paintZero = false); - - void paintProgressBar2 (const int pos_x, - const int pos_y, - const int value, - const int max_value = 100, - const fb_pixel_t activebar_col = 0, - const fb_pixel_t passivebar_col = 0, - const fb_pixel_t frame_col = 0, - const fb_pixel_t shadowbar_col = 0, - const char * upper_labeltext = NULL, - const uint8_t uppertext_col = 0, - const char * iconfile = NULL, - bool paintZero = false); - - void paintProgressBarDefault ( const int pos_x, - const int pos_y, - const int pb_width, - const int pb_height, - const int value, - const int max_value); - - void reset() { last_width = -1; } /* force update on next paint */ - - void hide(); - - enum pb_color_t { - PB_MATRIX = 0, /* 0 */ - PB_LINES_V, /* 1 */ - PB_LINES_H, /* 2 */ - PB_COLOR /* 3 */ - }; -}; - -#endif /* __gui_widget_progressbar_h__ */ diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 54f174369..8972e07c6 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -644,6 +644,8 @@ void CTextBox::hide (void) if(frameBuffer == NULL) return; - frameBuffer->paintBackgroundBoxRel(m_cFrame.iX, m_cFrame.iY, m_cFrame.iWidth, m_cFrame.iHeight); + if (m_nPaintBackground) + frameBuffer->paintBackgroundBoxRel(m_cFrame.iX, m_cFrame.iY, m_cFrame.iWidth, m_cFrame.iHeight); + frameBuffer = NULL; } diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index b7e8c1166..b3a34971e 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -72,7 +72,7 @@ class CBox public: /* Constructor */ - inline CBox(){iY = 0; iX = 0; iWidth = 0;iHeight = 0;}; + inline CBox(){iX=0; iY=0; iWidth=0; iHeight=0;}; inline CBox( const int _iX, const int _iY, const int _iWidth, const int _iHeight){iX=_iX; iY=_iY; iWidth=_iWidth; iHeight=_iHeight;}; inline ~CBox(){;}; /* Functions */ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index c8b9f5ef5..5fe846e98 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -89,10 +89,6 @@ #include "gui/pipsetup.h" #endif -#if HAVE_COOL_HARDWARE -#include "gui/widget/progressbar.h" -#endif - #include #include #include @@ -620,6 +616,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.zapto_pre_time = configfile.getInt32( "zapto_pre_time", 0); g_settings.spectrum = configfile.getBool("spectrum" , false); g_settings.channellist_additional = configfile.getInt32("channellist_additional", 2); //default minitv + g_settings.eventlist_additional = configfile.getInt32("eventlist_additional", 0); g_settings.channellist_epgtext_align_right = configfile.getBool("channellist_epgtext_align_right" , false); g_settings.channellist_extended = configfile.getBool("channellist_extended" , true); g_settings.channellist_foot = configfile.getInt32("channellist_foot" , 1);//default next Event @@ -1058,6 +1055,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32( "mode_clock", g_settings.mode_clock ); configfile.setInt32( "zapto_pre_time", g_settings.zapto_pre_time ); configfile.setBool("spectrum", g_settings.spectrum); + configfile.setInt32("eventlist_additional", g_settings.eventlist_additional); configfile.setInt32("channellist_additional", g_settings.channellist_additional); configfile.setBool("channellist_epgtext_align_right", g_settings.channellist_epgtext_align_right); configfile.setBool("channellist_extended" , g_settings.channellist_extended); diff --git a/src/neutrino_menue.h b/src/neutrino_menue.h index 3efe11bd3..970bc2afc 100644 --- a/src/neutrino_menue.h +++ b/src/neutrino_menue.h @@ -55,6 +55,7 @@ enum MN_WIDGET_ID //osd setup MN_WIDGET_ID_OSDSETUP, MN_WIDGET_ID_OSDSETUP_CHANNELLIST, + MN_WIDGET_ID_OSDSETUP_EVENTLIST, MN_WIDGET_ID_OSDSETUP_FONT, MN_WIDGET_ID_OSDSETUP_FONTSCALE, MN_WIDGET_ID_OSDSETUP_INFOBAR, diff --git a/src/system/locals.h b/src/system/locals.h index 970327326..b2fc84933 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -348,6 +348,8 @@ typedef enum LOCALE_EVENTFINDER_SEARCH_WITHIN_LIST, LOCALE_EVENTFINDER_SEARCHING, LOCALE_EVENTFINDER_START_SEARCH, + LOCALE_EVENTLIST_ADDITIONAL, + LOCALE_EVENTLIST_NAME, LOCALE_EVENTLISTBAR_CHANNELSWITCH, LOCALE_EVENTLISTBAR_EVENTSORT, LOCALE_EVENTLISTBAR_RECORDEVENT, @@ -562,6 +564,7 @@ typedef enum LOCALE_FONTSIZE_EPG_INFO2, LOCALE_FONTSIZE_EPG_TITLE, LOCALE_FONTSIZE_EVENTLIST_DATETIME, + LOCALE_FONTSIZE_EVENTLIST_EVENT, LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, LOCALE_FONTSIZE_EVENTLIST_TITLE, @@ -610,6 +613,7 @@ typedef enum LOCALE_IMAGEINFO_HEAD, LOCALE_IMAGEINFO_HOMEPAGE, LOCALE_IMAGEINFO_IMAGE, + LOCALE_IMAGEINFO_KERNEL, LOCALE_IMAGEINFO_LICENSE, LOCALE_IMAGEINFO_VERSION, LOCALE_INETRADIO_NAME, @@ -797,7 +801,9 @@ typedef enum LOCALE_MENU_HINT_EPG_SAVE, LOCALE_MENU_HINT_EPG_SAVE_STANDBY, LOCALE_MENU_HINT_EVENT_TEXTCOLOR, + LOCALE_MENU_HINT_EVENTLIST_ADDITIONAL, LOCALE_MENU_HINT_EVENTLIST_FONTS, + LOCALE_MENU_HINT_EVENTLIST_SETUP, LOCALE_MENU_HINT_EXTENDED, LOCALE_MENU_HINT_FACTORY, LOCALE_MENU_HINT_FADE, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 909e97512..64b2eff8f 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -348,6 +348,8 @@ const char * locale_real_names[] = "eventfinder.search_within_list", "eventfinder.searching", "eventfinder.start_search", + "eventlist.additional", + "eventlist.name", "eventlistbar.channelswitch", "eventlistbar.eventsort", "eventlistbar.recordevent", @@ -562,6 +564,7 @@ const char * locale_real_names[] = "fontsize.epg_info2", "fontsize.epg_title", "fontsize.eventlist_datetime", + "fontsize.eventlist_event", "fontsize.eventlist_itemlarge", "fontsize.eventlist_itemsmall", "fontsize.eventlist_title", @@ -610,6 +613,7 @@ const char * locale_real_names[] = "imageinfo.head", "imageinfo.homepage", "imageinfo.image", + "imageinfo.kernel", "imageinfo.license", "imageinfo.version", "inetradio.name", @@ -797,7 +801,9 @@ const char * locale_real_names[] = "menu.hint_epg_save", "menu.hint_epg_save_standby", "menu.hint_event_textcolor", + "menu.hint_eventlist_additional", "menu.hint_eventlist_fonts", + "menu.hint_eventlist_setup", "menu.hint_extended", "menu.hint_factory", "menu.hint_fade", diff --git a/src/system/settings.h b/src/system/settings.h index 983cb2c8e..d6ffa8cec 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -432,6 +432,7 @@ struct SNeutrinoSettings int pip_y; int bigFonts; int big_windows; + int eventlist_additional; int channellist_additional; int channellist_epgtext_align_right; int channellist_extended; @@ -617,6 +618,15 @@ struct SNeutrinoSettings std::string usermenu_text[BUTTON_MAX]; int usermenu[BUTTON_MAX][ITEM_MAX]; // (USER_ITEM) [button][position in Menue] = feature item + //progressbar arrangement for infobar + typedef enum + { + INFOBAR_PROGRESSBAR_ARRANGEMENT_DEFAULT = 0, + INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME = 1, + INFOBAR_PROGRESSBAR_ARRANGEMENT_BELOW_CH_NAME_SMALL = 2, + INFOBAR_PROGRESSBAR_ARRANGEMENT_BETWEEN_EVENTS = 3 + }INFOBAR_PROGRESSBAR_ARRANGEMENT_TYPES; + }; /* some default Values */