wxStyledTextCtrl styling issues

CodeLite installation/troubleshooting forum
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

wxStyledTextCtrl styling issues

Post by ColinTaylor »

Looking for advice, not sure how to proceed on this problem

Windows 8 / Codelite 5.3 / wxWidgets 2.9.5

I'm seeing some odd styling when using the wxStyledTextCtrl class, and I don't recall seeing this when using wxWidgets 2.9.4 (although haven't tested this)

It seems easy to recreate ...

1. Create a codelite gui project, wxFrame using wxCrafter
2. Add a wxStyledTextCtrl object
3. Add lines similar to the following to MainFrame.cpp constructor

m_stc13->StyleClearAll();
m_stc13->SetLexer(wxSTC_LEX_CPP);
m_stc13->LoadFile("E:\\Dev\\wxWidgets-2.9.5-full\\samples\\access\\accesstest.cpp");

(The file in the loadfile call needs to contain #ifdef statements)

4. Compile, link and run the program
5. The appearance of statements inside the #ifdef preprocessor block contains odd characters as in the first example (Image1.png)
Image1.png
The appearance improves if the first '#' character is removed as in Image2.png
Image2.png
Any advice on how to make the appearance look better?
Thanks, Colin
You do not have the required permissions to view the files attached to this post.
5k3105
CodeLite Enthusiast
Posts: 22
Joined: Tue Sep 17, 2013 11:44 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxStyledTextCtrl styling issues

Post by 5k3105 »

This happens to me as well. Still haven't figured out what I'm doing wrong.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxStyledTextCtrl styling issues

Post by eranif »

Try adding this to your wxStyledTextCtrl initialization and see if it helps:

Code: Select all

stc->SetProperty(wxT("lexer.cpp.track.preprocessor"), "0");
stc->SetProperty(wxT("lexer.cpp.update.preprocessor"), "0");
Eran
Make sure you have read the HOW TO POST thread
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxStyledTextCtrl styling issues

Post by ColinTaylor »

Many thanks Eran, that works perfectly. :D

As an aside, I just noticed that wxCrafter suffers from the same issue. If you look at the generated C++ code *and* Crafter has used an #ifdef construct, which happens (I think) if you change a component font ...

Code: Select all

    #ifdef __WXMSW__
    // To get the newer version of the font on MSW, we use font wxSYS_DEFAULT_GUI_FONT with family set to wxFONTFAMILY_TELETYPE
    wxFont m_stc13Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    m_stc13Font.SetFamily(wxFONTFAMILY_TELETYPE);
    #else
    wxFont m_stc13Font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
    #endif
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxStyledTextCtrl styling issues

Post by eranif »

ColinTaylor wrote:As an aside, I just noticed that wxCrafter suffers from the same issue.
After you reported your error, I remembered something similar in wxCrafter... so I already fixed that before posting the fix here

Eran
Make sure you have read the HOW TO POST thread
Post Reply