diff options
| author | nyamatongwe <unknown> | 2011-07-10 10:16:59 +1000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2011-07-10 10:16:59 +1000 | 
| commit | 1bcd5c53f4d187b7c3655bd50d7e0f80ed8f8811 (patch) | |
| tree | f01b9af9d12e4179c0376e3a5c6626918ef97673 | |
| parent | 9b3a416a47343b276936d0896a14f8002eef662f (diff) | |
| download | scintilla-mirror-1bcd5c53f4d187b7c3655bd50d7e0f80ed8f8811.tar.gz | |
Implement ScrollText.
| -rw-r--r-- | cocoa/ScintillaCocoa.h | 1 | ||||
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 45 | 
2 files changed, 46 insertions, 0 deletions
| diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 80a483b06..58cc66b88 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -143,6 +143,7 @@ public:    bool SetIdle(bool on);    void SetMouseCapture(bool on);    bool HaveMouseCapture(); +  void ScrollText(int linesToMove);    void SetVerticalScrollPos();    void SetHorizontalScrollPos();    bool ModifyScrollBars(int nMax, int nPage); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 899078b68..e097007c9 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1168,6 +1168,51 @@ void ScintillaCocoa::SyncPaint(void* gc, PRectangle rc)  //--------------------------------------------------------------------------------------------------  /** + * Scrolls the pixels in the window some number of lines. + * Invalidates the pixels scrolled into view. + */ +void ScintillaCocoa::ScrollText(int linesToMove) +{ +	// Move those pixels +	NSView *content = ContentView(); +     +	[content lockFocus]; +	int diff = vs.lineHeight * linesToMove; +	PRectangle textRect = GetTextRectangle(); +	// Include margins as they must scroll +	textRect.left = 0; +	NSRect textRectangle = PRectangleToNSRect(textRect); +	NSPoint destPoint = textRectangle.origin; +    destPoint.y += diff; +	NSCopyBits(0, textRectangle, destPoint); + +	// Paint them nice +	NSRect redrawRectangle = textRectangle; +	if (linesToMove < 0) { +		// Repaint bottom +		redrawRectangle.origin.y = redrawRectangle.origin.y + redrawRectangle.size.height + diff; +		redrawRectangle.size.height = -diff; +	} else { +		// Repaint top +		redrawRectangle.size.height = diff; +	} +	 +	[content drawRect: redrawRectangle]; +	[content unlockFocus]; + +	// If no flush done here then multiple scrolls will get buffered and screen  +	// will only update a few times a second. +	//[[content window] flushWindow]; +    // However, doing the flush leads to the caret updating as a separate operation +    // which looks bad when scrolling by holding down the down arrow key. + +	// Could invalidate instead of synchronous draw but that may not be as smooth +	//[content setNeedsDisplayInRect: redrawRectangle]; +} + +//-------------------------------------------------------------------------------------------------- + +/**   * Modfies the vertical scroll position to make the current top line show up as such.   */  void ScintillaCocoa::SetVerticalScrollPos() | 
