← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2526: use a different value (in the COLORREF range) for non-specified colors

 

------------------------------------------------------------
revno: 2526
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2011-05-07 20:52:09 +0200
message:
  use a different value (in the COLORREF range) for non-specified colors
modified:
  dwt/include/dwt/Theme.h
  dwt/include/dwt/forward.h
  dwt/include/dwt/widgets/FontDialog.h
  dwt/include/dwt/widgets/RichTextBox.h
  dwt/src/Theme.cpp
  dwt/src/widgets/FontDialog.cpp
  dwt/src/widgets/RichTextBox.cpp
  dwt/src/widgets/Table.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 'dwt/include/dwt/Theme.h'
--- dwt/include/dwt/Theme.h	2011-01-27 22:57:05 +0000
+++ dwt/include/dwt/Theme.h	2011-05-07 18:52:09 +0000
@@ -56,16 +56,16 @@
 	void drawBackground(Canvas& canvas, int part, int state, const Rectangle& rect, bool drawParent = true);
 	/**
 	* @param textFlags see the DrawText doc for possible values.
-	* @param color either a COLORREF or -1 for the default theme color.
+	* @param color text color, or NaC for the default theme color.
 	*/
-	void drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect, int64_t color = -1);
+	void drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect, COLORREF color = NaC);
 	/// @param textFlags see the DrawText doc for possible values.
 	void formatTextRect(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, Rectangle& rect);
 	/**
 	* @param specifier color property of the theme, see the TMT_COLOR doc for possible values.
-	* @return either a COLORREF or -1 if not specified.
+	* may return NaC if no color is available.
 	*/
-	int64_t getColor(int part, int state, int specifier);
+	COLORREF getColor(int part, int state, int specifier);
 	bool getPartSize(Canvas& canvas, int part, int state, Point& ret);
 	bool isBackgroundPartiallyTransparent(int part, int state);
 

=== modified file 'dwt/include/dwt/forward.h'
--- dwt/include/dwt/forward.h	2011-04-15 21:51:55 +0000
+++ dwt/include/dwt/forward.h	2011-05-07 18:52:09 +0000
@@ -112,6 +112,9 @@
 class MDIParent;
 typedef MDIParent* MDIParentPtr;
 
+// Not a Color - corresponds to 1 + 0xFFFFFF (the max value of a COLORREF)
+enum { NaC = 0x1000000 };
+
 class Notification;
 typedef shared_ptr<Notification> NotificationPtr;
 
@@ -179,4 +182,5 @@
 typedef Window* WindowPtr;
 
 }
+
 #endif /*FORWARD_H_*/

=== modified file 'dwt/include/dwt/widgets/FontDialog.h'
--- dwt/include/dwt/widgets/FontDialog.h	2011-01-27 22:57:05 +0000
+++ dwt/include/dwt/widgets/FontDialog.h	2011-05-07 18:52:09 +0000
@@ -51,9 +51,9 @@
 		bool strikeout; /// if false, the "Strikeout" check-box will be hidden
 		bool underline; /// if false, the "Underline" check-box will be hidden
 
-		int64_t bgColor; /// either a COLORREF or -1 for the default
+		COLORREF bgColor; /// background color of the preview control, or NaC for the default
 
-		Options() : strikeout(true), underline(true), bgColor(-1) { }
+		Options() : strikeout(true), underline(true), bgColor(NaC) { }
 	};
 
 	/** Shows the dialog

=== modified file 'dwt/include/dwt/widgets/RichTextBox.h'
--- dwt/include/dwt/widgets/RichTextBox.h	2011-04-16 14:19:18 +0000
+++ dwt/include/dwt/widgets/RichTextBox.h	2011-05-07 18:52:09 +0000
@@ -80,8 +80,8 @@
 		typedef RichTextBox::ThisType WidgetType;
 
 		FontPtr font;
-		int64_t foregroundColor; /// either a COLORREF or -1 for the default
-		int64_t backgroundColor; /// either a COLORREF or -1 for the default
+		COLORREF foregroundColor; /// the text color, or NaC for the default
+		COLORREF backgroundColor; /// the background color, or NaC for the default
 		bool scrollBarHorizontallyFlag;
 		bool scrollBarVerticallyFlag;
 

=== modified file 'dwt/src/Theme.cpp'
--- dwt/src/Theme.cpp	2011-02-01 20:32:13 +0000
+++ dwt/src/Theme.cpp	2011-05-07 18:52:09 +0000
@@ -123,12 +123,12 @@
 	DrawThemeBackground(theme, canvas.handle(), part, state, &rc, 0);
 }
 
-void Theme::drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect, int64_t color) {
+void Theme::drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect, COLORREF color) {
 	::RECT rc = rect;
 
 	if(DrawThemeTextEx) {
 		DTTOPTS opts = { sizeof(DTTOPTS) };
-		if(color != -1) {
+		if(color != NaC) {
 			opts.dwFlags |= DTT_TEXTCOLOR;
 			opts.crText = color;
 		}
@@ -155,11 +155,11 @@
 		? rcOut : rc);
 }
 
-int64_t Theme::getColor(int part, int state, int specifier) {
+COLORREF Theme::getColor(int part, int state, int specifier) {
 	COLORREF color;
 	if(GetThemeColor(theme, part, state, specifier, &color) == S_OK)
 		return color;
-	return -1;
+	return NaC;
 }
 
 bool Theme::getPartSize(Canvas& canvas, int part, int state, Point& ret) {

=== modified file 'dwt/src/widgets/FontDialog.cpp'
--- dwt/src/widgets/FontDialog.cpp	2011-02-01 21:33:33 +0000
+++ dwt/src/widgets/FontDialog.cpp	2011-05-07 18:52:09 +0000
@@ -67,7 +67,7 @@
 				::ShowWindow(box, SW_HIDE);
 			}
 
-			if(options.bgColor != -1) {
+			if(options.bgColor != NaC) {
 				::SetProp(hwnd, _T("bgColor"), &options.bgColor);
 			}
 

=== modified file 'dwt/src/widgets/RichTextBox.cpp'
--- dwt/src/widgets/RichTextBox.cpp	2011-04-16 14:24:56 +0000
+++ dwt/src/widgets/RichTextBox.cpp	2011-05-07 18:52:09 +0000
@@ -49,8 +49,8 @@
 RichTextBox::Seed::Seed() :
 	BaseType::Seed(WS_CHILD | WS_TABSTOP | WS_VSCROLL | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL),
 	font(new Font(DefaultGuiFont)),
-	foregroundColor(-1),
-	backgroundColor(-1),
+	foregroundColor(NaC),
+	backgroundColor(NaC),
 	scrollBarHorizontallyFlag(false),
 	scrollBarVerticallyFlag(false)
 {
@@ -67,8 +67,8 @@
 	if(cs.font)
 		setFont(cs.font);
 
-	COLORREF bg = (cs.backgroundColor == -1) ? ::GetSysColor(COLOR_WINDOW) : cs.backgroundColor;
-	COLORREF fg = (cs.foregroundColor == -1) ? ::GetSysColor(COLOR_WINDOWTEXT) : cs.foregroundColor;
+	COLORREF bg = (cs.backgroundColor == NaC) ? ::GetSysColor(COLOR_WINDOW) : cs.backgroundColor;
+	COLORREF fg = (cs.foregroundColor == NaC) ? ::GetSysColor(COLOR_WINDOWTEXT) : cs.foregroundColor;
 
 	setBackgroundColor(bg);
 

=== modified file 'dwt/src/widgets/Table.cpp'
--- dwt/src/widgets/Table.cpp	2011-04-23 10:33:55 +0000
+++ dwt/src/widgets/Table.cpp	2011-05-07 18:52:09 +0000
@@ -385,10 +385,8 @@
 			case CDDS_PREPAINT:
 				{
 					// got a group! get the current theme text color and compare it to the bg.
-					int64_t color = -1;
-					if(theme)
-						color = theme.getColor(LVP_GROUPHEADER, LVGH_OPEN, TMT_HEADING1TEXTCOLOR);
-					if(color == -1)
+					COLORREF color = theme ? theme.getColor(LVP_GROUPHEADER, LVGH_OPEN, TMT_HEADING1TEXTCOLOR) : NaC;
+					if(color == NaC)
 						color = 0; // assume black
 					auto r = GetRValue(bgColor), g = GetGValue(bgColor), b = GetBValue(bgColor);
 					if(abs(GetRValue(color) + GetGValue(color) + GetBValue(color) - r - g - b) < 300) {