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(-)
New commits: commit 9a6609e02589c2b38fd71817ed9e5cf47c37ab07 Author: Gergo Mocsi <gmocs...@gmail.com> Date: Wed Jul 17 15:54:13 2013 +0200 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 diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index c0d93aa..51a130c 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 c570be6..1f134d1 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(); } } } @@ -2393,6 +2374,12 @@ CodeCompleteListBox::~CodeCompleteListBox() IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) { + InsertSelectedEntry(); + return 0; +} + +void CodeCompleteListBox::InsertSelectedEntry() +{ if( GetEntry( GetSelectEntryPos() ) != OUString("") ) { pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->GetTextSelection() ); @@ -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: */ diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index abbbce9..207fd91 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 3cdd27c..f253719 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 <svtools/miscopt.hxx> 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits