Teodor:
> Are you implementing this feature for an open-source project or closed one?
> If it is the former can you share some code? :)
Yes, it's an open-source project (
http://studio.zerobrane.com), but this code is not included yet; it's only a prototype I'm working on.
Something like this should give you an idea; this is in Lua, but you can easily map wxwidgets/wxstc calls to whatever works for you. This code simply sets the first line when it is scrolled. As the minimap is likely to have a different font size, you may need to come up with a different synchronization condition, but the main idea is likely to be the same.
require "wx"
local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "STC Demo",
wx.wxDefaultPosition, wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE )
local e1 = wxstc.wxStyledTextCtrl(frame, wx.wxID_ANY,
wx.wxDefaultPosition, wx.wxSize(0, 0), wx.wxBORDER_STATIC)
local e2 = wxstc.wxStyledTextCtrl(frame, wx.wxID_ANY,
wx.wxDefaultPosition, wx.wxSize(0, 0), wx.wxBORDER_STATIC)
local sizer = wx.wxBoxSizer(wx.wxHORIZONTAL)
sizer:Add(e1, 1, wx.wxEXPAND + wx.wxALL, 10)
sizer:Add(e2, 1, wx.wxEXPAND + wx.wxALL, 10)
frame:SetAutoLayout(true)
frame:SetSizer(sizer)
e2:SetMarginWidth(1, 0)
e2:SetMarginLeft(2)
-- set doc pointers to the same document
local docpointer = e1:GetDocPointer()
e1:AddRefDocument(docpointer)
e2:SetDocPointer(docpointer)
-- create handlers that keep the two viewes in sync
local nosync = false
local function sync(ed1, ed2)
return function()
if nosync then return end
nosync = true
local line = ed1:GetFirstVisibleLine()
if ed2:GetFirstVisibleLine() ~= line then ed2:ScrollToLine(line) end
nosync = false
end
end
e1:Connect(wxstc.wxEVT_STC_PAINTED, sync(e1, e2))
e2:Connect(wxstc.wxEVT_STC_PAINTED, sync(e2, e1))
frame:Show(true)
wx.wxGetApp():MainLoop()
Paul.