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/list.hxx>
25 #include <tools/debug.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/help.hxx>
28 #include <vcl/wall.hxx>
29
30 #include <soldep/objwin.hxx>
31 #include <soldep/depwin.hxx>
32 //#include "depapp.hxx"
33 #include <soldep/depper.hxx>
34 //#include "prjdep.hxx"
35 #include <soldep/connctr.hxx>
36 #include <stdio.h>
37
38 static Color aDefaultColor = 0L;
39 static Wallpaper* pDefaultWallpaper = 0L;
40
41 // Initialize static class member
42 sal_Bool ObjectWin::msbHideMode = sal_False;
43 sal_uIntPtr ObjectWin::msnGlobalViewMask = 0;
44
45
46 sal_uInt32 aColorMap[] = {
47 RGB_COLORDATA( 0xFF, 0xFF, 0x80 ), //MARKMODE_DEFAULT 0
48 COL_GREEN, //MARKMODE_DEPENDING 1
49 COL_RED, //MARKMODE_NEEDED 2
50 COL_MAGENTA, //1+2
51 COL_GRAY, //MARKMODE_ACTIVATED 4
52 COL_LIGHTGREEN, //1+4
53 COL_LIGHTRED, //2+4
54 COL_LIGHTMAGENTA, //1+2+4
55 COL_BLUE, //MARKMODE_SELECTED 8
56 COL_LIGHTGRAY, //1+8
57 COL_CYAN, //2+8
58 COL_LIGHTCYAN, //1+2+8
59 COL_LIGHTBLUE, //4+8
60 COL_BROWN, //1+4+8
61 COL_BLACK, //2+4+8
62 COL_BLUE //1+2+4+8
63 };
64
65
66 //
67 // class ObjectWin
68 //
69
70 /*****************************************************************************/
ObjectWin(Window * pParent,WinBits nWinStyle)71 ObjectWin::ObjectWin( Window* pParent, WinBits nWinStyle )
72 /*****************************************************************************/
73 : Window( pParent, nWinStyle ),
74 msBodyText( "" ),
75 msTipText( "" ),
76 mnObjectId( 0 ),
77 mnMarkMode( 0 ),
78 mnViewMask( 0 ),
79 mbVisible( sal_False ),
80 mbMenuExecute( sal_False ),
81 mbVisited( sal_False ),
82 mnRootDist( 0 ),
83 mnHeadDist( 0 ),
84 mbFixed( sal_False )
85 {
86 SetBackground( Wallpaper( aColorMap[0] ));
87
88 aTipTimer.SetTimeout( 500 );
89 aTipTimer.SetTimeoutHdl(
90 LINK( this, ObjectWin, TipHdl ));
91
92 SetFont( Font( GetFont() ) );
93 Font aFont( GetFont() );
94 Size aSize = aFont.GetSize();
95 aFont.SetSize( aSize );
96 SetFont( aFont );
97
98 EnableClipSiblings();
99 SetZOrder( NULL, WINDOW_ZORDER_FIRST );
100 mpPopup = new PopupMenu();
101 mpPopup->InsertItem( OBJWIN_EDIT_TEXT, String::CreateFromAscii( "Details" ));
102 mpPopup->InsertItem( OBJWIN_ADD_CONNECTOR, String::CreateFromAscii( "New connection" ));
103 mpPopup->InsertItem( OBJWIN_REMOVE_WIN, String::CreateFromAscii( "Remove object" ));
104 mpPopup->InsertItem( OBJWIN_VIEW_CONTENT, String::CreateFromAscii( "View content" ));
105 // mpPopup->InsertSeparator();
106 mpPopup->SetSelectHdl( LINK( this, ObjectWin, PopupSelected ));
107 mpPopup->SetDeactivateHdl( LINK( this, ObjectWin, PopupDeactivated ));
108 mnPopupStaticItems = mpPopup->GetItemCount();
109
110 if ( ! pDefaultWallpaper )
111 {
112 pDefaultWallpaper = new Wallpaper( GetBackground() );
113 aDefaultColor = GetTextColor();
114 }
115 Hide();
116 }
117
118 /*****************************************************************************/
~ObjectWin()119 ObjectWin::~ObjectWin()
120 /*****************************************************************************/
121 {
122 while ( mConnections.Count() > 0 )
123 {
124 delete mConnections.GetObject( 0 );
125 }
126 }
127
SetHideMode(sal_Bool bHide)128 void ObjectWin::SetHideMode(sal_Bool bHide)
129 {
130 msbHideMode = bHide;
131 mConnections.GetObject(0)->SetHideMode(msbHideMode);
132 }
133
ToggleHideMode()134 sal_Bool ObjectWin::ToggleHideMode()
135 {
136 msbHideMode = !msbHideMode;
137 mConnections.GetObject(0)->SetHideMode(msbHideMode);
138 return msbHideMode;
139 }
140
141 /*****************************************************************************/
SetViewMask(sal_uIntPtr nMask)142 void ObjectWin::SetViewMask( sal_uIntPtr nMask )
143 /*****************************************************************************/
144 {
145 mnViewMask = nMask;
146 // Compares
147 if ( mnViewMask & msnGlobalViewMask) {
148 mbVisible = sal_True;
149 Show();
150 }
151 else {
152 Hide();
153 mbVisible = sal_False;
154 }
155 for ( sal_uIntPtr i = 0; i < mConnections.Count(); i++ )
156 mConnections.GetObject( i )->UpdateVisibility();
157 }
158
159 /*****************************************************************************/
SetBodyText(const ByteString & rNewString)160 void ObjectWin::SetBodyText( const ByteString& rNewString )
161 /*****************************************************************************/
162 {
163 msBodyText = rNewString;
164 }
165
166 /*****************************************************************************/
GetBodyText()167 ByteString& ObjectWin::GetBodyText()
168 /*****************************************************************************/
169 {
170 return msBodyText;
171 }
172
173 /*****************************************************************************/
SetTipText(const ByteString & rNewString)174 void ObjectWin::SetTipText( const ByteString& rNewString )
175 /*****************************************************************************/
176 {
177 msTipText = rNewString;
178 }
179
180 /*****************************************************************************/
GetTipText()181 ByteString& ObjectWin::GetTipText()
182 /*****************************************************************************/
183 {
184 return msTipText;
185 }
186
187 /*****************************************************************************/
GetFixPoint(const Point & rRefPoint,sal_Bool bUseRealPos)188 Point ObjectWin::GetFixPoint( const Point& rRefPoint, sal_Bool bUseRealPos )
189 /*****************************************************************************/
190 {
191 Point aLocalPoint;
192 if ( bUseRealPos )
193 aLocalPoint = GetPosPixel();
194 else
195 aLocalPoint = GetCalcPosPixel();
196
197 Size aLocalSize = GetSizePixel();
198 Point aRetPoint;
199
200 sal_uInt16 nRefX = aLocalPoint.X() + aLocalSize.Width() / 2 ;
201 sal_uInt16 nRefY = aLocalPoint.Y() + aLocalSize.Height() / 2 ;
202
203 // always false...
204 //if ( nRefX < 0 ) nRefX = 0;
205 //if ( nRefY < 0 ) nRefY = 0;
206
207 if ( rRefPoint.X() > nRefX )
208 {
209 if ( rRefPoint.Y() > nRefY )
210 {
211 if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY ))
212 {
213 aRetPoint.X() = aLocalPoint.X() + aLocalSize.Width();
214 aRetPoint.Y() = nRefY;
215 }
216 else
217 {
218 aRetPoint.X() = nRefX;
219 aRetPoint.Y() = aLocalPoint.Y() + aLocalSize.Height();
220 }
221 }
222 else
223 {
224 if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY ))
225 {
226 aRetPoint.X() = aLocalPoint.X() + aLocalSize.Width();
227 aRetPoint.Y() = nRefY;
228 }
229 else
230 {
231 aRetPoint.X() = nRefX;
232 aRetPoint.Y() = aLocalPoint.Y();
233 }
234 }
235 }
236 else
237 {
238 if ( rRefPoint.Y() > nRefY )
239 {
240 if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY ))
241 {
242 aRetPoint.X() = aLocalPoint.X();
243 aRetPoint.Y() = nRefY;
244 }
245 else
246 {
247 aRetPoint.X() = nRefX;
248 aRetPoint.Y() = aLocalPoint.Y() + aLocalSize.Height();
249 }
250 }
251 else
252 {
253 if ( Abs( rRefPoint.X() - nRefX ) > Abs( rRefPoint.Y() - nRefY ))
254 {
255 aRetPoint.X() = aLocalPoint.X();
256 aRetPoint.Y() = nRefY;
257 }
258 else
259 {
260 aRetPoint.X() = nRefX;
261 aRetPoint.Y() = aLocalPoint.Y();
262 }
263 }
264 }
265
266 return PixelToLogic(aRetPoint);
267
268 }
269
270 /*****************************************************************************/
AddConnector(Connector * pNewCon)271 void ObjectWin::AddConnector( Connector* pNewCon )
272 /*****************************************************************************/
273 {
274 mConnections.Insert( pNewCon );
275 }
276
277 /*****************************************************************************/
ConnectionExistsInAnyDirection(ObjectWin * pWin)278 sal_Bool ObjectWin::ConnectionExistsInAnyDirection( ObjectWin *pWin )
279 /*****************************************************************************/
280 {
281 for ( sal_uIntPtr i = 0; i < mConnections.Count(); i++ )
282 if ( mConnections.GetObject( i )->GetOtherWin( this ) == pWin )
283 return sal_True;
284
285 return sal_False;
286 }
287
288 /*****************************************************************************/
RemoveConnector(Connector * pOldCon)289 void ObjectWin::RemoveConnector( Connector* pOldCon )
290 /*****************************************************************************/
291 {
292 mConnections.Remove( pOldCon );
293 }
294
295 /*****************************************************************************/
GetConnector(sal_uIntPtr nIndex)296 Connector* ObjectWin::GetConnector( sal_uIntPtr nIndex )
297 /*****************************************************************************/
298 {
299 sal_uIntPtr nConCount = mConnections.Count();
300
301 if ( nIndex < nConCount )
302 return mConnections.GetObject( nIndex );
303 return NULL;
304 }
305
306 /*****************************************************************************/
GetConnector(sal_uIntPtr nStartId,sal_uIntPtr nEndId)307 Connector* ObjectWin::GetConnector( sal_uIntPtr nStartId, sal_uIntPtr nEndId )
308 /*****************************************************************************/
309 {
310 if ( mnObjectId != nStartId )
311 return NULL;
312
313 sal_uInt16 i;
314 Connector* pCon;
315 sal_uIntPtr nConCount = mConnections.Count();
316
317 for ( i = 0; i < nConCount; i++ )
318 {
319 pCon = mConnections.GetObject( i );
320 if ( pCon->GetOtherWin( this )->GetId() == nEndId )
321 return pCon;
322 }
323 return NULL;
324 }
325
SetAllConnectorsUnvisible()326 void ObjectWin::SetAllConnectorsUnvisible()
327 {
328 Connector* pCon;
329 sal_uIntPtr nConCount = mConnections.Count();
330 for ( sal_uIntPtr i = 0; i < nConCount; i++ )
331 {
332 pCon = mConnections.GetObject( i );
333 if (pCon) pCon->SetVisibility( sal_False );
334 }
335 }
336
337 /*****************************************************************************/
SetMarkMode(sal_uIntPtr nMarkMode)338 void ObjectWin::SetMarkMode( sal_uIntPtr nMarkMode )
339 /*****************************************************************************/
340 {
341 //Wallpaper aWallpaper;
342
343 if ( nMarkMode == MARKMODE_DEFAULT )
344 {
345 if ( pDefaultWallpaper )
346 {
347 maObjWallpaper = GetBackground();
348 maObjWallpaper.SetColor( pDefaultWallpaper->GetColor() );
349 SetBackground( maObjWallpaper );
350 SetTextColor( aDefaultColor );
351 }
352 }
353 else
354 {
355 mnMarkMode |= nMarkMode;
356 maObjWallpaper = GetBackground();
357 maObjWallpaper.SetColor( aColorMap[ mnMarkMode ] );
358 SetBackground( maObjWallpaper );
359 SetTextColor( COL_WHITE );
360 }
361
362 Invalidate();
363 }
364
365 /*****************************************************************************/
UnsetMarkMode(sal_uIntPtr nMarkMode)366 void ObjectWin::UnsetMarkMode( sal_uIntPtr nMarkMode )
367 /*****************************************************************************/
368 {
369 //Wallpaper aWallpaper;
370
371 sal_uIntPtr nOldMode = mnMarkMode;
372 mnMarkMode &= ( !nMarkMode );
373
374 if ( nOldMode != mnMarkMode ) {
375 if ( mnMarkMode == MARKMODE_DEFAULT )
376 {
377 if ( pDefaultWallpaper )
378 {
379 maObjWallpaper = GetBackground();
380 maObjWallpaper.SetColor( pDefaultWallpaper->GetColor() );
381 SetBackground( maObjWallpaper );
382 SetTextColor( aDefaultColor );
383 }
384 }
385 else
386 {
387 maObjWallpaper = GetBackground();
388 maObjWallpaper.SetColor( aColorMap[ mnMarkMode ] ); //mnMarkMode
389 SetBackground( maObjWallpaper );
390 SetTextColor( COL_WHITE );
391 }
392 Invalidate();
393 }
394 }
395
396 /*****************************************************************************/
MarkNeeded(sal_Bool bReset)397 void ObjectWin::MarkNeeded( sal_Bool bReset )
398 /*****************************************************************************/
399 {
400 Connector* pCon;
401 ObjectWin* pWin;
402
403 sal_uIntPtr nConCount = mConnections.Count();
404 sal_uIntPtr i;
405
406 for ( i = 0; i < nConCount; i++ )
407 {
408 pCon = mConnections.GetObject( i );
409 if ( pCon && !pCon->IsStart( this))
410 {
411 pWin = pCon->GetOtherWin( this );
412 if ( pWin )
413 {
414 if ( bReset )
415 pWin->UnsetMarkMode( MARKMODE_NEEDED );
416 else
417 pWin->SetMarkMode( MARKMODE_NEEDED );
418 pWin->MarkNeeded( bReset ); // recursive call
419 }
420 }
421 }
422 }
423
424 /*****************************************************************************/
MarkDepending(sal_Bool bReset)425 void ObjectWin::MarkDepending( sal_Bool bReset )
426 /*****************************************************************************/
427 {
428 //if ( !bReset )
429 // return;
430
431 Connector* pCon;
432 ObjectWin* pWin;
433
434 sal_uIntPtr nConCount = mConnections.Count();
435 sal_uIntPtr i;
436
437 for ( i = 0; i < nConCount; i++ )
438 {
439 pCon = mConnections.GetObject( i );
440 if ( pCon && pCon->IsStart( this) )
441 {
442 pWin = pCon->GetOtherWin( this );
443 if ( pWin )
444 {
445 if ( bReset )
446 pWin->UnsetMarkMode( MARKMODE_DEPENDING );
447 else
448 pWin->SetMarkMode( MARKMODE_DEPENDING );
449 pWin->MarkDepending( bReset ); // recursive call
450 }
451 }
452 }
453 }
454
455 /*****************************************************************************/
Paint(const Rectangle & rRect)456 void ObjectWin::Paint( const Rectangle& rRect )
457 /*****************************************************************************/
458 {
459 Size aWinSize = PixelToLogic( GetOutputSizePixel() );
460 Size aTextSize;
461 ByteString sbt = msBodyText; //debug
462 //sbt += " "; //debug
463 //sbt += ByteString::CreateFromInt32(mnMarkMode); //debug
464 aTextSize.Width() = GetTextWidth( String( msBodyText, RTL_TEXTENCODING_UTF8 ));
465 aTextSize.Height() = GetTextHeight();
466 Point aPos( aWinSize.Width() / 2 - aTextSize.Width() / 2,
467 aWinSize.Height() / 2 - aTextSize.Height() / 2 );
468
469 //DrawText( aPos , String( sBodyText, RTL_TEXTENCODING_UTF8 ));
470 if (msBodyText =="null") //don't paint this "window"
471 {
472 Hide();
473 Invalidate();
474 } else
475 DrawText( aPos , String( sbt, RTL_TEXTENCODING_UTF8 )); //debug
476 }
477
DrawOutput(OutputDevice * pDevice,const Point & rOffset)478 void ObjectWin::DrawOutput( OutputDevice* pDevice, const Point& rOffset )
479 /*****************************************************************************/
480 {
481 Size aWinSize = PixelToLogic( GetSizePixel() );
482 Size aTextSize;
483 ByteString sbt = msBodyText;
484 aTextSize.Width() = GetTextWidth( String( msBodyText, RTL_TEXTENCODING_UTF8 ));
485 aTextSize.Height() = GetTextHeight();
486 Point aPos = GetPosPixel();
487 Point aTextPos( aWinSize.Width() / 2 - aTextSize.Width() / 2,
488 aWinSize.Height() / 2 - aTextSize.Height() / 2 );
489 aTextPos += aPos;
490 aPos = pDevice->PixelToLogic( aPos ) - rOffset;
491 aTextPos = pDevice->PixelToLogic( aTextPos ) - rOffset;
492 if ( msBodyText !="null" )
493 {
494 pDevice->SetFillColor( GetBackground().GetColor() );
495 pDevice->DrawRect( Rectangle( aPos, pDevice->PixelToLogic( GetSizePixel() ) ) );
496 Font aFont( GetFont() );
497 Size aSize = aFont.GetSize();
498 aSize = pDevice->PixelToLogic( aSize );
499 aFont.SetSize( aSize );
500 pDevice->SetFont( aFont );
501 pDevice->SetTextColor( GetTextColor() );
502 pDevice->DrawText( aTextPos, String( sbt, RTL_TEXTENCODING_UTF8 ) );
503 }
504 }
505
506 /*****************************************************************************/
MouseButtonDown(const MouseEvent & rMEvt)507 void ObjectWin::MouseButtonDown( const MouseEvent& rMEvt )
508 /*****************************************************************************/
509 {
510 //Notify Soldep to clear ObjectList
511 SetZOrder( NULL, WINDOW_ZORDER_FIRST );
512 GrabFocus();
513
514 // workaround fuer vcl-bug
515 // GetWindow( WINDOW_REALPARENT)->Invalidate();
516 // MyApp *pApp = (MyApp*)GetpApp();
517 // SolDep *pSoldep = pApp->GetSolDep();
518
519 maMouseOffset = rMEvt.GetPosPixel();
520 if ( rMEvt.IsLeft() )
521 {
522
523 if ( rMEvt.IsMod2() ) // alt + mouse click left
524 {
525 CallEventListeners( VCLEVENT_USER_MOUSEBUTTON_DOWN_ALT, this );
526 }
527 else {
528 CallEventListeners( VCLEVENT_USER_MOUSEBUTTON_DOWN, this );
529 }
530 if( rMEvt.GetClicks() == 2 )
531 CallEventListeners( VCLEVENT_USER_MOUSEBUTTON_DOWN_DBLCLICK, this );
532 else if ( !rMEvt.IsShift() && !((DepWin*)GetParent())->IsStartNewCon())
533 {
534 //((DepWin*)GetParent())->SaveSelectedObjWin(&this);
535 CaptureMouse();
536 }
537 }
538 }
539
540 /*****************************************************************************/
MouseButtonUp(const MouseEvent & rMEvt)541 void ObjectWin::MouseButtonUp( const MouseEvent& rMEvt )
542 /*****************************************************************************/
543 {
544 fprintf(stdout,"ObjectWin::MouseButtonUp\n");
545 if ( rMEvt.IsLeft() )
546 {
547 if ( rMEvt.IsShift() || ((DepWin*)GetParent())->IsStartNewCon())
548 CallEventListeners( VCLEVENT_USER_MOUSEBUTTON_UP_SHFT, this );
549 // ((DepWin*)GetParent())->NewConnector( this );
550 else
551 {
552 CallEventListeners( VCLEVENT_USER_MOUSEBUTTON_UP, this );
553 if ( IsMouseCaptured() ) ReleaseMouse();
554 }
555 }
556 else if ( rMEvt.IsRight() )
557 {
558 sal_uInt16 i;
559
560 while ( mnPopupStaticItems < mpPopup->GetItemCount() )
561 {
562 mpPopup->RemoveItem( mnPopupStaticItems );
563 }
564
565 if ( mConnections.Count()) {
566 mpPopup->InsertSeparator();
567
568 for( i = 0; i < mConnections.Count() ; i++ )
569 {
570 mpPopup->InsertItem( mnPopupStaticItems + i + 1, String( ((mConnections.GetObject( i ))->GetOtherWin( this ))->GetBodyText(), RTL_TEXTENCODING_UTF8 ));
571 }
572 }
573 mbMenuExecute = sal_True;
574 mpPopup->Execute( GetParent(), rMEvt.GetPosPixel() + GetPosPixel());
575 }
576 }
577
578 /*****************************************************************************/
MouseMove(const MouseEvent & rMEvt)579 void ObjectWin::MouseMove( const MouseEvent& rMEvt )
580 /*****************************************************************************/
581 {
582 if ( IsMouseCaptured() )
583 {
584 sal_uInt16 i;
585
586 Point aNewWinPos( GetPosPixel() + rMEvt.GetPosPixel() - maMouseOffset );
587
588 aNewWinPos.X() = Max( 0L, aNewWinPos.X());
589 aNewWinPos.Y() = Max( 0L, aNewWinPos.Y());
590 SetPosPixel( aNewWinPos );
591 //int t = mConnections.Count();
592
593 for ( i=0; i < mConnections.Count();i++)
594 {
595 mConnections.GetObject( i )->UpdatePosition( this );
596 }
597 }
598 else // !IsMouseCaptured()
599 {
600 if ( rMEvt.IsLeaveWindow() )
601 aTipTimer.Stop();
602 else
603 aTipTimer.Start();
604
605 MouseEvent aNewMEvt( rMEvt.GetPosPixel() + GetPosPixel());
606
607 GetParent()->MouseMove( aNewMEvt ); //call to DepWin::MouseMove
608 }
609 }
610
611 /*****************************************************************************/
Save(SvFileStream & rOutFile)612 sal_uInt16 ObjectWin::Save( SvFileStream& rOutFile )
613 /*****************************************************************************/
614 {
615 return 0;
616 }
617
618 /*****************************************************************************/
Load(SvFileStream & rInFile)619 sal_uInt16 ObjectWin::Load( SvFileStream& rInFile )
620 /*****************************************************************************/
621 {
622 return 0;
623 }
624
625 /*****************************************************************************/
SetId(sal_uIntPtr nId)626 void ObjectWin::SetId( sal_uIntPtr nId )
627 /*****************************************************************************/
628 {
629 mnObjectId = nId;
630 }
631
632 /*****************************************************************************/
GetId()633 sal_uIntPtr ObjectWin::GetId()
634 /*****************************************************************************/
635 {
636 return mnObjectId;
637 }
638
639 /*****************************************************************************/
UpdateConnectors()640 void ObjectWin::UpdateConnectors()
641 /*****************************************************************************/
642 {
643 sal_uInt16 i;
644
645 for ( i = 0; i < mConnections.Count(); i++ )
646 {
647 mConnections.GetObject( i )->UpdatePosition( this );
648 }
649 }
650
IMPL_LINK(ObjectWin,PopupSelected,PopupMenu *,mpPopup_l)651 IMPL_LINK( ObjectWin, PopupSelected, PopupMenu*, mpPopup_l )
652 {
653 sal_uInt16 nItemId = mpPopup_l->GetCurItemId();
654
655 switch( nItemId )
656 {
657 case OBJWIN_EDIT_TEXT :
658 DBG_ASSERT( sal_False,"edit");
659 break;
660 case OBJWIN_REMOVE_WIN :
661 // DBG_ASSERT( FALSE,"remove");
662 // DBG_ASSERT( mpDepperDontuseme,"remove");
663 //mpDepperDontuseme->RemoveObject(mpDepperDontuseme->mpObjectList, ( sal_uInt16 ) GetId());
664 break;
665 case OBJWIN_ADD_CONNECTOR :
666 // DBG_ASSERT( FALSE,"add con");
667 ((DepWin*)GetParent())->NewConnector( this );
668 break;
669 case OBJWIN_VIEW_CONTENT :
670 // DBG_ASSERT( FALSE,"view cnt");
671 // mpDepperDontuseme->ViewContent( msBodyText );
672 // TBD: CallEventListener
673 break;
674 default :
675 // DBG_ASSERT( sal_False, String (nItemId) );
676 Connector* pCon = mConnections.GetObject( nItemId - mnPopupStaticItems - 1);
677 pCon = 0;
678 // delete pCon;
679 // mpDepperDontuseme->RemoveConnector( pCon->GetStartId(), pCon->GetEndId());
680 // TBD: CallEventListener
681
682 break;
683 }
684 return 0;
685 }
686
687 /*****************************************************************************/
IMPL_LINK(ObjectWin,TipHdl,void *,EMTY_ARG)688 IMPL_LINK( ObjectWin, TipHdl, void *, EMTY_ARG )
689 /*****************************************************************************/
690 {
691 aTipTimer.Stop();
692
693 if ( msTipText.Len()) {
694 Point aPos( GetpApp()->GetAppWindow()->GetPointerPosPixel());
695 Help::ShowBalloon( GetpApp()->GetAppWindow(),
696 Point( aPos.X(), aPos.Y()),
697 String( msTipText, RTL_TEXTENCODING_UTF8 ));
698 }
699 return 0;
700 }
701
702 /*****************************************************************************/
703 //void ObjectWin::GetFocus()
704 /*****************************************************************************/
705 //{
706 //SetMarkMode( MARKMODE_SELECTED );
707 //}
708
709 /*****************************************************************************/
LoseFocus()710 void ObjectWin::LoseFocus()
711 /*****************************************************************************/
712 {
713 if ( !mbMenuExecute && !msbHideMode ) {
714 UnsetMarkMode( MARKMODE_SELECTED );
715 UnsetMarkMode( MARKMODE_ACTIVATED );
716 MarkNeeded( sal_True );
717 MarkDepending( sal_True );
718 }
719 else
720 mbMenuExecute = sal_False;
721 }
722
723 /*****************************************************************************/
IMPL_LINK(ObjectWin,PopupDeactivated,PopupMenu *,mpPopup_l)724 IMPL_LINK( ObjectWin, PopupDeactivated, PopupMenu*, mpPopup_l )
725 /*****************************************************************************/
726 {
727 mbMenuExecute = sal_False;
728
729 if ( !HasFocus()) {
730 UnsetMarkMode( MARKMODE_SELECTED );
731 UnsetMarkMode( MARKMODE_ACTIVATED );
732 MarkNeeded( sal_True );
733 MarkDepending( sal_True );
734 }
735
736 return 0;
737 }
738
739 /*****************************************************************************/
Command(const CommandEvent & rEvent)740 void ObjectWin::Command( const CommandEvent& rEvent)
741 /*****************************************************************************/
742 {
743 fprintf(stdout, "ObjectWin::Command");
744 // mpDepperDontuseme->GetGraphWin()->Command( rEvent );
745 // TBD: CallEventListener
746
747 }
748
749 /*****************************************************************************/
750 /*****************************************************************************/
751
ObjectList()752 ObjectList::ObjectList() : ObjWinList()
753 {
754 }
755
756 /*****************************************************************************/
ResetSelectedObject()757 void ObjectList::ResetSelectedObject()
758 /*****************************************************************************/
759 {
760 // return;
761
762 sal_uIntPtr nCount_l = Count();
763 ObjectWin* pObjectWin = NULL;
764 for (sal_uIntPtr i=0; i < nCount_l; i++ )
765 {
766 pObjectWin = GetObject( i );
767 pObjectWin->UnsetMarkMode( MARKMODE_SELECTED );
768 pObjectWin->UnsetMarkMode( MARKMODE_NEEDED );
769 pObjectWin->UnsetMarkMode( MARKMODE_DEPENDING );
770 pObjectWin->SetActualWallpaper(*pDefaultWallpaper);
771 pObjectWin->SetAllConnectorsUnvisible();
772 }
773 return;
774 }
775
776 /*****************************************************************************/
GetPtrByName(const ByteString & rText)777 ObjectWin* ObjectList::GetPtrByName( const ByteString& rText )
778 /*****************************************************************************/
779 {
780 sal_uIntPtr i = 0;
781 sal_uIntPtr nCount_l = Count();
782 ObjectWin* pObjectWin = NULL;
783 while ( i < nCount_l )
784 {
785 pObjectWin = GetObject( i );
786 ByteString sPrj = pObjectWin->GetBodyText();
787 if (sPrj == rText) return pObjectWin;
788 i++;
789 }
790 return 0;
791 }
792
FindTopLevelModules()793 ObjectList* ObjectList::FindTopLevelModules()
794 {
795 ObjectList* pList = new ObjectList;
796 for ( sal_uInt16 i=0; i<Count(); i++ )
797 {
798 ObjectWin* pObjectWin = GetObject( i );
799 if ( pObjectWin->IsTop() )
800 pList->Insert( pObjectWin );
801 }
802
803 return pList;
804 }
805
IsTop()806 sal_Bool ObjectWin::IsTop()
807 {
808 sal_uIntPtr nConCount = mConnections.Count();
809 for ( sal_uIntPtr i = 0; i < nConCount; i++ )
810 {
811 Connector* pCon = mConnections.GetObject( i );
812 if ( pCon && pCon->IsStart( this) )
813 return sal_False;
814 }
815
816 return sal_True;
817 }
818