From 50e4094a211153f0a49d9c41e6c70e419242b94a Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Thu, 26 Feb 2004 13:51:54 +0000 Subject: Initial revision --- soldep/source/connctr.cxx | 242 +++++++++ soldep/source/depapp.cxx | 226 +++++++++ soldep/source/depper.cxx | 1209 ++++++++++++++++++++++++++++++++++++++++++++ soldep/source/depwin.cxx | 224 ++++++++ soldep/source/graphwin.cxx | 114 +++++ soldep/source/hashobj.cxx | 73 +++ soldep/source/makefile.mk | 159 ++++++ soldep/source/objwin.cxx | 715 ++++++++++++++++++++++++++ soldep/source/soldep.cxx | 566 +++++++++++++++++++++ soldep/source/soldlg.cxx | 254 ++++++++++ soldep/source/soldlg.src | 247 +++++++++ 11 files changed, 4029 insertions(+) create mode 100644 soldep/source/connctr.cxx create mode 100644 soldep/source/depapp.cxx create mode 100644 soldep/source/depper.cxx create mode 100644 soldep/source/depwin.cxx create mode 100644 soldep/source/graphwin.cxx create mode 100644 soldep/source/hashobj.cxx create mode 100644 soldep/source/makefile.mk create mode 100644 soldep/source/objwin.cxx create mode 100644 soldep/source/soldep.cxx create mode 100644 soldep/source/soldlg.cxx create mode 100644 soldep/source/soldlg.src diff --git a/soldep/source/connctr.cxx b/soldep/source/connctr.cxx new file mode 100644 index 000000000000..42f2231f29ce --- /dev/null +++ b/soldep/source/connctr.cxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * $RCSfile: connctr.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:13 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#include "connctr.hxx" +#include "objwin.hxx" +#include "depwin.hxx" + +#include "math.h" + +Connector::Connector( DepWin* pParent, WinBits nWinStyle ) : +mpStartWin( 0L ), +mpEndWin( 0L ), +mnStartId( 0 ), +mnEndId( 0 ), +len( 70 ), +bVisible( FALSE ) +{ + mpParent = pParent; + if ( mpParent ) + mpParent->AddConnector( this ); +} + +Connector::~Connector() +{ + if ( mpStartWin ) + mpStartWin->RemoveConnector( this ); + if ( mpEndWin ) + mpEndWin->RemoveConnector( this ); + if ( mpParent ) + mpParent->RemoveConnector( this ); + mpParent->Invalidate( Rectangle( mStart, mEnd )); + mpParent->Invalidate( Rectangle( mEnd - Point( 3, 3), mEnd + Point( 3, 3))); +} + +void Connector::Initialize( ObjectWin* pStartWin, ObjectWin* pEndWin ) +{ + mpStartWin = pStartWin; + mpEndWin = pEndWin; + mpStartWin->AddConnector( this ); + mpEndWin->AddConnector( this ); + mCenter = GetMiddle(); + mStart = pStartWin->GetFixPoint( mCenter ); + mEnd = pEndWin->GetFixPoint( mCenter ); + mnStartId = pStartWin->GetId(); + mnEndId = pEndWin->GetId(); + + if ( mpParent->IsPaintEnabled()) + { + mpParent->DrawLine( mEnd, mStart ); + mpParent->DrawEllipse( Rectangle( mEnd - Point( 2, 2), mEnd + Point( 2, 2))); + } + UpdateVisibility(); +} + +void Connector::UpdateVisibility() +{ + bVisible = mpStartWin->IsVisible() && mpEndWin->IsVisible(); +} + + +Point Connector::GetMiddle() +{ + Point aStartPoint = mpStartWin->GetPosPixel(); + Size aStartSize = mpStartWin->GetSizePixel(); + int nMoveHorz, nMoveVert; + aStartPoint.Move( aStartSize.Width() / 2, aStartSize.Height() / 2 ); + + Point aEndPoint = mpEndWin->GetPosPixel(); + Size aEndSize = mpEndWin->GetSizePixel(); + + aEndPoint.Move( aEndSize.Width() / 2, aEndSize.Height() / 2 ); + + Point aRetPoint = aEndPoint; + + nMoveHorz = aStartPoint.X() - aEndPoint.X(); + if ( nMoveHorz ) + nMoveHorz /= 2; + nMoveVert = aStartPoint.Y() - aEndPoint.Y(); + if ( nMoveVert ) + nMoveVert /= 2; + aRetPoint.Move( nMoveHorz, nMoveVert ); + return aRetPoint; + +} + +void Connector::Paint( const Rectangle& rRect ) +{ + if ( IsVisible()) { + mpParent->DrawLine( mEnd, mStart ); + mpParent->DrawEllipse( Rectangle( mEnd - Point( 2, 2), mEnd + Point( 2, 2))); + } +} + +void Connector::UpdatePosition( ObjectWin* pWin, BOOL bPaint ) +{ +// more than one call ? +// + Point OldStart, OldEnd; + static nCallCount; +// BOOL bPaint = TRUE; + + if ( nCallCount ) + nCallCount++; + else + { + nCallCount++; + while ( nCallCount ) + { + if ( bPaint ) + { + OldStart = mStart; + OldEnd = mEnd; + } + mCenter = GetMiddle(); + mStart=mpStartWin->GetFixPoint( mCenter, bPaint ); + mEnd=mpEndWin->GetFixPoint( mCenter, bPaint ); + if ( bPaint ) + { + mpParent->Invalidate( Rectangle( OldStart, OldEnd )); + mpParent->Invalidate( Rectangle( OldEnd - Point( 2, 2), OldEnd + Point( 2, 2))); +//who uses this rectangle??? + Paint ( Rectangle( mEnd - Point( 3, 3), mEnd + Point( 3, 3))); + Paint ( Rectangle( mEnd, mStart )); + } + nCallCount--; + } + } +// mpParent->DrawLine( mEnd, mStart ); +// mpParent->DrawEllipse( Rectangle( mEnd - Point( 2, 2), mEnd + Point( 2, 2))); +} + +USHORT Connector::Save( SvFileStream& rOutFile ) +{ + rOutFile << mpStartWin->GetId(); + rOutFile << mpEndWin->GetId(); + + return 0; +} + +USHORT Connector::Load( SvFileStream& rInFile ) +{ + rInFile >> mnStartId; + rInFile >> mnEndId; + + return 0; +} + +ObjectWin* Connector::GetOtherWin( ObjectWin* pWin ) +{ + if ( mpStartWin == pWin ) + return mpEndWin; + else + if ( mpEndWin == pWin ) + return mpStartWin; + + return NULL; +} + +ULONG Connector::GetOtherId( ULONG nId ) +{ + if ( mnStartId == nId ) + return mnEndId; + else + if ( mnEndId == nId ) + return mnStartId; + + return NULL; +} + +ULONG Connector::GetLen() +{ + double dx, dy; + + dx = mStart.X() - mEnd.X(); + dy = mStart.Y() - mEnd.Y(); + + return sqrt( dx * dx + dy * dy ); +} + +BOOL Connector::IsStart( ObjectWin* pWin ) +{ + return pWin == mpStartWin; +} + diff --git a/soldep/source/depapp.cxx b/soldep/source/depapp.cxx new file mode 100644 index 000000000000..b46b096e4723 --- /dev/null +++ b/soldep/source/depapp.cxx @@ -0,0 +1,226 @@ +/************************************************************************* + * + * $RCSfile: depapp.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:13 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "soldep.hxx" +// ----------------------------------------------------------------------- +#include +#include +#include +#include +#include + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + + +class MyApp : public Application +{ + ResMgr* pResMgr; + SolDep* pSolDep; +public: + void Main(); + ResMgr* GetResMgr() const { return pResMgr; } +}; + + +MyApp aMyApp; + +// ----------------------------------------------------------------------- + +class MyWin : public WorkWindow +{ +public: + MyWin( Window* pParent, WinBits nWinStyle ); + + void MouseMove( const MouseEvent& rMEvt ); + void MouseButtonDown( const MouseEvent& rMEvt ); + void MouseButtonUp( const MouseEvent& rMEvt ); + void KeyInput( const KeyEvent& rKEvt ); + void KeyUp( const KeyEvent& rKEvt ); + void Paint( const Rectangle& rRect ); + void Resize(); +}; + +// ----------------------------------------------------------------------- + + +void MyApp::Main() +{ + ByteString aResMgrName( "dep" ); + aResMgrName += ByteString::CreateFromInt64( SOLARUPD ); + Application* pApp; + pApp = GetpApp(); + International iNat; + iNat = GetpApp()->GetAppInternational(); + LanguageType lt; + lt = iNat.GetLanguage(); + pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), + GetpApp()->GetAppInternational().GetLanguage()); + DtSodResId::SetResMgr( pResMgr ); + + MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); + aMainWin.SetText( String::CreateFromAscii( SOLDEPL_NAME )); + aMainWin.Show(); + pSolDep = new SolDep( &aMainWin ); + pSolDep->Init(); + Help aHelp; + SetHelp(&aHelp); + aHelp.EnableContextHelp(); + aHelp.EnableQuickHelp(); + Execute(); + delete pResMgr; + delete pSolDep; +} + +// ----------------------------------------------------------------------- + +MyWin::MyWin( Window* pParent, WinBits nWinStyle ) : + WorkWindow( pParent, nWinStyle ) +{ +} + +// ----------------------------------------------------------------------- + +void MyWin::MouseMove( const MouseEvent& rMEvt ) +{ + WorkWindow::MouseMove( rMEvt ); +} + +// ----------------------------------------------------------------------- + +void MyWin::MouseButtonDown( const MouseEvent& rMEvt ) +{ + WorkWindow::MouseButtonDown( rMEvt ); +} + +// ----------------------------------------------------------------------- + +void MyWin::MouseButtonUp( const MouseEvent& rMEvt ) +{ + WorkWindow::MouseButtonUp( rMEvt ); +} + +// ----------------------------------------------------------------------- + +void MyWin::KeyInput( const KeyEvent& rKEvt ) +{ + WorkWindow::KeyInput( rKEvt ); +} + +// ----------------------------------------------------------------------- + +void MyWin::KeyUp( const KeyEvent& rKEvt ) +{ + WorkWindow::KeyUp( rKEvt ); +} + +// ----------------------------------------------------------------------- + +void MyWin::Paint( const Rectangle& rRect ) +{ + WorkWindow::Paint( rRect ); +} + +// ----------------------------------------------------------------------- + +void MyWin::Resize() +{ + WorkWindow::Resize(); + Window* pWin; + USHORT i, nChildCount = GetChildCount(); + + for ( i = 0; i < nChildCount; i++ ) + { + pWin = GetChild( i ); + pWin->SetPosSizePixel( GetPosPixel(), GetSizePixel() ); +// pWin->Resize(); +// ((GraphWin*) pWin)->EndScroll( 0, 0 ); + } +} + +SAL_IMPLEMENT_MAIN() +{ + Reference< XMultiServiceFactory > xMS; + + // for this to work make sure an .ini file is available, you can just copy soffice.ini + Reference< XComponentContext > xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext(); + xMS = cppu::createRegistryServiceFactory( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True ); + + InitVCL( xMS ); + //GetpApp()->WaitForClientConnect(); // is a no-op in local case + //::Main(); + aMyApp.Main(); + DeInitVCL(); + return 0; +} + diff --git a/soldep/source/depper.cxx b/soldep/source/depper.cxx new file mode 100644 index 000000000000..778f116d665d --- /dev/null +++ b/soldep/source/depper.cxx @@ -0,0 +1,1209 @@ + +/************************************************************************* + * + * $RCSfile: depper.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:13 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include +#include +#include +#include +#include + +#include "depper.hxx" +#include "objwin.hxx" +#include "soldlg.hxx" + +#include "math.h" +#include "time.h" +#include "stdlib.h" + +#include + +#define MIN(a,b) (a)<(b)?(a):(b) +#define MAX(a,b) (a)>(b)?(a):(b) + +ResMgr *DtSodResId::pResMgr = NULL; +DtSodResId::DtSodResId( USHORT nId ) : + ResId( nId, pResMgr ) +{ +} + +Depper::Depper( Window* pBaseWindow ): + maDefPos( 50, 50 ), + maDefSize( 60, 25 ), + mpTravellerList( NULL ), + nViewMask( 1 ), + pMainBar( NULL ), + pSubBar( NULL ), + pMainText( NULL ), + pSubText( NULL ) +{ + mpProcessWin = pBaseWindow; + mpGraphWin = new GraphWin( mpProcessWin ); + mpBaseWin = new DepWin( mpGraphWin->GetBufferWindow(), WB_NOBORDER | WB_SIZEABLE | WB_AUTOSIZE ); + + mpGraphWin->SetBackgroundBrush( Brush( Color( COL_WHITE ))); + mpBaseWin->SetBackgroundBrush( Brush( Color( COL_WHITE ))); + + mpBaseWin->mpDepperDontuseme = this; + + mpGraphWin->SetZOrder( NULL, WINDOW_ZORDER_FIRST ); + mpBaseWin->SetZOrder( NULL, WINDOW_ZORDER_FIRST ); + + mpGraphWin->EnableClipSiblings(); + + mpBaseWin->mpPopup->InsertItem( DEPPOPUP_AUTOARRANGE, String::CreateFromAscii("Autoarrange")) ; +#ifdef HJS_TEST + // not realy working + // mpBaseWin->mpPopup->InsertItem( DEPPOPUP_LOAD, "Load" ); + // mpBaseWin->mpPopup->InsertItem( DEPPOPUP_SAVE, "Save" ); +#endif +#ifdef HJS_TEST + mpBaseWin->mpPopup->InsertItem( DEPPOPUP_TEST, "TEST" ); +#endif + + mpBaseWin->Show(); + mnWinCount = 0; + mnLastId = 0; + nZoomed = 0; + + mpBaseWin->SetPopupHdl( this ); + pObjectList = new ObjWinList(); +} + +Depper::~Depper() +{ + delete pObjectList; + delete mpBaseWin; + delete mpGraphWin; +} + +void Depper::SetViewMask( ULONG nMask ) +{ + nViewMask = nMask; + for ( ULONG i = 0; i < pObjectList->Count(); i ++ ) { + ObjectWin *pWin = pObjectList->GetObject( i ); + if ( pWin->IsVisible()) + pWin->Show(); + else + pWin->Hide(); + } +} + +ULONG Depper::AddObject( ByteString& rBodyText, BOOL bInteract ) +{ + Point aPos; + Size aSize = maDefSize; + + aPos = mpBaseWin->LogicToPixel( aPos ); + aSize = mpBaseWin->LogicToPixel( aSize ); + return AddObject( rBodyText, aPos, aSize ); +} + +ULONG Depper::AddObject( ByteString& rBodyText, Point& rPos, Size& rSize ) +{ + ObjectWin* pWin = new ObjectWin( mpBaseWin, WB_BORDER ); + pWin->mpDepperDontuseme = this; + + Size aNewSize; + aNewSize.Width() = pWin->GetTextWidth( String( rBodyText, RTL_TEXTENCODING_UTF8 )); + aNewSize.Height() = pWin->GetTextHeight(); + if ( aNewSize.Width() > rSize.Width() - 8 ) + { + aNewSize.Width() = aNewSize.Width() + 8; + aNewSize.Height() = rSize.Height(); + } + else + aNewSize = rSize; + pWin->SetPosSizePixel( rPos,aNewSize); + + MapMode aMapMode = mpBaseWin->GetMapMode(); + pWin->SetMapMode( aMapMode ); + + pObjectList->Insert( pWin, LIST_APPEND ); + pWin->SetId( mnLastId ); + mnLastId++; + mnWinCount++; + pWin->SetBodyText( rBodyText ); +// pWin->Show(); + return pWin->GetId(); +} + +ObjectWin* Depper::RemoveObject( USHORT nId, BOOL bDelete ) +{ + ObjectWin* pWin = ObjIdToPtr( nId ); + + if ( pWin ) + { + pObjectList ->Remove( pWin ); + mnWinCount--; + if( bDelete ) + delete pWin; + return pWin; + } + else + return NULL; +} + +void Depper::RemoveAllObjects( ObjWinList* pObjLst ) +{ + ULONG i; + + for ( i = pObjLst->Count(); i > 0; i-- ) + delete pObjLst->GetObject( i - 1 ); + pObjLst->Clear(); +} + +USHORT Depper::AddConnector( ULONG nStartId, ULONG nEndId ) +{ + ObjectWin* pStartWin = ObjIdToPtr( nStartId ); + + if ( !pStartWin ) + return DEP_STARTID_NOT_FOUND; + + ObjectWin* pEndWin = ObjIdToPtr( nEndId ); + + if ( !pEndWin ) + return DEP_STARTID_NOT_FOUND; + + return AddConnector( pStartWin, pEndWin ); +} + +USHORT Depper::RemoveConnector( ULONG nStartId, ULONG nEndId ) +{ +// DBG_ASSERT( FALSE , "noch nicht" ); + ObjectWin* pStartWin = ObjIdToPtr( nStartId ); + + if ( !pStartWin ) + return DEP_STARTID_NOT_FOUND; + + ObjectWin* pEndWin = ObjIdToPtr( nEndId ); + + if ( !pEndWin ) + return DEP_STARTID_NOT_FOUND; + + return RemoveConnector( pStartWin, pEndWin ); +} + +USHORT Depper::AddConnector( ObjectWin* pStartWin, ObjectWin* pEndWin ) +{ + if ( pStartWin->ConnectionExistsInAnyDirection( pEndWin )) + return 0; + + Connector* pCon = new Connector( mpBaseWin, WB_NOBORDER ); + pCon->Initialize( pStartWin, pEndWin ); + + return 0; +} + +USHORT Depper::RemoveConnector( ObjectWin* pStartWin, ObjectWin* pEndWin ) +{ + Connector* pCon = pStartWin->GetConnector( pStartWin->GetId(), pEndWin->GetId() ); + + if ( !pCon ) + return DEP_CONNECTOR_NOT_FOUND; + else + { + delete pCon; + return DEP_OK; + } +} + +USHORT Depper::Save( const ByteString& rFileName ) +{ + DBG_ASSERT( FALSE , "you are dead!" ); + SvFileStream aOutFile( String( rFileName, RTL_TEXTENCODING_UTF8 ), STREAM_WRITE ); + depper_head dh; + USHORT i; + ULONG nObjCount = pObjectList->Count(); + + ConnectorList* pConList = mpBaseWin->GetConnectorList(); + ULONG nCnctrCount = pConList->Count(); + + dh.nID = DEPPER_ID; + dh.nObjectCount = nObjCount; + dh.nCnctrCount = nCnctrCount; + + aOutFile.Write( &dh, sizeof( dh )); + + for ( i=0; i < nObjCount ; i++ ) + { + pObjectList->GetObject( i )->Save( aOutFile ); + } + + for ( i=0; i < nCnctrCount ; i++ ) + { + pConList->GetObject( i )->Save( aOutFile ); + } + + return 0; +} + +USHORT Depper::Load( const ByteString& rFileName ) +{ + DBG_ASSERT( FALSE , "you are dead!" ); + SvFileStream aInFile( String( rFileName, RTL_TEXTENCODING_UTF8 ), STREAM_READ ); + depper_head dh; + ULONG i; + ULONG nLoadOffs = mnLastId; + ObjectWin* pNewWin; + aInFile.Read( &dh, sizeof( dh )); + + ULONG nObjCount = dh.nObjectCount; + ULONG nCnctrCount = dh.nCnctrCount; + + for ( i=0; i < nObjCount ; i++ ) + { + ObjectWin* pWin = new ObjectWin( mpBaseWin, WB_BORDER ); + pWin->Load( aInFile ); + pNewWin = ObjIdToPtr( AddObject( pWin->GetBodyText(), FALSE )); + pNewWin->SetId( nLoadOffs + pWin->GetId()); + pNewWin->SetPosPixel( pWin->GetPosPixel()); + pNewWin->SetSizePixel( pWin->GetSizePixel()); + } + + ULONG nStartId; + ULONG nEndId; +// ueber addconnector fuehren! + for ( i=0; i < nCnctrCount ; i++ ) + { + Connector* pCon = new Connector( mpBaseWin, WB_NOBORDER ); + pCon->Load( aInFile ); + + nStartId = nLoadOffs + pCon->GetStartId(); + nEndId = nLoadOffs + pCon->GetEndId(); + + ObjectWin* pStartWin = ObjIdToPtr( nStartId ); + ObjectWin* pEndWin = ObjIdToPtr( nEndId ); + + pCon->Initialize( pStartWin, pEndWin ); + } + + + return 0; +} +USHORT Depper::WriteSource() +{ + DBG_ASSERT( FALSE , "overload it!" ); + return 0; +}; + +USHORT Depper::ReadSource() +{ + DBG_ASSERT( FALSE , "overload it!" ); + return 0; +}; + +USHORT Depper::OpenSource() +{ + DBG_ASSERT( FALSE , "overload it!" ); + return 0; +}; + +ObjectWin* Depper::ObjIdToPtr( ULONG nId ) +{ + ULONG nObjCount = pObjectList->Count(); + ULONG i = 0; + ObjectWin* pWin; + + do + { + pWin = pObjectList->GetObject( i ); + i++; + } + while( i < nObjCount && pWin->GetId() != nId ); + if ( pWin->GetId() == nId ) + return pWin; + else + return NULL; +} + +USHORT Depper::Impl_Traveller( ObjectWin* pWin, USHORT nDepth ) +{ + USHORT i = 0; + ObjectWin* pNewWin; + Connector* pCon; + + nDepth++; + + USHORT nMaxDepth = nDepth; + + pWin->mbVisited = TRUE; + pWin->mnRootDist = Max ( nDepth, pWin-> mnRootDist ); + if ( nDepth > DEPPER_MAX_DEPTH ) + { + DBG_ASSERT( nDepth != DEPPER_MAX_DEPTH + 1, "ring abh." ); + nDepth++; + return DEP_ENDLES_RECURSION_FOUND; + } + + while ( pCon = pWin->GetConnector( i ) ) + { + if ( pCon->IsStart( pWin ) && pCon->IsVisible()) + { + pNewWin = pCon->GetOtherWin( pWin ); + nMaxDepth = Max( Impl_Traveller( pNewWin, nDepth ), nMaxDepth ); + if( nMaxDepth == DEP_ENDLES_RECURSION_FOUND ) + { + mpTravellerList->Insert( pWin, LIST_APPEND ); + return DEP_ENDLES_RECURSION_FOUND; + } + } + i++; + } + pWin->mnHeadDist = MAX( pWin->mnHeadDist, nMaxDepth - nDepth ); + return nMaxDepth; +} + +double Depper::CalcDistSum( ObjWinList* pObjList, DistType eDistType ) +{ + ObjectWin* pWin; + Connector* pCon; + ULONG nObjCount = pObjList->Count(); + double dRetVal = 0; + double dWinVal; + USHORT i, j; + BOOL bIsStart; + + for ( i = 0; i < nObjCount; i++ ) + { + pWin = pObjList->GetObject( i ); + + if ( pWin && pWin->IsVisible()) + { + j = 0; + dWinVal = 0; + while ( pCon = pWin->GetConnector( j ) ) + { + if ( pCon->IsVisible()) { + bIsStart = pCon->IsStart( pWin ); + if ( eDistType != BOTH ) + if ( eDistType == TOPDOWN ) + { + if ( bIsStart ) + { + pCon->UpdatePosition( pWin, FALSE ); + dWinVal += pCon->GetLen() * pWin->mnHeadDist; + } + } + else + { + if ( !bIsStart ) + { + pCon->UpdatePosition( pWin, FALSE ); + dWinVal += pCon->GetLen() * pWin->mnRootDist; + } + + } + else + { + pCon->UpdatePosition( pWin, FALSE ); + if ( !bIsStart ) + dWinVal += pCon->GetLen() * ( pWin->mnHeadDist + 1 ); + else + dWinVal += pCon->GetLen() * pWin->mnRootDist; + } + } + j++; + } +// if ( j != 0 ) +// dWinVal /= j; + dRetVal += dWinVal; + } + } + + return dRetVal; +} +ULONG Depper::CalcXOffset( ULONG nObjectsToFit ) +{ + long nDynXOffs; + long nXMiddle; + ULONG nTrigger; + + nXMiddle = mpBaseWin->PixelToLogic( mpBaseWin->GetSizePixel()).Width() / 2; + if ( nObjectsToFit > DEPPER_MAX_WIDTH ) + nObjectsToFit = DEPPER_MAX_WIDTH - 1 + DEPPER_MAX_WIDTH % 2; + nTrigger = ( nObjectsToFit - 1 ) / 2; + nDynXOffs = ( maDefSize.Width() + OBJWIN_X_SPACING ) * nTrigger; + ULONG nXOffs = nXMiddle - nDynXOffs; + + if ( nXMiddle - nDynXOffs < mnMinDynXOffs ) + mnMinDynXOffs = nXMiddle - nDynXOffs; + + return nXOffs; + +} + +double Depper::Impl_PermuteMin( ObjWinList& rObjList, Point* pPosArray, ObjWinList& rResultList, double dMinDist, ULONG nStart, ULONG nSize, DistType eDistType ) +{ + + ULONG i, j, l; + ULONG nEnd = nStart + nSize; + ObjectWin* pSwapWin; + ULONG nLevelObjCount = rObjList.Count(); + +//dont use full recusion for more than 6 objects + if ( nLevelObjCount > 6 ) + { + srand(( unsigned ) time( NULL )); + + ULONG nIdx1, nIdx2; + for ( i = 0; i < 101; i++ ) + { + if ( pSubBar ) { +#ifndef SOLARIS + pSubBar->SetValue( i ); +#endif + pSubBar->Update(); + GetpApp()->Reschedule(); + } + for ( j = 0; j < 100; j++ ) + { + nIdx1 = (ULONG) ( double( rand() ) / RAND_MAX * nLevelObjCount ); + while ( rObjList.GetObject( nIdx1 ) == NULL ) + nIdx1 = (ULONG) ( double( rand() ) / RAND_MAX * nLevelObjCount ); + nIdx2 = (ULONG) ( double( rand() ) / RAND_MAX * nLevelObjCount ); + while ( nIdx1 == nIdx2 || nIdx2 == nLevelObjCount ) + nIdx2 = (ULONG) ( double( rand() ) / RAND_MAX * nLevelObjCount ); + + pSwapWin = rObjList.GetObject( nIdx1 ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( pPosArray[ nIdx2 ] ); + pSwapWin = rObjList.Replace( pSwapWin, nIdx2 ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( pPosArray[ nIdx1 ] ); + rObjList.Replace( pSwapWin, nIdx1 ); + + double dCurDist = CalcDistSum( &rObjList, eDistType ); + + if ( dCurDist < dMinDist ) + { + dMinDist = dCurDist; + rResultList.Clear(); + for ( l = 0; l < nLevelObjCount; l++ ) + { + pSwapWin = rObjList.GetObject( l ); + rResultList.Insert( pSwapWin, LIST_APPEND); + } + } +// if ( dCurDist > dMinDist * 1.5 ) + if ( dCurDist > dMinDist * 15 ) + { + pSwapWin = rObjList.GetObject( nIdx1 ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( pPosArray[ nIdx2 ] ); + pSwapWin = rObjList.Replace( pSwapWin, nIdx2 ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( pPosArray[ nIdx1 ] ); + rObjList.Replace( pSwapWin, nIdx1 ); + } + } + } + } + else + { + for ( i = nStart ; i < nEnd; i++) + { + if ( nSize > 1 ) + { + pSwapWin = rObjList.GetObject( i ); + pSwapWin = rObjList.Replace( pSwapWin, nStart ); + rObjList.Replace( pSwapWin, i ); + + dMinDist = MIN( dMinDist, Impl_PermuteMin( rObjList, pPosArray, rResultList, dMinDist, nStart + 1, nSize - 1, eDistType )); + pSwapWin = rObjList.GetObject( i ); + pSwapWin = rObjList.Replace( pSwapWin, nStart ); + rObjList.Replace( pSwapWin, i ); + + } + else + { + for ( l = 0; l < nLevelObjCount; l++ ) + { + pSwapWin = rObjList.GetObject( l ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( pPosArray[ l ] ); + } + + double dCurDist = CalcDistSum( &rObjList, eDistType ); + + if ( dCurDist < dMinDist ) + { + dMinDist = dCurDist; + rResultList.Clear(); + for ( l = 0; l < nLevelObjCount; l++ ) + { + pSwapWin = rObjList.GetObject( l ); + rResultList.Insert( pSwapWin, LIST_APPEND); + } + } + + } + } + } + + return dMinDist; +} + +Point Depper::CalcPos( USHORT nSet, USHORT nIndex ) +{ + int nRowIndex = nIndex / DEPPER_MAX_WIDTH; + ULONG nPosX = mnXOffset + nRowIndex % 3 * maDefSize.Width() / 3 + ( nIndex - ( DEPPER_MAX_WIDTH * nRowIndex )) * (maDefSize.Width() + OBJWIN_X_SPACING ); + + ULONG nPosY = ( nSet + mnLevelOffset + nRowIndex ) * ( maDefSize.Height() + OBJWIN_Y_SPACING ) + OBJWIN_Y_SPACING; + Point aPos( nPosX, nPosY ); + return aPos; +} + +USHORT Depper::AutoArrange( ULONG nTopId, ULONG nBottmId ) +{ + SolAutoarrangeDlg aArrangeDlg( mpProcessWin ); + pSubBar = aArrangeDlg.GetSubBar(); + pMainBar = aArrangeDlg.GetMainBar(); + pSubText = aArrangeDlg.GetSubText(); + pMainText = aArrangeDlg.GetMainText(); + pMainText->SetText( String::CreateFromAscii( "Overall status" )); + mpBaseWin->Enable( FALSE ); + OptimizePos( GetStart(), 0 ); + mpBaseWin->Enable( TRUE ); + pSubBar = NULL; + pMainBar = NULL; + pSubText = NULL; + pMainText = NULL; + + return 0; +} + +USHORT Depper::OptimizePos( ULONG nTopId, ULONG nBottmId ) +{ + ObjWinList aWorkList; + ObjectWin* pWin; + Connector* pCon; + USHORT nRootDist = -1; + USHORT i, j, k, l, nRetVal; + USHORT LevelUse[ DEPPER_MAX_DEPTH ]; + USHORT LevelSecUse[ DEPPER_MAX_DEPTH ]; + ObjWinList* LevelList[ DEPPER_MAX_DEPTH ]; + ObjWinList* LevelSecList[ DEPPER_MAX_DEPTH ]; + Point aPosArray[ DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH ]; + + mnMinDynXOffs = 0xffff; + + for ( i = 0; i < DEPPER_MAX_DEPTH; i++ ) + { + LevelUse[ i ] = 0; + LevelList[ i ] = NULL; + LevelSecUse[ i ] = 0; + LevelSecList[ i ] = NULL; + } + + mpBaseWin->EnablePaint( FALSE ); + + ULONG nObjCount = pObjectList->Count(); + for ( i = 0; i < nObjCount; i++ ) + { + pWin = pObjectList->GetObject( i ); + if ( pWin->IsVisible()) { + pWin->mbVisited = FALSE; + pWin->mnHeadDist = 0; + pWin->mnRootDist = 0; + + // find initial objects which need to be connected with + // root object + j = 0; + USHORT nStartCount = 0; + USHORT nEndCount = 0; + while ( pCon = pWin->GetConnector( j ) ) + { + if ( pCon->IsVisible()) { + if( pCon->IsStart( pWin )) + nStartCount++; + else + { + nEndCount = 1; + break; + } + } + j++; + } + if ( nStartCount > 0 && nEndCount == 0 ) + if ( nTopId != pWin->GetId()) + Depper::AddConnector( nTopId, pWin->GetId()); + } + } + + pWin = ObjIdToPtr( nTopId ); + + if ( mpTravellerList ) + { + mpTravellerList->Clear(); + delete mpTravellerList; + } + mpTravellerList = new ObjWinList(); + // set root and top distance + nRetVal = Impl_Traveller( pWin, nRootDist ); + + DBG_ASSERT( nRetVal < DEPPER_MAX_DEPTH , "zu tief" ); + if ( nRetVal == DEP_ENDLES_RECURSION_FOUND ) + { + WarningBox aWBox( mpBaseWin, WB_OK, String::CreateFromAscii("graph too deep! dat geiht nich gut.\nlook at depper.err in your Tmp-directory\nfor list of objects")); + aWBox.Execute(); + char *tmpdir = getenv("TMP"); + char *errfilebasename = "depper.err"; + char *ErrFileName = (char*) malloc( strlen( tmpdir ) + strlen( errfilebasename) + 3 ); + *ErrFileName = '\0'; + strcat( ErrFileName, tmpdir ); + strcat( ErrFileName, "\\" ); + strcat( ErrFileName, errfilebasename ); + FILE* pErrFile = fopen( "depper.err", "w+" ); + if ( pErrFile ) + { + for ( USHORT i = 0; i < mpTravellerList->Count(); i++ ) + { + pWin = mpTravellerList->GetObject( i ); + fprintf( pErrFile, " %s -> \n", (pWin->GetBodyText()).GetBuffer()); + } + fclose( pErrFile ); + } + return nRetVal; + } + + ULONG nUnvisited = 0; + ULONG nUnvisYOffs = 0; + + // seperate mainstream, secondary and unconnected + for ( i = 0; i < nObjCount; i++ ) + { + pWin = pObjectList->GetObject( i ); + if ( pWin->IsVisible()) { + if (( pWin->mnHeadDist + pWin->mnRootDist ) == nRetVal ) + { + if ( !LevelList[ pWin->mnHeadDist ] ) + LevelList[ pWin->mnHeadDist ] = new ObjWinList; + LevelList[ pWin->mnHeadDist ]->Insert( pWin ); + LevelUse[ pWin->mnHeadDist ]++; + } + else + if ( pWin->mbVisited ) + { + if ( !LevelSecList[ nRetVal - pWin->mnRootDist ] ) + LevelSecList[ nRetVal - pWin->mnRootDist ] = new ObjWinList; + LevelSecList[ nRetVal - pWin->mnRootDist ]->Insert( pWin ); + LevelSecUse[ nRetVal - pWin->mnRootDist ]++; + } + else + { + // need to be arranged more intelligent... + Point aPos( 5, nUnvisYOffs ); + pWin->SetCalcPosPixel( aPos ); + + Point aTmpPos = pWin->GetCalcPosPixel(); + pWin->SetPosPixel( mpBaseWin->LogicToPixel( aTmpPos )); + + nUnvisYOffs += pWin->PixelToLogic( pWin->GetSizePixel()).Height(); + nUnvisited++; + } + } + } + + mnLevelOffset = 0; + + USHORT nScaleVal; + + if ( nRetVal == 0 ) + nScaleVal = 1; + else + nScaleVal = nRetVal; + + i = 0; + + USHORT nStep = 0; + + while ( LevelList[ i ] ) + { + if ( pMainBar ) { +#ifndef SOLARIS + pMainBar->SetValue( i * 50 / nScaleVal ); +#endif + pMainBar->Update(); + String sText( String::CreateFromAscii( "Optimize step " )); + sText += String::CreateFromInt32( ++nStep ); + pSubText->SetText( sText ); + } + + DBG_ASSERT( LevelUse[ i ] == LevelList[ i ]->Count() , "level index im a..." ); + ObjectWin* pSwapWin; + ULONG nLevelObjCount = LevelList[ i ]->Count(); + + if ( nLevelObjCount % 2 == 0 ) + { + LevelList[ i ]->Insert( NULL, LIST_APPEND ); + nLevelObjCount++; +// LevelUse bleibt orginal... +// LevelUse[ i ]++; + } + +// catch too big lists + DBG_ASSERT( nLevelObjCount < DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH , "graph zu breit! dat geiht nich gut. breaking" ); + if ( nLevelObjCount >= DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH ) + { + WarningBox aWBox( mpBaseWin, WB_OK, String::CreateFromAscii("graph zu breit! dat geiht nich gut. breaking")); + aWBox.Execute(); + break; + } + mnXOffset = CalcXOffset( nLevelObjCount ); + aWorkList.Clear(); + + // initial positioning for mainstream + for ( j = 0; j < nLevelObjCount; j++ ) + { + pSwapWin = LevelList[ i ]->GetObject( j ); + aWorkList.Insert( pSwapWin, LIST_APPEND); + Point aPos = CalcPos( i, j ); + aPosArray[ j ] = aPos; + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + + double dMinDist = CalcDistSum( LevelList[ i ] ); + + // optimize mainstream order and return best matching list in "aWorkList" + dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelObjCount )); + + // set optimized positions - may still be wrong from later tries + for ( j = 0; j < nLevelObjCount; j++ ) + { + pSwapWin = aWorkList.GetObject( j ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + + if ( LevelSecList[ i ] != NULL ) + { + ULONG nLevelSecObjCount = LevelSecList[ i ]->Count(); + // expand list for better positioning + while ( nLevelSecObjCount + LevelUse[ i ] < DEPPER_MAX_WIDTH - 1 ) + { + LevelSecList[ i ]->Insert( NULL, LIST_APPEND ); + nLevelSecObjCount++; + } + if ( ( nLevelSecObjCount + LevelUse[ i ])% 2 == 0 ) + { + LevelSecList[ i ]->Insert( NULL, LIST_APPEND ); + nLevelSecObjCount++; + } + + DBG_ASSERT( nLevelSecObjCount < DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH , "graph zu breit! dat geiht nich gut. breaking" ); + if ( nLevelObjCount >= DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH ) + { + WarningBox aWBox( mpBaseWin, WB_OK, String::CreateFromAscii("graph zu breit! dat geiht nich gut. breaking")); + aWBox.Execute(); + break; + } + mnXOffset = CalcXOffset( LevelUse[ i ] + nLevelSecObjCount ); + aWorkList.Clear(); + + l = 0; + BOOL bUsedPos; + + // find free positions for secondary objects + for ( j = 0; j < ( LevelUse[ i ] + nLevelSecObjCount ) ; j++ ) + { + Point aPos = CalcPos( i, j ); + bUsedPos = FALSE; + // is already occupied? + for ( k = 0; k < nLevelObjCount; k++ ) + { + if ( LevelList[ i ]->GetObject( k ) ) + if ( aPos == LevelList[ i ]->GetObject( k )->GetCalcPosPixel() ) + bUsedPos = TRUE; + } + // if its free, add to pool + if ( !bUsedPos ) + { + aPosArray[ l ] = aPos; + l++; + } + } + + // initial positioning for secodaries + for ( j = 0 ; j < nLevelSecObjCount ; j++ ) + { + pSwapWin = LevelSecList[ i ]->GetObject( j ); + aWorkList.Insert( pSwapWin, LIST_APPEND); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + dMinDist = CalcDistSum( LevelSecList[ i ] ); + + dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelSecList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelSecObjCount )); + + // set optimized positions - may still be wrong from later tries + for ( j = 0; j < nLevelSecObjCount; j++ ) + { + pSwapWin = aWorkList.GetObject( j ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + if ( LevelUse[ i ] + LevelSecUse[ i ] > DEPPER_MAX_WIDTH ) + mnLevelOffset++; + } + if ( LevelUse[ i ] + LevelSecUse[ i ] > DEPPER_MAX_WIDTH ) + mnLevelOffset+= ( LevelUse[ i ] + LevelSecUse[ i ] ) / DEPPER_MAX_WIDTH ; + i++; + } + + mnMinDynXOffs = 0xffff; + +// and back again... +/**/ + // get better results form already preoptimized upper and lower rows + +// i--; +// while ( LevelList[ i ] && i < 60000 ) + do + { + i--; + if ( pMainBar ) + { +#ifndef SOLARIS + pMainBar->SetValue( 50 + ( nScaleVal - i ) * 50 / nScaleVal ); +#endif + pMainBar->Update(); + String sText( String::CreateFromAscii( "Optimize step " )); + sText += String::CreateFromInt32( ++nStep ); + pSubText->SetText( sText ); + } + if ( LevelUse[ i ] + LevelSecUse[ i ] > DEPPER_MAX_WIDTH ) + mnLevelOffset-= ( LevelUse[ i ] + LevelSecUse[ i ] ) / DEPPER_MAX_WIDTH ; + ObjectWin* pSwapWin; + ULONG nLevelObjCount = LevelList[ i ]->Count(); + mnXOffset = CalcXOffset( nLevelObjCount ); + aWorkList.Clear(); + + for ( j = 0; j < nLevelObjCount; j++ ) + { + pSwapWin = LevelList[ i ]->GetObject( j ); + aWorkList.Insert( pSwapWin, LIST_APPEND); + Point aPos = CalcPos( i, j ); + aPosArray[ j ] = aPos; +//no need to do this stuff....... ????? + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + + double dMinDist = CalcDistSum( LevelList[ i ], BOTH ); + + dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelObjCount, BOTH )); +// wrong position for remaping - keep old positions for comparing + for ( j = 0; j < nLevelObjCount; j++ ) + { + pSwapWin = aWorkList.GetObject( j ); + if ( pSwapWin ) +// pSwapWin->SetCalcPosPixel( mpBaseWin->LogicToPixel( aPosArray[ j ] )); + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + + if ( LevelSecList[ i ] != NULL ) + { + ULONG nLevelSecObjCount = LevelSecList[ i ]->Count(); + mnXOffset = CalcXOffset( LevelUse[ i ] + nLevelSecObjCount ); + aWorkList.Clear(); + + l = 0; + BOOL bUsedPos; + + for ( j = 0; j < ( LevelUse[ i ] + nLevelSecObjCount ) ; j++ ) + { + Point aPos = CalcPos( i, j ); + bUsedPos = FALSE; +// could be faster + for ( k = 0; k < nLevelObjCount; k++ ) + { + if ( LevelList[ i ]->GetObject( k ) ) + if ( aPos == LevelList[ i ]->GetObject( k )->GetCalcPosPixel() ) + bUsedPos = TRUE; + } + if ( !bUsedPos ) + { + aPosArray[ l ] = aPos; + l++; + } + } + + for ( j = 0 ; j < nLevelSecObjCount ; j++ ) + { + pSwapWin = LevelSecList[ i ]->GetObject( j ); + aWorkList.Insert( pSwapWin, LIST_APPEND); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + dMinDist = CalcDistSum( LevelSecList[ i ], BOTH ); + + dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelSecList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelSecObjCount, BOTH )); +// wrong position for remaping - keep old positions for comparing + for ( j = 0; j < nLevelSecObjCount; j++ ) + { + pSwapWin = aWorkList.GetObject( j ); + if ( pSwapWin ) + pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); + } + } +// i--; + } while ( i != 0 ); + if ( pMainBar ) { +#ifndef SOLARIS + pMainBar->SetValue( 100 ); +#endif + pMainBar->Update(); + } + + ULONG nNewXSize = ( DEPPER_MAX_WIDTH + 1 ) * ( OBJWIN_X_SPACING + maDefSize.Width() ); + ULONG nNewYSize = ObjIdToPtr( GetStart())->GetCalcPosPixel().Y() + maDefSize.Height() + 2 * OBJWIN_Y_SPACING; + if (( nUnvisYOffs + maDefSize.Height()) > nNewYSize ) + nNewYSize = nUnvisYOffs + maDefSize.Height(); + + MapMode aMapMode = mpBaseWin->GetMapMode(); + Size aTmpSize( double(nNewXSize) * double( aMapMode.GetScaleX()), double( nNewYSize) * double( aMapMode.GetScaleY())); + + Size aNowSize( mpGraphWin->GetSizePixel()); + + if ( mpBaseWin->LogicToPixel( aNowSize ).Width() > aTmpSize.Width() ) + aTmpSize.Width() = mpBaseWin->LogicToPixel( aNowSize ).Width() ; + + if ( mpBaseWin->LogicToPixel( aNowSize ).Height() > aTmpSize.Height() ) + aTmpSize.Height() = mpBaseWin->LogicToPixel( aNowSize ).Height() ; + + if ( nZoomed <= 0 ) + { +// mpBaseWin->SetSizePixel( aTmpSize ); +// mpGraphWin->SetTotalSize( aTmpSize ); +// mpGraphWin->EndScroll( 0, 0 ); + } +// now remap all objects + ULONG nAllObjCount = pObjectList->Count(); + Point aTmpPos; + for ( j = 0; j < nAllObjCount; j++ ) + { + pWin = pObjectList->GetObject( j ); + if ( pWin->IsVisible()) { + aTmpPos = pWin->GetCalcPosPixel(); + if ( pWin->mbVisited ) + { +// reserve space for unconnected + aTmpPos.X() -= mnMinDynXOffs; + aTmpPos.X() += maDefSize.Width() + OBJWIN_X_SPACING; +// center window + aTmpPos.X() += maDefSize.Width() / 2; + aTmpPos.X() -= pWin->PixelToLogic( pWin->GetSizePixel()).Width() / 2 ; + } + pWin->SetPosPixel( mpBaseWin->LogicToPixel( aTmpPos )); + } + } + aWorkList.Clear(); + mpBaseWin->EnablePaint( TRUE ); + mpBaseWin->Invalidate(); +//LevelListen loeschen + + ObjectWin* pObject1; + for ( i = 0 ; i < nObjCount ; i++) + { + pObject1 = pObjectList->GetObject( i ); + if ( pObject1->IsVisible()) + pObject1->UpdateConnectors(); + }; + return 0; +} + +ULONG Depper::GetStart() +{ + DBG_ASSERT( FALSE , "overload it!" ); + return 0; +} + +USHORT Depper::Zoom( MapMode& rMapMode ) +{ + ULONG i; + ObjectWin* pWin; + Point aPos; + Size aSize; + + aSize = mpBaseWin->GetSizePixel(); + mpGraphWin->SetTotalSize( aSize ); + mpGraphWin->EndScroll( 0, 0 ); + + for ( i = pObjectList->Count(); i > 0; i-- ) + { + pWin = pObjectList->GetObject( i - 1 ); + aPos = pWin->PixelToLogic( pWin->GetPosPixel()); + aSize = pWin->PixelToLogic( pWin->GetSizePixel()); + pWin->SetMapMode( rMapMode ); + aPos = pWin->LogicToPixel( aPos ); + aSize = pWin->LogicToPixel( aSize ); + pWin->SetPosSizePixel( aPos, aSize ); + } + mpBaseWin->Invalidate(); + return 0; +} + +IMPL_LINK( Depper, PopupSelected, PopupMenu*, mpPopup ) +{ + USHORT nItemId = mpPopup->GetCurItemId(); + ByteString sNew = ByteString("new"); + + switch( nItemId ) + { + case DEPPOPUP_NEW : +// DBG_ASSERT( FALSE,"new"); + AddObject( sNew , TRUE ); + break; + case DEPPOPUP_AUTOARRANGE : + { +// DBG_ASSERT( FALSE,"autoarrange"); + AutoArrange( GetStart(), 0 ); + }; + break; + case DEPPOPUP_LOAD : + Load( ByteString("test.dep")); +// DBG_ASSERT( FALSE,"load"); + break; + case DEPPOPUP_SAVE : + Save( ByteString("test.dep")); +// DBG_ASSERT( FALSE,"save"); + break; + case DEPPOPUP_WRITE_SOURCE : + WriteSource(); +// DBG_ASSERT( FALSE,"write source"); + break; + case DEPPOPUP_READ_SOURCE : + ReadSource(); +// DBG_ASSERT( FALSE,"read source"); + break; + case DEPPOPUP_OPEN_SOURCE : + OpenSource(); +// DBG_ASSERT( FALSE,"open source"); + break; + case DEPPOPUP_ZOOMIN : + { +// DBG_ASSERT( FALSE,"zoomin"); + MapMode aMapMode = mpBaseWin->GetMapMode(); + aMapMode.SetScaleX( aMapMode.GetScaleX() * Fraction( 1.25 )); + aMapMode.SetScaleY( aMapMode.GetScaleY() * Fraction( 1.25 )); + mpBaseWin->SetMapMode( aMapMode ); + + if ( nZoomed < 1 ) + { + Size aZoomInSize( mpBaseWin->GetSizePixel()); + aZoomInSize.Width() *= 1.25; + aZoomInSize.Height() *= 1.25; + mpBaseWin->SetSizePixel( aZoomInSize ); + } + nZoomed--; + + Zoom( aMapMode ); + }; + break; + case DEPPOPUP_ZOOMOUT : + { +// DBG_ASSERT( FALSE,"zoomout"); + MapMode aMapMode = mpBaseWin->GetMapMode(); + if ( aMapMode.GetScaleX() > Fraction( 0.25 )) + { + aMapMode.SetScaleX( aMapMode.GetScaleX() * Fraction( 0.8 )); + aMapMode.SetScaleY( aMapMode.GetScaleY() * Fraction( 0.8 )); + mpBaseWin->SetMapMode( aMapMode ); + + if ( nZoomed < 0 ) + { + Size aZoomOutSize( mpBaseWin->GetSizePixel()); + aZoomOutSize.Width() *= 0.8; + aZoomOutSize.Height() *= 0.8; + mpBaseWin->SetSizePixel( aZoomOutSize ); + } + nZoomed++; + + Zoom( aMapMode ); + } + }; + break; + case DEPPOPUP_CLEAR : +// DBG_ASSERT( FALSE,"clear"); + RemoveAllObjects( pObjectList ); + break; + case DEPPOPUP_CLOSE : +// DBG_ASSERT( FALSE,"close"); + CloseWindow(); + break; + case DEPPOPUP_HELP : +// DBG_ASSERT( FALSE,"help"); + ShowHelp(); + break; + case DEPPOPUP_TEST : +// DBG_ASSERT( FALSE,"TEST!"); +// test(); + break; + default : + DBG_ASSERT( FALSE, "default" ); + break; + } + return 0; +} + diff --git a/soldep/source/depwin.cxx b/soldep/source/depwin.cxx new file mode 100644 index 000000000000..87f508211d51 --- /dev/null +++ b/soldep/source/depwin.cxx @@ -0,0 +1,224 @@ + +/************************************************************************* + * + * $RCSfile: depwin.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:14 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include + +#include "depwin.hxx" +#include "depper.hxx" +#include "connctr.hxx" +#include "objwin.hxx" + +Bitmap* pWinCopy; + +DepWin::DepWin( Window* pParent, WinBits nWinStyle ) : + Window( pParent, nWinStyle ), + mbStartNewCon( FALSE ), + maNewConStart( 0, 0 ), + maNewConEnd( 0, 0 ), + mpCapturer( NULL ) +{ + if ( !pParent->IsChildNotify() ) + pParent->EnableChildNotify( TRUE ); +// if ( !pParent->IsAllResizeEnabled()) +// pParent->EnableAllResize( TRUE ); + SetUpdateMode( TRUE ); + SetPosSizePixel( Point(0,0), Size( 2000, 2000 )); + + mpPopup = new PopupMenu(); + mpPopup->InsertItem( DEPPOPUP_NEW, String::CreateFromAscii("New object") ); + mpPopup->InsertItem( DEPPOPUP_ZOOMIN, String::CreateFromAscii("Zoom in") ); + mpPopup->InsertItem( DEPPOPUP_ZOOMOUT, String::CreateFromAscii("Zoom out") ); + mpPopup->InsertSeparator(); + mpPopup->InsertItem( DEPPOPUP_CLEAR, String::CreateFromAscii("Clear") ); +} + +DepWin::~DepWin() +{ + Hide(); + while( ConList.Count() > 0 ) + { + delete ConList.GetObject( 0 ); + } +// if ( mpPopup ) +/// delete mpPopup; +} + +void DepWin::AddConnector( Connector* pNewCon ) +{ + ConList.Insert( pNewCon ); +} + +void DepWin::RemoveConnector( Connector* pOldCon ) +{ + ConList.Remove( pOldCon ); +} + +void DepWin::NewConnector( ObjectWin* pWin ) +{ + if ( !mbStartNewCon ) + { + mpNewConWin = pWin; + mbStartNewCon = TRUE; + maNewConStart = pWin->GetFixPoint(Point(0,0)); + } + else + { + Invalidate( Rectangle( maNewConStart, maNewConEnd )); + if ( pWin != mpNewConWin ) + { +// Connector* pConctr; +// pConctr = new Connector( this, WB_NOBORDER ); +// pConctr->Initialize( mpNewConWin, pWin ); + mpDepperDontuseme->AddConnector( mpNewConWin, pWin ); + } + mpNewConWin = 0L; + mbStartNewCon = FALSE; + } + +} + +void DepWin::Paint( const Rectangle& rRect ) +{ + ULONG i = 0; + + if ( ! mpCapturer ) + { + ULONG nListCount = ConList.Count(); + + for ( i=0 ; i < nListCount ; i++ ) + { + ConList.GetObject( i )->Paint( aEmptyRect ); + } + if ( mbStartNewCon ) + { + DrawLine( maNewConStart, maNewConEnd ); + } + } + else + { + Connector* pCon; + + Point aPoint( 0, 0 ); + DrawBitmap( aPoint, *pWinCopy ); + while( pCon = mpCapturer->GetConnector( i )) + { + pCon->Paint( aEmptyRect ); + i++; + } + } +} + +/*void DepWin::Resize() +{ +} */ + +void DepWin::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( rMEvt.IsRight() ) + { +//#ifdef DEBUG + mpPopup->Execute( this, rMEvt.GetPosPixel()); +//#endif + } +} + +void DepWin::MouseMove( const MouseEvent& rMEvt ) +{ + if ( mbStartNewCon ) + { + Invalidate( Rectangle( maNewConStart, maNewConEnd )); + maNewConEnd = PixelToLogic(rMEvt.GetPosPixel()); + maNewConStart = mpNewConWin->GetFixPoint( maNewConEnd ); + } +} + + +ConnectorList* DepWin::GetConnectorList() +{ + return &ConList; +} + +void DepWin::SetPopupHdl( void* pHdl ) +{ + mpPopup->SetSelectHdl( LINK( pHdl, Depper, PopupSelected )); +} + + +void DepWin::SetCapturer( ObjectWin* pWin ) +{ + mpCapturer = pWin; + if ( pWin ) + pWinCopy = new Bitmap( GetBitmap( Point( 0, 0 ), GetParent()->GetSizePixel())); + else + { + Invalidate(); + delete pWinCopy; + pWinCopy = NULL; + } +} + +void DepWin::Command( const CommandEvent& rEvent) +{ + mpDepperDontuseme->GetGraphWin()->Command( rEvent ); +} + diff --git a/soldep/source/graphwin.cxx b/soldep/source/graphwin.cxx new file mode 100644 index 000000000000..61b089aa94d5 --- /dev/null +++ b/soldep/source/graphwin.cxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * $RCSfile: graphwin.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:14 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include "graphwin.hxx" + +GraphWin::GraphWin( Window * pParent ) +: ScrollableWindow( pParent, 0L, SCRWIN_DEFAULT | SCRWIN_VCENTER | SCRWIN_HCENTER ) +, aBufferWindow( this ) +{ + SetSizePixel( pParent->GetSizePixel()); + SetPosPixel( pParent->GetPosPixel()); +// SetPosSizePixel( PIXELS( 0, 0, 500, 500 ) ); + SetTotalSize( Size( 2000,2000 )); +// SetTotalSize( pParent->GetSizePixel()); + + aBufferWindow.SetBackgroundBrush( Color( COL_WHITE )); + +// aBufferWindow.SetPosSizePixel( PIXELS( 0, 0, 238, 80 ) ); + aBufferWindow.SetPosSizePixel( PIXELS( 0, 0, 2000, 2000 ) ); + aBufferWindow.Show(); + + Show(); +} + +void GraphWin::EndScroll( long nDeltaX, long nDeltaY ) +{ + // get the visible area + Rectangle aArea( GetVisibleArea()); + long nX = aArea.Right(); + long nY = aArea.Bottom(); + + // set the new pos and size by using LogicToPixel (this is mandatory) + aBufferWindow.SetPosSizePixel( LogicToPixel( Point( 0, 0 )), + LogicToPixel( Size( nX, nY ))); + aBufferWindow.Invalidate(); +} + +void GraphWin::Resize() +{ + // get the visible area + ScrollableWindow::Resize(); + Rectangle aArea( GetVisibleArea()); + long nX = aArea.Right(); + long nY = aArea.Bottom(); + + // set the new pos and size by using LogicToPixel (this is mandatory) + aBufferWindow.SetPosSizePixel( LogicToPixel( Point( 0, 0 )), + LogicToPixel( Size( nX, nY ))); +} + +void GraphWin::Command( const CommandEvent& rEvent) +{ + ScrollableWindow::Command( rEvent ); +} + diff --git a/soldep/source/hashobj.cxx b/soldep/source/hashobj.cxx new file mode 100644 index 000000000000..fa58c277360e --- /dev/null +++ b/soldep/source/hashobj.cxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * $RCSfile: hashobj.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:14 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include "hashobj.hxx" + +class ObjectWin; + + +MyHashObject::MyHashObject( ULONG nId, ObjectWin* pWin ) +{ + mnId = nId; + mpWin = pWin; +}; + diff --git a/soldep/source/makefile.mk b/soldep/source/makefile.mk new file mode 100644 index 000000000000..6809a234970f --- /dev/null +++ b/soldep/source/makefile.mk @@ -0,0 +1,159 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: obo $ $Date: 2004-02-26 14:50:38 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +# --- Globals ------------------------------------------------------ + +PRJ = ..$/..$/.. +PRJINC = $(PRJ)$/source +PRJNAME = devtools +TARGET = depper + + +# --- Settings ----------------------------------------------------- + +.INCLUDE :settings.mk + + +# --- Files -------------------------------------------------------- + +CDEFS+=-DUPDSTRING=\"$(UPD)\" + +.IF "$(HJS_TEST)"!="" +CDEFS+=-DHJS_TEST +.ENDIF + +DEPOBJFILES= \ + $(OBJ)$/depapp.obj + +SRC1FILES = \ + soldlg.src + +RES1TARGET = dep +SRS1NAME=$(TARGET) +SRS1FILES = \ + $(SRS)$/depper.srs + +RESLIB1NAME = dep +RESLIB1SRSFILES = \ + $(SRS)$/depper.srs + + +OBJFILES = \ + $(OBJ)$/soldep.obj \ + $(OBJ)$/soldlg.obj \ + $(OBJ)$/prjdep.obj \ + $(OBJ)$/depper.obj \ + $(OBJ)$/hashtbl.obj \ + $(OBJ)$/hashobj.obj \ + $(OBJ)$/connctr.obj \ + $(OBJ)$/depwin.obj \ + $(OBJ)$/graphwin.obj \ + $(OBJ)$/objwin.obj + +APP1TARGET=soldepl +APP1OBJS=$(OBJFILES) \ + $(OBJ)$/depapp.obj + +#APP1LIBS= $(LB)$/hashtab.lib + +APP1STDLIBS= \ + $(SVTOOLLIB) \ + $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ + $(SVLIB) \ + $(SOTLIB) \ + $(BTSTRPLIB) \ + $(TOOLSLIB) \ + $(VOSLIB) \ + $(UNOLIB) \ + $(OSLLIB) \ + $(SALLIB) + +.IF "$(GUI)" == "UNX" +LIB1OBJFILES = $(OBJFILES) +LIB1ARCHIV = $(LB)$/libdepper.a +LIB1TARGET = $(LB)$/dep.lib +.ENDIF + +.IF "$(UPD)" >= "546" +.IF "$(USE_NAMESPACE)"!="" +APP1STDLIBS+= \ + $(CPPULIB) +.ENDIF +.ENDIF + +# --- Targets ------------------------------------------------------- + +ALL : \ + ALLTAR \ + $(BIN)$/applicat.rdb + +.INCLUDE : target.mk + +$(BIN)$/applicat.rdb : makefile.mk $(UNOUCRRDB) + rm -f $@ + $(GNUCOPY) $(UNOUCRRDB) $@ + +cd $(BIN) && \ + regcomp -register -r applicat.rdb \ + -c $(DLLPRE)i18n$(UPD)$(DLLPOSTFIX)$(DLLPOST) \ + -c $(DLLPRE)i18npool$(UPD)$(DLLPOSTFIX)$(DLLPOST) + diff --git a/soldep/source/objwin.cxx b/soldep/source/objwin.cxx new file mode 100644 index 000000000000..eb6624feb7b7 --- /dev/null +++ b/soldep/source/objwin.cxx @@ -0,0 +1,715 @@ +/************************************************************************* + * + * $RCSfile: objwin.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:15 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include +#include +#include +#include +#include +#include + +#include "objwin.hxx" +#include "depwin.hxx" +#include "depper.hxx" +#include "prjdep.hxx" +#include "connctr.hxx" + +static Brush* pDefaultBrush = NULL; +static Color aDefaultColor = 0L; + +UINT32 aColorMap[] = { + COL_TRANSPARENT, + COL_GREEN, + COL_RED, + COL_MAGENTA, + COL_BLUE, + COL_LIGHTGREEN, + COL_LIGHTRED, + COL_LIGHTMAGENTA, + COL_BLUE, + COL_BLUE, + COL_BLUE, + COL_BLUE, + COL_BLUE, + COL_BLUE, + COL_BLUE, + COL_BLUE +}; + + +// +// class ObjectWin +// + +/*****************************************************************************/ +ObjectWin::ObjectWin( Window* pParent, WinBits nWinStyle ) +/*****************************************************************************/ + : Window( pParent, nWinStyle ), + mnObjectId( 0 ), + sBodyText( "" ), + sTipText( "" ), + mnRootDist( 0 ), + mnHeadDist( 0 ), + mbVisited( FALSE ), + mbFixed( FALSE ), + mnMarkMode( 0 ), + nViewMask( 0 ), + bVisible( FALSE ), + bMenuExecute( FALSE ) +{ + SetBackgroundBrush( Brush( Color( COL_WHITE ))); + + aTipTimer.SetTimeout( 500 ); + aTipTimer.SetTimeoutHdl( + LINK( this, ObjectWin, TipHdl )); + + SetFont( System::_GetStandardFont( _STDFONT_SWISS )); + EnableClipSiblings(); + SetZOrder( NULL, WINDOW_ZORDER_FIRST ); + mpPopup = new PopupMenu(); +// mpPopup->InsertItem( OBJWIN_EDIT_TEXT, String::CreateFromAscii( "Details" )); + mpPopup->InsertItem( OBJWIN_ADD_CONNECTOR, String::CreateFromAscii( "New connection" )); + mpPopup->InsertItem( OBJWIN_REMOVE_WIN, String::CreateFromAscii( "Remove object" )); + mpPopup->InsertItem( OBJWIN_VIEW_CONTENT, String::CreateFromAscii( "View content" )); +// mpPopup->InsertSeparator(); + mpPopup->SetSelectHdl( LINK( this, ObjectWin, PopupSelected )); + mpPopup->SetDeactivateHdl( LINK( this, ObjectWin, PopupDeactivated )); + mnPopupStaticItems = mpPopup->GetItemCount(); + + if ( ! pDefaultBrush ) + { + pDefaultBrush = new Brush( GetBackgroundBrush() ); + aDefaultColor = GetTextColor(); + } + Hide(); +} + +/*****************************************************************************/ +ObjectWin::~ObjectWin() +/*****************************************************************************/ +{ + while ( Connections.Count() > 0 ) + { + delete Connections.GetObject( 0 ); + } +} + +/*****************************************************************************/ +void ObjectWin::SetViewMask( ULONG nMask ) +/*****************************************************************************/ +{ + nViewMask = nMask; + if ( nViewMask & mpDepperDontuseme->GetViewMask()) { + bVisible = TRUE; + Show(); + } + else { + Hide(); + bVisible = FALSE; + } + for ( ULONG i = 0; i < Connections.Count(); i++ ) + Connections.GetObject( i )->UpdateVisibility(); +} + +/*****************************************************************************/ +void ObjectWin::SetBodyText( const ByteString& rNewString ) +/*****************************************************************************/ +{ + sBodyText = rNewString; +} + +/*****************************************************************************/ +ByteString& ObjectWin::GetBodyText() +/*****************************************************************************/ +{ + return sBodyText; +} + +/*****************************************************************************/ +void ObjectWin::SetTipText( const ByteString& rNewString ) +/*****************************************************************************/ +{ + sTipText = rNewString; +} + +/*****************************************************************************/ +ByteString& ObjectWin::GetTipText() +/*****************************************************************************/ +{ + return sTipText; +} + +/*****************************************************************************/ +Point ObjectWin::GetFixPoint( const Point& rRefPoint, BOOL bUseRealPos ) +/*****************************************************************************/ +{ + Point aLocalPoint; + if ( bUseRealPos ) + aLocalPoint = GetPosPixel(); + else + aLocalPoint = GetCalcPosPixel(); + + Size aLocalSize = GetSizePixel(); + Point aRetPoint; + + USHORT nRefX = aLocalPoint.X() + aLocalSize.Width() / 2 ; + USHORT nRefY = aLocalPoint.Y() + aLocalSize.Height() / 2 ; + + if ( nRefX < 0 ) nRefX = 0; + if ( nRefY < 0 ) nRefY = 0; + + if ( rRefPoint.X() > nRefX ) + { + if ( rRefPoint.Y() > nRefY ) + { + if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY )) + { + aRetPoint.X() = aLocalPoint.X() + aLocalSize.Width(); + aRetPoint.Y() = nRefY; + } + else + { + aRetPoint.X() = nRefX; + aRetPoint.Y() = aLocalPoint.Y() + aLocalSize.Height(); + } + } + else + { + if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY )) + { + aRetPoint.X() = aLocalPoint.X() + aLocalSize.Width(); + aRetPoint.Y() = nRefY; + } + else + { + aRetPoint.X() = nRefX; + aRetPoint.Y() = aLocalPoint.Y(); + } + } + } + else + { + if ( rRefPoint.Y() > nRefY ) + { + if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY )) + { + aRetPoint.X() = aLocalPoint.X(); + aRetPoint.Y() = nRefY; + } + else + { + aRetPoint.X() = nRefX; + aRetPoint.Y() = aLocalPoint.Y() + aLocalSize.Height(); + } + } + else + { + if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY )) + { + aRetPoint.X() = aLocalPoint.X(); + aRetPoint.Y() = nRefY; + } + else + { + aRetPoint.X() = nRefX; + aRetPoint.Y() = aLocalPoint.Y(); + } + } + } + + return PixelToLogic(aRetPoint); + +} + +/*****************************************************************************/ +void ObjectWin::AddConnector( Connector* pNewCon ) +/*****************************************************************************/ +{ + Connections.Insert( pNewCon ); +} + +/*****************************************************************************/ +BOOL ObjectWin::ConnectionExistsInAnyDirection( ObjectWin *pWin ) +/*****************************************************************************/ +{ + for ( ULONG i = 0; i < Connections.Count(); i++ ) + if ( Connections.GetObject( i )->GetOtherWin( this ) == pWin ) + return TRUE; + + return FALSE; +} + +/*****************************************************************************/ +void ObjectWin::RemoveConnector( Connector* pOldCon ) +/*****************************************************************************/ +{ + Connections.Remove( pOldCon ); +} + +/*****************************************************************************/ +Connector* ObjectWin::GetConnector( ULONG nIndex ) +/*****************************************************************************/ +{ + ULONG nConCount = Connections.Count(); + + if ( nIndex < nConCount ) + return Connections.GetObject( nIndex ); + return NULL; +} + +/*****************************************************************************/ +Connector* ObjectWin::GetConnector( ULONG nStartId, ULONG nEndId ) +/*****************************************************************************/ +{ + if ( mnObjectId != nStartId ) + return NULL; + + USHORT i; + Connector* pCon; + ULONG nConCount = Connections.Count(); + + for ( i = 0; i < nConCount; i++ ) + { + pCon = Connections.GetObject( i ); + if ( pCon->GetOtherWin( this )->GetId() == nEndId ) + return pCon; + } + return NULL; +} + +/*****************************************************************************/ +void ObjectWin::SetMarkMode( ULONG nMarkMode ) +/*****************************************************************************/ +{ + Brush aBrush; + + if ( nMarkMode == MARKMODE_DEFAULT ) + { + if ( pDefaultBrush ) + { + aBrush = GetBackgroundBrush(); + aBrush.SetColor( pDefaultBrush->GetColor() ); + SetBackgroundBrush( aBrush ); + SetTextColor( aDefaultColor ); + } + } + else + { + mnMarkMode |= nMarkMode; + aBrush = GetBackgroundBrush(); + aBrush.SetColor( aColorMap[ mnMarkMode ] ); + SetBackgroundBrush( aBrush ); + SetTextColor( COL_WHITE ); + } + Invalidate(); +} + +/*****************************************************************************/ +void ObjectWin::UnsetMarkMode( ULONG nMarkMode ) +/*****************************************************************************/ +{ + Brush aBrush; + + ULONG nOldMode = mnMarkMode; + mnMarkMode &= ( !nMarkMode ); + + if ( nOldMode != mnMarkMode ) { + if ( mnMarkMode == MARKMODE_DEFAULT ) + { + if ( pDefaultBrush ) + { + aBrush = GetBackgroundBrush(); + aBrush.SetColor( pDefaultBrush->GetColor() ); + SetBackgroundBrush( aBrush ); + SetTextColor( aDefaultColor ); + } + } + else + { + aBrush = GetBackgroundBrush(); + aBrush.SetColor( aColorMap[ mnMarkMode ] ); + SetBackgroundBrush( aBrush ); + SetTextColor( COL_WHITE ); + } + Invalidate(); + } +} + +/*****************************************************************************/ +void ObjectWin::MarkNeeded( BOOL bReset ) +/*****************************************************************************/ +{ + Connector* pCon; + ObjectWin* pWin; + + ULONG nConCount = Connections.Count(); + ULONG i; + + for ( i = 0; i < nConCount; i++ ) + { + pCon = Connections.GetObject( i ); + if ( pCon && !pCon->IsStart( this) ) + { + pWin = pCon->GetOtherWin( this ); + if ( pWin ) + { + if ( bReset ) + pWin->UnsetMarkMode( MARKMODE_NEEDED ); + else + pWin->SetMarkMode( MARKMODE_NEEDED ); + pWin->MarkNeeded( bReset ); + } + } + } +} + +/*****************************************************************************/ +void ObjectWin::MarkDepending( BOOL bReset ) +/*****************************************************************************/ +{ + Connector* pCon; + ObjectWin* pWin; + + ULONG nConCount = Connections.Count(); + ULONG i; + + for ( i = 0; i < nConCount; i++ ) + { + pCon = Connections.GetObject( i ); + if ( pCon && pCon->IsStart( this) ) + { + pWin = pCon->GetOtherWin( this ); + if ( pWin ) + { + if ( bReset ) + pWin->UnsetMarkMode( MARKMODE_DEPENDING ); + else + pWin->SetMarkMode( MARKMODE_DEPENDING ); + pWin->MarkDepending( bReset ); + } + } + } +} + +/*****************************************************************************/ +void ObjectWin::Paint( const Rectangle& rRect ) +/*****************************************************************************/ +{ + + Size aWinSize = PixelToLogic( GetOutputSizePixel() ); + Size aTextSize; + aTextSize.Width() = GetTextWidth( String( sBodyText, RTL_TEXTENCODING_UTF8 )); + aTextSize.Height() = GetTextHeight(); + Point aPos( aWinSize.Width() / 2 - aTextSize.Width() / 2, + aWinSize.Height() / 2 - aTextSize.Height() / 2 ); + + DrawText( aPos , String( sBodyText, RTL_TEXTENCODING_UTF8 )); +} + +/*****************************************************************************/ +void ObjectWin::MouseButtonDown( const MouseEvent& rMEvt ) +/*****************************************************************************/ +{ + SetZOrder( NULL, WINDOW_ZORDER_FIRST ); + GrabFocus(); + + // workaround fuer vcl-bug +// GetWindow( WINDOW_REALPARENT)->Invalidate(); + + aMouseOffset = rMEvt.GetPosPixel(); + if ( rMEvt.IsLeft() ) + { + if ( rMEvt.IsMod1() ) //IsMod2 + { + CaptureMouse(); + SetMarkMode( MARKMODE_ACTIVATED ); + MarkNeeded(); + MarkDepending(); + } + else { + MarkNeeded( TRUE ); + MarkDepending( TRUE ); + } + if( rMEvt.GetClicks() == 2 ) + DoubleClick(); + else if ( !rMEvt.IsShift() && !((DepWin*)GetParent())->IsStartNewCon()) + CaptureMouse(); + } +} + +/*****************************************************************************/ +void ObjectWin::MouseButtonUp( const MouseEvent& rMEvt ) +/*****************************************************************************/ +{ + if ( rMEvt.IsLeft() ) + { + if ( rMEvt.IsShift() || ((DepWin*)GetParent())->IsStartNewCon()) + ((DepWin*)GetParent())->NewConnector( this ); + else + { + ReleaseMouse(); +// ((DepWin*)GetParent())->SetCapturer( NULL ); + // workaround fuer vcl-bug + +// try without +// GetParent()->Invalidate(); + } + if ( GetMarkMode() & MARKMODE_ACTIVATED ) + { +// UnsetMarkMode( MARKMODE_ACTIVATED ); +// MarkNeeded( TRUE ); +// MarkDepending( TRUE ); + SetMarkMode( MARKMODE_SELECTED ); + } + } + else if ( rMEvt.IsRight() ) + { + USHORT i; + + while ( mnPopupStaticItems < mpPopup->GetItemCount() ) + { + mpPopup->RemoveItem( mnPopupStaticItems ); + } + + if ( Connections.Count()) { + mpPopup->InsertSeparator(); + + for( i = 0; i < Connections.Count() ; i++ ) + { + mpPopup->InsertItem( mnPopupStaticItems + i, String( ((Connections.GetObject( i ))->GetOtherWin( this ))->GetBodyText(), RTL_TEXTENCODING_UTF8 )); + } + } + bMenuExecute = TRUE; + mpPopup->Execute( GetParent(), rMEvt.GetPosPixel() + GetPosPixel()); + } +} + +/*****************************************************************************/ +void ObjectWin::MouseMove( const MouseEvent& rMEvt ) +/*****************************************************************************/ +{ + if ( IsMouseCaptured() ) + { + USHORT i; + + Point aNewWinPos( GetPosPixel() + rMEvt.GetPosPixel() - aMouseOffset ); + + aNewWinPos.X() = Max( 0L, aNewWinPos.X()); + aNewWinPos.Y() = Max( 0L, aNewWinPos.Y()); + SetPosPixel( aNewWinPos ); + + for ( i=0; i < Connections.Count();i++) + { + Connections.GetObject( i )->UpdatePosition( this ); + } + } + else + { + if ( rMEvt.IsLeaveWindow() ) + aTipTimer.Stop(); + else + aTipTimer.Start(); + + MouseEvent aNewMEvt( rMEvt.GetPosPixel() + GetPosPixel()); + + GetParent()->MouseMove( aNewMEvt ); + } +} + +/*****************************************************************************/ +void ObjectWin::DoubleClick() +/*****************************************************************************/ +{ + mpDepperDontuseme->ViewContent( sBodyText ); +} + +/*****************************************************************************/ +USHORT ObjectWin::Save( SvFileStream& rOutFile ) +/*****************************************************************************/ +{ + return 0; +} + +/*****************************************************************************/ +USHORT ObjectWin::Load( SvFileStream& rInFile ) +/*****************************************************************************/ +{ + return 0; +} + +/*****************************************************************************/ +void ObjectWin::SetId( ULONG nId ) +/*****************************************************************************/ +{ + mnObjectId = nId; +} + +/*****************************************************************************/ +ULONG ObjectWin::GetId() +/*****************************************************************************/ +{ + return mnObjectId; +} + +/*****************************************************************************/ +void ObjectWin::UpdateConnectors() +/*****************************************************************************/ +{ + USHORT i; + + for ( i = 0; i < Connections.Count(); i++ ) + { + Connections.GetObject( i )->UpdatePosition( this ); + } +} + +IMPL_LINK( ObjectWin, PopupSelected, PopupMenu*, mpPopup ) +{ + USHORT nItemId = mpPopup->GetCurItemId(); + + switch( nItemId ) + { + case OBJWIN_EDIT_TEXT : + DBG_ASSERT( FALSE,"edit"); + break; + case OBJWIN_REMOVE_WIN : +// DBG_ASSERT( FALSE,"remove"); +// DBG_ASSERT( mpDepperDontuseme,"remove"); + mpDepperDontuseme->RemoveObject(( USHORT ) GetId()); + break; + case OBJWIN_ADD_CONNECTOR : +// DBG_ASSERT( FALSE,"add con"); + ((DepWin*)GetParent())->NewConnector( this ); + break; + case OBJWIN_VIEW_CONTENT : +// DBG_ASSERT( FALSE,"view cnt"); + mpDepperDontuseme->ViewContent( sBodyText ); + break; + default : +// DBG_ASSERT( FALSE, String (nItemId) ); + Connector* pCon = Connections.GetObject( nItemId - mnPopupStaticItems ); +// delete pCon; + mpDepperDontuseme->RemoveConnector( pCon->GetStartId(), pCon->GetEndId()); + break; + } + return 0; +} + +/*****************************************************************************/ +IMPL_LINK( ObjectWin, TipHdl, void *, EMTY_ARG ) +/*****************************************************************************/ +{ + aTipTimer.Stop(); + + if ( sTipText.Len()) { + Point aPos( GetpApp()->GetAppWindow()->GetPointerPosPixel()); + Help::ShowBalloon( GetpApp()->GetAppWindow(), + Point( aPos.X(), aPos.Y()), + String( sTipText, RTL_TEXTENCODING_UTF8 )); + } + return 0; +} + +/*****************************************************************************/ +void ObjectWin::GetFocus() +/*****************************************************************************/ +{ + SetMarkMode( MARKMODE_SELECTED ); +} + +/*****************************************************************************/ +void ObjectWin::LoseFocus() +/*****************************************************************************/ +{ + if ( !bMenuExecute ) { + UnsetMarkMode( MARKMODE_SELECTED ); + UnsetMarkMode( MARKMODE_ACTIVATED ); + MarkNeeded( TRUE ); + MarkDepending( TRUE ); + } + else + bMenuExecute = FALSE; +} + +/*****************************************************************************/ +IMPL_LINK( ObjectWin, PopupDeactivated, PopupMenu*, mpPopup ) +/*****************************************************************************/ +{ + bMenuExecute = FALSE; + + if ( !HasFocus()) { + UnsetMarkMode( MARKMODE_SELECTED ); + UnsetMarkMode( MARKMODE_ACTIVATED ); + MarkNeeded( TRUE ); + MarkDepending( TRUE ); + } + + return 0; +} + +/*****************************************************************************/ +void ObjectWin::Command( const CommandEvent& rEvent) +/*****************************************************************************/ +{ + mpDepperDontuseme->GetGraphWin()->Command( rEvent ); +} + diff --git a/soldep/source/soldep.cxx b/soldep/source/soldep.cxx new file mode 100644 index 000000000000..726dbee63f1d --- /dev/null +++ b/soldep/source/soldep.cxx @@ -0,0 +1,566 @@ +/************************************************************************* + * + * $RCSfile: soldep.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:16 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "depper.hxx" +#include "soldep.hxx" +#include "soldlg.hxx" +#include "dtsodcmp.hrc" + +IMPLEMENT_HASHTABLE_OWNER( SolIdMapper, ByteString, ULONG* ); + +ByteString sDelimiterLine("#=========================================================================="); + + +// +// class SolDep +// + +/*****************************************************************************/ +SolDep::SolDep( Window* pBaseWindow ) +/*****************************************************************************/ + : Depper( pBaseWindow ), + mpPrjDep( NULL ) +{ + mpSolIdMapper = new SolIdMapper( 63997 ); + mpStarWriter = new StarWriter( msSourceName, TRUE ); + + mpBaseWin->mpPopup->InsertSeparator(); + mpBaseWin->mpPopup->InsertItem( DEPPOPUP_READ_SOURCE, String::CreateFromAscii("Revert all changes") ); + mpBaseWin->mpPopup->InsertSeparator(); + mpBaseWin->mpPopup->InsertItem( DEPPOPUP_OPEN_SOURCE, String::CreateFromAscii("Open") ); + mpBaseWin->mpPopup->InsertItem( DEPPOPUP_WRITE_SOURCE, String::CreateFromAscii("Save") ); +// mpBaseWin->mpPopup->InsertItem( DEPPOPUP_CLOSE, String::CreateFromAscii("Close") ); +// mpBaseWin->mpPopup->InsertItem( DEPPOPUP_HELP, String::CreateFromAscii("Help") ); +} + +/*****************************************************************************/ +SolDep::~SolDep() +/*****************************************************************************/ +{ + delete mpSolIdMapper; + delete mpStarWriter; + delete mpPrjDep; + delete pStandLst; +} + +/*****************************************************************************/ +void SolDep::Init() +/*****************************************************************************/ +{ + InformationParser aParser; + String sStandLst( GetDefStandList(), RTL_TEXTENCODING_ASCII_US ); + pStandLst = aParser.Execute( sStandLst ); + + if ( pStandLst ) { + if ( GetVersion()) + ReadSource(); + } +} + +/*****************************************************************************/ +void SolDep::Init( ByteString &rVersion, GenericInformationList *pVersionList ) +/*****************************************************************************/ +{ + if ( pVersionList ) + pStandLst = new GenericInformationList( *pVersionList ); + else { + InformationParser aParser; + String sStandLst( GetDefStandList(), RTL_TEXTENCODING_ASCII_US ); + pStandLst = aParser.Execute( sStandLst ); + } + if ( pStandLst ) { + msVersion = rVersion; + ReadSource(); + } +} + +/*****************************************************************************/ +BOOL SolDep::GetVersion() +/*****************************************************************************/ +{ + SolSelectVersionDlg aVersionDlg( mpBaseWin, pStandLst ); + if ( aVersionDlg.Execute() == RET_OK ) { + msVersion = aVersionDlg.GetVersion(); + return TRUE; + } + return FALSE; +} + +/*****************************************************************************/ +ObjectWin *SolDep::RemoveObject( USHORT nId, BOOL bDelete ) +/*****************************************************************************/ +{ + Prj* pPrj; + +//hshtable auf stand halten + ObjectWin* pWin = Depper::RemoveObject( nId, FALSE ); + if ( pWin ) + { + ByteString aBodyText( pWin->GetBodyText() ); + if( pPrj = mpStarWriter->GetPrj( aBodyText )) + { + mpStarWriter->Remove( pPrj ); +//cleanup ist teuer... + mpStarWriter->CleanUp(); + delete pPrj; + } + else + DBG_ASSERT( FALSE, "project not found - write" ); + + mpSolIdMapper->Delete( aBodyText ); + if ( bDelete ) + delete pWin; + return pWin; + } + else + return NULL; +} + +/*****************************************************************************/ +ULONG SolDep::AddObject( ByteString& rBodyText, BOOL bInteract ) +/*****************************************************************************/ +{ + if ( bInteract ) + { + SolNewProjectDlg aNewProjectDlg( mpBaseWin, DtSodResId( RID_SD_DIALOG_NEWPROJECT )); + if ( aNewProjectDlg.Execute() ) + { + rBodyText = ByteString( aNewProjectDlg.maEName.GetText(), RTL_TEXTENCODING_UTF8); +//hashtable auf stand halten + MyHashObject* pHObject; + ULONG nObjectId = Depper::AddObject( rBodyText, FALSE ); + pHObject = new MyHashObject( nObjectId, ObjIdToPtr( nObjectId )); + mpSolIdMapper->Insert( rBodyText, pHObject ); + + ByteString sTokenLine( aNewProjectDlg.maEShort.GetText(), RTL_TEXTENCODING_UTF8 ); + sTokenLine += '\t'; + sTokenLine += ByteString( aNewProjectDlg.maEName.GetText(), RTL_TEXTENCODING_UTF8 ); + sTokenLine += "\t:\t"; + + ByteString sDeps = ByteString( aNewProjectDlg.maEDeps.GetText(), RTL_TEXTENCODING_UTF8 ); + + if ( sDeps != "" ) + { + USHORT i; + ByteString sDepName; + USHORT nToken = sDeps.GetTokenCount(' '); + for ( i = 0 ; i < nToken ; i++) + { + sDepName = sDeps.GetToken( i, ' ' ); + sTokenLine += sDepName; + sTokenLine +='\t'; + } + } + sTokenLine +="NULL"; + + mpStarWriter->InsertTokenLine( sTokenLine ); + mpStarWriter->InsertTokenLine( sDelimiterLine ); + + if ( sDeps != "" ) + { + USHORT i; + ByteString sDepName; + ULONG nObjectId, nHashedId; + MyHashObject* pHObject; + USHORT nToken = sDeps.GetTokenCount(' '); + for ( i = 0 ; i < nToken ; i++) + { + sDepName = sDeps.GetToken( i, ' ' ); + + pHObject = mpSolIdMapper->Find( sDepName ); + if ( !pHObject ) + { + String sMessage; + sMessage += String::CreateFromAscii("can't find "); + sMessage += String( sDepName, RTL_TEXTENCODING_UTF8 ); + sMessage += String::CreateFromAscii(".\ndependency ignored"); + WarningBox aBox( mpBaseWin, WB_OK, sMessage); + aBox.Execute(); + } + else + { + nHashedId = pHObject->GetId(); + pHObject = mpSolIdMapper->Find( rBodyText ); + nObjectId = pHObject->GetId(); + Depper::AddConnector( nHashedId, nObjectId ); + } + } + } + return nObjectId; + } + return 0; + } + else + { +//hashtable auf stand halten + MyHashObject* pHObject; + ULONG nObjectId = Depper::AddObject( rBodyText, FALSE ); + pHObject = new MyHashObject( nObjectId, ObjIdToPtr( nObjectId )); + mpSolIdMapper->Insert( rBodyText, pHObject ); + + return nObjectId; + } +} + +/*****************************************************************************/ +USHORT SolDep::AddConnector( ObjectWin* pStartWin, ObjectWin* pEndWin ) +/*****************************************************************************/ +{ +// DBG_ASSERT( FALSE , "not yet" ); + ByteString sEndName = pEndWin->GetBodyText(); + ByteString sStartName = pStartWin->GetBodyText(); + + Prj* pPrj = mpStarWriter->GetPrj( sEndName ); + if ( pPrj ) + { + pPrj->AddDependencies( sStartName ); + return Depper::AddConnector( pStartWin, pEndWin ); + } + else + { + DBG_ASSERT( FALSE , "non existing Project" ); + return 1; + } +} + +/*****************************************************************************/ +USHORT SolDep::RemoveConnector( ObjectWin* pStartWin, ObjectWin* pEndWin ) +/*****************************************************************************/ +{ + SByteStringList* pPrjDeps = NULL; + ByteString sEndName = pEndWin->GetBodyText(); + ByteString sStartName = pStartWin->GetBodyText(); + + Prj* pPrj = mpStarWriter->GetPrj( sEndName ); + pPrjDeps = pPrj->GetDependencies( FALSE ); + if ( pPrjDeps ) + { + ByteString* pString; + ULONG nPrjDepsCount = pPrjDeps->Count(); + for ( ULONG j = nPrjDepsCount; j > 0; j-- ) + { + pString = pPrjDeps->GetObject( j - 1 ); + if ( pString->GetToken( 0, '.') == sStartName ) + pPrjDeps->Remove( pString ); + } + } + + return Depper::RemoveConnector( pStartWin, pEndWin ); +} + +/*****************************************************************************/ +void SolDep::RemoveAllObjects( ObjWinList* pObjLst ) +/*****************************************************************************/ +{ + + Depper::RemoveAllObjects( pObjLst ); + + if ( mpSolIdMapper ) + { + delete mpSolIdMapper; + mpSolIdMapper = NULL; + } + if ( mpStarWriter ) + { + delete mpStarWriter; + mpStarWriter = NULL; + } +} + +/*****************************************************************************/ +ULONG SolDep::GetStart() +/*****************************************************************************/ +{ +// DBG_ASSERT( FALSE , "soldep" ); + MyHashObject* pHObject = mpSolIdMapper->Find( "null_project" ); + + if ( !pHObject ) { + ByteString sNullProject = ByteString( "null_project" ); + ULONG nObjectId = AddObject( sNullProject, FALSE ); + ObjIdToPtr( nObjectId )->SetViewMask( 1 ); + return nObjectId; + } + + return pHObject->GetId(); +} + +/*****************************************************************************/ +USHORT SolDep::OpenSource() +/*****************************************************************************/ +{ + if ( pStandLst ) { + if ( GetVersion()) + return ReadSource(); + } + return 0; +} + +/*****************************************************************************/ +USHORT SolDep::ReadSource() +/*****************************************************************************/ +{ + mpBaseWin->EnablePaint( FALSE ); + ULONG nObjectId, nHashedId; + ULONG i; + MyHashObject* pHObject; + ByteString* pStr; + ObjectWin *pStartWin, *pEndWin; + + RemoveAllObjects( pObjectList ); + delete mpSolIdMapper; + delete mpStarWriter; + + mpSolIdMapper = new SolIdMapper( 63997 ); + mpStarWriter = new StarWriter( pStandLst, msVersion, TRUE, getenv(SOURCEROOT) ); + + + ByteString sTitle( SOLDEPL_NAME ); + if ( mpStarWriter->GetMode() == STAR_MODE_SINGLE_PARSE ) { + sTitle += ByteString( " - mode: single file [" ); + sTitle += (ByteString) mpStarWriter->GetName(); + sTitle += ByteString( "]" ); + } + else if ( mpStarWriter->GetMode() == STAR_MODE_MULTIPLE_PARSE ) { + sTitle += ByteString( " - mode: multiple files [" ); + sTitle += ByteString(getenv(SOURCEROOT)); + sTitle += ByteString( "]" ); + } + SetTitle( String( sTitle, RTL_TEXTENCODING_UTF8) ); + + ULONG nCount = mpStarWriter->Count(); + for ( i=0; iGetObject(i); + ByteString sProjectName = pPrj->GetProjectName(); + nObjectId = AddObject( sProjectName, FALSE ); + ObjIdToPtr( nObjectId )->SetViewMask( 1 ); + } + for ( i=0; iGetObject(i); + SByteStringList *pLst = pPrj->GetDependencies( FALSE ); + if ( pLst ) + { + ULONG nDepCount = pLst->Count(); + for ( ULONG m=0; mGetObject(m); + pHObject = mpSolIdMapper->Find( *pStr ); + if ( !pHObject ) + { + // create new prj + Prj *pNewPrj = new Prj( *pStr ); + ByteString sNewProjectName = pNewPrj->GetProjectName(); + nObjectId = AddObject( sNewProjectName, FALSE ); + pHObject = mpSolIdMapper->Find( *pStr ); + ObjIdToPtr( nObjectId )->SetViewMask( 2 ); + } + + nHashedId = pHObject->GetId(); + ByteString sF_Os2 = pPrj->GetProjectName(); + pStr = &sF_Os2; + pHObject = mpSolIdMapper->Find( *pStr ); + nObjectId = pHObject->GetId(); + pStartWin = ObjIdToPtr( nHashedId ); + pEndWin = ObjIdToPtr( nObjectId ); +// Depper::AddConnector( nHashedId, nObjectId ); + Depper::AddConnector( pStartWin, pEndWin ); + } + } + } + AutoArrange( GetStart(), 0 ); + mpBaseWin->EnablePaint( TRUE ); + return 0; +} + +/*****************************************************************************/ +USHORT SolDep::WriteSource() +/*****************************************************************************/ +{ + USHORT nMode = mpStarWriter->GetMode(); + if ( nMode == STAR_MODE_SINGLE_PARSE ) { + ByteString sFileName = mpStarWriter->GetName(); + if ( sFileName.Len()) { + mpStarWriter->Write( String( sFileName, RTL_TEXTENCODING_UTF8) ); + mpStarWriter->RemoveProject( ByteString( "null_project")); + } + } + else if ( nMode == STAR_MODE_MULTIPLE_PARSE ) { + //*OBO* + //String sRoot = mpStarWriter->GetSourceRoot(); + //nicht mehr unterstützt mpStarWriter->GetSourceRoot() + String sRoot = String(getenv(SOURCEROOT), RTL_TEXTENCODING_UTF8); + ByteString sFileName = mpStarWriter->GetName(); + DirEntry aEntry( sFileName ); + aEntry.ToAbs(); + aEntry = aEntry.GetPath().GetPath().GetPath(); + + if ( sRoot.Len()) { + mpStarWriter->RemoveProject( ByteString( "null_project")); + mpStarWriter->WriteMultiple( sRoot ); + } + } + + return 1; +} + +/*****************************************************************************/ +BOOL SolDep::ViewContent( ByteString& rObjectName ) +/*****************************************************************************/ +{ + pFocusWin = NULL; + for ( ULONG i = 0; i < pObjectList->Count() && !pFocusWin; i++ ) + if ( pObjectList->GetObject( i )->HasFocus()) + pFocusWin = pObjectList->GetObject( i ); + + if ( mpPrjDep ) + delete mpPrjDep; + + mpGraphWin->Hide(); + mpBaseWin->Hide(); + + mpPrjDep = new PrjDep( mpProcessWin ); + mpPrjDep->SetCloseHdl( LINK( this, SolDep, PrjCloseHdl )); + + mpProcessWin->Resize(); + + return mpPrjDep->Init( rObjectName, mpStarWriter ); +} + +/*****************************************************************************/ +IMPL_LINK( SolDep, PrjCloseHdl, PrjDep *, pPrjDep ) +/*****************************************************************************/ +{ + delete mpPrjDep; + mpPrjDep = NULL; + + mpGraphWin->Show(); + mpBaseWin->Show(); + + if ( pFocusWin ) { + pFocusWin->GrabFocus(); + pFocusWin = NULL; + } + + return 0; +} + +/*****************************************************************************/ +USHORT SolDep::CloseWindow() +/*****************************************************************************/ +{ + + ((SystemWindow*)mpProcessWin)->Close(); + return 0; +} + +/*****************************************************************************/ +void SolDep::ShowHelp() +/*****************************************************************************/ +{ + SvFileStream aHelpFile( String::CreateFromAscii( "g:\\soldep.hlp" ), STREAM_READ ); + String aHelpText; + String aGetStr; + ByteString sRead; + + if ( aHelpFile.IsOpen() ) + { + while ( aHelpFile.ReadLine( sRead ) ) + { + aGetStr = String( sRead, RTL_TEXTENCODING_UTF8 ); + aHelpText += aGetStr; + aHelpText += String::CreateFromAscii("\n"); + } + } + else + aHelpText = String::CreateFromAscii("No Helpfile found."); + + SolHelpDlg aHelpDlg( mpBaseWin, DtSodResId( RID_SD_DIALOG_HELP )); + aHelpDlg.maMLEHelp.SetText( aHelpText ); + aHelpDlg.maMLEHelp.SetReadOnly(); + aHelpDlg.maMLEHelp.EnableFocusSelectionHide( TRUE ); + aHelpDlg.Execute(); +} + +/*****************************************************************************/ +void SolDep::test() +/*****************************************************************************/ +{ + FileDialog aTestDlg( mpBaseWin, WB_STDDIALOG ); + aTestDlg.SetDefaultExt( String::CreateFromAscii( "lst" )); + + if ( aTestDlg.Execute() ) + { + WarningBox aBox( mpBaseWin, WB_OK, aTestDlg.GetPath()); + aBox.Execute(); + } +} + + diff --git a/soldep/source/soldlg.cxx b/soldep/source/soldlg.cxx new file mode 100644 index 000000000000..db5cc52b3c9f --- /dev/null +++ b/soldep/source/soldlg.cxx @@ -0,0 +1,254 @@ +/************************************************************************* + * + * $RCSfile: soldlg.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:48:16 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#include +#include "depper.hxx" +#include "soldlg.hxx" +#include "soldlg.hrc" + +#ifndef SOLARIS +#define SIZE( nX, nY) \ + LogicToLogic(Size(##nX,##nY),&MapMode(MAP_APPFONT),&GetMapMode()) +#define POS(nX, nY) \ + LogicToLogic(Point(##nX,##nY),&MapMode(MAP_APPFONT),&GetMapMode()) +#else +#define SIZE( nX, nY) \ + LogicToLogic(Size(##nX,##nY),MapMode(MAP_APPFONT),GetMapMode()) +#define POS(nX, nY) \ + LogicToLogic(Point(##nX,##nY),MapMode(MAP_APPFONT),GetMapMode()) +#endif +// +// class SolNewProjectDlg +// + +/*****************************************************************************/ +SolNewProjectDlg::SolNewProjectDlg( Window* pParent, const ResId& rResId ) +/*****************************************************************************/ + : ModalDialog( pParent, rResId ), + maOkButton( this, DtSodResId( BTN_OK )), + maCancelButton( this, DtSodResId( BTN_CANCEL )), + maFTName( this, DtSodResId( FT_PRJNAME )), + maEName( this, DtSodResId( EDIT_PRJNAME )), + maFTShort( this, DtSodResId( FT_PRJSHORT )), + maEShort( this, DtSodResId( EDIT_PRJSHORT )), + maFTDeps( this, DtSodResId( FT_PRJDEPS )), + maEDeps( this, DtSodResId( EDIT_PRJDEPS )) +{ + FreeResource(); + maOkButton.SetClickHdl( LINK( this, SolNewProjectDlg, OkHdl )); + maCancelButton.SetClickHdl( LINK( this, SolNewProjectDlg, CancelHdl )); +} + +/*****************************************************************************/ +IMPL_LINK( SolNewProjectDlg, OkHdl, Button*, pOkBtn ) +/*****************************************************************************/ +{ + EndDialog( 1 ); + return 0; +} + +/*****************************************************************************/ +IMPL_LINK( SolNewProjectDlg, CancelHdl, Button*, pCancelBtn ) +/*****************************************************************************/ +{ + EndDialog( 0 ); + return 0; +} + +// +// class SolNewDirectoryDlg +// + +/*****************************************************************************/ +SolNewDirectoryDlg::SolNewDirectoryDlg( Window* pParent, const ResId& rResId ) +/*****************************************************************************/ + : ModalDialog( pParent, rResId ), + maOkButton( this, DtSodResId( BTN_OK )), + maCancelButton( this, DtSodResId( BTN_CANCEL )), + maFTName( this, DtSodResId( FT_DIRNAME )), + maEName( this, DtSodResId( EDIT_DIRNAME )), + maFTFlag( this, DtSodResId( FT_DIRFLAG )), + maEFlag( this, DtSodResId( EDIT_DIRFLAG )), + maFTDeps( this, DtSodResId( FT_DIRDEPS )), + maEDeps( this, DtSodResId( EDIT_DIRDEPS )), + maFTAction( this, DtSodResId( FT_DIRACTION )), + maEAction( this, DtSodResId( EDIT_DIRACTION )), + maFTEnv( this, DtSodResId( FT_DIRENV )), + maEEnv( this, DtSodResId( EDIT_DIRENV )) +{ + FreeResource(); + maOkButton.SetClickHdl( LINK( this, SolNewDirectoryDlg, OkHdl )); + maCancelButton.SetClickHdl( LINK( this, SolNewDirectoryDlg, CancelHdl )); +} + +/*****************************************************************************/ +IMPL_LINK( SolNewDirectoryDlg, OkHdl, Button*, pOkBtn ) +/*****************************************************************************/ +{ + EndDialog( 1 ); + return 0; +} + +/*****************************************************************************/ +IMPL_LINK( SolNewDirectoryDlg, CancelHdl, Button*, pCancelBtn ) +/*****************************************************************************/ +{ + EndDialog( 0 ); + return 0; +} + +// +// class SolHelpDlg +// + +/*****************************************************************************/ +SolHelpDlg::SolHelpDlg( Window* pParent, const ResId& rResId ) +/*****************************************************************************/ + : ModalDialog( pParent, rResId ), + maOkButton( this, DtSodResId( BTN_OK )), + maMLEHelp( this, DtSodResId( EDIT_HELP )) +{ + FreeResource(); + maOkButton.SetClickHdl( LINK( this, SolHelpDlg, OkHdl )); +} + +/*****************************************************************************/ +IMPL_LINK( SolHelpDlg, OkHdl, Button*, pOkBtn ) +/*****************************************************************************/ +{ + EndDialog( 1 ); + return 0; +} + +// +// class SolSelectVersionDlg +// + +/*****************************************************************************/ +SolSelectVersionDlg::SolSelectVersionDlg( + Window *pParent, GenericInformationList *pStandLst ) +/*****************************************************************************/ + : ModalDialog( pParent, DtSodResId( DLG_VERSIONSELECT )), + maVersionListBox( this, DtSodResId( DLG_VERSIONSELECT_LISTBOX )), + maVersionGroupBox( this, DtSodResId( DLG_VERSIONSELECT_GROUP )), + maOKButton( this, DtSodResId( DLG_VERSIONSELECT_OK )), + maCancelButton( this, DtSodResId( DLG_VERSIONSELECT_CANCEL )) +{ + FreeResource(); + + for ( ULONG i = 0; i < pStandLst->Count(); i++ ) { + String sVersion( *pStandLst->GetObject( i ), RTL_TEXTENCODING_ASCII_US ); + maVersionListBox.InsertEntry( sVersion ); + } + + if ( pStandLst->Count()) + maVersionListBox.SelectEntryPos( 0 ); + + maVersionListBox.SetDoubleClickHdl( + LINK( this, SolSelectVersionDlg, DoubleClickHdl )); +} + +/*****************************************************************************/ +ByteString SolSelectVersionDlg::GetVersion() +/*****************************************************************************/ +{ + ByteString sReturn( + maVersionListBox.GetSelectEntry(), RTL_TEXTENCODING_ASCII_US ); + + return sReturn; +} + +/*****************************************************************************/ +IMPL_LINK( SolSelectVersionDlg, DoubleClickHdl, ListBox *, pBox ) +/*****************************************************************************/ +{ + EndDialog( RET_OK ); + return 0; +} + +// +// class SolAutoarrangeDlg +// + +/*****************************************************************************/ +SolAutoarrangeDlg::SolAutoarrangeDlg( Window *pParent ) +/*****************************************************************************/ + : ModelessDialog( pParent, DtSodResId( DLG_AUTOARRANGE )), + maGroupBox( this, DtSodResId( DLG_AUTOARRANGE_GROUP )), + maModuleText( this, DtSodResId( DLG_AUTOARRANGE_TEXT_MODULE )), + maOverallText( this, DtSodResId( DLG_AUTOARRANGE_TEXT_OVERALL )), + maModuleBar( this ), + maOverallBar( this ) +{ + FreeResource(); + + maModuleBar.SetPosPixel( POS( 8, 28 )); + maOverallBar.SetPosPixel( POS( 8, 60 )); + maModuleBar.SetSizePixel( SIZE( 208,12 )); + maOverallBar.SetSizePixel( SIZE( 208,12 )); + + maModuleBar.Show(); + maOverallBar.Show(); + + maModuleText.Show(); + maOverallText.Show(); +} diff --git a/soldep/source/soldlg.src b/soldep/source/soldlg.src new file mode 100644 index 000000000000..0c0608dde9bf --- /dev/null +++ b/soldep/source/soldlg.src @@ -0,0 +1,247 @@ +/************************************************************************* + * + * $RCSfile: soldlg.src,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obo $ $Date: 2004-02-26 14:51:54 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#include +#include "soldlg.hrc" + +//======================================================================== +// Dialogs +ModalDialog RID_SD_DIALOG_NEWPROJECT +{ + OutputSize = TRUE; + Text = "New Project"; + PosSize = MAP_SYSFONT(18,18,142,142); + SVLook = TRUE; + MOVEABLE = TRUE; + CLOSEABLE = TRUE; + OKButton BTN_OK + { + PosSize = MAP_SYSFONT(5,123,40,14); + TabStop = TRUE; + Hide = FALSE; + DefButton = TRUE; + }; + CancelButton BTN_CANCEL { + PosSize = MAP_SYSFONT(50,123,40,14); + TabStop = TRUE; + }; + FixedText FT_PRJNAME { + PosSize = MAP_SYSFONT( 5, 10, 100, 10 ); + Text = "Project Name"; + }; + Edit EDIT_PRJNAME { + Border = TRUE; + PosSize = MAP_SYSFONT(5,20,132,10); + }; + FixedText FT_PRJSHORT { + PosSize = MAP_SYSFONT( 5, 30, 100, 10 ); + Text = "Project Short Name"; + }; + Edit EDIT_PRJSHORT { + Border = TRUE; + PosSize = MAP_SYSFONT(5,40,132,10); + }; + FixedText FT_PRJDEPS { + PosSize = MAP_SYSFONT( 5, 50, 100, 10 ); + Text = "Project Depends on"; + }; + Edit EDIT_PRJDEPS { + Border = TRUE; + PosSize = MAP_SYSFONT(5,60,132,10); + }; +}; + +ModalDialog RID_SD_DIALOG_NEWDIRECTORY +{ + OutputSize = TRUE; + Text = "New Directory"; + PosSize = MAP_SYSFONT(18,18,142,142); + SVLook = TRUE; + MOVEABLE = TRUE; + CLOSEABLE = TRUE; + OKButton BTN_OK + { + PosSize = MAP_SYSFONT(5,123,40,14); + TabStop = TRUE; + Hide = FALSE; + DefButton = TRUE; + }; + CancelButton BTN_CANCEL { + PosSize = MAP_SYSFONT(50,123,40,14); + TabStop = TRUE; + }; + FixedText FT_DIRNAME { + PosSize = MAP_SYSFONT( 5, 10, 132, 10 ); + Text = "Directory Name ( with projectname )"; + }; + Edit EDIT_DIRNAME { + Border = TRUE; + PosSize = MAP_SYSFONT(5,20,132,10); + }; + FixedText FT_DIRFLAG { + PosSize = MAP_SYSFONT( 5, 30, 100, 10 ); + Text = "Directory Flag"; + }; + Edit EDIT_DIRFLAG { + Border = TRUE; + PosSize = MAP_SYSFONT(5,40,132,10); + }; + FixedText FT_DIRDEPS { + PosSize = MAP_SYSFONT( 5, 50, 100, 10 ); + Text = "Directory Depends on"; + }; + Edit EDIT_DIRDEPS { + Border = TRUE; + PosSize = MAP_SYSFONT(5,60,132,10); + }; + FixedText FT_DIRACTION { + PosSize = MAP_SYSFONT( 5, 70, 100, 10 ); + Text = "What To Do"; + }; + Edit EDIT_DIRACTION { + Border = TRUE; + PosSize = MAP_SYSFONT(5,80,132,10); + }; + FixedText FT_DIRENV { + PosSize = MAP_SYSFONT( 5, 90, 100, 10 ); + Text = "Which Environments"; + }; + Edit EDIT_DIRENV { + Border = TRUE; + PosSize = MAP_SYSFONT(5,100,132,10); + }; +}; + + +ModalDialog RID_SD_DIALOG_HELP +{ + OutputSize = TRUE; + Text = "Help"; + PosSize = MAP_SYSFONT(18,18,242,242); + SVLook = TRUE; + MOVEABLE = TRUE; + CLOSEABLE = TRUE; + OKButton BTN_OK + { + PosSize = MAP_SYSFONT(101,223,40,14); + TabStop = TRUE; + Hide = FALSE; + DefButton = TRUE; + }; + MultiLineEdit EDIT_HELP { + Border = TRUE; + PosSize = MAP_SYSFONT(5,5,232,213); + }; +}; + +ModalDialog DLG_VERSIONSELECT { + OutputSize = TRUE; + Pos = MAP_APPFONT( 92, 40 ); + Size = MAP_APPFONT( 161, 98 ); + Text = "Open workspace"; + Moveable = TRUE; + Closeable = TRUE; + ListBox DLG_VERSIONSELECT_LISTBOX { + Border = TRUE; + Pos = MAP_APPFONT( 8, 16 ); + Size = MAP_APPFONT( 96, 72 ); + TabStop = TRUE; + }; + GroupBox DLG_VERSIONSELECT_GROUP { + Pos = MAP_APPFONT( 4, 4 ); + Size = MAP_APPFONT( 104, 88 ); + Text = "Workspaces"; + }; + OKButton DLG_VERSIONSELECT_OK { + Pos = MAP_APPFONT( 116, 64 ); + Size = MAP_APPFONT( 40, 12 ); + TabStop = TRUE; + }; + CancelButton DLG_VERSIONSELECT_CANCEL { + Pos = MAP_APPFONT( 116, 80 ); + Size = MAP_APPFONT( 40, 12 ); + TabStop = TRUE; + }; +}; + +ModelessDialog DLG_AUTOARRANGE { + OutputSize = TRUE; + Pos = MAP_APPFONT( 40, 12 ); + Size = MAP_APPFONT( 225, 82 ); + Text = "Autoarrange"; + Moveable = TRUE; + GroupBox DLG_AUTOARRANGE_GROUP { + Pos = MAP_APPFONT( 4, 4 ); + Size = MAP_APPFONT( 216, 72 ); + Text = "Progress"; + }; + FixedText DLG_AUTOARRANGE_TEXT_MODULE { + Pos = MAP_APPFONT( 8, 16 ); + Size = MAP_APPFONT( 208, 10 ); + Text = ""; + }; + FixedText DLG_AUTOARRANGE_TEXT_OVERALL { + Pos = MAP_APPFONT( 8, 48 ); + Size = MAP_APPFONT( 208, 10 ); + Text = ""; + }; +}; + -- cgit