From 728bc0518bd9ddd4564393b293a24e0a66a50ff5 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/baside2.hxx | 7 +++-- basctl/source/basicide/baside2b.cxx | 54 ++++++++++++++++++------------------- basic/source/comp/codegen.cxx | 12 ++++----- basic/source/inc/codegen.hxx | 3 +-- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index c0d93aa2db16..51a130cdac18 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -116,9 +116,7 @@ private: GetComponentInterface(sal_Bool bCreate = true); std::vector< CodeCompleteData > aCodeCompleteCache; CodeCompleteWindow* pCodeCompleteWnd; - //CodeCompleteListBox* aListBox; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number - std::vector< OUString > Split( const OUString& sStr, const sal_Unicode& aChar ); protected: virtual void Paint( const Rectangle& ); @@ -482,7 +480,6 @@ private: CodeCompleteListBox* pListBox; void InitListBox(); // initialize the ListBox - //DECL_LINK(ImplDoubleClickHdl, void*); public: CodeCompleteWindow( EditorWindow* pPar ); @@ -493,6 +490,7 @@ public: void SetTextSelection( const TextSelection& aSel ); const TextSelection& GetTextSelection() const; void ResizeListBox(); + void SelectFirstEntry(); //selects first entry in ListBox protected: virtual void KeyInput( const KeyEvent& rKeyEvt ); @@ -506,7 +504,8 @@ private: public: CodeCompleteListBox(CodeCompleteWindow* pPar); virtual ~CodeCompleteListBox(); - //DECL_LINK(ImplSelectHdl, void*); + void InsertSelectedEntry(); //insert the selected entry + DECL_LINK(ImplDoubleClickHdl, void*); virtual long PreNotify( NotifyEvent& rNEvt ); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 847dd41b1958..79b42f7dea28 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 ); } } @@ -490,25 +489,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; @@ -534,7 +514,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 ); @@ -595,7 +575,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) } pCodeCompleteWnd->ResizeListBox(); pCodeCompleteWnd->Show(); - pCodeCompleteWnd->GrabFocus(); + //pCodeCompleteWnd->GrabFocus(); + pCodeCompleteWnd->SelectFirstEntry(); } } } @@ -2398,6 +2379,12 @@ CodeCompleteListBox::~CodeCompleteListBox() } IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) +{ + InsertSelectedEntry(); + return 0; +} + +void CodeCompleteListBox::InsertSelectedEntry() { if( GetEntry( GetSelectEntryPos() ) != OUString("") ) { @@ -2407,7 +2394,6 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) pCodeCompleteWindow->LoseFocus(); pCodeCompleteWindow->Hide(); } - return 0; } long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) @@ -2419,12 +2405,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 ) @@ -2432,7 +2421,7 @@ CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) pParent(pPar) { InitListBox(); - SetSizePixel( Size(150,150) ); + SetSizePixel( Size(150,150) ); //default, later it changes } void CodeCompleteWindow::InitListBox() @@ -2500,6 +2489,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: */ diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index abbbce94b8f2..207fd9159bfb 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -46,7 +46,7 @@ sal_uInt32 SbiCodeGen::GetPC() void SbiCodeGen::Statement() { - if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + if( pParser->IsCodeCompleting() ) return; bStmnt = true; @@ -63,7 +63,7 @@ void SbiCodeGen::Statement() void SbiCodeGen::GenStmnt() { - if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + if( pParser->IsCodeCompleting() ) return; if( bStmnt ) @@ -78,7 +78,7 @@ void SbiCodeGen::GenStmnt() sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode ) { - if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + if( pParser->IsCodeCompleting() ) return 0; #ifdef DBG_UTIL @@ -92,7 +92,7 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode ) sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd ) { - if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + if( pParser->IsCodeCompleting() ) return 0; #ifdef DBG_UTIL @@ -108,7 +108,7 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd ) sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd1, sal_uInt32 nOpnd2 ) { - if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + if( pParser->IsCodeCompleting() ) return 0; #ifdef DBG_UTIL @@ -127,7 +127,7 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd1, sal_uInt32 nOp void SbiCodeGen::Save() { - if( aMiscOptions.IsExperimentalMode() && pParser->IsCodeCompleting() ) + if( pParser->IsCodeCompleting() ) return; SbiImage* p = new SbiImage; diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index 3cdd27c21710..f2537193e1ab 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -24,7 +24,6 @@ class SbiParser; class SbModule; #include "opcodes.hxx" #include "buffer.hxx" -#include class SbiCodeGen { SbiParser* pParser; // for error messages, line, column etc. @@ -33,7 +32,7 @@ class SbiCodeGen { short nLine, nCol; // for stmnt command short nForLevel; // #29955 bool bStmnt; // true: statement-opcode is pending - SvtMiscOptions aMiscOptions; + public: SbiCodeGen( SbModule&, SbiParser*, short ); SbiParser* GetParser() { return pParser; } -- cgit