Просмотр исходного кода

added view as image to description window

Scott Brogden 3 лет назад
Родитель
Сommit
db44039af5
4 измененных файлов с 52 добавлено и 7 удалено
  1. 1 0
      CP_Main.rc
  2. 2 1
      Resource.h
  3. 47 6
      ToolTipEx.cpp
  4. 2 0
      ToolTipEx.h

+ 1 - 0
CP_Main.rc

@@ -358,6 +358,7 @@ BEGIN
         MENUITEM "View as Text",                ID_FIRST_VIEWTEXT
         MENUITEM "View as RTF",                 ID_FIRST_VIEWRTF
         MENUITEM "View as HTML",                ID_FIRST_VIEWHTML
+        MENUITEM "View as Image",               ID_FIRST_VIEWASIMAGE
     END
 END
 

+ 2 - 1
Resource.h

@@ -806,6 +806,7 @@
 #define ID_FIRST_VIEWTEXT               32972
 #define ID_FIRST_VIEWRTF                32973
 #define ID_FIRST_VIEWHTML               32974
+#define ID_FIRST_VIEWASIMAGE            32975
 
 // Next default values for new objects
 // 
@@ -813,7 +814,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        389
-#define _APS_NEXT_COMMAND_VALUE         32975
+#define _APS_NEXT_COMMAND_VALUE         32976
 #define _APS_NEXT_CONTROL_VALUE         2173
 #define _APS_NEXT_SYMED_VALUE           104
 #endif

+ 47 - 6
ToolTipEx.cpp

@@ -73,6 +73,7 @@ BEGIN_MESSAGE_MAP(CToolTipEx, CWnd)
 	ON_COMMAND(ID_FIRST_VIEWTEXT, &CToolTipEx::OnFirstViewtext)
 	ON_COMMAND(ID_FIRST_VIEWRTF, &CToolTipEx::OnFirstViewrtf)
 	ON_COMMAND(ID_FIRST_VIEWHTML, &CToolTipEx::OnFirstViewhtml)
+	ON_COMMAND(ID_FIRST_VIEWASIMAGE, &CToolTipEx::OnFirstViewImage)
 	ON_UPDATE_COMMAND_UI(ID_FIRST_VIEWTEXT, &CToolTipEx::OnUpdateFirstViewtext)
 	ON_UPDATE_COMMAND_UI(ID_FIRST_VIEWRTF, &CToolTipEx::OnUpdateFirstViewrtf)
 	ON_UPDATE_COMMAND_UI(ID_FIRST_VIEWHTML, &CToolTipEx::OnUpdateFirstViewhtml)
@@ -155,6 +156,7 @@ BOOL CToolTipEx::Show(CPoint point)
 	m_showingText = false;
 	m_showingRTF = false;
 	m_showingHTML = false;
+	m_showingImage = false;
 
 	CRect rect;
 
@@ -187,10 +189,10 @@ BOOL CToolTipEx::Show(CPoint point)
 		}
 		
 		
-		long lNewWidth = (long)rect.Width() + (long)(rect.Width() *1.5);
+		long lNewWidth = (long)rect.Width() + (long)(rect.Width() *1.25);
 		rect.right = rect.left + lNewWidth;
 
-		long lNewHeight = (long)rect.Height() + (long)(rect.Height() *1.5);
+		long lNewHeight = (long)rect.Height() + (long)(rect.Height() *1.25);
 		rect.bottom = rect.top + lNewHeight;
 
 		ClientToScreen(rect);
@@ -272,7 +274,7 @@ BOOL CToolTipEx::Show(CPoint point)
 
 		m_imageViewer.ShowWindow(SW_SHOW);
 
-		m_showingText = true;
+		m_showingImage = true;
 	}
 	else if (m_html.GetLength() > 0 && m_csRTF.GetLength() <= 0)
 	{
@@ -300,7 +302,14 @@ BOOL CToolTipEx::Show(CPoint point)
 		m_RichEdit.ShowWindow(SW_SHOW);
 
 		//OutputDebugString(_T("Showing rich text\r\n"));
-		m_showingRTF = true;
+		if (m_csRTF.GetLength() > 0)
+		{
+			m_showingRTF = true;
+		}
+		else
+		{
+			m_showingText = true;
+		}
 	}
 
 	ShowWindow(SW_SHOWNA);
@@ -960,7 +969,7 @@ void CToolTipEx::DoSearch()
 	{
 		//if needing to scroll back to the left make sure the full text is visible
 		//setSel scrolls to the end of the selection
-		int start = ft.chrgText.cpMin - 5;
+		int start = ft.chrgText.cpMin;
 		if (start < 0)
 		{
 			start = 0;
@@ -985,7 +994,7 @@ void CToolTipEx::DoSearch()
 		{
 			//if needing to scroll back to the left make sure the full text is visible
 			//setSel scrolls to the end of the selection
-			int start = ft.chrgText.cpMin - 5;
+			int start = ft.chrgText.cpMin;
 			if (start < 0)
 			{
 				start = 0;
@@ -1213,6 +1222,15 @@ void CToolTipEx::OnOptions()
 			cmSubMenu->EnableMenuItem(ID_FIRST_VIEWHTML, MF_DISABLED);
 		}
 
+		if (m_showingImage)
+		{
+			cmSubMenu->CheckMenuItem(ID_FIRST_VIEWASIMAGE, MF_CHECKED);
+		}
+		if (m_imageViewer.m_pGdiplusBitmap == NULL)
+		{
+			cmSubMenu->EnableMenuItem(ID_FIRST_VIEWASIMAGE, MF_DISABLED);
+		}
+
 		UpdateMenuShortCut(cmSubMenu, ID_FIRST_WRAPTEXT, ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP);
 		UpdateMenuShortCut(cmSubMenu, ID_FIRST_ALWAYSONTOP, ActionEnums::TOGGLESHOWPERSISTANT);
 
@@ -1551,6 +1569,7 @@ void CToolTipEx::OnFirstViewtext()
 	m_showingText = true;
 	m_showingRTF = false;
 	m_showingHTML = false;
+	m_showingImage = false;
 }
 
 void CToolTipEx::OnFirstViewrtf()
@@ -1574,6 +1593,7 @@ void CToolTipEx::OnFirstViewrtf()
 	m_showingText = false;
 	m_showingRTF = true;
 	m_showingHTML = false;
+	m_showingImage = false;
 }
 
 
@@ -1590,6 +1610,27 @@ void CToolTipEx::OnFirstViewhtml()
 	m_showingText = false;
 	m_showingRTF = false;
 	m_showingHTML = true;
+	m_showingImage = false;
+}
+
+void CToolTipEx::OnFirstViewImage()
+{
+	m_RichEdit.ShowWindow(SW_HIDE);
+	if (::IsWindow(m_browser.m_hWnd))
+	{
+		m_browser.ShowWindow(SW_HIDE);
+	}
+
+	if (m_imageViewer.m_pGdiplusBitmap)
+	{
+		m_imageViewer.UpdateBitmapSize(true);
+		m_imageViewer.ShowWindow(SW_SHOW);
+	}
+
+	m_showingText = false;
+	m_showingRTF = false;
+	m_showingHTML = false;
+	m_showingImage = true;
 }
 
 

+ 2 - 0
ToolTipEx.h

@@ -105,6 +105,7 @@ protected:
 	bool m_showingText;
 	bool m_showingRTF;
 	bool m_showingHTML;
+	bool m_showingImage;
 
 protected:
 	CString GetFieldFromString(CString ref, int nIndex, TCHAR ch);	
@@ -151,6 +152,7 @@ public:
 	afx_msg void OnFirstViewtext();
 	afx_msg void OnFirstViewrtf();
 	afx_msg void OnFirstViewhtml();
+	afx_msg void OnFirstViewImage();
 	afx_msg void OnUpdateFirstViewtext(CCmdUI* pCmdUI);
 	afx_msg void OnUpdateFirstViewrtf(CCmdUI* pCmdUI);
 	afx_msg void OnUpdateFirstViewhtml(CCmdUI* pCmdUI);