mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-17 17:02:51 +08:00
Add Edit::ToggleLineNumbers() to the sample
Make it a bit simpler to show line numbers when showing the minimap.
This commit is contained in:
@@ -320,6 +320,10 @@ void Edit::OnIndentGuide (wxCommandEvent &WXUNUSED(event)) {
|
||||
}
|
||||
|
||||
void Edit::OnLineNumber (wxCommandEvent &WXUNUSED(event)) {
|
||||
ToggleLineNumbers();
|
||||
}
|
||||
|
||||
void Edit::ToggleLineNumbers() {
|
||||
SetMarginWidth (m_LineNrID,
|
||||
GetMarginWidth (m_LineNrID) == 0? m_LineNrMargin: 0);
|
||||
}
|
||||
|
||||
@@ -131,6 +131,9 @@ public:
|
||||
wxString GetFilename () {return m_filename;}
|
||||
void SetFilename (const wxString &filename) {m_filename = filename;}
|
||||
|
||||
// Toggle showing line numbers in the margin.
|
||||
void ToggleLineNumbers();
|
||||
|
||||
private:
|
||||
// file
|
||||
wxString m_filename;
|
||||
|
||||
@@ -1616,8 +1616,8 @@ void App::ShowDocumentMap(wxWindow* parent)
|
||||
auto* const edit = new Edit(splitter);
|
||||
edit->LoadFile("stctest.cpp");
|
||||
|
||||
// Show line numbers and hide the other margins not used here.
|
||||
edit->SetMarginWidth(0, edit->GetTextExtent("99999").x);
|
||||
// Show line numbers in the margin, which are hidden by default.
|
||||
edit->ToggleLineNumbers();
|
||||
|
||||
edit->SetWrapMode(wxSTC_WRAP_WORD);
|
||||
edit->SetWrapVisualFlags(wxSTC_WRAPVISUALFLAG_END);
|
||||
|
||||
Reference in New Issue
Block a user