diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-08-06 15:17:41 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:55 +0200 |
commit | 6b47b09f66e0e2a46b9111d6bd5d0a9fe8817582 (patch) | |
tree | cdb18e1fb0e55e1c2e07d6409d0bc0c73a006002 /basctl | |
parent | GSOC work, Extended types correction (diff) | |
download | core-6b47b09f66e0e2a46b9111d6bd5d0a9fe8817582.tar.gz core-6b47b09f66e0e2a46b9111d6bd5d0a9fe8817582.zip |
GSOC work, small fixes for listbox appearance
Listbox top does not cover the actual line.
Listbox width and height problems are fixed.
Change-Id: Ia814f14c3ae326eecd497df2a233eee0b6c30adb
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 1 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 47 |
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 adcfd0be8d26..4f127d9d0668 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(); } } } @@ -774,6 +774,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(); @@ -2626,15 +2627,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 @@ -2642,9 +2639,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(); } } } @@ -2676,12 +2671,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("") ) @@ -2698,7 +2691,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; @@ -2707,6 +2699,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 ), @@ -2755,18 +2754,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()); |