scintilla to work with splitter views

117 views
Skip to first unread message

Kenny Liu

unread,
Sep 4, 2016, 1:43:01 AM9/4/16
to scintilla-interest

Hi there,


To come straight to the point, I would like to know how to have scintilla to work with CSplitterWnd (in MFC).


The splitter itself create its own scrollbar and show the little divider on the corner, so the GUI looks like the screenshot below (with extra scrollbars). 

(This is a demo application built from CScintillaView with a few lines modification)


I know we can use SCI_SETVSCROLLBAR/SCI_SETHSCROLLBAR to hide scintilla's scrollbar, but still the scroll of splitter cannot update its position correctly.


One solution for this would be to have scintilla send notification to its parent window in ScintillaWin::SetScrollInfo/ScintillaWin::GetScrollInfo, e.g.:


int ScintillaWin::SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) {

SCNotification sc = {0};
sc.nmhdr.code = SCN_SETSCROLLINFO;
sc.nBar = nBar;
sc.lpsi = (void*) lpsi;

NotifyParent(sc);
return ::SetScrollInfo(MainHWND(), nBar, lpsi, bRedraw);
}

bool ScintillaWin::GetScrollInfo(int nBar, LPSCROLLINFO lpsi) {

SCNotification sc = {0};
sc.nmhdr.code = SCN_GETSCROLLINFO;
sc.lpsi = (void*) lpsi;
sc.nBar = nBar;
NotifyParent(sc);

return ::GetScrollInfo(MainHWND(), nBar, lpsi) ? true : false;
}


What do you think?





Kenny Liu

unread,
Sep 4, 2016, 6:20:00 AM9/4/16
to scintilla-interest
In case anyone need this, I decided to try another approach by responding to SCN_UPDATEUI notification and call SetScrollInfo(...), this way I don't need to modify source code in scintilla. I also need to add WM_VSCROLL & WM_HSCROLL messages then call SCI_LINESCROLL too. So far I don't see any problem.
Hope this helps :)

Neil Hodgson

unread,
Sep 4, 2016, 7:38:07 PM9/4/16
to scintilla...@googlegroups.com
Kenny Liu:

> To come straight to the point, I would like to know how to have scintilla to work with CSplitterWnd (in MFC).

PythonWin can split the view and since its based on MFC, its likely it uses CSplitterWnd. Its written in Python though.

https://sourceforge.net/projects/pywin32/

Neil

Kenny Liu

unread,
Sep 6, 2016, 7:00:49 AM9/6/16
to scintilla-interest, nyama...@me.com
Hi Neil,

> PythonWin can split the view and since its based on MFC, its likely it uses CSplitterWnd. Its written in Python though. 

pywin32 uses different "style" of splitter which kind of looks like a long divider bar instead of a single small divider on the corner. 



So in pywin32 they don't need to "hide/disable" the scrollbars from scintilla, but this won't work for my case (we need the scrollbar & the little divider on the corner that come with CSplitterWnd, and apparently we don't want four scrollbars)

Anyway, I hide scintilla's scrollbar via SCI_SETVSCROLLBAR/SCI_SETHSCROLLBAR (and call SetScrollInfo manually in respond to SCN_UPDATEUI and WM_VSCROLL/WM_HSCROLL), all works fine except today I just found one issue: my scintilla-based control fail to automatically track and update the horizontal scrollbar width.

The reason for this is because I use SCI_GETSCROLLWIDTH as the value of SCROLLINFO.nMax, but actually SCI_GETSCROLLWIDTH does not return bigger value even when there are long lines in code. I check the source code, this might be the problem:

if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) {
if (FineTickerAvailable()) {
scrollWidth = view.lineWidthMaxSeen;
if (!FineTickerRunning(tickWiden)) {
FineTickerStart(tickWiden, 50, 5);
}
}
}

scrollWidth gets updated only when scintilla's scrollbar is not hidden.

How can I fix this without modifying scintilla's code?

Kenny

Neil Hodgson

unread,
Sep 7, 2016, 4:28:20 AM9/7/16
to scintilla...@googlegroups.com
Kenny Liu:

> …all works fine except today I just found one issue: my scintilla-based control fail to automatically track and update the horizontal scrollbar width.
>
> The reason for this is because I use SCI_GETSCROLLWIDTH as the value of SCROLLINFO.nMax, but actually SCI_GETSCROLLWIDTH does not return bigger value even when there are long lines in code. I check the source code, this might be the problem:
>
> if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) {

I can’t see a clean way around this now.

Neil

Reply all
Reply to author
Forward
0 new messages