paragui-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-users] RICHEDIT


From: John Rainey
Subject: [paragui-users] RICHEDIT
Date: Fri, 30 Aug 2002 16:30:16 -0400

I've been trying to use a richedit widget
created by the layout manager. I'm using rel-1-0-3 from CVS.
I've come across a curios problem, the layout manager creates the
richedit widget and sets it's text property which parses the text and
completes the lines. Then when XMLEndDoc is called the widget addtext
function is called adding an empty string to the richedit my_text member.
This call clears out the my_text member.

It works fine for other widgets such as popups, dropdowns,
and buttons but clears the my_text member of the richedit which gets parsed
and clears all the text from the richedit text maps previously loaded when
processing the tag.

This is do to setting the std:string my_text to the const char* text
parameter
when text points to the buffer in the my_text std:string,in the
PG_Widget::SetText function.
There is no guarantee when setting a std:string that it will not deallocate
it's current
buffer and make a new one. That is indeed what happens. consequently the new
buffer
is blank which is of course what the const char* text points to.

I fixed the problem by creating a tempory std:string to receive the text
value, then set my_text to that temporary string.

This still requires the text to be parsed twice??? Why is the line

object_end:
                XMLParser->ParentObject->AddText(" ", true);

in the layout code XMLEndDoc procedure?

XMLParser->ParentObject->AddText("", true);

void PG_Widget::SetText(const char* text) {

        //added by jpr
        // to fix bug if text points to buffer of my_text
        std::string temptext=text;
        my_internaldata->widthText = TXT_HEIGHT_UNDEF;
        my_internaldata->heightText = TXT_HEIGHT_UNDEF;

        if(text == NULL) {
                my_text = "";
                return;
        }
        //added by jpr
        my_text = temptext;
        Update();
}

static void XMLEndDoc(void *userData, const char *name) {
        ParseUserData_t *XMLParser = (ParseUserData_t *)userData;
        PG_Widget               *WidgetToAdd = NULL;

        //if (XMLParser->Section & XML_SECTION_FONT)
        //      XMLTextDoc(userData, PG_FFT_END_TAG , 2);

        if ((XMLParser->EndTagFlags & ENDTAGFLAG_SETSIZE) != 0) {

XMLParser->ParentObject->SetSizeByText(XMLParser->Width,XMLParser->Height);
        }

        if ((XMLParser->EndTagFlags & ENDTAGFLAG_OBJECT) != 0) {
                if (((XMLParser->InhTagFlags & INHTAGFLAG_ADDWIDGET) != 0) &&
((XMLParser->EndTagFlags & ENDTAGFLAG_WIDGETLIST) == 0)) {
                        WidgetToAdd = XMLParser->ParentObject;
                        goto object_end;
                }

                if ((XMLParser->InhTagFlags & INHTAGFLAG_HIDE) == 0)
                        if(XMLParser->ParentObject->GetParent() == NULL) {
                                XMLParser->ParentObject->Show();
                        }
                else
                        XMLParser->ParentObject->Hide();

object_end:
                // jpr why is the text being reset?????
                XMLParser->ParentObject->AddText(" ", true);
        }

        RestoreUserData(XMLParser);

        if (WidgetToAdd == NULL) {
                return;
        }

        ((PG_WidgetList *)(XMLParser->ParentObject))->AddWidget(WidgetToAdd);
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]