|
From: andrew7 <bd...@us...> - 2006-11-05 17:55:15
|
Update of /cvsroot/smartwin/SmartWin/include/smartwin/aspects In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv7894/include/smartwin/aspects Modified Files: AspectText.h Log Message: Put setTextLines in the aspect. Index: AspectText.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/include/smartwin/aspects/AspectText.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- AspectText.h 5 May 2006 17:14:38 -0000 1.16 +++ AspectText.h 5 Nov 2006 17:55:12 -0000 1.17 @@ -137,6 +137,13 @@ */ void setText( const SmartUtil::tstring & txt ); + /// Sets the text in the Edit Control so that endl causes a new line. + /** Just the same as setText except that CR are expanded to LF CR + * Replaces \n with \r\n so that Windows textbox understands "endl" + */ + void setTextLines( const SmartUtil::tstring & txt ); + + /// Gets the text of the AspectText realizing class /** The Return value is the text of the realizing class. */ @@ -165,6 +172,24 @@ ::SendMessage( static_cast< WidgetType * >( this )->handle(), WM_SETTEXT, ( WPARAM ) 0, ( LPARAM ) txt.c_str() ); } + +template< class EventHandlerClass, class WidgetType, class MessageMapType > +void AspectText< EventHandlerClass, WidgetType, MessageMapType >::setTextLines( const SmartUtil::tstring & inTxt ) +{ + // Replaces \n with \r\n so that Windows textbox understands "endl" + SmartUtil::tstring txtEndl= inTxt; + + std::string::size_type pos= txtEndl.find( '\n', 0 ); + while ( std::string::npos != pos ) { + txtEndl.replace( pos, 1, "\r\n" ); + pos += 2; // Don't find the replacement \n. + pos= txtEndl.find( '\n', pos ); + } + setText( txtEndl ); +} + + + template< class EventHandlerClass, class WidgetType, class MessageMapType > SmartUtil::tstring AspectText< EventHandlerClass, WidgetType, MessageMapType >::getText() const { |