OSDN Git Service

Make a folder compare report with color 2.14.0+-jp-1
authorsdottaka <none@none>
Tue, 12 Feb 2013 07:58:34 +0000 (23:58 -0800)
committersdottaka <none@none>
Tue, 12 Feb 2013 07:58:34 +0000 (23:58 -0800)
Src/DirCmpReport.cpp
Src/IListCtrl.h
Src/IListCtrlImpl.h

index 8972d6b..6371d56 100644 (file)
@@ -39,9 +39,12 @@ static String GetCurrentTimeString()
  * @param [in] elName String to format as beginning tag.
  * @return String formatted as beginning tag.
  */
-static String BeginEl(const String& elName)
+static String BeginEl(const String& elName, const String& attr = _T(""))
 {
-       return string_format(_T("<%s>"), elName.c_str());
+       if (attr.empty())
+               return string_format(_T("<%s>"), elName.c_str());
+       else
+               return string_format(_T("<%s %s>"), elName.c_str(), attr.c_str());
 }
 
 /**
@@ -398,8 +401,17 @@ void DirCmpReport::GenerateXmlHtmlContent(bool xml)
 
                String rowEl = _T("tr");
                if (xml)
+               {
                        rowEl = _T("filediff");
-               WriteString(BeginEl(rowEl));
+                       WriteString(BeginEl(rowEl));
+               }
+               else
+               {
+                       COLORREF color = m_pList->GetBackColor(currRow);
+                       String attr = string_format(_T("style='background-color: #%02x%02x%02x'"),
+                               GetRValue(color), GetGValue(color), GetBValue(color));
+                       WriteString(BeginEl(rowEl, attr));
+               }
                for (int currCol = 0; currCol < m_nColumns; currCol++)
                {
                        String colEl = _T("td");
index 7a43d47..34cc84d 100644 (file)
@@ -9,6 +9,7 @@ struct IListCtrl
        virtual int GetRowCount() const = 0;
        virtual String GetColumnName(int col) const = 0;
        virtual String GetItemText(int row, int col) const = 0;
+       virtual int GetBackColor(int row) const = 0;
 };
 
 #endif
index 6552c8c..a78d09d 100644 (file)
@@ -1,13 +1,13 @@
-#include "IListCtrl.h"\r
-#include <commctrl.h>\r
-\r
-class IListCtrlImpl : public IListCtrl\r
-{\r
-public:\r
-       IListCtrlImpl(HWND hwndListCtrl) : m_hwndListCtrl(hwndListCtrl)\r
-       {\r
-       }\r
-\r
+#include "IListCtrl.h"
+#include <commctrl.h>
+
+class IListCtrlImpl : public IListCtrl
+{
+public:
+       IListCtrlImpl(HWND hwndListCtrl) : m_hwndListCtrl(hwndListCtrl)
+       {
+       }
+
        int GetColumnCount() const
        {
                return Header_GetItemCount(ListView_GetHeader(m_hwndListCtrl));
@@ -29,13 +29,25 @@ public:
                return lvc.pszText;
        }
 
-       String GetItemText(int row, int col) const\r
-       {\r
+       String GetItemText(int row, int col) const
+       {
                TCHAR text[512]; // Assuming max col header will never be > 512
-               ListView_GetItemText(m_hwndListCtrl, row, col, text, sizeof(text)/sizeof(text[0]));\r
-               return text;\r
-       }\r
-\r
-protected:\r
-       HWND m_hwndListCtrl;\r
-};
\ No newline at end of file
+               ListView_GetItemText(m_hwndListCtrl, row, col, text, sizeof(text)/sizeof(text[0]));
+               return text;
+       }
+
+       int GetBackColor(int row) const
+       {
+               NMLVCUSTOMDRAW nmlvcd = {0};
+               nmlvcd.nmcd.hdr.code = NM_CUSTOMDRAW;
+               nmlvcd.nmcd.hdr.idFrom = GetDlgCtrlID(m_hwndListCtrl);
+               nmlvcd.nmcd.hdr.hwndFrom = m_hwndListCtrl;
+               nmlvcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT | CDDS_SUBITEM;
+               nmlvcd.nmcd.dwItemSpec = row;
+               SendMessage(GetParent(m_hwndListCtrl), WM_NOTIFY, (WPARAM)m_hwndListCtrl, (LPARAM)&nmlvcd);
+               return nmlvcd.clrTextBk;
+       }
+
+protected:
+       HWND m_hwndListCtrl;
+};