3415 |msgType dropColl dropCollSize anyFile anyDir anyText anyOther |
3415 |msgType dropColl dropCollSize anyFile anyDir anyText anyOther |
3416 dropType dropTypeCode strings sz idx val| |
3416 dropType dropTypeCode strings sz idx val| |
3417 |
3417 |
3418 (msgType := self atomIDOf:#DndProtocol) notNil ifTrue:[ |
3418 (msgType := self atomIDOf:#DndProtocol) notNil ifTrue:[ |
3419 |
3419 |
3420 "/ DND can drop files, file, dir, links, dirLink and text |
3420 "/ DND can drop files, file, dir, links, dirLink and text |
3421 "/ check for this. |
3421 "/ check for this. |
3422 |
3422 |
3423 dropObjects isCollection ifFalse:[ |
3423 dropObjects isCollection ifFalse:[ |
3424 dropColl := Array with:dropObjects |
3424 dropColl := Array with:dropObjects |
3425 ] ifTrue:[ |
3425 ] ifTrue:[ |
3426 dropColl := dropObjects |
3426 dropColl := dropObjects |
3427 ]. |
3427 ]. |
3428 anyFile := anyDir := anyText := anyOther := false. |
3428 anyFile := anyDir := anyText := anyOther := false. |
3429 dropColl do:[:aDropObject | |
3429 dropColl do:[:aDropObject | |
3430 aDropObject isFileObject ifTrue:[ |
3430 aDropObject isFileObject ifTrue:[ |
3431 aDropObject theObject isDirectory ifTrue:[ |
3431 aDropObject theObject isDirectory ifTrue:[ |
3432 anyDir := true |
3432 anyDir := true |
3433 ] ifFalse:[ |
3433 ] ifFalse:[ |
3434 anyFile := true |
3434 anyFile := true |
3435 ] |
3435 ] |
3436 ] ifFalse:[ |
3436 ] ifFalse:[ |
3437 aDropObject isTextObject ifTrue:[ |
3437 aDropObject isTextObject ifTrue:[ |
3438 anyText := true |
3438 anyText := true |
3439 ] ifFalse:[ |
3439 ] ifFalse:[ |
3440 anyOther := true |
3440 anyOther := true |
3441 ] |
3441 ] |
3442 ] |
3442 ] |
3443 ]. |
3443 ]. |
3444 |
3444 |
3445 anyOther ifTrue:[ |
3445 anyOther ifTrue:[ |
3446 "/ DND does not support this ... |
3446 "/ DND does not support this ... |
3447 'XWorkstation [info]: DND can only drop files or text' infoPrintCR. |
3447 Logger info:'DND can only drop files or text'. |
3448 ^ false |
3448 ^ false |
3449 ]. |
3449 ]. |
3450 anyText ifTrue:[ |
3450 anyText ifTrue:[ |
3451 (anyFile or:[anyDir]) ifTrue:[ |
3451 (anyFile or:[anyDir]) ifTrue:[ |
3452 "/ DND does not support mixed types |
3452 "/ DND does not support mixed types |
3453 'XWorkstation [info]: DND cannot drop both files and text' infoPrintCR. |
3453 Logger info:'DND cannot drop both files and text'. |
3454 ^ false |
3454 ^ false |
3455 ] |
3455 ] |
3456 ]. |
3456 ]. |
3457 |
3457 |
3458 dropCollSize := dropColl size. |
3458 dropCollSize := dropColl size. |
3459 anyFile ifTrue:[ |
3459 anyFile ifTrue:[ |
3460 dropType := #DndFiles. |
3460 dropType := #DndFiles. |
3461 dropCollSize == 1 ifTrue:[ |
3461 dropCollSize == 1 ifTrue:[ |
3462 dropType := #DndFile |
3462 dropType := #DndFile |
3463 ] |
3463 ] |
3464 ] ifFalse:[ |
3464 ] ifFalse:[ |
3465 anyDir ifTrue:[ |
3465 anyDir ifTrue:[ |
3466 dropType := #DndFiles. |
3466 dropType := #DndFiles. |
3467 dropCollSize == 1 ifTrue:[ |
3467 dropCollSize == 1 ifTrue:[ |
3468 dropType := #DndDir |
3468 dropType := #DndDir |
3469 ] |
3469 ] |
3470 ] ifFalse:[ |
3470 ] ifFalse:[ |
3471 anyText ifTrue:[ |
3471 anyText ifTrue:[ |
3472 dropCollSize == 1 ifTrue:[ |
3472 dropCollSize == 1 ifTrue:[ |
3473 dropType := #DndText |
3473 dropType := #DndText |
3474 ] ifFalse:[ |
3474 ] ifFalse:[ |
3475 "/ can only drop a single text object |
3475 "/ can only drop a single text object |
3476 'XWorkstation [info]: DND can only drop a single text' infoPrintCR. |
3476 Logger info:'DND can only drop a single text'. |
3477 ^ false |
3477 ^ false |
3478 ] |
3478 ] |
3479 ] ifFalse:[ |
3479 ] ifFalse:[ |
3480 "/ mhmh ... |
3480 "/ mhmh ... |
3481 'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
3481 Logger info:'DND cannot drop this'. |
3482 ^ false |
3482 ^ false |
3483 ] |
3483 ] |
3484 ] |
3484 ] |
3485 ]. |
3485 ]. |
3486 |
3486 |
3487 dropTypeCode := self dndDropTypes indexOf:dropType. |
3487 dropTypeCode := self dndDropTypes indexOf:dropType. |
3488 dropTypeCode == 0 ifTrue:[ |
3488 dropTypeCode == 0 ifTrue:[ |
3489 'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
3489 Logger info:'DND cannot drop this'. |
3490 ^ false |
3490 ^ false |
3491 ]. |
3491 ]. |
3492 dropTypeCode := dropTypeCode - 1. |
3492 dropTypeCode := dropTypeCode - 1. |
3493 |
3493 |
3494 |
3494 |
3495 "/ place the selection inTo the DndSelection property |
3495 "/ place the selection inTo the DndSelection property |
3496 "/ of the rootView ... |
3496 "/ of the rootView ... |
3497 "/ ... need a single string, with 0-terminated parts. |
3497 "/ ... need a single string, with 0-terminated parts. |
3498 |
3498 |
3499 strings := OrderedCollection new. |
3499 strings := OrderedCollection new. |
3500 sz := 0. |
3500 sz := 0. |
3501 dropColl do:[:anObject | |
3501 dropColl do:[:anObject | |
3502 |s o| |
3502 |s o| |
3503 |
3503 |
3504 o := anObject theObject. |
3504 o := anObject theObject. |
3505 anObject isFileObject ifTrue:[ |
3505 anObject isFileObject ifTrue:[ |
3506 o := o pathName |
3506 o := o pathName |
3507 ]. |
3507 ]. |
3508 s := o asString. |
3508 s := o asString. |
3509 strings add:s. |
3509 strings add:s. |
3510 sz := sz + (s size) + 1. |
3510 sz := sz + (s size) + 1. |
3511 ]. |
3511 ]. |
3512 val := String new:sz. |
3512 val := String new:sz. |
3513 idx := 1. |
3513 idx := 1. |
3514 strings do:[:aString | |
3514 strings do:[:aString | |
3515 |sz| |
3515 |sz| |
3516 |
3516 |
3517 sz := aString size. |
3517 sz := aString size. |
3518 val replaceFrom:idx to:(idx + sz - 1) with:aString startingAt:1. |
3518 val replaceFrom:idx to:(idx + sz - 1) with:aString startingAt:1. |
3519 idx := idx + sz. |
3519 idx := idx + sz. |
3520 val at:idx put:(Character value:0). |
3520 val at:idx put:(Character value:0). |
3521 idx := idx + 1 |
3521 idx := idx + 1 |
3522 ]. |
3522 ]. |
3523 |
3523 |
3524 self |
3524 self |
3525 setProperty:(self atomIDOf:#DndSelection) |
3525 setProperty:(self atomIDOf:#DndSelection) |
3526 type:(self atomIDOf:#STRING) |
3526 type:(self atomIDOf:#STRING) |
3527 value:val |
3527 value:val |
3528 for:rootId. |
3528 for:rootId. |
3529 |
3529 |
3530 ^ self |
3530 ^ self |
3531 sendClientEvent:msgType |
3531 sendClientEvent:msgType |
3532 format:32 |
3532 format:32 |
3533 to:destinationId |
3533 to:destinationId |
3534 propagate:true |
3534 propagate:true |
3535 eventMask:nil |
3535 eventMask:nil |
3536 window:destinationId |
3536 window:destinationId |
3537 data1:dropTypeCode |
3537 data1:dropTypeCode |
3538 data2:0 |
3538 data2:0 |
3539 data3:destinationId |
3539 data3:destinationId |
3540 data4:nil |
3540 data4:nil |
3541 data5:nil. |
3541 data5:nil. |
3542 ]. |
3542 ]. |
3543 |
3543 |
3544 ^ false |
3544 ^ false |
3545 |
3545 |
3546 "Created: 6.4.1997 / 13:39:37 / cg" |
3546 "Created: 6.4.1997 / 13:39:37 / cg" |
5261 "/ redefined dropMessage methods in applications. |
5261 "/ redefined dropMessage methods in applications. |
5262 "/ Conversion is done for some well known types |
5262 "/ Conversion is done for some well known types |
5263 "/ in the default dropMessage handling of SimpleView. |
5263 "/ in the default dropMessage handling of SimpleView. |
5264 |
5264 |
5265 dropType == #DndFiles ifTrue:[ |
5265 dropType == #DndFiles ifTrue:[ |
5266 "/ actually, a list of fileNames |
5266 "/ actually, a list of fileNames |
5267 propertyType ~~ stringAtom ifTrue:[ |
5267 propertyType ~~ stringAtom ifTrue:[ |
5268 'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
5268 Logger info:'expected a string propertyValue in drop'. |
5269 ^ self |
5269 ^ self |
5270 ]. |
5270 ]. |
5271 |
5271 |
5272 names := OrderedCollection new. |
5272 names := OrderedCollection new. |
5273 i1 := 1. |
5273 i1 := 1. |
5274 [i1 ~~ 0] whileTrue:[ |
5274 [i1 ~~ 0] whileTrue:[ |
5275 i2 := dropValue indexOf:(Character value:0) startingAt:i1. |
5275 i2 := dropValue indexOf:(Character value:0) startingAt:i1. |
5276 i2 ~~ 0 ifTrue:[ |
5276 i2 ~~ 0 ifTrue:[ |
5277 names add:(dropValue copyFrom:i1 to:(i2-1)). |
5277 names add:(dropValue copyFrom:i1 to:(i2-1)). |
5278 i1 := i2 + 1. |
5278 i1 := i2 + 1. |
5279 ] ifFalse:[ |
5279 ] ifFalse:[ |
5280 i1 := i2 |
5280 i1 := i2 |
5281 ]. |
5281 ]. |
5282 ]. |
5282 ]. |
5283 dropValue := names. |
5283 dropValue := names. |
5284 dropValue := dropValue collect:[:nm | nm asFilename]. |
5284 dropValue := dropValue collect:[:nm | nm asFilename]. |
5285 dropType := #files. |
5285 dropType := #files. |
5286 ] ifFalse:[ (dropType == #DndFile) ifTrue:[ |
5286 ] ifFalse:[ (dropType == #DndFile) ifTrue:[ |
5287 propertyType ~~ stringAtom ifTrue:[ |
5287 propertyType ~~ stringAtom ifTrue:[ |
5288 'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
5288 Logger info:'expected a string propertyValue in drop'. |
5289 ^ self |
5289 ^ self |
5290 ]. |
5290 ]. |
5291 dropValue := dropValue asFilename. |
5291 dropValue := dropValue asFilename. |
5292 dropType := #file. |
5292 dropType := #file. |
5293 ] ifFalse:[ (dropType == #DndDir) ifTrue:[ |
5293 ] ifFalse:[ (dropType == #DndDir) ifTrue:[ |
5294 propertyType ~~ stringAtom ifTrue:[ |
5294 propertyType ~~ stringAtom ifTrue:[ |
5295 'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
5295 Logger info:'expected a string propertyValue in drop'. |
5296 ^ self |
5296 ^ self |
5297 ]. |
5297 ]. |
5298 dropValue := dropValue asFilename. |
5298 dropValue := dropValue asFilename. |
5299 dropType := #directory. |
5299 dropType := #directory. |
5300 ] ifFalse:[ (dropType == #DndText) ifTrue:[ |
5300 ] ifFalse:[ (dropType == #DndText) ifTrue:[ |
5301 propertyType ~~ stringAtom ifTrue:[ |
5301 propertyType ~~ stringAtom ifTrue:[ |
5302 'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
5302 Logger info:'expected a string propertyValue in drop'. |
5303 ^ self |
5303 ^ self |
5304 ]. |
5304 ]. |
5305 dropType := #text. |
5305 dropType := #text. |
5306 ] ifFalse:[ (dropType == #DndExe) ifTrue:[ |
5306 ] ifFalse:[ (dropType == #DndExe) ifTrue:[ |
5307 propertyType ~~ stringAtom ifTrue:[ |
5307 propertyType ~~ stringAtom ifTrue:[ |
5308 'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
5308 Logger info:'expected a string propertyValue in drop'. |
5309 ^ self |
5309 ^ self |
5310 ]. |
5310 ]. |
5311 dropType := #executable. |
5311 dropType := #executable. |
5312 ] ifFalse:[ (dropType == #DndLink) ifTrue:[ |
5312 ] ifFalse:[ (dropType == #DndLink) ifTrue:[ |
5313 propertyType ~~ stringAtom ifTrue:[ |
5313 propertyType ~~ stringAtom ifTrue:[ |
5314 'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
5314 Logger info:'expected a string propertyValue in drop'. |
5315 ^ self |
5315 ^ self |
5316 ]. |
5316 ]. |
5317 dropType := #link. |
5317 dropType := #link. |
5318 ] ifFalse:[ (dropType == #DndRawData) ifTrue:[ |
5318 ] ifFalse:[ (dropType == #DndRawData) ifTrue:[ |
5319 dropType := #rawData. |
5319 dropType := #rawData. |
5320 ] ifFalse:[ |
5320 ] ifFalse:[ |
5321 'XWorkstation [info]: unsupported dropType: ' infoPrint. dropType infoPrintCR. |
5321 Logger info:'unsupported dropType: %1 data: %2 ' with:dropType with:dropValue. |
5322 'XWorkstation [info]: data: ' infoPrint. dropValue infoPrintCR. |
5322 dropType := #unknown. |
5323 dropType := #unknown. |
|
5324 ]]]]]]]. |
5323 ]]]]]]]. |
5325 |
5324 |
5326 sensor := targetView sensor. |
5325 sensor := targetView sensor. |
5327 "not posted, if there is no sensor ..." |
5326 "not posted, if there is no sensor ..." |
5328 sensor notNil ifTrue:[ |
5327 sensor notNil ifTrue:[ |
5329 sensor dropMessage:dropType data:dropValue view:targetView position:nil handle:nil |
5328 sensor dropMessage:dropType data:dropValue view:targetView position:nil handle:nil |
5330 ]. |
5329 ]. |
5331 |
5330 |
5332 "Created: 4.4.1997 / 17:59:37 / cg" |
5331 "Created: 4.4.1997 / 17:59:37 / cg" |
5333 ! |
5332 ! |
5334 |
5333 |
11591 |buffer bufferAsString| |
11590 |buffer bufferAsString| |
11592 |
11591 |
11593 buffer := self perform:bufferGetSelector. |
11592 buffer := self perform:bufferGetSelector. |
11594 |
11593 |
11595 (aTargetAtomID == (self atomIDOf:#'ST_OBJECT')) ifTrue:[ |
11594 (aTargetAtomID == (self atomIDOf:#'ST_OBJECT')) ifTrue:[ |
11596 "/ 'st-object' printCR. |
11595 "/ 'st-object' printCR. |
11597 "send the selection in binaryStore format" |
11596 "send the selection in binaryStore format" |
11598 "require libboss to be loaded" |
11597 "require libboss to be loaded" |
11599 (Smalltalk isClassLibraryLoaded:'libstx_libboss') ifFalse:[ |
11598 (Smalltalk isClassLibraryLoaded:'libstx_libboss') ifFalse:[ |
11600 'XWorkstation: cannot use binary store for copy buffer (libboss missing)' errorPrintCR. |
11599 Logger error:'cannot use binary store for copy buffer (libboss missing)'. |
11601 ^ nil -> nil. |
11600 ^ nil -> nil. |
11602 ]. |
11601 ]. |
11603 |
11602 |
11604 [ |
11603 [ |
11605 ^ aTargetAtomID -> (buffer binaryStoreBytes). |
11604 ^ aTargetAtomID -> (buffer binaryStoreBytes). |
11606 ] on:Error do:[:ex| |
11605 ] on:Error do:[:ex| |
11607 'XWorkstation: error on binary store of copy buffer: ' infoPrint. |
11606 Logger info:'error on binary store of copy buffer: %1' with: ex description. |
11608 ex description infoPrintCR. |
11607 ^ nil -> nil. |
11609 ^ nil -> nil. |
11608 ]. |
11610 ]. |
|
11611 ]. |
11609 ]. |
11612 |
11610 |
11613 bufferAsString := self class bufferAsString:buffer. |
11611 bufferAsString := self class bufferAsString:buffer. |
11614 |
11612 |
11615 (aTargetAtomID == (self atomIDOf:#STRING) |
11613 (aTargetAtomID == (self atomIDOf:#STRING) |
11616 or:[aTargetAtomID == (self atomIDOf:#'text/plain')] |
11614 or:[aTargetAtomID == (self atomIDOf:#'text/plain')] |
11617 ) ifTrue:[ |
11615 ) ifTrue:[ |
11618 "/ 'string' printCR. |
11616 "/ 'string' printCR. |
11619 "the other view wants the selection as string" |
11617 "the other view wants the selection as string" |
11620 ^ aTargetAtomID -> (bufferAsString asSingleByteStringReplaceInvalidWith:$#). |
11618 ^ aTargetAtomID -> (bufferAsString asSingleByteStringReplaceInvalidWith:$#). |
11621 ]. |
11619 ]. |
11622 |
11620 |
11623 (aTargetAtomID == (self atomIDOf:#UTF8_STRING) |
11621 (aTargetAtomID == (self atomIDOf:#UTF8_STRING) |
11624 or:[aTargetAtomID == (self atomIDOf:#'text/plain;codeset=utf-8')] |
11622 or:[aTargetAtomID == (self atomIDOf:#'text/plain;codeset=utf-8')] |
11625 ) ifTrue:[ |
11623 ) ifTrue:[ |
11626 "/ 'utf string' printCR. |
11624 "/ 'utf string' printCR. |
11627 "the other view wants the selection as utf8 string" |
11625 "the other view wants the selection as utf8 string" |
11628 ^ aTargetAtomID -> (bufferAsString utf8Encoded). |
11626 ^ aTargetAtomID -> (bufferAsString utf8Encoded). |
11629 ]. |
11627 ]. |
11630 |
11628 |
11631 aTargetAtomID == (self atomIDOf:#LENGTH) ifTrue:[ |
11629 aTargetAtomID == (self atomIDOf:#LENGTH) ifTrue:[ |
11632 "the other one wants to know the size of our selection. |
11630 "the other one wants to know the size of our selection. |
11633 LENGTH is deprecated, since we do not know how the selection is |
11631 LENGTH is deprecated, since we do not know how the selection is |
11634 going to be converted. The client must not rely on the length returned" |
11632 going to be converted. The client must not rely on the length returned" |
11635 |
11633 |
11636 ^ (self atomIDOf:#INTEGER) -> (bufferAsString size). |
11634 ^ (self atomIDOf:#INTEGER) -> (bufferAsString size). |
11637 ]. |
11635 ]. |
11638 |
11636 |
11639 "we do not support the requestet target type" |
11637 "we do not support the requestet target type" |
11640 ^ nil -> nil. |
11638 ^ nil -> nil. |
11641 |
11639 |