xml and wxHtmlWindow

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
olivier1978
Knows some wx things
Knows some wx things
Posts: 27
Joined: Tue Mar 20, 2007 1:09 am

xml and wxHtmlWindow

Post by olivier1978 »

Hi all,

I would like to display a xml file. For taht, I use a wxHtmlWindow in a wxMiniFrame. The text is correctly rendered, but, the font is all black. Is there a way to display the text with colors, as in IE for example ?

Thanks.

Olivier
geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

Post by geralds »

The easiest route is to display the file in a wxStyledTextCtrl window and apply the XML lexer (if you need sample code, let me know).

Just set the window to read-only and you're on your way.

-Gerald
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Post by tbreina »

geralds wrote:The easiest route is to display the file in a wxStyledTextCtrl window and apply the XML lexer (if you need sample code, let me know).

Just set the window to read-only and you're on your way.

-Gerald
Gerald,

Could you provide me with a sample? I tried this, but don't get any formatting to occur:

Code: Select all

WxStyledTextCtrl1 = new wxStyledTextCtrl(this, ID_WXSTYLEDTEXTCTRL1, wxPoint(220, 22), wxSize(303, 359), 0,  wxT("WxStyledTextCtrl1"));
WxStyledTextCtrl1->SetLexer(wxSTC_LEX_XML);
WxStyledTextCtrl1->LoadFile("test.xml"); 
Thanks in advance.
-Tony
Everybody's got something to hide except for me and my monkey.
geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

Post by geralds »

Hi Tony

You also need to define the colours that attach to particular styles and then instruct the control to repaint.

Can't write in detail right now, but for a (rather untidy) attempt at using XmlCtrl, see:

http://xml-copy-editor.svn.sourceforge. ... /xmlctrl.h

http://xml-copy-editor.svn.sourceforge. ... mlctrl.cpp

Sorry I don't have time to reduce this down to the essential function calls right now...

-Gerald
Post Reply