← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2862: Show the last chat line in taskbar previews

 

------------------------------------------------------------
revno: 2862
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2012-02-09 20:45:38 +0100
message:
  Show the last chat line in taskbar previews
modified:
  changelog.txt
  dwt/include/dwt/widgets/TextBox.h
  dwt/src/widgets/RichTextBox.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2012-02-07 19:10:02 +0000
+++ changelog.txt	2012-02-09 19:45:38 +0000
@@ -19,6 +19,7 @@
 * Fix favorite hub groups on Win XP (poy)
 * [L#925659] Safer window cleanup (poy)
 * Reduce chat flickering (bigmuscle)
+* [L#923612] Show the last chat line in taskbar previews (poy)
 
 -- 0.791 2012-01-14 --
 * Update translations

=== modified file 'dwt/include/dwt/widgets/TextBox.h'
--- dwt/include/dwt/widgets/TextBox.h	2012-01-13 20:55:20 +0000
+++ dwt/include/dwt/widgets/TextBox.h	2012-02-09 19:45:38 +0000
@@ -145,7 +145,7 @@
 	  */
 	int getTextLimit() const ;
 
-	int lineIndex(int l = -1);
+	int lineIndex(int line = -1);
 
 	int lineFromChar(int c = -1);
 
@@ -277,8 +277,6 @@
 
 	int lineFromPos(const ScreenCoordinate& pt);
 
-	int lineIndex(int line);
-
 	tstring getLine(int line);
 
 	tstring textUnderCursor(const ScreenCoordinate& p, bool includeSpaces = false);
@@ -398,8 +396,8 @@
 	return this->sendMessage( EM_LINEFROMCHAR, c );
 }
 
-inline int TextBoxBase::lineIndex( int l ) {
-	return this->sendMessage( EM_LINEINDEX, l );
+inline int TextBoxBase::lineIndex(int line) {
+	return static_cast<int>(this->sendMessage(EM_LINEINDEX, static_cast<WPARAM>(line)));
 }
 
 inline void TextBoxBase::setModify( bool modify ) {
@@ -438,10 +436,6 @@
 	return HIWORD(sendMessage(EM_CHARFROMPOS, 0, lp));
 }
 
-inline int TextBox::lineIndex(int line) {
-	return static_cast<int>(sendMessage(EM_LINEINDEX, static_cast<WPARAM>(line)));
-}
-
 inline int TextBoxBase::lineLength(int c) {
 	return static_cast<int>(sendMessage(EM_LINELENGTH, static_cast<WPARAM>(c)));
 }

=== modified file 'dwt/src/widgets/RichTextBox.cpp'
--- dwt/src/widgets/RichTextBox.cpp	2012-02-07 19:10:02 +0000
+++ dwt/src/widgets/RichTextBox.cpp	2012-02-09 19:45:38 +0000
@@ -80,15 +80,22 @@
 		// paint a background in case the text doesn't span the whole box.
 		canvas.fill(rect, Brush(bgColor));
 
-		::FORMATRANGE format = { canvas.handle(), canvas.handle() };
+		FORMATRANGE format = { canvas.handle(), canvas.handle() };
 		format.rc = rect;
-		format.rc.bottom += 2; // useful when edge lines are cropped.
+		format.rc.bottom += abs(getFont()->getLogFont().lfHeight); // make room for the last line
 		// convert to twips and respect DPI settings.
 		format.rc.right *= 1440 / canvas.getDeviceCaps(LOGPIXELSX);
 		format.rc.bottom *= 1440 / canvas.getDeviceCaps(LOGPIXELSY);
 		format.rcPage = format.rc;
-		format.chrg.cpMin = lineIndex(getFirstVisibleLine());
+
+		// find the first fully visible line (sometimes they're partially cut).
+		for(auto line = getFirstVisibleLine(); ; ++line) {
+			format.chrg.cpMin = lineIndex(line);
+			if(posFromChar(format.chrg.cpMin).y >= 0)
+				break;
+		}
 		format.chrg.cpMax = -1;
+
 		sendMessage(EM_FORMATRANGE, 1, reinterpret_cast<LPARAM>(&format));
 		sendMessage(EM_FORMATRANGE); // "free the cached information" as MSDN recommends.
 	});