1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include <tools/debug.hxx> 25 26 #include <soldep/depwin.hxx> 27 #include <soldep/depper.hxx> 28 #include <soldep/connctr.hxx> 29 #include <soldep/objwin.hxx> 30 31 Bitmap* pWinCopy; 32 33 DepWin::DepWin( Window* pParent, WinBits nWinStyle ) : 34 Window( pParent, nWinStyle ), 35 mbStartNewCon( sal_False ), 36 maNewConStart( 0, 0 ), 37 maNewConEnd( 0, 0 ) 38 // mpSelectedProject( NULL ) unbekannt 39 // mpCapturer( NULL ) 40 { 41 if ( !pParent->IsChildNotify() ) 42 pParent->EnableChildNotify( sal_True ); 43 // if ( !pParent->IsAllResizeEnabled()) 44 // pParent->EnableAllResize( sal_True ); 45 SetUpdateMode( sal_True ); 46 SetPosSizePixel( Point(0,0), Size( 2000, 2000 )); //Size of the scrollable Window 47 mpPopup = new PopupMenu(); 48 } 49 50 DepWin::~DepWin() 51 { 52 Hide(); 53 while( ConList.Count() > 0 ) 54 { 55 delete ConList.GetObject( 0 ); 56 } 57 // if ( mpPopup ) 58 /// delete mpPopup; 59 } 60 61 void DepWin::AddConnector( Connector* pNewCon ) 62 { 63 ConList.Insert( pNewCon ); 64 } 65 66 void DepWin::RemoveConnector( Connector* pOldCon ) 67 { 68 ConList.Remove( pOldCon ); 69 } 70 71 void DepWin::NewConnector( ObjectWin* pWin ) 72 { 73 if ( !mbStartNewCon ) 74 { 75 mpNewConWin = pWin; 76 mbStartNewCon = sal_True; 77 maNewConStart = pWin->GetFixPoint(Point(0,0)); 78 } 79 else 80 { 81 Invalidate( Rectangle( maNewConStart, maNewConEnd )); 82 if ( pWin != mpNewConWin ) 83 { 84 // Connector* pConctr; 85 // pConctr = new Connector( this, WB_NOBORDER ); 86 // pConctr->Initialize( mpNewConWin, pWin ); 87 88 // AddConnector has been moved to soldep 89 // mpDepperDontuseme->AddConnector( mpNewConWin, pWin ); 90 } 91 mpNewConWin = 0L; 92 mbStartNewCon = sal_False; 93 } 94 95 } 96 97 void DepWin::Paint( const Rectangle& rRect ) 98 { 99 sal_uIntPtr i = 0; 100 sal_uIntPtr nListCount = ConList.Count(); 101 102 for ( i=0 ; i < nListCount ; i++ ) 103 { 104 ConList.GetObject( i )->Paint( aEmptyRect ); 105 } 106 if ( mbStartNewCon ) 107 { 108 DrawLine( maNewConStart, maNewConEnd ); 109 } 110 } 111 112 void DepWin::DrawOutput( OutputDevice* pDevice, const Point& rOffset ) 113 { 114 sal_uIntPtr i = 0; 115 sal_uIntPtr nListCount = ConList.Count(); 116 117 for ( i=0 ; i < nListCount ; i++ ) 118 { 119 ConList.GetObject( i )->DrawOutput( pDevice, rOffset ); 120 } 121 if ( mbStartNewCon ) 122 { 123 pDevice->DrawLine( maNewConStart, maNewConEnd ); 124 } 125 } 126 127 void DepWin::MouseButtonUp( const MouseEvent& rMEvt ) 128 { 129 if ( rMEvt.IsRight() ) 130 { 131 mpPopup->Execute( this, rMEvt.GetPosPixel()); 132 } 133 } 134 135 void DepWin::MouseMove( const MouseEvent& rMEvt ) 136 { 137 if ( mbStartNewCon ) 138 { 139 Invalidate( Rectangle( maNewConStart, maNewConEnd )); 140 maNewConEnd = PixelToLogic(rMEvt.GetPosPixel()); 141 maNewConStart = mpNewConWin->GetFixPoint( maNewConEnd ); 142 } 143 } 144 145 146 ConnectorList* DepWin::GetConnectorList() 147 { 148 return &ConList; 149 } 150 151 void DepWin::SetPopupHdl( void* pHdl ) 152 { 153 mpPopup->SetSelectHdl( LINK( pHdl, Depper, PopupSelected )); 154 } 155 156 void DepWin::Command( const CommandEvent& rEvent) 157 { 158 //mpDepperDontuseme->GetGraphWin()->Command( rEvent ); 159 GetParent()->Command( rEvent ); 160 } 161