/************************************************************************* * * $RCSfile: brkdlg.cxx,v $ * * $Revision: 1.1.1.1 $ * * last change: $Author: mh $ $Date: 2000-09-29 11:02:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://www.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ #pragma hdrstop #include // #define ITEMID_SEARCH SID_SEARCH_ITEM #define _SVX_NOIDERESIDS #include #include #include #ifndef _SFXDISPATCH_HXX //autogen #include #endif #include /************************** Soll-Aufbau des Strings: # **************************/ BOOL lcl_ParseText( String aText, USHORT& rLineNr ) { // Blanks ? aText.EraseLeadingChars( ' ' ); if ( !aText.Len() ) return FALSE; if ( aText.GetChar( 0 ) != '#' ) return FALSE; aText.EraseLeadingChars( ' ' ); if ( !aText.Len() ) return FALSE; rLineNr = (USHORT) aText.ToInt32(); return TRUE; } BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList ) : ModalDialog( pParent, IDEResId( RID_BASICIDE_BREAKPOINTDLG ) ), aComboBox( this, IDEResId( RID_CB_BRKPOINTS ) ), aOKButton( this, IDEResId( RID_PB_OK ) ), aCancelButton( this, IDEResId( RID_PB_CANCEL ) ), aNewButton( this, IDEResId( RID_PB_NEW ) ), aDelButton( this, IDEResId( RID_PB_DEL ) ), // aShowButton( this, IDEResId( RID_PB_SHOW ) ), aCheckBox( this, IDEResId( RID_CHKB_ACTIVE ) ), aBrkText( this, IDEResId( RID_FT_BRKPOINTS ) ), aPassText( this, IDEResId( RID_FT_PASS ) ), aNumericField( this, IDEResId( RID_FLD_PASS ) ), rBrkPointList( rBrkPntList ) { FreeResource(); aComboBox.SetUpdateMode( FALSE ); BreakPoint* pBrk = rBrkPointList.First(); BreakPoint* pFirstBrk = pBrk; while ( pBrk ) { String aEntryStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) ); aEntryStr += String::CreateFromInt32( pBrk->nLine ); aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND ); pBrk = rBrkPointList.Next(); } aComboBox.SetUpdateMode( TRUE ); aOKButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) ); aNewButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) ); aDelButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) ); // aShowButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) ); aCheckBox.SetClickHdl( LINK( this, BreakPointDialog, CheckBoxHdl ) ); aComboBox.SetSelectHdl( LINK( this, BreakPointDialog, ComboBoxHighlightHdl ) ); aComboBox.SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) ); aComboBox.GrabFocus(); aNumericField.SetMin( 0 ); aNumericField.SetMax( 0x7FFFFFFF ); aNumericField.SetSpinSize( 1 ); aNumericField.SetStrictFormat( TRUE ); aNumericField.SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) ); aComboBox.SetText( aComboBox.GetEntry( 0 ) ); UpdateFields( pFirstBrk ); CheckButtons(); } void BreakPointDialog::SetCurrentBreakPoint( const BreakPoint& rBrk ) { String aStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) ); aStr += String::CreateFromInt32( rBrk.nLine ); aComboBox.SetText( aStr ); } void BreakPointDialog::CheckButtons() { BOOL bEnableAdd = FALSE; String aEditText( aComboBox.GetText() ); if ( aEditText.Len() ) bEnableAdd = TRUE; // es besteht die Moeglichkeit. for ( USHORT i = 0; i < aComboBox.GetEntryCount(); i++ ) { String aStr( aComboBox.GetEntry( i ) ); if ( aStr.CompareIgnoreCaseToAscii( aEditText ) == COMPARE_EQUAL ) { bEnableAdd = FALSE; break; } } if ( bEnableAdd ) { aNewButton.Enable(); aOKButton.Disable(); aDelButton.Disable(); } else { aNewButton.Disable(); aOKButton.Enable(); aDelButton.Enable(); } } IMPL_LINK_INLINE_START( BreakPointDialog, CheckBoxHdl, CheckBox *, pChkBx ) { BreakPoint* pBrk = GetSelectedBreakPoint(); if ( pBrk ) pBrk->bEnabled = pChkBx->IsChecked(); return 0; } IMPL_LINK_INLINE_END( BreakPointDialog, CheckBoxHdl, CheckBox *, pChkBx ) IMPL_LINK( BreakPointDialog, ComboBoxHighlightHdl, ComboBox *, pBox ) { aNewButton.Disable(); aOKButton.Enable(); aDelButton.Enable(); USHORT nEntry = pBox->GetEntryPos( pBox->GetText() ); BreakPoint* pBrk = rBrkPointList.GetObject( nEntry ); DBG_ASSERT( pBrk, "Kein passender Breakpoint zur Liste ?" ); UpdateFields( pBrk ); return 0; } IMPL_LINK( BreakPointDialog, EditModifyHdl, Edit *, pEdit ) { if ( pEdit == &aComboBox ) CheckButtons(); else if ( pEdit == &aNumericField ) { BreakPoint* pBrk = GetSelectedBreakPoint(); if ( pBrk ) pBrk->nStopAfter = pEdit->GetText().ToInt32(); } return 0; } IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton ) { if ( pButton == &aOKButton ) EndDialog( 1 ); else if ( pButton == &aNewButton ) { // Checkbox beruecksichtigen! String aText( aComboBox.GetText() ); USHORT nLine; BOOL bValid = lcl_ParseText( aText, nLine ); if ( bValid ) { BreakPoint* pBrk = new BreakPoint( nLine ); pBrk->bEnabled = aCheckBox.IsChecked(); pBrk->nStopAfter = aNumericField.GetValue(); rBrkPointList.InsertSorted( pBrk ); String aEntryStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) ); aEntryStr += String::CreateFromInt32( pBrk->nLine ); aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND ); SfxViewFrame* pCurFrame = SfxViewFrame::Current(); DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; if( pDispatcher ) { pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED ); } } else { aComboBox.SetText( aText ); aComboBox.GrabFocus(); Sound::Beep(); } CheckButtons(); } else if ( pButton == &aDelButton ) { USHORT nEntry = aComboBox.GetEntryPos( aComboBox.GetText() ); BreakPoint* pBrk = rBrkPointList.GetObject( nEntry ); if ( pBrk ) { delete rBrkPointList.Remove( pBrk ); aComboBox.RemoveEntry( nEntry ); if ( nEntry && !( nEntry < aComboBox.GetEntryCount() ) ) nEntry--; aComboBox.SetText( aComboBox.GetEntry( nEntry ) ); SfxViewFrame* pCurFrame = SfxViewFrame::Current(); DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; if( pDispatcher ) { pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED ); } } CheckButtons(); } // else if ( pButton == &aShowButton ) // { // ; // } return 0; } void BreakPointDialog::UpdateFields( BreakPoint* pBrk ) { if ( pBrk ) { aCheckBox.Check( pBrk->bEnabled ); aNumericField.SetValue( pBrk->nStopAfter ); } } BreakPoint* BreakPointDialog::GetSelectedBreakPoint() { USHORT nEntry = aComboBox.GetEntryPos( aComboBox.GetText() ); BreakPoint* pBrk = rBrkPointList.GetObject( nEntry ); return pBrk; }