Page 1 of 1

wxStyledTextCtrl styling issues

Posted: Mon Dec 02, 2013 3:31 pm
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

Re: wxStyledTextCtrl styling issues

Posted: Thu Dec 12, 2013 8:14 am
by 5k3105
This happens to me as well. Still haven't figured out what I'm doing wrong.

Re: wxStyledTextCtrl styling issues

Posted: Thu Dec 12, 2013 10:17 am
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

Re: wxStyledTextCtrl styling issues

Posted: Thu Dec 12, 2013 12:58 pm
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

Re: wxStyledTextCtrl styling issues

Posted: Thu Dec 12, 2013 1:38 pm
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