예제 #1
0
void eWidgetDesktop::recalcClipRegions(eWidget *root)
{
	if (m_comp_mode == cmImmediate)
	{
		gRegion background_before = m_screen.m_background_region;

		m_screen.m_background_region = gRegion(eRect(ePoint(0, 0), m_screen.m_screen_size));

		for (ePtrList<eWidget>::iterator i(m_root.begin()); i != m_root.end(); ++i)
		{
			if (!(i->m_vis & eWidget::wVisShow))
			{
				clearVisibility(i);
				continue;
			}

			gRegion visible_before = i->m_visible_with_childs;

			calcWidgetClipRegion(*i, m_screen.m_background_region);

			gRegion redraw = (i->m_visible_with_childs - visible_before) | (visible_before - i->m_visible_with_childs);

			redraw.moveBy(i->position());

			invalidate(redraw);
		}

		gRegion redraw = (background_before - m_screen.m_background_region) | (m_screen.m_background_region - background_before);
		invalidate(redraw);
	} else if (m_comp_mode == cmBuffered)
	{
		if (!root->m_vis & eWidget::wVisShow)
		{
			clearVisibility(root);
			for (int i = 0; i < MAX_LAYER; ++i)
				removeBufferForWidget(root, i);
			return;
		}

		for (int i = 0; i < MAX_LAYER; ++i)
		{
			eWidgetDesktopCompBuffer *comp = root->m_comp_buffer[i];

					/* TODO: layers might not be required to have the screen size, for memory reasons. */
			if ((i == 0 && !comp) || (comp && (root->size() != comp->m_screen_size)))
				createBufferForWidget(root, 0);

			comp = root->m_comp_buffer[i]; /* it might have changed. */

			if (!comp)
				continue;  /* WAIT, don't we need to invalidate,whatever */

					/* CHECKME: don't we need to recalculate everything? after all, our buffer has changed and is likely to be cleared */
		 	gRegion visible_before = root->m_visible_with_childs;

			comp->m_background_region = gRegion(eRect(comp->m_position, comp->m_screen_size));

			gRegion visible_new = root->m_visible_with_childs - visible_before;
			gRegion visible_lost = visible_before - root->m_visible_with_childs;
			visible_new.moveBy(root->position());
			visible_lost.moveBy(root->position());

			invalidate(visible_new, root, i);
			invalidate(visible_lost, root, i);

			calcWidgetClipRegion(root, comp->m_background_region);
		}
	}
}
예제 #2
0
int eListbox::event(int event, void *data, void *data2)
{
	switch (event)
	{
	case evtPaint:
	{
		ePtr<eWindowStyle> style;
		
		if (!m_content)
			return eWidget::event(event, data, data2);
		ASSERT(m_content);
		
		getStyle(style);
		
		if (!m_content)
			return 0;
		
		gPainter &painter = *(gPainter*)data2;
		
		m_content->cursorSave();
		m_content->cursorMove(m_top - m_selected);
		
		gRegion entryrect = eRect(0, 0, size().width(), m_itemheight);
		const gRegion &paint_region = *(gRegion*)data;

		for (int y = 0, i = 0; i <= m_items_per_page; y += m_itemheight, ++i)
		{
			gRegion entry_clip_rect = paint_region & entryrect;

			if (!entry_clip_rect.empty())
				m_content->paint(painter, *style, ePoint(0, y), m_selected == m_content->cursorGet() && m_content->size() && m_selection_enabled);

				/* (we could clip with entry_clip_rect, but 
				   this shouldn't change the behavior of any
				   well behaving content, so it would just
				   degrade performance without any gain.) */

			m_content->cursorMove(+1);
			entryrect.moveBy(ePoint(0, m_itemheight));
		}

		// clear/repaint empty/unused space between scrollbar and listboxentrys
		if (m_scrollbar && m_scrollbar->isVisible())
		{
			style->setStyle(painter, eWindowStyle::styleListboxNormal);
			painter.clip(eRect(m_scrollbar->position() - ePoint(5,0), eSize(5,m_scrollbar->size().height())));
			painter.clear();
			painter.clippop();
		}

		m_content->cursorRestore();

		return 0;
	}

	case evtChangedSize:
		recalcSize();
		return eWidget::event(event, data, data2);
		
	case evtAction:
		if (isVisible())
		{
			moveSelection((long)data2);
			return 1;
		}
		return 0;
	default:
		return eWidget::event(event, data, data2);
	}
}
예제 #3
0
void eTimeCorrectionEditWindow::init_eTimeCorrectionEditWindow( tsref tp )
{
	int clktype = 0;
	eConfig::getInstance()->getKey("/ezap/osd/12hourClock", clktype);

	setText(_("Time Correction"));
	cresize( eSize(440,290 ) );
	valign();

	eLabel *l = new eLabel(this);
	l->move( ePoint(10,10) );
	l->resize( eSize(200,30));
	l->setText(_("Receiver Time:"));

	lCurTime = new eLabel(this);
	lCurTime->move( ePoint(210,10) );
	lCurTime->resize( eSize(100,30) );

	lCurDate = new eLabel(this);
	lCurDate->move( ePoint(320,10) );
	lCurDate->resize( eSize(120,30) );

	l = new eLabel(this);
	l->move( ePoint(10,50) );
	l->resize( eSize(200,30));
	l->setText(_("Transponder Time:"));

	lTpTime = new eLabel(this);
	lTpTime->move( ePoint(210,50) );
	lTpTime->resize( eSize(100,30) );

	lTpDate = new eLabel(this);
	lTpDate->move( ePoint(320,50) );
	lTpDate->resize( eSize(120,30) );

	l = new eLabel(this);
	l->setText(_("New Time:"));
	l->setFlags( eLabel::flagVCenter );
	l->move( ePoint(10,90) );
	l->resize( eSize(150,35) );

	time_t now = time(0)+eDVB::getInstance()->time_difference;
	tm tmp = *localtime( &now );

	nTime = new eNumber(this, 2, 0, 59, 2, 0, 0, l);
	nTime->resize(eSize(75,35));
	nTime->move(ePoint(210,90));
	nTime->setFlags( eNumber::flagVCenter|eNumber::flagTime|eNumber::flagFillWithZeros );
	nTime->loadDeco();
	nTime->setHelpText(_("enter correct time here"));
	nTime->setNumber(1, tmp.tm_min );
	if (clktype)
	{
		nTime->setNumber(0, tmp.tm_hour%12 ? tmp.tm_hour%12 : 12 );
		nTimeAmpm = new eCheckbox(this);
		nTimeAmpm->resize(eSize(90,35));
		nTimeAmpm->move(ePoint(290,90));
		nTimeAmpm->setText(_("AM/pm"));
		nTimeAmpm->setHelpText(_("Checked is AM, unchecked is PM"));
		nTimeAmpm->setCheck(tmp.tm_hour < 12 ? 1 : 0);
	}
	else
		nTime->setNumber(0, tmp.tm_hour );
	CONNECT( nTime->selected, eTimeCorrectionEditWindow::fieldSelected );

	l = new eLabel(this);
	l->setText(_("New Date:"));
	l->setFlags( eLabel::flagVCenter );
	l->move( ePoint(10,140) );
	l->resize( eSize(150,35) );

	cday = new eComboBox(this);
	cday->move(ePoint(210,140));
	cday->resize(eSize(60,35));
	cday->loadDeco();
	cday->setHelpText(_("press ok to select another day"));

	cmonth = new eComboBox( this );
	cmonth->move(ePoint(280,140));
	cmonth->resize(eSize(60,35));
	cmonth->loadDeco();
	cmonth->setHelpText(_("press ok to select another month"));
	for ( int i = 0; i < 12; i++ )
		new eListBoxEntryText( *cmonth, eString().sprintf("%02d",i+1), (void*)i );
	CONNECT( cmonth->selchanged, eTimeCorrectionEditWindow::monthChanged );

	cyear = new eComboBox(this);
	cyear->move(ePoint(350,140));
	cyear->resize(eSize(80,35));
	cyear->loadDeco();
	cyear->setHelpText(_("press ok to select another year"));
	for ( int i = -1; i < 4; i++ )
		new eListBoxEntryText( *cyear, eString().sprintf("%d",tmp.tm_year+(1900+i)), (void*)(tmp.tm_year+i) );

	cyear->setCurrent( (void*) tmp.tm_year );
	cmonth->setCurrent( (void*) tmp.tm_mon, true );
	cday->setCurrent( (void*) tmp.tm_mday );
	CONNECT( cyear->selchanged, eTimeCorrectionEditWindow::yearChanged );

	bSet=new eButton(this);
	bSet->setText(_("set"));
	bSet->setShortcut("green");
	bSet->setShortcutPixmap("green");

	bSet->move(ePoint(10, clientrect.height()-100));
	bSet->resize(eSize(220,40));
	bSet->setHelpText(_("set new time and close window"));
	bSet->loadDeco();
	CONNECT(bSet->selected, eTimeCorrectionEditWindow::savePressed);

	sbar = new eStatusBar(this);
	sbar->move( ePoint(0, clientrect.height()-50) );
	sbar->resize( eSize( clientrect.width(), 50) );
	sbar->loadDeco();
	CONNECT( updateTimer.timeout, eTimeCorrectionEditWindow::updateTimeDate );
}
예제 #4
0
void eLabel::redrawWidget(gPainter *target, const eRect &rc)
{
/*	eDebug("decoStr = %s, text=%s, name=%s, %p left = %d, top = %d, width=%d, height = %d", strDeco?strDeco.c_str():"no", text?text.c_str():"no" , name?name.c_str():"no", this, this->getPosition().x(), this->getPosition().y(), this->getSize().width(), this->getSize().height() ); 
	eDebug("renderContext left = %d, top = %d, width = %d, height = %d", rc.left(), rc.top(), rc.width(), rc.height() );*/

	target->clip( rc );
	eRect area=clientrect;
/*	eDebug("area left = %d, top = %d, width = %d, height = %d",
		area.left(), area.top(),
		area.width(), area.height() );*/

	if (deco_selected && have_focus)
	{
		deco_selected.drawDecoration(target, ePoint(width(), height()));
		area=crect_selected;
	} else if (deco)
	{
		deco.drawDecoration(target, ePoint(width(), height()));
		area=crect;
	}
	target->clippop();
	target->clip( area );
	if (shortcutPixmap)
	{
		//area.setWidth(area.width()-area.height());
		area.setX(area.height());
	}

	if (text.length())
	{
		if ( area.size().height() < size.height() ||
				area.size().width() < size.width() )
		{
		// then deco is drawed
			eSize s=area.size();
			validate( &s );
		} else
			validate();

		if (flags & flagVCenter)
			yOffs = ( (area.height() - para->getBoundBox().height() ) / 2 + 0) - para->getBoundBox().top();
		else
			yOffs = 0;

		eWidget *w;
		if ((blitFlags & BF_ALPHATEST) && (transparentBackgroundColor >= 0))
		{
			w=this;
			target->setBackgroundColor(transparentBackgroundColor);
		} else
		{
			w=getNonTransparentBackground();
			target->setBackgroundColor(w->getBackgroundColor());
		}
		target->setFont(font);
		target->renderPara(*para, ePoint( area.left(), area.top()+yOffs) );
	}
	if (pixmap)
	{
//		eDebug("blit pixmap area left=%d, top=%d, right=%d, bottom=%d", rc.left(), rc.top(), rc.right(), rc.bottom() );
//		eDebug("pixmap_pos x = %d, y = %d, xsize=%d, ysize=%d", pixmap_position.x(), pixmap_position.y(), pixmap->x, pixmap->y );
		if (flags & flagVCenter)
			pixmap_position.setY(area.top()+(area.height() - pixmap->y)/2);
		if (align == eTextPara::dirCenter)
			pixmap_position.setX(area.left()+(area.width() - pixmap->x)/2);
		target->blit(*pixmap, shortcutPixmap?pixmap_position+ePoint( area.left(), 0):pixmap_position, area, /*(blitFlags & BF_ALPHATEST) ?*/ gPixmap::blitAlphaTest/* : 0*/);
	}
	if (shortcutPixmap)
		target->blit(*shortcutPixmap, 
				ePoint((area.height()-shortcutPixmap->x)/2, area.top()+(area.height()-shortcutPixmap->y)/2),
				eRect(),
				gPixmap::blitAlphaTest);
	target->clippop();
}
예제 #5
0
파일: ui.cpp 프로젝트: djdron/UnrealSpeccyP
ePoint FontSize() { return ePoint(font.w, font.h); }
예제 #6
0
파일: bsod.cpp 프로젝트: kingvuplus/rr
void bsodFatal(const char *component)
{
	/* show no more than one bsod while shutting down/crashing */
	if (bsodhandled) return;
	bsodhandled = true;

	std::string lines = getLogBuffer();

		/* find python-tracebacks, and extract "  File "-strings */
	size_t start = 0;

	std::string crash_emailaddr = CRASH_EMAILADDR;
	std::string crash_component = "enigma2";

	if (component)
		crash_component = component;
	else
	{
		while ((start = lines.find("\n  File \"", start)) != std::string::npos)
		{
			start += 9;
			size_t end = lines.find("\"", start);
			if (end == std::string::npos)
				break;
			end = lines.rfind("/", end);
				/* skip a potential prefix to the path */
			unsigned int path_prefix = lines.find("/usr/", start);
			if (path_prefix != std::string::npos && path_prefix < end)
				start = path_prefix;

			if (end == std::string::npos)
				break;

			std::string filename(lines.substr(start, end - start) + INFOFILE);
			std::ifstream in(filename.c_str());
			if (in.good()) {
				std::getline(in, crash_emailaddr) && std::getline(in, crash_component);
				in.close();
			}
		}
	}

	FILE *f;
	std::string crashlog_name;
	std::ostringstream os;
	os << "/media/hdd/enigma2_crash_";
	os << time(0);
	os << ".log";
	crashlog_name = os.str();
	f = fopen(crashlog_name.c_str(), "wb");

	if (f == NULL)
	{
		/* No hardisk. If there is a crash log in /home/root, leave it
		 * alone because we may be in a crash loop and writing this file
		 * all night long may damage the flash. Also, usually the first
		 * crash log is the most interesting one. */
		crashlog_name = "/home/root/enigma2_crash.log";
		if ((access(crashlog_name.c_str(), F_OK) == 0) ||
		    ((f = fopen(crashlog_name.c_str(), "wb")) == NULL))
		{
			/* Re-write the same file in /tmp/ because it's expected to
			 * be in RAM. So the first crash log will end up in /home
			 * and the last in /tmp */
			crashlog_name = "/tmp/enigma2_crash.log";
			f = fopen(crashlog_name.c_str(), "wb");
		}
	}

	if (f)
	{
		time_t t = time(0);
		struct tm tm;
		char tm_str[32];

		localtime_r(&t, &tm);
		strftime(tm_str, sizeof(tm_str), "%a %b %_d %T %Y", &tm);

		XmlGenerator xml(f);

		xml.open("BlakHole");

		xml.open("enigma2");
		xml.string("crashdate", tm_str);
		xml.string("compiledate", __DATE__);
		xml.string("contactemail", crash_emailaddr);
		xml.comment("Please email this crashlog to above address");

		xml.string("skin", getConfigString("config.skin.primary_skin", "Default Skin"));
		xml.string("sourcedate", enigma2_date);
		xml.string("branch", enigma2_branch);
		xml.string("rev", enigma2_rev);
		xml.string("version", PACKAGE_VERSION);
		xml.close();

		xml.open("image");
		if(access("/proc/stb/info/boxtype", F_OK) != -1) {
			xml.stringFromFile("stbmodel", "/proc/stb/info/boxtype");
		}
		else if (access("/proc/stb/info/vumodel", F_OK) != -1) {
			xml.stringFromFile("stbmodel", "/proc/stb/info/vumodel");
		}
		else if (access("/proc/stb/info/model", F_OK) != -1) {
			xml.stringFromFile("stbmodel", "/proc/stb/info/model");
		}
		xml.cDataFromCmd("kernelversion", "uname -a");
		xml.stringFromFile("kernelcmdline", "/proc/cmdline");
		xml.stringFromFile("nimsockets", "/proc/bus/nim_sockets");
		xml.cDataFromFile("imageversion", "/etc/image-version");
		xml.cDataFromFile("imageissue", "/etc/issue.net");
		xml.close();

		xml.open("crashlogs");
		xml.cDataFromString("enigma2crashlog", getLogBuffer());
		xml.close();

		xml.close();

		fclose(f);
	}

	ePtr<gMainDC> my_dc;
	gMainDC::getInstance(my_dc);

	gPainter p(my_dc);
	p.resetOffset();
	p.resetClip(eRect(ePoint(0, 0), my_dc->size()));
	p.setBackgroundColor(gRGB(0x008000));
	p.setForegroundColor(gRGB(0xFFFFFF));

	int hd =  my_dc->size().width() == 1920;
	ePtr<gFont> font = new gFont("Regular", hd ? 30 : 20);
	p.setFont(font);
	p.clear();

	eRect usable_area = eRect(hd ? 30 : 100, hd ? 30 : 70, my_dc->size().width() - (hd ? 60 : 150), hd ? 150 : 100);

	os.str("");
	os.clear();
	os << "We are really sorry. Your STB encountered "
		"a software problem, and needs to be restarted.\n"
		"Please send the logfile " << crashlog_name << " to " << crash_emailaddr << ".\n"
		"Your STB restarts in 10 seconds!\n"
		"Component: " << crash_component;

	p.renderText(usable_area, os.str().c_str(), gPainter::RT_WRAP|gPainter::RT_HALIGN_LEFT);

	usable_area = eRect(hd ? 30 : 100, hd ? 180 : 170, my_dc->size().width() - (hd ? 60 : 180), my_dc->size().height() - (hd ? 30 : 20));

	int i;

	start = std::string::npos + 1;
	for (i=0; i<20; ++i)
	{
		start = lines.rfind('\n', start - 1);
		if (start == std::string::npos)
		{
			start = 0;
			break;
		}
	}

	font = new gFont("Regular", hd ? 21 : 14);
	p.setFont(font);

	p.renderText(usable_area,
		lines.substr(start), gPainter::RT_HALIGN_LEFT);
	sleep(10);

	/*
	 * When 'component' is NULL, we are called because of a python exception.
	 * In that case, we'd prefer to to a clean shutdown of the C++ objects,
	 * and this should be safe, because the crash did not occur in the
	 * C++ part.
	 * However, when we got here for some other reason, a segfault probably,
	 * we prefer to stop immediately instead of performing a clean shutdown.
	 * We'd risk destroying things with every additional instruction we're
	 * executing here.
	 */
	if (component) raise(SIGKILL);
}
예제 #7
0
ePoint eLabel::getLeftTop()
{
	validate();
	return ePoint(para->getBoundBox().left(), para->getBoundBox().top());
}
void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
{
	painter.clip(eRect(offset, m_itemsize));

	int marked = 0;

	if (m_current_marked && selected)
		marked = 2;
	else if (cursorValid() && isMarked(*m_cursor))
	{
		if (selected)
			marked = 2;
		else
			marked = 1;
	}
	else
		style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);

	eListboxStyle *local_style = 0;

		/* get local listbox style, if present */
	if (m_listbox)
		local_style = m_listbox->getLocalStyle();

	if (marked == 1)  // marked
	{
		style.setStyle(painter, eWindowStyle::styleListboxMarked);
		if (m_color_set[markedForeground])
			painter.setForegroundColor(m_color[markedForeground]);
		if (m_color_set[markedBackground])
			painter.setBackgroundColor(m_color[markedBackground]);
	}
	else if (marked == 2) // marked and selected
	{
		style.setStyle(painter, eWindowStyle::styleListboxMarkedAndSelected);
		if (m_color_set[markedForegroundSelected])
			painter.setForegroundColor(m_color[markedForegroundSelected]);
		if (m_color_set[markedBackgroundSelected])
			painter.setBackgroundColor(m_color[markedBackgroundSelected]);
	}
	else if (local_style)
	{
		if (selected)
		{
			/* if we have a local background color set, use that. */
			if (local_style->m_background_color_selected_set)
				painter.setBackgroundColor(local_style->m_background_color_selected);
			/* same for foreground */
			if (local_style->m_foreground_color_selected_set)
				painter.setForegroundColor(local_style->m_foreground_color_selected);
		}
		else
		{
			/* if we have a local background color set, use that. */
			if (local_style->m_background_color_set)
				painter.setBackgroundColor(local_style->m_background_color);
			/* same for foreground */
			if (local_style->m_foreground_color_set)
				painter.setForegroundColor(local_style->m_foreground_color);
		}
	}

	if (!local_style || !local_style->m_transparent_background)
		/* if we have no transparent background */
	{
		/* blit background picture, if available (otherwise, clear only) */
		if (local_style && local_style->m_background)
			painter.blit(local_style->m_background, offset, eRect(), 0);
		else
			painter.clear();
	} else
	{
		if (local_style->m_background)
			painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST);
		else if (selected && !local_style->m_selection)
			painter.clear();
	}

	if (cursorValid())
	{
		/* get service information */
		ePtr<iStaticServiceInformation> service_info;
		m_service_center->info(*m_cursor, service_info);
		eServiceReference ref = *m_cursor;
		bool isMarker = ref.flags & eServiceReference::isMarker;
		bool isPlayable = !(ref.flags & eServiceReference::isDirectory || isMarker);
		bool isRecorded = m_record_indicator_mode && isPlayable && checkServiceIsRecorded(ref);
		ePtr<eServiceEvent> evt;
		bool serviceAvail = true;
		bool serviceFallback = false;
		int isplayable_value;

		if (!marked && isPlayable && service_info && m_is_playable_ignore.valid())
		{
			isplayable_value = service_info->isPlayable(*m_cursor, m_is_playable_ignore);

			if (isplayable_value == 0) // service unavailable
			{
				if (m_color_set[serviceNotAvail])
					painter.setForegroundColor(m_color[serviceNotAvail]);
				else
					painter.setForegroundColor(gRGB(0xbbbbbb));
				serviceAvail = false;
			}
			else
			{
				if (isplayable_value == 2) // fallback receiver service
				{
					if (m_color_set[serviceItemFallback])
						painter.setForegroundColor(m_color[serviceItemFallback]);
					serviceFallback = true;
				}
			}
		}
		if (m_record_indicator_mode == 3 && isRecorded)
		{
			if (m_color_set[serviceRecorded])
				painter.setForegroundColor(m_color[serviceRecorded]);
			else
				painter.setForegroundColor(gRGB(0xb40431));
		}

		if (selected && local_style && local_style->m_selection)
			painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);

		int xoffset=0;  // used as offset when painting the folder/marker symbol or the serviceevent progress
		time_t now = time(0);

		for (int e = 0; e != celServiceTypePixmap; ++e)
		{
			if (m_element_font[e])
			{
				int flags=gPainter::RT_VALIGN_CENTER;
				int yoffs = 0;
				eRect area = m_element_position[e];
				std::string text = "<n/a>";
				switch (e)
				{
				case celServiceNumber:
				{
					if (area.width() <= 0)
						continue; // no point in going on if we won't paint anything

					if( m_cursor->getChannelNum() == 0 )
						continue;

					char buffer[15];
					snprintf(buffer, sizeof(buffer), "%d", m_cursor->getChannelNum() );
					text = buffer;
					flags|=gPainter::RT_HALIGN_RIGHT;
					if (isPlayable && serviceFallback && selected && m_color_set[serviceSelectedFallback])
						painter.setForegroundColor(m_color[serviceSelectedFallback]);
					break;
				}
				case celServiceName:
				{
					if (service_info)
						service_info->getName(*m_cursor, text);
					if (!isPlayable)
					{
						area.setWidth(area.width() + m_element_position[celServiceEventProgressbar].width() +  m_nonplayable_margins);
						if (m_element_position[celServiceEventProgressbar].left() == 0)
							area.setLeft(0);
						if (m_element_position[celServiceNumber].width() && m_element_position[celServiceEventProgressbar].left() == m_element_position[celServiceNumber].width() +  m_nonplayable_margins)
							area.setLeft(m_element_position[celServiceNumber].width() +  m_nonplayable_margins);
					}
					if (!(m_record_indicator_mode == 3 && isRecorded) && isPlayable && serviceFallback && selected && m_color_set[serviceSelectedFallback])
						painter.setForegroundColor(m_color[serviceSelectedFallback]);
					break;
				}
				case celServiceInfo:
				{
					if ( isPlayable && service_info && !service_info->getEvent(*m_cursor, evt) )
					{
						std::string name = evt->getEventName();
						if (name.empty())
							continue;
						text = evt->getEventName();
						if (serviceAvail)
						{
							if (!selected && m_color_set[eventForeground])
								painter.setForegroundColor(m_color[eventForeground]);
							else if (selected && m_color_set[eventForegroundSelected])
								painter.setForegroundColor(m_color[eventForegroundSelected]);
							else
								painter.setForegroundColor(gRGB(0xe7b53f));

							if (serviceFallback && !selected && m_color_set[eventForegroundFallback]) // fallback receiver
								painter.setForegroundColor(m_color[eventForegroundFallback]);
							else if (serviceFallback && selected && m_color_set[eventForegroundSelectedFallback])
								painter.setForegroundColor(m_color[eventForegroundSelectedFallback]);

						}
						break;
					}
					continue;
				}
				case celServiceEventProgressbar:
				{
					if (area.width() > 0 && isPlayable && service_info && !service_info->getEvent(*m_cursor, evt))
					{
						char buffer[15];
						snprintf(buffer, sizeof(buffer), "%d %%", (int)(100 * (now - evt->getBeginTime()) / evt->getDuration()));
						text = buffer;
						flags|=gPainter::RT_HALIGN_RIGHT;
						break;
					}
					continue;
				}
				}

				eRect tmp = area;
				int xoffs = 0;
				ePtr<gPixmap> piconPixmap;

				if (e == celServiceName)
				{
					//picon stuff
					if (isPlayable && PyCallable_Check(m_GetPiconNameFunc))
					{
						ePyObject pArgs = PyTuple_New(1);
						PyTuple_SET_ITEM(pArgs, 0, PyString_FromString(ref.toString().c_str()));
						ePyObject pRet = PyObject_CallObject(m_GetPiconNameFunc, pArgs);
						Py_DECREF(pArgs);
						if (pRet)
						{
							if (PyString_Check(pRet))
							{
								std::string piconFilename = PyString_AS_STRING(pRet);
								if (!piconFilename.empty())
									loadPNG(piconPixmap, piconFilename.c_str());
							}
							Py_DECREF(pRet);
						}
					}
					xoffs = xoffset;
					tmp.setWidth(((!isPlayable || m_column_width == -1 || (!piconPixmap && !m_column_width)) ? tmp.width() : m_column_width) - xoffs);
				}

				eTextPara *para = new eTextPara(tmp);
				para->setFont(m_element_font[e]);
				para->renderString(text.c_str());

				if (e == celServiceName)
				{
					eRect bbox = para->getBoundBox();

					int servicenameWidth = ((!isPlayable || m_column_width == -1 || (!piconPixmap && !m_column_width)) ? bbox.width() : m_column_width);
					m_element_position[celServiceInfo].setLeft(area.left() + servicenameWidth + m_items_distances + xoffs);
					m_element_position[celServiceInfo].setTop(area.top());
					m_element_position[celServiceInfo].setWidth(area.width() - (servicenameWidth + m_items_distances + xoffs));
					m_element_position[celServiceInfo].setHeight(area.height());

					if (isPlayable)
					{
						//picon stuff
						if (PyCallable_Check(m_GetPiconNameFunc) and (m_column_width || piconPixmap))
						{
							eRect area = m_element_position[celServiceInfo];
							/* PIcons are usually about 100:60. Make it a
							 * bit wider in case the icons are diffently
							 * shaped, and to add a bit of margin between
							 * icon and text. */
							const int iconWidth = area.height() * 9 / 5;
							m_element_position[celServiceInfo].setLeft(area.left() + iconWidth);
							m_element_position[celServiceInfo].setWidth(area.width() - iconWidth);
							area = m_element_position[celServiceName];
							xoffs += iconWidth;
							if (piconPixmap)
							{
								area.moveBy(offset);
								painter.clip(area);
								painter.blitScale(piconPixmap,
									eRect(area.left(), area.top(), iconWidth, area.height()),
									area,
									gPainter::BT_ALPHABLEND | gPainter::BT_KEEP_ASPECT_RATIO);
								painter.clippop();
							}
						}

						//service type marker stuff
						if (m_servicetype_icon_mode)
						{
							int orbpos = m_cursor->getUnsignedData(4) >> 16;
							const char *filename = ref.path.c_str();
							ePtr<gPixmap> &pixmap =
								(m_cursor->flags & eServiceReference::isGroup) ? m_pixmaps[picServiceGroup] :
								(strstr(filename, "://")) ? m_pixmaps[picStream] :
								(orbpos == 0xFFFF) ? m_pixmaps[picDVB_C] :
								(orbpos == 0xEEEE) ? m_pixmaps[picDVB_T] : m_pixmaps[picDVB_S];
							if (pixmap)
							{
								eSize pixmap_size = pixmap->size();
								eRect area = m_element_position[celServiceInfo];
								m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + m_items_distances);
								m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - m_items_distances);
								int offs = 0;
								if (m_servicetype_icon_mode == 1)
								{
									area = m_element_position[celServiceName];
									offs = xoffs;
									xoffs += pixmap_size.width() + m_items_distances;
								}
								else if (m_crypto_icon_mode == 1 && m_pixmaps[picCrypto])
									offs = offs + m_pixmaps[picCrypto]->size().width() + m_items_distances;
								int correction = (area.height() - pixmap_size.height()) / 2;
								area.moveBy(offset);
								painter.clip(area);
								painter.blit(pixmap, ePoint(area.left() + offs, offset.y() + correction), area, gPainter::BT_ALPHATEST);
								painter.clippop();
							}
						}

						//crypto icon stuff
						if (m_crypto_icon_mode && m_pixmaps[picCrypto])
						{
							eSize pixmap_size = m_pixmaps[picCrypto]->size();
							eRect area = m_element_position[celServiceInfo];
							int offs = 0;
							if (m_crypto_icon_mode == 1)
							{
								m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + m_items_distances);
								m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - m_items_distances);
								area = m_element_position[celServiceName];
								offs = xoffs;
								xoffs += pixmap_size.width() + m_items_distances;
							}
							int correction = (area.height() - pixmap_size.height()) / 2;
							area.moveBy(offset);
							if (service_info->isCrypted())
							{
								if (m_crypto_icon_mode == 2)
								{
									m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + m_items_distances);
									m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - m_items_distances);
								}
								painter.clip(area);
								painter.blit(m_pixmaps[picCrypto], ePoint(area.left() + offs, offset.y() + correction), area, gPainter::BT_ALPHATEST);
								painter.clippop();
							}
						}

						//record icon stuff
						if (isRecorded && m_record_indicator_mode < 3 && m_pixmaps[picRecord])
						{
							eSize pixmap_size = m_pixmaps[picRecord]->size();
							eRect area = m_element_position[celServiceInfo];
							int offs = 0;
							if (m_record_indicator_mode == 1)
							{
								m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + m_items_distances);
								m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - m_items_distances);
								area = m_element_position[celServiceName];
								offs = xoffs;
								xoffs += pixmap_size.width() + m_items_distances;
							}
							int correction = (area.height() - pixmap_size.height()) / 2;
							area.moveBy(offset);
							if (m_record_indicator_mode == 2)
							{
								m_element_position[celServiceInfo].setLeft(area.left() + pixmap_size.width() + m_items_distances);
								m_element_position[celServiceInfo].setWidth(area.width() - pixmap_size.width() - m_items_distances);
							}
							painter.clip(area);
							painter.blit(m_pixmaps[picRecord], ePoint(area.left() + offs, offset.y() + correction), area, gPainter::BT_ALPHATEST);
							painter.clippop();
						}
					}
				}

				if (flags & gPainter::RT_HALIGN_RIGHT)
					para->realign(eTextPara::dirRight);
				else if (flags & gPainter::RT_HALIGN_CENTER)
					para->realign(eTextPara::dirCenter);
				else if (flags & gPainter::RT_HALIGN_BLOCK)
					para->realign(eTextPara::dirBlock);

				if (flags & gPainter::RT_VALIGN_CENTER)
				{
					eRect bbox = para->getBoundBox();
					yoffs = (area.height() - bbox.height()) / 2 - bbox.top();
				}

				painter.renderPara(para, offset+ePoint(xoffs, yoffs));
			}
			else if ((e == celFolderPixmap && m_cursor->flags & eServiceReference::isDirectory) ||
				(e == celMarkerPixmap && m_cursor->flags & eServiceReference::isMarker &&
				!(m_cursor->flags & eServiceReference::isNumberedMarker)))
			{
				ePtr<gPixmap> &pixmap =
					(e == celFolderPixmap) ? m_pixmaps[picFolder] : m_pixmaps[picMarker];
				if (pixmap)
				{
					eSize pixmap_size = pixmap->size();
					eRect area;
					if (e == celFolderPixmap || m_element_position[celServiceNumber].width() < pixmap_size.width())
					{
						area = m_element_position[celServiceName];
						if (m_element_position[celServiceEventProgressbar].left() == 0)
							area.setLeft(0);
						xoffset = pixmap_size.width() + m_items_distances;			
					}
					else
						area = m_element_position[celServiceNumber];
					int correction = (area.height() - pixmap_size.height()) / 2;
					area.moveBy(offset);
					painter.clip(area);
					painter.blit(pixmap, ePoint(area.left(), offset.y() + correction), area, gPainter::BT_ALPHATEST);
					painter.clippop();
				}
			}
		}
예제 #9
0
int eSlider::event(int event, void *data, void *data2)
{
	switch (event)
	{
	case evtPaint:
	{
		ePtr<eWindowStyle> style;

		eSize s(size());
		getStyle(style);
			/* paint background */
		eWidget::event(evtPaint, data, data2);

		gPainter &painter = *(gPainter*)data2;

		style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style
		
		if (!m_pixmap)
			painter.fill(m_currently_filled);
		else
			painter.blit(m_pixmap, ePoint(0, 0), m_currently_filled.extends, isTransparent() ? gPainter::BT_ALPHATEST : 0);

// border
		if (m_have_border_color)
			painter.setForegroundColor(m_border_color);
		painter.fill(eRect(0, 0, s.width(), m_border_width));
		painter.fill(eRect(0, m_border_width, m_border_width, s.height()-m_border_width));
		painter.fill(eRect(m_border_width, s.height()-m_border_width, s.width()-m_border_width, m_border_width));
		painter.fill(eRect(s.width()-m_border_width, m_border_width, m_border_width, s.height()-m_border_width));

		return 0;
	}
	case evtChangedSlider:
	{
		int num_pix = 0, start_pix = 0;
		gRegion old_currently_filled = m_currently_filled;

		int pixsize = (m_orientation == orHorizontal) ? size().width() : size().height();

		if (m_min < m_max)
		{
			int val_range = m_max - m_min;
			num_pix = (pixsize * (m_value - m_start) + val_range - 1) / val_range; /* properly round up */
			start_pix = (pixsize * m_start + val_range - 1) / val_range;

			if (m_orientation_swapped)
				start_pix = pixsize - num_pix - start_pix;
		}

		if  (start_pix < 0)
		{
			num_pix += start_pix;
			start_pix = 0;
		}
		
		if (num_pix < 0)
			num_pix = 0;

		if (m_orientation == orHorizontal)
			m_currently_filled = eRect(start_pix, 0, num_pix, pixsize);
		else
			m_currently_filled = eRect(0, start_pix, pixsize, num_pix);

			// redraw what *was* filled before and now isn't.
		invalidate(m_currently_filled - old_currently_filled);
			// redraw what wasn't filled before and is now.
		invalidate(old_currently_filled - m_currently_filled);
		
		return 0;
	}
	default:
		return eWidget::event(event, data, data2);
	}
}
예제 #10
0
파일: grc.cpp 프로젝트: openmips/stbgui
void gDC::enableSpinner()
{
	ASSERT(m_spinner_saved);

		/* save the background to restore it later. We need to negative position because we want to blit from the middle of the screen. */
	m_spinner_saved->blit(*m_pixmap, eRect(-m_spinner_pos.topLeft(), eSize()), gRegion(eRect(ePoint(0, 0), m_spinner_saved->size())), 0);

	incrementSpinner();
}
예제 #11
0
파일: grc.cpp 프로젝트: openmips/stbgui
void gDC::exec(const gOpcode *o)
{
	switch (o->opcode)
	{
	case gOpcode::setBackgroundColor:
		m_background_color = o->parm.setColor->color;
		m_background_color_rgb = getRGB(m_background_color);
		delete o->parm.setColor;
		break;
	case gOpcode::setForegroundColor:
		m_foreground_color = o->parm.setColor->color;
		m_foreground_color_rgb = getRGB(m_foreground_color);
		delete o->parm.setColor;
		break;
	case gOpcode::setBackgroundColorRGB:
		if (m_pixmap->needClut())
			m_background_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color);
		m_background_color_rgb = o->parm.setColorRGB->color;
		delete o->parm.setColorRGB;
		break;
	case gOpcode::setForegroundColorRGB:
		if (m_pixmap->needClut())
			m_foreground_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color);
		m_foreground_color_rgb = o->parm.setColorRGB->color;
		delete o->parm.setColorRGB;
		break;
	case gOpcode::setFont:
		m_current_font = o->parm.setFont->font;
		o->parm.setFont->font->Release();
		delete o->parm.setFont;
		break;
	case gOpcode::renderText:
	{
		ePtr<eTextPara> para = new eTextPara(o->parm.renderText->area);
		int flags = o->parm.renderText->flags;
		ASSERT(m_current_font);
		para->setFont(m_current_font);
		para->renderString(o->parm.renderText->text, (flags & gPainter::RT_WRAP) ? RS_WRAP : 0, o->parm.renderText->border);
		if (o->parm.renderText->text)
			free(o->parm.renderText->text);
		if (flags & gPainter::RT_HALIGN_LEFT)
			para->realign(eTextPara::dirLeft);
		else if (flags & gPainter::RT_HALIGN_RIGHT)
			para->realign(eTextPara::dirRight);
		else if (flags & gPainter::RT_HALIGN_CENTER)
			para->realign((flags & gPainter::RT_WRAP) ? eTextPara::dirCenter : eTextPara::dirCenterIfFits);
		else if (flags & gPainter::RT_HALIGN_BLOCK)
			para->realign(eTextPara::dirBlock);
		else
			para->realign(eTextPara::dirBidi);

		ePoint offset = m_current_offset;

		if (o->parm.renderText->flags & gPainter::RT_VALIGN_CENTER)
		{
			eRect bbox = para->getBoundBox();
			int vcentered_top = o->parm.renderText->area.top() + ((o->parm.renderText->area.height() - bbox.height()) / 2);
			int correction = vcentered_top - bbox.top();
			// Only center if it fits, don't push text out the top
			if (correction > 0)
			{
				offset += ePoint(0, correction);
			}
		}
		else if (o->parm.renderText->flags & gPainter::RT_VALIGN_BOTTOM)
		{
			eRect bbox = para->getBoundBox();
			int correction = o->parm.renderText->area.height() - bbox.height() - 2;
			offset += ePoint(0, correction);
		}
		if (o->parm.renderText->border)
		{
			para->blit(*this, offset, m_background_color_rgb, o->parm.renderText->bordercolor, true);
			para->blit(*this, offset, o->parm.renderText->bordercolor, m_foreground_color_rgb);
		}
		else
		{
			para->blit(*this, offset, m_background_color_rgb, m_foreground_color_rgb);
		}
		delete o->parm.renderText;
		break;
	}
	case gOpcode::renderPara:
	{
		o->parm.renderPara->textpara->blit(*this, o->parm.renderPara->offset + m_current_offset, m_background_color_rgb, m_foreground_color_rgb);
		o->parm.renderPara->textpara->Release();
		delete o->parm.renderPara;
		break;
	}
	case gOpcode::fill:
	{
		eRect area = o->parm.fill->area;
		area.moveBy(m_current_offset);
		gRegion clip = m_current_clip & area;
		if (m_pixmap->needClut())
			m_pixmap->fill(clip, m_foreground_color);
		else
			m_pixmap->fill(clip, m_foreground_color_rgb);
		delete o->parm.fill;
		break;
	}
	case gOpcode::fillRegion:
	{
		o->parm.fillRegion->region.moveBy(m_current_offset);
		gRegion clip = m_current_clip & o->parm.fillRegion->region;
		if (m_pixmap->needClut())
			m_pixmap->fill(clip, m_foreground_color);
		else
			m_pixmap->fill(clip, m_foreground_color_rgb);
		delete o->parm.fillRegion;
		break;
	}
	case gOpcode::clear:
		if (m_pixmap->needClut())
			m_pixmap->fill(m_current_clip, m_background_color);
		else
			m_pixmap->fill(m_current_clip, m_background_color_rgb);
		delete o->parm.fill;
		break;
	case gOpcode::blit:
	{
		gRegion clip;
				// this code should be checked again but i'm too tired now

		o->parm.blit->position.moveBy(m_current_offset);

		if (o->parm.blit->clip.valid())
		{
			o->parm.blit->clip.moveBy(m_current_offset);
			clip.intersect(gRegion(o->parm.blit->clip), m_current_clip);
		} else
			clip = m_current_clip;

		m_pixmap->blit(*o->parm.blit->pixmap, o->parm.blit->position, clip, o->parm.blit->flags);
		o->parm.blit->pixmap->Release();
		delete o->parm.blit;
		break;
	}
	case gOpcode::setPalette:
		if (o->parm.setPalette->palette->start > m_pixmap->surface->clut.colors)
			o->parm.setPalette->palette->start = m_pixmap->surface->clut.colors;
		if (o->parm.setPalette->palette->colors > (m_pixmap->surface->clut.colors-o->parm.setPalette->palette->start))
			o->parm.setPalette->palette->colors = m_pixmap->surface->clut.colors-o->parm.setPalette->palette->start;
		if (o->parm.setPalette->palette->colors)
			memcpy(m_pixmap->surface->clut.data+o->parm.setPalette->palette->start, o->parm.setPalette->palette->data, o->parm.setPalette->palette->colors*sizeof(gRGB));

		delete[] o->parm.setPalette->palette->data;
		delete o->parm.setPalette->palette;
		delete o->parm.setPalette;
		break;
	case gOpcode::mergePalette:
		m_pixmap->mergePalette(*o->parm.mergePalette->target);
		o->parm.mergePalette->target->Release();
		delete o->parm.mergePalette;
		break;
	case gOpcode::line:
	{
		ePoint start = o->parm.line->start + m_current_offset, end = o->parm.line->end + m_current_offset;
		if (m_pixmap->needClut())
			m_pixmap->line(m_current_clip, start, end, m_foreground_color);
		else
			m_pixmap->line(m_current_clip, start, end, m_foreground_color_rgb);
		delete o->parm.line;
		break;
	}
	case gOpcode::addClip:
		m_clip_stack.push(m_current_clip);
		o->parm.clip->region.moveBy(m_current_offset);
		m_current_clip &= o->parm.clip->region;
		delete o->parm.clip;
		break;
	case gOpcode::setClip:
		o->parm.clip->region.moveBy(m_current_offset);
		m_current_clip = o->parm.clip->region & eRect(ePoint(0, 0), m_pixmap->size());
		delete o->parm.clip;
		break;
	case gOpcode::popClip:
		if (!m_clip_stack.empty())
		{
			m_current_clip = m_clip_stack.top();
			m_clip_stack.pop();
		}
		break;
	case gOpcode::setOffset:
		if (o->parm.setOffset->rel)
			m_current_offset += o->parm.setOffset->value;
		else
			m_current_offset  = o->parm.setOffset->value;
		delete o->parm.setOffset;
		break;
	case gOpcode::waitVSync:
		break;
	case gOpcode::flip:
		break;
	case gOpcode::flush:
		break;

#ifdef HAVE_OSDANIMATION
	case gOpcode::sendShow:
		break;
	case gOpcode::sendHide:
		break;
#endif

	case gOpcode::enableSpinner:
		enableSpinner();
		break;
	case gOpcode::disableSpinner:
		disableSpinner();
		break;
	case gOpcode::incrementSpinner:
		incrementSpinner();
		break;
	default:
		eFatal("[gDC] illegal opcode %d. expect memory leak!", o->opcode);
	}
}
예제 #12
0
파일: enigma.cpp 프로젝트: popazerty/e2-dmm
int main(int argc, char **argv)
{
#if defined(__sh__) // nits shm hack to behavior of e2 on the fly
        shm = findshm();
        if(shm == NULL)
            shm = createshm();
#endif
#ifdef MEMLEAK_CHECK
	atexit(DumpUnfreed);
#endif

#ifdef OBJECT_DEBUG
	atexit(object_dump);
#endif
#ifndef ENABLE_LIBEPLAYER3
	gst_init(&argc, &argv);
#endif

	// set pythonpath if unset
	setenv("PYTHONPATH", eEnv::resolve("${libdir}/enigma2/python").c_str(), 0);
	printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
	
	bsodLogInit();

	ePython python;
	eMain main;

#if 1
	ePtr<gMainDC> my_dc;
	gMainDC::getInstance(my_dc);
	
	//int double_buffer = my_dc->haveDoubleBuffering();

	ePtr<gLCDDC> my_lcd_dc;
	gLCDDC::getInstance(my_lcd_dc);


		/* ok, this is currently hardcoded for arabic. */
			/* some characters are wrong in the regular font, force them to use the replacement font */
	for (int i = 0x60c; i <= 0x66d; ++i)
		eTextPara::forceReplacementGlyph(i);
	eTextPara::forceReplacementGlyph(0xfdf2);
	for (int i = 0xfe80; i < 0xff00; ++i)
		eTextPara::forceReplacementGlyph(i);

	eWidgetDesktop dsk(eSize(720, 576));
	eWidgetDesktop dsk_lcd(my_lcd_dc->size());

	dsk.setStyleID(0);

#ifdef HAVE_GRAPHLCD
  	dsk_lcd.setStyleID(my_lcd_dc->size().width() == 320 ? 1 : 2);
#else
  	dsk_lcd.setStyleID(my_lcd_dc->size().width() == 96 ? 2 : 1);
#endif

/*	if (double_buffer)
	{
		eDebug(" - double buffering found, enable buffered graphics mode.");
		dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
	} */
	
	wdsk = &dsk;
	lcddsk = &dsk_lcd;

	dsk.setDC(my_dc);
	dsk_lcd.setDC(my_lcd_dc);

	ePtr<gPixmap> m_pm;
	loadPNG(m_pm, eEnv::resolve("${datadir}/enigma2/skin_default/pal.png").c_str());
	if (!m_pm)
	{
		eFatal("pal.png not found!");
	} else
		dsk.setPalette(*m_pm);

	dsk.setBackgroundColor(gRGB(0,0,0,0xFF));
#endif

		/* redrawing is done in an idle-timer, so we have to set the context */
	dsk.setRedrawTask(main);
	dsk_lcd.setRedrawTask(main);
	
	
	eDebug("Loading spinners...");
	
	{
		int i;
#define MAX_SPINNER 64
		ePtr<gPixmap> wait[MAX_SPINNER];
		for (i=0; i<MAX_SPINNER; ++i)
		{
			char filename[64];
			std::string rfilename;
			snprintf(filename, sizeof(filename), "${datadir}/enigma2/skin_default/spinner/wait%d.png", i + 1);
			rfilename = eEnv::resolve(filename);
			loadPNG(wait[i], rfilename.c_str());
			
			if (!wait[i])
			{
				if (!i)
					eDebug("failed to load %s! (%m)", rfilename.c_str());
				else
					eDebug("found %d spinner!\n", i);
				break;
			}
		}
		if (i)
			my_dc->setSpinner(eRect(ePoint(100, 100), wait[0]->size()), wait, i);
		else
			my_dc->setSpinner(eRect(100, 100, 0, 0), wait, 1);
	}
	
	gRC::getInstance()->setSpinnerDC(my_dc);

	eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));

#if defined(__sh__)  // initialise the vfd class
	evfd * vfd = new evfd;  
	vfd->init();  
	delete vfd;  
#endif  
	
	printf("executing main\n");
	
	bsodCatchSignals();

	setIoPrio(IOPRIO_CLASS_BE, 3);

//	python.execute("mytest", "__main__");
	python.execFile(eEnv::resolve("${libdir}/enigma2/python/mytest.py").c_str());

	extern void setFullsize(); // definend in lib/gui/evideo.cpp
	setFullsize();

	if (exit_code == 5) /* python crash */
	{
		eDebug("(exit code 5)");
		bsodFatal(0);
	}
	
	dsk.paint();
	dsk_lcd.paint();

	{
		gPainter p(my_lcd_dc);
		p.resetClip(eRect(ePoint(0, 0), my_lcd_dc->size()));
		p.clear();
		p.flush();
	}

	return exit_code;
}
예제 #13
0
void eExpertSetup::init_eExpertSetup()
{
    cmove(ePoint(135, 100));

    int lockWebIf=1;
    if ( eConfig::getInstance()->getKey("/ezap/webif/lockWebIf", lockWebIf) )
        eConfig::getInstance()->setKey("/ezap/webif/lockWebIf", lockWebIf);

    int showSatPos=1;
    if ( eConfig::getInstance()->getKey("/extras/showSatPos", showSatPos) )
        eConfig::getInstance()->setKey("/extras/showSatPos", showSatPos);

    int entry=0;
#ifndef DISABLE_NETWORK
    if (eSystemInfo::getInstance()->hasNetwork())
    {
        CONNECT((new eListBoxEntryMenu(&list, _("Communication Setup"), eString().sprintf("(%d) %s", ++entry, _("open communication setup")) ))->selected, eExpertSetup::communication_setup);
        CONNECT((new eListBoxEntryMenu(&list, _("Ngrab Streaming Setup"), eString().sprintf("(%d) %s", ++entry, _("open ngrab server setup")) ))->selected, eExpertSetup::ngrab_setup);
        switch (eSystemInfo::getInstance()->getHwType())
        {
        case eSystemInfo::DM7020:
        case eSystemInfo::DM600PVR:
        case eSystemInfo::DM500PLUS:
            break;
        default:
            CONNECT((new eListBoxEntryMenu(&list, _("Software Update"), eString().sprintf("(%d) %s", ++entry, _("open software update")) ))->selected, eExpertSetup::software_update);
        }
    }
    int startSamba=1;
    if ( eConfig::getInstance()->getKey("/elitedvb/network/samba", startSamba) )
        eConfig::getInstance()->setKey("/elitedvb/network/samba", startSamba);
#endif
    CONNECT((new eListBoxEntryMenu(&list, _("Remote Control"), eString().sprintf("(%d) %s", ++entry, _("open remote control setup")) ))->selected, eExpertSetup::rc_setup);
#ifndef DISABLE_HDD
#ifndef DISABLE_FILE
    CONNECT((new eListBoxEntryMenu(&list, _("Swap Manager"), eString().sprintf("(%d) %s", ++entry, _("open swapspace setup")) ))->selected, eExpertSetup::swapmanager);
#endif
#endif
    if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000 )
        CONNECT((new eListBoxEntryMenu(&list, _("Factory reset"), eString().sprintf("(%d) %s", ++entry, _("all settings will set to factory defaults")) ))->selected, eExpertSetup::factory_reset);
    new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
    list.setFlags(list.getFlags()|eListBoxBase::flagNoPageMovement);
#ifndef DISABLE_FILE
    if ( eSystemInfo::getInstance()->canRecordTS() && !eDVB::getInstance()->recorder )
    {
        record_split_size = new eListBoxEntryMulti(&list, _("record split size (left, right)"));
        record_split_size->add("         650MB        >", 650*1024);
        record_split_size->add("<        700MB        >", 700*1024);
        record_split_size->add("<        800MB        >", 800*1024);
        record_split_size->add("<         1GB         >", 1024*1024);
        record_split_size->add("<        1,5GB        >", 1536*1024);
        record_split_size->add("<         2GB         >", 2*1024*1024);
        record_split_size->add("<         4GB         >", 4*1024*1024);
        record_split_size->add("<         8GB         >", 8*1024*1024);
        record_split_size->add("<        16GB         ", 16*1024*1024);
        int splitsize=0;
        if (eConfig::getInstance()->getKey("/extras/record_splitsize", splitsize))
            splitsize=1024*1024; // 1G
        record_split_size->setCurrent(splitsize);
        CONNECT( list.selchanged, eExpertSetup::selChanged );
    }

    // Timeroffset (Anfang)
    timeroffsetstart = new eListBoxEntryMulti( &list, (_("Change timer offset [start] (left, right)")));
    timeroffsetstart->add( (eString)"  " + eString().sprintf(_("Timer offset [start] %d min"), 0) + (eString)" >", 0);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 1) + (eString)" >", 1);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 2) + (eString)" >", 2);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 3) + (eString)" >", 3);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 4) + (eString)" >", 4);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 5) + (eString)" >", 5);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 6) + (eString)" >", 6);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 7) + (eString)" >", 7);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 8) + (eString)" >", 8);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 9) + (eString)" >", 9);
    timeroffsetstart->add( (eString)"< " + eString().sprintf(_("Timer offset [start] %d min"), 10) + (eString)"  ", 10);
    int offsetstart=0;
    if (eConfig::getInstance()->getKey("/enigma/timeroffset", offsetstart) )
        offsetstart=0; // 0 Minutes
    timeroffsetstart->setCurrent(offsetstart);
    CONNECT(list.selchanged, eExpertSetup::startoffsetChanged );


    // Timeroffset (Ende)
    timeroffsetend = new eListBoxEntryMulti( &list, (_("Change timer offset [end] (left, right)")));
    timeroffsetend->add( (eString)"  " + eString().sprintf(_("Timer offset [end] %d min"), 0) + (eString)" >", 0);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 1) + (eString)" >", 1);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 2) + (eString)" >", 2);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 3) + (eString)" >", 3);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 4) + (eString)" >", 4);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 5) + (eString)" >", 5);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 6) + (eString)" >", 6);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 7) + (eString)" >", 7);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 8) + (eString)" >", 8);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 9) + (eString)" >", 9);
    timeroffsetend->add( (eString)"< " + eString().sprintf(_("Timer offset [end] %d min"), 10) + (eString)"  ", 10);
    int offsetend=0;
    if (eConfig::getInstance()->getKey("/enigma/timeroffset2", offsetend) )
        offsetend=0; // 0 Minutes
    timeroffsetend->setCurrent(offsetend);
    CONNECT(list.selchanged, eExpertSetup::endoffsetChanged );

    timerenddefaultaction = new eListBoxEntryMulti( &list, _("Default action on timer end (left, right)"));

    timerenddefaultaction->add( eString().sprintf("%s: %s%s",_("Action on timer end"),_("Nothing")," >").c_str(), 0 );

    if ( eSystemInfo::getInstance()->canShutdown() )
    {
        timerenddefaultaction->add( eString().sprintf("< %s: %s >", _("Action on timer end"), _("Standby")).c_str(), ePlaylistEntry::doGoSleep );
        timerenddefaultaction->add( eString().sprintf("< %s: %s", _("Action on timer end"), _("Shutdown")).c_str(), ePlaylistEntry::doShutdown );
    }
    else
    {
        timerenddefaultaction->add( eString().sprintf("< %s: %s", _("Action on timer end"), _("Standby")).c_str(), ePlaylistEntry::doGoSleep );
    }

    int defaultaction = 0;
    if (eConfig::getInstance()->getKey("/enigma/timerenddefaultaction", defaultaction) )
        defaultaction = 0;
    timerenddefaultaction->setCurrent(defaultaction);

    CONNECT(list.selchanged, eExpertSetup::timerenddefaultactionChanged );
    new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
    new eListBoxEntryCheck(&list, _("disable AC3 recording"), "/enigma/noac3recording", _("don't record AC3 audio track"));
    new eListBoxEntryCheck(&list, _("disable teletext recording"), "/enigma/nottxrecording", _("don't record teletext track"));
    new eListBoxEntryCheck(&list, _("disable timestamp detection"), "/enigma/notimestampdetect", _("don't try to detect duration from DVB timestamps when replaying recordings"));
    new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
#endif
    if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000 )
        CONNECT((new eListBoxEntryCheck(&list,_("Enable fast zapping"),"/elitedvb/extra/fastzapping",_("enables faster zapping.. but with visible sync")))->selected, eExpertSetup::fastZappingChanged );
    CONNECT((new eListBoxEntryCheck(&list, _("Use http authentification"), "/ezap/webif/lockWebIf", _("enables the http (user/password) authentification")))->selected, eExpertSetup::reinitializeHTTPServer );
    CONNECT((new eListBoxEntryCheck(&list, _("Don't open serial port"), "/ezap/extra/disableSerialOutput", _("don't write debug messages to /dev/tts/0")))->selected, eExpertSetup::reinitializeHTTPServer );
    new eListBoxEntryCheck(&list, _("Auto bouquet change"), "/elitedvb/extra/autobouquetchange", _("change into next bouquet when end of current bouquet is reached"));
    new eListBoxEntryCheck(&list, _("Auto reconnect cahandler"), "/elitedvb/extra/cahandlerReconnect", _("try to reconnect when an external cahandler connection was lost"));
#ifndef DISABLE_NETWORK
    if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000 ||
            eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7020)
        new eListBoxEntryCheck(&list, _("Enable file sharing"), "/elitedvb/network/samba", _("start file sharing(samba) on startup"));
#endif
#ifndef TUXTXT_CFG_STANDALONE
    CONNECT((new eListBoxEntryCheck(&list, _("Disable teletext caching"), "/ezap/extra/teletext_caching", _("don't cache teletext pages in background")))->selected, eExpertSetup::tuxtxtCachingChanged );
#endif
    new eListBoxEntryCheck(&list, _("Disable internal teletext"), "/ezap/teletext/use_external", _("use external tuxtxt plugin"));
    new eListBoxEntryCheck(&list, _("Enable Zapping History"), "/elitedvb/extra/extzapping", _("don't care about actual mode when zapping in history list"));
    if ( eSystemInfo::getInstance()->getHwType() < eSystemInfo::DM5600 )
        new eListBoxEntryCheck(&list, _("Disable Standby"), "/extras/fastshutdown", _("Box goes directly into Deep-Standby"));
#ifdef ENABLE_MHW_EPG
    int mhwepg=1;
    if ( eConfig::getInstance()->getKey("/extras/mhwepg", mhwepg) )
        eConfig::getInstance()->setKey("/extras/mhwepg", mhwepg);
    new eListBoxEntryCheck(&list, _("Enable MHW EPG"), "/extras/mhwepg", _("Mediahighway EPG, activate swap space when using with multiple operators"));
#endif
#ifdef HAVE_DREAMBOX_HARDWARE
    if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000 )
    {
        int corefilesDisable = 0;
        if (access("/var/etc/.no_corefiles", R_OK) == 0)
            corefilesDisable = 1;
        eConfig::getInstance()->setKey("/extras/corefiles_disable", corefilesDisable);
        new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
        CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable CoreFiles"), "/extras/corefiles_disable", _("don't create 'Corefiles' after an Enigma crash")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_corefiles");
#ifdef ENABLE_EXPERT_WEBIF
        int dontMountHDD = 0;
        if (access("/var/etc/.dont_mount_hdd", R_OK) == 0)
            dontMountHDD = 1;
        eConfig::getInstance()->setKey("/extras/dont_mount_hdd", dontMountHDD);
        CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable HDD mount"), "/extras/dont_mount_hdd", _("don't mount the HDD via 'rcS'")))->selected, eExpertSetup::fileToggle,"/var/etc/.dont_mount_hdd");
#endif
    }
#endif
#ifndef DISABLE_FILE
    int autoplay=1;
    if ( eConfig::getInstance()->getKey("/ezap/extra/autoplay", autoplay) )
        eConfig::getInstance()->setKey("/ezap/extra/autoplay", autoplay);
    new eListBoxEntryCheck(&list, _("Enable Filemode Autoplay"), "/ezap/extra/autoplay", _("continue playing last selected movie when entering Filemode"));
#endif
#ifndef HAVE_DREAMBOX_HARDWARE
    new eListBoxEntryMenuSeparator(&list, eSkin::getActive()->queryImage("listbox.separator"), 0, true );
//Boot-info
    int bootInfo = 0;
    if (access("/var/etc/.boot_info", R_OK) == 0)
        bootInfo = 1;
    eConfig::getInstance()->setKey("/extras/bootinfo", bootInfo);
    CONNECT_2_1((new eListBoxEntryCheck(&list, _("Show Boot-Info"), "/extras/bootinfo", _("Show Boot-Infos (IP, etc.)")))->selected, eExpertSetup::fileToggle,"/var/etc/.boot_info");
//HW-Sections
    int hwSectionsDisable = 0;
    if (access("/var/etc/.hw_sections", R_OK) == 0)
        hwSectionsDisable = 1;
    eConfig::getInstance()->setKey("/extras/hw_sections_disable", hwSectionsDisable);
    CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable HW_Sections"), "/extras/hw_sections_disable", _("don't use hardware section filtering")))->selected, eExpertSetup::fileToggle,"/var/etc/.hw_sections");
//Watchdog
    int watchdogDisable = 0;
    if (access("/var/etc/.no_watchdog", R_OK) == 0)
        watchdogDisable = 1;
    eConfig::getInstance()->setKey("/extras/watchdog_disable", watchdogDisable);
    CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable Watchdog"), "/extras/watchdog_disable", _("don't use the Watchdog")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_watchdog");
//ENX-Watchdog - Philips and Sagem
    if ( eSystemInfo::getInstance()->getHwType() != eSystemInfo::dbox2Nokia )
    {
        int enxWatchdogDisable = 0;
        if (access("/var/etc/.no_enxwatchdog", R_OK) == 0)
            enxWatchdogDisable = 1;
        eConfig::getInstance()->setKey("/extras/enxwatchdog_disable", enxWatchdogDisable);
        CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable ENX-Watchdog"), "/extras/enxwatchdog_disable", _("don't use the ENX-Watchdog")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_enxwatchdog");
    }
//SPTS-Recording
    int sptsMode = 0;
    if (access("/var/etc/.spts_mode", R_OK) == 0)
        sptsMode = 1;
    eConfig::getInstance()->setKey("/extras/spts_mode", sptsMode);
    CONNECT_2_1((new eListBoxEntryCheck(&list, _("Enable SPTS-Mode"), "/extras/spts_mode", _("use SPTS-Mode (enables TS-recording)")))->selected, eExpertSetup::fileToggle,"/var/etc/.spts_mode");
//File I/O-Options
    int OSyncDisable = 0;
    if (access("/var/etc/.no_o_sync", R_OK) == 0)
        OSyncDisable = 1;
    eConfig::getInstance()->setKey("/extras/O_SYNC_disable", OSyncDisable);
    CONNECT_2_1((new eListBoxEntryCheck(&list, _("Disable O_SYNC"), "/extras/O_SYNC_disable", _("The file/recording is not opened for synchronous I/O")))->selected, eExpertSetup::fileToggle,"/var/etc/.no_o_sync");
//Alternative Frontenddriver for Philips
    if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::dbox2Philips )
    {
        int tda80xx = 0;
        if (access("/var/etc/.tda80xx", R_OK) == 0)
            tda80xx = 1;
        eConfig::getInstance()->setKey("/extras/tda80xx", tda80xx);
        CONNECT_2_1((new eListBoxEntryCheck(&list, _("New Philips driver"), "/extras/tda80xx", _("use tda80xx driver for Philips boxes")))->selected, eExpertSetup::fileToggle,"/var/etc/.tda80xx");
    }
#endif
    setHelpID(92);
}
예제 #14
0
int main(int argc, char **argv)
{
#ifdef MEMLEAK_CHECK
	atexit(DumpUnfreed);
#endif

#ifdef OBJECT_DEBUG
	atexit(object_dump);
#endif

	gst_init(&argc, &argv);

	// set pythonpath if unset
	setenv("PYTHONPATH", eEnv::resolve("${libdir}/enigma2/python").c_str(), 0);
	printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
	printf("DVB_API_VERSION %d DVB_API_VERSION_MINOR %d\n", DVB_API_VERSION, DVB_API_VERSION_MINOR);

	bsodLogInit();

	ePython python;
	eMain main;

#if 1
	ePtr<gMainDC> my_dc;
	gMainDC::getInstance(my_dc);

	//int double_buffer = my_dc->haveDoubleBuffering();

	ePtr<gLCDDC> my_lcd_dc;
	gLCDDC::getInstance(my_lcd_dc);


		/* ok, this is currently hardcoded for arabic. */
			/* some characters are wrong in the regular font, force them to use the replacement font */
	for (int i = 0x60c; i <= 0x66d; ++i)
		eTextPara::forceReplacementGlyph(i);
	eTextPara::forceReplacementGlyph(0xfdf2);
	for (int i = 0xfe80; i < 0xff00; ++i)
		eTextPara::forceReplacementGlyph(i);

	eWidgetDesktop dsk(my_dc->size());
	eWidgetDesktop dsk_lcd(my_lcd_dc->size());

	dsk.setStyleID(0);
	dsk_lcd.setStyleID(my_lcd_dc->size().width() == 96 ? 2 : 1);

/*	if (double_buffer)
	{
		eDebug("[MAIN] - double buffering found, enable buffered graphics mode.");
		dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
	} */

	wdsk = &dsk;
	lcddsk = &dsk_lcd;

	dsk.setDC(my_dc);
	dsk_lcd.setDC(my_lcd_dc);

	dsk.setBackgroundColor(gRGB(0,0,0,0xFF));
#endif

		/* redrawing is done in an idle-timer, so we have to set the context */
	dsk.setRedrawTask(main);
	dsk_lcd.setRedrawTask(main);

	eDebug("Checking box...");
	
	FILE *infile;
	char line[100];
	char command[64];

	if((infile = fopen("/proc/stb/info/boxtype", "r")) != NULL)
	{
		fgets(line, sizeof(line), infile);
	    
		if(strcmp(line, "ini-5000sv\n") == 0) 
		{
			eDebug("Miraclebox Premium Twin detected");
		}
		else if(strcmp(line, "ini-1000sv\n") == 0) 
		{
			eDebug("Miraclebox PremiumMini detected");
		}
		else if(strcmp(line, "ini-2000sv\n") == 0) 
		{
			eDebug("Miraclebox Premium Mini Plus detected");
		}		
		else if(strcmp(line, "ini-8000sv\n") == 0) 
		{
			eDebug("Miraclebox Premium Ultra detected");
		}
		else if(strcmp(line, "g300\n") == 0) 
		{
			eDebug("Miraclebox Premium XXXXX detected");
		}
		else if(strcmp(line, "7000S\n") == 0) 
		{
			eDebug("Miraclebox Premium Micro detected");
		}
		else
		{
			eDebug("Wrong HW, this image can be only run on Miraclbox Premium Series");
			sprintf(command, "showiframe /usr/share/enigma2/box.mvi > /dev/null");
			system(command);
			sprintf(command, "flash_erase /dev/mtd/2 0 0");
			system(command);
			sprintf(command, "flash_erase /dev/mtd/4 0 0");
			system(command);
			sprintf(command, "flash_erase /dev/mtd/3 0 0");
			system(command);
			sprintf(command, "sleep 5;reboot -f");
		}
		fclose(infile);
	}
	
	eDebug("[MAIN] Loading spinners...");

	{
		int i;
#define MAX_SPINNER 64
		ePtr<gPixmap> wait[MAX_SPINNER];
		for (i=0; i<MAX_SPINNER; ++i)
		{
			char filename[64];
			std::string rfilename;
			snprintf(filename, sizeof(filename), "${datadir}/enigma2/skin_default/spinner/wait%d.png", i + 1);
			rfilename = eEnv::resolve(filename);
			loadPNG(wait[i], rfilename.c_str());

			if (!wait[i])
			{
				if (!i)
					eDebug("[MAIN] failed to load %s: %m", rfilename.c_str());
				else
					eDebug("[MAIN] found %d spinner!\n", i);
				break;
			}
		}
		if (i)
			my_dc->setSpinner(eRect(ePoint(100, 100), wait[0]->size()), wait, i);
		else
			my_dc->setSpinner(eRect(100, 100, 0, 0), wait, 1);
	}

	gRC::getInstance()->setSpinnerDC(my_dc);

	eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));

	printf("[MAIN] executing main\n");

	bsodCatchSignals();
	catchTermSignal();

	setIoPrio(IOPRIO_CLASS_BE, 3);

	/* start at full size */
	eVideoWidget::setFullsize(true);

//	python.execute("mytest", "__main__");
	python.execFile(eEnv::resolve("${libdir}/enigma2/python/mytest.py").c_str());

	/* restore both decoders to full size */
	eVideoWidget::setFullsize(true);

	if (exit_code == 5) /* python crash */
	{
		eDebug("[MAIN] (exit code 5)");
		bsodFatal(0);
	}

	dsk.paint();
	dsk_lcd.paint();

	{
		gPainter p(my_lcd_dc);
		p.resetClip(eRect(ePoint(0, 0), my_lcd_dc->size()));
		p.clear();
		p.flush();
	}

	return exit_code;
}