On Sun, Apr 07, 2002 at 03:54:38PM +0000, Mark and Janice Juszczec wrote:
> Hi folks,
> 
> Given a widget called orig, I'd like to create a new widget containing the 
> orig's text.  I've accomplished this with the code:
> 
>  editWidget=pgNewWidget(PG_WIDGET_FIELD,
>                         PG_DERIVE_INSIDE,
>                         editWidgetPopup);
>  pgSetWidget(editWidget,
>             PG_WP_TEXT,pgGetWidget(orig,PG_WP_TEXT),
>             0);
> 
> Now the user has indicated they're done with editWidget and I have to 
> decide if they changed any of the text.  In a perfect world, I'd like to:
> 
>  char *origText = text from orig; <- Is there a way to do this?
>  editWidget=pgNewWidget(PG_WIDGET_FIELD,
>                         PG_DERIVE_INSIDE,
>                         editWidgetPopup);
>  pgSetWidget(editWidget,
>             PG_WP_TEXT,pgGetWidget(orig,PG_WP_TEXT),
>             0);
> 
>  char *editWidgetText = text from editWidget; <- and this?
> 
> 
>  if (strcmp(origText,editWidgetText) != 0){
>     pgSetWidget(orig,
>                 PG_WP_TEXT,pgNewString(editWidgetText),
>                  any other widget properties for orig widget,
>                 0);
>  }
> 
> Basically I want to save the text from orig, compare it to the text from 
> editWidget and, if they are different, replace the text in orig with the 
> text from editWidget.
> 
> I tried char *origText=pgGetWidget(orig,PG_WP_TEXT) which failed since 
> pgGetWidget returns something of the type s32, which gdb revealed to be 
> 146. What is s32?

This is almost right. The piece you're missing is that pgGetWidget returns a handle to 
the text, so that s32 (short for signed 32-bit number) is only a way of referencing 
memory that's still in pgserver's address space. To get a copy for yourself you need 
to use pgGetString. Note that the return value of pgGetString is only valid until the 
next PicoGUI API call, so you may want to use strdup() to make a copy and free() it 
later.

> 
> If I can't do what I've described, the only other thing I can come up with 
> is to delete orig, create a new widget, add it to the list and set its text 
> to the text from editWidget using:
> 
>     pgSetWidget(newWidget,
>                 PG_WP_TEXT,pgGetWidget(editWidget,PG_WP_TEXT),
>                  any other widget properties for newWidget,
>                 0);
> 
> I'll have to do this even if the text hasn't changed since I've no way of 
> knowing if the user did or didn't change anything.  This is wasteful and I 
> hate waste.  Neither do I like deleting orig and adding a new widget to the 
> end of the list.  I don't think editing a list entry should cause it to be 
> displayed at the end of the list.  I think the entry should keep its 
> position and only the text should change.  Did that make any sense?

Yes, lots of sense. Hopefully pgGetString works for you.

Good luck on the PIM!

> 
> Anyway, does anyone have any suggestions?
> 
> Mark
> 
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> _______________________________________________
> Pgui-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/pgui-devel

-- 
Only you can prevent creeping featurism!

_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel

Reply via email to