00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #include "camtypes.h"
00101
00102 #include "sgldrag.h"
00103 #include "dragmgr.h"
00104 #include "dragbmp.h"
00105
00106
00107 #include "camview.h"
00108
00109
00110
00111 #include "grndbmp.h"
00112 #include "nodepath.h"
00113 #include "lineattr.h"
00114 #include "sgline.h"
00115 #include "osrndrgn.h"
00116
00117
00118
00119
00120 CC_IMPLEMENT_DYNCREATE(GalleryLineDragInfo, BitmapDragInformation)
00121 CC_IMPLEMENT_DYNAMIC(SGLineDragTarget, SGListDragTarget);
00122
00123
00124 #define new CAM_DEBUG_NEW
00125
00126
00127
00128 const LineAttrItem::TextPosition c_eLineAttrDragTextPos = LineAttrItem::NO_LABEL;
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 SGLineDragTarget::SGLineDragTarget(DialogOp *TheDialog, CGadgetID TheGadget)
00145 : SGListDragTarget(TheDialog, TheGadget)
00146 {
00147 ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(LineGallery)),
00148 "You can only use SGLineDragTargets with LineGallery dialogues!");
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 BOOL SGLineDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
00175 OilCoord *pMousePos, KeyPress* pKeyPress)
00176 {
00177 if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryLineDragInfo)))
00178 return(FALSE);
00179
00180 SGDisplayNode *DraggedNode = NULL;
00181 BOOL IsSimpleBitmapDrag = TRUE;
00182
00183 if (IS_A(pDragInfo, GalleryLineDragInfo))
00184 {
00185 DraggedNode = ((GalleryLineDragInfo *)pDragInfo)->GetDraggedLineAttr();
00186 }
00187
00188 if (DraggedNode != NULL)
00189 {
00190 switch(Event)
00191 {
00192 case DRAGEVENT_COMPLETED:
00193 HandleDragCompleted((SuperGallery *) TargetDialog,
00194 DraggedNode, pMousePos, IsSimpleBitmapDrag);
00195 return(TRUE);
00196
00197
00198 case DRAGEVENT_MOUSESTOPPED:
00199 case DRAGEVENT_MOUSEMOVED:
00200 case DRAGEVENT_MOUSEIDLE:
00201
00202 return(DetermineCursorShape((SuperGallery *) TargetDialog,
00203 DraggedNode, pMousePos));
00204 default:
00205 break;
00206 }
00207 }
00208
00209
00210 return(FALSE);
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 GalleryLineDragInfo::GalleryLineDragInfo()
00225 {
00226 ERROR3("Default GalleryLineDragInfo constructor called");
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 GalleryLineDragInfo::GalleryLineDragInfo(LineAttrItem *pSourceItem,
00250 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00251 BOOL IsAdjust)
00252 : BitmapDragInformation(NULL, 100,50,0,0,
00253 IsAdjust)
00254 {
00255 SourceItem = pSourceItem;
00256
00257 pAttr = SourceItem->CreateNewAttribute(IsAdjust);
00258
00259 MouseInfo = *pMouseInfo;
00260 MiscInfo = *pMiscInfo;
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 GalleryLineDragInfo::~GalleryLineDragInfo()
00275 {
00276 if (TheBitmap != NULL)
00277 {
00278 delete TheBitmap;
00279 TheBitmap = NULL;
00280 }
00281
00282 if (pAttr != NULL)
00283 delete pAttr;
00284 }
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 void GalleryLineDragInfo::OnClick(INT32 Flags ,POINT Point)
00304 {
00305 if (SourceItem != NULL)
00306 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00307 }
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 UINT32 GalleryLineDragInfo::GetCursorID(DragTarget* pDragTarget)
00321 {
00322 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00323 {
00324 PageDropInfo PageDropInfo;
00325 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00326
00327 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00328 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00329
00330 if (IS_A(pAttr, AttrStartArrow) || IS_A(pAttr, AttrEndArrow))
00331 {
00332 if (pObjectHit && pObjectHit->IS_KIND_OF(NodePath))
00333 {
00334 Path* pPath = &((NodePath*)pObjectHit)->InkPath;
00335 BOOL IsStart;
00336 if (DropStartOrEndArrow(pPath, PageDropInfo.DropPos, &IsStart))
00337 {
00338 TargetHit = IsStart ? STARTCOL_TARGET : ENDCOL_TARGET;
00339 }
00340 }
00341 }
00342
00343 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00344 BOOL IsInside = ClickMods.Constrain;
00345
00346 if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00347 {
00348 TargetHit = MANY_TARGET;
00349 }
00350
00351 switch (TargetHit)
00352 {
00353 case FILL_TARGET:
00354 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00355 case LINE_TARGET:
00356 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00357 case STARTCOL_TARGET:
00358 return IsInside ? _R(IDC_DROPINSIDEONFILLSTART) : _R(IDC_CANDROPONFILLSTART);
00359 case ENDCOL_TARGET:
00360 return IsInside ? _R(IDC_DROPINSIDEONFILLEND) : _R(IDC_CANDROPONFILLEND);
00361 case MANY_TARGET:
00362 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00363
00364 case NO_TARGET:
00365 return _R(IDC_CANDROPONPAGE);
00366 default:
00367 break;
00368 };
00369
00370 return _R(IDC_CANDROPONPAGE);
00371 }
00372
00373 return _R(IDC_CANTDROP);
00374 }
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387 BOOL GalleryLineDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
00388 {
00389 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00390
00391 if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00392 return FALSE;
00393
00394 String_256 DragString(_R(IDS_SGLDRAG_DRAG_LINE_ATTR));
00395 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
00396
00397 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00398 {
00399 PageDropInfo PageDropInfo;
00400 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00401
00402 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00403 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00404
00405 String_256 ObjectDesc = _R(IDS_SGLDRAG_THIS_OBJECT);
00406
00407 if (pObjectHit)
00408 {
00409 ObjectDesc = pObjectHit->Describe(FALSE);
00410 }
00411
00412 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00413 BOOL IsInside = ClickMods.Constrain;
00414
00415 if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00416 {
00417 TargetHit = MANY_TARGET;
00418 }
00419
00420 switch (TargetHit)
00421 {
00422 case FILL_TARGET:
00423 case LINE_TARGET:
00424 case STARTCOL_TARGET:
00425 case ENDCOL_TARGET:
00426 DragString += String_64(_R(IDS_SGLDRAG_DROP_TO_APPLY));
00427 DragString += ObjectDesc;
00428 if (IsInside)
00429 DragString += String_64(_R(IDS_SGLDRAG_SPACE_ALONE));
00430 break;
00431
00432 case MANY_TARGET:
00433 DragString += String_64(_R(IDS_SGLDRAG_DROP_TO_APPLY));
00434 DragString += ObjectDesc;
00435 DragString += String_64(_R(IDS_SGLDRAG_CONTROL_DROP_INSIDE));
00436 break;
00437
00438 case NO_TARGET:
00439 DragString += String_64(_R(IDS_SGLDRAG_DROP_CURRENT_ATTRIBUTE));
00440 break;
00441 default:
00442 break;
00443 };
00444
00445 *TheText = DragString;
00446 return TRUE;
00447 }
00448
00449 return FALSE;
00450 }
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 BOOL GalleryLineDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
00468 {
00469 PageDropInfo PageDropInfo;
00470 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00471 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00472
00473 NodeAttribute* Attrib = SourceItem->CreateNewAttribute(IsAnAdjustDrag());
00474
00475 if (Attrib == NULL)
00476 return FALSE;
00477
00478 if (pObjectHit && (IS_A(Attrib, AttrStartArrow) || IS_A(Attrib, AttrEndArrow)))
00479 {
00480 if (!pObjectHit->IS_KIND_OF(NodePath))
00481 {
00482 delete Attrib;
00483 return FALSE;
00484 }
00485
00486 Path* pPath = &((NodePath*)pObjectHit)->InkPath;
00487 BOOL IsStart;
00488
00489 if (!DropStartOrEndArrow(pPath, PageDropInfo.DropPos, &IsStart))
00490 {
00491 delete Attrib;
00492 return FALSE;
00493 }
00494
00495 Attrib = MakeStartOrEndArrow(Attrib, IsStart);
00496 }
00497
00498 if (pObjectHit)
00499 {
00500
00501 AttributeManager::ApplyAttribToNode(pObjectHit, Attrib);
00502 }
00503 else
00504 {
00505
00506 AttributeManager::AttributeSelected(Attrib);
00507 }
00508
00509 return TRUE;
00510 }
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527 INT32 GalleryLineDragInfo::GetDragTransparency()
00528 {
00529
00530
00531
00532 return 50;
00533 }
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 KernelBitmap* GalleryLineDragInfo::GetSolidDragMask()
00548 {
00549
00550
00551 if (!DragMask && !TheBitmap)
00552 {
00553 DocView *View = DocView::GetCurrent();
00554 if (View == NULL)
00555 {
00556 return NULL;
00557 }
00558
00559 Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
00560 if (pSpread == NULL)
00561 {
00562 return NULL;
00563 }
00564
00565
00566 DocRect ClipRegion(0,0, 750*100, 750*50);
00567
00568
00569 Matrix ConvertMatrix;
00570 FIXED16 ViewScale = 1;
00571
00572 wxScreenDC DisplayDC;
00573 double dpi = (double) OSRenderRegion::GetFixedDCPPI(DisplayDC).GetWidth();
00574
00575 GRenderBitmap* pMaskRegion = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale,
00576 32, dpi);
00577
00578 pMaskRegion->SetDoCompression(TRUE);
00579 pMaskRegion->AttachDevice(View, &DisplayDC, pSpread);
00580
00581
00582 pMaskRegion->StartRender();
00583 SourceItem->Render(pMaskRegion, ClipRegion, c_eLineAttrDragTextPos);
00584 pMaskRegion->StopRender();
00585
00586 OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
00587 TheBitmap = new KernelBitmap(pOilMaskBmp, TRUE);
00588
00589 delete pMaskRegion;
00590 }
00591
00592 return BitmapDragInformation::GetSolidDragMask();
00593 }
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609 BOOL GalleryLineDragInfo::DropStartOrEndArrow(Path* pPathHit, DocCoord DropPos,
00610 BOOL* IsStart)
00611 {
00612 double NearestDist = -1;
00613 BOOL GotNearest = FALSE;
00614 BOOL NearestIsStart = FALSE;
00615
00616 DocCoord* Coords = pPathHit->GetCoordArray();
00617 PathVerb* Verbs = pPathHit->GetVerbArray();
00618 INT32 NumCoords = pPathHit->GetNumCoords();
00619
00620 DocCoord ArrowCentre;
00621 DocCoord ArrowDirection;
00622
00623 INT32 PathIndex = 0;
00624
00625
00626 BOOL GotPos = ArrowRec::GetFirstArrowPos(TRUE,
00627 Coords, Verbs, NumCoords,
00628 &PathIndex, &ArrowCentre, &ArrowDirection);
00629 while (GotPos)
00630 {
00631 double Dist = ArrowCentre.Distance(DropPos);
00632
00633 if (NearestDist == -1 || Dist < NearestDist)
00634 {
00635 NearestDist = Dist;
00636 GotNearest = TRUE;
00637 NearestIsStart = TRUE;
00638 }
00639
00640
00641 GotPos = ArrowRec::GetNextArrowPos(TRUE,
00642 Coords, Verbs, NumCoords,
00643 &PathIndex, &ArrowCentre, &ArrowDirection);
00644 }
00645
00646
00647 PathIndex = 0;
00648
00649
00650 GotPos = ArrowRec::GetFirstArrowPos(FALSE,
00651 Coords, Verbs, NumCoords,
00652 &PathIndex, &ArrowCentre, &ArrowDirection);
00653 while (GotPos)
00654 {
00655 double Dist = ArrowCentre.Distance(DropPos);
00656
00657 if (NearestDist == -1 || Dist < NearestDist)
00658 {
00659 NearestDist = Dist;
00660 GotNearest = TRUE;
00661 NearestIsStart = FALSE;
00662 }
00663
00664
00665 GotPos = ArrowRec::GetNextArrowPos(FALSE,
00666 Coords, Verbs, NumCoords,
00667 &PathIndex, &ArrowCentre, &ArrowDirection);
00668 }
00669
00670 if (GotNearest)
00671 *IsStart = NearestIsStart;
00672
00673 return GotNearest;
00674 }
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688 NodeAttribute* GalleryLineDragInfo::MakeStartOrEndArrow(NodeAttribute* pArrowAttr, BOOL Start)
00689 {
00690 ArrowRec Arrow;
00691 NodeAttribute* NewAttr;
00692
00693 if (IS_A(pArrowAttr, AttrStartArrow))
00694 {
00695 Arrow = ((AttrStartArrow*)pArrowAttr)->Value.StartArrow;
00696 }
00697 else
00698 {
00699 Arrow = ((AttrEndArrow*)pArrowAttr)->Value.EndArrow;
00700 }
00701
00702 if (Start)
00703 {
00704 NewAttr = new AttrStartArrow();
00705 ((AttrStartArrow*)NewAttr)->Value.StartArrow = Arrow;
00706 }
00707 else
00708 {
00709 NewAttr = new AttrEndArrow();
00710 ((AttrEndArrow*)NewAttr)->Value.EndArrow = Arrow;
00711 }
00712
00713 delete pArrowAttr;
00714 return NewAttr;
00715 }