From 9a6609e02589c2b38fd71817ed9e5cf47c37ab07 Mon Sep 17 00:00:00 2001 From: Gergo Mocsi Date: Wed, 17 Jul 2013 15:54:13 +0200 Subject: GSOC work Window appearance fix 2 + code fixes Added a function to select the first entry in the ListBox by default. Selected entry can be inserted with the ENTER key. Fixed some code in basic code generation class (SbiCodeGen). Change-Id: Ia6eb43ee5661a0a3ae0b738b619f19972f019eac --- basctl/source/basicide/baside2b.cxx | 54 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'basctl/source/basicide/baside2b.cxx') diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index c570be643582..1f134d17a635 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -275,7 +275,6 @@ EditorWindow::~EditorWindow() pEditEngine->RemoveView(pEditView.get()); } - //delete aListBox; delete pCodeCompleteWnd; } @@ -438,8 +437,8 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt ) pEditView->MouseButtonUp( rEvt ); if (SfxBindings* pBindings = GetBindingsPtr()) { - pBindings->Invalidate( SID_COPY ); - pBindings->Invalidate( SID_CUT ); + /*pBindings->Invalidate( SID_COPY ); + pBindings->Invalidate( SID_CUT );*/ pBindings->Invalidate( SID_BASICIDE_STAT_POS ); } } @@ -484,25 +483,6 @@ bool EditorWindow::ImpCanModify() return bCanModify; } -std::vector< OUString > EditorWindow::Split( const OUString& sStr, const sal_Unicode& aChar ) -{ - std::vector< OUString > aRet; - OUString sTmp; - for( sal_Int32 i = 0; i < sStr.getLength(); ++i ) - { - if( sStr[i] != aChar) - sTmp += OUString(sStr[i]); - else - { - aRet.push_back(sTmp); - sTmp = OUString(""); - } - } - if(sTmp != OUString("")) - aRet.push_back(sTmp); - return aRet; -} - void EditorWindow::KeyInput( const KeyEvent& rKEvt ) { SvtMiscOptions aMiscOptions; @@ -528,7 +508,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified OUString aStr = aLine.copy( std::max(aLine.lastIndexOf(" "), aLine.lastIndexOf("\t"))+1 ); // variable name OUString sActSub = GetActualSubName( nLine ); - std::vector< OUString > aVect; //= Split( aStr, '.' ); + std::vector< OUString > aVect; HighlightPortions aPortions; aHighlighter.getHighlightPortions( nLine, aLine, aPortions ); @@ -589,7 +569,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) } pCodeCompleteWnd->ResizeListBox(); pCodeCompleteWnd->Show(); - pCodeCompleteWnd->GrabFocus(); + //pCodeCompleteWnd->GrabFocus(); + pCodeCompleteWnd->SelectFirstEntry(); } } } @@ -2392,6 +2373,12 @@ CodeCompleteListBox::~CodeCompleteListBox() } IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) +{ + InsertSelectedEntry(); + return 0; +} + +void CodeCompleteListBox::InsertSelectedEntry() { if( GetEntry( GetSelectEntryPos() ) != OUString("") ) { @@ -2401,7 +2388,6 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) pCodeCompleteWindow->LoseFocus(); pCodeCompleteWindow->Hide(); } - return 0; } long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) @@ -2413,12 +2399,15 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) { case KEY_ESCAPE: pCodeCompleteWindow->pParent->GetEditView()->EnableCursor( true ); + pCodeCompleteWindow->LoseFocus(); pCodeCompleteWindow->Hide(); return 0; - default: - return ListBox::PreNotify( rNEvt ); + case KEY_RETURN: + InsertSelectedEntry(); + return 0; } } + return ListBox::PreNotify( rNEvt ); } CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) @@ -2426,7 +2415,7 @@ CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) pParent(pPar) { InitListBox(); - SetSizePixel( Size(150,150) ); + SetSizePixel( Size(150,150) ); //default, later it changes } void CodeCompleteWindow::InitListBox() @@ -2494,6 +2483,15 @@ void CodeCompleteWindow::ResizeListBox() } } +void CodeCompleteWindow::SelectFirstEntry() +{ + if( pListBox->GetEntryCount() > 0 ) + { + pListBox->SelectEntryPos( 0 ); + pListBox->GrabFocus(); + } +} + } // namespace basctl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3