Пример #1
0
void bbWrite( BBStr *str ){
	gxCanvas *c=startPrinting();
	c->text( curs_x,curs_y,*str );
	curs_x+=curr_font->getWidth( *str );
	endPrinting( c );
	delete str;
}
Пример #2
0
void bbPrint( BBStr *str ){
	gxCanvas *c=startPrinting();
	c->text( curs_x,curs_y,*str );
	curs_x=0;
	curs_y+=curr_font->getHeight();
	endPrinting( c );
	delete str;
}
Пример #3
0
bool KPrinterImpl::printFiles(KPrinter *p, const TQStringList& f, bool flag)
{
	TQString	cmd;
	if (p->option("kde-isspecial") == "1")
	{
		if (p->option("kde-special-command").isEmpty() && p->outputToFile())
		{
			KURL url( p->outputFileName() );
			if ( !url.isLocalFile() )
			{
				cmd = ( flag ? "mv" : "cp" ) + ( " %in $out{" + p->outputFileName() + "}" );
			}
			else
			{
				if (f.count() > 1)
				{
					p->setErrorMessage(i18n("Cannot copy multiple files into one file."));
					return false;
				}
				else
				{
					TDEProcess proc;
					proc << (flag?"mv":"cp") << f[0] << p->outputFileName();
					if (!proc.start(TDEProcess::Block) || !proc.normalExit() || proc.exitStatus() != 0)
					{
						p->setErrorMessage(i18n("Cannot save print file to %1. Check that you have write access to it.").arg(p->outputFileName()));
						return false;
					}
				}
				return true;
			}
		}
		else if (!setupSpecialCommand(cmd,p,f))
			return false;
	}
	else if (!setupCommand(cmd,p))
		return false;
	return startPrinting(cmd,p,f,flag);
}
Пример #4
0
BBStr *bbInput( BBStr *prompt ){
	gxCanvas *c=startPrinting();
	string t=*prompt;delete prompt;

	//get temp canvas
	if( !p_canvas || p_canvas->getWidth()<c->getWidth() || p_canvas->getHeight()<curr_font->getHeight()*2 ){
		if( p_canvas ) gx_graphics->freeCanvas( p_canvas );
		p_canvas=gx_graphics->createCanvas( c->getWidth(),curr_font->getHeight()*2,0 );
		if( !p_canvas ){
			endPrinting(c);
			return d_new BBStr();
		}
	}
	//draw prompt
	c->text( curs_x,curs_y,t );
	curs_x+=curr_font->getWidth( t );

	p_canvas->setFont( curr_font );
	p_canvas->setColor( curr_color );
	p_canvas->blit( 0,0,c,0,curs_y,c->getWidth(),curr_font->getHeight(),true );

	string str;
	bool go=true;
	int curs=0,last_key=0,last_time,rep_delay;

	while( go ){

		//render all text
		//calc curs x and width
		int cx=curs_x+curr_font->getWidth( str.substr( 0,curs ) );
		int cw=curr_font->getWidth( curs<str.size() ? str.substr( curs,1 ) : "X" );

		//wait for a key
		int key=0,st=gx_runtime->getMilliSecs(),tc=-1;

		while( gx_runtime->idle() ){
			int t=gx_runtime->getMilliSecs();
			int n=(t-st)/320;
			if( n!=tc ){
				tc=n;
				if( !(tc&1) ){	//cursor ON
					c->setColor( curr_clsColor^0xffffff );
					c->rect( cx,curs_y,cw,curr_font->getHeight(),true );
					c->setColor( curr_clsColor );
				}else{			//cursor OFF
					c->blit( cx,curs_y,p_canvas,cx,0,cw,curr_font->getHeight(),true );
					c->setColor( curr_color );
				}
				c->text( cx,curs_y,str.substr( curs,1 ) );
			}
			if( key=gx_keyboard->getKey() ){
				if( int asc=gx_input->toAscii( key ) ){
					rep_delay=280;
					last_key=key;
					last_time=t;
					key=asc;
					break;
				}
			}
			if( last_key && gx_keyboard->keyDown( last_key ) ){
				if( t-last_time>rep_delay ){
					if( key=gx_input->toAscii( last_key ) ){
						last_time+=rep_delay;
						rep_delay=40;
						break;
					}
				}
			}else last_key=0;
			gx_runtime->delay( 20 );
		}

		//check the key
		switch( key ){
		case 0:
			go=false;
			str="";
			break;
		case 8:
			if( curs ){
				str=str.substr( 0,curs-1 )+str.substr( curs );
				--curs;
			}
			break;
		case 27:
			curs=0;str="";
			break;
		case gxInput::ASC_DELETE:
			if( curs<str.size() ) str=str.substr( 0,curs )+str.substr( curs+1 );
			break;
		case gxInput::ASC_HOME:
			curs=0;
			break;
		case gxInput::ASC_END:
			curs=str.size();
			break;
		case gxInput::ASC_LEFT:
			if( curs ) --curs;
			break;
		case gxInput::ASC_RIGHT:
			if( curs<str.size() ) ++curs;
			break;
		case '\r':
			go=false;
			break;
		default:
			if( curr_font->isPrintable( key ) ){
				str=str.substr(0,curs)+char(key)+str.substr(curs);
				++curs;
			}
		}

		//render text
		p_canvas->blit( 0,curr_font->getHeight(),p_canvas,0,0,c->getWidth(),curr_font->getHeight(),true );
		p_canvas->text( curs_x,curr_font->getHeight(),str );
		c->blit( 0,curs_y,p_canvas,0,curr_font->getHeight(),c->getWidth(),curr_font->getHeight(),true );
	}

	curs_x=0;
	curs_y+=curr_font->getHeight();
	endPrinting( c );
	return d_new BBStr( str );
}