wxRichTextCtrl GetStyle() bug example application

Tom Gersic wxdev at teleologic.net
Tue Jan 23 19:02:47 PST 2007


Hi All,

I've put together a quick example of the problem that I'm experiencing 
with wxRichTextCtrl. Here are some screenshots:

http://gersic.com/files/wxRichTextCtrl.jpg
http://gersic.com/files/wxRichTextCtrl2.jpg

As you can see, in the second screen shot, characters 15, 16, and 17 
should be shown as linked, but they're not.

Here's a link to the exe:

http://gersic.com/files/richTextCtrlBugExe.zip

Here's a link to the complete code:

http://gersic.com/files/richTextCtrlBugCode.zip

And here's the code for what the buttons do:

void richTextWindow::OnButtonClick( wxCommandEvent& event )
{
    outputCtrl->Clear();
    outputCtrl->AppendText("Counting Backwards from Character 29...\n\n");

    int startLocation=29;
    wxRichTextAttr attr;
    daTextCtrl->GetStyle(startLocation, attr);

    if(attr.HasFlag(wxTEXT_ATTR_URL))
    {
        outputCtrl->AppendText(wxString::Format("Character %d is 
linked\n",startLocation));           
    }
    else
    {
        outputCtrl->AppendText(wxString::Format("Character %d is not 
linked\n",startLocation));           
    }

    while(startLocation>0)
    {
        startLocation--;
        daTextCtrl->GetStyle(startLocation, attr);
        if(attr.HasFlag(wxTEXT_ATTR_URL))
        {
            outputCtrl->AppendText(wxString::Format("Character %d is 
linked\n",startLocation));           
        }
        else
        {
            outputCtrl->AppendText(wxString::Format("Character %d is not 
linked\n",startLocation));           
        }
    }
}

void richTextWindow::OnButton1Click( wxCommandEvent& event )
{
    outputCtrl->Clear();
    outputCtrl->AppendText("Counting Backwards from Character 18...\n\n");

    int startLocation=18;
    wxRichTextAttr attr;
    daTextCtrl->GetStyle(startLocation, attr);

    if(attr.HasFlag(wxTEXT_ATTR_URL))
    {
        outputCtrl->AppendText(wxString::Format("Character %d is 
linked\n",startLocation));           
    }
    else
    {
        outputCtrl->AppendText(wxString::Format("Character %d is not 
linked\n",startLocation));           
    }

    while(startLocation>0)
    {
        startLocation--;
        daTextCtrl->GetStyle(startLocation, attr);
        if(attr.HasFlag(wxTEXT_ATTR_URL))
        {
            outputCtrl->AppendText(wxString::Format("Character %d is 
linked\n",startLocation));           
        }
        else
        {
            outputCtrl->AppendText(wxString::Format("Character %d is not 
linked\n",startLocation));           
        }
    }
}


Thanks,
Tom




More information about the wx-dev mailing list