summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.hxx1
-rw-r--r--basctl/source/basicide/baside2b.cxx47
2 files changed, 26 insertions, 22 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 78932cfe2e92..20d421715648 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -488,6 +488,7 @@ private:
CodeCompleteWindow* pCodeCompleteWindow; // parent window
void SetVisibleEntries(); // sets the visible entries based on aFuncBuffer variable
+ void HideAndRestoreFocus();
public:
CodeCompleteListBox( CodeCompleteWindow* pPar );
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e49c97b7404d..95bac259d21b 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -447,7 +447,7 @@ void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
{
if( pEditView->GetSelection() != pCodeCompleteWnd->GetTextSelection() )
{//selection changed, code complete window should be hidden
- pCodeCompleteWnd->ClearAndHide();
+ pCodeCompleteWnd->GetListBox()->HideAndRestoreFocus();
}
}
}
@@ -768,6 +768,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
long nViewYOffset = pEditView->GetStartDocPos().Y();
Point aPoint = aRect.BottomRight();
aPoint.Y() = aPoint.Y() - nViewYOffset;
+ aPoint.Y() += 2;
aSel.GetStart().GetIndex() += 1;
aSel.GetEnd().GetIndex() += 1;
pCodeCompleteWnd->ClearListBox();
@@ -2620,15 +2621,11 @@ void CodeCompleteListBox::InsertSelectedEntry()
if( !((OUString) GetEntry( GetSelectEntryPos() )).isEmpty() )
{//if the user selected something
pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
- pCodeCompleteWindow->Hide();
- pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- pCodeCompleteWindow->pParent->GrabFocus();
+ HideAndRestoreFocus();
}
else
{
- pCodeCompleteWindow->Hide();
- pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- pCodeCompleteWindow->pParent->GrabFocus();
+ HideAndRestoreFocus();
}
}
else
@@ -2636,9 +2633,7 @@ void CodeCompleteListBox::InsertSelectedEntry()
if( !((OUString) GetEntry( GetSelectEntryPos() )).isEmpty() )
{//if the user selected something
pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
- pCodeCompleteWindow->Hide();
- pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- pCodeCompleteWindow->pParent->GrabFocus();
+ HideAndRestoreFocus();
}
}
}
@@ -2670,12 +2665,10 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
switch( aChar )
{
case KEY_ESCAPE: // hide, do nothing
- pCodeCompleteWindow->ClearAndHide();
+ HideAndRestoreFocus();
break;
case KEY_TAB: case KEY_SPACE:
- pCodeCompleteWindow->Hide();
- pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- pCodeCompleteWindow->pParent->GrabFocus();
+ HideAndRestoreFocus();
break;
case KEY_BACKSPACE: case KEY_DELETE:
if( aFuncBuffer.toString() != OUString("") )
@@ -2692,7 +2685,6 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
InsertSelectedEntry();
break;
case KEY_UP: case KEY_DOWN:
- //std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl;
NotifyEvent nEvt( EVENT_KEYINPUT, NULL, &rKeyEvt );
PreNotify(nEvt);
break;
@@ -2701,6 +2693,13 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
ListBox::KeyInput(rKeyEvt);
}
+void CodeCompleteListBox::HideAndRestoreFocus()
+{
+ pCodeCompleteWindow->Hide();
+ pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
+ pCodeCompleteWindow->pParent->GrabFocus();
+}
+
CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
: Window( pPar ),
pParent( pPar ),
@@ -2749,18 +2748,22 @@ void CodeCompleteWindow::ResizeListBox()
if( pListBox->GetEntryCount() > 0 )
{// if there is at least one element inside
OUString aLongestEntry = pListBox->GetEntry( 0 );//grab the longest one: max search
- for( sal_uInt16 i=0; i< pListBox->GetEntryCount(); ++i )
+ if( pListBox->GetEntryCount() > 0 )
{
- if( ((OUString) pListBox->GetEntry( i )).getLength() > aLongestEntry.getLength() )
- aLongestEntry = pListBox->GetEntry( i );
+ for( sal_uInt16 i=1; i< pListBox->GetEntryCount(); ++i )
+ {
+ if( ((OUString) pListBox->GetEntry( i )).getLength() > aLongestEntry.getLength() )
+ aLongestEntry = pListBox->GetEntry( i );
+ }
}
-
- Size aSize = pListBox->CalcSize( aLongestEntry.getLength(), std::min( (sal_uInt16) 4, pListBox->GetEntryCount()) );
+ long nWidth = GetTextWidth(aLongestEntry);
+ sal_uInt16 nColumns = aLongestEntry.getLength();
+ sal_uInt16 nLines = std::min( (sal_uInt16) 6, pListBox->GetEntryCount() );
const Font& aFont = pListBox->GetUnzoomedControlPointFont();
Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() );
- aSize.setHeight( aFont.GetSize().getHeight() * 16 );
- aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(), pListBox->GetEntryCount()).getWidth() );
+ Size aSize = pListBox->CalcSize( nColumns+1, nLines );
+ aSize.setWidth(nWidth+5);
Point aBottomPoint = aVisArea.BottomRight();
Point aTopPoint = aVisArea.TopRight();
long nYDiff = std::abs((aBottomPoint.Y() - aTopPoint.Y()) - GetPosPixel().Y());