Browse Source

Added option to description window to save position and size and scale bitmaps

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@691 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 12 years ago
parent
commit
cf9d73d561
12 changed files with 405 additions and 82 deletions
  1. 10 0
      CP_Main.rc
  2. 51 0
      Clip.cpp
  3. 1 0
      Clip.h
  4. 57 0
      Options.cpp
  5. 15 0
      Options.h
  6. 21 10
      QListCtrl.cpp
  7. 1 1
      QListCtrl.h
  8. 60 4
      QPasteWnd.cpp
  9. 1 0
      QPasteWnd.h
  10. 11 1
      Resource.h
  11. 171 66
      ToolTipEx.cpp
  12. 6 0
      ToolTipEx.h

+ 10 - 0
CP_Main.rc

@@ -323,6 +323,16 @@ BEGIN
     END
 END
 
+IDR_DESC_OPTIONS_MENU MENU
+BEGIN
+    POPUP "First"
+    BEGIN
+        MENUITEM "Remember window position",    ID_FIRST_REMEMBERWINDOWPOSITION
+        MENUITEM "Size window to content",      ID_FIRST_SIZEWINDOWTOCONTENT
+        MENUITEM "Scale images to fit window",  ID_FIRST_SCALEIMAGESTOFITWINDOW
+    END
+END
+
 
 /////////////////////////////////////////////////////////////////////////////
 //

+ 51 - 0
Clip.cpp

@@ -753,6 +753,57 @@ bool CClip::AddToDataTable()
 	return true;
 }
 
+void CClip::MoveUp()
+{
+	if(m_stickyClipOrder == 0)
+	{
+		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, clipOrder FROM Main Where clipOrder > %f ORDER BY clipOrder ASC LIMIT 1"), m_clipOrder);
+		if (q.eof() == false)
+		{
+			int idAbove = q.getIntField(_T("lID"));
+			double orderAbove = q.getFloatField(_T("clipOrder"));
+
+			CppSQLite3Query q2 = theApp.m_db.execQueryEx(_T("SELECT lID, clipOrder FROM Main Where clipOrder > %f ORDER BY clipOrder ASC LIMIT 1"), orderAbove);
+			if (q2.eof() == false)
+			{ 
+				int idTwoAbove = q2.getIntField(_T("lID"));
+				double orderTwoAbove = q2.getFloatField(_T("clipOrder"));
+			
+				m_clipOrder = orderAbove + (orderTwoAbove - orderAbove) / 2.0;
+			}
+			else
+			{
+				m_clipOrder = orderAbove + 1;
+			}
+		}
+	}
+	else  
+
+
+
+	{
+		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, stickyClipOrder FROM Main Where stickyClipOrder > %f ORDER BY clipOrder ASC LIMIT 1"), m_stickyClipOrder);
+		if (q.eof() == false)
+		{
+			int idAbove = q.getIntField(_T("lID"));
+			double orderAbove = q.getFloatField(_T("stickyClipOrder"));
+
+			CppSQLite3Query q2 = theApp.m_db.execQueryEx(_T("SELECT lID, stickyClipOrder FROM Main Where stickyClipOrder > %f ORDER BY clipOrder ASC LIMIT 1"), orderAbove);
+			if (q2.eof() == false)
+			{
+				int idTwoAbove = q2.getIntField(_T("lID"));
+				double orderTwoAbove = q2.getFloatField(_T("stickyClipOrder"));
+
+				m_stickyClipOrder = orderAbove + (orderTwoAbove - orderAbove) / 2.0;
+			}
+			else
+			{
+				m_stickyClipOrder = orderAbove + 1;
+			}
+		}
+	}
+}
+
 void CClip::MakeStickyTop(int parentId)
 {
 	if (parentId < 0)

+ 1 - 0
Clip.h

@@ -133,6 +133,7 @@ public:
 	void RemoveStickySetting(int parentId);
 	BOOL LoadMainTable(int id);
 	DWORD GenerateCRC();
+	void MoveUp();
 
 	// Allocates a Global containing the requested Clip's Format Data
 	static HGLOBAL LoadFormat(int id, UINT cfType);

+ 57 - 0
Options.cpp

@@ -715,6 +715,7 @@ BOOL CGetSetOptions::SetQuickPasteSize(CSize size)
 
 	return bRet;
 }
+
 void CGetSetOptions::GetQuickPasteSize(CSize &size)
 {
 	size.cx = GetProfileLong("QuickPasteCX", 300);
@@ -2075,4 +2076,60 @@ void CGetSetOptions::SetPasteAsAdmin(BOOL val)
 BOOL CGetSetOptions::GetPasteAsAdmin()
 {
 	return GetProfileLong(_T("PasteAsAdmin"), 1);
+}
+
+void CGetSetOptions::SetRememberDescPos(BOOL val)
+{
+	SetProfileLong(_T("RememberDescPos"), val);
+}
+BOOL CGetSetOptions::GetRememberDescPos()
+{
+	return GetProfileLong(_T("RememberDescPos"), FALSE);
+}
+
+void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
+{
+	SetProfileLong(_T("SizeDescWindowToContent"), val);
+}
+BOOL CGetSetOptions::GetSizeDescWindowToContent()
+{
+	return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
+}
+
+void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
+{
+	SetProfileLong(_T("ScaleImagesToDescWindow"), val);
+}
+BOOL CGetSetOptions::GetScaleImagesToDescWindow()
+{
+	return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
+}
+
+void CGetSetOptions::SetDescWndPoint(CPoint point)
+{
+	SetProfileLong("DescWndX", point.x);
+	SetProfileLong("DescWndY", point.y);
+}
+
+void CGetSetOptions::GetDescWndPoint(CPoint &point)
+{
+	point.x = GetProfileLong("DescWndX", 100);
+	point.y = GetProfileLong("DescWndY", 100);
+}
+
+void CGetSetOptions::GetDescWndSize(CSize &size)
+{
+	size.cx = GetProfileLong("DescWndCX", 300);
+	size.cy = GetProfileLong("DescWndCY", 300);
+	if(size.cx <= 0 && size.cy <= 0)
+	{
+		size.cx = 300;
+		size.cy = 300;
+	}
+}
+
+void CGetSetOptions::SetDescWndSize(CSize size)
+{
+	SetProfileLong("DescWndCX", size.cx);
+	SetProfileLong("DescWndCY", size.cy);
 }

+ 15 - 0
Options.h

@@ -439,6 +439,21 @@ public:
 
 	static void		SetPasteAsAdmin(BOOL val);
 	static BOOL		GetPasteAsAdmin();
+
+	static void		SetRememberDescPos(BOOL val);
+	static BOOL		GetRememberDescPos();
+
+	static void		SetSizeDescWindowToContent(BOOL val);
+	static BOOL		GetSizeDescWindowToContent();
+
+	static void		SetScaleImagesToDescWindow(BOOL val);
+	static BOOL		GetScaleImagesToDescWindow();
+
+	static void		SetDescWndPoint(CPoint point);
+	static void		GetDescWndPoint(CPoint &point);
+
+	static void		SetDescWndSize(CSize size);
+	static void		GetDescWndSize(CSize &size);
 };
 
 // global for easy access and for initialization of fast access variables

+ 21 - 10
QListCtrl.cpp

@@ -902,7 +902,7 @@ void CQListCtrl::LoadCopyOrCutToClipboard()
 	g_Opt.m_bUpdateTimeOnPaste = bItWas;
 }
 
-void CQListCtrl::ShowFullDescription(bool bFromAuto)
+void CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
 {
 	int nItem = GetCaret();
 	CRect rc, crWindow;
@@ -912,18 +912,25 @@ void CQListCtrl::ShowFullDescription(bool bFromAuto)
 
 	CPoint pt;
 	
-	if(bFromAuto == false)
+	if(CGetSetOptions::GetRememberDescPos())
+	{
+		CGetSetOptions::GetDescWndPoint(pt);
+	}
+	else if(bFromAuto == false)
 	{
 		pt = CPoint(rc.left, rc.bottom);
 	}
 	else
+	{
 		pt = CPoint((crWindow.left + (crWindow.right - crWindow.left)/2), rc.bottom);
+	}
 
 	CString csDescription;
 	GetToolTipText(nItem, csDescription);
 		
-	//if (bFromAuto == false ||
-	//	::IsWindow(m_toolTipHwnd) == FALSE)
+	if (m_pToolTip == NULL ||
+		fromNextPrev == false ||
+		::IsWindow(m_toolTipHwnd) == FALSE)
 	{
 		m_pToolTip->DestroyWindow();
 
@@ -932,12 +939,16 @@ void CQListCtrl::ShowFullDescription(bool bFromAuto)
 		m_toolTipHwnd = m_pToolTip->GetSafeHwnd();
 		m_pToolTip->SetNotifyWnd(GetParent());
 	}
-	//else
-	//{
-	//	CRect r;
-	//	m_pToolTip->GetWindowRect(r);
-	//	pt = r.TopLeft();
-	//}
+	else
+	{
+		CRect r;
+		m_pToolTip->GetWindowRect(r);
+		pt = r.TopLeft();
+
+		m_pToolTip->SetBitmap(NULL);
+		m_pToolTip->SetRTFText("");
+		m_pToolTip->SetToolTipText(_T(""));
+	}
 	
 	if(m_pToolTip)
 	{

+ 1 - 1
QListCtrl.h

@@ -125,7 +125,7 @@ public:
 
 	void DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db);
 
-	void ShowFullDescription(bool bFromAuto = false);
+	void ShowFullDescription(bool bFromAuto = false, bool fromNextPrev = false);
 	BOOL SetItemCountEx(int iCount, DWORD dwFlags = 0);
 
 	void HidePopup()	{ if(m_pToolTip) m_pToolTip->Hide();	}

+ 60 - 4
QPasteWnd.cpp

@@ -2015,6 +2015,8 @@ void CQPasteWnd::OnMakeTopStickyClip()
 
 void CQPasteWnd::OnMakeLastStickyClip()
 {
+//	OnMoveClipUp();
+//	return;
 	ARRAY IDs;
 	m_lstHeader.GetSelectionItemData(IDs);
 
@@ -2072,6 +2074,60 @@ void CQPasteWnd::OnMakeLastStickyClip()
 	}
 }
 
+void CQPasteWnd::OnMoveClipUp()
+{
+	ARRAY IDs;
+	m_lstHeader.GetSelectionItemData(IDs);
+
+	if (IDs.GetCount() > 0)
+	{
+		bool sort = false;
+		for (int i = IDs.GetCount() - 1; i >= 0; i--)
+		{
+			int id = IDs[i];
+			CClip clip;
+			if (clip.LoadMainTable(id))
+			{
+				clip.MoveUp();
+				clip.ModifyMainTable();
+
+				std::vector<CMainTable>::iterator iter = m_listItems.begin();
+				while (iter != m_listItems.end())
+				{
+					if (iter->m_lID == id)
+					{
+						iter->m_clipOrder = clip.m_clipOrder;
+						iter->m_stickyClipOrder = clip.m_stickyClipOrder;
+						
+						sort = true;
+						break;
+					}
+					iter++;
+				}
+			}
+		}
+
+		//theApp.m_FocusID = id;
+
+		if (sort)
+		{
+			if (theApp.m_GroupID > 0)
+			{
+				std::sort(m_listItems.begin(), m_listItems.end(), CMainTable::GroupSortDesc);
+			}
+			else
+			{
+				std::sort(m_listItems.begin(), m_listItems.end(), CMainTable::SortDesc);
+			}
+
+			//SelectFocusID();
+
+			m_lstHeader.RefreshVisibleRows();
+			m_lstHeader.RedrawWindow();
+		}
+	}
+}
+
 void CQPasteWnd::OnRemoveStickySetting()
 {
 	ARRAY IDs;
@@ -2660,7 +2716,7 @@ bool CQPasteWnd::DoActionNextDescription()
 		m_lstHeader.SetListPos(caret);
 	}
 	
-	m_lstHeader.ShowFullDescription();
+	m_lstHeader.ShowFullDescription(false, true);
 
 	return true;
 }
@@ -2702,7 +2758,7 @@ bool CQPasteWnd::DoActionPrevDescription()
 		m_lstHeader.SetListPos(caret);
 	}
 
-	m_lstHeader.ShowFullDescription();
+	m_lstHeader.ShowFullDescription(false, true);
 
 	return true;
 }
@@ -3411,14 +3467,14 @@ void CQPasteWnd::OnGetToolTipText(NMHDR *pNMHDR, LRESULT *pResult)
         CString cs;
 
         int id = m_lstHeader.GetItemData(pInfo->lItem);
-        CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, mText, lDate, lShortCut, lDontAutoDelete, QuickPasteText, lastPasteDate, globalShortCut FROM Main WHERE lID = %d"), id);
+        CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, mText, lDate, lShortCut, clipOrder, stickyClipOrder, lDontAutoDelete, QuickPasteText, lastPasteDate, globalShortCut FROM Main WHERE lID = %d"), id);
         if(q.eof() == false)
         {
             cs = q.getStringField(1);
             cs += "\n\n";
 
             #ifdef _DEBUG
-                cs += StrF(_T("(Index = %d) (DB ID = %d)\n"), pInfo->lItem, q.getIntField(_T("lID")));
+                cs += StrF(_T("(Index = %d) (DB ID = %d) (Seq = %f) (Sticky Seq = %f)\n"), pInfo->lItem, q.getIntField(_T("lID")), q.getFloatField(_T("clipOrder")), q.getFloatField(_T("stickyClipOrder")));
             #endif 
 
             COleDateTime time((time_t)q.getIntField(_T("lDate")));

+ 1 - 0
QPasteWnd.h

@@ -369,5 +369,6 @@ protected:
 	afx_msg void OnMakeLastStickyClip();
 	afx_msg void OnRemoveStickySetting();
 	afx_msg void OnElevateAppToPasteIntoElevatedApp();
+	afx_msg void OnMoveClipUp();
 	
 };

+ 11 - 1
Resource.h

@@ -87,6 +87,7 @@
 #define IDB_MAXIMIZE_12_12              220
 #define IDB_PNG7                        221
 #define IDB_MAXIMIZE_16_16              221
+#define IDR_DESC_OPTIONS_MENU           238
 #define IDB_YELLOW_STAR_32_32           222
 #define IDB_YELLOW_STAR_24_24           223
 #define IDB_YELLOW_STAR_20_20           224
@@ -104,6 +105,7 @@
 #define IDB_STICKY_20_20                236
 #define IDB_PNG8                        237
 #define IDB_STICKY_16_16                237
+
 #define IDC_PATH                        1000
 #define IDC_GET_PATH                    1001
 #define IDC_SELECT_SOUND                1002
@@ -435,14 +437,22 @@
 #define ID_STICKYCLIPS_MAKELASTSTICKYCLIP 32879
 #define ID_STICKYCLIPS_REMOVESTICKYSETTING 32880
 #define ID_QUICKOPTIONS_ELEVATEPREVILEGESTOPASTEINTOELEVATEDAPPS 32881
+#define ID_FIRST_REMEMBERWINDOWPOSITION 32882
+#define ID_FIRST_SIZEWINDOWTOCONTENT    32883
+#define ID_FIRST_SCALEIMAGESTOFITWINDOW 32884
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        238
+<<<<<<< .mine
+#define _APS_NEXT_RESOURCE_VALUE        223
+#define _APS_NEXT_COMMAND_VALUE         32885
+=======
+#define _APS_NEXT_RESOURCE_VALUE        239
 #define _APS_NEXT_COMMAND_VALUE         32882
+>>>>>>> .r690
 #define _APS_NEXT_CONTROL_VALUE         2101
 #define _APS_NEXT_SYMED_VALUE           101
 #endif

+ 171 - 66
ToolTipEx.cpp

@@ -2,6 +2,7 @@
 #include "cp_main.h"
 #include "ToolTipEx.h"
 #include "BitmapHelper.h"
+#include "Options.h"
 
 #ifdef _DEBUG
     #define new DEBUG_NEW
@@ -47,6 +48,10 @@ ON_WM_NCMOUSEMOVE()
 ON_WM_NCLBUTTONUP()
 ON_WM_ERASEBKGND()
 
+ON_COMMAND(ID_FIRST_REMEMBERWINDOWPOSITION, &CToolTipEx::OnRememberwindowposition)
+ON_COMMAND(ID_FIRST_SIZEWINDOWTOCONTENT, &CToolTipEx::OnSizewindowtocontent)
+ON_COMMAND(ID_FIRST_SCALEIMAGESTOFITWINDOW, &CToolTipEx::OnScaleimagestofitwindow)
+ON_COMMAND(2, OnOptions)
 END_MESSAGE_MAP() 
 
 
@@ -67,9 +72,11 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
         return FALSE;
     }
 
+	
+
 	m_DittoWindow.DoCreate(this);
 	m_DittoWindow.SetCaptionColors(g_Opt.m_Theme.CaptionLeft(), g_Opt.m_Theme.CaptionRight());
-	m_DittoWindow.SetCaptionOn(this, CGetSetOptions::GetCaptionPos(), true);
+	m_DittoWindow.SetCaptionOn(this, CAPTION_LEFT, true);
 	m_DittoWindow.m_bDrawMinimize = false;
 	m_DittoWindow.m_bDrawMinimize = false;
 	m_DittoWindow.m_bDrawChevron = false;
@@ -84,6 +91,11 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
 
     SetLogFont(GetSystemToolTipFont(), FALSE);
 
+	m_optionsButton.Create(NULL, WS_CHILD | BS_OWNERDRAW | WS_TABSTOP, CRect(0, 0, 0, 0), this, 2);
+	m_optionsButton.LoadStdImageDPI(IDB_COG_16_16, IDB_COG_20_20, IDB_COG_24_24, IDB_COG_32_32, _T("PNG"));
+	m_optionsButton.SetToolTipText(theApp.m_Language.GetString(_T("DescriptionOptionsTooltip"), _T("Description Options")));
+	m_optionsButton.ShowWindow(SW_SHOW);
+
     return TRUE;
 }
 
@@ -99,77 +111,109 @@ BOOL CToolTipEx::Show(CPoint point)
         m_RichEdit.ShowWindow(SW_SHOW);
     }
 
-    CRect rect = GetBoundsRect();
+	CRect rect;
 
-    //account for the scroll bars
-    rect.right += 20;
-    rect.bottom += 20;
-
-	if (m_pBitmap)
+	if(CGetSetOptions::GetSizeDescWindowToContent() == FALSE)
 	{
-		int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
-		int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
-
-		rect.right = rect.left + nWidth;
-		rect.bottom = rect.top + nHeight;
+		rect.left = point.x;
+		rect.top = point.y;
+		CSize size;
+		CGetSetOptions::GetDescWndSize(size);
+		rect.right = rect.left + size.cx;
+		rect.bottom = rect.top + size.cy;
+
+		EnsureWindowVisible(&rect);
 	}
-    else if(m_csRTF != "")
-    {
-		//if showing rtf then increase the size because
-		//rtf will probably draw bigger
-        long lNewWidth = (long)rect.Width() + (long)(rect.Width() *.3);
-        rect.right = rect.left + lNewWidth;
+	else
+	{
+		rect = GetBoundsRect();
 
-        long lNewHeight = rect.Height() + (rect.Height() *1);
-        rect.bottom = rect.top + lNewHeight;
-    }
+		//account for the scroll bars
+		rect.right += 20;
+		rect.bottom += 20;
+
+		if (m_pBitmap)
+		{
+			int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
+			int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
 
-	rect.right += CAPTION_BORDER * 2;
-	rect.bottom += CAPTION_BORDER * 2;
+			rect.right = rect.left + nWidth;
+			rect.bottom = rect.top + nHeight;
+		}
+		else if(m_csRTF != "")
+		{
+			//if showing rtf then increase the size because
+			//rtf will probably draw bigger
+			long lNewWidth = (long)rect.Width() + (long)(rect.Width() *.3);
+			rect.right = rect.left + lNewWidth;
 
-    CRect rcScreen;
+			long lNewHeight = rect.Height() + (rect.Height() *1);
+			rect.bottom = rect.top + lNewHeight;
+		}
 
-    ClientToScreen(rect);
+		rect.right += CAPTION_BORDER * 2;
+		rect.bottom += CAPTION_BORDER * 2;
 
-    CRect cr(point, point);
+		CRect rcScreen;
 
-    int nMonitor = GetMonitorFromRect(&cr);
-    GetMonitorRect(nMonitor, &rcScreen);
+		ClientToScreen(rect);
 
-    //ensure that we don't go outside the screen
-    if(point.x < 0)
-    {
-        point.x = 5;
-		m_reducedWindowSize = true;
-    }
-    if(point.y < 0)
-    {
-        point.y = 5;
-		m_reducedWindowSize = true;
-    }
+		CRect cr(point, point);
 
-    rcScreen.DeflateRect(0, 0, 5, 5);
+		int nMonitor = GetMonitorFromRect(&cr);
+		GetMonitorRect(nMonitor, &rcScreen);
 
-    long lWidth = rect.Width();
-    long lHeight = rect.Height();
+		//ensure that we don't go outside the screen
+		if(point.x < 0)
+		{
+			point.x = 5;
+			m_reducedWindowSize = true;
+		}
+		if(point.y < 0)
+		{
+			point.y = 5;
+			m_reducedWindowSize = true;
+		}
 
-    rect.left = point.x;
-    rect.top = point.y;
-    rect.right = rect.left + lWidth;
-    rect.bottom = rect.top + lHeight;
+		rcScreen.DeflateRect(0, 0, 5, 5);
 
-    if(rect.right > rcScreen.right)
-    {
-        rect.right = rcScreen.right;
-		m_reducedWindowSize = true;
-    }
-    if(rect.bottom > rcScreen.bottom)
-    {
-        rect.bottom = rcScreen.bottom;
-		m_reducedWindowSize = true;
-    }
+		long lWidth = rect.Width();
+		long lHeight = rect.Height();
+
+		rect.left = point.x;
+		rect.top = point.y;
+		rect.right = rect.left + lWidth;
+		rect.bottom = rect.top + lHeight;
+
+		if(rect.right > rcScreen.right)
+		{
+			int diff = rect.right - rcScreen.right;
+
+			int newLeft = rect.left - diff;
+			if(newLeft > 0)
+			{
+				rect.left = newLeft;
+			}
+
+			rect.right = rcScreen.right;
+			m_reducedWindowSize = true;
+		}
+		if(rect.bottom > rcScreen.bottom)
+		{
+			int diff = rect.bottom - rcScreen.bottom;
+
+			int newTop = rect.top - diff;
+			if(newTop > 0)
+			{
+				rect.top = newTop;
+			}
 
-    SetWindowPos(&CWnd::wndTopMost, point.x, point.y, rect.Width(), rect.Height
+			rect.bottom = rcScreen.bottom;
+			m_reducedWindowSize = true;
+		}
+	}
+
+    SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height
                  (), SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE |
                  SWP_NOZORDER);
 
@@ -185,6 +229,11 @@ BOOL CToolTipEx::Hide()
     m_csRTF = "";
     m_csText = "";
 
+	CRect rect;
+	this->GetWindowRect(&rect);
+	CGetSetOptions::SetDescWndSize(rect.Size());
+	CGetSetOptions::SetDescWndPoint(rect.TopLeft());
+
     return TRUE;
 }
 
@@ -201,16 +250,17 @@ void CToolTipEx::OnPaint()
     //    dc.SetBkMode(TRANSPARENT);
     //    rect.DeflateRect(m_rectMargin);
 
-    if(m_pBitmap)
-    {
-		CBrush  Brush, *pOldBrush;
-		Brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
+    
+	CBrush  Brush, *pOldBrush;
+	Brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
 
-		pOldBrush = dc.SelectObject(&Brush);
-		CFont *pOldFont = dc.SelectObject(&m_Font);
+	pOldBrush = dc.SelectObject(&Brush);
+	CFont *pOldFont = dc.SelectObject(&m_Font);
 
-		dc.FillRect(&rect, &Brush);
+	dc.FillRect(&rect, &Brush);
 
+	if(m_pBitmap)
+	{
         CDC MemDc;
         MemDc.CreateCompatibleDC(&dc);
 
@@ -219,7 +269,7 @@ void CToolTipEx::OnPaint()
         int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
         int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
 
-		if(m_reducedWindowSize)
+		if(CGetSetOptions::GetScaleImagesToDescWindow())
 		{
 			dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nWidth, SRCCOPY);
 		}
@@ -499,9 +549,11 @@ void CToolTipEx::OnSize(UINT nType, int cx, int cy)
 
     CRect cr;
     GetClientRect(cr);
-    //	cr.DeflateRect(0, 0, 15, 0);
+    cr.DeflateRect(0, 0, 0, theApp.m_metrics.ScaleY(21));
     m_RichEdit.MoveWindow(cr);
 
+	m_optionsButton.MoveWindow(cr.left, cr.bottom + theApp.m_metrics.ScaleY(2), theApp.m_metrics.ScaleX(17), theApp.m_metrics.ScaleY(17));
+
 	this->Invalidate();
 }
 
@@ -611,4 +663,57 @@ void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point)
 	m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
 
 	CWnd::OnNcMouseMove(nHitTest, point);
+}
+
+void CToolTipEx::OnOptions()
+{
+	POINT pp;
+	CMenu cmPopUp;
+	CMenu *cmSubMenu = NULL;
+
+	GetCursorPos(&pp);
+	if(cmPopUp.LoadMenu(IDR_DESC_OPTIONS_MENU) != 0)
+	{
+		cmSubMenu = cmPopUp.GetSubMenu(0);
+		if(!cmSubMenu)
+		{
+			return ;
+		}
+
+		GetCursorPos(&pp);
+
+		if(CGetSetOptions::GetRememberDescPos())
+			cmSubMenu->CheckMenuItem(ID_FIRST_REMEMBERWINDOWPOSITION, MF_CHECKED);
+
+		if(CGetSetOptions::GetSizeDescWindowToContent())
+			cmSubMenu->CheckMenuItem(ID_FIRST_SIZEWINDOWTOCONTENT, MF_CHECKED);
+
+		if(CGetSetOptions::GetScaleImagesToDescWindow())
+			cmSubMenu->CheckMenuItem(ID_FIRST_SCALEIMAGESTOFITWINDOW, MF_CHECKED);
+		
+		//theApp.m_Language.UpdateRightClickMenu(cmSubMenu);
+		
+		cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
+	}
+}
+
+void CToolTipEx::OnRememberwindowposition()
+{
+	CGetSetOptions::SetRememberDescPos(!CGetSetOptions::GetRememberDescPos());
+}
+
+void CToolTipEx::OnSizewindowtocontent()
+{
+	CGetSetOptions::SetSizeDescWindowToContent(!CGetSetOptions::GetSizeDescWindowToContent());
+
+	CRect rect;
+	this->GetWindowRect(&rect);
+
+	Show(rect.TopLeft());
+}
+
+void CToolTipEx::OnScaleimagestofitwindow()
+{
+	CGetSetOptions::SetScaleImagesToDescWindow(!CGetSetOptions::GetScaleImagesToDescWindow());
+	Invalidate();
 }

+ 6 - 0
ToolTipEx.h

@@ -9,6 +9,7 @@
 #include "RichEditCtrlEx.h"
 #include "WndEx.h"
 #include "DittoWindow.h"
+#include "GdipButton.h"
 /////////////////////////////////////////////////////////////////////////////
 // CToolTipEx window
 
@@ -59,6 +60,7 @@ protected:
 	CRichEditCtrlEx m_RichEdit;
 	CWnd *m_pNotifyWnd;
 	bool m_reducedWindowSize;
+	CGdipButton m_optionsButton;
 
 	CDittoWindow m_DittoWindow;
 
@@ -80,10 +82,14 @@ protected:
 	afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); 
 	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); 
 	afx_msg void OnNcPaint();
+	afx_msg void OnOptions();
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 public:
 	afx_msg void OnTimer(UINT_PTR nIDEvent);
+	afx_msg void OnRememberwindowposition();
+	afx_msg void OnSizewindowtocontent();
+	afx_msg void OnScaleimagestofitwindow();
 };
 
 /////////////////////////////////////////////////////////////////////////////