1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <tools/debug.hxx> 29 30 #include <soldep/depwin.hxx> 31 #include <soldep/depper.hxx> 32 #include <soldep/connctr.hxx> 33 #include <soldep/objwin.hxx> 34 35 Bitmap* pWinCopy; 36 37 DepWin::DepWin( Window* pParent, WinBits nWinStyle ) : 38 Window( pParent, nWinStyle ), 39 mbStartNewCon( sal_False ), 40 maNewConStart( 0, 0 ), 41 maNewConEnd( 0, 0 ) 42 // mpSelectedProject( NULL ) unbekannt 43 // mpCapturer( NULL ) 44 { 45 if ( !pParent->IsChildNotify() ) 46 pParent->EnableChildNotify( sal_True ); 47 // if ( !pParent->IsAllResizeEnabled()) 48 // pParent->EnableAllResize( sal_True ); 49 SetUpdateMode( sal_True ); 50 SetPosSizePixel( Point(0,0), Size( 2000, 2000 )); //Size of the scrollable Window 51 mpPopup = new PopupMenu(); 52 } 53 54 DepWin::~DepWin() 55 { 56 Hide(); 57 while( ConList.Count() > 0 ) 58 { 59 delete ConList.GetObject( 0 ); 60 } 61 // if ( mpPopup ) 62 /// delete mpPopup; 63 } 64 65 void DepWin::AddConnector( Connector* pNewCon ) 66 { 67 ConList.Insert( pNewCon ); 68 } 69 70 void DepWin::RemoveConnector( Connector* pOldCon ) 71 { 72 ConList.Remove( pOldCon ); 73 } 74 75 void DepWin::NewConnector( ObjectWin* pWin ) 76 { 77 if ( !mbStartNewCon ) 78 { 79 mpNewConWin = pWin; 80 mbStartNewCon = sal_True; 81 maNewConStart = pWin->GetFixPoint(Point(0,0)); 82 } 83 else 84 { 85 Invalidate( Rectangle( maNewConStart, maNewConEnd )); 86 if ( pWin != mpNewConWin ) 87 { 88 // Connector* pConctr; 89 // pConctr = new Connector( this, WB_NOBORDER ); 90 // pConctr->Initialize( mpNewConWin, pWin ); 91 92 // AddConnector has been moved to soldep 93 // mpDepperDontuseme->AddConnector( mpNewConWin, pWin ); 94 } 95 mpNewConWin = 0L; 96 mbStartNewCon = sal_False; 97 } 98 99 } 100 101 void DepWin::Paint( const Rectangle& rRect ) 102 { 103 sal_uIntPtr i = 0; 104 sal_uIntPtr nListCount = ConList.Count(); 105 106 for ( i=0 ; i < nListCount ; i++ ) 107 { 108 ConList.GetObject( i )->Paint( aEmptyRect ); 109 } 110 if ( mbStartNewCon ) 111 { 112 DrawLine( maNewConStart, maNewConEnd ); 113 } 114 } 115 116 void DepWin::DrawOutput( OutputDevice* pDevice, const Point& rOffset ) 117 { 118 sal_uIntPtr i = 0; 119 sal_uIntPtr nListCount = ConList.Count(); 120 121 for ( i=0 ; i < nListCount ; i++ ) 122 { 123 ConList.GetObject( i )->DrawOutput( pDevice, rOffset ); 124 } 125 if ( mbStartNewCon ) 126 { 127 pDevice->DrawLine( maNewConStart, maNewConEnd ); 128 } 129 } 130 131 void DepWin::MouseButtonUp( const MouseEvent& rMEvt ) 132 { 133 if ( rMEvt.IsRight() ) 134 { 135 mpPopup->Execute( this, rMEvt.GetPosPixel()); 136 } 137 } 138 139 void DepWin::MouseMove( const MouseEvent& rMEvt ) 140 { 141 if ( mbStartNewCon ) 142 { 143 Invalidate( Rectangle( maNewConStart, maNewConEnd )); 144 maNewConEnd = PixelToLogic(rMEvt.GetPosPixel()); 145 maNewConStart = mpNewConWin->GetFixPoint( maNewConEnd ); 146 } 147 } 148 149 150 ConnectorList* DepWin::GetConnectorList() 151 { 152 return &ConList; 153 } 154 155 void DepWin::SetPopupHdl( void* pHdl ) 156 { 157 mpPopup->SetSelectHdl( LINK( pHdl, Depper, PopupSelected )); 158 } 159 160 void DepWin::Command( const CommandEvent& rEvent) 161 { 162 //mpDepperDontuseme->GetGraphWin()->Command( rEvent ); 163 GetParent()->Command( rEvent ); 164 } 165