|
From: andrew7 <bd...@us...> - 2006-12-07 13:45:16
|
Update of /cvsroot/smartwin/SmartWin/include/smartwin/widgets In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv22950/include/smartwin/widgets Modified Files: WidgetTextBox.h Log Message: Add addText and addTextLines functions Index: WidgetTextBox.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/include/smartwin/widgets/WidgetTextBox.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- WidgetTextBox.h 30 Nov 2006 00:43:57 -0000 1.35 +++ WidgetTextBox.h 7 Dec 2006 13:45:12 -0000 1.36 @@ -164,6 +164,20 @@ */ SmartUtil::tstring getSelection() const; + + /// Appends text to the text box + /** The txt parameter is the new text to append to the text box. + */ + void addText( const SmartUtil::tstring & txt ); + + /// Appends the text in the text box so that endl causes a new line. + /** Just the same as addText except that CR are expanded to LF CR + * Replaces \n with \r\n so that Windows textbox understands "endl" + */ + void addTextLines( const SmartUtil::tstring & txt ); + + + /// Replaces the currently selected text in the text box with the given text parameter /** If canUndo is true this operation is stacked into the undo que ( can be * undone ), else this operation cannot be undone. <br> @@ -344,6 +358,26 @@ ::SendMessage( this->Widget::itsHandle, EM_REPLACESEL, static_cast< WPARAM >( canUndo ? TRUE : FALSE ), reinterpret_cast< LPARAM >( txt.c_str() ) ); } + + + +template< class EventHandlerClass, class MessageMapPolicy, class TextBoxType > +void WidgetTextBox< EventHandlerClass, MessageMapPolicy, TextBoxType >::addText( const SmartUtil::tstring & addtxt ) +{ + setSelection( ( long ) getText().size() ); + replaceSelection( addtxt ); +} + + +template< class EventHandlerClass, class MessageMapPolicy, class TextBoxType > +void WidgetTextBox< EventHandlerClass, MessageMapPolicy, TextBoxType >::addTextLines( const SmartUtil::tstring & addtxt ) +{ + setSelection( ( long ) getText().size() ); + replaceSelection( replaceEndlWithLfCr( addtxt ) ); +} + + + template< class EventHandlerClass, class MessageMapPolicy, class TextBoxType > long WidgetTextBox< EventHandlerClass, MessageMapPolicy, TextBoxType >::findText( const SmartUtil::tstring & txt, unsigned offset ) const { |