Update of /cvsroot/plib/plib/src/pui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30628
Modified Files:
pu.h puInput.cxx puLargeInput.cxx
Log Message:
Removing the "new" and "delete" from within the input box display function
Index: pu.h
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/pu.h,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- pu.h 20 Mar 2006 15:17:35 -0000 1.153
+++ pu.h 22 Mar 2006 19:25:28 -0000 1.154
@@ -1625,6 +1625,13 @@
{
UL_TYPE_DATA
+ int display_starting_point ;
+
+ char *getDisplayedText ( void )
+ {
+ return ( displayed_text == NULL ? getStringValue () : displayed_text ) ;
+ }
+
public:
void draw ( int dx, int dy ) ;
void doHit ( int button, int updown, int x, int y ) ;
@@ -1642,6 +1649,8 @@
{
type |= PUCLASS_INPUT ;
+ display_starting_point = 0 ;
+
setColourScheme ( colour [ PUCOL_EDITFIELD ][0],
colour [ PUCOL_EDITFIELD ][1],
colour [ PUCOL_EDITFIELD ][2],
Index: puInput.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puInput.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- puInput.cxx 6 May 2005 18:31:11 -0000 1.36
+++ puInput.cxx 22 Mar 2006 19:25:28 -0000 1.37
@@ -27,7 +27,7 @@
UL_RTTI_DEF2(puInput,puInputBase,puObject)
-static char *chop_to_width ( puFont fnt, const char *s, int width, int cursor_position, int *ncut )
+static char *chop_to_width ( puFont fnt, const char *s, int width, int cursor_position, int *display_starting_point )
{
int new_len = strlen ( s ) ;
char *res = new char [ new_len + 1 ] ;
@@ -37,7 +37,7 @@
if ( new_len == 0 )
{
[...150 lines suppressed...]
highlight () ;
+
+ /* Required because we have pretty much destroyed "displayed_text" */
+ delete [] displayed_text ;
+ displayed_text = chop_to_width ( legendFont, getStringValue(),
+ abox.max[0]-abox.min[0], getCursor (), &display_starting_point ) ;
}
else
lowlight () ;
@@ -411,6 +407,10 @@
setValue ( p ) ; /* Set the widget value to the new string */
delete [] p ;
+
+ /* Since the keystroke has changed the text value, we need to change the displayed text as well. */
+ delete [] displayed_text ;
+ displayed_text = NULL ;
}
normalizeCursors () ;
|