fold background

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

fold background

Michael Surette-3
I am using a wxStyledTextCtrl and everything is working out fairly well except the background of my fold marging is not what I'd like it to be.  See the attached screenshot.

I have Googled away to no avail.

Here is the code setting up the folding:

void CQlexerInfo::fold(wxStyledTextCtrl *stc)
{
    auto bg= stc->StyleGetBackground(wxSTC_STYLE_DEFAULT);
    auto fg= stc->StyleGetForeground(wxSTC_STYLE_DEFAULT);
    
    if (_currentTheme.styles.count("fold")>0)
    {
        auto style= _currentTheme.styles["fold"];
        if (style.fg.IsOk())
            fg= style.fg;
        if (style.bg.IsOk())
            bg= style.bg;
    }

    stc->SetMarginWidth(MARGIN_FOLD, 15);
    stc->SetMarginMask (MARGIN_FOLD, wxSTC_MASK_FOLDERS);
    stc->StyleSetBackground(MARGIN_FOLD,bg);
    stc->SetMarginSensitive(MARGIN_FOLD, true);

    stc->SetProperty (wxT("fold"),         wxT("1") );
    stc->SetProperty (wxT("fold.comment"), wxT("1") );
    stc->SetProperty (wxT("fold.compact"), wxT("1") );

    stc->SetFoldMarginColour(true,bg);
    stc->SetFoldMarginHiColour(true,fg);

    stc->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN,    wxSTC_MARK_BOXMINUS);
    stc->MarkerDefine(wxSTC_MARKNUM_FOLDER,        wxSTC_MARK_BOXPLUS);
    stc->MarkerDefine(wxSTC_MARKNUM_FOLDEREND,     wxSTC_MARK_BOXPLUSCONNECTED);
    stc->MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXPLUSCONNECTED);
    stc->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER);
    stc->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL,     wxSTC_MARK_LCORNER);
    stc->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB,      wxSTC_MARK_VLINE);
}

How do I change the background of the fold margin?

Mike

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users

fold.png (62K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fold background

New Pagodi


On Wednesday, February 15, 2017 at 11:38:25 AM UTC-6, Michael Surette wrote:

How do I change the background of the fold margin?

Unlike all the other margin types which have a solid color, a fold margin is a checkerboard of pixels of 2 alternating colors.  Those colors are set with the SetFoldMarginColour and SetFoldMarginHiColour methods.  The code you posted above seems to use the background and foreground colors of the default style for those 2 colors.  I have no clue why it decided to use those colors, but if you want to keep using that system, you would need to change those colors with calls like these somewhere else in your program: 

stc->StyleSetForeground(wxSTC_STYLE_DEFAULT, wxColour(r1,g1,b1) );
stc
->StyleSetBackground(wxSTC_STYLE_DEFAULT, wxColour(r2,g2,b2) );

where you would fill in the r1,g1,b1,etc with actual the actual numbers for the colors you want.

Or if you're not committed to that system, you can simply change the lines 24 and 25 and  to something like:

stc->SetFoldMarginColour(true, wxColour(r1,g1,b1) );
stc
->SetFoldMarginHiColour(true, wxColour(r2,g2,b2) );

where, again, you need to fill in r1,g1, b1, etc.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: fold background

Michael Surette-3
Awesome!  Thank you.  I never would have figured that out by myself.

Mike

On Wed, Feb 15, 2017 at 4:57 PM, New Pagodi <[hidden email]> wrote:

>
>
> On Wednesday, February 15, 2017 at 11:38:25 AM UTC-6, Michael Surette wrote:
>>
>>
>> How do I change the background of the fold margin?
>
>
> Unlike all the other margin types which have a solid color, a fold margin is
> a checkerboard of pixels of 2 alternating colors.  Those colors are set with
> the SetFoldMarginColour and SetFoldMarginHiColour methods.  The code you
> posted above seems to use the background and foreground colors of the
> default style for those 2 colors.  I have no clue why it decided to use
> those colors, but if you want to keep using that system, you would need to
> change those colors with calls like these somewhere else in your program:
>
> stc->StyleSetForeground(wxSTC_STYLE_DEFAULT, wxColour(r1,g1,b1) );
> stc->StyleSetBackground(wxSTC_STYLE_DEFAULT, wxColour(r2,g2,b2) );
>
> where you would fill in the r1,g1,b1,etc with actual the actual numbers for
> the colors you want.
>
> Or if you're not committed to that system, you can simply change the lines
> 24 and 25 and  to something like:
>
> stc->SetFoldMarginColour(true, wxColour(r1,g1,b1) );
> stc->SetFoldMarginHiColour(true, wxColour(r2,g2,b2) );
>
> where, again, you need to fill in r1,g1, b1, etc.
>
> --
> Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
> To unsubscribe, send email to [hidden email]
> or visit http://groups.google.com/group/wx-users



--
Mike

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users