Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Dec 30, 2023
1 parent bd32ecd commit f170e0b
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 40 deletions.
31 changes: 23 additions & 8 deletions src/WinWebDiffLib/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
#define IDR_POPUP_WEBPAGE_COMPARE 131
#define IDR_POPUP_WEBPAGE_SYNC_EVENTS 132
#define IDC_COMPARE 1021
#define IDC_ZOOM 1022
#define IDC_WIDTH 1023
#define IDC_BY 1024
#define IDC_HEIGHT 1025
#define IDC_FITTOWINDOW 1026
#define IDC_USERAGENT 1027
#define IDC_SHOWDIFFERENCES 1028
#define IDC_SYNC_EVENTS 1029
#define IDC_ZOOM_LABEL 1022
#define IDC_ZOOM 1023
#define IDC_WIDTH 1024
#define IDC_BY 1025
#define IDC_HEIGHT 1026
#define IDC_FITTOWINDOW 1027
#define IDC_USERAGENT 1028
#define IDC_SHOWDIFFERENCES 1029
#define IDC_SYNC_EVENTS 1030
#define ID_WEB_COMPARE_SCREENSHOTS 1633
#define ID_WEB_COMPARE_FULLSIZE_SCREENSHOTS 1634
#define ID_WEB_COMPARE_HTMLS 1635
Expand All @@ -31,6 +32,20 @@
#define ID_WEB_SYNC_CLICK 1640
#define ID_WEB_SYNC_INPUT 1641
#define ID_WEB_SYNC_GOBACKFORWARD 1642
#define IDS_COMPARE 2000
#define IDS_ZOOM 2001
#define IDS_SYNC_EVENTS 2002
#define IDS_SHOWDIFFERENCES 2003
#define IDS_WEB_COMPARE_SCREENSHOTS 2004
#define IDS_WEB_COMPARE_FULLSIZE_SCREENSHOTS 2005
#define IDS_WEB_COMPARE_HTMLS 2006
#define IDS_WEB_COMPARE_TEXTS 2007
#define IDS_WEB_COMPARE_RESOURCETREES 2008
#define IDS_WEB_SYNC_ENABLED 2009
#define IDS_WEB_SYNC_SCROLL 2010
#define IDS_WEB_SYNC_CLICK 2011
#define IDS_WEB_SYNC_INPUT 2012
#define IDS_WEB_SYNC_GOBACKFORWARD 2013
#define IDC_STATIC -1

// Next default values for new objects
Expand Down
86 changes: 65 additions & 21 deletions src/WinWebDiffLib/WebToolWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
{
public:
CWebToolWindow() :
m_hWnd(NULL)
, m_hInstance(NULL)
, m_pWebDiffWindow(NULL)
m_hWnd(nullptr)
, m_hInstance(nullptr)
, m_hComparePopup(nullptr)
, m_hEventSyncPopup(nullptr)
, m_pWebDiffWindow(nullptr)
, m_bInSync(false)
, m_nRef(0)
{
}

Expand All @@ -26,13 +29,19 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
{
m_hInstance = hInstance;
m_hWnd = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DIALOGBAR), hWndParent, DlgProc, reinterpret_cast<LPARAM>(this));
m_hComparePopup = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_WEBPAGE_COMPARE));
m_hEventSyncPopup = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_WEBPAGE_SYNC_EVENTS));
return m_hWnd ? true : false;
}

bool Destroy()
{
BOOL bSucceeded = DestroyWindow(m_hWnd);
m_hWnd = NULL;
m_hWnd = nullptr;
DestroyMenu(m_hComparePopup);
m_hComparePopup = nullptr;
DestroyMenu(m_hEventSyncPopup);
m_hEventSyncPopup = nullptr;
return !!bSucceeded;
}

Expand Down Expand Up @@ -61,17 +70,6 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
EnableWindow(GetDlgItem(m_hWnd, IDC_HEIGHT), !m_pWebDiffWindow->GetFitToWindow());

/*
SendDlgItemMessage(m_hWnd, IDC_DIFF_HIGHLIGHT, BM_SETCHECK, m_pWebDiffWindow->GetShowDifferences() ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(m_hWnd, IDC_DIFF_BLOCKSIZE_SLIDER, TBM_SETPOS, TRUE, m_pWebDiffWindow->GetDiffBlockSize());
SendDlgItemMessage(m_hWnd, IDC_DIFF_BLOCKALPHA_SLIDER, TBM_SETPOS, TRUE, static_cast<LPARAM>(m_pWebDiffWindow->GetDiffColorAlpha() * 100));
SendDlgItemMessage(m_hWnd, IDC_DIFF_CDTHRESHOLD_SLIDER, TBM_SETPOS, TRUE, static_cast<LPARAM>(m_pWebDiffWindow->GetColorDistanceThreshold()));
SendDlgItemMessage(m_hWnd, IDC_OVERLAY_ALPHA_SLIDER, TBM_SETPOS, TRUE, static_cast<LPARAM>(m_pWebDiffWindow->GetOverlayAlpha() * 100));
SendDlgItemMessage(m_hWnd, IDC_ZOOM_SLIDER, TBM_SETPOS, TRUE, static_cast<LPARAM>(m_pWebDiffWindow->GetZoom() * 8 - 8));
SendDlgItemMessage(m_hWnd, IDC_DIFF_INSERTION_DELETION_DETECTION_MODE, CB_SETCURSEL, m_pWebDiffWindow->GetInsertionDeletionDetectionMode(), 0);
SendDlgItemMessage(m_hWnd, IDC_OVERLAY_MODE, CB_SETCURSEL, m_pWebDiffWindow->GetOverlayMode(), 0);
SendDlgItemMessage(m_hWnd, IDC_PAGE_SPIN, UDM_SETRANGE, 0, MAKELONG(1, m_pWebDiffWindow->GetMaxPageCount()));
SendDlgItemMessage(m_hWnd, IDC_PAGE_SPIN, UDM_SETPOS, 0, MAKELONG(m_pWebDiffWindow->GetCurrentMaxPage() + 1, 0));
int w = static_cast<CWebDiffWindow *>(m_pWebDiffWindow)->GetDiffImageWidth();
int h = static_cast<CWebDiffWindow *>(m_pWebDiffWindow)->GetDiffImageHeight();
Expand Down Expand Up @@ -123,6 +121,51 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
wcscpy_s(translated, org);
return std::wstring(translated);
};

struct StringIdControlId
{
int stringId;
int controlId;
};
static const StringIdControlId stringIdControlId[] = {
{IDS_COMPARE, IDC_COMPARE},
{IDS_ZOOM, IDC_ZOOM_LABEL},
{IDS_SYNC_EVENTS, IDC_SYNC_EVENTS},
{IDS_SHOWDIFFERENCES, IDC_SHOWDIFFERENCES},
};
for (auto& e: stringIdControlId)
::SetDlgItemText(m_hWnd, e.controlId, translateString(e.stringId).c_str());

static const StringIdControlId stringIdControlId1[] = {
{IDS_WEB_COMPARE_SCREENSHOTS, ID_WEB_COMPARE_SCREENSHOTS},
{IDS_WEB_COMPARE_FULLSIZE_SCREENSHOTS, ID_WEB_COMPARE_FULLSIZE_SCREENSHOTS},
{IDS_WEB_COMPARE_HTMLS, ID_WEB_COMPARE_HTMLS},
{IDS_WEB_COMPARE_TEXTS, ID_WEB_COMPARE_TEXTS},
{IDS_WEB_COMPARE_RESOURCETREES, ID_WEB_COMPARE_RESOURCETREES},
};
for (auto& e : stringIdControlId1)
{
std::wstring str = translateString(e.stringId);
MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
mii.fMask = MIIM_STRING;
mii.dwTypeData = const_cast<LPWSTR>(str.c_str());
::SetMenuItemInfo(m_hComparePopup, e.controlId, FALSE, &mii);
}
static const StringIdControlId stringIdControlId2[] = {
{IDS_WEB_SYNC_ENABLED, ID_WEB_SYNC_ENABLED},
{IDS_WEB_SYNC_SCROLL, ID_WEB_SYNC_SCROLL},
{IDS_WEB_SYNC_CLICK, ID_WEB_SYNC_CLICK},
{IDS_WEB_SYNC_INPUT, ID_WEB_SYNC_INPUT},
{IDS_WEB_SYNC_GOBACKFORWARD, ID_WEB_SYNC_GOBACKFORWARD},
};
for (auto& e : stringIdControlId2)
{
std::wstring str = translateString(e.stringId);
MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
mii.fMask = MIIM_STRING;
mii.dwTypeData = const_cast<LPWSTR>(str.c_str());
::SetMenuItemInfo(m_hEventSyncPopup, e.controlId, FALSE, &mii);
}
}

private:
Expand All @@ -141,8 +184,7 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
RECT rc;
GetWindowRect(GetDlgItem(m_hWnd, IDC_COMPARE), &rc);
POINT point{ rc.left, rc.bottom };
HMENU hPopup = LoadMenu(GetModuleHandle(L"WinWebDiffLib.dll"), MAKEINTRESOURCE(IDR_POPUP_WEBPAGE_COMPARE));
HMENU hSubMenu = GetSubMenu(hPopup, 0);
HMENU hSubMenu = GetSubMenu(m_hComparePopup, 0);
TrackPopupMenu(hSubMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, 0, m_hWnd, nullptr);
}

Expand All @@ -151,8 +193,7 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
RECT rc;
GetWindowRect(GetDlgItem(m_hWnd, IDC_SYNC_EVENTS), &rc);
POINT point{ rc.left, rc.bottom };
HMENU hPopup = LoadMenu(GetModuleHandle(L"WinWebDiffLib.dll"), MAKEINTRESOURCE(IDR_POPUP_WEBPAGE_SYNC_EVENTS));
HMENU hSubMenu = GetSubMenu(hPopup, 0);
HMENU hSubMenu = GetSubMenu(m_hEventSyncPopup, 0);
CheckMenuItem(hSubMenu, ID_WEB_SYNC_ENABLED, m_pWebDiffWindow->GetSyncEvents() ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hSubMenu, ID_WEB_SYNC_SCROLL, m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_SCROLL) ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hSubMenu, ID_WEB_SYNC_CLICK, m_pWebDiffWindow->GetSyncEventFlag(IWebDiffWindow::EVENT_CLICK) ? MF_CHECKED : MF_UNCHECKED);
Expand Down Expand Up @@ -224,6 +265,7 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
case IDC_SYNC_EVENTS:
if (codeNotify == BN_CLICKED)
ShowSyncEventsPopupMenu();
break;
case ID_WEB_SYNC_ENABLED:
m_pWebDiffWindow->SetSyncEvents(!m_pWebDiffWindow->GetSyncEvents());
break;
Expand Down Expand Up @@ -381,7 +423,7 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler

HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override { return E_NOTIMPL; }
ULONG STDMETHODCALLTYPE AddRef(void) override { return ++m_nRef; }
ULONG STDMETHODCALLTYPE Release(void) override { if (--m_nRef == 0) { delete this; return 0; } return m_nRef; }
ULONG STDMETHODCALLTYPE Release(void) override { if (--m_nRef == 0) { return 0; } return m_nRef; }

HRESULT Invoke(const WebDiffEvent& event)
{
Expand All @@ -396,8 +438,10 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler

HWND m_hWnd;
HINSTANCE m_hInstance;
HMENU m_hComparePopup;
HMENU m_hEventSyncPopup;
IWebDiffWindow *m_pWebDiffWindow;
bool m_bInSync;
int m_nRef = 0;
int m_nRef;

};
46 changes: 35 additions & 11 deletions src/WinWebDiffLib/WinWebDiffLib.rc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ BEGIN
EDITTEXT IDC_WIDTH,16,16,24,12,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "x",IDC_BY,40,20,6,8
EDITTEXT IDC_HEIGHT,46,16,24,12,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Zoom:",IDC_STATIC,2,30,34,10
LTEXT "Zoom:",IDC_ZOOM_LABEL,2,30,34,10
COMBOBOX IDC_ZOOM,36,30,34,88,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT "UA:",IDC_STATIC,2,44,16,10
EDITTEXT IDC_USERAGENT,18,44,52,14,ES_AUTOHSCROLL | WS_TABSTOP
Expand All @@ -159,27 +159,51 @@ IDR_POPUP_WEBPAGE_COMPARE MENU
BEGIN
POPUP "_POPUP_"
BEGIN
MENUITEM "&Screenshots", ID_WEB_COMPARE_SCREENSHOTS
MENUITEM "&Full Size Screenshots", ID_WEB_COMPARE_FULLSIZE_SCREENSHOTS
MENUITEM "&HTMLs", ID_WEB_COMPARE_HTMLS
MENUITEM "&Texts", ID_WEB_COMPARE_TEXTS
MENUITEM "&Resource Trees", ID_WEB_COMPARE_RESOURCETREES
MENUITEM "&Screenshots", ID_WEB_COMPARE_SCREENSHOTS
MENUITEM "&Full Size Screenshots", ID_WEB_COMPARE_FULLSIZE_SCREENSHOTS
MENUITEM "&HTMLs", ID_WEB_COMPARE_HTMLS
MENUITEM "&Texts", ID_WEB_COMPARE_TEXTS
MENUITEM "&Resource Trees", ID_WEB_COMPARE_RESOURCETREES
END
END

IDR_POPUP_WEBPAGE_SYNC_EVENTS MENU
BEGIN
POPUP "_POPUP_"
BEGIN
MENUITEM "&Enabled", ID_WEB_SYNC_ENABLED
MENUITEM "&Enabled", ID_WEB_SYNC_ENABLED
MENUITEM SEPARATOR
MENUITEM "&Scroll", ID_WEB_SYNC_SCROLL
MENUITEM "&Click", ID_WEB_SYNC_CLICK
MENUITEM "&Input", ID_WEB_SYNC_INPUT
MENUITEM "&GoBack/Forward", ID_WEB_SYNC_GOBACKFORWARD
MENUITEM "&Scroll", ID_WEB_SYNC_SCROLL
MENUITEM "&Click", ID_WEB_SYNC_CLICK
MENUITEM "&Input", ID_WEB_SYNC_INPUT
MENUITEM "&GoBack/Forward", ID_WEB_SYNC_GOBACKFORWARD
END
END


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE
BEGIN
IDS_COMPARE "Compare"
IDS_ZOOM "Zoom:"
IDS_SYNC_EVENTS "&Event Sync"
IDS_SHOWDIFFERENCES "View &Differences"
IDS_WEB_COMPARE_SCREENSHOTS "&Screenshots"
IDS_WEB_COMPARE_FULLSIZE_SCREENSHOTS "&Full Size Screenshots"
IDS_WEB_COMPARE_HTMLS "&HTMLs"
IDS_WEB_COMPARE_TEXTS "&Texts"
IDS_WEB_COMPARE_RESOURCETREES "&Resource Trees"
IDS_WEB_SYNC_ENABLED "&Enabled"
IDS_WEB_SYNC_SCROLL "&Scroll"
IDS_WEB_SYNC_CLICK "&Click"
IDS_WEB_SYNC_INPUT "&Input"
IDS_WEB_SYNC_GOBACKFORWARD "&GoBack/Forward"
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down

0 comments on commit f170e0b

Please sign in to comment.