aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2002-04-07 02:24:40 +0000
committernyamatongwe <devnull@localhost>2002-04-07 02:24:40 +0000
commitef5b2192b86405b14f7cc45f6d48b9f9889eedbe (patch)
treec4a4656a5cf4fdf8eeb37bf82ce19710a8d76dc3
parentdbae5814b486802378c41ca4c095d0aa6dfcff86 (diff)
downloadscintilla-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.
-rw-r--r--include/Scintilla.h2
-rw-r--r--include/Scintilla.iface6
-rw-r--r--src/Editor.cxx38
-rw-r--r--src/Editor.h2
4 files changed, 42 insertions, 6 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 2f763de0f..e5ccd6f11 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -361,6 +361,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETLAYOUTCACHE 2273
#define SCI_SETSCROLLWIDTH 2274
#define SCI_GETSCROLLWIDTH 2275
+#define SCI_TEXTWIDTH 2276
#define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302
@@ -527,6 +528,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCN_URIDROPPED 2015
#define SCN_DWELLSTART 2016
#define SCN_DWELLEND 2017
+#define SCN_ZOOM 2018
//--Autogenerated -- end of section automatically generated from Scintilla.iface
// These structures are defined to be exactly the same shape as the Win32
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index c49ca40e0..99afef5c0 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -938,6 +938,11 @@ set void SetScrollWidth=2274(int pixelWidth,)
# Retrieve the document width assumed for scrolling.
get int GetScrollWidth=2275(,)
+# Measure the pixel width of some text in a particular style.
+# Nul terminated text argument.
+# Does not handle tab or control characters.
+fun int TextWidth=2276(int style, string text)
+
## Start of key messages
# Move caret down one line.
fun void LineDown=2300(,)
@@ -1725,6 +1730,7 @@ evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text)
evt void DwellStart=2016(int position)
evt void DwellEnd=2017(int position)
+evt void Zoom=2018(void)
cat Deprecated
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);