diff options
author | nyamatongwe <devnull@localhost> | 2002-04-07 02:24:40 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2002-04-07 02:24:40 +0000 |
commit | ef5b2192b86405b14f7cc45f6d48b9f9889eedbe (patch) | |
tree | c4a4656a5cf4fdf8eeb37bf82ce19710a8d76dc3 /src | |
parent | dbae5814b486802378c41ca4c095d0aa6dfcff86 (diff) | |
download | scintilla-mirror-ef5b2192b86405b14f7cc45f6d48b9f9889eedbe.tar.gz |
Added ZOOM notification. Added TextWidth method to allow clients to determine width of text items such as width needed for line numbers.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 38 | ||||
-rw-r--r-- | src/Editor.h | 2 |
2 files changed, 34 insertions, 6 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 4e430b0d7..86b0aa1f2 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2168,6 +2168,16 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { return endPosPrint; } +int Editor::TextWidth(int style, const char *text) { + RefreshStyleData(); + AutoSurface surface(IsUnicodeMode()); + if (surface) { + return surface->WidthText(vs.styles[style].font, text, strlen(text)); + } else { + return 1; + } +} + // Empty method is overridden on GTK+ to show / hide scrollbars void Editor::ReconfigureScrollBars() {} @@ -2528,6 +2538,12 @@ void Editor::NotifyDwelling(Point pt, bool state) { NotifyParent(scn); } +void Editor::NotifyZoom() { + SCNotification scn; + scn.nmhdr.code = SCN_ZOOM; + NotifyParent(scn); +} + // Notifications from document void Editor::NotifyModifyAttempt(Document*, void *) { //Platform::DebugPrintf("** Modify Attempt\n"); @@ -3028,16 +3044,20 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_ZOOMIN: - if (vs.zoomLevel < 20) + if (vs.zoomLevel < 20) { vs.zoomLevel++; - NeedWrapping(); - InvalidateStyleRedraw(); + NeedWrapping(); + InvalidateStyleRedraw(); + NotifyZoom(); + } break; case SCI_ZOOMOUT: - if (vs.zoomLevel > -10) + if (vs.zoomLevel > -10) { vs.zoomLevel--; - NeedWrapping(); - InvalidateStyleRedraw(); + NeedWrapping(); + InvalidateStyleRedraw(); + NotifyZoom(); + } break; case SCI_DELWORDLEFT: { int startWord = pdoc->NextWordStart(currentPos, -1); @@ -4679,6 +4699,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETSCROLLWIDTH: return scrollWidth; + case SCI_TEXTWIDTH: + PLATFORM_ASSERT((wParam >= 0) && (wParam <= STYLE_MAX)); + PLATFORM_ASSERT(lParam); + return TextWidth(wParam, reinterpret_cast<char *>(lParam)); + case SCI_GETCOLUMN: return pdoc->GetColumn(wParam); @@ -5178,6 +5203,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.zoomLevel = wParam; NeedWrapping(); InvalidateStyleRedraw(); + NotifyZoom(); break; case SCI_GETZOOM: diff --git a/src/Editor.h b/src/Editor.h index ba35c83c3..5a82f32ff 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -343,6 +343,7 @@ protected: // ScintillaBase subclass needs access to much of Editor PRectangle rcLine, LineLayout *ll, int subLine=0); void Paint(Surface *surfaceWindow, PRectangle rcArea); long FormatRange(bool draw, RangeToFormat *pfr); + int TextWidth(int style, const char *text); virtual void SetVerticalScrollPos() = 0; virtual void SetHorizontalScrollPos() = 0; @@ -384,6 +385,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); void NotifyNeedShown(int pos, int len); void NotifyDwelling(Point pt, bool state); + void NotifyZoom(); void NotifyModifyAttempt(Document *document, void *userData); void NotifySavePoint(Document *document, void *userData, bool atSavePoint); |