Browse Source

return TRUE for handled keys - CQPasteWnd::PreTranslateMessage
only parse nMaxLines - CMainTable::GetDisplayText( int nMaxLines )
MoveToXY replaced with equivalent code - CPopup::AdjustPos


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@46 595ec19a-5cb4-439b-94a8-42fb3063c22c

ingenuus 22 years ago
parent
commit
6b0aa607ed
7 changed files with 27 additions and 12 deletions
  1. 4 2
      MainTable.cpp
  2. 1 1
      MainTable.h
  3. 9 1
      Misc.cpp
  4. 1 0
      Misc.h
  5. 3 1
      ProcessPaste.cpp
  6. 0 1
      QListCtrl.cpp
  7. 9 6
      QPasteWnd.cpp

+ 4 - 2
MainTable.cpp

@@ -88,7 +88,7 @@ void CMainTable::Requery()
 /////////////////////////////////////////////////////////////////////////////
 // CMainTable member functions
 
-CString CMainTable::GetDisplayText()
+CString CMainTable::GetDisplayText( int nMaxLines )
 {
 CString text = m_strText;
 	// assign tabs to 2 spaces (rather than the default 8)
@@ -102,8 +102,10 @@ CString text = m_strText;
 CString token;
 CStringArray tokens;
 CTokenizer tokenizer(text,"\r\n");
-	while( tokenizer.Next( token ) )
+	for( int nLines=0; nLines < nMaxLines && tokenizer.Next(token); nLines++ )
+	{
 		tokens.Add( token );
+	}
 
 	// remove each line's indent
 char chFirst;

+ 1 - 1
MainTable.h

@@ -41,7 +41,7 @@ public:
 	//}}AFX_VIRTUAL
 
 public:
-	CString GetDisplayText();
+	CString GetDisplayText( int nMaxLines );
 	void AddNew(); // assigns the new autoincr ID to m_lID
 	void OnQuery();
 

+ 9 - 1
Misc.cpp

@@ -397,6 +397,7 @@ CString GetFilePath(CString csFileName)
 	CGetSetOptions
 \*------------------------------------------------------------------*/
 
+long CGetSetOptions::m_nLinesPerRow;
 BOOL CGetSetOptions::m_bUseCtrlNumAccel;
 BOOL CGetSetOptions::m_bAllowDuplicates;
 BOOL CGetSetOptions::m_bUpdateTimeOnPaste;
@@ -410,6 +411,7 @@ CGetSetOptions g_Opt;
 
 CGetSetOptions::CGetSetOptions()
 {
+	m_nLinesPerRow = GetLinesPerRow();
 	m_bUseCtrlNumAccel = GetUseCtrlNumForFirstTenHotKeys();
 	m_bAllowDuplicates = GetAllowDuplicates();
 	m_bUpdateTimeOnPaste = GetUpdateTimeOnPaste();
@@ -553,6 +555,7 @@ long CGetSetOptions::GetTransparencyPercent()
 
 BOOL CGetSetOptions::SetLinesPerRow(long lLines)
 {
+	m_nLinesPerRow = lLines;
 	return SetProfileLong("LinesPerRow", lLines);
 }
 
@@ -1620,13 +1623,18 @@ CRect rect(0,0,0,0);
 	if( ::IsWindow(m_hWndPosRelativeTo) )
 		::GetWindowRect(m_hWndPosRelativeTo, &rel);
 
-	rect.left = rel.left;
+	// move the rect to the relative origin
+	rect.bottom = rect.Height() + rel.top;
 	rect.top = rel.top;
+	rect.right = rect.Width() + rel.left;
+	rect.left = rel.left;
 
+	// adjust the y position
 	rect.OffsetRect( 0, pos.y - (m_bCenterY? rect.Height()/2: (m_bTop? 0: rect.Height())) );
 	if( rect.bottom > m_ScreenMaxY )
 		rect.OffsetRect( 0, m_ScreenMaxY - rect.bottom );
 
+	// adjust the x position
 	rect.OffsetRect( pos.x - (m_bCenterX? rect.Width()/2: (m_bLeft? 0: rect.Width())), 0 );
 	if( rect.right > m_ScreenMaxX )
 		rect.OffsetRect( m_ScreenMaxX - rect.right, 0 );

+ 1 - 0
Misc.h

@@ -126,6 +126,7 @@ public:
 	static BOOL SetTransparencyPercent(long lPercent);
 	static long GetTransparencyPercent();
 
+	static long m_nLinesPerRow;
 	static BOOL SetLinesPerRow(long lLines);
 	static long GetLinesPerRow();
 

+ 3 - 1
ProcessPaste.cpp

@@ -166,6 +166,7 @@ CString sql;
 // deletes the given item
 BOOL DeleteID( long lID, bool bDisband )
 {
+BOOL bIsGroup;
 long lDataID = 0;
 int i = 0;
 COleVariant varKey( (long) 0 ); // VT_I4
@@ -185,12 +186,13 @@ COleVariant varKey( (long) 0 ); // VT_I4
 		}
 
 		lDataID = recs.m_lDataID;
+		bIsGroup = recs.m_bIsGroup;
 
 		// must delete this record first so that DeleteDataID can properly
 		//  determine if any other Clip is using the same Data.
 		recs.Delete(); 
 
-		if( recs.m_bIsGroup )
+		if( bIsGroup )
 			DeleteGroupID( lID, bDisband );
 		else
 			DeleteDataID( lDataID );

+ 0 - 1
QListCtrl.cpp

@@ -710,7 +710,6 @@ DWORD dID;
 			{
 				ShowFullDescription();
 				return TRUE;
-				break;
 			}
 		} // end switch(vk)
 

+ 9 - 6
QPasteWnd.cpp

@@ -1068,15 +1068,18 @@ BOOL CQPasteWnd::PreTranslateMessage(MSG* pMsg)
 				NewGroup( true );
 			else
 				NewGroup( false );
-			break;
+			return TRUE;
 
 		case VK_BACK:
 			theApp.EnterGroupID( theApp.m_GroupParentID );
-			break;
+			return TRUE;
 
 		case VK_SPACE:
 			if(GetKeyState(VK_CONTROL) & 0x8000)
+			{
 				theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
+				return TRUE;
+			}
 			break;
 
 		case VK_ESCAPE:
@@ -1131,15 +1134,15 @@ BOOL CQPasteWnd::PreTranslateMessage(MSG* pMsg)
 			{
 				OnCancelFilter();
 			}
-			break;
+			return TRUE;
 
 		case VK_HOME:
 			theApp.EnterGroupID( 0 );  // History
-			break;
+			return TRUE;
 
 		case VK_END:
 			theApp.EnterGroupID( -1 ); // All Groups
-			break; 
+			return TRUE;
 
 		} // end switch( pMsg->wParam )
 
@@ -1224,7 +1227,7 @@ void CQPasteWnd::GetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
 					cs += "!";
 
 				// pipe is the "end of symbols" marker
-				cs += "|" + m_Recset.GetDisplayText();
+				cs += "|" + m_Recset.GetDisplayText( g_Opt.m_nLinesPerRow );
 
 				lstrcpyn(pItem->pszText, cs, pItem->cchTextMax);
 				pItem->pszText[pItem->cchTextMax-1] = '\0';