Пример #1
0
void MUrl::setUrl(const MString &url)
{
    m_url = url;

    if (!url.isEmpty()) {
        parse();
    }
}
Пример #2
0
/*****************************************************
**
**   Painter   ---   drawMString
**
******************************************************/
void Painter::drawMString( const MRect &r, MString &f, const int& align )
{
#ifdef SHOW_STOP_WATCH
	static wxLongLong totaltime = 0;
	const wxLongLong starttime = wxGetLocalTimeMillis();
#endif

	static int count = 0;
	SheetFormatter sfmt;
	wxString s;

	if ( f.formattedLines.size() == 0 )
	{
		if ( ! f.isEmpty() && f.size.real() == 0 )
		{
			s = sfmt.fragment2PlainText( f );
			//printf( "Painter::drawMString - old size %f %f\n", f.size.real(), f.size.imag());
			f.size = getTextExtent( f );
			printf( "Painter::drawMString - size not set #%d contents was %s, size now %f %f\n", count++, str2char( s ), f.size.real(), f.size.imag());
		}
		drawSingleMStringLine( r, f, align );
		//return;
	}
	else
	{
		double y0 = r.y;
		if ( align & Align::Top )
		{
			// nothing
		}
		else if ( align & Align::Bottom )
		{
			y0 = y0 + r.height - f.size.imag();
		}
		else // default: align & align::VCenter
		{
			y0 += .5 * ( r.height - f.size.imag());
		}

		MRect rect( r.x, y0, r.width, r.height );

		int line = 0;
		for( list<MString>::iterator iter = f.formattedLines.begin(); iter != f.formattedLines.end(); iter++ )
		{
			line++;
			rect.height = iter->size.imag();
			//printf( "  --->>> Line %d width %f h %f\n", line, iter->size.real(), iter->size.imag() );
			drawSingleMStringLine( rect, *iter, align );
			rect.y += rect.height;
		}
	}
#ifdef SHOW_STOP_WATCH
	const wxLongLong duration = wxGetLocalTimeMillis() - starttime;
	totaltime += duration;
	wxLogMessage( wxString::Format( wxT( "Painter::drawTextFormatted in %ld msec, total %ld" ), duration.ToLong(), totaltime.ToLong() ));
#endif

}
Пример #3
0
MStringList MString::split(const MString &sep)
{
    MString temp(*this);
    MStringList ret;
    if (sep.isEmpty()) {
        return ret;
    }

    while (temp.contains(sep)) {
        size_type index = temp.find(sep);

        MString ss = temp.substr(0, index);
        if (!ss.isEmpty()) {
            ret << ss;
        }
        temp = temp.substr(index + sep.size(), temp.size() - 1);
    }
    if (!temp.isEmpty()) {
        ret << temp;
    }

    return ret;
}
Пример #4
0
static void add_to_status_history(const MString& message)
{
    static MString empty = rm(" ");

    if (history == 0)
	history = new MString[status_history_size];

    int last_history = 
	(status_history_size + current_history - 1) % status_history_size;

    if (message.isNull() || message.isEmpty() || message == empty)
	return;

    if (is_prefix(history[last_history], message))
    {
	history[last_history] = message;
	return;
    }

    history[current_history] = message;
    current_history = (current_history + 1) % status_history_size;
}
Пример #5
0
/*****************************************************
**
**   Painter   ---   drawSingleMStringLine
**
******************************************************/
void Painter::drawSingleMStringLine( const MRect &r, MString &f, const int& align )
{
	assert( f.formattedLines.size() == 0 );
	wxString s;
	MPoint p;
	Lang lang( writercfg );
	wxFont oldFont = getCurrentFont();
	const int drawalign = Align::Left + Align::VCenter;
	SheetFormatter formatter( writercfg );

	if ( ! f.isEmpty() && ( f.size.real() == 0 ||  f.size.imag() == 0 ))
	{
		printf( "WARN: size not set\n" );
		f.size = getTextExtent( f );
	}

	//printf( "PAINT -- --- - - - - x %f y %f w %f h %f SIZE x %f y %f\n", r.x, r.y, r.width, r.height, size.real(), size.imag() );
	//printf( " ----- %s\n", str2char( formatter.fragment2PlainText( f )));

	double x0 = r.x;
	double y0 = r.y;

	if ( align & Align::HCenter )
	{
		x0 += .5 * ( r.width - f.size.real());
	}
	else if ( align & Align::Right )
	{
		x0 = x0 + r.width - f.size.real();
	}

	// offset for subscriptum and superscriptum
	const double yoffset = .5 * f.size.imag();

	double yy = y0; // + .5 * ( r.height - size.imag());
	for( list<MToken>::const_iterator iter = f.tokens.begin(); iter != f.tokens.end(); iter++ )
	{
		switch ( iter->fontFormat )
		{
			case TTFF_SUBSCRPTUM:
				yy = y0 + yoffset;
			break;
			case TTFF_SUPERSCRPTUM:
				yy = y0 - yoffset;
			break;
			case TTFF_NORMAL:
			default:
				yy = y0;
			break;
		}

		setFont( oldFont );

		wxChar symbol = 0;
		SymbolProvider sp( writercfg );
		switch ( iter->entity )
		{
			case TTSE_PLANET:
				if ( writercfg->planetSymbols ) symbol = sp.getPlanetCode( (ObjectId)iter->entityId );
				if ( ! symbol || symbol == SYMBOL_CODE_ERROR )
					s = formatter.getObjectNamePlain( (ObjectId)iter->entityId, iter->textFormat, iter->vedic );
			break;
			case TTSE_SIGN:
				if ( writercfg->signSymbols ) symbol = sp.getSignCode( (Rasi)iter->entityId );
				if ( ! symbol ) s = lang.getSignName( (Rasi)iter->entityId, iter->textFormat ); //, writercfg->vedicSignNames );
			break;
			case TTSE_ASPECT:
				symbol = SymbolProvider().getAspectCode( (ASPECT_TYPE)iter->entityId );
				if ( ! symbol ) s = AspectExpert::getAspectShortDescription( (int)iter->entityId );
			break;
			case TTSE_DIRECTION:
				symbol = sp.getRetroCode( (MOVING_DIRECTION)iter->entityId );
				if ( ! symbol ) s = wxT( "R" );
			break;
			default:
				symbol = 0;
				s = iter->text;
			break;
		}
		if ( symbol && symbol != SYMBOL_CODE_ERROR )
		{
			const int pointSize = oldFont.GetPointSize();
			setFont( *FontProvider::get()->getFontBySize( FONT_GRAPHIC_SYMBOLS, pointSize ));
			drawTextFormatted( MRect( x0, yy, r.width, r.height ), symbol, drawalign );
			p = getTextExtent( symbol );
		}
		else
		{
			drawTextFormatted( MRect( x0, yy, r.width, r.height ), s, drawalign );
			p = getTextExtent( s );
		}

		x0 += p.real();
	}
}
Пример #6
0
inline bool is_tip(const MString& m)
{
    return !m.isNull() && !m.isEmpty();
}