[Libreoffice-commits] core.git: Branch 'feature/gsoc-basic-ide-completion-and-other-bits' - basctl/source

Gergo Mocsi gmocsi91 at gmail.com
Fri Aug 23 02:46:55 PDT 2013


 basctl/source/basicide/baside2b.cxx |   47 +++++++++++++++---------------------
 1 file changed, 20 insertions(+), 27 deletions(-)

New commits:
commit 1ce55a2f53a8bffc76903e3966dd2920fd9a76a4
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Fri Aug 23 11:38:03 2013 +0200

    GSOC work, fix the clipped listbox
    
    Listbox clipping works correcly on the right side and on the bottom.
    The function calculations are done from the initial position: if the actual X/Y coordinate + width/height exceeds the visible area, listbox is poitioned up/a bit left.
    
    Change-Id: I17ff28cd23423819b55d7079c6d35484b567899c

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 8bcc199..1bf8be1 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2641,21 +2641,19 @@ void CodeCompleteListBox::InsertSelectedEntry()
     if( !aFuncBuffer.toString().isEmpty() )
     {
         // if the user typed in something: remove, and insert
-        //TextPaM aEnd( GetParentEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetEnd()) );
-        //GetParentEditView()->SetSelection(TextSelection(pCodeCompleteWindow->GetTextSelection().GetStart(), aEnd ) );
         GetParentEditView()->SetSelection( pCodeCompleteWindow->pParent->GetLastHighlightPortionTextSelection() );
         GetParentEditView()->DeleteSelected();
 
         if( !((OUString) GetEntry( GetSelectEntryPos() )).isEmpty() )
         {//if the user selected something
-            GetParentEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
+            GetParentEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_False );
         }
     }
     else
     {
         if( !((OUString) GetEntry( GetSelectEntryPos() )).isEmpty() )
         {//if the user selected something
-            GetParentEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
+            GetParentEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_False );
         }
     }
     HideAndRestoreFocus();
@@ -2695,8 +2693,7 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
                 TextSelection aTextSelection( GetParentEditView()->GetSelection() );
                 if( aTextSelection.GetEnd().GetPara() != pCodeCompleteWindow->GetTextSelection().GetEnd().GetPara()-1 )
                 {
-                    pCodeCompleteWindow->Hide();
-                    pCodeCompleteWindow->pParent->GrabFocus();
+                    HideAndRestoreFocus();
                 }
                 break;
             }
@@ -2705,8 +2702,7 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
                 TextSelection aTextSelection( GetParentEditView()->GetSelection() );
                 if( aTextSelection.GetStart().GetIndex()-1 < pCodeCompleteWindow->GetTextSelection().GetStart().GetIndex() )
                 {//leave the cursor where it is
-                    pCodeCompleteWindow->Hide();
-                    pCodeCompleteWindow->pParent->GrabFocus();
+                    HideAndRestoreFocus();
                 }
                 break;
             }
@@ -2841,33 +2837,30 @@ void CodeCompleteWindow::ResizeListBox()
         // get column/line count
         const sal_uInt16& nColumns = aLongestEntry.getLength();
         const sal_uInt16& nLines = std::min( (sal_uInt16) 6, pListBox->GetEntryCount() );
-        const Font& aFont = pListBox->GetFont();// listbox's font: height is needed
 
-        const Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() );
-        Size aSize = pListBox->GetOptimalSize();// this sets the correct width
-        aSize.setHeight( pListBox->CalcSize( nColumns, nLines ).getHeight() );// correct height
+        Size aSize = pListBox->CalcSize( nColumns, nLines );
+        //set the size
+        SetSizePixel( aSize );
+        //1 px smaller, to see the border
+        aSize.setWidth( aSize.getWidth() - 1 );
+        aSize.setHeight( aSize.getHeight() - 1 );
+        pListBox->SetSizePixel( aSize );
 
+        //calculate position
+        const Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() );//the visible area
         const Point& aBottomPoint = aVisArea.BottomRight();
-        const Point& aTopPoint = aVisArea.TopRight();
 
-        const long& nYDiff = aBottomPoint.Y() - aTopPoint.Y() - aPos.Y();
-        if( (nYDiff + aFont.GetHeight()) < aSize.Height() )
-        {//bottom part is clipped, fix the visibility by placing it over the line (not under)
-            const Font& aParFont = pParent->GetEditEngine()->GetFont();//parent's font (in the IDE): needed for height
-            aPos.Y() -= aSize.Height() + aParFont.GetHeight() + nCursorPad;
+        if( aVisArea.TopRight().getY() + aPos.getY() + aSize.getHeight() > aBottomPoint.getY() )
+        {//clipped at the bottom: move it up
+            const long& nParentFontHeight = pParent->GetEditEngine()->GetFont().GetHeight();//parent's font (in the IDE): needed for height
+            aPos.Y() -= aSize.getHeight() + nParentFontHeight + nCursorPad;
         }
 
-        const long& nXDiff = aBottomPoint.X() - aPos.X();
-        if( nXDiff < aSize.Width() )
+        if( aVisArea.BottomLeft().getX() + aPos.getX() + aSize.getWidth() > aBottomPoint.getX() )
         {//clipped at the right side, move it a bit left
-            aPos.X() -= aSize.Width();
+            aPos.X() -= aSize.getWidth();
         }
-
-        pListBox->SetSizePixel( aSize );
-        aSize.setWidth( aSize.getWidth() + 1 );
-        aSize.setHeight( aSize.getHeight() + 1 );
-        // set the size and the position of the window
-        SetSizePixel( aSize );
+        //set the position
         SetPosPixel( aPos );
     }
 }


More information about the Libreoffice-commits mailing list